Program: 12008
Project: 12008
Buggy source:
public AT_Machine_State(byte[] atId,byte[] creator,byte[] creationBytes,int height){
  this.version=AT_Constants.getInstance().AT_VERSION(height);
  this.atID=atId;
  this.creator=creator;
  ByteBuffer b=ByteBuffer.allocate(creationBytes.length);
  b.order(ByteOrder.LITTLE_ENDIAN);
  b.put(creationBytes);
  b.clear();
  this.version=b.getShort();
  b.getShort();
  int pageSize=(int)AT_Constants.getInstance().PAGE_SIZE(height);
  short codePages=b.getShort();
  short dataPages=b.getShort();
  short callStackPages=b.getShort();
  short userStackPages=b.getShort();
  this.csize=codePages * pageSize;
  this.dsize=dataPages * pageSize;
  this.c_call_stack_bytes=callStackPages * pageSize;
  this.c_user_stack_bytes=userStackPages * pageSize;
  int codeLen=0;
  if (codePages * pageSize < pageSize + 1) {
    codeLen=b.get();
    if (codeLen < 0)     codeLen+=(Byte.MAX_VALUE + 1) * 2;
  }
 else   if (codePages * pageSize < Short.MAX_VALUE + 1) {
    codeLen=b.getShort();
    if (codeLen < 0)     codeLen+=(Short.MAX_VALUE + 1) * 2;
  }
 else {
    codeLen=b.getInt();
  }
  byte[] code=new byte[codeLen];
  b.get(code,0,codeLen);
  this.ap_code=ByteBuffer.allocate(csize);
  this.ap_code.order(ByteOrder.LITTLE_ENDIAN);
  this.ap_code.put(code);
  this.ap_code.clear();
  int dataLen=0;
  if (dataPages * pageSize < 257) {
    dataLen=b.get();
    if (dataLen < 0)     dataLen+=(Byte.MAX_VALUE + 1) * 2;
  }
 else   if (dataPages * pageSize < Short.MAX_VALUE + 1) {
    dataLen=b.getShort();
    if (dataLen < 0)     dataLen+=(Short.MAX_VALUE + 1) * 2;
  }
 else {
    dataLen=b.getInt();
  }
  byte[] data=new byte[dataLen];
  b.get(data,0,dataLen);
  this.ap_data=ByteBuffer.allocate(this.dsize + this.c_call_stack_bytes + this.c_user_stack_bytes);
  this.ap_data.order(ByteOrder.LITTLE_ENDIAN);
  this.ap_data.put(data);
  this.ap_data.clear();
  this.creationBlockHeight=height;
  this.minimumFee=(codePages + dataPages + callStackPages+ userStackPages) * AT_Constants.getInstance().COST_PER_PAGE(height);
  this.waitForNumberOfBlocks=0;
  this.sleepBetween=0;
  this.freezeWhenSameBalance=false;
  this.minActivationAmount=1L;
  this.transactions=new LinkedList<>();
  this.g_balance=0;
  this.p_balance=0;
  this.machineState=new Machine_State();
}

Fixed version (ground truth):
public AT_Machine_State(byte[] atId,byte[] creator,byte[] creationBytes,int height){
  this.version=AT_Constants.getInstance().AT_VERSION(height);
  this.atID=atId;
  this.creator=creator;
  ByteBuffer b=ByteBuffer.allocate(creationBytes.length);
  b.order(ByteOrder.LITTLE_ENDIAN);
  b.put(creationBytes);
  b.clear();
  this.version=b.getShort();
  b.getShort();
  int pageSize=(int)AT_Constants.getInstance().PAGE_SIZE(height);
  short codePages=b.getShort();
  short dataPages=b.getShort();
  short callStackPages=b.getShort();
  short userStackPages=b.getShort();
  this.csize=codePages * pageSize;
  this.dsize=dataPages * pageSize;
  this.c_call_stack_bytes=callStackPages * pageSize;
  this.c_user_stack_bytes=userStackPages * pageSize;
  int codeLen=0;
  if (codePages * pageSize < pageSize + 1) {
    codeLen=b.get();
    if (codeLen < 0)     codeLen+=(Byte.MAX_VALUE + 1) * 2;
  }
 else   if (codePages * pageSize < Short.MAX_VALUE + 1) {
    codeLen=b.getShort();
    if (codeLen < 0)     codeLen+=(Short.MAX_VALUE + 1) * 2;
  }
 else {
    codeLen=b.getInt();
  }
  byte[] code=new byte[codeLen];
  b.get(code,0,codeLen);
  this.ap_code=ByteBuffer.allocate(csize);
  this.ap_code.order(ByteOrder.LITTLE_ENDIAN);
  this.ap_code.put(code);
  this.ap_code.clear();
  int dataLen=0;
  if (dataPages * pageSize < 257) {
    dataLen=b.get();
    if (dataLen < 0)     dataLen+=(Byte.MAX_VALUE + 1) * 2;
  }
 else   if (dataPages * pageSize < Short.MAX_VALUE + 1) {
    dataLen=b.getShort();
    if (dataLen < 0)     dataLen+=(Short.MAX_VALUE + 1) * 2;
  }
 else {
    dataLen=b.getInt();
  }
  byte[] data=new byte[dataLen];
  b.get(data,0,dataLen);
  this.ap_data=ByteBuffer.allocate(this.dsize + this.c_call_stack_bytes + this.c_user_stack_bytes);
  this.ap_data.order(ByteOrder.LITTLE_ENDIAN);
  this.ap_data.put(data);
  this.ap_data.clear();
  this.creationBlockHeight=height;
  this.minimumFee=(codePages + dataPages + callStackPages+ userStackPages) * AT_Constants.getInstance().COST_PER_PAGE(height);
  this.waitForNumberOfBlocks=0;
  this.sleepBetween=0;
  this.freezeWhenSameBalance=false;
  this.minActivationAmount=1L;
  this.transactions=new LinkedHashMap<>();
  this.g_balance=0;
  this.p_balance=0;
  this.machineState=new Machine_State();
}