Program: 150195
Project: 150195
Buggy source:
/** 
 * Calling convention to implement calls to  native (C) routines using the AIX linkage conventions
 */
public static void expandSysCall(OPT_Instruction s,OPT_IR ir){
  OPT_RegisterOperand ip=null;
  OPT_RegisterOperand t1=OPT_ConvertToLowLevelIR.getStatic(s,ir,VM_Entrypoints.the_boot_recordField);
  OPT_RegisterOperand toc=OPT_ConvertToLowLevelIR.getField(s,ir,t1,VM_Entrypoints.sysTOCField);
  if (Call.getMethod(s) != null) {
    OPT_MethodOperand nat=Call.getClearMethod(s);
    VM_Field target=null;
    target=nat.getMemberRef().asFieldReference().resolve();
    ip=OPT_ConvertToLowLevelIR.getField(s,ir,t1.copyRO(),target);
  }
 else {
    ip=(OPT_RegisterOperand)Call.getClearAddress(s);
  }
  int numberParams=Call.getNumberOfParams(s);
  int parameterWords=0;
  for (int i=0; i < numberParams; i++) {
    parameterWords++;
    OPT_Operand op=Call.getParam(s,i);
    if (op instanceof OPT_RegisterOperand) {
      OPT_RegisterOperand reg=(OPT_RegisterOperand)op;
      if (reg.type.isLongType() || reg.type.isDoubleType())       parameterWords++;
    }
 else     if ((op instanceof OPT_LongConstantOperand) || (op instanceof OPT_DoubleConstantOperand))     parameterWords++;
  }
  int parameterWords=numberParams;
  ir.stackManager.allocateParameterSpace((6 + parameterWords) * BYTES_IN_ADDRESS);
  OPT_Instruction s2=Store.create(REF_STORE,ir.regpool.makeJTOCOp(ir,s),ir.regpool.makeFPOp(),I(20),null);
  s.insertBack(s2);
  s.insertBack(Move.create(REF_MOVE,ir.regpool.makeJTOCOp(ir,s),toc));
  Call.mutate0(s,SYSCALL,Call.getClearResult(s),ip,null);
  s2=Load.create(REF_LOAD,ir.regpool.makeJTOCOp(ir,s),ir.regpool.makeFPOp(),I(20),null);
  s.insertFront(s2);
  OPT_RegisterOperand temp=ir.regpool.makeTempInt();
  s2=Move.create(REF_MOVE,temp,I(ir.compiledMethod.getId()));
  OPT_RegisterOperand temp=ir.regpool.makeTempLong();
  s2=Move.create(REF_MOVE,temp,LC(ir.compiledMethod.getId()));
  OPT_Instruction s3=Store.create(REF_STORE,temp.copy(),ir.regpool.makeFPOp(),I(STACKFRAME_METHOD_ID_OFFSET),null);
  s.insertFront(s3);
  s.insertFront(s2);
}

Fixed version (ground truth):
/** 
 * Calling convention to implement calls to  native (C) routines using the AIX linkage conventions
 */
public static void expandSysCall(OPT_Instruction s,OPT_IR ir){
  OPT_RegisterOperand ip=null;
  OPT_RegisterOperand t1=OPT_ConvertToLowLevelIR.getStatic(s,ir,VM_Entrypoints.the_boot_recordField);
  OPT_RegisterOperand toc=OPT_ConvertToLowLevelIR.getField(s,ir,t1,VM_Entrypoints.sysTOCField);
  if (Call.getMethod(s) != null) {
    OPT_MethodOperand nat=Call.getClearMethod(s);
    VM_Field target=null;
    target=nat.getMemberRef().asFieldReference().resolve();
    ip=OPT_ConvertToLowLevelIR.getField(s,ir,t1.copyRO(),target);
  }
 else {
    ip=(OPT_RegisterOperand)Call.getClearAddress(s);
  }
  int numberParams=Call.getNumberOfParams(s);
  int parameterWords=0;
  for (int i=0; i < numberParams; i++) {
    parameterWords++;
    OPT_Operand op=Call.getParam(s,i);
    if (op instanceof OPT_RegisterOperand) {
      OPT_RegisterOperand reg=(OPT_RegisterOperand)op;
      if (reg.type.isLongType() || reg.type.isDoubleType())       parameterWords++;
    }
 else     if ((op instanceof OPT_LongConstantOperand) || (op instanceof OPT_DoubleConstantOperand))     parameterWords++;
  }
  int parameterWords=numberParams;
  ir.stackManager.allocateParameterSpace((6 + parameterWords) * BYTES_IN_ADDRESS);
  OPT_Instruction s2=Store.create(REF_STORE,ir.regpool.makeJTOCOp(ir,s),ir.regpool.makeFPOp(),I(5 * BYTES_IN_ADDRESS),null);
  s.insertBack(s2);
  s.insertBack(Move.create(REF_MOVE,ir.regpool.makeJTOCOp(ir,s),toc));
  Call.mutate0(s,SYSCALL,Call.getClearResult(s),ip,null);
  s2=Load.create(REF_LOAD,ir.regpool.makeJTOCOp(ir,s),ir.regpool.makeFPOp(),I(5 * BYTES_IN_ADDRESS),null);
  s.insertFront(s2);
  OPT_RegisterOperand temp=ir.regpool.makeTempInt();
  s2=Move.create(INT_MOVE,temp,I(ir.compiledMethod.getId()));
  OPT_Instruction s3=Store.create(INT_STORE,temp.copy(),ir.regpool.makeFPOp(),I(STACKFRAME_METHOD_ID_OFFSET),null);
  s.insertFront(s3);
  s.insertFront(s2);
}