Credit for this EECS 583 project shared between @zakird, @zrenner, and myself.
This is an 64bit LLVM 3.1 version of what is described in section 3 of this paper: http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=194F16EA6366CE9747425661F27C8496?doi=10.1.1.13.7372&rep=rep1&type=pdf