Program: 76867
Project: 76867
Buggy source:
public int[] resolve(int specifiedWidth,int maxWidth){
  assert(specifiedWidth <= maxWidth);
  int columnNumber=table.getColumnCount();
  int[] columns=new int[columnNumber];
  int columnWithWidth=0;
  int colSum=0;
  for (int j=0; j < table.getColumnCount(); j++) {
    IColumn column=(IColumn)table.getColumn(j);
    int columnWidth=getDimensionValue(column.getWidth(),tableWidth);
    if (columnWidth > 0) {
      columns[j]=columnWidth;
      colSum+=columnWidth;
      columnWithWidth++;
    }
 else {
      columns[j]=-1;
    }
  }
  if (columnWithWidth == columnNumber) {
    if (colSum <= maxWidth) {
      return columns;
    }
 else {
      float delta=colSum - maxWidth;
      for (int i=0; i < columnNumber; i++) {
        columns[i]-=(int)(delta * columns[i] / colSum);
      }
      return columns;
    }
  }
 else {
    if (specifiedWidth == 0) {
      if (colSum < maxWidth) {
        distributeLeftWidth(columns,(maxWidth - colSum) / (columnNumber - columnWithWidth));
      }
 else {
        redistributeWidth(columns,colSum - maxWidth + (columnNumber - columnWithWidth) * maxWidth / columnNumber,maxWidth,colSum);
      }
    }
 else {
      if (colSum < specifiedWidth) {
        distributeLeftWidth(columns,(specifiedWidth - colSum) / columnNumber - columnWithWidth);
      }
 else {
        if (colSum < maxWidth) {
          distributeLeftWidth(columns,(maxWidth - colSum) / (columnNumber - columnWithWidth));
        }
 else {
          redistributeWidth(columns,colSum - specifiedWidth + (columnNumber - columnWithWidth) * specifiedWidth / columnNumber,specifiedWidth,colSum);
        }
      }
    }
  }
  return columns;
}

Fixed version (ground truth):
public int[] resolve(int specifiedWidth,int maxWidth){
  assert(specifiedWidth <= maxWidth);
  int columnNumber=table.getColumnCount();
  int[] columns=new int[columnNumber];
  int columnWithWidth=0;
  int colSum=0;
  for (int j=0; j < table.getColumnCount(); j++) {
    IColumn column=(IColumn)table.getColumn(j);
    int columnWidth=getDimensionValue(column.getWidth(),tableWidth);
    if (columnWidth > 0) {
      columns[j]=columnWidth;
      colSum+=columnWidth;
      columnWithWidth++;
    }
 else {
      columns[j]=-1;
    }
  }
  if (columnWithWidth == columnNumber) {
    if (colSum <= maxWidth) {
      return columns;
    }
 else {
      float delta=colSum - maxWidth;
      for (int i=0; i < columnNumber; i++) {
        columns[i]-=(int)(delta * columns[i] / colSum);
      }
      return columns;
    }
  }
 else {
    if (specifiedWidth == 0) {
      if (colSum < maxWidth) {
        distributeLeftWidth(columns,(maxWidth - colSum) / (columnNumber - columnWithWidth));
      }
 else {
        redistributeWidth(columns,colSum - maxWidth + (columnNumber - columnWithWidth) * maxWidth / columnNumber,maxWidth,colSum);
      }
    }
 else {
      if (colSum < specifiedWidth) {
        distributeLeftWidth(columns,(specifiedWidth - colSum) / (columnNumber - columnWithWidth));
      }
 else {
        if (colSum < maxWidth) {
          distributeLeftWidth(columns,(maxWidth - colSum) / (columnNumber - columnWithWidth));
        }
 else {
          redistributeWidth(columns,colSum - specifiedWidth + (columnNumber - columnWithWidth) * specifiedWidth / columnNumber,specifiedWidth,colSum);
        }
      }
    }
  }
  return columns;
}