Program: 58379
Project: 58379
Buggy source:
private boolean data_encode_blockf(){
  int i, j, input_position, current_row;
  int column_position, c, done, exit_status;
  cfMode current_mode;
  exit_status=0;
  current_row=0;
  current_mode=cfMode.MODEA;
  column_position=0;
  input_position=0;
  c=0;
  do {
    done=0;
    if (column_position == 0) {
      c=columns_needed;
      current_mode=character_subset_select(input_position);
      subset_selector[current_row]=current_mode;
      if ((current_row == 0) && gs1) {
        blockmatrix[current_row][column_position]=102;
        column_position++;
        c--;
      }
    }
    if (gs1 && (source[input_position] == '[')) {
      blockmatrix[current_row][column_position]=102;
      column_position++;
      c--;
      input_position++;
      done=1;
    }
    if (done == 0) {
      if (c <= 2) {
switch (current_mode) {
case MODEA:
          if (findSubset(source[input_position]) == Mode.ABORC) {
            blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
            column_position++;
            c--;
            input_position++;
            done=1;
          }
        if ((findSubset(source[input_position]) == Mode.SHIFTB) && (c == 1)) {
          blockmatrix[current_row][column_position]=100;
          column_position++;
          c--;
          done=1;
        }
      if ((source[input_position] >= 244) && (done == 0)) {
        blockmatrix[current_row][column_position]=100;
        column_position++;
        c--;
        if (c == 1) {
          blockmatrix[current_row][column_position]=101;
          column_position++;
          c--;
        }
        done=1;
      }
    if ((source[input_position] >= 128) && (done == 0)) {
      if (c == 1) {
        blockmatrix[current_row][column_position]=100;
        column_position++;
        c--;
        done=1;
      }
    }
  break;
case MODEB:
if (findSubset(source[input_position]) == Mode.ABORC) {
  blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
  column_position++;
  c--;
  input_position++;
  done=1;
}
if ((findSubset(source[input_position]) == Mode.SHIFTA) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=1;
}
if (((source[input_position] >= 128) && (source[input_position] <= 159)) && (done == 0)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (c == 1) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
done=1;
}
if ((source[input_position] >= 160) && (done == 0)) {
if (c == 1) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=1;
}
}
break;
case MODEC:
if ((findSubset(source[input_position]) != Mode.ABORC) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=1;
}
if (((findSubset(source[input_position]) == Mode.ABORC) && (findSubset(source[input_position + 1]) != Mode.ABORC)) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=1;
}
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (c == 1) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
}
break;
}
}
}
if (done == 0) {
if (((findSubset(source[input_position]) == Mode.AORB) || (findSubset(source[input_position]) == Mode.SHIFTA)) && (current_mode == cfMode.MODEA)) {
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=1;
}
}
if (done == 0) {
if (((findSubset(source[input_position]) == Mode.AORB) || (findSubset(source[input_position]) == Mode.SHIFTB)) && (current_mode == cfMode.MODEB)) {
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=1;
}
}
if (done == 0) {
if (((findSubset(source[input_position]) == Mode.ABORC) && (findSubset(source[input_position + 1]) == Mode.ABORC)) && (current_mode == cfMode.MODEC)) {
blockmatrix[current_row][column_position]=((source[input_position] - '0') * 10) + (source[input_position + 1] - '0');
column_position++;
c--;
input_position+=2;
done=1;
}
}
if (done == 0) {
if (((current_mode == cfMode.MODEA) || (current_mode == cfMode.MODEB)) && ((findSubset(source[input_position]) == Mode.ABORC) || (gs1 && (source[input_position] == '[')))) {
i=0;
j=0;
do {
i++;
if (gs1 && (source[input_position + j] == '[')) {
i++;
}
j++;
}
 while ((findSubset(source[input_position + j]) == Mode.ABORC) || (gs1 && (source[input_position + j] == '[')));
i--;
if (i >= 4) {
if ((i % 2) == 1) {
blockmatrix[current_row][column_position]=99;
column_position++;
c--;
blockmatrix[current_row][column_position]=((source[input_position] - '0') * 10) + (source[input_position + 1] - '0');
column_position++;
c--;
input_position+=2;
current_mode=cfMode.MODEC;
}
 else {
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
done=1;
}
 else {
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=1;
}
}
}
if (done == 0) {
if ((current_mode == cfMode.MODEB) && (findSubset(source[input_position]) == Mode.SHIFTA)) {
if ((source[input_position + 1] >= 96) && (source[input_position + 1] <= 127)) {
blockmatrix[current_row][column_position]=98;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
 else {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEA;
}
done=1;
}
}
if (done == 0) {
if ((current_mode == cfMode.MODEA) && (findSubset(source[input_position]) == Mode.SHIFTB)) {
if ((findSubset(source[input_position + 1]) == Mode.SHIFTA) && (findSubset(source[input_position + 2]) == Mode.SHIFTB)) {
blockmatrix[current_row][column_position]=98;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
 else {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEB;
}
done=1;
}
}
if (done == 0) {
if ((current_mode == cfMode.MODEC) && ((findSubset(source[input_position]) != Mode.ABORC) || (findSubset(source[input_position + 1]) != Mode.ABORC))) {
if (findSubset(source[input_position]) == Mode.SHIFTA) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEA;
}
 else {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEB;
}
done=1;
}
}
if (input_position == content.length()) {
if (c == 1) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][column_position]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][column_position]=101;
current_mode=cfMode.MODEA;
}
column_position++;
c--;
}
if (c == 0) {
column_position=0;
c=columns_needed;
current_row++;
subset_selector[current_row]=cfMode.MODEA;
current_mode=cfMode.MODEA;
}
if (c > 2) {
do {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][column_position]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][column_position]=101;
current_mode=cfMode.MODEA;
}
column_position++;
c--;
}
 while (c > 2);
}
exit_status=1;
final_mode=current_mode;
}
 else {
if (c <= 0) {
column_position=0;
current_row++;
if (current_row > 43) {
return false;
}
}
}
}
 while (exit_status == 0);
if (current_row == 0) {
for (c=column_position; c <= columns_needed; c++) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][c]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][c]=101;
current_mode=cfMode.MODEA;
}
}
current_row++;
subset_selector[current_row]=cfMode.MODEA;
current_mode=cfMode.MODEA;
for (c=0; c <= columns_needed - 2; c++) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][c]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][c]=101;
current_mode=cfMode.MODEA;
}
}
}
rows_needed=current_row + 1;
return true;
}

Fixed version (ground truth):
private boolean data_encode_blockf(){
  int i, j, input_position, current_row;
  int column_position, c;
  cfMode current_mode;
  boolean done, exit_status;
  exit_status=false;
  current_row=0;
  current_mode=cfMode.MODEA;
  column_position=0;
  input_position=0;
  c=0;
  do {
    done=false;
    if (column_position == 0) {
      c=columns_needed;
      current_mode=character_subset_select(input_position);
      subset_selector[current_row]=current_mode;
      if ((current_row == 0) && gs1) {
        blockmatrix[current_row][column_position]=102;
        column_position++;
        c--;
      }
    }
    if (gs1 && (source[input_position] == '[')) {
      blockmatrix[current_row][column_position]=102;
      column_position++;
      c--;
      input_position++;
      done=true;
    }
    if (!done) {
      if (c <= 2) {
switch (current_mode) {
case MODEA:
          if (findSubset(source[input_position]) == Mode.ABORC) {
            blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
            column_position++;
            c--;
            input_position++;
            done=true;
          }
        if ((findSubset(source[input_position]) == Mode.SHIFTB) && (c == 1)) {
          blockmatrix[current_row][column_position]=100;
          column_position++;
          c--;
          done=true;
        }
      if ((source[input_position] >= 244) && (!done)) {
        blockmatrix[current_row][column_position]=100;
        column_position++;
        c--;
        if (c == 1) {
          blockmatrix[current_row][column_position]=101;
          column_position++;
          c--;
        }
        done=true;
      }
    if ((source[input_position] >= 128) && (!done)) {
      if (c == 1) {
        blockmatrix[current_row][column_position]=100;
        column_position++;
        c--;
        done=true;
      }
    }
  break;
case MODEB:
if (findSubset(source[input_position]) == Mode.ABORC) {
  blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
  column_position++;
  c--;
  input_position++;
  done=true;
}
if ((findSubset(source[input_position]) == Mode.SHIFTA) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=true;
}
if (((source[input_position] >= 128) && (source[input_position] <= 159)) && (!done)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (c == 1) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
done=true;
}
if ((source[input_position] >= 160) && (!done)) {
if (c == 1) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=true;
}
}
break;
case MODEC:
if ((findSubset(source[input_position]) != Mode.ABORC) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=true;
}
if (((findSubset(source[input_position]) == Mode.ABORC) && (findSubset(source[input_position + 1]) != Mode.ABORC)) && (c == 1)) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
done=true;
}
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (c == 1) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
}
break;
}
}
}
if (!done) {
if (((findSubset(source[input_position]) == Mode.AORB) || (findSubset(source[input_position]) == Mode.SHIFTA)) && (current_mode == cfMode.MODEA)) {
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=true;
}
}
if (!done) {
if (((findSubset(source[input_position]) == Mode.AORB) || (findSubset(source[input_position]) == Mode.SHIFTB)) && (current_mode == cfMode.MODEB)) {
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=true;
}
}
if (!done) {
if (((findSubset(source[input_position]) == Mode.ABORC) && (findSubset(source[input_position + 1]) == Mode.ABORC)) && (current_mode == cfMode.MODEC)) {
blockmatrix[current_row][column_position]=((source[input_position] - '0') * 10) + (source[input_position + 1] - '0');
column_position++;
c--;
input_position+=2;
done=true;
}
}
if (!done) {
if (((current_mode == cfMode.MODEA) || (current_mode == cfMode.MODEB)) && ((findSubset(source[input_position]) == Mode.ABORC) || (gs1 && (source[input_position] == '[')))) {
i=0;
j=0;
do {
i++;
if (gs1 && (source[input_position + j] == '[')) {
i++;
}
j++;
}
 while ((findSubset(source[input_position + j]) == Mode.ABORC) || (gs1 && (source[input_position + j] == '[')));
i--;
if (i >= 4) {
if ((i % 2) == 1) {
blockmatrix[current_row][column_position]=99;
column_position++;
c--;
blockmatrix[current_row][column_position]=((source[input_position] - '0') * 10) + (source[input_position + 1] - '0');
column_position++;
c--;
input_position+=2;
current_mode=cfMode.MODEC;
}
 else {
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
done=true;
}
 else {
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
done=true;
}
}
}
if (!done) {
if ((current_mode == cfMode.MODEB) && (findSubset(source[input_position]) == Mode.SHIFTA)) {
if ((source[input_position + 1] >= 96) && (source[input_position + 1] <= 127)) {
blockmatrix[current_row][column_position]=98;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
 else {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEA;
}
done=true;
}
}
if (!done) {
if ((current_mode == cfMode.MODEA) && (findSubset(source[input_position]) == Mode.SHIFTB)) {
if ((findSubset(source[input_position + 1]) == Mode.SHIFTA) && (findSubset(source[input_position + 2]) == Mode.SHIFTB)) {
blockmatrix[current_row][column_position]=98;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
}
 else {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEB;
}
done=true;
}
}
if (!done) {
if ((current_mode == cfMode.MODEC) && ((findSubset(source[input_position]) != Mode.ABORC) || (findSubset(source[input_position + 1]) != Mode.ABORC))) {
if (findSubset(source[input_position]) == Mode.SHIFTA) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=101;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEA;
}
 else {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
if (source[input_position] >= 128) {
blockmatrix[current_row][column_position]=100;
column_position++;
c--;
}
blockmatrix[current_row][column_position]=a3_convert(source[input_position]);
column_position++;
c--;
input_position++;
current_mode=cfMode.MODEB;
}
done=true;
}
}
if (input_position == content.length()) {
if (c == 1) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][column_position]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][column_position]=101;
current_mode=cfMode.MODEA;
}
column_position++;
c--;
}
if (c == 0) {
column_position=0;
c=columns_needed;
current_row++;
subset_selector[current_row]=cfMode.MODEA;
current_mode=cfMode.MODEA;
}
if (c > 2) {
do {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][column_position]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][column_position]=101;
current_mode=cfMode.MODEA;
}
column_position++;
c--;
}
 while (c > 2);
}
exit_status=true;
final_mode=current_mode;
}
 else {
if (c <= 0) {
column_position=0;
current_row++;
if (current_row > 43) {
return false;
}
}
}
}
 while (!exit_status);
if (current_row == 0) {
for (c=column_position; c <= columns_needed; c++) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][c]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][c]=101;
current_mode=cfMode.MODEA;
}
}
current_row++;
subset_selector[current_row]=cfMode.MODEA;
current_mode=cfMode.MODEA;
for (c=0; c <= columns_needed - 2; c++) {
if (current_mode == cfMode.MODEA) {
blockmatrix[current_row][c]=100;
current_mode=cfMode.MODEB;
}
 else {
blockmatrix[current_row][c]=101;
current_mode=cfMode.MODEA;
}
}
}
rows_needed=current_row + 1;
return true;
}