Program: 196679
Project: 196679
Buggy source:
private void updateOomLevels(int displayWidth,int displayHeight,boolean write){
  float scaleMem=((float)(mTotalMemMb - 300)) / (700 - 300);
  int minSize=480 * 800;
  int maxSize=1280 * 800;
  float scaleDisp=((float)(displayWidth * displayHeight) - minSize) / (maxSize - minSize);
  if (false) {
    Slog.i("String_Node_Str","String_Node_Str" + scaleMem);
    Slog.i("String_Node_Str","String_Node_Str" + scaleDisp + "String_Node_Str"+ displayWidth+ "String_Node_Str"+ displayHeight);
  }
  float scale=scaleMem > scaleDisp ? scaleMem : scaleDisp;
  if (scale < 0)   scale=0;
 else   if (scale > 1)   scale=1;
  int minfree_adj=Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAdjust);
  int minfree_abs=Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAbsolute);
  if (false) {
    Slog.i("String_Node_Str","String_Node_Str" + minfree_adj + "String_Node_Str"+ minfree_abs);
  }
  final boolean is64bit=Build.SUPPORTED_64_BIT_ABIS.length > 0;
  for (int i=0; i < mOomAdj.length; i++) {
    int low=mOomMinFreeLow[i];
    int high=mOomMinFreeHigh[i];
    mOomMinFree[i]=(int)(low + ((high - low) * scale));
    if (is64bit) {
      mOomMinFree[i]=(3 * mOomMinFree[i]) / 2;
    }
  }
  if (minfree_abs >= 0) {
    for (int i=0; i < mOomAdj.length; i++) {
      mOomMinFree[i]=(int)((float)minfree_abs * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
    }
  }
  if (minfree_adj != 0) {
    for (int i=0; i < mOomAdj.length; i++) {
      mOomMinFree[i]+=(int)((float)minfree_adj * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
      if (mOomMinFree[i] < 0) {
        mOomMinFree[i]=0;
      }
    }
  }
  mCachedRestoreLevel=(getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024) / 3;
  int reserve=displayWidth * displayHeight * 4* 3 / 1024;
  int reserve_adj=Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAdjust);
  int reserve_abs=Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAbsolute);
  if (reserve_abs >= 0) {
    reserve=reserve_abs;
  }
  if (reserve_adj != 0) {
    reserve+=reserve_adj;
    if (reserve < 0) {
      reserve=0;
    }
  }
  if (write) {
    ByteBuffer buf=ByteBuffer.allocate(4 * (2 * mOomAdj.length + 1));
    buf.putInt(LMK_TARGET);
    for (int i=0; i < mOomAdj.length; i++) {
      buf.putInt((mOomMinFree[i] * 1024) / PAGE_SIZE);
      buf.putInt(mOomAdj[i]);
    }
    writeLmkd(buf);
    SystemProperties.set("String_Node_Str",Integer.toString(reserve));
  }
}

Fixed version (ground truth):
private void updateOomLevels(int displayWidth,int displayHeight,boolean write){
  float scaleMem=((float)(mTotalMemMb - 300)) / (700 - 300);
  int minSize=480 * 800;
  int maxSize=1280 * 800;
  float scaleDisp=((float)(displayWidth * displayHeight) - minSize) / (maxSize - minSize);
  if (false) {
    Slog.i("String_Node_Str","String_Node_Str" + scaleMem);
    Slog.i("String_Node_Str","String_Node_Str" + scaleDisp + "String_Node_Str"+ displayWidth+ "String_Node_Str"+ displayHeight);
  }
  float scale=scaleMem > scaleDisp ? scaleMem : scaleDisp;
  if (scale < 0)   scale=0;
 else   if (scale > 1)   scale=1;
  int minfree_adj=Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAdjust);
  int minfree_abs=Resources.getSystem().getInteger(com.android.internal.R.integer.config_lowMemoryKillerMinFreeKbytesAbsolute);
  if (false) {
    Slog.i("String_Node_Str","String_Node_Str" + minfree_adj + "String_Node_Str"+ minfree_abs);
  }
  final boolean is64bit=false;
  for (int i=0; i < mOomAdj.length; i++) {
    int low=mOomMinFreeLow[i];
    int high=mOomMinFreeHigh[i];
    mOomMinFree[i]=(int)(low + ((high - low) * scale));
    if (is64bit) {
      mOomMinFree[i]=(3 * mOomMinFree[i]) / 2;
    }
  }
  if (minfree_abs >= 0) {
    for (int i=0; i < mOomAdj.length; i++) {
      mOomMinFree[i]=(int)((float)minfree_abs * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
    }
  }
  if (minfree_adj != 0) {
    for (int i=0; i < mOomAdj.length; i++) {
      mOomMinFree[i]+=(int)((float)minfree_adj * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]);
      if (mOomMinFree[i] < 0) {
        mOomMinFree[i]=0;
      }
    }
  }
  mCachedRestoreLevel=(getMemLevel(ProcessList.CACHED_APP_MAX_ADJ) / 1024) / 3;
  int reserve=displayWidth * displayHeight * 4* 3 / 1024;
  int reserve_adj=Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAdjust);
  int reserve_abs=Resources.getSystem().getInteger(com.android.internal.R.integer.config_extraFreeKbytesAbsolute);
  if (reserve_abs >= 0) {
    reserve=reserve_abs;
  }
  if (reserve_adj != 0) {
    reserve+=reserve_adj;
    if (reserve < 0) {
      reserve=0;
    }
  }
  if (write) {
    ByteBuffer buf=ByteBuffer.allocate(4 * (2 * mOomAdj.length + 1));
    buf.putInt(LMK_TARGET);
    for (int i=0; i < mOomAdj.length; i++) {
      buf.putInt((mOomMinFree[i] * 1024) / PAGE_SIZE);
      buf.putInt(mOomAdj[i]);
    }
    writeLmkd(buf);
    SystemProperties.set("String_Node_Str",Integer.toString(reserve));
  }
}