C++'ification of Quick compiler's casts

 o Eliminate old useless LIR casts.
 o Replace remaining C-style casts with new C++ versions.
 o Unified instruction encoding enum
 o Expand usage of the auto-generated ostream helpers for enum LOG messages.
 o Replaced all usages of intptr_t with uintptr_t.
 o Fixed bug in removeRedundantBranches, and moved to common code

Change-Id: I53211c0de1be913f958c8fde915296ac08345b7e
diff --git a/build/Android.common.mk b/build/Android.common.mk
index d86a785..4c1f005 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -346,7 +346,8 @@
 	src/mutex.h \
 	src/object.h \
 	src/thread.h \
-	src/verifier/method_verifier.h
+	src/verifier/method_verifier.h \
+	src/compiler/compiler_enums.h
 
 LIBARTTEST_COMMON_SRC_FILES := \
 	test/StackWalk/stack_walk_jni.cc \
diff --git a/src/compiler/codegen/arm/arm_lir.h b/src/compiler/codegen/arm/arm_lir.h
index 503fbda..a3c4ca1 100644
--- a/src/compiler/codegen/arm/arm_lir.h
+++ b/src/compiler/codegen/arm/arm_lir.h
@@ -134,11 +134,11 @@
   kArmRegEnd   = 48,
 };
 
-#define ENCODE_ARM_REG_LIST(N)      ((uint64_t) N)
+#define ENCODE_ARM_REG_LIST(N)      (static_cast<uint64_t>(N))
 #define ENCODE_ARM_REG_SP           (1ULL << kArmRegSP)
 #define ENCODE_ARM_REG_LR           (1ULL << kArmRegLR)
 #define ENCODE_ARM_REG_PC           (1ULL << kArmRegPC)
-#define ENCODE_ARM_REG_FPCS_LIST(N) ((uint64_t)N << kArmFPReg16)
+#define ENCODE_ARM_REG_FPCS_LIST(N) (static_cast<uint64_t>(N) << kArmFPReg16)
 
 enum ArmNativeRegisterPool {
   r0   = 0,
@@ -232,7 +232,7 @@
   kArmRor = 0x3
 };
 
-#define isPseudoOpcode(opcode) ((int)(opcode) < 0)
+#define isPseudoOpcode(opcode) (static_cast<int>(opcode) < 0)
 
 /*
  * The following enum defines the list of supported Thumb instructions by the
diff --git a/src/compiler/codegen/arm/assemble_arm.cc b/src/compiler/codegen/arm/assemble_arm.cc
index 6370f6c..d7fa05d 100644
--- a/src/compiler/codegen/arm/assemble_arm.cc
+++ b/src/compiler/codegen/arm/assemble_arm.cc
@@ -988,12 +988,12 @@
  * instruction.
  */
 AssemblerStatus oatAssembleInstructions(CompilationUnit* cUnit,
-                    intptr_t startAddr)
+                    uintptr_t startAddr)
 {
   LIR* lir;
   AssemblerStatus res = kSuccess;  // Assume success
 
-  for (lir = (LIR *) cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
+  for (lir = cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
 
     if (lir->opcode < 0) {
       /* 1 means padding is needed */
@@ -1031,9 +1031,9 @@
          * However, if the load displacement exceeds the limit,
          * we revert to a 2-instruction materialization sequence.
          */
-        LIR *lirTarget = (LIR *) lir->target;
-        intptr_t pc = (lir->offset + 4) & ~3;
-        intptr_t target = lirTarget->offset;
+        LIR *lirTarget = lir->target;
+        uintptr_t pc = (lir->offset + 4) & ~3;
+        uintptr_t target = lirTarget->offset;
         int delta = target - pc;
         if (delta & 0x3) {
           LOG(FATAL) << "PC-rel offset not multiple of 4: " << delta;
@@ -1059,7 +1059,7 @@
           // Add new Adr to generate the address
           LIR* newAdr = rawLIR(cUnit, lir->dalvikOffset, kThumb2Adr,
                      baseReg, 0, 0, 0, 0, lir->target);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newAdr);
+          oatInsertLIRBefore(lir, newAdr);
 
           // Convert to normal load
           if (lir->opcode == kThumb2LdrPcRel12) {
@@ -1080,9 +1080,9 @@
           }
         }
       } else if (lir->opcode == kThumb2Cbnz || lir->opcode == kThumb2Cbz) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         if (delta > 126 || delta < 0) {
           /*
@@ -1093,7 +1093,7 @@
             rawLIR(cUnit, lir->dalvikOffset, kThumbBCond, 0,
                    (lir->opcode == kThumb2Cbz) ? kArmCondEq : kArmCondNe,
                    0, 0, 0, lir->target);
-          oatInsertLIRAfter((LIR *)lir, (LIR *)newInst);
+          oatInsertLIRAfter(lir, newInst);
           /* Convert the cb[n]z to a cmp rx, #0 ] */
           lir->opcode = kThumbCmpRI8;
           /* operand[0] is src1 in both cb[n]z & CmpRI8 */
@@ -1128,11 +1128,11 @@
           res = kRetryAll;
         }
       } else if (lir->opcode == kThumbBCond || lir->opcode == kThumb2BCond) {
-        LIR *targetLIR = (LIR *) lir->target;
+        LIR *targetLIR = lir->target;
         int delta = 0;
         DCHECK(targetLIR);
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         delta = target - pc;
         if ((lir->opcode == kThumbBCond) && (delta > 254 || delta < -256)) {
           lir->opcode = kThumb2BCond;
@@ -1141,9 +1141,9 @@
         }
         lir->operands[0] = delta >> 1;
       } else if (lir->opcode == kThumb2BUncond) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         lir->operands[0] = delta >> 1;
         if (!(cUnit->disableOpt & (1 << kSafeOptimizations)) &&
@@ -1152,9 +1152,9 @@
           res = kRetryAll;
         }
       } else if (lir->opcode == kThumbBUncond) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         if (delta > 2046 || delta < -2048) {
           // Convert to Thumb2BCond w/ kArmCondAl
@@ -1173,8 +1173,8 @@
       } else if (lir->opcode == kThumbBlx1) {
         DCHECK(NEXT_LIR(lir)->opcode == kThumbBlx2);
         /* curPC is Thumb */
-        intptr_t curPC = (startAddr + lir->offset + 4) & ~3;
-        intptr_t target = lir->operands[1];
+        uintptr_t curPC = (startAddr + lir->offset + 4) & ~3;
+        uintptr_t target = lir->operands[1];
 
         /* Match bit[1] in target with base */
         if (curPC & 0x2) {
@@ -1188,8 +1188,8 @@
       } else if (lir->opcode == kThumbBl1) {
         DCHECK(NEXT_LIR(lir)->opcode == kThumbBl2);
         /* Both curPC and target are Thumb */
-        intptr_t curPC = startAddr + lir->offset + 4;
-        intptr_t target = lir->operands[1];
+        uintptr_t curPC = startAddr + lir->offset + 4;
+        uintptr_t target = lir->operands[1];
 
         int delta = target - curPC;
         DCHECK((delta >= -(1<<22)) && (delta <= ((1<<22)-2)));
@@ -1197,8 +1197,8 @@
         lir->operands[0] = (delta >> 12) & 0x7ff;
         NEXT_LIR(lir)->operands[0] = (delta>> 1) & 0x7ff;
       } else if (lir->opcode == kThumb2Adr) {
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[2];
-        LIR* target = (LIR*)lir->target;
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[2]);
+        LIR* target = lir->target;
         int targetDisp = tabRec ? tabRec->offset
                     : target->offset;
         int disp = targetDisp - ((lir->offset + 4) & ~3);
@@ -1208,14 +1208,14 @@
           // convert to ldimm16l, ldimm16h, add tgt, pc, operands[0]
           LIR *newMov16L =
               rawLIR(cUnit, lir->dalvikOffset, kThumb2MovImm16LST,
-                     lir->operands[0], 0, (intptr_t)lir, (intptr_t)tabRec,
-                     0, lir->target);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newMov16L);
+                     lir->operands[0], 0, reinterpret_cast<uintptr_t>(lir),
+                     reinterpret_cast<uintptr_t>(tabRec), 0, lir->target);
+          oatInsertLIRBefore(lir, newMov16L);
           LIR *newMov16H =
               rawLIR(cUnit, lir->dalvikOffset, kThumb2MovImm16HST,
-                     lir->operands[0], 0, (intptr_t)lir, (intptr_t)tabRec,
-                     0, lir->target);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newMov16H);
+                     lir->operands[0], 0, reinterpret_cast<uintptr_t>(lir),
+                     reinterpret_cast<uintptr_t>(tabRec), 0, lir->target);
+          oatInsertLIRBefore(lir, newMov16H);
           lir->opcode = kThumb2AddRRR;
           lir->operands[1] = rARM_PC;
           lir->operands[2] = lir->operands[0];
@@ -1224,18 +1224,18 @@
         }
       } else if (lir->opcode == kThumb2MovImm16LST) {
         // operands[1] should hold disp, [2] has add, [3] has tabRec
-        LIR *addPCInst = (LIR*)lir->operands[2];
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[3];
+        LIR *addPCInst = reinterpret_cast<LIR*>(lir->operands[2]);
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[3]);
         // If tabRec is null, this is a literal load. Use target
-        LIR* target = (LIR*)lir->target;
+        LIR* target = lir->target;
         int targetDisp = tabRec ? tabRec->offset : target->offset;
         lir->operands[1] = (targetDisp - (addPCInst->offset + 4)) & 0xffff;
       } else if (lir->opcode == kThumb2MovImm16HST) {
         // operands[1] should hold disp, [2] has add, [3] has tabRec
-        LIR *addPCInst = (LIR*)lir->operands[2];
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[3];
+        LIR *addPCInst = reinterpret_cast<LIR*>(lir->operands[2]);
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[3]);
         // If tabRec is null, this is a literal load. Use target
-        LIR* target = (LIR*)lir->target;
+        LIR* target = lir->target;
         int targetDisp = tabRec ? tabRec->offset : target->offset;
         lir->operands[1] =
             ((targetDisp - (addPCInst->offset + 4)) >> 16) & 0xffff;
@@ -1348,7 +1348,7 @@
           }
           break;
         default:
-          LOG(FATAL) << "Bad fmt:" << (int)encoder->fieldLoc[i].kind;
+          LOG(FATAL) << "Bad fmt:" << encoder->fieldLoc[i].kind;
       }
     }
     if (encoder->size == 4) {
@@ -1374,9 +1374,7 @@
   LIR* armLIR;
   int offset = 0;
 
-  for (armLIR = (LIR *) cUnit->firstLIRInsn;
-     armLIR;
-     armLIR = NEXT_LIR(armLIR)) {
+  for (armLIR = cUnit->firstLIRInsn; armLIR; armLIR = NEXT_LIR(armLIR)) {
     armLIR->offset = offset;
     if (armLIR->opcode >= 0) {
       if (!armLIR->flags.isNop) {
diff --git a/src/compiler/codegen/arm/call_arm.cc b/src/compiler/codegen/arm/call_arm.cc
index 92b067c..acf825a 100644
--- a/src/compiler/codegen/arm/call_arm.cc
+++ b/src/compiler/codegen/arm/call_arm.cc
@@ -128,7 +128,7 @@
   /* Don't generate the SSA annotation unless verbose mode is on */
   if (cUnit->printMe && mir->ssaRep) {
     char* ssaString = oatGetSSAString(cUnit, mir->ssaRep);
-    newLIR1(cUnit, kPseudoSSARep, (int) ssaString);
+    newLIR1(cUnit, kPseudoSSARep, reinterpret_cast<uintptr_t>(ssaString));
   }
 }
 
@@ -329,13 +329,13 @@
     dumpSparseSwitchTable(table);
   }
   // Add the table to the list - we'll process it later
-  SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable),
-                                              true, kAllocData);
+  SwitchTable *tabRec =
+      static_cast<SwitchTable*>(oatNew(cUnit, sizeof(SwitchTable), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   int size = table[1];
-  tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR);
-  oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec);
+  tabRec->targets = static_cast<LIR**>(oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR));
+  oatInsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
 
   // Get the switch value
   rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
@@ -350,7 +350,7 @@
     rKey = tmp;
   }
   // Materialize a pointer to the switch table
-  newLIR3(cUnit, kThumb2Adr, rBase, 0, (intptr_t)tabRec);
+  newLIR3(cUnit, kThumb2Adr, rBase, 0, reinterpret_cast<uintptr_t>(tabRec));
   // Set up rIdx
   int rIdx = oatAllocTemp(cUnit);
   loadConstant(cUnit, rIdx, size);
@@ -377,19 +377,19 @@
     dumpPackedSwitchTable(table);
   }
   // Add the table to the list - we'll process it later
-  SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable),
-                                              true, kAllocData);
+  SwitchTable *tabRec =
+      static_cast<SwitchTable*>(oatNew(cUnit, sizeof(SwitchTable), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   int size = table[1];
-  tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR);
-  oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec);
+  tabRec->targets = static_cast<LIR**>(oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR));
+  oatInsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
 
   // Get the switch value
   rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
   int tableBase = oatAllocTemp(cUnit);
   // Materialize a pointer to the switch table
-  newLIR3(cUnit, kThumb2Adr, tableBase, 0, (intptr_t)tabRec);
+  newLIR3(cUnit, kThumb2Adr, tableBase, 0, reinterpret_cast<uintptr_t>(tabRec));
   int lowKey = s4FromSwitchData(&table[2]);
   int keyReg;
   // Remove the bias, if necessary
@@ -413,7 +413,7 @@
 
   /* branchOver target here */
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
 }
 
 /*
@@ -430,15 +430,15 @@
 {
   const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
   // Add the table to the list - we'll process it later
-  FillArrayData *tabRec = (FillArrayData *)
-     oatNew(cUnit, sizeof(FillArrayData), true, kAllocData);
+  FillArrayData *tabRec =
+      static_cast<FillArrayData*>(oatNew(cUnit, sizeof(FillArrayData), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   uint16_t width = tabRec->table[1];
   uint32_t size = tabRec->table[2] | ((static_cast<uint32_t>(tabRec->table[3])) << 16);
   tabRec->size = (size * width) + 8;
 
-  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, (intptr_t)tabRec);
+  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, reinterpret_cast<uintptr_t>(tabRec));
 
   // Making a call - use explicit registers
   oatFlushAllRegs(cUnit);   /* Everything to home location */
@@ -446,7 +446,7 @@
   loadWordDisp(cUnit, rARM_SELF, ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode),
                rARM_LR);
   // Materialize a pointer to the fill data image
-  newLIR3(cUnit, kThumb2Adr, r1, 0, (intptr_t)tabRec);
+  newLIR3(cUnit, kThumb2Adr, r1, 0, reinterpret_cast<uintptr_t>(tabRec));
   oatClobberCalleeSave(cUnit);
   LIR* callInst = opReg(cUnit, kOpBlx, rARM_LR);
   markSafepointPC(cUnit, callInst);
@@ -552,7 +552,7 @@
   storeBaseIndexed(cUnit, regCardBase, regCardNo, regCardBase, 0,
                    kUnsignedByte);
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
   oatFreeTemp(cUnit, regCardBase);
   oatFreeTemp(cUnit, regCardNo);
 }
@@ -577,7 +577,7 @@
    * a leaf *and* our frame size < fudge factor.
    */
   bool skipOverflowCheck = ((cUnit->attrs & METHOD_IS_LEAF) &&
-                            ((size_t)cUnit->frameSize <
+                            (static_cast<size_t>(cUnit->frameSize) <
                             Thread::kStackOverflowReservedBytes));
   newLIR0(cUnit, kPseudoMethodEntry);
   if (!skipOverflowCheck) {
diff --git a/src/compiler/codegen/arm/fp_arm.cc b/src/compiler/codegen/arm/fp_arm.cc
index 8c22050..70783a4 100644
--- a/src/compiler/codegen/arm/fp_arm.cc
+++ b/src/compiler/codegen/arm/fp_arm.cc
@@ -54,7 +54,7 @@
   rlSrc1 = loadValue(cUnit, rlSrc1, kFPReg);
   rlSrc2 = loadValue(cUnit, rlSrc2, kFPReg);
   rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-  newLIR3(cUnit, (ArmOpcode)op, rlResult.lowReg, rlSrc1.lowReg, rlSrc2.lowReg);
+  newLIR3(cUnit, op, rlResult.lowReg, rlSrc1.lowReg, rlSrc2.lowReg);
   storeValue(cUnit, rlDest, rlResult);
   return false;
 }
@@ -98,8 +98,7 @@
   rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
   DCHECK(rlDest.wide);
   DCHECK(rlResult.wide);
-  newLIR3(cUnit, (ArmOpcode)op, s2d(rlResult.lowReg, rlResult.highReg),
-          s2d(rlSrc1.lowReg, rlSrc1.highReg),
+  newLIR3(cUnit, op, s2d(rlResult.lowReg, rlResult.highReg), s2d(rlSrc1.lowReg, rlSrc1.highReg),
           s2d(rlSrc2.lowReg, rlSrc2.highReg));
   storeValueWide(cUnit, rlDest, rlResult);
   return false;
@@ -148,12 +147,11 @@
   }
   if (rlDest.wide) {
     rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-    newLIR2(cUnit, (ArmOpcode)op, s2d(rlResult.lowReg, rlResult.highReg),
-            srcReg);
+    newLIR2(cUnit, op, s2d(rlResult.lowReg, rlResult.highReg), srcReg);
     storeValueWide(cUnit, rlDest, rlResult);
   } else {
     rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-    newLIR2(cUnit, (ArmOpcode)op, rlResult.lowReg, srcReg);
+    newLIR2(cUnit, op, rlResult.lowReg, srcReg);
     storeValue(cUnit, rlDest, rlResult);
   }
   return false;
@@ -207,7 +205,7 @@
       }
       break;
     default:
-      LOG(FATAL) << "Unexpected ccode: " << (int)ccode;
+      LOG(FATAL) << "Unexpected ccode: " << ccode;
   }
   opCondBranch(cUnit, ccode, target);
 }
diff --git a/src/compiler/codegen/arm/int_arm.cc b/src/compiler/codegen/arm/int_arm.cc
index d7bd523..159b329 100644
--- a/src/compiler/codegen/arm/int_arm.cc
+++ b/src/compiler/codegen/arm/int_arm.cc
@@ -111,8 +111,8 @@
   storeValue(cUnit, rlDest, rlTemp);
   oatFreeTemp(cUnit, tReg);
 
-  branch1->target = (LIR*)target1;
-  branch2->target = (LIR*)target2;
+  branch1->target = target1;
+  branch2->target = target2;
   branch3->target = branch1->target;
 }
 
@@ -155,7 +155,7 @@
       ccode = kCondCs;
       break;
     default:
-      LOG(FATAL) << "Unexpected ccode: " << (int)ccode;
+      LOG(FATAL) << "Unexpected ccode: " << ccode;
   }
   opRegReg(cUnit, kOpCmp, rlSrc1.lowReg, rlSrc2.lowReg);
   opCondBranch(cUnit, ccode, taken);
@@ -215,7 +215,7 @@
 LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc)
 {
   LIR* res = opRegCopyNoInsert(cUnit, rDest, rSrc);
-  oatAppendLIR(cUnit, (LIR*)res);
+  oatAppendLIR(cUnit, res);
   return res;
 }
 
@@ -249,13 +249,6 @@
 }
 
 // Table of magic divisors
-enum DividePattern {
-  DivideNone,
-  Divide3,
-  Divide5,
-  Divide7,
-};
-
 struct MagicTable {
   uint32_t magic;
   uint32_t shift;
@@ -285,7 +278,7 @@
 bool smallLiteralDivide(CompilationUnit* cUnit, Instruction::Code dalvikOpcode,
                         RegLocation rlSrc, RegLocation rlDest, int lit)
 {
-  if ((lit < 0) || (lit >= (int)(sizeof(magicTable)/sizeof(magicTable[0])))) {
+  if ((lit < 0) || (lit >= static_cast<int>(sizeof(magicTable)/sizeof(magicTable[0])))) {
     return false;
   }
   DividePattern pattern = magicTable[lit].pattern;
@@ -321,7 +314,7 @@
                encodeShift(kArmAsr, magicTable[lit].shift));
       break;
     default:
-      LOG(FATAL) << "Unexpected pattern: " << (int)pattern;
+      LOG(FATAL) << "Unexpected pattern: " << pattern;
   }
   storeValue(cUnit, rlDest, rlResult);
   return true;
diff --git a/src/compiler/codegen/arm/target_arm.cc b/src/compiler/codegen/arm/target_arm.cc
index 5838ca7..6640707 100644
--- a/src/compiler/codegen/arm/target_arm.cc
+++ b/src/compiler/codegen/arm/target_arm.cc
@@ -221,10 +221,10 @@
   }
 }
 
-ArmConditionCode oatArmConditionEncoding(ConditionCode code)
+ArmConditionCode oatArmConditionEncoding(ConditionCode ccode)
 {
   ArmConditionCode res;
-  switch (code) {
+  switch (ccode) {
     case kCondEq: res = kArmCondEq; break;
     case kCondNe: res = kArmCondNe; break;
     case kCondCs: res = kArmCondCs; break;
@@ -242,8 +242,8 @@
     case kCondAl: res = kArmCondAl; break;
     case kCondNv: res = kArmCondNv; break;
     default:
-      LOG(FATAL) << "Bad condition code" << (int)code;
-      res = (ArmConditionCode)0;  // Quiet gcc
+      LOG(FATAL) << "Bad condition code " << ccode;
+      res = static_cast<ArmConditionCode>(0);  // Quiet gcc
   }
   return res;
 }
@@ -352,7 +352,7 @@
         strcpy(tbuf, "!");
       } else {
          DCHECK_LT(fmt, fmtEnd);
-         DCHECK_LT((unsigned)(nc-'0'), 4U);
+         DCHECK_LT(static_cast<unsigned>(nc-'0'), 4U);
          operand = lir->operands[nc-'0'];
          switch (*fmt++) {
            case 'H':
@@ -432,18 +432,18 @@
              break;
            case 't':
              sprintf(tbuf,"0x%08x (L%p)",
-                 (int) baseAddr + lir->offset + 4 +
+                 reinterpret_cast<uintptr_t>(baseAddr) + lir->offset + 4 +
                  (operand << 1),
                  lir->target);
              break;
            case 'u': {
              int offset_1 = lir->operands[0];
              int offset_2 = NEXT_LIR(lir)->operands[0];
-             intptr_t target =
-                 ((((intptr_t) baseAddr + lir->offset + 4) &
+             uintptr_t target =
+                 (((reinterpret_cast<uintptr_t>(baseAddr) + lir->offset + 4) &
                  ~3) + (offset_1 << 21 >> 9) + (offset_2 << 1)) &
                  0xfffffffc;
-             sprintf(tbuf, "%p", (void *) target);
+             sprintf(tbuf, "%p", reinterpret_cast<void *>(target));
              break;
           }
 
@@ -473,11 +473,10 @@
   return buf;
 }
 
-void oatDumpResourceMask(LIR* lir, uint64_t mask, const char* prefix)
+void oatDumpResourceMask(LIR* armLIR, uint64_t mask, const char* prefix)
 {
   char buf[256];
   buf[0] = 0;
-  LIR* armLIR = (LIR*) lir;
 
   if (mask == ENCODE_ALL) {
     strcpy(buf, "all");
@@ -520,46 +519,9 @@
   }
 }
 
-/*
- * Nop any unconditional branches that go to the next instruction.
- * Note: new redundant branches may be inserted later, and we'll
- * use a check in final instruction assembly to nop those out.
- */
-void removeRedundantBranches(CompilationUnit* cUnit)
+bool branchUnconditional(LIR* lir)
 {
-  LIR* thisLIR;
-
-  for (thisLIR = (LIR*) cUnit->firstLIRInsn;
-     thisLIR != (LIR*) cUnit->lastLIRInsn;
-     thisLIR = NEXT_LIR(thisLIR)) {
-
-    /* Branch to the next instruction */
-    if ((thisLIR->opcode == kThumbBUncond) ||
-      (thisLIR->opcode == kThumb2BUncond)) {
-      LIR* nextLIR = thisLIR;
-
-      while (true) {
-        nextLIR = NEXT_LIR(nextLIR);
-
-        /*
-         * Is the branch target the next instruction?
-         */
-        if (nextLIR == (LIR*) thisLIR->target) {
-          thisLIR->flags.isNop = true;
-          break;
-        }
-
-        /*
-         * Found real useful stuff between the branch and the target.
-         * Need to explicitly check the lastLIRInsn here because it
-         * might be the last real instruction.
-         */
-        if (!isPseudoOpcode(nextLIR->opcode) ||
-          (nextLIR = (LIR*) cUnit->lastLIRInsn))
-          break;
-      }
-    }
-  }
+  return ((lir->opcode == kThumbBUncond) || (lir->opcode == kThumb2BUncond));
 }
 
 /* Common initialization routine for an architecture family */
@@ -571,7 +533,7 @@
     if (EncodingMap[i].opcode != i) {
       LOG(FATAL) << "Encoding order for " << EncodingMap[i].name
                  << " is wrong: expecting " << i << ", seeing "
-                 << (int)EncodingMap[i].opcode;
+                 << static_cast<int>(EncodingMap[i].opcode);
     }
   }
 
@@ -627,17 +589,15 @@
   int numTemps = sizeof(coreTemps)/sizeof(*coreTemps);
   int numFPRegs = sizeof(fpRegs)/sizeof(*fpRegs);
   int numFPTemps = sizeof(fpTemps)/sizeof(*fpTemps);
-  RegisterPool *pool = (RegisterPool *)oatNew(cUnit, sizeof(*pool), true,
-                        kAllocRegAlloc);
+  RegisterPool *pool =
+      static_cast<RegisterPool*>(oatNew(cUnit, sizeof(*pool), true, kAllocRegAlloc));
   cUnit->regPool = pool;
   pool->numCoreRegs = numRegs;
-  pool->coreRegs = (RegisterInfo *)
-      oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs),
-             true, kAllocRegAlloc);
+  pool->coreRegs = reinterpret_cast<RegisterInfo*>
+      (oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs), true, kAllocRegAlloc));
   pool->numFPRegs = numFPRegs;
-  pool->FPRegs = (RegisterInfo *)
-      oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs), true,
-             kAllocRegAlloc);
+  pool->FPRegs = static_cast<RegisterInfo*>
+      (oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs), true, kAllocRegAlloc));
   oatInitPool(pool->coreRegs, coreRegs, pool->numCoreRegs);
   oatInitPool(pool->FPRegs, fpRegs, pool->numFPRegs);
   // Keep special registers from being allocated
@@ -660,9 +620,8 @@
   pool->nextCoreReg = r2;
 
   // Construct the alias map.
-  cUnit->phiAliasMap = (int*)oatNew(cUnit, cUnit->numSSARegs *
-                                    sizeof(cUnit->phiAliasMap[0]), false,
-                                    kAllocDFInfo);
+  cUnit->phiAliasMap = static_cast<int*>
+      (oatNew(cUnit, cUnit->numSSARegs * sizeof(cUnit->phiAliasMap[0]), false, kAllocDFInfo));
   for (int i = 0; i < cUnit->numSSARegs; i++) {
     cUnit->phiAliasMap[i] = i;
   }
@@ -837,12 +796,6 @@
   oatFreeTemp(cUnit, r3);
 }
 
-/* Convert an instruction to a NOP */
-void oatNopLIR( LIR* lir)
-{
-  ((LIR*)lir)->flags.isNop = true;
-}
-
 int loadHelper(CompilationUnit* cUnit, int offset)
 {
   loadWordDisp(cUnit, rARM_SELF, offset, rARM_LR);
diff --git a/src/compiler/codegen/arm/utility_arm.cc b/src/compiler/codegen/arm/utility_arm.cc
index 9069826..1873c2a 100644
--- a/src/compiler/codegen/arm/utility_arm.cc
+++ b/src/compiler/codegen/arm/utility_arm.cc
@@ -54,8 +54,8 @@
   LIR* loadPcRel = rawLIR(cUnit, cUnit->currentDalvikOffset, kThumb2Vldrs,
                           rDest, r15pc, 0, 0, 0, dataTarget);
   setMemRefType(loadPcRel, true, kLiteral);
-  loadPcRel->aliasInfo = (intptr_t)dataTarget;
-  oatAppendLIR(cUnit, (LIR* ) loadPcRel);
+  loadPcRel->aliasInfo = reinterpret_cast<uintptr_t>(dataTarget);
+  oatAppendLIR(cUnit, loadPcRel);
   return loadPcRel;
 }
 
@@ -157,9 +157,9 @@
   LIR* loadPcRel = rawLIR(cUnit, cUnit->currentDalvikOffset,
                           kThumb2LdrPcRel12, rDest, 0, 0, 0, 0, dataTarget);
   setMemRefType(loadPcRel, true, kLiteral);
-  loadPcRel->aliasInfo = (intptr_t)dataTarget;
+  loadPcRel->aliasInfo = reinterpret_cast<uintptr_t>(dataTarget);
   res = loadPcRel;
-  oatAppendLIR(cUnit, (LIR* ) loadPcRel);
+  oatAppendLIR(cUnit, loadPcRel);
 
   /*
    * To save space in the constant pool, we use the ADD_RRI8 instruction to
@@ -193,7 +193,7 @@
       opcode = kThumbBlxR;
       break;
     default:
-      LOG(FATAL) << "Bad opcode " << (int)op;
+      LOG(FATAL) << "Bad opcode " << op;
   }
   return newLIR1(cUnit, opcode, rDestSrc);
 }
@@ -295,7 +295,7 @@
       DCHECK_EQ(shift, 0);
       return newLIR4(cUnit, kThumb2Ubfx, rDestSrc1, rSrc2, 0, 16);
     default:
-      LOG(FATAL) << "Bad opcode: " << (int)op;
+      LOG(FATAL) << "Bad opcode: " << op;
       break;
   }
   DCHECK_GE(static_cast<int>(opcode), 0);
@@ -374,7 +374,7 @@
       opcode = kThumb2RorRRR;
       break;
     default:
-      LOG(FATAL) << "Bad opcode: " << (int)op;
+      LOG(FATAL) << "Bad opcode: " << op;
       break;
   }
   DCHECK_GE(static_cast<int>(opcode), 0);
@@ -496,7 +496,7 @@
       return res;
     }
     default:
-      LOG(FATAL) << "Bad opcode: " << (int)op;
+      LOG(FATAL) << "Bad opcode: " << op;
   }
 
   if (modImm >= 0) {
@@ -611,8 +611,8 @@
           rawLIR(cUnit, cUnit->currentDalvikOffset, kThumb2Vldrd,
                  s2d(rDestLo, rDestHi), r15pc, 0, 0, 0, dataTarget);
       setMemRefType(loadPcRel, true, kLiteral);
-      loadPcRel->aliasInfo = (intptr_t)dataTarget;
-      oatAppendLIR(cUnit, (LIR* ) loadPcRel);
+      loadPcRel->aliasInfo = reinterpret_cast<uintptr_t>(dataTarget);
+      oatAppendLIR(cUnit, loadPcRel);
       res = loadPcRel;
     }
   } else {
@@ -681,7 +681,7 @@
       opcode = (thumbForm) ? kThumbLdrsbRRR : kThumb2LdrsbRRR;
       break;
     default:
-      LOG(FATAL) << "Bad size: " << (int)size;
+      LOG(FATAL) << "Bad size: " << size;
   }
   if (thumbForm)
     load = newLIR3(cUnit, opcode, rDest, rBase, rIndex);
@@ -742,7 +742,7 @@
       opcode = (thumbForm) ? kThumbStrbRRR : kThumb2StrbRRR;
       break;
     default:
-      LOG(FATAL) << "Bad size: " << (int)size;
+      LOG(FATAL) << "Bad size: " << size;
   }
   if (thumbForm)
     store = newLIR3(cUnit, opcode, rSrc, rBase, rIndex);
@@ -854,7 +854,7 @@
       }
       break;
     default:
-      LOG(FATAL) << "Bad size: " << (int)size;
+      LOG(FATAL) << "Bad size: " << size;
   }
 
   if (shortForm) {
@@ -961,7 +961,7 @@
       }
       break;
     default:
-      LOG(FATAL) << "Bad size: " << (int)size;
+      LOG(FATAL) << "Bad size: " << size;
   }
   if (shortForm) {
     store = res = newLIR3(cUnit, opcode, rSrc, rBase, encodedDisp);
diff --git a/src/compiler/codegen/codegen_util.cc b/src/compiler/codegen/codegen_util.cc
index 6ce48ab..5da552c 100644
--- a/src/compiler/codegen/codegen_util.cc
+++ b/src/compiler/codegen/codegen_util.cc
@@ -21,6 +21,12 @@
 
 namespace art {
 
+/* Convert an instruction to a NOP */
+void oatNopLIR( LIR* lir)
+{
+  lir->flags.isNop = true;
+}
+
 void setMemRefType(LIR* lir, bool isLoad, int memType)
 {
   uint64_t *maskPtr;
@@ -162,9 +168,8 @@
 #define DUMP_SSA_REP(X)
 
 /* Pretty-print a LIR instruction */
-void oatDumpLIRInsn(CompilationUnit* cUnit, LIR* arg, unsigned char* baseAddr)
+void oatDumpLIRInsn(CompilationUnit* cUnit, LIR* lir, unsigned char* baseAddr)
 {
-  LIR* lir = (LIR*) arg;
   int offset = lir->offset;
   int dest = lir->operands[0];
   const bool dumpNop = (cUnit->enableDebug & (1 << kDebugShowNops));
@@ -182,23 +187,23 @@
       LOG(INFO) << "-------- BARRIER";
       break;
     case kPseudoExtended:
-      LOG(INFO) << "-------- " << (char* ) dest;
+      LOG(INFO) << "-------- " << reinterpret_cast<char*>(dest);
       break;
     case kPseudoSSARep:
-      DUMP_SSA_REP(LOG(INFO) << "-------- kMirOpPhi: " <<  (char* ) dest);
+      DUMP_SSA_REP(LOG(INFO) << "-------- kMirOpPhi: " <<  reinterpret_cast<char*>(dest));
       break;
     case kPseudoEntryBlock:
       LOG(INFO) << "-------- entry offset: 0x" << std::hex << dest;
       break;
     case kPseudoDalvikByteCodeBoundary:
       LOG(INFO) << "-------- dalvik offset: 0x" << std::hex
-                << lir->dalvikOffset << " @ " << (char* )lir->operands[0];
+                << lir->dalvikOffset << " @ " << reinterpret_cast<char*>(lir->operands[0]);
       break;
     case kPseudoExitBlock:
       LOG(INFO) << "-------- exit offset: 0x" << std::hex << dest;
       break;
     case kPseudoPseudoAlign4:
-      LOG(INFO) << (intptr_t)baseAddr + offset << " (0x" << std::hex
+      LOG(INFO) << reinterpret_cast<uintptr_t>(baseAddr) + offset << " (0x" << std::hex
                 << offset << "): .align4";
       break;
     case kPseudoEHBlockLabel:
@@ -206,16 +211,16 @@
       break;
     case kPseudoTargetLabel:
     case kPseudoNormalBlockLabel:
-      LOG(INFO) << "L" << (void*)lir << ":";
+      LOG(INFO) << "L" << reinterpret_cast<void*>(lir) << ":";
       break;
     case kPseudoThrowTarget:
-      LOG(INFO) << "LT" << (void*)lir << ":";
+      LOG(INFO) << "LT" << reinterpret_cast<void*>(lir) << ":";
       break;
     case kPseudoIntrinsicRetry:
-      LOG(INFO) << "IR" << (void*)lir << ":";
+      LOG(INFO) << "IR" << reinterpret_cast<void*>(lir) << ":";
       break;
     case kPseudoSuspendTarget:
-      LOG(INFO) << "LS" << (void*)lir << ":";
+      LOG(INFO) << "LS" << reinterpret_cast<void*>(lir) << ":";
       break;
     case kPseudoSafepointPC:
       LOG(INFO) << "LsafepointPC_0x" << std::hex << lir->offset << "_" << lir->dalvikOffset << ":";
@@ -224,7 +229,7 @@
       LOG(INFO) << "LexportedPC_0x" << std::hex << lir->offset << "_" << lir->dalvikOffset << ":";
       break;
     case kPseudoCaseLabel:
-      LOG(INFO) << "LC" << (void*)lir << ": Case target 0x"
+      LOG(INFO) << "LC" << reinterpret_cast<void*>(lir) << ": Case target 0x"
                 << std::hex << lir->operands[0] << "|" << std::dec <<
         lir->operands[0];
       break;
@@ -237,7 +242,7 @@
         std::string op_operands(buildInsnString(EncodingMap[lir->opcode].fmt
                                               , lir, baseAddr));
         LOG(INFO) << StringPrintf("%05x: %-9s%s%s",
-                                  (unsigned int)(baseAddr + offset),
+                                  reinterpret_cast<unsigned int>(baseAddr + offset),
                                   op_name.c_str(), op_operands.c_str(),
                                   lir->flags.isNop ? "(nop)" : "");
       }
@@ -302,7 +307,6 @@
   LOG(INFO) << "Dumping LIR insns for "
             << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
   LIR* lirInsn;
-  LIR* thisLIR;
   int insnsSize = cUnit->insnsSize;
 
   LOG(INFO) << "Regs (excluding ins) : " << cUnit->numRegs;
@@ -315,16 +319,14 @@
   LOG(INFO) << "code size is " << cUnit->totalSize <<
     " bytes, Dalvik size is " << insnsSize * 2;
   LOG(INFO) << "expansion factor: "
-            << (float)cUnit->totalSize / (float)(insnsSize * 2);
+            << static_cast<float>(cUnit->totalSize) / static_cast<float>(insnsSize * 2);
   oatDumpPromotionMap(cUnit);
   for (lirInsn = cUnit->firstLIRInsn; lirInsn; lirInsn = lirInsn->next) {
     oatDumpLIRInsn(cUnit, lirInsn, 0);
   }
   for (lirInsn = cUnit->literalList; lirInsn; lirInsn = lirInsn->next) {
-    thisLIR = (LIR*) lirInsn;
-    LOG(INFO) << StringPrintf("%x (%04x): .word (%#x)",
-                              thisLIR->offset, thisLIR->offset,
-                              thisLIR->operands[0]);
+    LOG(INFO) << StringPrintf("%x (%04x): .word (%#x)", lirInsn->offset, lirInsn->offset,
+                              lirInsn->operands[0]);
   }
 
   const DexFile::MethodId& method_id =
@@ -342,7 +344,7 @@
 LIR* rawLIR(CompilationUnit* cUnit, int dalvikOffset, int opcode, int op0,
       int op1, int op2, int op3, int op4, LIR* target)
 {
-  LIR* insn = (LIR* ) oatNew(cUnit, sizeof(LIR), true, kAllocLIR);
+  LIR* insn = static_cast<LIR*>(oatNew(cUnit, sizeof(LIR), true, kAllocLIR));
   insn->dalvikOffset = dalvikOffset;
   insn->opcode = opcode;
   insn->operands[0] = op0;
@@ -367,11 +369,11 @@
 LIR* newLIR0(CompilationUnit* cUnit, int opcode)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & NO_OPERAND))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
   LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -379,11 +381,11 @@
                int dest)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & IS_UNARY_OP))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
   LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -391,11 +393,11 @@
                int dest, int src1)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & IS_BINARY_OP))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
   LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -403,12 +405,11 @@
                int dest, int src1, int src2)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & IS_TERTIARY_OP))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
-  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1,
-                     src2);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1, src2);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -416,12 +417,11 @@
       int dest, int src1, int src2, int info)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & IS_QUAD_OP))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
-  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1,
-                     src2, info);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1, src2, info);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -429,12 +429,11 @@
        int dest, int src1, int src2, int info1, int info2)
 {
   DCHECK(isPseudoOpcode(opcode) || (EncodingMap[opcode].flags & IS_QUIN_OP))
-      << EncodingMap[opcode].name << " " << (int)opcode << " "
+      << EncodingMap[opcode].name << " " << opcode << " "
       << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
       << cUnit->currentDalvikOffset;
-  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1,
-                     src2, info1, info2);
-  oatAppendLIR(cUnit, (LIR*) insn);
+  LIR* insn = rawLIR(cUnit, cUnit->currentDalvikOffset, opcode, dest, src1, src2, info1, info2);
+  oatAppendLIR(cUnit, insn);
   return insn;
 }
 
@@ -445,8 +444,8 @@
 LIR* scanLiteralPool(LIR* dataTarget, int value, unsigned int delta)
 {
   while (dataTarget) {
-    if (((unsigned) (value - ((LIR* ) dataTarget)->operands[0])) <= delta)
-      return (LIR* ) dataTarget;
+    if ((static_cast<unsigned>(value - dataTarget->operands[0])) <= delta)
+      return dataTarget;
     dataTarget = dataTarget->next;
   }
   return NULL;
@@ -458,11 +457,11 @@
   bool loMatch = false;
   LIR* loTarget = NULL;
   while (dataTarget) {
-    if (loMatch && (((LIR*)dataTarget)->operands[0] == valHi)) {
-      return (LIR*)loTarget;
+    if (loMatch && (dataTarget->operands[0] == valHi)) {
+      return loTarget;
     }
     loMatch = false;
-    if (((LIR*)dataTarget)->operands[0] == valLo) {
+    if (dataTarget->operands[0] == valLo) {
       loMatch = true;
       loTarget = dataTarget;
     }
@@ -481,10 +480,10 @@
 {
   /* Add the constant to the literal pool */
   if (constantListP) {
-    LIR* newValue = (LIR* ) oatNew(cUnit, sizeof(LIR), true, kAllocData);
+    LIR* newValue = static_cast<LIR*>(oatNew(cUnit, sizeof(LIR), true, kAllocData));
     newValue->operands[0] = value;
     newValue->next = *constantListP;
-    *constantListP = (LIR*) newValue;
+    *constantListP = newValue;
     return newValue;
   }
   return NULL;
@@ -564,8 +563,7 @@
   GrowableListIterator iterator;
   oatGrowableListIteratorInit(&cUnit->switchTables, &iterator);
   while (true) {
-    SwitchTable* tabRec = (SwitchTable *) oatGrowableListIteratorNext(
-       &iterator);
+    SwitchTable* tabRec = reinterpret_cast<SwitchTable*>(oatGrowableListIteratorNext( &iterator));
     if (tabRec == NULL) break;
     alignBuffer(cUnit->codeBuffer, tabRec->offset);
     /*
@@ -591,7 +589,7 @@
       LOG(INFO) << "Switch table for offset 0x" << std::hex << bxOffset;
     }
     if (tabRec->table[0] == Instruction::kSparseSwitchSignature) {
-      int* keys = (int*)&(tabRec->table[2]);
+      const int* keys = reinterpret_cast<const int*>(&(tabRec->table[2]));
       for (int elems = 0; elems < tabRec->table[1]; elems++) {
         int disp = tabRec->targets[elems]->offset - bxOffset;
         if (cUnit->printMe) {
@@ -624,8 +622,8 @@
   GrowableListIterator iterator;
   oatGrowableListIteratorInit(&cUnit->fillArrayData, &iterator);
   while (true) {
-    FillArrayData *tabRec = (FillArrayData *) oatGrowableListIteratorNext(
-       &iterator);
+    FillArrayData *tabRec =
+        reinterpret_cast<FillArrayData*>(oatGrowableListIteratorNext( &iterator));
     if (tabRec == NULL) break;
     alignBuffer(cUnit->codeBuffer, tabRec->offset);
     for (int i = 0; i < (tabRec->size + 1) / 2; i++) {
@@ -680,7 +678,7 @@
 
 void createMappingTables(CompilationUnit* cUnit)
 {
-  for (LIR* tgtLIR = (LIR *) cUnit->firstLIRInsn; tgtLIR != NULL; tgtLIR = NEXT_LIR(tgtLIR)) {
+  for (LIR* tgtLIR = cUnit->firstLIRInsn; tgtLIR != NULL; tgtLIR = NEXT_LIR(tgtLIR)) {
     if (!tgtLIR->flags.isNop && (tgtLIR->opcode == kPseudoSafepointPC)) {
       cUnit->pc2dexMappingTable.push_back(tgtLIR->offset);
       cUnit->pc2dexMappingTable.push_back(tgtLIR->dalvikOffset);
@@ -820,8 +818,7 @@
   GrowableListIterator iterator;
   oatGrowableListIteratorInit(&cUnit->switchTables, &iterator);
   while (true) {
-    SwitchTable *tabRec = (SwitchTable *) oatGrowableListIteratorNext(
-       &iterator);
+    SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(oatGrowableListIteratorNext(&iterator));
     if (tabRec == NULL) break;
     tabRec->offset = offset;
     if (tabRec->table[0] == Instruction::kSparseSwitchSignature) {
@@ -840,8 +837,8 @@
   GrowableListIterator iterator;
   oatGrowableListIteratorInit(&cUnit->fillArrayData, &iterator);
   while (true) {
-    FillArrayData *tabRec = (FillArrayData *) oatGrowableListIteratorNext(
-       &iterator);
+    FillArrayData *tabRec =
+        reinterpret_cast<FillArrayData*>(oatGrowableListIteratorNext(&iterator));
     if (tabRec == NULL) break;
     tabRec->offset = offset;
     offset += tabRec->size;
@@ -932,11 +929,11 @@
   if (it == cUnit->boundaryMap.end()) {
     LOG(FATAL) << "Error: didn't find vaddr 0x" << std::hex << vaddr;
   }
-  LIR* newLabel = (LIR*)oatNew(cUnit, sizeof(LIR), true, kAllocLIR);
+  LIR* newLabel = static_cast<LIR*>(oatNew(cUnit, sizeof(LIR), true, kAllocLIR));
   newLabel->dalvikOffset = vaddr;
   newLabel->opcode = kPseudoCaseLabel;
   newLabel->operands[0] = keyVal;
-  oatInsertLIRAfter(it->second, (LIR*)newLabel);
+  oatInsertLIRAfter(it->second, newLabel);
   return newLabel;
 }
 
@@ -944,12 +941,11 @@
 {
   const uint16_t* table = tabRec->table;
   int baseVaddr = tabRec->vaddr;
-  int *targets = (int*)&table[4];
+  const int *targets = reinterpret_cast<const int*>(&table[4]);
   int entries = table[1];
   int lowKey = s4FromSwitchData(&table[2]);
   for (int i = 0; i < entries; i++) {
-    tabRec->targets[i] = insertCaseLabel(cUnit, baseVaddr + targets[i],
-                                         i + lowKey);
+    tabRec->targets[i] = insertCaseLabel(cUnit, baseVaddr + targets[i], i + lowKey);
   }
 }
 
@@ -958,11 +954,10 @@
   const uint16_t* table = tabRec->table;
   int baseVaddr = tabRec->vaddr;
   int entries = table[1];
-  int* keys = (int*)&table[2];
-  int* targets = &keys[entries];
+  const int* keys = reinterpret_cast<const int*>(&table[2]);
+  const int* targets = &keys[entries];
   for (int i = 0; i < entries; i++) {
-    tabRec->targets[i] = insertCaseLabel(cUnit, baseVaddr + targets[i],
-                                         keys[i]);
+    tabRec->targets[i] = insertCaseLabel(cUnit, baseVaddr + targets[i], keys[i]);
   }
 }
 
@@ -972,7 +967,7 @@
   oatGrowableListIteratorInit(&cUnit->switchTables, &iterator);
   while (true) {
     SwitchTable *tabRec =
-        (SwitchTable *) oatGrowableListIteratorNext(&iterator);
+        reinterpret_cast<SwitchTable*>(oatGrowableListIteratorNext(&iterator));
     if (tabRec == NULL) break;
     if (tabRec->table[0] == Instruction::kPackedSwitchSignature) {
       markPackedCaseLabels(cUnit, tabRec);
@@ -997,8 +992,8 @@
 {
   uint16_t ident = table[0];
   int entries = table[1];
-  int* keys = (int*)&table[2];
-  int* targets = &keys[entries];
+  const int* keys = reinterpret_cast<const int*>(&table[2]);
+  const int* targets = &keys[entries];
   LOG(INFO) <<  "Sparse switch table - ident:0x" << std::hex << ident
             << ", entries: " << std::dec << entries;
   for (int i = 0; i < entries; i++) {
@@ -1018,7 +1013,7 @@
    */
 {
   uint16_t ident = table[0];
-  int* targets = (int*)&table[4];
+  const int* targets = reinterpret_cast<const int*>(&table[4]);
   int entries = table[1];
   int lowKey = s4FromSwitchData(&table[2]);
   LOG(INFO) << "Packed switch table - ident:0x" << std::hex << ident
@@ -1037,7 +1032,7 @@
  */
 LIR* markBoundary(CompilationUnit* cUnit, int offset, const char* instStr)
 {
-  LIR* res = newLIR1(cUnit, kPseudoDalvikByteCodeBoundary, (intptr_t) instStr);
+  LIR* res = newLIR1(cUnit, kPseudoDalvikByteCodeBoundary, reinterpret_cast<uintptr_t>(instStr));
   if (cUnit->boundaryMap.find(offset) == cUnit->boundaryMap.end()) {
     cUnit->boundaryMap.Put(offset, res);
   }
diff --git a/src/compiler/codegen/codegen_util.h b/src/compiler/codegen/codegen_util.h
index 49d52e8..c50c0f0 100644
--- a/src/compiler/codegen/codegen_util.h
+++ b/src/compiler/codegen/codegen_util.h
@@ -19,7 +19,7 @@
 
 namespace art {
 
-inline int32_t s4FromSwitchData(const void* switchData) { return *(int32_t*) switchData; }
+inline int32_t s4FromSwitchData(const void* switchData) { return *reinterpret_cast<const int32_t*>(switchData); }
 inline RegisterClass oatRegClassBySize(OpSize size) { return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte || size == kSignedByte ) ? kCoreReg : kAnyReg; }
 void oatAssembleLIR(CompilationUnit* cUnit);
 void setMemRefType(LIR* lir, bool isLoad, int memType);
diff --git a/src/compiler/codegen/gen_common.cc b/src/compiler/codegen/gen_common.cc
index fe10fe4..c548376 100644
--- a/src/compiler/codegen/gen_common.cc
+++ b/src/compiler/codegen/gen_common.cc
@@ -177,7 +177,7 @@
 void callRuntimeHelperRegReg(CompilationUnit* cUnit, int helperOffset, int arg0, int arg1,
                              bool safepointPC) {
   int rTgt = callHelperSetup(cUnit, helperOffset);
-  DCHECK_NE((int)targetReg(kArg0), arg1);  // check copy into arg0 won't clobber arg1
+  DCHECK_NE(targetReg(kArg0), arg1);  // check copy into arg0 won't clobber arg1
   opRegCopy(cUnit, targetReg(kArg0), arg0);
   opRegCopy(cUnit, targetReg(kArg1), arg1);
   oatClobberCalleeSave(cUnit);
@@ -187,7 +187,7 @@
 void callRuntimeHelperRegRegImm(CompilationUnit* cUnit, int helperOffset, int arg0, int arg1,
                                 int arg2, bool safepointPC) {
   int rTgt = callHelperSetup(cUnit, helperOffset);
-  DCHECK_NE((int)targetReg(kArg0), arg1);  // check copy into arg0 won't clobber arg1
+  DCHECK_NE(targetReg(kArg0), arg1);  // check copy into arg0 won't clobber arg1
   opRegCopy(cUnit, targetReg(kArg0), arg0);
   opRegCopy(cUnit, targetReg(kArg1), arg1);
   loadConstant(cUnit, targetReg(kArg2), arg2);
@@ -246,7 +246,7 @@
 LIR* opUnconditionalBranch(CompilationUnit* cUnit, LIR* target)
 {
   LIR* branch = opBranchUnconditional(cUnit, kOpUncondBr);
-  branch->target = (LIR*) target;
+  branch->target = target;
   return branch;
 }
 
@@ -260,7 +260,7 @@
                     cUnit->currentDalvikOffset);
   LIR* branch = opCondBranch(cUnit, cCode, tgt);
   // Remember branch target - will process later
-  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
+  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, reinterpret_cast<uintptr_t>(tgt));
   return branch;
 }
 
@@ -276,7 +276,7 @@
     branch = opCmpImmBranch(cUnit, cCode, reg, immVal, tgt);
   }
   // Remember branch target - will process later
-  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
+  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, reinterpret_cast<uintptr_t>(tgt));
   return branch;
 }
 
@@ -298,7 +298,7 @@
                     cUnit->currentDalvikOffset, reg1, reg2);
   LIR* branch = opCmpBranch(cUnit, cCode, reg1, reg2, tgt);
   // Remember branch target - will process later
-  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
+  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, reinterpret_cast<uintptr_t>(tgt));
   return branch;
 }
 
@@ -329,8 +329,8 @@
       cond = kCondLe;
       break;
     default:
-      cond = (ConditionCode)0;
-      LOG(FATAL) << "Unexpected opcode " << (int)opcode;
+      cond = static_cast<ConditionCode>(0);
+      LOG(FATAL) << "Unexpected opcode " << opcode;
   }
   opCmpBranch(cUnit, cond, rlSrc1.lowReg, rlSrc2.lowReg, taken);
   opUnconditionalBranch(cUnit, fallThrough);
@@ -361,8 +361,8 @@
       cond = kCondLe;
       break;
     default:
-      cond = (ConditionCode)0;
-      LOG(FATAL) << "Unexpected opcode " << (int)opcode;
+      cond = static_cast<ConditionCode>(0);
+      LOG(FATAL) << "Unexpected opcode " << opcode;
   }
   if (cUnit->instructionSet == kThumb2) {
     opRegImm(cUnit, kOpCmp, rlSrc.lowReg, 0);
@@ -601,7 +601,7 @@
         opRegCopy(cUnit, rBase, targetReg(kRet0));
       }
       LIR* skipTarget = newLIR0(cUnit, kPseudoTargetLabel);
-      branchOver->target = (LIR*)skipTarget;
+      branchOver->target = skipTarget;
       oatFreeTemp(cUnit, rMethod);
     }
     // rBase now holds static storage base
@@ -692,7 +692,7 @@
         opRegCopy(cUnit, rBase, targetReg(kRet0));
       }
       LIR* skipTarget = newLIR0(cUnit, kPseudoTargetLabel);
-      branchOver->target = (LIR*)skipTarget;
+      branchOver->target = skipTarget;
       oatFreeTemp(cUnit, rMethod);
     }
     // rBase now holds static storage base
@@ -736,19 +736,19 @@
   LIR* branchOver = opCmpImmBranch(cUnit, kCondNe, targetReg(kInvokeTgt), 0, NULL);
   loadWordDisp(cUnit, targetReg(kSelf), ENTRYPOINT_OFFSET(pDebugMe), targetReg(kInvokeTgt));
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
 }
 
 void handleSuspendLaunchpads(CompilationUnit *cUnit)
 {
-  LIR** suspendLabel = (LIR **)cUnit->suspendLaunchpads.elemList;
+  LIR** suspendLabel = reinterpret_cast<LIR**>(cUnit->suspendLaunchpads.elemList);
   int numElems = cUnit->suspendLaunchpads.numUsed;
   int helperOffset = ENTRYPOINT_OFFSET(pTestSuspendFromCode);
   for (int i = 0; i < numElems; i++) {
     oatResetRegPool(cUnit);
     oatResetDefTracking(cUnit);
     LIR* lab = suspendLabel[i];
-    LIR* resumeLab = (LIR*)lab->operands[0];
+    LIR* resumeLab = reinterpret_cast<LIR*>(lab->operands[0]);
     cUnit->currentDalvikOffset = lab->operands[1];
     oatAppendLIR(cUnit, lab);
     int rTgt = callHelperSetup(cUnit, helperOffset);
@@ -759,18 +759,18 @@
 
 void handleIntrinsicLaunchpads(CompilationUnit *cUnit)
 {
-  LIR** intrinsicLabel = (LIR **)cUnit->intrinsicLaunchpads.elemList;
+  LIR** intrinsicLabel = reinterpret_cast<LIR**>(cUnit->intrinsicLaunchpads.elemList);
   int numElems = cUnit->intrinsicLaunchpads.numUsed;
   for (int i = 0; i < numElems; i++) {
     oatResetRegPool(cUnit);
     oatResetDefTracking(cUnit);
     LIR* lab = intrinsicLabel[i];
-    CallInfo* info = (CallInfo*)lab->operands[0];
+    CallInfo* info = reinterpret_cast<CallInfo*>(lab->operands[0]);
     cUnit->currentDalvikOffset = info->offset;
     oatAppendLIR(cUnit, lab);
     // NOTE: genInvoke handles markSafepointPC
     genInvoke(cUnit, info);
-    LIR* resumeLab = (LIR*)lab->operands[2];
+    LIR* resumeLab = reinterpret_cast<LIR*>(lab->operands[2]);
     if (resumeLab != NULL) {
       opUnconditionalBranch(cUnit, resumeLab);
     }
@@ -779,7 +779,7 @@
 
 void handleThrowLaunchpads(CompilationUnit *cUnit)
 {
-  LIR** throwLabel = (LIR **)cUnit->throwLaunchpads.elemList;
+  LIR** throwLabel = reinterpret_cast<LIR**>(cUnit->throwLaunchpads.elemList);
   int numElems = cUnit->throwLaunchpads.numUsed;
   for (int i = 0; i < numElems; i++) {
     oatResetRegPool(cUnit);
@@ -1031,8 +1031,8 @@
       oatClobberSReg(cUnit, rlDest.sRegLow);
       // Rejoin code paths
       LIR* target2 = newLIR0(cUnit, kPseudoTargetLabel);
-      branch1->target = (LIR*)target1;
-      branch2->target = (LIR*)target2;
+      branch1->target = target1;
+      branch2->target = target2;
     } else {
       // Fast path, we're done - just store result
       storeValue(cUnit, rlDest, rlResult);
@@ -1172,7 +1172,7 @@
       loadValueDirectFixed(cUnit, rlSrc, targetReg(kArg0));  /* reload Ref */
       // Rejoin code paths
       LIR* hopTarget = newLIR0(cUnit, kPseudoTargetLabel);
-      hopBranch->target = (LIR*)hopTarget;
+      hopBranch->target = hopTarget;
     }
   }
   /* kArg0 is ref, kArg2 is class. If ref==null, use directly as bool result */
@@ -1257,7 +1257,7 @@
       opRegCopy(cUnit, classReg, targetReg(kRet0)); // Align usage with fast path
       // Rejoin code paths
       LIR* hopTarget = newLIR0(cUnit, kPseudoTargetLabel);
-      hopBranch->target = (LIR*)hopTarget;
+      hopBranch->target = hopTarget;
     }
   }
   // At this point, classReg (kArg2) has class
@@ -1705,8 +1705,7 @@
       op = kOpLsr;
       break;
     default:
-      LOG(FATAL) << "Invalid word arith op: " <<
-        (int)opcode;
+      LOG(FATAL) << "Invalid word arith op: " << opcode;
   }
   if (!isDivRem) {
     if (unary) {
@@ -1901,7 +1900,7 @@
                       RegLocation rlDest, RegLocation rlSrc, int lit)
 {
   RegLocation rlResult;
-  OpKind op = (OpKind)0;    /* Make gcc happy */
+  OpKind op = static_cast<OpKind>(0);    /* Make gcc happy */
   int shiftOp = false;
   bool isDiv = false;
 
@@ -2296,9 +2295,9 @@
   LIR* branch = opTestSuspend(cUnit, NULL);
   LIR* retLab = newLIR0(cUnit, kPseudoTargetLabel);
   LIR* target = rawLIR(cUnit, cUnit->currentDalvikOffset, kPseudoSuspendTarget,
-                       (intptr_t)retLab, cUnit->currentDalvikOffset);
-  branch->target = (LIR*)target;
-  oatInsertGrowableList(cUnit, &cUnit->suspendLaunchpads, (intptr_t)target);
+                       reinterpret_cast<uintptr_t>(retLab), cUnit->currentDalvikOffset);
+  branch->target = target;
+  oatInsertGrowableList(cUnit, &cUnit->suspendLaunchpads, reinterpret_cast<uintptr_t>(target));
 }
 
 /* Check if we need to check for pending suspend request */
@@ -2309,11 +2308,12 @@
     return;
   }
   opTestSuspend(cUnit, target);
-  LIR* launchPad = rawLIR(cUnit, cUnit->currentDalvikOffset, kPseudoSuspendTarget, (intptr_t)target,
-                          cUnit->currentDalvikOffset);
+  LIR* launchPad =
+      rawLIR(cUnit, cUnit->currentDalvikOffset, kPseudoSuspendTarget,
+             reinterpret_cast<uintptr_t>(target), cUnit->currentDalvikOffset);
   oatFlushAllRegs(cUnit);
   opUnconditionalBranch(cUnit, launchPad);
-  oatInsertGrowableList(cUnit, &cUnit->suspendLaunchpads, (intptr_t)launchPad);
+  oatInsertGrowableList(cUnit, &cUnit->suspendLaunchpads, reinterpret_cast<uintptr_t>(launchPad));
 }
 
 }  // namespace art
diff --git a/src/compiler/codegen/gen_invoke.cc b/src/compiler/codegen/gen_invoke.cc
index bac6a76..fbab59f 100644
--- a/src/compiler/codegen/gen_invoke.cc
+++ b/src/compiler/codegen/gen_invoke.cc
@@ -113,13 +113,13 @@
   LIR* curTarget = cUnit->methodLiteralList;
   LIR* nextTarget = curTarget != NULL ? curTarget->next : NULL;
   while (curTarget != NULL && nextTarget != NULL) {
-    if (curTarget->operands[0] == (int)dexFile &&
-      nextTarget->operands[0] == (int)dexMethodIdx) {
+    if (curTarget->operands[0] == reinterpret_cast<intptr_t>(dexFile) &&
+      nextTarget->operands[0] == static_cast<int>(dexMethodIdx)) {
     *codeTarget = curTarget;
     *methodTarget = nextTarget;
     DCHECK((*codeTarget)->next == *methodTarget);
-    DCHECK_EQ((*codeTarget)->operands[0], (int)dexFile);
-    DCHECK_EQ((*methodTarget)->operands[0], (int)dexMethodIdx);
+    DCHECK_EQ((*codeTarget)->operands[0], reinterpret_cast<intptr_t>(dexFile));
+    DCHECK_EQ((*methodTarget)->operands[0], static_cast<int>(dexMethodIdx));
     break;
     }
     curTarget = nextTarget->next;
@@ -144,7 +144,7 @@
   if (directCode != 0 && directMethod != 0) {
     switch (state) {
     case 0:  // Get the current Method* [sets kArg0]
-      if (directCode != (uintptr_t)-1) {
+      if (directCode != static_cast<unsigned int>(-1)) {
         loadConstant(cUnit, targetReg(kInvokeTgt), directCode);
       } else {
         LIR* dataTarget = scanLiteralPool(cUnit->codeLiteralList, dexIdx, 0);
@@ -154,9 +154,9 @@
         }
         LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget);
         oatAppendLIR(cUnit, loadPcRel);
-        DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
+        DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget);
       }
-      if (directMethod != (uintptr_t)-1) {
+      if (directMethod != static_cast<unsigned int>(-1)) {
         loadConstant(cUnit, targetReg(kArg0), directMethod);
       } else {
         LIR* dataTarget = scanLiteralPool(cUnit->methodLiteralList, dexIdx, 0);
@@ -166,7 +166,7 @@
         }
         LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget);
         oatAppendLIR(cUnit, loadPcRel);
-        DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
+        DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget);
       }
       break;
     default:
@@ -183,7 +183,7 @@
         AbstractMethod::DexCacheResolvedMethodsOffset().Int32Value(), targetReg(kArg0));
       // Set up direct code if known.
       if (directCode != 0) {
-        if (directCode != (uintptr_t)-1) {
+        if (directCode != static_cast<unsigned int>(-1)) {
           loadConstant(cUnit, targetReg(kInvokeTgt), directCode);
         } else {
           LIR* dataTarget = scanLiteralPool(cUnit->codeLiteralList, dexIdx, 0);
@@ -193,7 +193,7 @@
           }
           LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kInvokeTgt), dataTarget);
           oatAppendLIR(cUnit, loadPcRel);
-          DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
+          DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget);
         }
       }
       break;
@@ -287,7 +287,7 @@
           loadWordDisp(cUnit, targetReg(kSelf), trampoline, targetReg(kInvokeTgt));
         }
         // Get the interface Method* [sets kArg0]
-        if (directMethod != (uintptr_t)-1) {
+        if (directMethod != static_cast<unsigned int>(-1)) {
           loadConstant(cUnit, targetReg(kArg0), directMethod);
         } else {
           LIR* dataTarget = scanLiteralPool(cUnit->methodLiteralList, dexIdx, 0);
@@ -297,7 +297,7 @@
           }
           LIR* loadPcRel = opPcRelLoad(cUnit, targetReg(kArg0), dataTarget);
           oatAppendLIR(cUnit, loadPcRel);
-          DCHECK_EQ(cUnit->instructionSet, kThumb2) << (void*)dataTarget;
+          DCHECK_EQ(cUnit->instructionSet, kThumb2) << reinterpret_cast<void*>(dataTarget);
         }
         break;
       default:
@@ -509,8 +509,7 @@
                           type, skipThis);
 
   if (pcrLabel) {
-    *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1),
-                             info->optFlags);
+    *pcrLabel = genNullCheck(cUnit, info->args[0].sRegLow, targetReg(kArg1), info->optFlags);
   }
   return callState;
 }
@@ -677,9 +676,9 @@
     loadWordDisp(cUnit, rlObj.lowReg, valueOffset, regPtr);
     if (rangeCheck) {
       // Set up a launch pad to allow retry in case of bounds violation */
-      launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
+      launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info));
       oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
-                            (intptr_t)launchPad);
+                            reinterpret_cast<uintptr_t>(launchPad));
       opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax);
       oatFreeTemp(cUnit, regMax);
       opCondBranch(cUnit, kCondCs, launchPad);
@@ -689,9 +688,9 @@
       regMax = oatAllocTemp(cUnit);
       loadWordDisp(cUnit, rlObj.lowReg, countOffset, regMax);
       // Set up a launch pad to allow retry in case of bounds violation */
-      launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
+      launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info));
       oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
-                            (intptr_t)launchPad);
+                            reinterpret_cast<uintptr_t>(launchPad));
       opRegReg(cUnit, kOpCmp, rlIdx.lowReg, regMax);
       oatFreeTemp(cUnit, regMax);
       opCondBranch(cUnit, kCondCc, launchPad);
@@ -865,9 +864,8 @@
   }
   int rTgt = (cUnit->instructionSet != kX86) ? loadHelper(cUnit, ENTRYPOINT_OFFSET(pIndexOf)) : 0;
   genNullCheck(cUnit, rlObj.sRegLow, regPtr, info->optFlags);
-  LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
-  oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
-              (intptr_t)launchPad);
+  LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info));
+  oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, reinterpret_cast<uintptr_t>(launchPad));
   opCmpImmBranch(cUnit, kCondGt, regChar, 0xFFFF, launchPad);
   // NOTE: not a safepoint
   if (cUnit->instructionSet != kX86) {
@@ -876,7 +874,7 @@
     opThreadMem(cUnit, kOpBlx, ENTRYPOINT_OFFSET(pIndexOf));
   }
   LIR* resumeTgt = newLIR0(cUnit, kPseudoTargetLabel);
-  launchPad->operands[2] = (uintptr_t)resumeTgt;
+  launchPad->operands[2] = reinterpret_cast<uintptr_t>(resumeTgt);
   // Record that we've already inlined & null checked
   info->optFlags |= (MIR_INLINED | MIR_IGNORE_NULL_CHECK);
   RegLocation rlReturn = oatGetReturn(cUnit, false);
@@ -905,9 +903,8 @@
       loadHelper(cUnit, ENTRYPOINT_OFFSET(pStringCompareTo)) : 0;
   genNullCheck(cUnit, rlThis.sRegLow, regThis, info->optFlags);
   //TUNING: check if rlCmp.sRegLow is already null checked
-  LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, (uintptr_t)info);
-  oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads,
-                        (intptr_t)launchPad);
+  LIR* launchPad = rawLIR(cUnit, 0, kPseudoIntrinsicRetry, reinterpret_cast<uintptr_t>(info));
+  oatInsertGrowableList(cUnit, &cUnit->intrinsicLaunchpads, reinterpret_cast<uintptr_t>(launchPad));
   opCmpImmBranch(cUnit, kCondEq, regCmp, 0, launchPad);
   // NOTE: not a safepoint
   if (cUnit->instructionSet != kX86) {
diff --git a/src/compiler/codegen/gen_loadstore.cc b/src/compiler/codegen/gen_loadstore.cc
index 600b324..b5802ae 100644
--- a/src/compiler/codegen/gen_loadstore.cc
+++ b/src/compiler/codegen/gen_loadstore.cc
@@ -166,11 +166,11 @@
   oatResetDefLoc(cUnit, rlDest);
   if (oatIsDirty(cUnit, rlDest.lowReg) &&
       oatLiveOut(cUnit, rlDest.sRegLow)) {
-    defStart = (LIR* )cUnit->lastLIRInsn;
+    defStart = cUnit->lastLIRInsn;
     storeBaseDisp(cUnit, targetReg(kSp), oatSRegOffset(cUnit, rlDest.sRegLow),
                   rlDest.lowReg, kWord);
     oatMarkClean(cUnit, rlDest);
-    defEnd = (LIR* )cUnit->lastLIRInsn;
+    defEnd = cUnit->lastLIRInsn;
     oatMarkDef(cUnit, rlDest, defStart, defEnd);
   }
 }
@@ -245,13 +245,13 @@
       oatIsDirty(cUnit, rlDest.highReg)) &&
       (oatLiveOut(cUnit, rlDest.sRegLow) ||
       oatLiveOut(cUnit, oatSRegHi(rlDest.sRegLow)))) {
-    defStart = (LIR*)cUnit->lastLIRInsn;
+    defStart = cUnit->lastLIRInsn;
     DCHECK_EQ((SRegToVReg(cUnit, rlDest.sRegLow)+1),
               SRegToVReg(cUnit, oatSRegHi(rlDest.sRegLow)));
     storeBaseDispWide(cUnit, targetReg(kSp), oatSRegOffset(cUnit, rlDest.sRegLow),
                       rlDest.lowReg, rlDest.highReg);
     oatMarkClean(cUnit, rlDest);
-    defEnd = (LIR*)cUnit->lastLIRInsn;
+    defEnd = cUnit->lastLIRInsn;
     oatMarkDefWide(cUnit, rlDest, defStart, defEnd);
   }
 }
diff --git a/src/compiler/codegen/local_optimizations.cc b/src/compiler/codegen/local_optimizations.cc
index e485f03..03f9463 100644
--- a/src/compiler/codegen/local_optimizations.cc
+++ b/src/compiler/codegen/local_optimizations.cc
@@ -50,7 +50,7 @@
    * will need to be re-checked (eg the new dest clobbers the src used in
    * thisLIR).
    */
-  oatInsertLIRAfter((LIR*) origLIR, (LIR*) moveLIR);
+  oatInsertLIRAfter(origLIR, moveLIR);
 }
 
 /*
@@ -240,15 +240,14 @@
         DEBUG_OPT(dumpDependentInsnPair(thisLIR, checkLIR, "REG CLOBBERED"));
         /* Only sink store instructions */
         if (sinkDistance && !isThisLIRLoad) {
-          LIR* newStoreLIR =
-              (LIR* ) oatNew(cUnit, sizeof(LIR), true, kAllocLIR);
+          LIR* newStoreLIR = static_cast<LIR*>(oatNew(cUnit, sizeof(LIR), true, kAllocLIR));
           *newStoreLIR = *thisLIR;
           /*
            * Stop point found - insert *before* the checkLIR
            * since the instruction list is scanned in the
            * top-down order.
            */
-          oatInsertLIRBefore((LIR*) checkLIR, (LIR*) newStoreLIR);
+          oatInsertLIRBefore(checkLIR, newStoreLIR);
           thisLIR->flags.isNop = true;
         }
         break;
@@ -429,14 +428,13 @@
       /* Found a slot to hoist to */
       if (slot >= 0) {
         LIR* curLIR = prevInstList[slot];
-        LIR* newLoadLIR = (LIR* ) oatNew(cUnit, sizeof(LIR),
-                             true, kAllocLIR);
+        LIR* newLoadLIR = static_cast<LIR*>(oatNew(cUnit, sizeof(LIR), true, kAllocLIR));
         *newLoadLIR = *thisLIR;
         /*
          * Insertion is guaranteed to succeed since checkLIR
          * is never the first LIR on the list
          */
-        oatInsertLIRBefore((LIR*) curLIR, (LIR*) newLoadLIR);
+        oatInsertLIRBefore(curLIR, newLoadLIR);
         thisLIR->flags.isNop = true;
       }
     }
@@ -447,11 +445,49 @@
                     LIR* tailLIR)
 {
   if (!(cUnit->disableOpt & (1 << kLoadStoreElimination))) {
-    applyLoadStoreElimination(cUnit, (LIR* ) headLIR,
-                  (LIR* ) tailLIR);
+    applyLoadStoreElimination(cUnit, headLIR, tailLIR);
   }
   if (!(cUnit->disableOpt & (1 << kLoadHoisting))) {
-    applyLoadHoisting(cUnit, (LIR* ) headLIR, (LIR* ) tailLIR);
+    applyLoadHoisting(cUnit, headLIR, tailLIR);
+  }
+}
+
+/*
+ * Nop any unconditional branches that go to the next instruction.
+ * Note: new redundant branches may be inserted later, and we'll
+ * use a check in final instruction assembly to nop those out.
+ */
+void removeRedundantBranches(CompilationUnit* cUnit)
+{
+  LIR* thisLIR;
+
+  for (thisLIR = cUnit->firstLIRInsn; thisLIR != cUnit->lastLIRInsn; thisLIR = NEXT_LIR(thisLIR)) {
+
+    /* Branch to the next instruction */
+    if (branchUnconditional(thisLIR)) {
+      LIR* nextLIR = thisLIR;
+
+      while (true) {
+        nextLIR = NEXT_LIR(nextLIR);
+
+        /*
+         * Is the branch target the next instruction?
+         */
+        if (nextLIR == thisLIR->target) {
+          thisLIR->flags.isNop = true;
+          break;
+        }
+
+        /*
+         * Found real useful stuff between the branch and the target.
+         * Need to explicitly check the lastLIRInsn here because it
+         * might be the last real instruction.
+         */
+        if (!isPseudoOpcode(nextLIR->opcode) ||
+          (nextLIR == cUnit->lastLIRInsn))
+          break;
+      }
+    }
   }
 }
 
diff --git a/src/compiler/codegen/local_optimizations.h b/src/compiler/codegen/local_optimizations.h
index 440090f..5f0c17b 100644
--- a/src/compiler/codegen/local_optimizations.h
+++ b/src/compiler/codegen/local_optimizations.h
@@ -20,6 +20,7 @@
 namespace art {
 
 void oatApplyLocalOptimizations(CompilationUnit* cUnit, LIR* headLIR, LIR* tailLIR);
+void removeRedundantBranches(CompilationUnit* cUnit);
 
 }  // namespace art
 
diff --git a/src/compiler/codegen/method_bitcode.cc b/src/compiler/codegen/method_bitcode.cc
index d6f1ae9..2996e9a 100644
--- a/src/compiler/codegen/method_bitcode.cc
+++ b/src/compiler/codegen/method_bitcode.cc
@@ -46,7 +46,7 @@
 
 llvm::Value* getLLVMValue(CompilationUnit* cUnit, int sReg)
 {
-  return (llvm::Value*)oatGrowableListGetElement(&cUnit->llvmValues, sReg);
+  return reinterpret_cast<llvm::Value*>(oatGrowableListGetElement(&cUnit->llvmValues, sReg));
 }
 
 // Replace the placeholder value with the real definition
@@ -60,7 +60,7 @@
   }
   placeholder->replaceAllUsesWith(val);
   val->takeName(placeholder);
-  cUnit->llvmValues.elemList[sReg] = (intptr_t)val;
+  cUnit->llvmValues.elemList[sReg] = reinterpret_cast<uintptr_t>(val);
   llvm::Instruction* inst = llvm::dyn_cast<llvm::Instruction>(placeholder);
   DCHECK(inst != NULL);
   inst->eraseFromParent();
@@ -173,10 +173,9 @@
 
   if (cUnit->printMe && loc.home) {
     if (loc.wide) {
-      LOG(INFO) << "Promoted wide " << s << " to regs " << static_cast<int>(loc.lowReg)
-                << "/" << loc.highReg;
+      LOG(INFO) << "Promoted wide " << s << " to regs " << loc.lowReg << "/" << loc.highReg;
     } else {
-      LOG(INFO) << "Promoted " << s << " to reg " << static_cast<int>(loc.lowReg);
+      LOG(INFO) << "Promoted " << s << " to reg " << loc.lowReg;
     }
   }
   cUnit->locMap.Put(val, loc);
@@ -638,8 +637,8 @@
   if (info->result.location != kLocInvalid) {
     defineValue(cUnit, res, info->result.origSReg);
     if (info->result.ref) {
-      setShadowFrameEntry(cUnit, (llvm::Value*)
-                          cUnit->llvmValues.elemList[info->result.origSReg]);
+      setShadowFrameEntry(cUnit, reinterpret_cast<llvm::Value*>
+                          (cUnit->llvmValues.elemList[info->result.origSReg]));
     }
   }
 }
@@ -866,6 +865,7 @@
   RegLocation rlSrc[3];
   RegLocation rlDest = badLoc;
   Instruction::Code opcode = mir->dalvikInsn.opcode;
+  int opVal = opcode;
   uint32_t vB = mir->dalvikInsn.vB;
   uint32_t vC = mir->dalvikInsn.vC;
   int optFlags = mir->optimizationFlags;
@@ -873,11 +873,10 @@
   bool objectDefinition = false;
 
   if (cUnit->printMe) {
-    if ((int)opcode < kMirOpFirst) {
-      LOG(INFO) << ".. " << Instruction::Name(opcode) << " 0x"
-                << std::hex << (int)opcode;
+    if (opVal < kMirOpFirst) {
+      LOG(INFO) << ".. " << Instruction::Name(opcode) << " 0x" << std::hex << opVal;
     } else {
-      LOG(INFO) << ".. opcode 0x" << std::hex << (int)opcode;
+      LOG(INFO) << extendedMIROpNames[opVal - kMirOpFirst] << " 0x" << std::hex << opVal;
     }
   }
 
@@ -1679,8 +1678,8 @@
       res = true;
   }
   if (objectDefinition) {
-    setShadowFrameEntry(cUnit, (llvm::Value*)
-                        cUnit->llvmValues.elemList[rlDest.origSReg]);
+    setShadowFrameEntry(cUnit, reinterpret_cast<llvm::Value*>
+                        (cUnit->llvmValues.elemList[rlDest.origSReg]));
   }
   return res;
 }
@@ -1690,7 +1689,7 @@
                         llvm::BasicBlock* llvmBB)
 {
 
-  switch ((ExtendedMIROpcode)mir->dalvikInsn.opcode) {
+  switch (static_cast<ExtendedMIROpcode>(mir->dalvikInsn.opcode)) {
     case kMirOpPhi: {
       RegLocation rlDest = cUnit->regLocation[mir->ssaRep->defs[0]];
       /*
@@ -1703,7 +1702,7 @@
       if (rlDest.highWord) {
         return;  // No Phi node - handled via low word
       }
-      int* incoming = (int*)mir->dalvikInsn.vB;
+      int* incoming = reinterpret_cast<int*>(mir->dalvikInsn.vB);
       llvm::Type* phiType =
           llvmTypeFromLocRec(cUnit, rlDest);
       llvm::PHINode* phi = cUnit->irb->CreatePHI(phiType, mir->ssaRep->numUses);
@@ -1823,9 +1822,8 @@
 
   if (bb->blockType == kEntryBlock) {
     setMethodInfo(cUnit);
-    bool *canBeRef = (bool*)  oatNew(cUnit, sizeof(bool) *
-                                     cUnit->numDalvikRegisters, true,
-                                     kAllocMisc);
+    bool *canBeRef = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * cUnit->numDalvikRegisters,
+                                               true, kAllocMisc));
     for (int i = 0; i < cUnit->numSSARegs; i++) {
       int vReg = SRegToVReg(cUnit, i);
       if (vReg > SSA_METHOD_BASEREG) {
@@ -1838,9 +1836,8 @@
       }
     }
     if (cUnit->numShadowFrameEntries > 0) {
-      cUnit->shadowMap = (int*) oatNew(cUnit, sizeof(int) *
-                                       cUnit->numShadowFrameEntries, true,
-                                       kAllocMisc);
+      cUnit->shadowMap = static_cast<int*>(oatNew(cUnit, sizeof(int) * cUnit->numShadowFrameEntries,
+                                                  true, kAllocMisc));
       for (int i = 0, j = 0; i < cUnit->numDalvikRegisters; i++) {
         if (canBeRef[i]) {
           cUnit->shadowMap[j++] = i;
@@ -1902,7 +1899,7 @@
                                      bb->successorBlockList.blocks.numUsed);
         while (true) {
           SuccessorBlockInfo *successorBlockInfo =
-              (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iter);
+              reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iter));
           if (successorBlockInfo == NULL) break;
           llvm::BasicBlock *target =
               getLLVMBlock(cUnit, successorBlockInfo->block->id);
@@ -2077,11 +2074,11 @@
          cUnit->irb->GetJLong(0) : cUnit->irb->GetJInt(0);
       val = emitConst(cUnit, immValue, cUnit->regLocation[i]);
       val->setName(llvmSSAName(cUnit, i));
-      oatInsertGrowableList(cUnit, &cUnit->llvmValues, (intptr_t)val);
+      oatInsertGrowableList(cUnit, &cUnit->llvmValues, reinterpret_cast<uintptr_t>(val));
     } else {
       // Recover previously-created argument values
       llvm::Value* argVal = arg_iter++;
-      oatInsertGrowableList(cUnit, &cUnit->llvmValues, (intptr_t)argVal);
+      oatInsertGrowableList(cUnit, &cUnit->llvmValues, reinterpret_cast<uintptr_t>(argVal));
     }
   }
 
@@ -2835,8 +2832,7 @@
 void cvtInvoke(CompilationUnit* cUnit, llvm::CallInst* callInst,
                bool isVoid, bool isFilledNewArray)
 {
-  CallInfo* info = (CallInfo*)oatNew(cUnit, sizeof(CallInfo), true,
-                                         kAllocMisc);
+  CallInfo* info = static_cast<CallInfo*>(oatNew(cUnit, sizeof(CallInfo), true, kAllocMisc));
   if (isVoid) {
     info->result.location = kLocInvalid;
   } else {
@@ -2859,8 +2855,8 @@
     RegLocation tLoc = getLoc(cUnit, callInst->getArgOperand(i));
     info->numArgWords += tLoc.wide ? 2 : 1;
   }
-  info->args = (info->numArgWords == 0) ? NULL : (RegLocation*)
-      oatNew(cUnit, sizeof(RegLocation) * info->numArgWords, false, kAllocMisc);
+  info->args = (info->numArgWords == 0) ? NULL : static_cast<RegLocation*>
+      (oatNew(cUnit, sizeof(RegLocation) * info->numArgWords, false, kAllocMisc));
   // Now, fill in the location records, synthesizing high loc of wide vals
   for (int i = 3, next = 0; next < info->numArgWords;) {
     info->args[next] = getLoc(cUnit, callInst->getArgOperand(i++));
@@ -2933,8 +2929,8 @@
     oatClobberAllRegs(cUnit);
 
     if (isEntry) {
-      RegLocation* argLocs = (RegLocation*)
-          oatNew(cUnit, sizeof(RegLocation) * cUnit->numIns, true, kAllocMisc);
+      RegLocation* argLocs = static_cast<RegLocation*>
+          (oatNew(cUnit, sizeof(RegLocation) * cUnit->numIns, true, kAllocMisc));
       llvm::Function::arg_iterator it(cUnit->func->arg_begin());
       llvm::Function::arg_iterator it_end(cUnit->func->arg_end());
       // Skip past Method*
@@ -3301,8 +3297,7 @@
                 break;
 
               default:
-                LOG(FATAL) << "Unexpected intrinsic " << (int)id << ", "
-                           << cUnit->intrinsic_helper->GetName(id);
+                LOG(FATAL) << "Unexpected intrinsic " << cUnit->intrinsic_helper->GetName(id);
             }
           }
           break;
@@ -3409,7 +3404,7 @@
   int numBasicBlocks = func->getBasicBlockList().size();
   // Allocate a list for LIR basic block labels
   cUnit->blockLabelList =
-    (LIR*)oatNew(cUnit, sizeof(LIR) * numBasicBlocks, true, kAllocLIR);
+    static_cast<LIR*>(oatNew(cUnit, sizeof(LIR) * numBasicBlocks, true, kAllocLIR));
   LIR* labelList = cUnit->blockLabelList;
   int nextLabel = 0;
   for (llvm::Function::iterator i = func->begin(),
diff --git a/src/compiler/codegen/method_codegen_driver.cc b/src/compiler/codegen/method_codegen_driver.cc
index 4ca06b7..b41bd83 100644
--- a/src/compiler/codegen/method_codegen_driver.cc
+++ b/src/compiler/codegen/method_codegen_driver.cc
@@ -184,8 +184,7 @@
 CallInfo* oatNewCallInfo(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir,
                          InvokeType type, bool isRange)
 {
-  CallInfo* info = (CallInfo*)oatNew(cUnit, sizeof(CallInfo), true,
-                                         kAllocMisc);
+  CallInfo* info = static_cast<CallInfo*>(oatNew(cUnit, sizeof(CallInfo), true, kAllocMisc));
   MIR* moveResultMIR = oatFindMoveResult(cUnit, bb, mir);
   if (moveResultMIR == NULL) {
     info->result.location = kLocInvalid;
@@ -194,8 +193,8 @@
     moveResultMIR->dalvikInsn.opcode = Instruction::NOP;
   }
   info->numArgWords = mir->ssaRep->numUses;
-  info->args = (info->numArgWords == 0) ? NULL : (RegLocation*)
-      oatNew(cUnit, sizeof(RegLocation) * info->numArgWords, false, kAllocMisc);
+  info->args = (info->numArgWords == 0) ? NULL : static_cast<RegLocation*>
+      (oatNew(cUnit, sizeof(RegLocation) * info->numArgWords, false, kAllocMisc));
   for (int i = 0; i < info->numArgWords; i++) {
     info->args[i] = oatGetRawSrc(cUnit, mir, i);
   }
@@ -794,41 +793,26 @@
   return res;
 }
 
-const char* extendedMIROpNames[kMirOpLast - kMirOpFirst] = {
-  "kMirOpPhi",
-  "kMirOpCopy",
-  "kMirFusedCmplFloat",
-  "kMirFusedCmpgFloat",
-  "kMirFusedCmplDouble",
-  "kMirFusedCmpgDouble",
-  "kMirFusedCmpLong",
-  "kMirNop",
-  "kMirOpNullCheck",
-  "kMirOpRangeCheck",
-  "kMirOpDivZeroCheck",
-  "kMirOpCheck",
-};
-
 /* Extended MIR instructions like PHI */
 void handleExtendedMethodMIR(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir)
 {
   int opOffset = mir->dalvikInsn.opcode - kMirOpFirst;
   char* msg = NULL;
   if (cUnit->printMe) {
-    msg = (char*)oatNew(cUnit, strlen(extendedMIROpNames[opOffset]) + 1,
-                        false, kAllocDebugInfo);
+    msg = static_cast<char*>(oatNew(cUnit, strlen(extendedMIROpNames[opOffset]) + 1,
+                                    false, kAllocDebugInfo));
     strcpy(msg, extendedMIROpNames[opOffset]);
   }
-  LIR* op = newLIR1(cUnit, kPseudoExtended, (int) msg);
+  LIR* op = newLIR1(cUnit, kPseudoExtended, reinterpret_cast<uintptr_t>(msg));
 
-  switch ((ExtendedMIROpcode)mir->dalvikInsn.opcode) {
+  switch (static_cast<ExtendedMIROpcode>(mir->dalvikInsn.opcode)) {
     case kMirOpPhi: {
       char* ssaString = NULL;
       if (cUnit->printMe) {
         ssaString = oatGetSSAString(cUnit, mir->ssaRep);
       }
       op->flags.isNop = true;
-      newLIR1(cUnit, kPseudoSSARep, (int) ssaString);
+      newLIR1(cUnit, kPseudoSSARep, reinterpret_cast<uintptr_t>(ssaString));
       break;
     }
     case kMirOpCopy: {
@@ -871,7 +855,7 @@
 
   /* Insert the block label */
   labelList[blockId].opcode = kPseudoNormalBlockLabel;
-  oatAppendLIR(cUnit, (LIR*) &labelList[blockId]);
+  oatAppendLIR(cUnit, &labelList[blockId]);
 
   LIR* headLIR = NULL;
 
@@ -928,7 +912,7 @@
     /* Don't generate the SSA annotation unless verbose mode is on */
     if (cUnit->printMe && mir->ssaRep) {
       char* ssaString = oatGetSSAString(cUnit, mir->ssaRep);
-      newLIR1(cUnit, kPseudoSSARep, (int) ssaString);
+      newLIR1(cUnit, kPseudoSSARep, reinterpret_cast<uintptr_t>(ssaString));
     }
 
     if (opcode == kMirOpCheck) {
@@ -960,7 +944,7 @@
      * Eliminate redundant loads/stores and delay stores into later
      * slots
      */
-    oatApplyLocalOptimizations(cUnit, (LIR*) headLIR, cUnit->lastLIRInsn);
+    oatApplyLocalOptimizations(cUnit, headLIR, cUnit->lastLIRInsn);
 
     /*
      * Generate an unconditional branch to the fallthrough block.
@@ -994,7 +978,7 @@
   BasicBlock*bb = NULL;
   for (int idx = 0; idx < numReachableBlocks; idx++) {
     int dfsIndex = cUnit->dfsOrder.elemList[idx];
-    bb = (BasicBlock*)oatGrowableListGetElement(blockList, dfsIndex);
+    bb = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, dfsIndex));
     if (bb->blockType == kDalvikByteCode) {
       break;
     }
@@ -1020,7 +1004,7 @@
 {
   /* Used to hold the labels of each block */
   cUnit->blockLabelList =
-      (LIR*) oatNew(cUnit, sizeof(LIR) * cUnit->numBlocks, true, kAllocLIR);
+      static_cast<LIR*>(oatNew(cUnit, sizeof(LIR) * cUnit->numBlocks, true, kAllocLIR));
 
   oatDataFlowAnalysisDispatcher(cUnit, methodBlockCodeGen,
                                 kPreOrderDFSTraversal, false /* Iterative */);
diff --git a/src/compiler/codegen/mips/assemble_mips.cc b/src/compiler/codegen/mips/assemble_mips.cc
index 1fa3a6b..79259fb 100644
--- a/src/compiler/codegen/mips/assemble_mips.cc
+++ b/src/compiler/codegen/mips/assemble_mips.cc
@@ -479,7 +479,7 @@
     case kMipsBltz: opcode = kMipsBgez; break;
     case kMipsBnez: opcode = kMipsBeqz; break;
     default:
-      LOG(FATAL) << "Unexpected branch kind " << (int)opcode;
+      LOG(FATAL) << "Unexpected branch kind " << opcode;
   }
   LIR* hopTarget = NULL;
   if (!unconditional) {
@@ -492,11 +492,11 @@
   oatInsertLIRBefore(lir, currPC);
   LIR* anchor = rawLIR(cUnit, dalvikOffset, kPseudoTargetLabel);
   LIR* deltaHi = rawLIR(cUnit, dalvikOffset, kMipsDeltaHi, r_AT, 0,
-                        (uintptr_t)anchor, 0, 0, lir->target);
+                        reinterpret_cast<uintptr_t>(anchor), 0, 0, lir->target);
   oatInsertLIRBefore(lir, deltaHi);
   oatInsertLIRBefore(lir, anchor);
   LIR* deltaLo = rawLIR(cUnit, dalvikOffset, kMipsDeltaLo, r_AT, 0,
-                        (uintptr_t)anchor, 0, 0, lir->target);
+                        reinterpret_cast<uintptr_t>(anchor), 0, 0, lir->target);
   oatInsertLIRBefore(lir, deltaLo);
   LIR* addu = rawLIR(cUnit, dalvikOffset, kMipsAddu, r_AT, r_AT, r_RA);
   oatInsertLIRBefore(lir, addu);
@@ -515,12 +515,12 @@
  * sequence or request that the trace be shortened and retried.
  */
 AssemblerStatus oatAssembleInstructions(CompilationUnit *cUnit,
-                    intptr_t startAddr)
+                    uintptr_t startAddr)
 {
   LIR *lir;
   AssemblerStatus res = kSuccess;  // Assume success
 
-  for (lir = (LIR *) cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
+  for (lir = cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
     if (lir->opcode < 0) {
       continue;
     }
@@ -542,8 +542,8 @@
          * and is found in lir->target.  If operands[3] is non-NULL,
          * then it is a Switch/Data table.
          */
-        int offset1 = ((LIR*)lir->operands[2])->offset;
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[3];
+        int offset1 = (reinterpret_cast<LIR*>(lir->operands[2]))->offset;
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[3]);
         int offset2 = tabRec ? tabRec->offset : lir->target->offset;
         int delta = offset2 - offset1;
         if ((delta & 0xffff) == delta && ((delta & 0x8000) == 0)) {
@@ -555,35 +555,35 @@
               rawLIR(cUnit, lir->dalvikOffset, kMipsDeltaHi,
                      lir->operands[0], 0, lir->operands[2],
                      lir->operands[3], 0, lir->target);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newDeltaHi);
+          oatInsertLIRBefore(lir, newDeltaHi);
           LIR *newDeltaLo =
               rawLIR(cUnit, lir->dalvikOffset, kMipsDeltaLo,
                      lir->operands[0], 0, lir->operands[2],
                      lir->operands[3], 0, lir->target);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newDeltaLo);
+          oatInsertLIRBefore(lir, newDeltaLo);
           LIR *newAddu =
               rawLIR(cUnit, lir->dalvikOffset, kMipsAddu,
                      lir->operands[0], lir->operands[0], r_RA);
-          oatInsertLIRBefore((LIR*)lir, (LIR*)newAddu);
+          oatInsertLIRBefore(lir, newAddu);
           lir->flags.isNop = true;
           res = kRetryAll;
         }
       } else if (lir->opcode == kMipsDeltaLo) {
-        int offset1 = ((LIR*)lir->operands[2])->offset;
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[3];
+        int offset1 = (reinterpret_cast<LIR*>(lir->operands[2]))->offset;
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[3]);
         int offset2 = tabRec ? tabRec->offset : lir->target->offset;
         int delta = offset2 - offset1;
         lir->operands[1] = delta & 0xffff;
       } else if (lir->opcode == kMipsDeltaHi) {
-        int offset1 = ((LIR*)lir->operands[2])->offset;
-        SwitchTable *tabRec = (SwitchTable*)lir->operands[3];
+        int offset1 = (reinterpret_cast<LIR*>(lir->operands[2]))->offset;
+        SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(lir->operands[3]);
         int offset2 = tabRec ? tabRec->offset : lir->target->offset;
         int delta = offset2 - offset1;
         lir->operands[1] = (delta >> 16) & 0xffff;
       } else if (lir->opcode == kMipsB || lir->opcode == kMipsBal) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         if (delta & 0x3) {
           LOG(FATAL) << "PC-rel offset not multiple of 4: " << delta;
@@ -595,9 +595,9 @@
           lir->operands[0] = delta >> 2;
         }
       } else if (lir->opcode >= kMipsBeqz && lir->opcode <= kMipsBnez) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         if (delta & 0x3) {
           LOG(FATAL) << "PC-rel offset not multiple of 4: " << delta;
@@ -609,9 +609,9 @@
           lir->operands[1] = delta >> 2;
         }
       } else if (lir->opcode == kMipsBeq || lir->opcode == kMipsBne) {
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t pc = lir->offset + 4;
-        intptr_t target = targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t pc = lir->offset + 4;
+        uintptr_t target = targetLIR->offset;
         int delta = target - pc;
         if (delta & 0x3) {
           LOG(FATAL) << "PC-rel offset not multiple of 4: " << delta;
@@ -623,8 +623,8 @@
           lir->operands[2] = delta >> 2;
         }
       } else if (lir->opcode == kMipsJal) {
-        intptr_t curPC = (startAddr + lir->offset + 4) & ~3;
-        intptr_t target = lir->operands[0];
+        uintptr_t curPC = (startAddr + lir->offset + 4) & ~3;
+        uintptr_t target = lir->operands[0];
         /* ensure PC-region branch can be used */
         DCHECK_EQ((curPC & 0xF0000000), (target & 0xF0000000));
         if (target & 0x3) {
@@ -632,12 +632,12 @@
         }
         lir->operands[0] =  target >> 2;
       } else if (lir->opcode == kMipsLahi) { /* ld address hi (via lui) */
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t target = startAddr + targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t target = startAddr + targetLIR->offset;
         lir->operands[1] = target >> 16;
       } else if (lir->opcode == kMipsLalo) { /* ld address lo (via ori) */
-        LIR *targetLIR = (LIR *) lir->target;
-        intptr_t target = startAddr + targetLIR->offset;
+        LIR *targetLIR = lir->target;
+        uintptr_t target = startAddr + targetLIR->offset;
         lir->operands[2] = lir->operands[2] + target;
       }
     }
@@ -689,8 +689,7 @@
           bits |= value;
           break;
         default:
-          LOG(FATAL) << "Bad encoder format: "
-                     << (int)encoder->fieldLoc[i].kind;
+          LOG(FATAL) << "Bad encoder format: " << encoder->fieldLoc[i].kind;
       }
     }
     // We only support little-endian MIPS.
@@ -724,9 +723,7 @@
   LIR* mipsLIR;
   int offset = 0;
 
-  for (mipsLIR = (LIR *) cUnit->firstLIRInsn;
-    mipsLIR;
-    mipsLIR = NEXT_LIR(mipsLIR)) {
+  for (mipsLIR = cUnit->firstLIRInsn; mipsLIR; mipsLIR = NEXT_LIR(mipsLIR)) {
     mipsLIR->offset = offset;
     if (mipsLIR->opcode >= 0) {
       if (!mipsLIR->flags.isNop) {
diff --git a/src/compiler/codegen/mips/call_mips.cc b/src/compiler/codegen/mips/call_mips.cc
index bf67b42..1db4eee 100644
--- a/src/compiler/codegen/mips/call_mips.cc
+++ b/src/compiler/codegen/mips/call_mips.cc
@@ -65,14 +65,14 @@
     dumpSparseSwitchTable(table);
   }
   // Add the table to the list - we'll process it later
-  SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable),
-                                              true, kAllocData);
+  SwitchTable *tabRec =
+      static_cast<SwitchTable*>(oatNew(cUnit, sizeof(SwitchTable), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   int elements = table[1];
-  tabRec->targets = (LIR* *)oatNew(cUnit, elements * sizeof(LIR*), true,
-                                   kAllocLIR);
-  oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec);
+  tabRec->targets =
+      static_cast<LIR**>(oatNew(cUnit, elements * sizeof(LIR*), true, kAllocLIR));
+  oatInsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
 
   // The table is composed of 8-byte key/disp pairs
   int byteSize = elements * 8;
@@ -100,7 +100,8 @@
   // Remember base label so offsets can be computed later
   tabRec->anchor = baseLabel;
   int rBase = oatAllocTemp(cUnit);
-  newLIR4(cUnit, kMipsDelta, rBase, 0, (intptr_t)baseLabel, (intptr_t)tabRec);
+  newLIR4(cUnit, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(baseLabel),
+          reinterpret_cast<uintptr_t>(tabRec));
   opRegRegReg(cUnit, kOpAdd, rEnd, rEnd, rBase);
 
   // Grab switch test value
@@ -144,14 +145,13 @@
     dumpPackedSwitchTable(table);
   }
   // Add the table to the list - we'll process it later
-  SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable),
-                        true, kAllocData);
+  SwitchTable *tabRec =
+      static_cast<SwitchTable*>(oatNew(cUnit, sizeof(SwitchTable), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   int size = table[1];
-  tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true,
-                    kAllocLIR);
-  oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec);
+  tabRec->targets = static_cast<LIR**>(oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR));
+  oatInsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
 
   // Get the switch value
   rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
@@ -195,7 +195,8 @@
 
   // Materialize the table base pointer
   int rBase = oatAllocTemp(cUnit);
-  newLIR4(cUnit, kMipsDelta, rBase, 0, (intptr_t)baseLabel, (intptr_t)tabRec);
+  newLIR4(cUnit, kMipsDelta, rBase, 0, reinterpret_cast<uintptr_t>(baseLabel),
+          reinterpret_cast<uintptr_t>(tabRec));
 
   // Load the displacement from the switch table
   int rDisp = oatAllocTemp(cUnit);
@@ -207,7 +208,7 @@
 
   /* branchOver target here */
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
 }
 
 /*
@@ -225,15 +226,15 @@
 {
   const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
   // Add the table to the list - we'll process it later
-  FillArrayData *tabRec = (FillArrayData *)
-     oatNew(cUnit, sizeof(FillArrayData), true, kAllocData);
+  FillArrayData *tabRec =
+      reinterpret_cast<FillArrayData*>(oatNew(cUnit, sizeof(FillArrayData), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   uint16_t width = tabRec->table[1];
   uint32_t size = tabRec->table[2] | ((static_cast<uint32_t>(tabRec->table[3])) << 16);
   tabRec->size = (size * width) + 8;
 
-  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, (intptr_t)tabRec);
+  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, reinterpret_cast<uintptr_t>(tabRec));
 
   // Making a call - use explicit registers
   oatFlushAllRegs(cUnit);   /* Everything to home location */
@@ -251,7 +252,8 @@
   LIR* baseLabel = newLIR0(cUnit, kPseudoTargetLabel);
 
   // Materialize a pointer to the fill data image
-  newLIR4(cUnit, kMipsDelta, rMIPS_ARG1, 0, (intptr_t)baseLabel, (intptr_t)tabRec);
+  newLIR4(cUnit, kMipsDelta, rMIPS_ARG1, 0, reinterpret_cast<uintptr_t>(baseLabel),
+          reinterpret_cast<uintptr_t>(tabRec));
 
   // And go...
   oatClobberCalleeSave(cUnit);
@@ -304,7 +306,7 @@
   storeBaseIndexed(cUnit, regCardBase, regCardNo, regCardBase, 0,
                    kUnsignedByte);
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
   oatFreeTemp(cUnit, regCardBase);
   oatFreeTemp(cUnit, regCardNo);
 }
@@ -328,7 +330,7 @@
    * a leaf *and* our frame size < fudge factor.
    */
   bool skipOverflowCheck = ((cUnit->attrs & METHOD_IS_LEAF) &&
-      ((size_t)cUnit->frameSize < Thread::kStackOverflowReservedBytes));
+      (static_cast<size_t>(cUnit->frameSize) < Thread::kStackOverflowReservedBytes));
   newLIR0(cUnit, kPseudoMethodEntry);
   int checkReg = oatAllocTemp(cUnit);
   int newSP = oatAllocTemp(cUnit);
diff --git a/src/compiler/codegen/mips/fp_mips.cc b/src/compiler/codegen/mips/fp_mips.cc
index 5ee5de4..1954824 100644
--- a/src/compiler/codegen/mips/fp_mips.cc
+++ b/src/compiler/codegen/mips/fp_mips.cc
@@ -57,8 +57,7 @@
   rlSrc1 = loadValue(cUnit, rlSrc1, kFPReg);
   rlSrc2 = loadValue(cUnit, rlSrc2, kFPReg);
   rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-  newLIR3(cUnit, (MipsOpCode)op, rlResult.lowReg, rlSrc1.lowReg,
-          rlSrc2.lowReg);
+  newLIR3(cUnit, op, rlResult.lowReg, rlSrc1.lowReg, rlSrc2.lowReg);
   storeValue(cUnit, rlDest, rlResult);
 
   return false;
@@ -106,8 +105,7 @@
   rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
   DCHECK(rlDest.wide);
   DCHECK(rlResult.wide);
-  newLIR3(cUnit, (MipsOpCode)op, s2d(rlResult.lowReg, rlResult.highReg),
-          s2d(rlSrc1.lowReg, rlSrc1.highReg),
+  newLIR3(cUnit, op, s2d(rlResult.lowReg, rlResult.highReg), s2d(rlSrc1.lowReg, rlSrc1.highReg),
           s2d(rlSrc2.lowReg, rlSrc2.highReg));
   storeValueWide(cUnit, rlDest, rlResult);
   return false;
@@ -155,12 +153,11 @@
   }
   if (rlDest.wide) {
     rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-    newLIR2(cUnit, (MipsOpCode)op, s2d(rlResult.lowReg, rlResult.highReg),
-            srcReg);
+    newLIR2(cUnit, op, s2d(rlResult.lowReg, rlResult.highReg), srcReg);
     storeValueWide(cUnit, rlDest, rlResult);
   } else {
     rlResult = oatEvalLoc(cUnit, rlDest, kFPReg, true);
-    newLIR2(cUnit, (MipsOpCode)op, rlResult.lowReg, srcReg);
+    newLIR2(cUnit, op, rlResult.lowReg, srcReg);
     storeValue(cUnit, rlDest, rlResult);
   }
   return false;
diff --git a/src/compiler/codegen/mips/int_mips.cc b/src/compiler/codegen/mips/int_mips.cc
index 0e1ae62..82ac547 100644
--- a/src/compiler/codegen/mips/int_mips.cc
+++ b/src/compiler/codegen/mips/int_mips.cc
@@ -54,7 +54,7 @@
   oatFreeTemp(cUnit, t0);
   oatFreeTemp(cUnit, t1);
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branch->target = (LIR*)target;
+  branch->target = target;
   storeValue(cUnit, rlDest, rlResult);
 }
 
@@ -107,7 +107,7 @@
       swapped = true;
       break;
     default:
-      LOG(FATAL) << "No support for ConditionCode: " << (int) cond;
+      LOG(FATAL) << "No support for ConditionCode: " << cond;
       return NULL;
   }
   if (cmpZero) {
@@ -177,7 +177,7 @@
 LIR* opRegCopy(CompilationUnit *cUnit, int rDest, int rSrc)
 {
   LIR *res = opRegCopyNoInsert(cUnit, rDest, rSrc);
-  oatAppendLIR(cUnit, (LIR*)res);
+  oatAppendLIR(cUnit, res);
   return res;
 }
 
diff --git a/src/compiler/codegen/mips/mips_lir.h b/src/compiler/codegen/mips/mips_lir.h
index 4b604d2..b6f686d 100644
--- a/src/compiler/codegen/mips/mips_lir.h
+++ b/src/compiler/codegen/mips/mips_lir.h
@@ -163,7 +163,7 @@
   kMipsRegEnd   = 51,
 };
 
-#define ENCODE_MIPS_REG_LIST(N)      ((uint64_t) N)
+#define ENCODE_MIPS_REG_LIST(N)      (static_cast<uint64_t>(N))
 #define ENCODE_MIPS_REG_SP           (1ULL << kMipsRegSP)
 #define ENCODE_MIPS_REG_LR           (1ULL << kMipsRegLR)
 #define ENCODE_MIPS_REG_PC           (1ULL << kMipsRegPC)
@@ -303,7 +303,7 @@
 #define kST kSYNC0
 #define kSY kSYNC0
 
-#define isPseudoOpcode(opCode) ((int)(opCode) < 0)
+#define isPseudoOpcode(opCode) (static_cast<int>(opCode) < 0)
 
 /*
  * The following enum defines the list of supported Thumb instructions by the
diff --git a/src/compiler/codegen/mips/target_mips.cc b/src/compiler/codegen/mips/target_mips.cc
index a5a8d7e..e157760 100644
--- a/src/compiler/codegen/mips/target_mips.cc
+++ b/src/compiler/codegen/mips/target_mips.cc
@@ -199,7 +199,7 @@
         strcpy(tbuf, "!");
       } else {
          DCHECK_LT(fmt, fmtEnd);
-         DCHECK_LT((unsigned)(nc-'0'), 4u);
+         DCHECK_LT(static_cast<unsigned>(nc-'0'), 4u);
          operand = lir->operands[nc-'0'];
          switch (*fmt++) {
            case 'b':
@@ -233,19 +233,19 @@
              sprintf(tbuf,"%d", operand*2);
              break;
            case 't':
-             sprintf(tbuf,"0x%08x (L%p)", (int) baseAddr + lir->offset + 4 +
+             sprintf(tbuf,"0x%08x (L%p)", reinterpret_cast<uintptr_t>(baseAddr) + lir->offset + 4 +
                      (operand << 2), lir->target);
              break;
            case 'T':
-             sprintf(tbuf,"0x%08x", (int) (operand << 2));
+             sprintf(tbuf,"0x%08x", operand << 2);
              break;
            case 'u': {
              int offset_1 = lir->operands[0];
              int offset_2 = NEXT_LIR(lir)->operands[0];
-             intptr_t target =
-                 ((((intptr_t) baseAddr + lir->offset + 4) & ~3) +
+             uintptr_t target =
+                 (((reinterpret_cast<uintptr_t>(baseAddr) + lir->offset + 4) & ~3) +
                  (offset_1 << 21 >> 9) + (offset_2 << 1)) & 0xfffffffc;
-             sprintf(tbuf, "%p", (void *) target);
+             sprintf(tbuf, "%p", reinterpret_cast<void*>(target));
              break;
           }
 
@@ -275,11 +275,10 @@
 }
 
 // FIXME: need to redo resource maps for MIPS - fix this at that time
-void oatDumpResourceMask(LIR *lir, uint64_t mask, const char *prefix)
+void oatDumpResourceMask(LIR *mipsLIR, uint64_t mask, const char *prefix)
 {
   char buf[256];
   buf[0] = 0;
-  LIR *mipsLIR = (LIR *) lir;
 
   if (mask == ENCODE_ALL) {
     strcpy(buf, "all");
@@ -467,12 +466,6 @@
   oatFreeTemp(cUnit, rMIPS_ARG3);
 }
 
-/* Convert an instruction to a NOP */
-void oatNopLIR( LIR* lir)
-{
-  ((LIR*)lir)->flags.isNop = true;
-}
-
 /*
  * Determine the initial instruction set to be used for this trace.
  * Later components may decide to change this.
@@ -544,17 +537,15 @@
   int numFPRegs = 0;
   int numFPTemps = 0;
 #endif
-  RegisterPool *pool = (RegisterPool *)oatNew(cUnit, sizeof(*pool), true,
-                        kAllocRegAlloc);
+  RegisterPool *pool =
+      static_cast<RegisterPool*>(oatNew(cUnit, sizeof(*pool), true, kAllocRegAlloc));
   cUnit->regPool = pool;
   pool->numCoreRegs = numRegs;
-  pool->coreRegs = (RegisterInfo *)
-      oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs),
-             true, kAllocRegAlloc);
+  pool->coreRegs = static_cast<RegisterInfo*>
+     (oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs), true, kAllocRegAlloc));
   pool->numFPRegs = numFPRegs;
-  pool->FPRegs = (RegisterInfo *)
-      oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs), true,
-             kAllocRegAlloc);
+  pool->FPRegs = static_cast<RegisterInfo*>
+      (oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs), true, kAllocRegAlloc));
   oatInitPool(pool->coreRegs, coreRegs, pool->numCoreRegs);
   oatInitPool(pool->FPRegs, fpRegs, pool->numFPRegs);
   // Keep special registers from being allocated
@@ -573,9 +564,8 @@
     oatMarkTemp(cUnit, fpTemps[i]);
   }
   // Construct the alias map.
-  cUnit->phiAliasMap = (int*)oatNew(cUnit, cUnit->numSSARegs *
-                                    sizeof(cUnit->phiAliasMap[0]), false,
-                                    kAllocDFInfo);
+  cUnit->phiAliasMap = static_cast<int*>
+      (oatNew(cUnit, cUnit->numSSARegs * sizeof(cUnit->phiAliasMap[0]), false, kAllocDFInfo));
   for (int i = 0; i < cUnit->numSSARegs; i++) {
     cUnit->phiAliasMap[i] = i;
   }
@@ -645,48 +635,11 @@
   opRegImm(cUnit, kOpAdd, rMIPS_SP, cUnit->frameSize);
 }
 
-/*
- * Nop any unconditional branches that go to the next instruction.
- * Note: new redundant branches may be inserted later, and we'll
- * use a check in final instruction assembly to nop those out.
- */
-void removeRedundantBranches(CompilationUnit* cUnit)
+bool branchUnconditional(LIR* lir)
 {
-  LIR* thisLIR;
-
-  for (thisLIR = (LIR*) cUnit->firstLIRInsn;
-     thisLIR != (LIR*) cUnit->lastLIRInsn;
-     thisLIR = NEXT_LIR(thisLIR)) {
-
-    /* Branch to the next instruction */
-    if (thisLIR->opcode == kMipsB) {
-      LIR* nextLIR = thisLIR;
-
-      while (true) {
-        nextLIR = NEXT_LIR(nextLIR);
-
-        /*
-         * Is the branch target the next instruction?
-         */
-        if (nextLIR == (LIR*) thisLIR->target) {
-          thisLIR->flags.isNop = true;
-          break;
-        }
-
-        /*
-         * Found real useful stuff between the branch and the target.
-         * Need to explicitly check the lastLIRInsn here because it
-         * might be the last real instruction.
-         */
-        if (!isPseudoOpcode(nextLIR->opcode) ||
-          (nextLIR = (LIR*) cUnit->lastLIRInsn))
-          break;
-      }
-    }
-  }
+  return (lir->opcode == kMipsB);
 }
 
-
 /* Common initialization routine for an architecture family */
 bool oatArchInit()
 {
@@ -695,8 +648,7 @@
   for (i = 0; i < kMipsLast; i++) {
     if (EncodingMap[i].opcode != i) {
       LOG(FATAL) << "Encoding order for " << EncodingMap[i].name <<
-         " is wrong: expecting " << i << ", seeing " <<
-         (int)EncodingMap[i].opcode;
+         " is wrong: expecting " << i << ", seeing " << static_cast<int>(EncodingMap[i].opcode);
     }
   }
 
diff --git a/src/compiler/codegen/ralloc_util.cc b/src/compiler/codegen/ralloc_util.cc
index 4b66ddf..efdbd32 100644
--- a/src/compiler/codegen/ralloc_util.cc
+++ b/src/compiler/codegen/ralloc_util.cc
@@ -67,8 +67,8 @@
     LOG(INFO) << StringPrintf(
         "R[%d]: T:%d, U:%d, P:%d, p:%d, LV:%d, D:%d, SR:%d, ST:%x, EN:%x",
         p[i].reg, p[i].isTemp, p[i].inUse, p[i].pair, p[i].partner,
-        p[i].live, p[i].dirty, p[i].sReg,(int)p[i].defStart,
-        (int)p[i].defEnd);
+        p[i].live, p[i].dirty, p[i].sReg, reinterpret_cast<uintptr_t>(p[i].defStart),
+        reinterpret_cast<uintptr_t>(p[i].defEnd));
   }
   LOG(INFO) << "================================================";
 }
@@ -1077,8 +1077,8 @@
 /* qsort callback function, sort descending */
 int oatSortCounts(const void *val1, const void *val2)
 {
-  const RefCounts* op1 = (const RefCounts*)val1;
-  const RefCounts* op2 = (const RefCounts*)val2;
+  const RefCounts* op1 = reinterpret_cast<const RefCounts*>(val1);
+  const RefCounts* op2 = reinterpret_cast<const RefCounts*>(val2);
   return (op1->count == op2->count) ? 0 : (op1->count < op2->count ? 1 : -1);
 }
 
@@ -1115,10 +1115,10 @@
    * TUNING: replace with linear scan once we have the ability
    * to describe register live ranges for GC.
    */
-  RefCounts *coreRegs = (RefCounts *)
-      oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
-  RefCounts *fpRegs = (RefCounts *)
-      oatNew(cUnit, sizeof(RefCounts) * numRegs, true, kAllocRegAlloc);
+  RefCounts *coreRegs = static_cast<RefCounts*>(oatNew(cUnit, sizeof(RefCounts) * numRegs,
+                                                       true, kAllocRegAlloc));
+  RefCounts *fpRegs = static_cast<RefCounts *>(oatNew(cUnit, sizeof(RefCounts) * numRegs,
+                                                      true, kAllocRegAlloc));
   // Set ssa names for original Dalvik registers
   for (int i = 0; i < dalvikRegs; i++) {
     coreRegs[i].sReg = fpRegs[i].sReg = i;
@@ -1128,7 +1128,7 @@
   fpRegs[dalvikRegs].sReg = cUnit->methodSReg;  // For consistecy
   // Set ssa names for compilerTemps
   for (int i = 1; i <= cUnit->numCompilerTemps; i++) {
-    CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
+    CompilerTemp* ct = reinterpret_cast<CompilerTemp*>(cUnit->compilerTemps.elemList[i]);
     coreRegs[dalvikRegs + i].sReg = ct->sReg;
     fpRegs[dalvikRegs + i].sReg = ct->sReg;
   }
@@ -1137,7 +1137,7 @@
   oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
   while (true) {
     BasicBlock* bb;
-    bb = (BasicBlock*)oatGrowableListIteratorNext(&iterator);
+    bb = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iterator));
     if (bb == NULL) break;
     oatCountRefs(cUnit, bb, coreRegs, fpRegs);
   }
diff --git a/src/compiler/codegen/target_list.h b/src/compiler/codegen/target_list.h
index 2ada073..dba00f5 100644
--- a/src/compiler/codegen/target_list.h
+++ b/src/compiler/codegen/target_list.h
@@ -1,5 +1,5 @@
 ArmConditionCode oatArmConditionEncoding(ConditionCode code);
-AssemblerStatus oatAssembleInstructions(CompilationUnit* cUnit, intptr_t startAddr);
+AssemblerStatus oatAssembleInstructions(CompilationUnit* cUnit, uintptr_t startAddr);
 bool doubleReg(int reg);
 bool fpReg(int reg);
 bool genAddLong(CompilationUnit* cUnit, RegLocation rlDest, RegLocation rlSrc1, RegLocation rlSrc2);
@@ -136,7 +136,7 @@
 void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi, int srcLo, int srcHi);
 void opRegThreadMem(CompilationUnit* cUnit, OpKind op, int rDest, int threadOffset);
 void opTlsCmp(CompilationUnit* cUnit, int offset, int val);
-void removeRedundantBranches(CompilationUnit* cUnit);
+bool branchUnconditional(LIR* lir);
 void setupTargetResourceMasks(CompilationUnit* cUnit, LIR* lir);
 void spillCoreRegs(CompilationUnit* cUnit);
 void unSpillCoreRegs(CompilationUnit* cUnit);
diff --git a/src/compiler/codegen/x86/assemble_x86.cc b/src/compiler/codegen/x86/assemble_x86.cc
index 63d2b83..0c2ff0d 100644
--- a/src/compiler/codegen/x86/assemble_x86.cc
+++ b/src/compiler/codegen/x86/assemble_x86.cc
@@ -557,7 +557,7 @@
     reg = reg & X86_FP_REG_MASK;
   }
   if (reg >= 4) {
-    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << (int) reg
+    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << static_cast<int>(reg)
         << " in " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
   }
   DCHECK_LT(reg, 8);
@@ -614,7 +614,7 @@
     reg = reg & X86_FP_REG_MASK;
   }
   if (reg >= 4) {
-    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << (int) reg
+    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << static_cast<int>(reg)
         << " in " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
   }
   DCHECK_LT(reg, 8);
@@ -705,7 +705,7 @@
     reg = reg & X86_FP_REG_MASK;
   }
   if (reg >= 4) {
-    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << (int) reg
+    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << static_cast<int>(reg)
         << " in " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
   }
   DCHECK_LT(reg, 8);
@@ -958,7 +958,7 @@
     DCHECK_EQ(0, entry->skeleton.extra_opcode2);
   }
   if (reg >= 4) {
-    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << (int) reg
+    DCHECK(strchr(entry->name, '8') == NULL) << entry->name << " " << static_cast<int>(reg)
         << " in " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
   }
   DCHECK_LT(reg, 8);
@@ -1118,11 +1118,11 @@
                       int base_or_table, uint8_t index, int scale, int table_or_disp) {
   int disp;
   if (entry->opcode == kX86PcRelLoadRA) {
-    SwitchTable *tabRec = (SwitchTable*)table_or_disp;
+    SwitchTable *tabRec = reinterpret_cast<SwitchTable*>(table_or_disp);
     disp = tabRec->offset;
   } else {
     DCHECK(entry->opcode == kX86PcRelAdr);
-    FillArrayData *tabRec = (FillArrayData *)base_or_table;
+    FillArrayData *tabRec = reinterpret_cast<FillArrayData*>(base_or_table);
     disp = tabRec->offset;
   }
   if (entry->skeleton.prefix1 != 0) {
@@ -1189,12 +1189,12 @@
  * instruction.  In those cases we will try to substitute a new code
  * sequence or request that the trace be shortened and retried.
  */
-AssemblerStatus oatAssembleInstructions(CompilationUnit *cUnit, intptr_t startAddr) {
+AssemblerStatus oatAssembleInstructions(CompilationUnit *cUnit, uintptr_t startAddr) {
   LIR *lir;
   AssemblerStatus res = kSuccess;  // Assume success
 
   const bool kVerbosePcFixup = false;
-  for (lir = (LIR *) cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
+  for (lir = cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) {
     if (lir->opcode < 0) {
       continue;
     }
@@ -1209,13 +1209,13 @@
           LIR *targetLIR = lir->target;
           DCHECK(targetLIR != NULL);
           int delta = 0;
-          intptr_t pc;
+          uintptr_t pc;
           if (IS_SIMM8(lir->operands[0])) {
             pc = lir->offset + 2 /* opcode + rel8 */;
           } else {
             pc = lir->offset + 6 /* 2 byte opcode + rel32 */;
           }
-          intptr_t target = targetLIR->offset;
+          uintptr_t target = targetLIR->offset;
           delta = target - pc;
           if (IS_SIMM8(delta) != IS_SIMM8(lir->operands[0])) {
             if (kVerbosePcFixup) {
@@ -1239,8 +1239,8 @@
         case kX86Jcc32: {
           LIR *targetLIR = lir->target;
           DCHECK(targetLIR != NULL);
-          intptr_t pc = lir->offset + 6 /* 2 byte opcode + rel32 */;
-          intptr_t target = targetLIR->offset;
+          uintptr_t pc = lir->offset + 6 /* 2 byte opcode + rel32 */;
+          uintptr_t target = targetLIR->offset;
           int delta = target - pc;
           if (kVerbosePcFixup) {
             LOG(INFO) << "Source:";
@@ -1256,13 +1256,13 @@
           LIR *targetLIR = lir->target;
           DCHECK(targetLIR != NULL);
           int delta = 0;
-          intptr_t pc;
+          uintptr_t pc;
           if (IS_SIMM8(lir->operands[0])) {
             pc = lir->offset + 2 /* opcode + rel8 */;
           } else {
             pc = lir->offset + 5 /* opcode + rel32 */;
           }
-          intptr_t target = targetLIR->offset;
+          uintptr_t target = targetLIR->offset;
           delta = target - pc;
           if (!(cUnit->disableOpt & (1 << kSafeOptimizations)) && delta == 0) {
             // Useless branch
@@ -1285,8 +1285,8 @@
         case kX86Jmp32: {
           LIR *targetLIR = lir->target;
           DCHECK(targetLIR != NULL);
-          intptr_t pc = lir->offset + 5 /* opcode + rel32 */;
-          intptr_t target = targetLIR->offset;
+          uintptr_t pc = lir->offset + 5 /* opcode + rel32 */;
+          uintptr_t target = targetLIR->offset;
           int delta = target - pc;
           lir->operands[0] = delta;
           break;
@@ -1423,9 +1423,7 @@
     LIR* x86LIR;
     int offset = 0;
 
-    for (x86LIR = (LIR *) cUnit->firstLIRInsn;
-        x86LIR;
-        x86LIR = NEXT_LIR(x86LIR)) {
+    for (x86LIR = cUnit->firstLIRInsn; x86LIR; x86LIR = NEXT_LIR(x86LIR)) {
         x86LIR->offset = offset;
         if (x86LIR->opcode >= 0) {
             if (!x86LIR->flags.isNop) {
diff --git a/src/compiler/codegen/x86/call_x86.cc b/src/compiler/codegen/x86/call_x86.cc
index 2b52270..c2b456f 100644
--- a/src/compiler/codegen/x86/call_x86.cc
+++ b/src/compiler/codegen/x86/call_x86.cc
@@ -38,8 +38,8 @@
     dumpSparseSwitchTable(table);
   }
   int entries = table[1];
-  int* keys = (int*)&table[2];
-  int* targets = &keys[entries];
+  const int* keys = reinterpret_cast<const int*>(&table[2]);
+  const int* targets = &keys[entries];
   rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
   for (int i = 0; i < entries; i++) {
     int key = keys[i];
@@ -76,14 +76,13 @@
     dumpPackedSwitchTable(table);
   }
   // Add the table to the list - we'll process it later
-  SwitchTable *tabRec = (SwitchTable *)oatNew(cUnit, sizeof(SwitchTable),
-                                              true, kAllocData);
+  SwitchTable *tabRec =
+      static_cast<SwitchTable *>(oatNew(cUnit, sizeof(SwitchTable), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   int size = table[1];
-  tabRec->targets = (LIR* *)oatNew(cUnit, size * sizeof(LIR*), true,
-                                   kAllocLIR);
-  oatInsertGrowableList(cUnit, &cUnit->switchTables, (intptr_t)tabRec);
+  tabRec->targets = static_cast<LIR**>(oatNew(cUnit, size * sizeof(LIR*), true, kAllocLIR));
+  oatInsertGrowableList(cUnit, &cUnit->switchTables, reinterpret_cast<uintptr_t>(tabRec));
 
   // Get the switch value
   rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
@@ -107,7 +106,7 @@
   // Load the displacement from the switch table
   int dispReg = oatAllocTemp(cUnit);
   newLIR5(cUnit, kX86PcRelLoadRA, dispReg, startOfMethodReg, keyReg, 2,
-          (intptr_t)tabRec);
+          reinterpret_cast<uintptr_t>(tabRec));
   // Add displacement to start of method
   opRegReg(cUnit, kOpAdd, startOfMethodReg, dispReg);
   // ..and go!
@@ -116,7 +115,7 @@
 
   /* branchOver target here */
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
 }
 
 void callRuntimeHelperRegReg(CompilationUnit* cUnit, int helperOffset,
@@ -136,25 +135,25 @@
 {
   const uint16_t* table = cUnit->insns + cUnit->currentDalvikOffset + tableOffset;
   // Add the table to the list - we'll process it later
-  FillArrayData *tabRec = (FillArrayData *)oatNew(cUnit, sizeof(FillArrayData),
-      true, kAllocData);
+  FillArrayData *tabRec =
+      static_cast<FillArrayData*>(oatNew(cUnit, sizeof(FillArrayData), true, kAllocData));
   tabRec->table = table;
   tabRec->vaddr = cUnit->currentDalvikOffset;
   uint16_t width = tabRec->table[1];
   uint32_t size = tabRec->table[2] | ((static_cast<uint32_t>(tabRec->table[3])) << 16);
   tabRec->size = (size * width) + 8;
 
-  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, (intptr_t)tabRec);
+  oatInsertGrowableList(cUnit, &cUnit->fillArrayData, reinterpret_cast<uintptr_t>(tabRec));
 
   // Making a call - use explicit registers
   oatFlushAllRegs(cUnit);   /* Everything to home location */
   loadValueDirectFixed(cUnit, rlSrc, rX86_ARG0);
   // Materialize a pointer to the fill data image
   newLIR1(cUnit, kX86StartOfMethod, rX86_ARG2);
-  newLIR2(cUnit, kX86PcRelAdr, rX86_ARG1, (intptr_t)tabRec);
+  newLIR2(cUnit, kX86PcRelAdr, rX86_ARG1, reinterpret_cast<uintptr_t>(tabRec));
   newLIR2(cUnit, kX86Add32RR, rX86_ARG1, rX86_ARG2);
-  callRuntimeHelperRegReg(cUnit, ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode), rX86_ARG0, rX86_ARG1,
-                          true);
+  callRuntimeHelperRegReg(cUnit, ENTRYPOINT_OFFSET(pHandleFillArrayDataFromCode), rX86_ARG0,
+                          rX86_ARG1, true);
 }
 
 void genMonitorEnter(CompilationUnit* cUnit, int optFlags, RegLocation rlSrc)
@@ -209,7 +208,7 @@
   storeBaseIndexed(cUnit, regCardBase, regCardNo, regCardBase, 0,
                    kUnsignedByte);
   LIR* target = newLIR0(cUnit, kPseudoTargetLabel);
-  branchOver->target = (LIR*)target;
+  branchOver->target = target;
   oatFreeTemp(cUnit, regCardBase);
   oatFreeTemp(cUnit, regCardNo);
 }
@@ -235,7 +234,7 @@
    * a leaf *and* our frame size < fudge factor.
    */
   bool skipOverflowCheck = ((cUnit->attrs & METHOD_IS_LEAF) &&
-                ((size_t)cUnit->frameSize <
+                (static_cast<size_t>(cUnit->frameSize) <
                 Thread::kStackOverflowReservedBytes));
   newLIR0(cUnit, kPseudoMethodEntry);
   /* Spill core callee saves */
@@ -248,7 +247,7 @@
     opRegThreadMem(cUnit, kOpCmp, rX86_SP, Thread::StackEndOffset().Int32Value());
     opCondBranch(cUnit, kCondUlt, tgt);
     // Remember branch target - will process later
-    oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
+    oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, reinterpret_cast<uintptr_t>(tgt));
   }
 
   flushIns(cUnit, argLocs, rlMethod);
diff --git a/src/compiler/codegen/x86/fp_x86.cc b/src/compiler/codegen/x86/fp_x86.cc
index 411bd1e..37e9168 100644
--- a/src/compiler/codegen/x86/fp_x86.cc
+++ b/src/compiler/codegen/x86/fp_x86.cc
@@ -324,7 +324,7 @@
       ccode = kCondCc;
       break;
     default:
-      LOG(FATAL) << "Unexpected ccode: " << (int)ccode;
+      LOG(FATAL) << "Unexpected ccode: " << ccode;
   }
   opCondBranch(cUnit, ccode, taken);
 }
diff --git a/src/compiler/codegen/x86/int_x86.cc b/src/compiler/codegen/x86/int_x86.cc
index 1673b55..bcb51c4 100644
--- a/src/compiler/codegen/x86/int_x86.cc
+++ b/src/compiler/codegen/x86/int_x86.cc
@@ -29,7 +29,7 @@
   opRegMem(cUnit, kOpCmp, reg1, base, offset);
   LIR* branch = opCondBranch(cUnit, cCode, tgt);
   // Remember branch target - will process later
-  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
+  oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, reinterpret_cast<uintptr_t>(tgt));
   return branch;
 }
 
@@ -208,7 +208,7 @@
     case kCondGe:
       break;
     default:
-      LOG(FATAL) << "Unexpected ccode: " << (int)ccode;
+      LOG(FATAL) << "Unexpected ccode: " << ccode;
   }
   opCondBranch(cUnit, ccode, taken);
 }
diff --git a/src/compiler/codegen/x86/target_x86.cc b/src/compiler/codegen/x86/target_x86.cc
index a254876..b6440a7 100644
--- a/src/compiler/codegen/x86/target_x86.cc
+++ b/src/compiler/codegen/x86/target_x86.cc
@@ -281,11 +281,10 @@
   return buf;
 }
 
-void oatDumpResourceMask(LIR *lir, uint64_t mask, const char *prefix)
+void oatDumpResourceMask(LIR *x86LIR, uint64_t mask, const char *prefix)
 {
   char buf[256];
   buf[0] = 0;
-  LIR *x86LIR = (LIR *) lir;
 
   if (mask == ENCODE_ALL) {
     strcpy(buf, "all");
@@ -437,12 +436,6 @@
   oatFreeTemp(cUnit, rX86_ARG3);
 }
 
-/* Convert an instruction to a NOP */
-void oatNopLIR( LIR* lir)
-{
-  ((LIR*)lir)->flags.isNop = true;
-}
-
 /*
  * Determine the initial instruction set to be used for this trace.
  * Later components may decide to change this.
@@ -502,17 +495,17 @@
   int numTemps = sizeof(coreTemps)/sizeof(*coreTemps);
   int numFPRegs = sizeof(fpRegs)/sizeof(*fpRegs);
   int numFPTemps = sizeof(fpTemps)/sizeof(*fpTemps);
-  RegisterPool *pool = (RegisterPool *)oatNew(cUnit, sizeof(*pool), true,
-                                              kAllocRegAlloc);
+  RegisterPool *pool =
+      static_cast<RegisterPool*>(oatNew(cUnit, sizeof(*pool), true, kAllocRegAlloc));
   cUnit->regPool = pool;
   pool->numCoreRegs = numRegs;
-  pool->coreRegs = (RegisterInfo *)
-      oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs), true,
-             kAllocRegAlloc);
+  pool->coreRegs =
+      static_cast<RegisterInfo*>(oatNew(cUnit, numRegs * sizeof(*cUnit->regPool->coreRegs),
+                                             true, kAllocRegAlloc));
   pool->numFPRegs = numFPRegs;
-  pool->FPRegs = (RegisterInfo *)
-      oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs), true,
-             kAllocRegAlloc);
+  pool->FPRegs =
+      static_cast<RegisterInfo *>(oatNew(cUnit, numFPRegs * sizeof(*cUnit->regPool->FPRegs),
+                                              true, kAllocRegAlloc));
   oatInitPool(pool->coreRegs, coreRegs, pool->numCoreRegs);
   oatInitPool(pool->FPRegs, fpRegs, pool->numFPRegs);
   // Keep special registers from being allocated
@@ -527,9 +520,8 @@
     oatMarkTemp(cUnit, fpTemps[i]);
   }
   // Construct the alias map.
-  cUnit->phiAliasMap = (int*)oatNew(cUnit, cUnit->numSSARegs *
-                                    sizeof(cUnit->phiAliasMap[0]), false,
-                                    kAllocDFInfo);
+  cUnit->phiAliasMap = static_cast<int*>
+      (oatNew(cUnit, cUnit->numSSARegs * sizeof(cUnit->phiAliasMap[0]), false, kAllocDFInfo));
   for (int i = 0; i < cUnit->numSSARegs; i++) {
     cUnit->phiAliasMap[i] = i;
   }
@@ -586,44 +578,9 @@
   }
 }
 
-/*
- * Nop any unconditional branches that go to the next instruction.
- * Note: new redundant branches may be inserted later, and we'll
- * use a check in final instruction assembly to nop those out.
- */
-void removeRedundantBranches(CompilationUnit* cUnit) {
-  LIR* thisLIR;
-
-  for (thisLIR = (LIR*) cUnit->firstLIRInsn;
-    thisLIR != (LIR*) cUnit->lastLIRInsn;
-    thisLIR = NEXT_LIR(thisLIR)) {
-
-  /* Branch to the next instruction */
-  if (thisLIR->opcode == kX86Jmp8 || thisLIR->opcode == kX86Jmp32) {
-    LIR* nextLIR = thisLIR;
-
-    while (true) {
-      nextLIR = NEXT_LIR(nextLIR);
-
-      /*
-       * Is the branch target the next instruction?
-       */
-      if (nextLIR == (LIR*) thisLIR->target) {
-        thisLIR->flags.isNop = true;
-        break;
-      }
-
-      /*
-       * Found real useful stuff between the branch and the target.
-       * Need to explicitly check the lastLIRInsn here because it
-       * might be the last real instruction.
-       */
-      if (!isPseudoOpcode(nextLIR->opcode) ||
-          (nextLIR = (LIR*) cUnit->lastLIRInsn))
-        break;
-      }
-    }
-  }
+bool branchUnconditional(LIR* lir)
+{
+  return (lir->opcode == kX86Jmp8 || lir->opcode == kX86Jmp32);
 }
 
 /* Common initialization routine for an architecture family */
@@ -634,7 +591,7 @@
     if (EncodingMap[i].opcode != i) {
       LOG(FATAL) << "Encoding order for " << EncodingMap[i].name
                  << " is wrong: expecting " << i << ", seeing "
-                 << (int)EncodingMap[i].opcode;
+                 << static_cast<int>(EncodingMap[i].opcode);
     }
   }
 
diff --git a/src/compiler/codegen/x86/x86_lir.h b/src/compiler/codegen/x86/x86_lir.h
index 3008bc2..9f29d08 100644
--- a/src/compiler/codegen/x86/x86_lir.h
+++ b/src/compiler/codegen/x86/x86_lir.h
@@ -220,7 +220,7 @@
 #define rX86_COUNT rCX
 #define rX86_PC INVALID_REG
 
-#define isPseudoOpcode(opCode) ((int)(opCode) < 0)
+#define isPseudoOpcode(opCode) (static_cast<int>(opCode) < 0)
 
 /*
  * The following enum defines the list of supported X86 instructions by the
diff --git a/src/compiler/compiler_enums.h b/src/compiler/compiler_enums.h
new file mode 100644
index 0000000..3895924
--- /dev/null
+++ b/src/compiler/compiler_enums.h
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_COMPILERENUMS_H_
+#define ART_SRC_COMPILER_COMPILERENUMS_H_
+
+#include "dex_instruction.h"
+
+namespace art {
+
+enum RegisterClass {
+  kCoreReg,
+  kFPReg,
+  kAnyReg,
+};
+
+enum SpecialTargetRegister {
+  kSelf,            // Thread
+  kSuspend,         // Used to reduce suspend checks
+  kLr,
+  kPc,
+  kSp,
+  kArg0,
+  kArg1,
+  kArg2,
+  kArg3,
+  kFArg0,
+  kFArg1,
+  kFArg2,
+  kFArg3,
+  kRet0,
+  kRet1,
+  kInvokeTgt,
+  kCount
+};
+
+enum RegLocationType {
+  kLocDalvikFrame = 0, // Normal Dalvik register
+  kLocPhysReg,
+  kLocCompilerTemp,
+  kLocInvalid
+};
+
+enum BBType {
+  kEntryBlock,
+  kDalvikByteCode,
+  kExitBlock,
+  kExceptionHandling,
+  kDead,
+};
+
+/*
+ * Def/Use encoding in 64-bit useMask/defMask.  Low positions used for target-specific
+ * registers (and typically use the register number as the position).  High positions
+ * reserved for common and abstract resources.
+ */
+
+enum ResourceEncodingPos {
+  kMustNotAlias = 63,
+  kHeapRef = 62,          // Default memory reference type
+  kLiteral = 61,          // Literal pool memory reference
+  kDalvikReg = 60,        // Dalvik vReg memory reference
+  kFPStatus = 59,
+  kCCode = 58,
+  kLowestCommonResource = kCCode
+};
+
+/* Shared pseudo opcodes - must be < 0 */
+enum LIRPseudoOpcode {
+  kPseudoExportedPC = -18,
+  kPseudoSafepointPC = -17,
+  kPseudoIntrinsicRetry = -16,
+  kPseudoSuspendTarget = -15,
+  kPseudoThrowTarget = -14,
+  kPseudoCaseLabel = -13,
+  kPseudoMethodEntry = -12,
+  kPseudoMethodExit = -11,
+  kPseudoBarrier = -10,
+  kPseudoExtended = -9,
+  kPseudoSSARep = -8,
+  kPseudoEntryBlock = -7,
+  kPseudoExitBlock = -6,
+  kPseudoTargetLabel = -5,
+  kPseudoDalvikByteCodeBoundary = -4,
+  kPseudoPseudoAlign4 = -3,
+  kPseudoEHBlockLabel = -2,
+  kPseudoNormalBlockLabel = -1,
+};
+
+enum ExtendedMIROpcode {
+  kMirOpFirst = kNumPackedOpcodes,
+  kMirOpPhi = kMirOpFirst,
+  kMirOpCopy,
+  kMirOpFusedCmplFloat,
+  kMirOpFusedCmpgFloat,
+  kMirOpFusedCmplDouble,
+  kMirOpFusedCmpgDouble,
+  kMirOpFusedCmpLong,
+  kMirOpNop,
+  kMirOpNullCheck,
+  kMirOpRangeCheck,
+  kMirOpDivZeroCheck,
+  kMirOpCheck,
+  kMirOpLast,
+};
+
+enum MIROptimizationFlagPositons {
+  kMIRIgnoreNullCheck = 0,
+  kMIRNullCheckOnly,
+  kMIRIgnoreRangeCheck,
+  kMIRRangeCheckOnly,
+  kMIRInlined,                        // Invoke is inlined (ie dead)
+  kMIRInlinedPred,                    // Invoke is inlined via prediction
+  kMIRCallee,                         // Instruction is inlined from callee
+  kMIRIgnoreSuspendCheck,
+  kMIRDup,
+  kMIRMark,                           // Temporary node mark
+};
+
+/* For successorBlockList */
+enum BlockListType {
+  kNotUsed = 0,
+  kCatch,
+  kPackedSwitch,
+  kSparseSwitch,
+};
+
+enum AssemblerStatus {
+  kSuccess,
+  kRetryAll,
+};
+
+enum OpSize {
+  kWord,
+  kLong,
+  kSingle,
+  kDouble,
+  kUnsignedHalf,
+  kSignedHalf,
+  kUnsignedByte,
+  kSignedByte,
+};
+
+std::ostream& operator<<(std::ostream& os, const OpSize& kind);
+
+enum OpKind {
+  kOpMov,
+  kOpMvn,
+  kOpCmp,
+  kOpLsl,
+  kOpLsr,
+  kOpAsr,
+  kOpRor,
+  kOpNot,
+  kOpAnd,
+  kOpOr,
+  kOpXor,
+  kOpNeg,
+  kOpAdd,
+  kOpAdc,
+  kOpSub,
+  kOpSbc,
+  kOpRsub,
+  kOpMul,
+  kOpDiv,
+  kOpRem,
+  kOpBic,
+  kOpCmn,
+  kOpTst,
+  kOpBkpt,
+  kOpBlx,
+  kOpPush,
+  kOpPop,
+  kOp2Char,
+  kOp2Short,
+  kOp2Byte,
+  kOpCondBr,
+  kOpUncondBr,
+  kOpBx,
+  kOpInvalid,
+};
+
+std::ostream& operator<<(std::ostream& os, const OpKind& kind);
+
+enum ConditionCode {
+  kCondEq,  // equal
+  kCondNe,  // not equal
+  kCondCs,  // carry set (unsigned less than)
+  kCondUlt = kCondCs,
+  kCondCc,  // carry clear (unsigned greater than or same)
+  kCondUge = kCondCc,
+  kCondMi,  // minus
+  kCondPl,  // plus, positive or zero
+  kCondVs,  // overflow
+  kCondVc,  // no overflow
+  kCondHi,  // unsigned greater than
+  kCondLs,  // unsigned lower or same
+  kCondGe,  // signed greater than or equal
+  kCondLt,  // signed less than
+  kCondGt,  // signed greater than
+  kCondLe,  // signed less than or equal
+  kCondAl,  // always
+  kCondNv,  // never
+};
+
+std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
+
+// Target specific condition encodings
+enum ArmConditionCode {
+  kArmCondEq = 0x0,  // 0000
+  kArmCondNe = 0x1,  // 0001
+  kArmCondCs = 0x2,  // 0010
+  kArmCondCc = 0x3,  // 0011
+  kArmCondMi = 0x4,  // 0100
+  kArmCondPl = 0x5,  // 0101
+  kArmCondVs = 0x6,  // 0110
+  kArmCondVc = 0x7,  // 0111
+  kArmCondHi = 0x8,  // 1000
+  kArmCondLs = 0x9,  // 1001
+  kArmCondGe = 0xa,  // 1010
+  kArmCondLt = 0xb,  // 1011
+  kArmCondGt = 0xc,  // 1100
+  kArmCondLe = 0xd,  // 1101
+  kArmCondAl = 0xe,  // 1110
+  kArmCondNv = 0xf,  // 1111
+};
+
+std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
+
+enum X86ConditionCode {
+  kX86CondO   = 0x0,    // overflow
+  kX86CondNo  = 0x1,    // not overflow
+
+  kX86CondB   = 0x2,    // below
+  kX86CondNae = kX86CondB,  // not-above-equal
+  kX86CondC   = kX86CondB,  // carry
+
+  kX86CondNb  = 0x3,    // not-below
+  kX86CondAe  = kX86CondNb, // above-equal
+  kX86CondNc  = kX86CondNb, // not-carry
+
+  kX86CondZ   = 0x4,    // zero
+  kX86CondEq  = kX86CondZ,  // equal
+
+  kX86CondNz  = 0x5,    // not-zero
+  kX86CondNe  = kX86CondNz, // not-equal
+
+  kX86CondBe  = 0x6,    // below-equal
+  kX86CondNa  = kX86CondBe, // not-above
+
+  kX86CondNbe = 0x7,    // not-below-equal
+  kX86CondA   = kX86CondNbe,// above
+
+  kX86CondS   = 0x8,    // sign
+  kX86CondNs  = 0x9,    // not-sign
+
+  kX86CondP   = 0xa,    // 8-bit parity even
+  kX86CondPE  = kX86CondP,
+
+  kX86CondNp  = 0xb,    // 8-bit parity odd
+  kX86CondPo  = kX86CondNp,
+
+  kX86CondL   = 0xc,    // less-than
+  kX86CondNge = kX86CondL,  // not-greater-equal
+
+  kX86CondNl  = 0xd,    // not-less-than
+  kX86CondGe  = kX86CondNl, // not-greater-equal
+
+  kX86CondLe  = 0xe,    // less-than-equal
+  kX86CondNg  = kX86CondLe, // not-greater
+
+  kX86CondNle = 0xf,    // not-less-than
+  kX86CondG   = kX86CondNle,// greater
+};
+
+std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
+
+enum ThrowKind {
+  kThrowNullPointer,
+  kThrowDivZero,
+  kThrowArrayBounds,
+  kThrowNoSuchMethod,
+  kThrowStackOverflow,
+};
+
+enum SpecialCaseHandler {
+  kNoHandler,
+  kNullMethod,
+  kConstFunction,
+  kIGet,
+  kIGetBoolean,
+  kIGetObject,
+  kIGetByte,
+  kIGetChar,
+  kIGetShort,
+  kIGetWide,
+  kIPut,
+  kIPutBoolean,
+  kIPutObject,
+  kIPutByte,
+  kIPutChar,
+  kIPutShort,
+  kIPutWide,
+  kIdentity,
+};
+
+enum DividePattern {
+  DivideNone,
+  Divide3,
+  Divide5,
+  Divide7,
+};
+
+std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
+
+/* Customized node traversal orders for different needs */
+enum DataFlowAnalysisMode {
+  kAllNodes = 0,              // All nodes
+  kReachableNodes,            // All reachable nodes
+  kPreOrderDFSTraversal,      // Depth-First-Search / Pre-Order
+  kPostOrderDFSTraversal,     // Depth-First-Search / Post-Order
+  kPostOrderDOMTraversal,     // Dominator tree / Post-Order
+  kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order
+};
+
+std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode);
+
+}  // namespace art
+
+#endif // ART_SRC_COMPILER_COMPILERENUMS_H_
diff --git a/src/compiler/compiler_ir.h b/src/compiler/compiler_ir.h
index f73fe92..bc09a9c 100644
--- a/src/compiler/compiler_ir.h
+++ b/src/compiler/compiler_ir.h
@@ -25,6 +25,7 @@
 #include "safe_map.h"
 #include "greenland/ir_builder.h"
 #include "llvm/Module.h"
+#include "compiler_enums.h"
 
 namespace art {
 
@@ -42,39 +43,6 @@
 struct LIR;
 class LLVMInfo;
 
-enum RegisterClass {
-  kCoreReg,
-  kFPReg,
-  kAnyReg,
-};
-
-enum SpecialTargetRegister {
-  kSelf,            // Thread
-  kSuspend,         // Used to reduce suspend checks
-  kLr,
-  kPc,
-  kSp,
-  kArg0,
-  kArg1,
-  kArg2,
-  kArg3,
-  kFArg0,
-  kFArg1,
-  kFArg2,
-  kFArg3,
-  kRet0,
-  kRet1,
-  kInvokeTgt,
-  kCount
-};
-
-enum RegLocationType {
-  kLocDalvikFrame = 0, // Normal Dalvik register
-  kLocPhysReg,
-  kLocCompilerTemp,
-  kLocInvalid
-};
-
 struct PromotionMap {
   RegLocationType coreLocation:3;
   uint8_t coreReg;
@@ -170,14 +138,6 @@
 #define MANY_BLOCKS_INITIALIZER 1000 /* Threshold for switching dataflow off */
 #define MANY_BLOCKS 4000 /* Non-initializer threshold */
 
-enum BBType {
-  kEntryBlock,
-  kDalvikByteCode,
-  kExitBlock,
-  kExceptionHandling,
-  kDead,
-};
-
 /* Utility macros to traverse the LIR list */
 #define NEXT_LIR(lir) (lir->next)
 #define PREV_LIR(lir) (lir->prev)
@@ -188,22 +148,6 @@
 #define DECODE_ALIAS_INFO_WIDE(X)       ((X & DECODE_ALIAS_INFO_WIDE_FLAG) ? 1 : 0)
 #define ENCODE_ALIAS_INFO(REG, ISWIDE)  (REG | (ISWIDE ? DECODE_ALIAS_INFO_WIDE_FLAG : 0))
 
-/*
- * Def/Use encoding in 64-bit useMask/defMask.  Low positions used for target-specific
- * registers (and typically use the register number as the position).  High positions
- * reserved for common and abstract resources.
- */
-
-enum ResourceEncodingPos {
-  kMustNotAlias = 63,
-  kHeapRef = 62,          // Default memory reference type
-  kLiteral = 61,          // Literal pool memory reference
-  kDalvikReg = 60,        // Dalvik vReg memory reference
-  kFPStatus = 59,
-  kCCode = 58,
-  kLowestCommonResource = kCCode
-};
-
 /* Common resource macros */
 #define ENCODE_CCODE            (1ULL << kCCode)
 #define ENCODE_FP_STATUS        (1ULL << kFPStatus)
@@ -237,60 +181,10 @@
   uint64_t defMask;           // Resource mask for def
 };
 
-/* Shared pseudo opcodes - must be < 0 */
-enum LIRPseudoOpcode {
-  kPseudoExportedPC = -18,
-  kPseudoSafepointPC = -17,
-  kPseudoIntrinsicRetry = -16,
-  kPseudoSuspendTarget = -15,
-  kPseudoThrowTarget = -14,
-  kPseudoCaseLabel = -13,
-  kPseudoMethodEntry = -12,
-  kPseudoMethodExit = -11,
-  kPseudoBarrier = -10,
-  kPseudoExtended = -9,
-  kPseudoSSARep = -8,
-  kPseudoEntryBlock = -7,
-  kPseudoExitBlock = -6,
-  kPseudoTargetLabel = -5,
-  kPseudoDalvikByteCodeBoundary = -4,
-  kPseudoPseudoAlign4 = -3,
-  kPseudoEHBlockLabel = -2,
-  kPseudoNormalBlockLabel = -1,
-};
-
-enum ExtendedMIROpcode {
-  kMirOpFirst = kNumPackedOpcodes,
-  kMirOpPhi = kMirOpFirst,
-  kMirOpCopy,
-  kMirOpFusedCmplFloat,
-  kMirOpFusedCmpgFloat,
-  kMirOpFusedCmplDouble,
-  kMirOpFusedCmpgDouble,
-  kMirOpFusedCmpLong,
-  kMirOpNop,
-  kMirOpNullCheck,
-  kMirOpRangeCheck,
-  kMirOpDivZeroCheck,
-  kMirOpCheck,
-  kMirOpLast,
-};
+extern const char* extendedMIROpNames[kMirOpLast - kMirOpFirst];
 
 struct SSARepresentation;
 
-enum MIROptimizationFlagPositons {
-  kMIRIgnoreNullCheck = 0,
-  kMIRNullCheckOnly,
-  kMIRIgnoreRangeCheck,
-  kMIRRangeCheckOnly,
-  kMIRInlined,                        // Invoke is inlined (ie dead)
-  kMIRInlinedPred,                    // Invoke is inlined via prediction
-  kMIRCallee,                         // Instruction is inlined from callee
-  kMIRIgnoreSuspendCheck,
-  kMIRDup,
-  kMIRMark,                           // Temporary node mark
-};
-
 #define MIR_IGNORE_NULL_CHECK           (1 << kMIRIgnoreNullCheck)
 #define MIR_NULL_CHECK_ONLY             (1 << kMIRNullCheckOnly)
 #define MIR_IGNORE_RANGE_CHECK          (1 << kMIRIgnoreRangeCheck)
@@ -327,14 +221,6 @@
 
 struct BasicBlockDataFlow;
 
-/* For successorBlockList */
-enum BlockListType {
-  kNotUsed = 0,
-  kCatch,
-  kPackedSwitch,
-  kSparseSwitch,
-};
-
 struct BasicBlock {
   int id;
   int dfsId;
@@ -379,11 +265,6 @@
 struct ArenaMemBlock;
 struct Memstats;
 
-enum AssemblerStatus {
-  kSuccess,
-  kRetryAll,
-};
-
 #define NOTVISITED (-1)
 
 struct CompilationUnit {
@@ -653,152 +534,6 @@
   int* opcodeCount;    // Count Dalvik opcodes for tuning
 };
 
-enum OpSize {
-  kWord,
-  kLong,
-  kSingle,
-  kDouble,
-  kUnsignedHalf,
-  kSignedHalf,
-  kUnsignedByte,
-  kSignedByte,
-};
-
-enum OpKind {
-  kOpMov,
-  kOpMvn,
-  kOpCmp,
-  kOpLsl,
-  kOpLsr,
-  kOpAsr,
-  kOpRor,
-  kOpNot,
-  kOpAnd,
-  kOpOr,
-  kOpXor,
-  kOpNeg,
-  kOpAdd,
-  kOpAdc,
-  kOpSub,
-  kOpSbc,
-  kOpRsub,
-  kOpMul,
-  kOpDiv,
-  kOpRem,
-  kOpBic,
-  kOpCmn,
-  kOpTst,
-  kOpBkpt,
-  kOpBlx,
-  kOpPush,
-  kOpPop,
-  kOp2Char,
-  kOp2Short,
-  kOp2Byte,
-  kOpCondBr,
-  kOpUncondBr,
-  kOpBx,
-  kOpInvalid,
-};
-
-std::ostream& operator<<(std::ostream& os, const OpKind& kind);
-
-enum ConditionCode {
-  kCondEq,  // equal
-  kCondNe,  // not equal
-  kCondCs,  // carry set (unsigned less than)
-  kCondUlt = kCondCs,
-  kCondCc,  // carry clear (unsigned greater than or same)
-  kCondUge = kCondCc,
-  kCondMi,  // minus
-  kCondPl,  // plus, positive or zero
-  kCondVs,  // overflow
-  kCondVc,  // no overflow
-  kCondHi,  // unsigned greater than
-  kCondLs,  // unsigned lower or same
-  kCondGe,  // signed greater than or equal
-  kCondLt,  // signed less than
-  kCondGt,  // signed greater than
-  kCondLe,  // signed less than or equal
-  kCondAl,  // always
-  kCondNv,  // never
-};
-
-// Target specific condition encodings
-enum ArmConditionCode {
-  kArmCondEq = 0x0,  /* 0000 */
-  kArmCondNe = 0x1,  /* 0001 */
-  kArmCondCs = 0x2,  /* 0010 */
-  kArmCondCc = 0x3,  /* 0011 */
-  kArmCondMi = 0x4,  /* 0100 */
-  kArmCondPl = 0x5,  /* 0101 */
-  kArmCondVs = 0x6,  /* 0110 */
-  kArmCondVc = 0x7,  /* 0111 */
-  kArmCondHi = 0x8,  /* 1000 */
-  kArmCondLs = 0x9,  /* 1001 */
-  kArmCondGe = 0xa,  /* 1010 */
-  kArmCondLt = 0xb,  /* 1011 */
-  kArmCondGt = 0xc,  /* 1100 */
-  kArmCondLe = 0xd,  /* 1101 */
-  kArmCondAl = 0xe,  /* 1110 */
-  kArmCondNv = 0xf,  /* 1111 */
-};
-
-enum X86ConditionCode {
-  kX86CondO   = 0x0,    // overflow
-  kX86CondNo  = 0x1,    // not overflow
-
-  kX86CondB   = 0x2,    // below
-  kX86CondNae = kX86CondB,  // not-above-equal
-  kX86CondC   = kX86CondB,  // carry
-
-  kX86CondNb  = 0x3,    // not-below
-  kX86CondAe  = kX86CondNb, // above-equal
-  kX86CondNc  = kX86CondNb, // not-carry
-
-  kX86CondZ   = 0x4,    // zero
-  kX86CondEq  = kX86CondZ,  // equal
-
-  kX86CondNz  = 0x5,    // not-zero
-  kX86CondNe  = kX86CondNz, // not-equal
-
-  kX86CondBe  = 0x6,    // below-equal
-  kX86CondNa  = kX86CondBe, // not-above
-
-  kX86CondNbe = 0x7,    // not-below-equal
-  kX86CondA   = kX86CondNbe,// above
-
-  kX86CondS   = 0x8,    // sign
-  kX86CondNs  = 0x9,    // not-sign
-
-  kX86CondP   = 0xA,    // 8-bit parity even
-  kX86CondPE  = kX86CondP,
-
-  kX86CondNp  = 0xB,    // 8-bit parity odd
-  kX86CondPo  = kX86CondNp,
-
-  kX86CondL   = 0xC,    // less-than
-  kX86CondNge = kX86CondL,  // not-greater-equal
-
-  kX86CondNl  = 0xD,    // not-less-than
-  kX86CondGe  = kX86CondNl, // not-greater-equal
-
-  kX86CondLe  = 0xE,    // less-than-equal
-  kX86CondNg  = kX86CondLe, // not-greater
-
-  kX86CondNle = 0xF,    // not-less-than
-  kX86CondG   = kX86CondNle,// greater
-};
-
-
-enum ThrowKind {
-  kThrowNullPointer,
-  kThrowDivZero,
-  kThrowArrayBounds,
-  kThrowNoSuchMethod,
-  kThrowStackOverflow,
-};
-
 struct SwitchTable {
   int offset;
   const uint16_t* table;            // Original dex table
@@ -816,27 +551,6 @@
 
 #define MAX_PATTERN_LEN 5
 
-enum SpecialCaseHandler {
-  kNoHandler,
-  kNullMethod,
-  kConstFunction,
-  kIGet,
-  kIGetBoolean,
-  kIGetObject,
-  kIGetByte,
-  kIGetChar,
-  kIGetShort,
-  kIGetWide,
-  kIPut,
-  kIPutBoolean,
-  kIPutObject,
-  kIPutByte,
-  kIPutChar,
-  kIPutShort,
-  kIPutWide,
-  kIdentity,
-};
-
 struct CodePattern {
   const Instruction::Code opcodes[MAX_PATTERN_LEN];
   const SpecialCaseHandler handlerCode;
diff --git a/src/compiler/compiler_utility.cc b/src/compiler/compiler_utility.cc
index 8bd4713..a0ab292 100644
--- a/src/compiler/compiler_utility.cc
+++ b/src/compiler/compiler_utility.cc
@@ -18,6 +18,21 @@
 
 namespace art {
 
+const char* extendedMIROpNames[kMirOpLast - kMirOpFirst] = {
+  "kMirOpPhi",
+  "kMirOpCopy",
+  "kMirFusedCmplFloat",
+  "kMirFusedCmpgFloat",
+  "kMirFusedCmplDouble",
+  "kMirFusedCmpgDouble",
+  "kMirFusedCmpLong",
+  "kMirNop",
+  "kMirOpNullCheck",
+  "kMirOpRangeCheck",
+  "kMirOpDivZeroCheck",
+  "kMirOpCheck",
+};
+
 #ifdef WITH_MEMSTATS
 struct Memstats {
   uint32_t allocStats[kNumAllocKinds];
@@ -88,7 +103,7 @@
 {
   DCHECK(cUnit->arenaHead == NULL);
   cUnit->arenaHead =
-      (ArenaMemBlock *) malloc(sizeof(ArenaMemBlock) + ARENA_DEFAULT_SIZE);
+      static_cast<ArenaMemBlock*>(malloc(sizeof(ArenaMemBlock) + ARENA_DEFAULT_SIZE));
   if (cUnit->arenaHead == NULL) {
     LOG(FATAL) << "No memory left to create compiler heap memory";
   }
@@ -137,8 +152,8 @@
 
     size_t blockSize = (size < ARENA_DEFAULT_SIZE) ?  ARENA_DEFAULT_SIZE : size;
     /* Time to allocate a new arena */
-    ArenaMemBlock *newArena = (ArenaMemBlock *)
-        malloc(sizeof(ArenaMemBlock) + blockSize);
+    ArenaMemBlock *newArena =
+        static_cast<ArenaMemBlock*>(malloc(sizeof(ArenaMemBlock) + blockSize));
     if (newArena == NULL) {
       LOG(FATAL) << "Arena allocation failure";
     }
@@ -174,12 +189,12 @@
 {
   gList->numAllocated = initLength;
   gList->numUsed = 0;
-  gList->elemList = (intptr_t *) oatNew(cUnit, sizeof(intptr_t) * initLength,
-                                        true, kAllocGrowableList);
+  gList->elemList = static_cast<uintptr_t *>(oatNew(cUnit, sizeof(intptr_t) * initLength,
+                                             true, kAllocGrowableList));
 #ifdef WITH_MEMSTATS
-  cUnit->mstats->listSizes[kind] += sizeof(intptr_t) * initLength;
+  cUnit->mstats->listSizes[kind] += sizeof(uintptr_t) * initLength;
   gList->kind = kind;
-  if ((int)initLength > cUnit->mstats->listMaxElems[kind]) {
+  if (static_cast<int>(initLength) > cUnit->mstats->listMaxElems[kind]) {
     cUnit->mstats->listMaxElems[kind] = initLength;
   }
 #endif
@@ -194,14 +209,14 @@
   } else {
     newLength += 128;
   }
-  intptr_t *newArray =
-      (intptr_t *) oatNew(cUnit, sizeof(intptr_t) * newLength, true,
-                          kAllocGrowableList);
-  memcpy(newArray, gList->elemList, sizeof(intptr_t) * gList->numAllocated);
+  uintptr_t *newArray =
+      static_cast<uintptr_t*>(oatNew(cUnit, sizeof(uintptr_t) * newLength, true,
+                                     kAllocGrowableList));
+  memcpy(newArray, gList->elemList, sizeof(uintptr_t) * gList->numAllocated);
 #ifdef WITH_MEMSTATS
-  cUnit->mstats->listSizes[gList->kind] += sizeof(intptr_t) * newLength;
+  cUnit->mstats->listSizes[gList->kind] += sizeof(uintptr_t) * newLength;
   cUnit->mstats->listWasted[gList->kind] +=
-      sizeof(intptr_t) * gList->numAllocated;
+      sizeof(uintptr_t) * gList->numAllocated;
   cUnit->mstats->listGrows[gList->kind]++;
   if (newLength > cUnit->mstats->listMaxElems[gList->kind]) {
     cUnit->mstats->listMaxElems[gList->kind] = newLength;
@@ -213,7 +228,7 @@
 
 /* Insert a new element into the growable list */
 void oatInsertGrowableList(CompilationUnit* cUnit, GrowableList* gList,
-                         intptr_t elem)
+                           uintptr_t elem)
 {
   DCHECK_NE(gList->numAllocated, 0U);
   if (gList->numUsed == gList->numAllocated) {
@@ -223,7 +238,7 @@
 }
 
 /* Delete an element from a growable list. Element must be present */
-void oatDeleteGrowableList(GrowableList* gList, intptr_t elem)
+void oatDeleteGrowableList(GrowableList* gList, uintptr_t elem)
 {
   bool found = false;
   for (unsigned int i = 0; i < gList->numUsed; i++) {
@@ -246,14 +261,14 @@
   iterator->size = gList->numUsed;
 }
 
-intptr_t oatGrowableListIteratorNext(GrowableListIterator* iterator)
+uintptr_t oatGrowableListIteratorNext(GrowableListIterator* iterator)
 {
   DCHECK_EQ(iterator->size, iterator->list->numUsed);
   if (iterator->idx == iterator->size) return 0;
   return iterator->list->elemList[iterator->idx++];
 }
 
-intptr_t oatGrowableListGetElement(const GrowableList* gList, size_t idx)
+uintptr_t oatGrowableListGetElement(const GrowableList* gList, size_t idx)
 {
   DCHECK_LT(idx, gList->numUsed);
   return gList->elemList[idx];
@@ -318,7 +333,7 @@
   oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
 
   while (true) {
-    bb = (BasicBlock *) oatGrowableListIteratorNext(&iterator);
+    bb = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iterator));
     if (bb == NULL) break;
     LOG(INFO) << StringPrintf("Block %d (%s) (insn %04x - %04x%s)",
         bb->id,
@@ -361,8 +376,8 @@
 
   DCHECK_EQ(sizeof(bv->storage[0]), 4U);        /* assuming 32-bit units */
 
-  bv = (ArenaBitVector*) oatNew(cUnit, sizeof(ArenaBitVector), false,
-                                kAllocGrowableBitMap);
+  bv = static_cast<ArenaBitVector*>(oatNew(cUnit, sizeof(ArenaBitVector), false,
+                                                kAllocGrowableBitMap));
 
   count = (startBits + 31) >> 5;
 
@@ -486,7 +501,7 @@
   LOG(INFO) <<  msg;
   for (i = 0; i < length; i++) {
     if (oatIsBitSet(bv, i)) {
-      BasicBlock *bb = (BasicBlock *) oatGrowableListGetElement(blocks, i);
+      BasicBlock *bb = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blocks, i));
       char blockName[BLOCK_NAME_LEN];
       oatGetBlockName(bb, blockName);
       LOG(INFO) << "Bit " << i << " / " << blockName << " is set";
diff --git a/src/compiler/compiler_utility.h b/src/compiler/compiler_utility.h
index 2e30380..ab91549 100644
--- a/src/compiler/compiler_utility.h
+++ b/src/compiler/compiler_utility.h
@@ -106,7 +106,7 @@
 
   size_t numAllocated;
   size_t numUsed;
-  intptr_t* elemList;
+  uintptr_t* elemList;
 #ifdef WITH_MEMSTATS
   oatListKind kind;
 #endif
@@ -140,7 +140,7 @@
   uint32_t bitSize;
 };
 
-#define GET_ELEM_N(LIST, TYPE, N) (((TYPE*) LIST->elemList)[N])
+#define GET_ELEM_N(LIST, TYPE, N) ((reinterpret_cast<TYPE*>(LIST->elemList)[N]))
 
 #define BLOCK_NAME_LEN 80
 
@@ -153,12 +153,12 @@
 void oatInitGrowableList(CompilationUnit* cUnit,GrowableList* gList,
                          size_t initLength, oatListKind kind = kListMisc);
 void oatInsertGrowableList(CompilationUnit* cUnit, GrowableList* gList,
-                           intptr_t elem);
-void oatDeleteGrowableList(GrowableList* gList, intptr_t elem);
+                           uintptr_t elem);
+void oatDeleteGrowableList(GrowableList* gList, uintptr_t elem);
 void oatGrowableListIteratorInit(GrowableList* gList,
                                  GrowableListIterator* iterator);
-intptr_t oatGrowableListIteratorNext(GrowableListIterator* iterator);
-intptr_t oatGrowableListGetElement(const GrowableList* gList, size_t idx);
+uintptr_t oatGrowableListIteratorNext(GrowableListIterator* iterator);
+uintptr_t oatGrowableListGetElement(const GrowableList* gList, size_t idx);
 
 ArenaBitVector* oatAllocBitVector(CompilationUnit* cUnit,
                                   unsigned int startBits, bool expandable,
diff --git a/src/compiler/dataflow.cc b/src/compiler/dataflow.cc
index 65068ed..5ec5bc2 100644
--- a/src/compiler/dataflow.cc
+++ b/src/compiler/dataflow.cc
@@ -838,19 +838,19 @@
 /* Return the base virtual register for a SSA name */
 int SRegToVReg(const CompilationUnit* cUnit, int ssaReg)
 {
-  DCHECK_LT(ssaReg, (int)cUnit->ssaBaseVRegs->numUsed);
+  DCHECK_LT(ssaReg, static_cast<int>(cUnit->ssaBaseVRegs->numUsed));
   return GET_ELEM_N(cUnit->ssaBaseVRegs, int, ssaReg);
 }
 
 int SRegToSubscript(const CompilationUnit* cUnit, int ssaReg)
 {
-  DCHECK(ssaReg < (int)cUnit->ssaSubscripts->numUsed);
+  DCHECK(ssaReg < static_cast<int>(cUnit->ssaSubscripts->numUsed));
   return GET_ELEM_N(cUnit->ssaSubscripts, int, ssaReg);
 }
 
 int getSSAUseCount(CompilationUnit* cUnit, int sReg)
 {
-  DCHECK(sReg < (int)cUnit->rawUseCounts.numUsed);
+  DCHECK(sReg < static_cast<int>(cUnit->rawUseCounts.numUsed));
   return cUnit->rawUseCounts.elemList[sReg];
 }
 
@@ -889,20 +889,19 @@
     switch (dalvikFormat) {
       case Instruction::k21t:
         str.append(StringPrintf(" v%d,", insn.vA));
-        offset = (int) insn.vB;
+        offset = insn.vB;
         break;
       case Instruction::k22t:
         str.append(StringPrintf(" v%d, v%d,", insn.vA, insn.vB));
-        offset = (int) insn.vC;
+        offset = insn.vC;
         break;
       case Instruction::k10t:
       case Instruction::k20t:
       case Instruction::k30t:
-        offset = (int) insn.vA;
+        offset = insn.vA;
         break;
       default:
-        LOG(FATAL) << "Unexpected branch format " << (int)dalvikFormat
-                   << " / opcode " << (int)opcode;
+        LOG(FATAL) << "Unexpected branch format " << dalvikFormat << " from " << insn.opcode;
     }
     str.append(StringPrintf(" (%c%x)",
                             offset > 0 ? '+' : '-',
@@ -922,17 +921,17 @@
     }
     if (dfAttributes & DF_B_IS_REG) {
       str.append(StringPrintf(", v%d", insn.vB));
-    } else if ((int)opcode < (int)kMirOpFirst) {
+    } else if (static_cast<int>(opcode) < static_cast<int>(kMirOpFirst)) {
       str.append(StringPrintf(", (#%d)", insn.vB));
     }
     if (dfAttributes & DF_C_IS_REG) {
       str.append(StringPrintf(", v%d", insn.vC));
-    } else if ((int)opcode < (int)kMirOpFirst) {
+    } else if (static_cast<int>(opcode) < static_cast<int>(kMirOpFirst)) {
       str.append(StringPrintf(", (#%d)", insn.vC));
     }
   }
   int length = str.length() + 1;
-  ret = (char*)oatNew(cUnit, length, false, kAllocDFInfo);
+  ret = static_cast<char*>(oatNew(cUnit, length, false, kAllocDFInfo));
   strncpy(ret, str.c_str(), length);
   return ret;
 }
@@ -957,7 +956,7 @@
 
   if (opcode >= kMirOpFirst) {
     if (opcode == kMirOpPhi) {
-      int* incoming = (int*)mir->dalvikInsn.vB;
+      int* incoming = reinterpret_cast<int*>(mir->dalvikInsn.vB);
       str.append(StringPrintf("PHI %s = (%s",
                  getSSAName(cUnit, mir->ssaRep->defs[0]).c_str(),
                  getSSAName(cUnit, mir->ssaRep->uses[0]).c_str()));
@@ -990,21 +989,21 @@
       case Instruction::k21t:
         str.append(StringPrintf(" %s, ",
                    getSSAName(cUnit, mir->ssaRep->uses[0]).c_str()));
-        delta = (int) insn->vB;
+        delta = insn->vB;
         break;
       case Instruction::k22t:
         str.append(StringPrintf(" %s, %s, ",
                  getSSAName(cUnit, mir->ssaRep->uses[0]).c_str(),
                  getSSAName(cUnit, mir->ssaRep->uses[1]).c_str()));
-        delta = (int) insn->vC;
+        delta = insn->vC;
         break;
       case Instruction::k10t:
       case Instruction::k20t:
       case Instruction::k30t:
-        delta = (int) insn->vA;
+        delta = insn->vA;
         break;
       default:
-        LOG(FATAL) << "Unexpected branch format: " << (int)dalvikFormat;
+        LOG(FATAL) << "Unexpected branch format: " << dalvikFormat;
       }
       str.append(StringPrintf(" %04x", mir->offset + delta));
   } else if (dfAttributes & (DF_FORMAT_35C | DF_FORMAT_3RC)) {
@@ -1063,7 +1062,7 @@
 
 done:
   length = str.length() + 1;
-  ret = (char*) oatNew(cUnit, length, false, kAllocDFInfo);
+  ret = static_cast<char*>(oatNew(cUnit, length, false, kAllocDFInfo));
   strncpy(ret, str.c_str(), length);
   return ret;
 }
@@ -1092,7 +1091,7 @@
   }
 
   int length = str.length() + 1;
-  ret = (char*)oatNew(cUnit, length, false, kAllocDFInfo);
+  ret = static_cast<char*>(oatNew(cUnit, length, false, kAllocDFInfo));
   strncpy(ret, str.c_str(), length);
   return ret;
 }
@@ -1186,9 +1185,9 @@
   oatInsertGrowableList(cUnit, cUnit->ssaBaseVRegs, vReg);
   oatInsertGrowableList(cUnit, cUnit->ssaSubscripts, subscript);
   std::string ssaName = getSSAName(cUnit, ssaReg);
-  char* name = (char*)oatNew(cUnit, ssaName.length() + 1, false, kAllocDFInfo);
+  char* name = static_cast<char*>(oatNew(cUnit, ssaName.length() + 1, false, kAllocDFInfo));
   strncpy(name, ssaName.c_str(), ssaName.length() + 1);
-  oatInsertGrowableList(cUnit, cUnit->ssaStrings, (intptr_t)name);
+  oatInsertGrowableList(cUnit, cUnit->ssaStrings, reinterpret_cast<uintptr_t>(name));
   DCHECK_EQ(cUnit->ssaBaseVRegs->numUsed, cUnit->ssaSubscripts->numUsed);
   return ssaReg;
 }
@@ -1219,11 +1218,10 @@
   int i;
 
   mir->ssaRep->numUses = numUses;
-  mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses, true,
-                                    kAllocDFInfo);
+  mir->ssaRep->uses = static_cast<int*>(oatNew(cUnit, sizeof(int) * numUses, true, kAllocDFInfo));
   // NOTE: will be filled in during type & size inference pass
-  mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses, true,
-                                      kAllocDFInfo);
+  mir->ssaRep->fpUse = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * numUses, true,
+                                                 kAllocDFInfo));
 
   for (i = 0; i < numUses; i++) {
     handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->arg[i], i);
@@ -1238,11 +1236,10 @@
   int i;
 
   mir->ssaRep->numUses = numUses;
-  mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses, true,
-                                    kAllocDFInfo);
+  mir->ssaRep->uses = static_cast<int*>(oatNew(cUnit, sizeof(int) * numUses, true, kAllocDFInfo));
   // NOTE: will be filled in during type & size inference pass
-  mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses, true,
-                                      kAllocDFInfo);
+  mir->ssaRep->fpUse = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * numUses, true,
+                                                 kAllocDFInfo));
 
   for (i = 0; i < numUses; i++) {
     handleSSAUse(cUnit, mir->ssaRep->uses, dInsn->vC+i, i);
@@ -1257,8 +1254,8 @@
   if (bb->dataFlowInfo == NULL) return false;
 
   for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
-    mir->ssaRep = (struct SSARepresentation *)
-        oatNew(cUnit, sizeof(SSARepresentation), true, kAllocDFInfo);
+    mir->ssaRep = static_cast<struct SSARepresentation *>(oatNew(cUnit, sizeof(SSARepresentation),
+                                                                 true, kAllocDFInfo));
 
     int dfAttributes = oatDataFlowAttributes[mir->dalvikInsn.opcode];
 
@@ -1311,10 +1308,10 @@
 
     if (numUses) {
       mir->ssaRep->numUses = numUses;
-      mir->ssaRep->uses = (int *)oatNew(cUnit, sizeof(int) * numUses,
-                                        false, kAllocDFInfo);
-      mir->ssaRep->fpUse = (bool *)oatNew(cUnit, sizeof(bool) * numUses,
-                                          false, kAllocDFInfo);
+      mir->ssaRep->uses = static_cast<int*>(oatNew(cUnit, sizeof(int) * numUses, false,
+                                                   kAllocDFInfo));
+      mir->ssaRep->fpUse = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * numUses, false,
+                                                     kAllocDFInfo));
     }
 
     int numDefs = 0;
@@ -1328,10 +1325,10 @@
 
     if (numDefs) {
       mir->ssaRep->numDefs = numDefs;
-      mir->ssaRep->defs = (int *)oatNew(cUnit, sizeof(int) * numDefs,
-                                        false, kAllocDFInfo);
-      mir->ssaRep->fpDef = (bool *)oatNew(cUnit, sizeof(bool) * numDefs,
-                                          false, kAllocDFInfo);
+      mir->ssaRep->defs = static_cast<int*>(oatNew(cUnit, sizeof(int) * numDefs, false,
+                                                   kAllocDFInfo));
+      mir->ssaRep->fpDef = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * numDefs, false,
+                                                     kAllocDFInfo));
     }
 
     DecodedInstruction *dInsn = &mir->dalvikInsn;
@@ -1380,8 +1377,8 @@
      * predecessor blocks.
      */
     bb->dataFlowInfo->vRegToSSAMap =
-        (int *)oatNew(cUnit, sizeof(int) * cUnit->numDalvikRegisters, false,
-                      kAllocDFInfo);
+        static_cast<int*>(oatNew(cUnit, sizeof(int) * cUnit->numDalvikRegisters, false,
+                                 kAllocDFInfo));
 
     memcpy(bb->dataFlowInfo->vRegToSSAMap, cUnit->vRegToSSAMap,
            sizeof(int) * cUnit->numDalvikRegisters);
@@ -1426,9 +1423,8 @@
             setConstant(cUnit, mir->ssaRep->defs[1], 0);
             break;
           case Instruction::CONST_WIDE:
-            setConstant(cUnit, mir->ssaRep->defs[0], (int) dInsn->vB_wide);
-            setConstant(cUnit, mir->ssaRep->defs[1],
-                        (int) (dInsn->vB_wide >> 32));
+            setConstant(cUnit, mir->ssaRep->defs[0], static_cast<int>(dInsn->vB_wide));
+            setConstant(cUnit, mir->ssaRep->defs[1], static_cast<int>(dInsn->vB_wide >> 32));
             break;
           case Instruction::CONST_WIDE_HIGH16:
             setConstant(cUnit, mir->ssaRep->defs[0], 0);
@@ -1466,12 +1462,12 @@
   int i;
   int numDalvikReg = cUnit->numDalvikRegisters;
 
-  cUnit->ssaBaseVRegs = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
-                                               false, kAllocDFInfo);
-  cUnit->ssaSubscripts = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
-                                                false, kAllocDFInfo);
-  cUnit->ssaStrings = (GrowableList *)oatNew(cUnit, sizeof(GrowableList),
-                                             false, kAllocDFInfo);
+  cUnit->ssaBaseVRegs =
+      static_cast<GrowableList*>(oatNew(cUnit, sizeof(GrowableList), false, kAllocDFInfo));
+  cUnit->ssaSubscripts =
+      static_cast<GrowableList*>(oatNew(cUnit, sizeof(GrowableList), false, kAllocDFInfo));
+  cUnit->ssaStrings =
+      static_cast<GrowableList*>(oatNew(cUnit, sizeof(GrowableList), false, kAllocDFInfo));
   // Create the ssa mappings, estimating the max size
   oatInitGrowableList(cUnit, cUnit->ssaBaseVRegs,
                       numDalvikReg + cUnit->defCount + 128,
@@ -1497,20 +1493,20 @@
     oatInsertGrowableList(cUnit, cUnit->ssaBaseVRegs, i);
     oatInsertGrowableList(cUnit, cUnit->ssaSubscripts, 0);
     std::string ssaName = getSSAName(cUnit, i);
-    char* name = (char*)oatNew(cUnit, ssaName.length() + 1, true, kAllocDFInfo);
+    char* name = static_cast<char*>(oatNew(cUnit, ssaName.length() + 1, true, kAllocDFInfo));
     strncpy(name, ssaName.c_str(), ssaName.length() + 1);
-    oatInsertGrowableList(cUnit, cUnit->ssaStrings, (intptr_t)name);
+    oatInsertGrowableList(cUnit, cUnit->ssaStrings, reinterpret_cast<uintptr_t>(name));
   }
 
   /*
    * Initialize the DalvikToSSAMap map. There is one entry for each
    * Dalvik register, and the SSA names for those are the same.
    */
-  cUnit->vRegToSSAMap = (int *)oatNew(cUnit, sizeof(int) * numDalvikReg,
-                                      false, kAllocDFInfo);
+  cUnit->vRegToSSAMap =
+      static_cast<int*>(oatNew(cUnit, sizeof(int) * numDalvikReg, false, kAllocDFInfo));
   /* Keep track of the higest def for each dalvik reg */
-  cUnit->SSALastDefs = (int *)oatNew(cUnit, sizeof(int) * numDalvikReg,
-                                     false, kAllocDFInfo);
+  cUnit->SSALastDefs =
+      static_cast<int*>(oatNew(cUnit, sizeof(int) * numDalvikReg, false, kAllocDFInfo));
 
   for (i = 0; i < numDalvikReg; i++) {
     cUnit->vRegToSSAMap[i] = i;
@@ -1528,14 +1524,14 @@
   oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
 
   while (true) {
-    BasicBlock* bb = (BasicBlock *) oatGrowableListIteratorNext(&iterator);
+    BasicBlock* bb = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iterator));
     if (bb == NULL) break;
     if (bb->hidden == true) continue;
     if (bb->blockType == kDalvikByteCode ||
       bb->blockType == kEntryBlock ||
       bb->blockType == kExitBlock) {
-      bb->dataFlowInfo = (BasicBlockDataFlow *)
-          oatNew(cUnit, sizeof(BasicBlockDataFlow), true, kAllocDFInfo);
+      bb->dataFlowInfo = static_cast<BasicBlockDataFlow*>(oatNew(cUnit, sizeof(BasicBlockDataFlow),
+                                                                 true, kAllocDFInfo));
       }
   }
 }
@@ -1564,8 +1560,7 @@
           GrowableListIterator iterator;
           oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
           while (true) {
-            BasicBlock* bb =
-                (BasicBlock *) oatGrowableListIteratorNext(&iterator);
+            BasicBlock* bb = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iterator));
             if (bb == NULL) break;
             if (bb->hidden == true) continue;
               change |= (*func)(cUnit, bb);
@@ -1581,8 +1576,8 @@
 
           for (idx = 0; idx < numReachableBlocks; idx++) {
             int blockIdx = cUnit->dfsOrder.elemList[idx];
-            BasicBlock* bb = (BasicBlock *)
-                oatGrowableListGetElement(blockList, blockIdx);
+            BasicBlock* bb =
+                reinterpret_cast<BasicBlock*>( oatGrowableListGetElement(blockList, blockIdx));
             change |= (*func)(cUnit, bb);
           }
         }
@@ -1597,8 +1592,8 @@
 
           for (idx = 0; idx < numReachableBlocks; idx++) {
             int dfsIdx = cUnit->dfsOrder.elemList[idx];
-            BasicBlock* bb = (BasicBlock *)
-                oatGrowableListGetElement(blockList, dfsIdx);
+            BasicBlock* bb =
+                reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, dfsIdx));
             change |= (*func)(cUnit, bb);
             }
         }
@@ -1612,8 +1607,8 @@
 
           for (idx = numReachableBlocks - 1; idx >= 0; idx--) {
             int dfsIdx = cUnit->dfsOrder.elemList[idx];
-            BasicBlock* bb = (BasicBlock *)
-                oatGrowableListGetElement(blockList, dfsIdx);
+            BasicBlock* bb =
+                reinterpret_cast<BasicBlock *>( oatGrowableListGetElement(blockList, dfsIdx));
             change |= (*func)(cUnit, bb);
             }
         }
@@ -1627,8 +1622,8 @@
 
           for (idx = 0; idx < numReachableBlocks; idx++) {
             int domIdx = cUnit->domPostOrderTraversal.elemList[idx];
-            BasicBlock* bb = (BasicBlock *)
-                oatGrowableListGetElement(blockList, domIdx);
+            BasicBlock* bb =
+                reinterpret_cast<BasicBlock*>( oatGrowableListGetElement(blockList, domIdx));
             change |= (*func)(cUnit, bb);
           }
         }
@@ -1642,14 +1637,14 @@
 
           for (idx = numReachableBlocks - 1; idx >= 0; idx--) {
             int revIdx = cUnit->dfsPostOrder.elemList[idx];
-            BasicBlock* bb = (BasicBlock *)
-                oatGrowableListGetElement(blockList, revIdx);
+            BasicBlock* bb =
+                reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, revIdx));
             change |= (*func)(cUnit, bb);
             }
         }
         break;
       default:
-        LOG(FATAL) << "Unknown traversal mode " << (int)dfaMode;
+        LOG(FATAL) << "Unknown traversal mode: " << dfaMode;
     }
     /* If isIterative is false, exit the loop after the first iteration */
     change &= isIterative;
@@ -1765,7 +1760,7 @@
 int allocCompilerTempSreg(CompilationUnit* cUnit, ArenaBitVector* bv)
 {
   for (int i = 0; i < cUnit->numCompilerTemps; i++) {
-    CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
+    CompilerTemp* ct = reinterpret_cast<CompilerTemp*>(cUnit->compilerTemps.elemList[i]);
     ArenaBitVector* tBv = ct->bv;
     if (!oatTestBitVectors(bv, tBv)) {
       // Combine live maps and reuse existing temp
@@ -1775,16 +1770,16 @@
   }
 
   // Create a new compiler temp & associated live bitmap
-  CompilerTemp* ct = (CompilerTemp*)oatNew(cUnit, sizeof(CompilerTemp),
-                                           true, kAllocMisc);
+  CompilerTemp* ct =
+      static_cast<CompilerTemp*>(oatNew(cUnit, sizeof(CompilerTemp), true, kAllocMisc));
   ArenaBitVector *nBv = oatAllocBitVector(cUnit, cUnit->numBlocks, true,
                                           kBitMapMisc);
   oatCopyBitVector(nBv, bv);
   ct->bv = nBv;
   ct->sReg = addNewSReg(cUnit, SSA_CTEMP_BASEREG - cUnit->numCompilerTemps);
   cUnit->numCompilerTemps++;
-  oatInsertGrowableList(cUnit, &cUnit->compilerTemps, (intptr_t)ct);
-  DCHECK_EQ(cUnit->numCompilerTemps, (int)cUnit->compilerTemps.numUsed);
+  oatInsertGrowableList(cUnit, &cUnit->compilerTemps, reinterpret_cast<uintptr_t>(ct));
+  DCHECK_EQ(cUnit->numCompilerTemps, static_cast<int>(cUnit->compilerTemps.numUsed));
   return ct->sReg;
 }
 
@@ -1792,20 +1787,17 @@
 MIR* rawMIR(CompilationUnit* cUnit, Instruction::Code opcode, int defs,
             int uses)
 {
-  MIR* res = (MIR*)oatNew( cUnit, sizeof(MIR), true, kAllocMIR);
-  res->ssaRep =(struct SSARepresentation *)
-      oatNew(cUnit, sizeof(SSARepresentation), true, kAllocDFInfo);
+  MIR* res = static_cast<MIR*>(oatNew(cUnit, sizeof(MIR), true, kAllocMIR));
+  res->ssaRep = static_cast<struct SSARepresentation*>
+      (oatNew(cUnit, sizeof(SSARepresentation), true, kAllocDFInfo));
   if (uses) {
     res->ssaRep->numUses = uses;
-    res->ssaRep->uses = (int*)oatNew(cUnit, sizeof(int) * uses, false,
-                                     kAllocDFInfo);
+    res->ssaRep->uses = static_cast<int*>(oatNew(cUnit, sizeof(int) * uses, false, kAllocDFInfo));
   }
   if (defs) {
     res->ssaRep->numDefs = defs;
-    res->ssaRep->defs = (int*)oatNew(cUnit, sizeof(int) * defs, false,
-                                     kAllocDFInfo);
-    res->ssaRep->fpDef = (bool*)oatNew(cUnit, sizeof(bool) * defs, true,
-                                       kAllocDFInfo);
+    res->ssaRep->defs = static_cast<int*>(oatNew(cUnit, sizeof(int) * defs, false, kAllocDFInfo));
+    res->ssaRep->fpDef = static_cast<bool*>(oatNew(cUnit, sizeof(bool) * defs, true, kAllocDFInfo));
   }
   res->dalvikInsn.opcode = opcode;
   return res;
@@ -1910,7 +1902,7 @@
                 mirNext->dalvikInsn.opcode =
                     static_cast<Instruction::Code>(kMirOpFusedCmpLong);
                 break;
-              default: LOG(ERROR) << "Unexpected opcode: " << (int)opcode;
+              default: LOG(ERROR) << "Unexpected opcode: " << opcode;
             }
             mir->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpNop);
             mirNext->ssaRep->numUses = mir->ssaRep->numUses;
@@ -2003,7 +1995,7 @@
         case Instruction::IF_GEZ: opcode = Instruction::IF_LTZ; break;
         case Instruction::IF_GTZ: opcode = Instruction::IF_LEZ; break;
         case Instruction::IF_LEZ: opcode = Instruction::IF_GTZ; break;
-        default: LOG(FATAL) << "Unexpected opcode 0x" << std::hex << (int)opcode;
+        default: LOG(FATAL) << "Unexpected opcode " << opcode;
       }
       prev->lastMIRInsn->dalvikInsn.opcode = opcode;
       BasicBlock* tBB = prev->taken;
@@ -2029,7 +2021,7 @@
         || (bb->blockType == kDead)
         || ((bb->taken == NULL) || (bb->taken->blockType != kExceptionHandling))
         || (bb->successorBlockList.blockListType != kNotUsed)
-        || ((int)bb->lastMIRInsn->dalvikInsn.opcode != kMirOpCheck)) {
+        || (static_cast<int>(bb->lastMIRInsn->dalvikInsn.opcode) != kMirOpCheck)) {
       break;
     }
 
@@ -2101,12 +2093,12 @@
     // Starting state is intesection of all incoming arcs
     GrowableListIterator iter;
     oatGrowableListIteratorInit(bb->predecessors, &iter);
-    BasicBlock* predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+    BasicBlock* predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
     DCHECK(predBB != NULL);
     oatCopyBitVector(cUnit->tempSSARegisterV,
                      predBB->dataFlowInfo->endingNullCheckV);
     while (true) {
-      predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+      predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
       if (!predBB) break;
       if ((predBB->dataFlowInfo == NULL) ||
           (predBB->dataFlowInfo->endingNullCheckV == NULL)) {
@@ -2140,14 +2132,13 @@
         oatSetBit(cUnit, cUnit->tempSSARegisterV, nextMir->ssaRep->defs[0]);
       } else {
         if (nextMir) {
-          LOG(WARNING) << "Unexpected opcode following new: "
-                       << (int)nextMir->dalvikInsn.opcode;
+          LOG(WARNING) << "Unexpected opcode following new: " << nextMir->dalvikInsn.opcode;
         } else if (bb->fallThrough) {
           // Look in next basic block
           struct BasicBlock* nextBB = bb->fallThrough;
           for (MIR* tmir = nextBB->firstMIRInsn; tmir;
             tmir =tmir->next) {
-            if ((int)tmir->dalvikInsn.opcode >= (int)kMirOpFirst) {
+            if (static_cast<int>(tmir->dalvikInsn.opcode) >= static_cast<int>(kMirOpFirst)) {
               continue;
             }
             // First non-pseudo should be MOVE_RESULT_OBJECT
@@ -2155,8 +2146,7 @@
               // Mark as null checked
               oatSetBit(cUnit, cUnit->tempSSARegisterV, tmir->ssaRep->defs[0]);
             } else {
-              LOG(WARNING) << "Unexpected op after new: "
-                           << (int)tmir->dalvikInsn.opcode;
+              LOG(WARNING) << "Unexpected op after new: " << tmir->dalvikInsn.opcode;
             }
             break;
           }
@@ -2238,18 +2228,23 @@
 
 void oatDumpCheckStats(CompilationUnit *cUnit)
 {
-  Checkstats* stats = (Checkstats*)oatNew(cUnit, sizeof(Checkstats), true, kAllocDFInfo);
+  Checkstats* stats =
+      static_cast<Checkstats*>(oatNew(cUnit, sizeof(Checkstats), true, kAllocDFInfo));
   cUnit->checkstats = stats;
   oatDataFlowAnalysisDispatcher(cUnit, countChecks, kAllNodes, false /* isIterative */);
   if (stats->nullChecks > 0) {
+    float eliminated = static_cast<float>(stats->nullChecksEliminated);
+    float checks = static_cast<float>(stats->nullChecks);
     LOG(INFO) << "Null Checks: " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
               << stats->nullChecksEliminated << " of " << stats->nullChecks << " -> "
-              << ((float)stats->nullChecksEliminated/(float)stats->nullChecks) * 100.0 << "%";
+              << (eliminated/checks) * 100.0 << "%";
     }
   if (stats->rangeChecks > 0) {
+    float eliminated = static_cast<float>(stats->rangeChecksEliminated);
+    float checks = static_cast<float>(stats->rangeChecks);
     LOG(INFO) << "Range Checks: " << PrettyMethod(cUnit->method_idx, *cUnit->dex_file) << " "
               << stats->rangeChecksEliminated << " of " << stats->rangeChecks << " -> "
-              << ((float)stats->rangeChecksEliminated/(float)stats->rangeChecks) * 100.0 << "%";
+              << (eliminated/checks) * 100.0 << "%";
   }
 }
 
@@ -2268,20 +2263,19 @@
 {
   GrowableListIterator iter;
   oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
-  for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
-      (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
+  for (LoopInfo* loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter));
+      (loop != NULL); loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter))) {
     if (loop->header == header) {
       oatInsertGrowableList(cUnit, &loop->incomingBackEdges,
-                            (intptr_t)backEdge);
+                            reinterpret_cast<uintptr_t>(backEdge));
       return;
     }
   }
-  LoopInfo* info = (LoopInfo*)oatNew(cUnit, sizeof(LoopInfo), true,
-                                     kAllocDFInfo);
+  LoopInfo* info = static_cast<LoopInfo*>(oatNew(cUnit, sizeof(LoopInfo), true, kAllocDFInfo));
   info->header = header;
   oatInitGrowableList(cUnit, &info->incomingBackEdges, 2, kListMisc);
-  oatInsertGrowableList(cUnit, &info->incomingBackEdges, (intptr_t)backEdge);
-  oatInsertGrowableList(cUnit, &cUnit->loopHeaders, (intptr_t)info);
+  oatInsertGrowableList(cUnit, &info->incomingBackEdges, reinterpret_cast<uintptr_t>(backEdge));
+  oatInsertGrowableList(cUnit, &cUnit->loopHeaders, reinterpret_cast<uintptr_t>(info));
 }
 
 bool findBackEdges(struct CompilationUnit* cUnit, struct BasicBlock* bb)
@@ -2317,8 +2311,8 @@
   GrowableListIterator iter;
   oatGrowableListIteratorInit(bb->predecessors, &iter);
   BasicBlock* predBB;
-  for (predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); predBB;
-       predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
+  for (predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter)); predBB;
+       predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter))) {
     addBlocksToLoop(cUnit, blocks, predBB, headId);
   }
 }
@@ -2327,16 +2321,16 @@
 {
   GrowableListIterator iter;
   oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
-  for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
-      (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
+  for (LoopInfo* loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter));
+      (loop != NULL); loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter))) {
     LOG(INFO) << "Loop head block id " << loop->header->id
               << ", offset 0x" << std::hex << loop->header->startOffset
               << ", Depth: " << loop->header->nestingDepth;
     GrowableListIterator iter;
     oatGrowableListIteratorInit(&loop->incomingBackEdges, &iter);
     BasicBlock* edgeBB;
-    for (edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); edgeBB;
-         edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
+    for (edgeBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter)); edgeBB;
+         edgeBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter))) {
       LOG(INFO) << "    Backedge block id " << edgeBB->id
                 << ", offset 0x" << std::hex << edgeBB->startOffset;
       ArenaBitVectorIterator bIter;
@@ -2344,8 +2338,7 @@
       for (int bbId = oatBitVectorIteratorNext(&bIter); bbId != -1;
            bbId = oatBitVectorIteratorNext(&bIter)) {
         BasicBlock *bb;
-        bb = (BasicBlock*)
-            oatGrowableListGetElement(&cUnit->blockList, bbId);
+        bb = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(&cUnit->blockList, bbId));
         LOG(INFO) << "        (" << bb->id << ", 0x" << std::hex
                   << bb->startOffset << ")";
       }
@@ -2360,33 +2353,32 @@
   }
   oatInitGrowableList(cUnit, &cUnit->loopHeaders, 6, kListMisc);
   // Find the loop headers
-  oatDataFlowAnalysisDispatcher(cUnit, findBackEdges,
-                                kAllNodes, false /* isIterative */);
+  oatDataFlowAnalysisDispatcher(cUnit, findBackEdges, kAllNodes, false /* isIterative */);
   GrowableListIterator iter;
   oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
   // Add blocks to each header
-  for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
-       loop; loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
+  for (LoopInfo* loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter));
+       loop; loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter))) {
     loop->blocks = oatAllocBitVector(cUnit, cUnit->numBlocks, true,
                                      kBitMapMisc);
     oatSetBit(cUnit, loop->blocks, loop->header->id);
     GrowableListIterator iter;
     oatGrowableListIteratorInit(&loop->incomingBackEdges, &iter);
     BasicBlock* edgeBB;
-    for (edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter); edgeBB;
-         edgeBB = (BasicBlock*)oatGrowableListIteratorNext(&iter)) {
+    for (edgeBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter)); edgeBB;
+         edgeBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter))) {
       addBlocksToLoop(cUnit, loop->blocks, edgeBB, loop->header->id);
     }
   }
   // Compute the nesting depth of each header
   oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
-  for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
-       loop; loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
+  for (LoopInfo* loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter));
+       loop; loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter))) {
     GrowableListIterator iter2;
     oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter2);
     LoopInfo* loop2;
-    for (loop2 = (LoopInfo*)oatGrowableListIteratorNext(&iter2);
-         loop2; loop2 = (LoopInfo*)oatGrowableListIteratorNext(&iter2)) {
+    for (loop2 = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter2));
+         loop2; loop2 = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter2))) {
       if (oatIsBitSet(loop2->blocks, loop->header->id)) {
          loop->header->nestingDepth++;
       }
@@ -2394,14 +2386,14 @@
   }
   // Assign nesting depth to each block in all loops
   oatGrowableListIteratorInit(&cUnit->loopHeaders, &iter);
-  for (LoopInfo* loop = (LoopInfo*)oatGrowableListIteratorNext(&iter);
-       (loop != NULL); loop = (LoopInfo*)oatGrowableListIteratorNext(&iter)) {
+  for (LoopInfo* loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter));
+       (loop != NULL); loop = reinterpret_cast<LoopInfo*>(oatGrowableListIteratorNext(&iter))) {
     ArenaBitVectorIterator bIter;
     oatBitVectorIteratorInit(loop->blocks, &bIter);
     for (int bbId = oatBitVectorIteratorNext(&bIter); bbId != -1;
         bbId = oatBitVectorIteratorNext(&bIter)) {
       BasicBlock *bb;
-      bb = (BasicBlock*) oatGrowableListGetElement(&cUnit->blockList, bbId);
+      bb = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(&cUnit->blockList, bbId));
       bb->nestingDepth = std::max(bb->nestingDepth,
                                   loop->header->nestingDepth);
     }
@@ -2442,7 +2434,7 @@
       type = kSuper;
       break;
     default:
-      LOG(WARNING) << "Unexpected invoke op: " << (int)opcode;
+      LOG(WARNING) << "Unexpected invoke op: " << opcode;
       return false;
   }
   OatCompilationUnit mUnit(cUnit->class_loader, cUnit->class_linker,
@@ -2477,10 +2469,10 @@
     if (mir->ssaRep == NULL) {
       continue;
     }
-    uint32_t weight = std::min(16U, (uint32_t)bb->nestingDepth);
+    uint32_t weight = std::min(16U, static_cast<uint32_t>(bb->nestingDepth));
     for (int i = 0; i < mir->ssaRep->numUses; i++) {
       int sReg = mir->ssaRep->uses[i];
-      DCHECK_LT(sReg, (int)cUnit->useCounts.numUsed);
+      DCHECK_LT(sReg, static_cast<int>(cUnit->useCounts.numUsed));
       cUnit->rawUseCounts.elemList[sReg]++;
       cUnit->useCounts.elemList[sReg] += (1 << weight);
     }
@@ -2511,10 +2503,8 @@
 
 void oatMethodUseCount(CompilationUnit *cUnit)
 {
-  oatInitGrowableList(cUnit, &cUnit->useCounts, cUnit->numSSARegs + 32,
-                      kListMisc);
-  oatInitGrowableList(cUnit, &cUnit->rawUseCounts, cUnit->numSSARegs + 32,
-                      kListMisc);
+  oatInitGrowableList(cUnit, &cUnit->useCounts, cUnit->numSSARegs + 32, kListMisc);
+  oatInitGrowableList(cUnit, &cUnit->rawUseCounts, cUnit->numSSARegs + 32, kListMisc);
   // Initialize list
   for (int i = 0; i < cUnit->numSSARegs; i++) {
     oatInsertGrowableList(cUnit, &cUnit->useCounts, 0);
diff --git a/src/compiler/frontend.cc b/src/compiler/frontend.cc
index 134aaa7..c329e9d 100644
--- a/src/compiler/frontend.cc
+++ b/src/compiler/frontend.cc
@@ -100,7 +100,7 @@
 
 inline bool contentIsInsn(const uint16_t* codePtr) {
   uint16_t instr = *codePtr;
-  Instruction::Code opcode = (Instruction::Code)(instr & 0xff);
+  Instruction::Code opcode = static_cast<Instruction::Code>(instr & 0xff);
 
   /*
    * Since the low 8-bit in metadata may look like NOP, we need to check
@@ -126,8 +126,7 @@
   if (printMe) {
     char* decodedString = oatGetDalvikDisassembly(cUnit, *decoded_instruction,
                                                   NULL);
-    LOG(INFO) << codePtr << ": 0x"
-              << std::hex << static_cast<int>(decoded_instruction->opcode)
+    LOG(INFO) << codePtr << ": 0x" << std::hex << static_cast<int>(decoded_instruction->opcode)
               << " " << decodedString;
   }
   return instruction->SizeInCodeUnits();
@@ -175,7 +174,7 @@
   }
   BasicBlock *bottomBlock = oatNewBB(cUnit, kDalvikByteCode,
                                      cUnit->numBlocks++);
-  oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bottomBlock);
+  oatInsertGrowableList(cUnit, &cUnit->blockList, reinterpret_cast<uintptr_t>(bottomBlock));
 
   bottomBlock->startOffset = codeOffset;
   bottomBlock->firstMIRInsn = insn;
@@ -188,22 +187,21 @@
   bottomBlock->taken = origBlock->taken;
   if (bottomBlock->taken) {
     origBlock->taken = NULL;
-    oatDeleteGrowableList(bottomBlock->taken->predecessors,
-                          (intptr_t)origBlock);
+    oatDeleteGrowableList(bottomBlock->taken->predecessors, reinterpret_cast<uintptr_t>(origBlock));
     oatInsertGrowableList(cUnit, bottomBlock->taken->predecessors,
-                          (intptr_t)bottomBlock);
+                          reinterpret_cast<uintptr_t>(bottomBlock));
   }
 
   /* Handle the fallthrough path */
   bottomBlock->fallThrough = origBlock->fallThrough;
   origBlock->fallThrough = bottomBlock;
   oatInsertGrowableList(cUnit, bottomBlock->predecessors,
-                        (intptr_t)origBlock);
+                        reinterpret_cast<uintptr_t>(origBlock));
   if (bottomBlock->fallThrough) {
     oatDeleteGrowableList(bottomBlock->fallThrough->predecessors,
-                          (intptr_t)origBlock);
+                          reinterpret_cast<uintptr_t>(origBlock));
     oatInsertGrowableList(cUnit, bottomBlock->fallThrough->predecessors,
-                          (intptr_t)bottomBlock);
+                          reinterpret_cast<uintptr_t>(bottomBlock));
   }
 
   /* Handle the successor list */
@@ -216,11 +214,11 @@
                                 &iterator);
     while (true) {
       SuccessorBlockInfo *successorBlockInfo =
-          (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+          reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
       if (successorBlockInfo == NULL) break;
       BasicBlock *bb = successorBlockInfo->block;
-      oatDeleteGrowableList(bb->predecessors, (intptr_t)origBlock);
-      oatInsertGrowableList(cUnit, bb->predecessors, (intptr_t)bottomBlock);
+      oatDeleteGrowableList(bb->predecessors, reinterpret_cast<uintptr_t>(origBlock));
+      oatInsertGrowableList(cUnit, bb->predecessors, reinterpret_cast<uintptr_t>(bottomBlock));
     }
   }
 
@@ -264,7 +262,7 @@
 
   if (split) {
     for (i = 0; i < blockList->numUsed; i++) {
-      bb = (BasicBlock *) blockList->elemList[i];
+      bb = reinterpret_cast<BasicBlock*>(blockList->elemList[i]);
       if (bb->blockType != kDalvikByteCode) continue;
       /* Check if a branch jumps into the middle of an existing block */
       if ((codeOffset > bb->startOffset) && (bb->lastMIRInsn != NULL) &&
@@ -279,7 +277,7 @@
 
   /* Create a new one */
   bb = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++);
-  oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) bb);
+  oatInsertGrowableList(cUnit, &cUnit->blockList, reinterpret_cast<uintptr_t>(bb));
   bb->startOffset = codeOffset;
   cUnit->blockMap.Put(bb->startOffset, bb);
   return bb;
@@ -324,8 +322,7 @@
 
   for (idx = 0; idx < numReachableBlocks; idx++) {
     int blockIdx = cUnit->dfsOrder.elemList[idx];
-    BasicBlock *bb = (BasicBlock *) oatGrowableListGetElement(blockList,
-                                                              blockIdx);
+    BasicBlock *bb = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, blockIdx));
     if (bb == NULL) break;
     if (bb->blockType == kDead) continue;
     if (bb->blockType == kEntryBlock) {
@@ -375,7 +372,7 @@
       oatGrowableListIteratorInit(&bb->successorBlockList.blocks,
                                   &iterator);
       SuccessorBlockInfo *successorBlockInfo =
-          (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+          reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
 
       int succId = 0;
       while (true) {
@@ -383,7 +380,7 @@
 
         BasicBlock *destBlock = successorBlockInfo->block;
         SuccessorBlockInfo *nextSuccessorBlockInfo =
-            (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+            reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
 
         fprintf(file, "    {<f%d> %04x: %04x\\l}%s\\\n",
                 succId++,
@@ -407,8 +404,8 @@
 
         succId = 0;
         while (true) {
-          SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
-              oatGrowableListIteratorNext(&iterator);
+          SuccessorBlockInfo *successorBlockInfo =
+              reinterpret_cast<SuccessorBlockInfo*>( oatGrowableListIteratorNext(&iterator));
           if (successorBlockInfo == NULL) break;
 
           BasicBlock *destBlock = successorBlockInfo->block;
@@ -441,7 +438,7 @@
 
   oatGrowableListIteratorInit(bb->predecessors, &iter);
   while (true) {
-    BasicBlock *predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+    BasicBlock *predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
     if (!predBB) break;
     bool found = false;
     if (predBB->taken == bb) {
@@ -453,8 +450,8 @@
       oatGrowableListIteratorInit(&predBB->successorBlockList.blocks,
                                   &iterator);
       while (true) {
-        SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
-            oatGrowableListIteratorNext(&iterator);
+        SuccessorBlockInfo *successorBlockInfo =
+            reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
         if (successorBlockInfo == NULL) break;
         BasicBlock *succBB = successorBlockInfo->block;
         if (succBB == bb) {
@@ -522,7 +519,7 @@
     case Instruction::GOTO:
     case Instruction::GOTO_16:
     case Instruction::GOTO_32:
-      target += (int) insn->dalvikInsn.vA;
+      target += insn->dalvikInsn.vA;
       break;
     case Instruction::IF_EQ:
     case Instruction::IF_NE:
@@ -531,7 +528,7 @@
     case Instruction::IF_GT:
     case Instruction::IF_LE:
       curBlock->conditionalBranch = true;
-      target += (int) insn->dalvikInsn.vC;
+      target += insn->dalvikInsn.vC;
       break;
     case Instruction::IF_EQZ:
     case Instruction::IF_NEZ:
@@ -540,11 +537,10 @@
     case Instruction::IF_GTZ:
     case Instruction::IF_LEZ:
       curBlock->conditionalBranch = true;
-      target += (int) insn->dalvikInsn.vB;
+      target += insn->dalvikInsn.vB;
       break;
     default:
-      LOG(FATAL) << "Unexpected opcode(" << (int)insn->dalvikInsn.opcode
-                 << ") with kBranch set";
+      LOG(FATAL) << "Unexpected opcode(" << insn->dalvikInsn.opcode << ") with kBranch set";
   }
   BasicBlock *takenBlock = findBlock(cUnit, target,
                                      /* split */
@@ -554,7 +550,7 @@
                                      /* immedPredBlockP */
                                      &curBlock);
   curBlock->taken = takenBlock;
-  oatInsertGrowableList(cUnit, takenBlock->predecessors, (intptr_t)curBlock);
+  oatInsertGrowableList(cUnit, takenBlock->predecessors, reinterpret_cast<uintptr_t>(curBlock));
 
   /* Always terminate the current block for conditional branches */
   if (flags & Instruction::kContinue) {
@@ -579,7 +575,7 @@
                                              &curBlock);
     curBlock->fallThrough = fallthroughBlock;
     oatInsertGrowableList(cUnit, fallthroughBlock->predecessors,
-                          (intptr_t)curBlock);
+                          reinterpret_cast<uintptr_t>(curBlock));
   } else if (codePtr < codeEnd) {
     /* Create a fallthrough block for real instructions (incl. NOP) */
     if (contentIsInsn(codePtr)) {
@@ -599,10 +595,11 @@
 void processCanSwitch(CompilationUnit* cUnit, BasicBlock* curBlock,
                       MIR* insn, int curOffset, int width, int flags)
 {
-  uint16_t* switchData= (uint16_t*) (cUnit->insns + curOffset + insn->dalvikInsn.vB);
+  const uint16_t* switchData =
+      reinterpret_cast<const uint16_t*>(cUnit->insns + curOffset + insn->dalvikInsn.vB);
   int size;
-  int* keyTable;
-  int* targetTable;
+  const int* keyTable;
+  const int* targetTable;
   int i;
   int firstKey;
 
@@ -620,7 +617,7 @@
               static_cast<int>(Instruction::kPackedSwitchSignature));
     size = switchData[1];
     firstKey = switchData[2] | (switchData[3] << 16);
-    targetTable = (int *) &switchData[4];
+    targetTable = reinterpret_cast<const int*>(&switchData[4]);
     keyTable = NULL;        // Make the compiler happy
   /*
    * Sparse switch data format:
@@ -635,14 +632,14 @@
     DCHECK_EQ(static_cast<int>(switchData[0]),
               static_cast<int>(Instruction::kSparseSwitchSignature));
     size = switchData[1];
-    keyTable = (int *) &switchData[2];
-    targetTable = (int *) &switchData[2 + size*2];
+    keyTable = reinterpret_cast<const int*>(&switchData[2]);
+    targetTable = reinterpret_cast<const int*>(&switchData[2 + size*2]);
     firstKey = 0;   // To make the compiler happy
   }
 
   if (curBlock->successorBlockList.blockListType != kNotUsed) {
     LOG(FATAL) << "Successor block list already in use: "
-               << (int)curBlock->successorBlockList.blockListType;
+               << static_cast<int>(curBlock->successorBlockList.blockListType);
   }
   curBlock->successorBlockList.blockListType =
       (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ?
@@ -659,16 +656,16 @@
                                       /* immedPredBlockP */
                                       &curBlock);
     SuccessorBlockInfo *successorBlockInfo =
-        (SuccessorBlockInfo *) oatNew(cUnit, sizeof(SuccessorBlockInfo),
-                                      false, kAllocSuccessor);
+        static_cast<SuccessorBlockInfo*>(oatNew(cUnit, sizeof(SuccessorBlockInfo),
+                                         false, kAllocSuccessor));
     successorBlockInfo->block = caseBlock;
     successorBlockInfo->key =
         (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ?
         firstKey + i : keyTable[i];
     oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks,
-                          (intptr_t) successorBlockInfo);
+                          reinterpret_cast<uintptr_t>(successorBlockInfo));
     oatInsertGrowableList(cUnit, caseBlock->predecessors,
-                          (intptr_t)curBlock);
+                          reinterpret_cast<uintptr_t>(curBlock));
   }
 
   /* Fall-through case */
@@ -682,7 +679,7 @@
                                            NULL);
   curBlock->fallThrough = fallthroughBlock;
   oatInsertGrowableList(cUnit, fallthroughBlock->predecessors,
-                        (intptr_t)curBlock);
+                        reinterpret_cast<uintptr_t>(curBlock));
 }
 
 /* Process instructions with the kThrow flag */
@@ -701,7 +698,7 @@
     if (curBlock->successorBlockList.blockListType != kNotUsed) {
       LOG(INFO) << PrettyMethod(cUnit->method_idx, *cUnit->dex_file);
       LOG(FATAL) << "Successor block list already in use: "
-                 << (int)curBlock->successorBlockList.blockListType;
+                 << static_cast<int>(curBlock->successorBlockList.blockListType);
     }
 
     curBlock->successorBlockList.blockListType = kCatch;
@@ -715,22 +712,22 @@
                                          NULL  /* immedPredBlockP */);
       catchBlock->catchEntry = true;
       cUnit->catches.insert(catchBlock->startOffset);
-      SuccessorBlockInfo *successorBlockInfo = (SuccessorBlockInfo *)
-          oatNew(cUnit, sizeof(SuccessorBlockInfo), false, kAllocSuccessor);
+      SuccessorBlockInfo *successorBlockInfo = reinterpret_cast<SuccessorBlockInfo*>
+          (oatNew(cUnit, sizeof(SuccessorBlockInfo), false, kAllocSuccessor));
       successorBlockInfo->block = catchBlock;
       successorBlockInfo->key = iterator.GetHandlerTypeIndex();
       oatInsertGrowableList(cUnit, &curBlock->successorBlockList.blocks,
-                            (intptr_t) successorBlockInfo);
+                            reinterpret_cast<uintptr_t>(successorBlockInfo));
       oatInsertGrowableList(cUnit, catchBlock->predecessors,
-                            (intptr_t)curBlock);
+                            reinterpret_cast<uintptr_t>(curBlock));
     }
   } else {
     BasicBlock *ehBlock = oatNewBB(cUnit, kExceptionHandling,
                                    cUnit->numBlocks++);
     curBlock->taken = ehBlock;
-    oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t) ehBlock);
+    oatInsertGrowableList(cUnit, &cUnit->blockList, reinterpret_cast<uintptr_t>(ehBlock));
     ehBlock->startOffset = curOffset;
-    oatInsertGrowableList(cUnit, ehBlock->predecessors, (intptr_t)curBlock);
+    oatInsertGrowableList(cUnit, ehBlock->predecessors, reinterpret_cast<uintptr_t>(curBlock));
   }
 
   if (insn->dalvikInsn.opcode == Instruction::THROW){
@@ -761,11 +758,11 @@
    * contain following instructions.
    */
   BasicBlock *newBlock = oatNewBB(cUnit, kDalvikByteCode, cUnit->numBlocks++);
-  oatInsertGrowableList(cUnit, &cUnit->blockList, (intptr_t)newBlock);
+  oatInsertGrowableList(cUnit, &cUnit->blockList, reinterpret_cast<uintptr_t>(newBlock));
   newBlock->startOffset = insn->offset;
   curBlock->fallThrough = newBlock;
-  oatInsertGrowableList(cUnit, newBlock->predecessors, (intptr_t)curBlock);
-  MIR* newInsn = (MIR*)oatNew(cUnit, sizeof(MIR), true, kAllocMIR);
+  oatInsertGrowableList(cUnit, newBlock->predecessors, reinterpret_cast<uintptr_t>(curBlock));
+  MIR* newInsn = static_cast<MIR*>(oatNew(cUnit, sizeof(MIR), true, kAllocMIR));
   *newInsn = *insn;
   insn->dalvikInsn.opcode =
       static_cast<Instruction::Code>(kMirOpCheck);
@@ -892,8 +889,8 @@
 
   /* Gathering opcode stats? */
   if (kCompilerDebugFlags & (1 << kDebugCountOpcodes)) {
-    cUnit->opcodeCount = (int*)oatNew(cUnit.get(),
-       kNumPackedOpcodes * sizeof(int), true, kAllocMisc);
+    cUnit->opcodeCount =
+        static_cast<int*>(oatNew(cUnit.get(), kNumPackedOpcodes * sizeof(int), true, kAllocMisc));
   }
 
   /* Assume non-throwing leaf */
@@ -937,18 +934,18 @@
   cUnit->entryBlock = entryBlock;
   cUnit->exitBlock = exitBlock;
 
-  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) entryBlock);
-  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) exitBlock);
+  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, reinterpret_cast<uintptr_t>(entryBlock));
+  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, reinterpret_cast<uintptr_t>(exitBlock));
 
   /* Current block to record parsed instructions */
   BasicBlock *curBlock = oatNewBB(cUnit.get(), kDalvikByteCode, numBlocks++);
   curBlock->startOffset = 0;
-  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, (intptr_t) curBlock);
+  oatInsertGrowableList(cUnit.get(), &cUnit->blockList, reinterpret_cast<uintptr_t>(curBlock));
   /* Add first block to the fast lookup cache */
   cUnit->blockMap.Put(curBlock->startOffset, curBlock);
   entryBlock->fallThrough = curBlock;
   oatInsertGrowableList(cUnit.get(), curBlock->predecessors,
-                        (intptr_t)entryBlock);
+                        reinterpret_cast<uintptr_t>(entryBlock));
 
   /*
    * Store back the number of blocks since new blocks may be created of
@@ -962,14 +959,14 @@
   /* Set up for simple method detection */
   int numPatterns = sizeof(specialPatterns)/sizeof(specialPatterns[0]);
   bool livePattern = (numPatterns > 0) && !(cUnit->disableOpt & (1 << kMatch));
-  bool* deadPattern = (bool*)oatNew(cUnit.get(), sizeof(bool) * numPatterns, true,
-                                     kAllocMisc);
+  bool* deadPattern =
+      static_cast<bool*>(oatNew(cUnit.get(), sizeof(bool) * numPatterns, true, kAllocMisc));
   SpecialCaseHandler specialCase = kNoHandler;
   int patternPos = 0;
 
   /* Parse all instructions and put them into containing basic blocks */
   while (codePtr < codeEnd) {
-    MIR *insn = (MIR *) oatNew(cUnit.get(), sizeof(MIR), true, kAllocMIR);
+    MIR *insn = static_cast<MIR *>(oatNew(cUnit.get(), sizeof(MIR), true, kAllocMIR));
     insn->offset = curOffset;
     int width = parseInsn(cUnit.get(), codePtr, &insn->dalvikInsn, false);
     insn->width = width;
@@ -1016,7 +1013,7 @@
     } else if (flags & Instruction::kReturn) {
       curBlock->fallThrough = exitBlock;
       oatInsertGrowableList(cUnit.get(), exitBlock->predecessors,
-                            (intptr_t)curBlock);
+                            reinterpret_cast<uintptr_t>(curBlock));
       /*
        * Terminate the current block if there are instructions
        * afterwards.
@@ -1064,7 +1061,7 @@
       if ((curBlock->fallThrough == NULL) && (flags & Instruction::kContinue)) {
         curBlock->fallThrough = nextBlock;
         oatInsertGrowableList(cUnit.get(), nextBlock->predecessors,
-                              (intptr_t)curBlock);
+                              reinterpret_cast<uintptr_t>(curBlock));
       }
       curBlock = nextBlock;
     }
@@ -1113,8 +1110,7 @@
   cUnit->isConstantV = oatAllocBitVector(cUnit.get(), cUnit->numSSARegs,
                                          false  /* not expandable */);
   cUnit->constantValues =
-      (int*)oatNew(cUnit.get(), sizeof(int) * cUnit->numSSARegs, true,
-                   kAllocDFInfo);
+      static_cast<int*>(oatNew(cUnit.get(), sizeof(int) * cUnit->numSSARegs, true, kAllocDFInfo));
   oatDataFlowAnalysisDispatcher(cUnit.get(), oatDoConstantPropagation,
                                 kAllNodes,
                                 false /* isIterative */);
diff --git a/src/compiler/frontend.h b/src/compiler/frontend.h
index 049d9d4..702d5d4 100644
--- a/src/compiler/frontend.h
+++ b/src/compiler/frontend.h
@@ -105,16 +105,6 @@
 #define METHOD_IS_SETTER        (1 << kIsSetter)
 #define METHOD_CANNOT_COMPILE   (1 << kCannotCompile)
 
-/* Customized node traversal orders for different needs */
-enum DataFlowAnalysisMode {
-  kAllNodes = 0,              // All nodes
-  kReachableNodes,            // All reachable nodes
-  kPreOrderDFSTraversal,      // Depth-First-Search / Pre-Order
-  kPostOrderDFSTraversal,     // Depth-First-Search / Post-Order
-  kPostOrderDOMTraversal,     // Dominator tree / Post-Order
-  kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order
-};
-
 class LLVMInfo {
   public:
     LLVMInfo();
diff --git a/src/compiler/intermediate_rep.cc b/src/compiler/intermediate_rep.cc
index 2c648d9..6930d76 100644
--- a/src/compiler/intermediate_rep.cc
+++ b/src/compiler/intermediate_rep.cc
@@ -18,61 +18,14 @@
 
 namespace art {
 
-static const char* gOpKindNames[kOpInvalid + 1] = {
-  "OpMov",
-  "OpMvn",
-  "OpCmp",
-  "OpLsl",
-  "OpLsr",
-  "OpAsr",
-  "OpRor",
-  "OpNot",
-  "OpAnd",
-  "OpOr",
-  "OpXor",
-  "OpNeg",
-  "OpAdd",
-  "OpAdc",
-  "OpSub",
-  "OpSbc",
-  "OpRsub",
-  "OpMul",
-  "OpDiv",
-  "OpRem",
-  "OpBic",
-  "OpCmn",
-  "OpTst",
-  "OpBkpt",
-  "OpBlx",
-  "OpPush",
-  "OpPop",
-  "Op2Char",
-  "Op2Short",
-  "Op2Byte",
-  "OpCondBr",
-  "OpUncondBr",
-  "OpBx",
-  "OpInvalid",
-};
-
-std::ostream& operator<<(std::ostream& os, const OpKind& kind) {
-  if (kind >= kOpMov && kind <= kOpInvalid) {
-    os << gOpKindNames[kind];
-  } else {
-    os << "Unknown Op " << static_cast<int>(kind);
-  }
-  return os;
-}
-
 /* Allocate a new basic block */
 BasicBlock* oatNewBB(CompilationUnit* cUnit, BBType blockType, int blockId)
 {
-  BasicBlock* bb = (BasicBlock* )oatNew(cUnit, sizeof(BasicBlock), true,
-                                        kAllocBB);
+  BasicBlock* bb = static_cast<BasicBlock*>(oatNew(cUnit, sizeof(BasicBlock), true, kAllocBB));
   bb->blockType = blockType;
   bb->id = blockId;
-  bb->predecessors = (GrowableList*) oatNew(cUnit, sizeof(GrowableList),
-                                            false, kAllocPredecessors);
+  bb->predecessors = static_cast<GrowableList*>
+      (oatNew(cUnit, sizeof(GrowableList), false, kAllocPredecessors));
   oatInitGrowableList(cUnit, bb->predecessors,
                       (blockType == kExitBlock) ? 2048 : 2,
                       kListPredecessors);
diff --git a/src/compiler/ralloc.cc b/src/compiler/ralloc.cc
index ffb7fec..34edb51 100644
--- a/src/compiler/ralloc.cc
+++ b/src/compiler/ralloc.cc
@@ -410,8 +410,8 @@
   RegLocation* loc;
 
   /* Allocate the location map */
-  loc = (RegLocation*)oatNew(cUnit, cUnit->numSSARegs * sizeof(*loc), true,
-                             kAllocRegAlloc);
+  loc = static_cast<RegLocation*>(oatNew(cUnit, cUnit->numSSARegs * sizeof(*loc),
+                                  true, kAllocRegAlloc));
   for (i=0; i< cUnit->numSSARegs; i++) {
     loc[i] = freshLoc;
     loc[i].sRegLow = i;
@@ -422,7 +422,7 @@
   loc[cUnit->methodSReg].location = kLocCompilerTemp;
   loc[cUnit->methodSReg].defined = true;
   for (i = 0; i < cUnit->numCompilerTemps; i++) {
-    CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
+    CompilerTemp* ct = reinterpret_cast<CompilerTemp*>(cUnit->compilerTemps.elemList[i]);
     loc[ct->sReg].location = kLocCompilerTemp;
     loc[ct->sReg].defined = true;
   }
@@ -431,10 +431,9 @@
 
   /* Allocation the promotion map */
   int numRegs = cUnit->numDalvikRegisters;
-  cUnit->promotionMap =
-      (PromotionMap*)oatNew(cUnit, (numRegs + cUnit->numCompilerTemps + 1) *
-                            sizeof(cUnit->promotionMap[0]), true,
-                            kAllocRegAlloc);
+  cUnit->promotionMap = static_cast<PromotionMap*>
+      (oatNew(cUnit, (numRegs + cUnit->numCompilerTemps + 1) * sizeof(cUnit->promotionMap[0]),
+              true, kAllocRegAlloc));
 
   /* Add types of incoming arguments based on signature */
   int numIns = cUnit->numIns;
diff --git a/src/compiler/ssa_transformation.cc b/src/compiler/ssa_transformation.cc
index e689f6a..bbe08f5 100644
--- a/src/compiler/ssa_transformation.cc
+++ b/src/compiler/ssa_transformation.cc
@@ -42,8 +42,8 @@
         oatGrowableListIteratorInit(&bb->successorBlockList.blocks,
                                     &iterator);
         while (true) {
-          SuccessorBlockInfo *sbi = (SuccessorBlockInfo*)
-              oatGrowableListIteratorNext(&iterator);
+          SuccessorBlockInfo *sbi = reinterpret_cast<SuccessorBlockInfo*>
+              (oatGrowableListIteratorNext(&iterator));
           if (sbi == NULL) break;
           res = needsVisit(sbi->block);
           if (res != NULL) break;
@@ -246,9 +246,8 @@
 {
   int numRegisters = cUnit->numDalvikRegisters;
   /* Allocate numDalvikRegisters bit vector pointers */
-  cUnit->defBlockMatrix = (ArenaBitVector **)
-      oatNew(cUnit, sizeof(ArenaBitVector *) * numRegisters, true,
-             kAllocDFInfo);
+  cUnit->defBlockMatrix = static_cast<ArenaBitVector**>
+      (oatNew(cUnit, sizeof(ArenaBitVector *) * numRegisters, true, kAllocDFInfo));
   int i;
 
   /* Initialize numRegister vectors with numBlocks bits each */
@@ -285,7 +284,7 @@
     int bbIdx = oatBitVectorIteratorNext(&bvIterator);
     if (bbIdx == -1) break;
     BasicBlock* dominatedBB =
-        (BasicBlock* ) oatGrowableListGetElement(blockList, bbIdx);
+        reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, bbIdx));
     computeDomPostOrderTraversal(cUnit, dominatedBB);
   }
 
@@ -330,7 +329,7 @@
                                   &iterator);
       while (true) {
         SuccessorBlockInfo *successorBlockInfo =
-            (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+            reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
         if (successorBlockInfo == NULL) break;
         BasicBlock* succBB = successorBlockInfo->block;
         checkForDominanceFrontier(cUnit, bb, succBB);
@@ -344,16 +343,16 @@
     //TUNING: hot call to oatBitVectorIteratorNext
     int dominatedIdx = oatBitVectorIteratorNext(&bvIterator);
     if (dominatedIdx == -1) break;
-    BasicBlock* dominatedBB = (BasicBlock* )
-        oatGrowableListGetElement(blockList, dominatedIdx);
+    BasicBlock* dominatedBB =
+        reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, dominatedIdx));
     ArenaBitVectorIterator dfIterator;
     oatBitVectorIteratorInit(dominatedBB->domFrontier, &dfIterator);
     while (true) {
       //TUNING: hot call to oatBitVectorIteratorNext
       int dfUpIdx = oatBitVectorIteratorNext(&dfIterator);
       if (dfUpIdx == -1) break;
-      BasicBlock* dfUpBlock = (BasicBlock* )
-          oatGrowableListGetElement(blockList, dfUpIdx);
+      BasicBlock* dfUpBlock =
+          reinterpret_cast<BasicBlock*>( oatGrowableListGetElement(blockList, dfUpIdx));
       checkForDominanceFrontier(cUnit, bb, dfUpBlock);
     }
   }
@@ -410,7 +409,7 @@
   /* Iterate through the predecessors */
   oatGrowableListIteratorInit(bb->predecessors, &iter);
   while (true) {
-    BasicBlock* predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+    BasicBlock* predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
     if (!predBB) break;
     /* tempBlockV = tempBlockV ^ dominators */
     if (predBB->dominators != NULL) {
@@ -446,9 +445,8 @@
   /* Should not see any dead block */
   DCHECK_NE(oatCountSetBits(tempBlockV),  0);
   if (oatCountSetBits(tempBlockV) == 1) {
-    iDom = (BasicBlock* )
-        oatGrowableListGetElement(blockList,
-                                  oatBitVectorIteratorNext(&bvIterator));
+    iDom = reinterpret_cast<BasicBlock*>
+        (oatGrowableListGetElement(blockList, oatBitVectorIteratorNext(&bvIterator)));
     bb->iDom = iDom;
   } else {
     int iDomIdx = oatBitVectorIteratorNext(&bvIterator);
@@ -456,15 +454,15 @@
     while (true) {
       int nextDom = oatBitVectorIteratorNext(&bvIterator);
       if (nextDom == -1) break;
-      BasicBlock* nextDomBB = (BasicBlock* )
-          oatGrowableListGetElement(blockList, nextDom);
+      BasicBlock* nextDomBB =
+          reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, nextDom));
       /* iDom dominates nextDom - set new iDom */
       if (oatIsBitSet(nextDomBB->dominators, iDomIdx)) {
           iDomIdx = nextDom;
       }
 
     }
-    iDom = (BasicBlock* ) oatGrowableListGetElement(blockList, iDomIdx);
+    iDom = reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, iDomIdx));
     /* Set the immediate dominator block for bb */
     bb->iDom = iDom;
   }
@@ -509,7 +507,7 @@
 
   /* Find the first processed predecessor */
   while (true) {
-    BasicBlock* predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+    BasicBlock* predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
     CHECK(predBB != NULL);
     if (cUnit->iDomList[predBB->dfsId] != NOTVISITED) {
       idom = predBB->dfsId;
@@ -519,7 +517,7 @@
 
   /* Scan the rest of the predecessors */
   while (true) {
-      BasicBlock* predBB = (BasicBlock*)oatGrowableListIteratorNext(&iter);
+      BasicBlock* predBB = reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
       if (!predBB) break;
       if (cUnit->iDomList[predBB->dfsId] == NOTVISITED) {
         continue;
@@ -556,8 +554,8 @@
     int iDomDFSIdx = cUnit->iDomList[bb->dfsId];
     DCHECK_NE(iDomDFSIdx, NOTVISITED);
     int iDomIdx = cUnit->dfsPostOrder.elemList[iDomDFSIdx];
-    BasicBlock* iDom = (BasicBlock*)
-          oatGrowableListGetElement(&cUnit->blockList, iDomIdx);
+    BasicBlock* iDom =
+        reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(&cUnit->blockList, iDomIdx));
     if (cUnit->enableDebug & (1 << kDebugVerifyDataflow)) {
       DCHECK_EQ(bb->iDom->id, iDom->id);
     }
@@ -580,8 +578,8 @@
 
   /* Initalize & Clear iDomList */
   if (cUnit->iDomList == NULL) {
-    cUnit->iDomList = (int*)oatNew(cUnit, sizeof(int) * numReachableBlocks,
-                                   false, kAllocDFInfo);
+    cUnit->iDomList = static_cast<int*>(oatNew(cUnit, sizeof(int) * numReachableBlocks,
+                                               false, kAllocDFInfo));
   }
   for (int i = 0; i < numReachableBlocks; i++) {
     cUnit->iDomList[i] = NOTVISITED;
@@ -641,8 +639,7 @@
   }
 
   computeDomPostOrderTraversal(cUnit, cUnit->entryBlock);
-  DCHECK_EQ(cUnit->domPostOrderTraversal.numUsed,
-         (unsigned) cUnit->numReachableBlocks);
+  DCHECK_EQ(cUnit->domPostOrderTraversal.numUsed, static_cast<unsigned>(cUnit->numReachableBlocks));
 
   /* Now compute the dominance frontier for each block */
   oatDataFlowAnalysisDispatcher(cUnit, computeDominanceFrontier,
@@ -695,7 +692,7 @@
                                 &iterator);
     while (true) {
       SuccessorBlockInfo *successorBlockInfo =
-          (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+          reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
       if (successorBlockInfo == NULL) break;
       BasicBlock* succBB = successorBlockInfo->block;
       if (succBB->dataFlowInfo) {
@@ -749,7 +746,7 @@
         int idx = oatBitVectorIteratorNext(&iterator);
         if (idx == -1) break;
           BasicBlock* defBB =
-              (BasicBlock* ) oatGrowableListGetElement(blockList, idx);
+              reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, idx));
 
           /* Merge the dominance frontier to tmpBlocks */
           //TUNING: hot call to oatUnifyBitVectors
@@ -780,11 +777,11 @@
       int idx = oatBitVectorIteratorNext(&iterator);
       if (idx == -1) break;
       BasicBlock* phiBB =
-          (BasicBlock* ) oatGrowableListGetElement(blockList, idx);
+          reinterpret_cast<BasicBlock*>(oatGrowableListGetElement(blockList, idx));
       /* Variable will be clobbered before being used - no need for phi */
       if (!oatIsBitSet(phiBB->dataFlowInfo->liveInV, dalvikReg)) continue;
-      MIR *phi = (MIR *) oatNew(cUnit, sizeof(MIR), true, kAllocDFInfo);
-      phi->dalvikInsn.opcode = (Instruction::Code)kMirOpPhi;
+      MIR *phi = static_cast<MIR*>(oatNew(cUnit, sizeof(MIR), true, kAllocDFInfo));
+      phi->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpPhi);
       phi->dalvikInsn.vA = dalvikReg;
       phi->offset = phiBB->startOffset;
       phi->meta.phiNext = cUnit->phiList;
@@ -807,7 +804,7 @@
 
   /* Phi nodes are at the beginning of each block */
   for (mir = bb->firstMIRInsn; mir; mir = mir->next) {
-    if (mir->dalvikInsn.opcode != (Instruction::Code)kMirOpPhi)
+    if (mir->dalvikInsn.opcode != static_cast<Instruction::Code>(kMirOpPhi))
       return true;
     int ssaReg = mir->ssaRep->defs[0];
     DCHECK_GE(ssaReg, 0);   // Shouldn't see compiler temps here
@@ -820,7 +817,7 @@
     oatGrowableListIteratorInit(bb->predecessors, &iter);
     while (true) {
       BasicBlock* predBB =
-         (BasicBlock*)oatGrowableListIteratorNext(&iter);
+         reinterpret_cast<BasicBlock*>(oatGrowableListIteratorNext(&iter));
       if (!predBB) break;
       int ssaReg = predBB->dataFlowInfo->vRegToSSAMap[vReg];
       uses.push_back(ssaReg);
@@ -831,13 +828,13 @@
     int numUses = uses.size();
     mir->ssaRep->numUses = numUses;
     mir->ssaRep->uses =
-        (int*) oatNew(cUnit, sizeof(int) * numUses, false, kAllocDFInfo);
+        static_cast<int*>(oatNew(cUnit, sizeof(int) * numUses, false, kAllocDFInfo));
     mir->ssaRep->fpUse =
-        (bool*) oatNew(cUnit, sizeof(bool) * numUses, true, kAllocDFInfo);
+        static_cast<bool*>(oatNew(cUnit, sizeof(bool) * numUses, true, kAllocDFInfo));
     int* incoming =
-        (int*) oatNew(cUnit, sizeof(int) * numUses, false, kAllocDFInfo);
+        static_cast<int*>(oatNew(cUnit, sizeof(int) * numUses, false, kAllocDFInfo));
     // TODO: Ugly, rework (but don't burden each MIR/LIR for Phi-only needs)
-    mir->dalvikInsn.vB = (intptr_t) incoming;
+    mir->dalvikInsn.vB = reinterpret_cast<uintptr_t>(incoming);
 
     /* Set the uses array for the phi node */
     int *usePtr = mir->ssaRep->uses;
@@ -861,8 +858,7 @@
   int mapSize = sizeof(int) * cUnit->numDalvikRegisters;
 
   /* Save SSA map snapshot */
-  int* savedSSAMap = (int*)oatNew(cUnit, mapSize, false,
-                                  kAllocDalvikToSSAMap);
+  int* savedSSAMap = static_cast<int*>(oatNew(cUnit, mapSize, false, kAllocDalvikToSSAMap));
   memcpy(savedSSAMap, cUnit->vRegToSSAMap, mapSize);
 
   if (block->fallThrough) {
@@ -877,11 +873,10 @@
   }
   if (block->successorBlockList.blockListType != kNotUsed) {
     GrowableListIterator iterator;
-    oatGrowableListIteratorInit(&block->successorBlockList.blocks,
-                                &iterator);
+    oatGrowableListIteratorInit(&block->successorBlockList.blocks, &iterator);
     while (true) {
       SuccessorBlockInfo *successorBlockInfo =
-          (SuccessorBlockInfo *) oatGrowableListIteratorNext(&iterator);
+          reinterpret_cast<SuccessorBlockInfo*>(oatGrowableListIteratorNext(&iterator));
       if (successorBlockInfo == NULL) break;
       BasicBlock* succBB = successorBlockInfo->block;
       doDFSPreOrderSSARename(cUnit, succBB);
@@ -929,8 +924,7 @@
          false, kBitMapTempSSARegisterV);
 
     cUnit->tempSSABlockIdV =
-        (int*)oatNew(cUnit, sizeof(int) * cUnit->numSSARegs, false,
-                     kAllocDFInfo);
+        static_cast<int*>(oatNew(cUnit, sizeof(int) * cUnit->numSSARegs, false, kAllocDFInfo));
 
     /* Insert phi-operands with latest SSA names from predecessor blocks */
     oatDataFlowAnalysisDispatcher(cUnit, insertPhiNodeOperands,
diff --git a/src/gc/card_table.h b/src/gc/card_table.h
index d0d25fd..5b38ae5 100644
--- a/src/gc/card_table.h
+++ b/src/gc/card_table.h
@@ -244,7 +244,7 @@
 
   // Returns the address of the relevant byte in the card table, given an address on the heap.
   byte* CardFromAddr(const void *addr) const {
-    byte *card_addr = biased_begin_ + ((uintptr_t)addr >> kCardShift);
+    byte *card_addr = biased_begin_ + (reinterpret_cast<uintptr_t>(addr) >> kCardShift);
     // Sanity check the caller was asking for address covered by the card table
     DCHECK(IsValidCard(card_addr)) << "addr: " << addr
         << " card_addr: " << reinterpret_cast<void*>(card_addr);
diff --git a/src/gc/space_bitmap.h b/src/gc/space_bitmap.h
index 25fd538..8bd75d5 100644
--- a/src/gc/space_bitmap.h
+++ b/src/gc/space_bitmap.h
@@ -110,7 +110,7 @@
   bool HasAddress(const void* obj) const {
     // If obj < heap_begin_ then offset underflows to some very large value past the end of the
     // bitmap.
-    const uintptr_t offset = (uintptr_t)obj - heap_begin_;
+    const uintptr_t offset = reinterpret_cast<uintptr_t>(obj) - heap_begin_;
     const size_t index = OffsetToIndex(offset);
     return index < bitmap_size_ / kWordSize;
   }
diff --git a/src/gc_map.h b/src/gc_map.h
index 9e1bed9..afccaa1 100644
--- a/src/gc_map.h
+++ b/src/gc_map.h
@@ -80,7 +80,7 @@
 
   // The number of bytes used to encode registers.
   size_t RegWidth() const {
-    return ((size_t)data_[0] | ((size_t)data_[1] << 8)) >> 3;
+    return (static_cast<size_t>(data_[0]) | (static_cast<size_t>(data_[1]) << 8)) >> 3;
   }
 
  private:
diff --git a/src/leb128.h b/src/leb128.h
index 918d711..a5a6683 100644
--- a/src/leb128.h
+++ b/src/leb128.h
@@ -46,7 +46,7 @@
     }
   }
   *data = ptr;
-  return (uint32_t)result;
+  return static_cast<uint32_t>(result);
 }
 
 // Reads an unsigned LEB128 + 1 value. updating the given pointer to point