original_code:
void print_lp(lprec *lp)
{
  int i, j;
  double *fatmat;
  InitStream();
  if ((((((lp->rows + 1) * lp->columns) == 0) || ((fatmat = calloc((size_t)((lp->rows + 1) * lp->columns), sizeof(*fatmat))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", ((lp->rows + 1) * lp->columns) * sizeof(*fatmat), 135, "debug.c"), (fatmat = (void *) 0) : fatmat ) != ((void *)0)) {
    for(i = 1; i <= lp->columns; i++)
      for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++)
 fatmat[(i - 1) * (lp->rows + 1) + lp->mat[j].row_nr] = lp->mat[j].value;
    fprintf(stream, "\nModel name: %s\n", lp->lp_name);
    fprintf(stream, "          ");
    for(j = 1; j <= lp->columns; j++)
      fprintf(stream, "%8.8s ", get_col_name(lp, j));
    if(lp->maximise) {
      fprintf(stream, "\nMaximize  ");
      for(j = 0; j < lp->columns; j++)
 fprintf(stream, "%8g ", (double) -fatmat[j * (lp->rows + 1)]);
    }
    else {
      fprintf(stream, "\nMinimize  ");
      for(j = 0; j < lp->columns; j++)
 fprintf(stream, "%8g ", (double) fatmat[j * (lp->rows + 1)]);
    }
    fprintf(stream, "\n");
    for(i = 1; i <= lp->rows; i++) {
      fprintf(stream, "%-9s ", get_row_name(lp, i));
      for(j = 0; j < lp->columns; j++)
 if(lp->ch_sign[i] && fatmat[j*(lp->rows + 1) + i] != 0)
   fprintf(stream, "%8g ", (double)-fatmat[j * (lp->rows+1) + i]);
 else
   fprintf(stream, "%8g ", (double)fatmat[j * (lp->rows + 1) + i]);
      if(lp->orig_upbo[i] != 0) {
 if(lp->ch_sign[i])
   fprintf(stream, ">= ");
 else
   fprintf(stream, "<= ");
      }
      else
 fprintf(stream, " = ");
      if(lp->ch_sign[i])
 fprintf(stream, "%8g", (double)-lp->orig_rh[i]);
      else
 fprintf(stream, "%8g", (double)lp->orig_rh[i]);
      if(lp->orig_lowbo[i] != 0) {
 fprintf(stream, "  %s = %8g", (lp->ch_sign[i]) ? "lowbo" : "upbo",
        (double)(lp->orig_lowbo[i]+lp->orig_rh[i])*(lp->ch_sign[i] ? 1.0 : -1.0));
      }
      if((lp->orig_upbo[i] != lp->infinite) && (lp->orig_upbo[i] != 0.0)) {
 fprintf(stream, "  %s = %8g", (lp->ch_sign[i]) ? "upbo" : "lowbo",
        (double)(lp->orig_upbo[i]-lp->orig_rh[i])*(lp->ch_sign[i] ? 1.0 : -1.0));
      }
      fprintf(stream, "\n");
    }
    for(i = 0; i < lp->nr_lagrange; i++) {
      fprintf(stream, "lag[%-5d]", i);
      for(j = 1; j <= lp->columns; j++)
 fprintf(stream, "%8g ", (double)lp->lag_row[i][j]);
      if(lp->orig_upbo[i] == lp->infinite) {
 if(lp->lag_con_type[i] == 2)
   fprintf(stream, ">= ");
 else if(lp->lag_con_type[i] == 0)
   fprintf(stream, "<= ");
 else if(lp->lag_con_type[i] == 1)
   fprintf(stream, " = ");
      }
      fprintf(stream, "%8g\n", (double)lp->lag_rhs[i]);
    }
    fprintf(stream, "Type      ");
    for(i = 1; i <= lp->columns; i++)
      if(is_int(lp,i))
 fprintf(stream, "     Int ");
      else
 fprintf(stream, "    Real ");
    fprintf(stream, "\nupbo      ");
    for(i = 1; i <= lp->columns; i++)
      if(lp->orig_upbo[lp->rows + i] == lp->infinite)
 fprintf(stream, " Infinite");
      else
 fprintf(stream, "%8g ", (double)lp->orig_upbo[lp->rows + i]);
    fprintf(stream, "\nlowbo     ");
    for(i = 1; i <= lp->columns; i++)
      fprintf(stream, "%8g ", (double)lp->orig_lowbo[lp->rows + i]);
    fprintf(stream, "\n");
    free(fatmat);
  }
  fflush(stream);
}

canonical_original_code:
void print_lp(struct _lprec *lp)
{
  int i; int j;
  double *fatmat;
  InitStream();
  if ((((((lp->rows + 1) * lp->columns) == 0) || ((fatmat = calloc((unsigned long)((lp->rows + 1) * lp->columns), sizeof(*fatmat))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", ((lp->rows + 1) * lp->columns) * sizeof(*fatmat), 135, "debug.c"), (fatmat = (void *) 0) : fatmat ) != ((void *)0)) {
    for(i = 1; i <= lp->columns; i++)
      for(j = lp->col_end[i - 1]; j < lp->col_end[i]; j++)
 fatmat[(i - 1) * (lp->rows + 1) + lp->mat[j].row_nr] = lp->mat[j].value;
    fprintf(stream, "\nModel name: %s\n", lp->lp_name);
    fprintf(stream, "          ");
    for(j = 1; j <= lp->columns; j++)
      fprintf(stream, "%8.8s ", get_col_name(lp, j));
    if(lp->maximise) {
      fprintf(stream, "\nMaximize  ");
      for(j = 0; j < lp->columns; j++)
 fprintf(stream, "%8g ", (double) -fatmat[j * (lp->rows + 1)]);
    }
    else {
      fprintf(stream, "\nMinimize  ");
      for(j = 0; j < lp->columns; j++)
 fprintf(stream, "%8g ", (double) fatmat[j * (lp->rows + 1)]);
    }
    fprintf(stream, "\n");
    for(i = 1; i <= lp->rows; i++) {
      fprintf(stream, "%-9s ", get_row_name(lp, i));
      for(j = 0; j < lp->columns; j++)
 if(lp->ch_sign[i] && fatmat[j*(lp->rows + 1) + i] != 0)
   fprintf(stream, "%8g ", (double)-fatmat[j * (lp->rows+1) + i]);
 else
   fprintf(stream, "%8g ", (double)fatmat[j * (lp->rows + 1) + i]);
      if(lp->orig_upbo[i] != 0) {
 if(lp->ch_sign[i])
   fprintf(stream, ">= ");
 else
   fprintf(stream, "<= ");
      }
      else
 fprintf(stream, " = ");
      if(lp->ch_sign[i])
 fprintf(stream, "%8g", (double)-lp->orig_rh[i]);
      else
 fprintf(stream, "%8g", (double)lp->orig_rh[i]);
      if(lp->orig_lowbo[i] != 0) {
 fprintf(stream, "  %s = %8g", (lp->ch_sign[i]) ? "lowbo" : "upbo",
        (double)(lp->orig_lowbo[i]+lp->orig_rh[i])*(lp->ch_sign[i] ? 1.0 : -1.0));
      }
      if((lp->orig_upbo[i] != lp->infinite) && (lp->orig_upbo[i] != 0.0)) {
 fprintf(stream, "  %s = %8g", (lp->ch_sign[i]) ? "upbo" : "lowbo",
        (double)(lp->orig_upbo[i]-lp->orig_rh[i])*(lp->ch_sign[i] ? 1.0 : -1.0));
      }
      fprintf(stream, "\n");
    }
    for(i = 0; i < lp->nr_lagrange; i++) {
      fprintf(stream, "lag[%-5d]", i);
      for(j = 1; j <= lp->columns; j++)
 fprintf(stream, "%8g ", (double)lp->lag_row[i][j]);
      if(lp->orig_upbo[i] == lp->infinite) {
 if(lp->lag_con_type[i] == 2)
   fprintf(stream, ">= ");
 else if(lp->lag_con_type[i] == 0)
   fprintf(stream, "<= ");
 else if(lp->lag_con_type[i] == 1)
   fprintf(stream, " = ");
      }
      fprintf(stream, "%8g\n", (double)lp->lag_rhs[i]);
    }
    fprintf(stream, "Type      ");
    for(i = 1; i <= lp->columns; i++)
      if(is_int(lp,i))
 fprintf(stream, "     Int ");
      else
 fprintf(stream, "    Real ");
    fprintf(stream, "\nupbo      ");
    for(i = 1; i <= lp->columns; i++)
      if(lp->orig_upbo[lp->rows + i] == lp->infinite)
 fprintf(stream, " Infinite");
      else
 fprintf(stream, "%8g ", (double)lp->orig_upbo[lp->rows + i]);
    fprintf(stream, "\nlowbo     ");
    for(i = 1; i <= lp->columns; i++)
      fprintf(stream, "%8g ", (double)lp->orig_lowbo[lp->rows + i]);
    fprintf(stream, "\n");
    free(fatmat);
  }
  fflush(stream);
}

variable_types: j int

variable_types:
fatmat
double *


decompiled_code:
int __fastcall print_objective(__int64 a1)
{
InitStream();
return fprintf(stream, "\nValue of objective function: %g\n", **(double **)(a1 + 296));
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
func0();
return fprintf(stream, "\nValue of objective function: %g\n", **(double **)(a1 + 296));
}

original_code:
void print_objective(lprec *lp)
{
  InitStream();
  fprintf(stream, "\nValue of objective function: %g\n",
   (double)lp->best_solution[0]);
}

canonical_original_code:
void print_objective(struct _lprec *lp)
{
  InitStream();
  fprintf(stream, "\nValue of objective function: %g\n",
   (double)lp->best_solution[0]);
}

variable_types: struct _lprec { char *lp_name; short verbose; unsigned char print_duals; unsigned char print_sol; unsigned char debug; short print_at_invert; unsigned char trace; unsigned char anti_degen; unsigned char do_presolve; int rows; int rows_alloc; int columns; int columns_alloc; int sum; int sum_alloc; unsigned char names_used; char **row_name; char **col_name; int non_zeros; int mat_alloc; struct _matrec { int row_nr; double value; } *mat; int *col_end; int *col_no; unsigned char row_end_valid; int *row_end; double *orig_rh; double *rh; long double *rhs; unsigned char *must_be_int; double *orig_upbo; double *orig_lowbo; double *upbo; double *lowbo; unsigned char basis_valid; int *bas; unsigned char *basis; unsigned char *lower; unsigned char eta_valid; int eta_alloc; int eta_size; int num_inv; int max_num_inv; double *eta_value; int *eta_row_nr; int *eta_col_end; unsigned char bb_rule; double obj_bound; int iter; int total_iter; int max_level; int total_nodes; double *solution; double *best_solution; double *duals; unsigned char maximise; unsigned char floor_first; unsigned char *ch_sign; unsigned char scaling_used; unsigned char columns_scaled; double *scale; int nr_lagrange; double **lag_row; double *lag_rhs; double *lambda; unsigned char *lag_con_type; double lag_bound; unsigned char valid; double infinite; double epsilon; double epsb; double epsd; double epsel; struct _hashstruct { struct _hashelem { char *name; struct _hashelem *next; struct _column { int row; double value; struct _column *next; } *col; struct _bound { double upbo; double lowbo; } *bnd; int must_be_int; int index; } **table; int size; } *rowname_hashtab; struct _hashstruct *colname_hashtab; double *dualsfrom; double *dualstill; double *objfrom; double *objtill; int orig_rows; int orig_columns; short spx_status; short lag_status; int solutioncount; int solutionlimit; int num_refact; unsigned char scalemode; unsigned char improve; unsigned char lag_trace; unsigned char piv_rule; unsigned char break_at_first; short bb_floorfirst; double break_at_value; int int_count; int *var_is_free; double Extrad; unsigned char doIterate; unsigned char doInvert; unsigned char justInverted; unsigned char wasprocessed; unsigned char Break_bb; int Level; double lag_accept; double negrange; double epsperturb; double epspivot; long sectimeout; double timestart; double timeend; double time_refactstart; int (*abort)(void *lp, void *userhandle); void *aborthandle; void (*writelog)(void *lp, void *userhandle, char *buf); void *loghandle; void (*debuginfo)(void *lp, void *userhandle, char *buf); void *(*usermessage)(void *lp, void *userhandle, int message); int msgmask; void *msghandle; int sc_count; int sos_alloc; int sos_count; int sos_ints; double *var_is_sc; struct _SOSrec { int tagorder; char *name; short type; int size; int priority; int *members; double *weights; int *membersSorted; int *membersMapped; } **sos_list; int sos_vars; int *sos_priority; } *

return_type: void

user_defined_types: struct _lprec { char *lp_name; short verbose; unsigned char print_duals; unsigned char print_sol; unsigned char debug; short print_at_invert; unsigned char trace; unsigned char anti_degen; unsigned char do_presolve; int rows; int rows_alloc; int columns; int columns_alloc; int sum; int sum_alloc; unsigned char names_used; char **row_name; char **col_name; int non_zeros; int mat_alloc; struct _matrec *mat; int *col_end; int *col_no; unsigned char row_end_valid; int *row_end; double *orig_rh; double *rh; long double *rhs; unsigned char *must_be_int; double *orig_upbo; double *orig_lowbo; double *upbo; double *lowbo; unsigned char basis_valid; int *bas; unsigned char *basis; unsigned char *lower; unsigned char eta_valid; int eta_alloc; int eta_size; int num_inv; int max_num_inv; double *eta_value; int *eta_row_nr; int *eta_col_end; unsigned char bb_rule; double obj_bound; int iter; int total_iter; int max_level; int total_nodes; double *solution; double *best_solution; double *duals; unsigned char maximise; unsigned char floor_first; unsigned char *ch_sign; unsigned char scaling_used; unsigned char columns_scaled; double *scale; int nr_lagrange; double **lag_row; double *lag_rhs; double *lambda; unsigned char *lag_con_type; double lag_bound; unsigned char valid; double infinite; double epsilon; double epsb; double epsd; double epsel; struct _hashstruct *rowname_hashtab; struct _hashstruct *colname_hashtab; double *dualsfrom; double *dualstill; double *objfrom; double *objtill; int orig_rows; int orig_columns; short spx_status; short lag_status; int solutioncount; int solutionlimit; int num_refact; unsigned char scalemode; unsigned char improve; unsigned char lag_trace; unsigned char piv_rule; unsigned char break_at_first; short bb_floorfirst; double break_at_value; int int_count; int *var_is_free; double Extrad; unsigned char doIterate; unsigned char doInvert; unsigned char justInverted; unsigned char wasprocessed; unsigned char Break_bb; int Level; double lag_accept; double negrange; double epsperturb; double epspivot; long sectimeout; double timestart; double timeend; double time_refactstart; int (*abort)(void *lp, void *userhandle); void *aborthandle; void (*writelog)(void *lp, void *userhandle, char *buf); void *loghandle; void (*debuginfo)(void *lp, void *userhandle, char *buf); void *(*usermessage)(void *lp, void *userhandle, int message); int msgmask; void *msghandle; int sc_count; int sos_alloc; int sos_count; int sos_ints; double *var_is_sc; struct _SOSrec **sos_list; int sos_vars; int *sos_priority; }

user_defined_types: struct _hashstruct { struct _hashelem **table; int size; }

user_defined_types: struct _hashelem { char *name; struct _hashelem *next; struct _column *col; struct _bound *bnd; int must_be_int; int index; }


decompiled_code:
int __fastcall print_solution(__int64 a1)
{
int v1; // ebx
double v2; // r12
const char *v3; // rax

InitStream();
fwrite("\nActual values of the variables:\n", 1uLL, 0x21uLL, stream);
if ( *(int *)(a1 + 28) > 0 )
{
v1 = 1;
do
{
v2 = *(double *)(*(_QWORD *)(a1 + 296) + 8LL * (*(_DWORD *)(a1 + 20) + v1));
v3 = (const char *)get_col_name(a1, (unsigned int)v1);
fprintf(stream, "%-20s %g\n", v3, v2);
++v1;
}
while ( *(_DWORD *)(a1 + 28) >= v1 );
}
return fflush(stream);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
int v1; // ebx
double v2; // r12
const char *v3; // rax

func0();
fwrite("\nActual values of the variables:\n", 1uLL, 0x21uLL, stream);
if ( *(int *)(a1 + 28) > 0 )
{
v1 = 1;
do
{
v2 = *(double *)(*(_QWORD *)(a1 + 296) + 8LL * (*(_DWORD *)(a1 + 20) + v1));
v3 = (const char *)get_col_name(a1, (unsigned int)v1);
fprintf(stream, "%-20s %g\n", v3, v2);
++v1;
}
while ( *(_DWORD *)(a1 + 28) >= v1 );
}
return fflush(stream);
}

original_code:
void print_solution(lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nActual values of the variables:\n");
  for(i = 1; i <= lp->columns; i++)
    fprintf(stream, "%-20s %g\n", get_col_name(lp, i),
     (double)lp->best_solution[lp->rows + i]);
  fflush(stream);
}

canonical_original_code:
void print_solution(struct _lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nActual values of the variables:\n");
  for(i = 1; i <= lp->columns; i++)
    fprintf(stream, "%-20s %g\n", get_col_name(lp, i),
     (double)lp->best_solution[lp->rows + i]);
  fflush(stream);
}

variable_types: i int

user_defined_types: struct _matrec { int row_nr; double value; }

user_defined_types: struct _SOSrec { int tagorder; char *name; short type; int size; int priority; int *members; double *weights; int *membersSorted; int *membersMapped; }

user_defined_types: struct _column { int row; double value; struct _column *next; }

user_defined_types: struct _bound { double upbo; double lowbo; }


decompiled_code:
int __fastcall print_constraints(__int64 a1)
{
__int64 v1; // rsi
double v2; // r12
const char *v3; // rax

InitStream();
fwrite("\nActual values of the constraints:\n", 1uLL, 0x23uLL, stream);
if ( *(int *)(a1 + 20) > 0 )
{
v1 = 0LL;
do
{
v2 = *(double *)(*(_QWORD *)(a1 + 296) + 8 * (v1 + 1));
v3 = (const char *)get_row_name(a1, (unsigned int)(v1 + 1));
fprintf(stream, "%-20s %g\n", v3, v2);
++v1;
}
while ( *(_DWORD *)(a1 + 20) >= (int)v1 + 1 );
}
return fflush(stream);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
__int64 v1; // rsi
double v2; // r12
const char *v3; // rax

func0();
fwrite("\nActual values of the constraints:\n", 1uLL, 0x23uLL, stream);
if ( *(int *)(a1 + 20) > 0 )
{
v1 = 0LL;
do
{
v2 = *(double *)(*(_QWORD *)(a1 + 296) + 8 * (v1 + 1));
v3 = (const char *)get_row_name(a1, (unsigned int)(v1 + 1));
fprintf(stream, "%-20s %g\n", v3, v2);
++v1;
}
while ( *(_DWORD *)(a1 + 20) >= (int)v1 + 1 );
}
return fflush(stream);
}

original_code:
void print_constraints(lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nActual values of the constraints:\n");
  for(i = 1; i <= lp->rows; i++)
    fprintf(stream, "%-20s %g\n", get_row_name(lp, i),
     (double)lp->best_solution[i]);
  fflush(stream);
}

canonical_original_code:
void print_constraints(struct _lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nActual values of the constraints:\n");
  for(i = 1; i <= lp->rows; i++)
    fprintf(stream, "%-20s %g\n", get_row_name(lp, i),
     (double)lp->best_solution[i]);
  fflush(stream);
}


decompiled_code:
int __fastcall print_duals(__int64 a1)
{
int v1; // eax
__int64 v2; // r12
int v3; // ebp
const char *v4; // rdx
double v5; // r15
double v6; // r14
double v7; // r13

InitStream();
fwrite("\nDual values with from - till limits:\n", 1uLL, 0x26uLL, stream);
v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 28) + v1 > 0 )
{
v2 = 8LL;
v3 = 1;
do
{
v5 = *(double *)(*(_QWORD *)(a1 + 464) + v2);
v6 = *(double *)(*(_QWORD *)(a1 + 456) + v2);
v7 = *(double *)(*(_QWORD *)(a1 + 304) + v2);
if ( v1 < v3 )
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v1));
else
v4 = (const char *)get_row_name(a1, (unsigned int)v3);
fprintf(stream, "%-20s %8g %8g %8g\n", v4, v7, v6, v5);
++v3;
v1 = *(_DWORD *)(a1 + 20);
v2 += 8LL;
}
while ( *(_DWORD *)(a1 + 28) + v1 >= v3 );
}
return fflush(stream);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
int v1; // eax
__int64 v2; // r12
int v3; // ebp
const char *v4; // rdx
double v5; // r15
double v6; // r14
double v7; // r13

func0();
fwrite("\nDual values with from - till limits:\n", 1uLL, 0x26uLL, stream);
v1 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 28) + v1 > 0 )
{
v2 = 8LL;
v3 = 1;
do
{
v5 = *(double *)(*(_QWORD *)(a1 + 464) + v2);
v6 = *(double *)(*(_QWORD *)(a1 + 456) + v2);
v7 = *(double *)(*(_QWORD *)(a1 + 304) + v2);
if ( v1 < v3 )
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v1));
else
v4 = (const char *)get_row_name(a1, (unsigned int)v3);
fprintf(stream, "%-20s %8g %8g %8g\n", v4, v7, v6, v5);
++v3;
v1 = *(_DWORD *)(a1 + 20);
v2 += 8LL;
}
while ( *(_DWORD *)(a1 + 28) + v1 >= v3 );
}
return fflush(stream);
}

original_code:
void print_duals(lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nDual values with from - till limits:\n");
  for(i = 1; i <= lp->rows + lp->columns; i++)
    fprintf(stream, "%-20s %8g  %8g %8g\n", (i <= lp->rows) ? get_row_name(lp, i) : get_col_name(lp, i - lp->rows),
     (double)lp->duals[i], (double)lp->dualsfrom[i], (double)lp->dualstill[i]);
  fflush(stream);
}

canonical_original_code:
void print_duals(struct _lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "\nDual values with from - till limits:\n");
  for(i = 1; i <= lp->rows + lp->columns; i++)
    fprintf(stream, "%-20s %8g  %8g %8g\n", (i <= lp->rows) ? get_row_name(lp, i) : get_col_name(lp, i - lp->rows),
     (double)lp->duals[i], (double)lp->dualsfrom[i], (double)lp->dualstill[i]);
  fflush(stream);
}


decompiled_code:
int __fastcall print_scales(__int64 a1)
{
int v2; // eax
__int64 v3; // rbx
const char *v4; // rdx
double v5; // r12

InitStream();
if ( *(_BYTE *)(a1 + 328) )
{
fwrite("\nScale factors:\n", 1uLL, 0x10uLL, stream);
v2 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 28) + v2 >= 0 )
{
v3 = 0LL;
do
{
v5 = *(double *)(*(_QWORD *)(a1 + 336) + 8 * v3);
if ( v2 < (int)v3 )
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v2));
else
v4 = (const char *)get_row_name(a1, (unsigned int)v3);
fprintf(stream, "%-20s scaled at %g\n", v4, v5);
v2 = *(_DWORD *)(a1 + 20);
++v3;
}
while ( *(_DWORD *)(a1 + 28) + v2 >= (int)v3 );
}
}
return fflush(stream);
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
int v2; // eax
__int64 v3; // rbx
const char *v4; // rdx
double v5; // r12

func0();
if ( *(_BYTE *)(a1 + 328) )
{
fwrite("\nScale factors:\n", 1uLL, 0x10uLL, stream);
v2 = *(_DWORD *)(a1 + 20);
if ( *(_DWORD *)(a1 + 28) + v2 >= 0 )
{
v3 = 0LL;
do
{
v5 = *(double *)(*(_QWORD *)(a1 + 336) + 8 * v3);
if ( v2 < (int)v3 )
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v2));
else
v4 = (const char *)get_row_name(a1, (unsigned int)v3);
fprintf(stream, "%-20s scaled at %g\n", v4, v5);
v2 = *(_DWORD *)(a1 + 20);
++v3;
}
while ( *(_DWORD *)(a1 + 28) + v2 >= (int)v3 );
}
}
return fflush(stream);
}

original_code:
void print_scales(lprec *lp)
{
  int i;
  InitStream();
  if(lp->scaling_used) {
    fprintf(stream, "\nScale factors:\n");
    for(i = 0; i <= lp->rows + lp->columns; i++)
      fprintf(stream, "%-20s scaled at %g\n", (i <= lp->rows) ? get_row_name(lp, i) : get_col_name(lp, i - lp->rows),
       (double)lp->scale[i]);
  }
  fflush(stream);
}

canonical_original_code:
void print_scales(struct _lprec *lp)
{
  int i;
  InitStream();
  if(lp->scaling_used) {
    fprintf(stream, "\nScale factors:\n");
    for(i = 0; i <= lp->rows + lp->columns; i++)
      fprintf(stream, "%-20s scaled at %g\n", (i <= lp->rows) ? get_row_name(lp, i) : get_col_name(lp, i - lp->rows),
       (double)lp->scale[i]);
  }
  fflush(stream);
}


decompiled_code:
_BOOL8 __fastcall print_file(char *filename)
{
if ( stream && stream != stderr )
fclose(stream);
if ( filename )
stream = fopen(filename, "w");
else
stream = stderr;
return stream != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(char *filename)
{
if ( stream && stream != stderr )
fclose(stream);
if ( filename )
stream = fopen(filename, "w");
else
stream = stderr;
return stream != 0LL;
}

original_code:
int print_file(char *filename)
{
  if ((stream != ((void *)0)) && (stream != stderr))
    fclose(stream);
  if (filename == ((void *)0))
    stream = stderr;
  else
    stream = fopen(filename, "w");
  return(stream != ((void *)0));
}

variable_types:
filename
char *

return_type: int


decompiled_code:
int __fastcall print_help(const char **a1)
{
printf("Usage of %s version %d.%d.%d.%d:\n", *a1, 4LL, 0LL, 1LL, 0LL);
printf("%s [options] [[<]input_file]\n", *a1);
puts("List of options:");
puts("-h\t\tprints this message");
puts("-v <level>\tverbose mode, gives flow through the program.");
puts("\t\t if level not provided (-v) then -v2 (NORMAL) is taken.");
puts("\t -v0: CRITICALSTOP");
puts("\t -v1: CRITICAL");
puts("\t -v2: SEVERE");
puts("\t -v3: IMPORTANT (default)");
puts("\t -v4: NORMAL");
puts("\t -v5: DETAILED");
puts("\t -v6: FULL");
puts("-d\t\tdebug mode, all intermediate results are printed,\n\t\tand the branch-and-bound decisions");
puts("-p\t\tprint the values of the dual variables");
puts(
"-b <bound>\tspecify a lower bound for the objective function\n"
"\t\tto the program. If close enough, may speed up the\n"
"\t\tcalculations.");
puts(
"-i\t\tprint all intermediate valid solutions.\n"
"\t\tCan give you useful solutions even if the total run time\n"
"\t\tis too long");
puts(
"-e <number>\tspecifies the epsilon which is used to determine whether a\n"
"\t\tfloating point number is in fact an integer.\n"
"\t\tShould be < 0.5");
puts("-c\t\tduring branch-and-bound, take the ceiling branch first");
puts("-ca\t\tduring branch-and-bound, the algorithm chooses branch");
puts("-B <rule>\tspecify branch-and-bound rule");
puts("\t -B0: Select Lowest indexed non-integer column (default)");
puts("\t -B1: Select Random non-integer column");
puts("\t -B2: Select Largest deviation from an integer value");
puts("\t -B3: Select Best ???");
puts("\t -B4: Select Median value deviation from an integer value");
puts("\t -B5: Select Greedy ???");
puts("-s <mode>\tuse automatic problem scaling.");
puts("\t -s:");
puts("\t -s0: Numerical range-based scaling");
puts("\t -s1: Geometric scaling");
puts("\t -s2: Curtis-reid scaling");
puts("-sp\t\talso do power scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-sl\t\talso do Lagrange scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-si\t\talso do Integer scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-I\t\tprint info after reinverting");
puts("-t\t\ttrace pivot selection");
puts("-lp\t\tread from LP file (default)");
puts("-mps\t\tread from MPS file");
puts("-degen\t\tuse perturbations to reduce degeneracy,\n\t\tcan increase numerical instability");
puts("-trej <Trej>\tset minimum pivot value");
puts("-parse_only\tparse input file but do not calculate (ie check)");
puts("-presolve\tpresolve problem before start optimizing");
puts("-improve <level>\titerative improvement level");
puts("\t -improve0: none (default)");
puts("\t -improve1: FTRAN only");
puts("\t -improve2: BTRAN only");
puts("\t -improve3: FTRAN + BTRAN");
puts("-time\t\tPrint CPU time to parse input and to calculate result");
puts("-min\t\tMinimize the lp problem (overrules setting in file)");
puts("-max\t\tMaximize the lp problem (overrules setting in file)");
puts("-S <detail>\tPrint solution. If detail ommited, then -S2 is used.");
puts("\t -S0: Print nothing");
puts("\t -S1: Only objective value");
puts("\t -S2: Objective value + variables (default)");
puts("\t -S3: Objective value + variables + constraints");
puts("\t -S4: Objective value + variables + constraints + duals");
puts("\t -S5: Objective value + variables + constraints + duals + lp model");
return puts("\t -S6: Objective value + variables + constraints + duals + lp model + lp scales");
}

canonical_decompiled_code:
int __fastcall func0(const char **a1)
{
printf("Usage of %s version %d.%d.%d.%d:\n", *a1, 4LL, 0LL, 1LL, 0LL);
printf("%s [options] [[<]input_file]\n", *a1);
puts("List of options:");
puts("-h\t\tprints this message");
puts("-v <level>\tverbose mode, gives flow through the program.");
puts("\t\t if level not provided (-v) then -v2 (NORMAL) is taken.");
puts("\t -v0: CRITICALSTOP");
puts("\t -v1: CRITICAL");
puts("\t -v2: SEVERE");
puts("\t -v3: IMPORTANT (default)");
puts("\t -v4: NORMAL");
puts("\t -v5: DETAILED");
puts("\t -v6: FULL");
puts("-d\t\tdebug mode, all intermediate results are printed,\n\t\tand the branch-and-bound decisions");
puts("-p\t\tprint the values of the dual variables");
puts(
"-b <bound>\tspecify a lower bound for the objective function\n"
"\t\tto the program. If close enough, may speed up the\n"
"\t\tcalculations.");
puts(
"-i\t\tprint all intermediate valid solutions.\n"
"\t\tCan give you useful solutions even if the total run time\n"
"\t\tis too long");
puts(
"-e <number>\tspecifies the epsilon which is used to determine whether a\n"
"\t\tfloating point number is in fact an integer.\n"
"\t\tShould be < 0.5");
puts("-c\t\tduring branch-and-bound, take the ceiling branch first");
puts("-ca\t\tduring branch-and-bound, the algorithm chooses branch");
puts("-B <rule>\tspecify branch-and-bound rule");
puts("\t -B0: Select Lowest indexed non-integer column (default)");
puts("\t -B1: Select Random non-integer column");
puts("\t -B2: Select Largest deviation from an integer value");
puts("\t -B3: Select Best ???");
puts("\t -B4: Select Median value deviation from an integer value");
puts("\t -B5: Select Greedy ???");
puts("-s <mode>\tuse automatic problem scaling.");
puts("\t -s:");
puts("\t -s0: Numerical range-based scaling");
puts("\t -s1: Geometric scaling");
puts("\t -s2: Curtis-reid scaling");
puts("-sp\t\talso do power scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-sl\t\talso do Lagrange scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-si\t\talso do Integer scaling.\n\t\tThis option must come AFTER -s <mode> option");
puts("-I\t\tprint info after reinverting");
puts("-t\t\ttrace pivot selection");
puts("-lp\t\tread from LP file (default)");
puts("-mps\t\tread from MPS file");
puts("-degen\t\tuse perturbations to reduce degeneracy,\n\t\tcan increase numerical instability");
puts("-trej <Trej>\tset minimum pivot value");
puts("-parse_only\tparse input file but do not calculate (ie check)");
puts("-presolve\tpresolve problem before start optimizing");
puts("-improve <level>\titerative improvement level");
puts("\t -improve0: none (default)");
puts("\t -improve1: FTRAN only");
puts("\t -improve2: BTRAN only");
puts("\t -improve3: FTRAN + BTRAN");
puts("-time\t\tPrint CPU time to parse input and to calculate result");
puts("-min\t\tMinimize the lp problem (overrules setting in file)");
puts("-max\t\tMaximize the lp problem (overrules setting in file)");
puts("-S <detail>\tPrint solution. If detail ommited, then -S2 is used.");
puts("\t -S0: Print nothing");
puts("\t -S1: Only objective value");
puts("\t -S2: Objective value + variables (default)");
puts("\t -S3: Objective value + variables + constraints");
puts("\t -S4: Objective value + variables + constraints + duals");
puts("\t -S5: Objective value + variables + constraints + duals + lp model");
return puts("\t -S6: Objective value + variables + constraints + duals + lp model + lp scales");
}

original_code:
void print_help(char *argv[])
{
  printf("Usage of %s version %d.%d.%d.%d:\n", argv[0], 4, 0, 1, 0);
  printf("%s [options] [[<]input_file]\n", argv[0]);
  printf("List of options:\n");
  printf("-h\t\tprints this message\n");
  printf("-v <level>\tverbose mode, gives flow through the program.\n");
  printf("\t\t if level not provided (-v) then -v2 (NORMAL) is taken.\n");
  printf("\t -v0: CRITICALSTOP\n");
  printf("\t -v1: CRITICAL\n");
  printf("\t -v2: SEVERE\n");
  printf("\t -v3: IMPORTANT (default)\n");
  printf("\t -v4: NORMAL\n");
  printf("\t -v5: DETAILED\n");
  printf("\t -v6: FULL\n");
  printf("-d\t\tdebug mode, all intermediate results are printed,\n\t\tand the branch-and-bound decisions\n");
  printf("-p\t\tprint the values of the dual variables\n");
  printf("-b <bound>\tspecify a lower bound for the objective function\n\t\tto the program. If close enough, may speed up the\n\t\tcalculations.\n");
  printf("-i\t\tprint all intermediate valid solutions.\n\t\tCan give you useful solutions even if the total run time\n\t\tis too long\n");
  printf("-e <number>\tspecifies the epsilon which is used to determine whether a\n\t\tfloating point number is in fact an integer.\n\t\tShould be < 0.5\n");
  printf("-c\t\tduring branch-and-bound, take the ceiling branch first\n");
  printf("-ca\t\tduring branch-and-bound, the algorithm chooses branch\n");
  printf("-B <rule>\tspecify branch-and-bound rule\n");
  printf("\t -B0: Select Lowest indexed non-integer column (default)\n");
  printf("\t -B1: Select Random non-integer column\n");
  printf("\t -B2: Select Largest deviation from an integer value\n");
  printf("\t -B3: Select Best ???\n");
  printf("\t -B4: Select Median value deviation from an integer value\n");
  printf("\t -B5: Select Greedy ???\n");
  printf("-s <mode>\tuse automatic problem scaling.\n");
  printf("\t  -s:\n");
  printf("\t -s0: Numerical range-based scaling\n");
  printf("\t -s1: Geometric scaling\n");
  printf("\t -s2: Curtis-reid scaling\n");
  printf("-sp\t\talso do power scaling.\n\t\tThis option must come AFTER -s <mode> option\n");
  printf("-sl\t\talso do Lagrange scaling.\n\t\tThis option must come AFTER -s <mode> option\n");
  printf("-si\t\talso do Integer scaling.\n\t\tThis option must come AFTER -s <mode> option\n");
  printf("-I\t\tprint info after reinverting\n");
  printf("-t\t\ttrace pivot selection\n");
  printf("-lp\t\tread from LP file (default)\n");
  printf("-mps\t\tread from MPS file\n");
  printf("-degen\t\tuse perturbations to reduce degeneracy,\n\t\tcan increase numerical instability\n");
  printf("-trej <Trej>\tset minimum pivot value\n");
  printf("-parse_only\tparse input file but do not calculate (ie check)\n");
  printf("-presolve\tpresolve problem before start optimizing\n");
  printf("-improve <level>\titerative improvement level\n");
  printf("\t -improve0: none (default)\n");
  printf("\t -improve1: FTRAN only\n");
  printf("\t -improve2: BTRAN only\n");
  printf("\t -improve3: FTRAN + BTRAN\n");
  printf("-time\t\tPrint CPU time to parse input and to calculate result\n");
  printf("-min\t\tMinimize the lp problem (overrules setting in file)\n");
  printf("-max\t\tMaximize the lp problem (overrules setting in file)\n");
  printf("-S <detail>\tPrint solution. If detail ommited, then -S2 is used.\n");
  printf("\t -S0: Print nothing\n");
  printf("\t -S1: Only objective value\n");
  printf("\t -S2: Objective value + variables (default)\n");
  printf("\t -S3: Objective value + variables + constraints\n");
  printf("\t -S4: Objective value + variables + constraints + duals\n");
  printf("\t -S5: Objective value + variables + constraints + duals + lp model\n");
  printf("\t -S6: Objective value + variables + constraints + duals + lp model + lp scales\n");
}

variable_types:
argv
char *[]


decompiled_code:
int __fastcall print_cpu_times(const char *a1)
{
clock_t v1; // rbx
int result; // eax

v1 = clock();
result = fprintf(
stderr,
"CPU Time for %s: %gs (%gs total since program start)\n",
a1,
(double)((int)v1 - (int)last_time_0) / 1000000.0,
(double)(int)v1 / 1000000.0);
last_time_0 = v1;
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
clock_t v1; // rbx
int result; // eax

v1 = clock();
result = fprintf(
stderr,
"CPU Time for %s: %gs (%gs total since program start)\n",
a1,
(double)((int)v1 - (int)last_time_0) / 1000000.0,
(double)(int)v1 / 1000000.0);
last_time_0 = v1;
return result;
}

original_code:
void print_cpu_times(const char *info)
{
  static clock_t last_time = 0;
  clock_t new_time;
  new_time = clock();
  fprintf(stderr, "CPU Time for %s: %gs (%gs total since program start)\n",
   info, (new_time - last_time) / (double) ((__clock_t) 1000000),
   new_time / (double) ((__clock_t) 1000000));
  last_time = new_time;
}

canonical_original_code:
void print_cpu_times(char *info)
{
  static long last_time = 0;
  long new_time;
  new_time = clock();
  fprintf(stderr, "CPU Time for %s: %gs (%gs total since program start)\n",
   info, (new_time - last_time) / (double) ((long) 1000000),
   new_time / (double) ((long) 1000000));
  last_time = new_time;
}

variable_types:
info
char *


presolve

decompiled_code:
__int64 __fastcall presolve(__int64 a1)
{
char v1; // al
int v2; // er13
unsigned int v3; // ebp
int v4; // er12
unsigned int v5; // eax
int v6; // er12
int v7; // ebp
int v8; // eax
size_t v9; // r13
_DWORD *v10; // r15
_DWORD *v11; // rbp
double *v12; // r14
_DWORD *v13; // r12
unsigned int v14; // er15
double *v16; // rbp
double v17; // xmm0_8
int v18; // er13
__int64 v19; // r14
double *v20; // rax
double v21; // xmm0_8
__int64 v22; // rbp
double v23; // xmm0_8
__int64 v24; // rbp
double *v25; // rax
double v26; // xmm2_8
double v27; // xmm1_8
__int64 v28; // rax
unsigned int v29; // er13
int v30; // ebp
__int64 v31; // rbx
int v32; // er12
__int64 v33; // rbx
unsigned int v34; // er12
__int16 v35; // r12
int v36; // ecx
__int64 v37; // rax
int v38; // ecx
__int64 v39; // rax
__int64 v40; // rbx
int v41; // [rsp+0h] [rbp-88h]
double v42; // [rsp+0h] [rbp-88h]
double v43; // [rsp+8h] [rbp-80h]
char *v44; // [rsp+10h] [rbp-78h]
double v45; // [rsp+10h] [rbp-78h]
_DWORD *v46; // [rsp+10h] [rbp-78h]
double *ptr; // [rsp+18h] [rbp-70h]
double *v48; // [rsp+20h] [rbp-68h]
int v49; // [rsp+20h] [rbp-68h]
_DWORD *v50; // [rsp+28h] [rbp-60h]
unsigned int v51; // [rsp+28h] [rbp-60h]
__int16 v52; // [rsp+30h] [rbp-58h]
unsigned int v53; // [rsp+38h] [rbp-50h]
unsigned int v54; // [rsp+3Ch] [rbp-4Ch]
unsigned int v55[15]; // [rsp+4Ch] [rbp-3Ch] BYREF

v1 = *(_BYTE *)(a1 + 18);
if ( v1 == 5 )
return 5LL;
if ( !v1 )
return 5;
if ( *(_BYTE *)(a1 + 16) || *(_BYTE *)(a1 + 12) )
report(a1, 6LL, "Entered presolve at iteration %d", *(unsigned int *)(a1 + 276));
*(_DWORD *)(a1 + 488) = *(_DWORD *)(a1 + 20);
v55[0] = 0;
if ( *(int *)(a1 + 704) > 0 )
{
v52 = 5;
v2 = 0;
v3 = 1;
do
{
v4 = SOS_infeasible(a1, v3);
if ( v4 > 0 )
{
v5 = SOS_get_type(a1, v3);
report(
a1,
4LL,
"presolve found SOS %d (type %d) to be range-infeasible on variable %d",
v3,
v5,
(unsigned int)v4);
++v2;
v52 = 2;
}
++v3;
}
while ( *(_DWORD *)(a1 + 704) >= (signed int)v3 );
if ( v2 <= 0 )
goto LABEL_12;
return (unsigned int)v52;
}
v52 = 5;
LABEL_12:
v6 = *(_DWORD *)(a1 + 28);
v7 = *(_DWORD *)(a1 + 20);
v8 = v7;
if ( v6 >= v7 )
v8 = *(_DWORD *)(a1 + 28);
v41 = v8;
if ( v7 == -1 || (v9 = v7 + 1, (v10 = calloc(v9, 4uLL)) == 0LL) )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4LL * (v7 + 1), 207LL, "presolve.c");
v10 = 0LL;
}
else
{
v11 = calloc(v7 + 1, 4uLL);
if ( v11 )
{
if ( v41 == -1 || (v12 = (double *)calloc(v41 + 1, 8uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8LL * (v41 + 1), 209LL, "presolve.c");
}
else
{
ptr = (double *)calloc(v9, 8uLL);
if ( ptr )
{
v44 = (_BYTE *)&loc_4;
if ( v6 > 0 )
{
v13 = v10;
v50 = v11;
v48 = v12;
v14 = 1;
do
{
v28 = *(_QWORD *)(a1 + 80);
v18 = *(_DWORD *)&v44[v28 - 4];
if ( v18 < *(_DWORD *)&v44[v28] )
{
v19 = 16LL * v18;
do
{
v20 = (double *)(*(_QWORD *)(a1 + 72) + v19);
v21 = v20[1];
v22 = *(int *)v20;
v42 = v21;
if ( *(_BYTE *)(*(_QWORD *)(a1 + 320) + v22) )
*(_QWORD *)&v42 = *(_QWORD *)&v21 ^ LC1;
if ( *(_BYTE *)(a1 + 328) )
v42 = v42
/ (*(double *)(*(_QWORD *)(a1 + 336) + 8LL * (int)(*(_DWORD *)(a1 + 20) + v14))
* *(double *)(*(_QWORD *)(a1 + 336) + 8 * v22));
++v13[v22];
if ( v21 < 0.0 )
--v50[v22];
else
++v50[v22];
v23 = get_upbo(a1, v14);
v24 = v22;
v25 = &v48[v24];
v26 = v48[v24];
v27 = *(double *)(a1 + 400);
if ( v27 > v26 )
{
if ( v23 < v27 )
*v25 = v23 * v42 + v26;
else
*v25 = v27;
}
v43 = get_lowbo(a1, v14);
v16 = &ptr[v24];
*(_QWORD *)&v17 = *(_QWORD *)(a1 + 400) ^ LC1;
if ( *v16 > v17 )
{
if ( v17 < v43 )
{
if ( !(unsigned int)is_semicont(a1, v14) )
*v16 = v42 * v43 + *v16;
}
else
{
*v16 = v17;
}
}
++v18;
v19 += 16LL;
}
while ( *(_DWORD *)&v44[*(_QWORD *)(a1 + 80)] > v18 );
}
++v14;
v44 += 4;
}
while ( *(_DWORD *)(a1 + 28) >= (signed int)v14 );
v10 = v13;
v11 = v50;
v12 = v48;
}
v53 = 0;
v54 = 0;
v51 = 0;
while ( 1 )
{
v32 = *(_DWORD *)(a1 + 28);
if ( v32 <= 0 )
break;
v31 = 4LL * v32;
v29 = v54;
v46 = v11;
v30 = 0;
do
{
if ( *(_DWORD *)(*(_QWORD *)(a1 + 80) + v31) == *(_DWORD *)(*(_QWORD *)(a1 + 80) + v31 - 4) )
{
if ( *(int *)(a1 + 704) > 0 && (unsigned int)SOS_is_member(a1, 0LL, (unsigned int)v32) )
{
report(a1, 4LL, "presolve found empty variable %d as member of a SOS", (unsigned int)v32);
}
else
{
del_column(a1, (unsigned int)v32);
++v29;
++v30;
}
}
v31 -= 4LL;
--v32;
}
while ( v32 );
v49 = v30;
v54 = v29;
v11 = v46;
LODWORD(v33) = *(_DWORD *)(a1 + 20);
if ( (int)v33 > 0 )
goto LABEL_60;
LABEL_84:
if ( v49 <= 0 )
{
v40 = a1;
goto LABEL_89;
}
}
LODWORD(v33) = *(_DWORD *)(a1 + 20);
if ( (int)v33 > 0 )
{
v49 = 0;
LABEL_60:
v33 = (int)v33;
while ( 1 )
{
v35 = get_constr_type(a1, (unsigned int)v33);
if ( !v35 )
goto LABEL_68;
v45 = v12[v33];
if ( v45 - get_rh(a1, (unsigned int)v33) > *(double *)(a1 + 400) )
{
report(a1, 4LL, "presolve found upper bound infeasibility in row %d", (unsigned int)v33);
free(ptr);
free(v12);
free(v11);
free(v10);
return 2LL;
}
if ( v35 != 2 )
{
LABEL_68:
if ( COERCE_DOUBLE(*(_QWORD *)(a1 + 400) ^ LC1) > get_rh(a1, (unsigned int)v33) - ptr[v33] )
{
report(a1, 4LL, "presolve found lower bound infeasibility in row %d", (unsigned int)v33);
free(ptr);
free(v12);
free(v11);
free(v10);
return 2LL;
}
}
v34 = v10[v33];
if ( v34
&& (abs32(v11[v33]) != v34
|| *(double *)(a1 + 432) <= COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v12[v33] - ptr[v33]) & LC2)) )
{
if ( v34 == 1 )
{
if ( *(int *)(a1 + 28) > 0 )
{
do
{
if ( get_mat_raw(a1, (unsigned int)v33, v34) != 0.0 )
break;
++v34;
}
while ( *(_DWORD *)(a1 + 28) >= (signed int)v34 );
}
v52 = tighten_bounds(a1, v33, v34, 1, (__int64)ptr, (__int64)v12, (int *)v55);
if ( v52 == 2 )
{
v40 = a1;
goto LABEL_89;
}
del_constraint(a1, (unsigned int)v33);
v38 = *(_DWORD *)(a1 + 20);
if ( v38 >= (int)v33 )
{
v39 = v33;
do
{
v10[v39] = v10[v39 + 1];
v11[v39] = v11[v39 + 1];
ptr[v39] = ptr[v39 + 1];
v12[v39] = v12[v39 + 1];
++v39;
}
while ( v38 >= (int)v39 );
}
++v53;
++v49;
}
}
else
{
del_constraint(a1, (unsigned int)v33);
v36 = *(_DWORD *)(a1 + 20);
if ( v36 >= (int)v33 )
{
v37 = v33;
do
{
v10[v37] = v10[v37 + 1];
v11[v37] = v11[v37 + 1];
ptr[v37] = ptr[v37 + 1];
v12[v37] = v12[v37 + 1];
++v37;
}
while ( v36 >= (int)v37 );
}
++v51;
++v49;
}
if ( (int)--v33 <= 0 )
goto LABEL_84;
}
}
v40 = a1;
LABEL_89:
if ( *(double *)(v40 + 432) > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*v12 - *ptr) & LC2) )
report(v40, 4LL, "presolve identified optimal solution");
if ( v51 )
report(v40, 4LL, "presolve removed %d empty or redundant rows", v51);
if ( v53 )
report(v40, 4LL, "presolve converted %d singleton rows to bounds", v53);
if ( v55[0] )
report(v40, 4LL, "presolve tightened %d bounds", v55[0]);
if ( v54 )
report(v40, 4LL, "presolve removed %d empty columns", v54);
free(v10);
free(v11);
free(ptr);
free(v12);
return (unsigned int)v52;
}
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8 * v9, 210LL, "presolve.c");
free(v12);
}
free(v11);
}
else
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v9, 208LL, "presolve.c");
}
}
if ( v10 )
free(v10);
*(_WORD *)(a1 + 496) = 12;
return 2LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
char v1; // al
int v2; // er13
unsigned int v3; // ebp
int v4; // er12
unsigned int v5; // eax
int v6; // er12
int v7; // ebp
int v8; // eax
size_t v9; // r13
_DWORD *v10; // r15
_DWORD *v11; // rbp
double *v12; // r14
_DWORD *v13; // r12
unsigned int v14; // er15
double *v16; // rbp
double v17; // xmm0_8
int v18; // er13
__int64 v19; // r14
double *v20; // rax
double v21; // xmm0_8
__int64 v22; // rbp
double v23; // xmm0_8
__int64 v24; // rbp
double *v25; // rax
double v26; // xmm2_8
double v27; // xmm1_8
__int64 v28; // rax
unsigned int v29; // er13
int v30; // ebp
__int64 v31; // rbx
int v32; // er12
__int64 v33; // rbx
unsigned int v34; // er12
__int16 v35; // r12
int v36; // ecx
__int64 v37; // rax
int v38; // ecx
__int64 v39; // rax
__int64 v40; // rbx
int v41; // [rsp+0h] [rbp-88h]
double v42; // [rsp+0h] [rbp-88h]
double v43; // [rsp+8h] [rbp-80h]
char *v44; // [rsp+10h] [rbp-78h]
double v45; // [rsp+10h] [rbp-78h]
_DWORD *v46; // [rsp+10h] [rbp-78h]
double *ptr; // [rsp+18h] [rbp-70h]
double *v48; // [rsp+20h] [rbp-68h]
int v49; // [rsp+20h] [rbp-68h]
_DWORD *v50; // [rsp+28h] [rbp-60h]
unsigned int v51; // [rsp+28h] [rbp-60h]
__int16 v52; // [rsp+30h] [rbp-58h]
unsigned int v53; // [rsp+38h] [rbp-50h]
unsigned int v54; // [rsp+3Ch] [rbp-4Ch]
unsigned int v55[15]; // [rsp+4Ch] [rbp-3Ch] BYREF

v1 = *(_BYTE *)(a1 + 18);
if ( v1 == 5 )
return 5LL;
if ( !v1 )
return 5;
if ( *(_BYTE *)(a1 + 16) || *(_BYTE *)(a1 + 12) )
report(a1, 6LL, "Entered presolve at iteration %d", *(unsigned int *)(a1 + 276));
*(_DWORD *)(a1 + 488) = *(_DWORD *)(a1 + 20);
v55[0] = 0;
if ( *(int *)(a1 + 704) > 0 )
{
v52 = 5;
v2 = 0;
v3 = 1;
do
{
v4 = SOS_infeasible(a1, v3);
if ( v4 > 0 )
{
v5 = SOS_get_type(a1, v3);
report(
a1,
4LL,
"presolve found SOS %d (type %d) to be range-infeasible on variable %d",
v3,
v5,
(unsigned int)v4);
++v2;
v52 = 2;
}
++v3;
}
while ( *(_DWORD *)(a1 + 704) >= (signed int)v3 );
if ( v2 <= 0 )
goto LABEL_12;
return (unsigned int)v52;
}
v52 = 5;
LABEL_12:
v6 = *(_DWORD *)(a1 + 28);
v7 = *(_DWORD *)(a1 + 20);
v8 = v7;
if ( v6 >= v7 )
v8 = *(_DWORD *)(a1 + 28);
v41 = v8;
if ( v7 == -1 || (v9 = v7 + 1, (v10 = calloc(v9, 4uLL)) == 0LL) )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4LL * (v7 + 1), 207LL, "presolve.c");
v10 = 0LL;
}
else
{
v11 = calloc(v7 + 1, 4uLL);
if ( v11 )
{
if ( v41 == -1 || (v12 = (double *)calloc(v41 + 1, 8uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8LL * (v41 + 1), 209LL, "presolve.c");
}
else
{
ptr = (double *)calloc(v9, 8uLL);
if ( ptr )
{
v44 = (_BYTE *)&loc_4;
if ( v6 > 0 )
{
v13 = v10;
v50 = v11;
v48 = v12;
v14 = 1;
do
{
v28 = *(_QWORD *)(a1 + 80);
v18 = *(_DWORD *)&v44[v28 - 4];
if ( v18 < *(_DWORD *)&v44[v28] )
{
v19 = 16LL * v18;
do
{
v20 = (double *)(*(_QWORD *)(a1 + 72) + v19);
v21 = v20[1];
v22 = *(int *)v20;
v42 = v21;
if ( *(_BYTE *)(*(_QWORD *)(a1 + 320) + v22) )
*(_QWORD *)&v42 = *(_QWORD *)&v21 ^ LC1;
if ( *(_BYTE *)(a1 + 328) )
v42 = v42
/ (*(double *)(*(_QWORD *)(a1 + 336) + 8LL * (int)(*(_DWORD *)(a1 + 20) + v14))
* *(double *)(*(_QWORD *)(a1 + 336) + 8 * v22));
++v13[v22];
if ( v21 < 0.0 )
--v50[v22];
else
++v50[v22];
v23 = get_upbo(a1, v14);
v24 = v22;
v25 = &v48[v24];
v26 = v48[v24];
v27 = *(double *)(a1 + 400);
if ( v27 > v26 )
{
if ( v23 < v27 )
*v25 = v23 * v42 + v26;
else
*v25 = v27;
}
v43 = get_lowbo(a1, v14);
v16 = &ptr[v24];
*(_QWORD *)&v17 = *(_QWORD *)(a1 + 400) ^ LC1;
if ( *v16 > v17 )
{
if ( v17 < v43 )
{
if ( !(unsigned int)is_semicont(a1, v14) )
*v16 = v42 * v43 + *v16;
}
else
{
*v16 = v17;
}
}
++v18;
v19 += 16LL;
}
while ( *(_DWORD *)&v44[*(_QWORD *)(a1 + 80)] > v18 );
}
++v14;
v44 += 4;
}
while ( *(_DWORD *)(a1 + 28) >= (signed int)v14 );
v10 = v13;
v11 = v50;
v12 = v48;
}
v53 = 0;
v54 = 0;
v51 = 0;
while ( 1 )
{
v32 = *(_DWORD *)(a1 + 28);
if ( v32 <= 0 )
break;
v31 = 4LL * v32;
v29 = v54;
v46 = v11;
v30 = 0;
do
{
if ( *(_DWORD *)(*(_QWORD *)(a1 + 80) + v31) == *(_DWORD *)(*(_QWORD *)(a1 + 80) + v31 - 4) )
{
if ( *(int *)(a1 + 704) > 0 && (unsigned int)SOS_is_member(a1, 0LL, (unsigned int)v32) )
{
report(a1, 4LL, "presolve found empty variable %d as member of a SOS", (unsigned int)v32);
}
else
{
del_column(a1, (unsigned int)v32);
++v29;
++v30;
}
}
v31 -= 4LL;
--v32;
}
while ( v32 );
v49 = v30;
v54 = v29;
v11 = v46;
LODWORD(v33) = *(_DWORD *)(a1 + 20);
if ( (int)v33 > 0 )
goto LABEL_60;
LABEL_84:
if ( v49 <= 0 )
{
v40 = a1;
goto LABEL_89;
}
}
LODWORD(v33) = *(_DWORD *)(a1 + 20);
if ( (int)v33 > 0 )
{
v49 = 0;
LABEL_60:
v33 = (int)v33;
while ( 1 )
{
v35 = get_constr_type(a1, (unsigned int)v33);
if ( !v35 )
goto LABEL_68;
v45 = v12[v33];
if ( v45 - get_rh(a1, (unsigned int)v33) > *(double *)(a1 + 400) )
{
report(a1, 4LL, "presolve found upper bound infeasibility in row %d", (unsigned int)v33);
free(ptr);
free(v12);
free(v11);
free(v10);
return 2LL;
}
if ( v35 != 2 )
{
LABEL_68:
if ( COERCE_DOUBLE(*(_QWORD *)(a1 + 400) ^ LC1) > get_rh(a1, (unsigned int)v33) - ptr[v33] )
{
report(a1, 4LL, "presolve found lower bound infeasibility in row %d", (unsigned int)v33);
free(ptr);
free(v12);
free(v11);
free(v10);
return 2LL;
}
}
v34 = v10[v33];
if ( v34
&& (abs32(v11[v33]) != v34
|| *(double *)(a1 + 432) <= COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v12[v33] - ptr[v33]) & LC2)) )
{
if ( v34 == 1 )
{
if ( *(int *)(a1 + 28) > 0 )
{
do
{
if ( get_mat_raw(a1, (unsigned int)v33, v34) != 0.0 )
break;
++v34;
}
while ( *(_DWORD *)(a1 + 28) >= (signed int)v34 );
}
v52 = func0(a1, v33, v34, 1, (__int64)ptr, (__int64)v12, (int *)v55);
if ( v52 == 2 )
{
v40 = a1;
goto LABEL_89;
}
del_constraint(a1, (unsigned int)v33);
v38 = *(_DWORD *)(a1 + 20);
if ( v38 >= (int)v33 )
{
v39 = v33;
do
{
v10[v39] = v10[v39 + 1];
v11[v39] = v11[v39 + 1];
ptr[v39] = ptr[v39 + 1];
v12[v39] = v12[v39 + 1];
++v39;
}
while ( v38 >= (int)v39 );
}
++v53;
++v49;
}
}
else
{
del_constraint(a1, (unsigned int)v33);
v36 = *(_DWORD *)(a1 + 20);
if ( v36 >= (int)v33 )
{
v37 = v33;
do
{
v10[v37] = v10[v37 + 1];
v11[v37] = v11[v37 + 1];
ptr[v37] = ptr[v37 + 1];
v12[v37] = v12[v37 + 1];
++v37;
}
while ( v36 >= (int)v37 );
}
++v51;
++v49;
}
if ( (int)--v33 <= 0 )
goto LABEL_84;
}
}
v40 = a1;
LABEL_89:
if ( *(double *)(v40 + 432) > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*v12 - *ptr) & LC2) )
report(v40, 4LL, "presolve identified optimal solution");
if ( v51 )
report(v40, 4LL, "presolve removed %d empty or redundant rows", v51);
if ( v53 )
report(v40, 4LL, "presolve converted %d singleton rows to bounds", v53);
if ( v55[0] )
report(v40, 4LL, "presolve tightened %d bounds", v55[0]);
if ( v54 )
report(v40, 4LL, "presolve removed %d empty columns", v54);
free(v10);
free(v11);
free(ptr);
free(v12);
return (unsigned int)v52;
}
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8 * v9, 210LL, "presolve.c");
free(v12);
}
free(v11);
}
else
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v9, 208LL, "presolve.c");
}
}
if ( v10 )
free(v10);
*(_WORD *)(a1 + 496) = 12;
return 2LL;
}

original_code:
int presolve(lprec *lp)
{
  int i, j, ix, nn, nc, nv, nb, ns, nt;
  int *counts = ((void *)0), *signs = ((void *)0);
  double *uppers = ((void *)0), *lowers = ((void *)0), value, bound;
  short status, rowtype;
  status = 5;
  if(lp->do_presolve == status)
    return(status);
  if(lp->do_presolve) {
    if(lp->trace || lp->debug)
      report(lp, 6, "Entered presolve at iteration %d",lp->total_iter);
    lp->orig_rows = lp->rows;
    nv = 0;
    nc = 0;
    nb = 0;
    ns = 0;
    nt = 0;
    for(i = 1; i <= lp->sos_count; i++) {
      nn = SOS_infeasible(lp, i);
      if(nn > 0) {
        report(lp, 4, "presolve found SOS %d (type %d) to be range-infeasible on variable %d",
                  i, SOS_get_type(lp, i), nn);
 status = 2;
 ns++;
      }
    }
    if(ns <= 0) {
      ix = ((lp->rows) > (lp->columns) ? (lp->rows) : (lp->columns));
      if ((((((lp->rows + 1) == 0) || ((counts = calloc((size_t)(lp->rows + 1), sizeof(*counts))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*counts), 207, "presolve.c"), (counts = (void *) 0) : counts ) == ((void *)0)) ||
          (((((lp->rows + 1) == 0) || ((signs = calloc((size_t)(lp->rows + 1), sizeof(*signs))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*signs), 208, "presolve.c"), (signs = (void *) 0) : signs ) == ((void *)0)) ||
          (((((ix + 1) == 0) || ((uppers = calloc((size_t)(ix + 1), sizeof(*uppers))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (ix + 1) * sizeof(*uppers), 209, "presolve.c"), (uppers = (void *) 0) : uppers ) == ((void *)0)) ||
          (((((lp->rows + 1) == 0) || ((lowers = calloc((size_t)(lp->rows + 1), sizeof(*lowers))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*lowers), 210, "presolve.c"), (lowers = (void *) 0) : lowers ) == ((void *)0))) {
        if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
        if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
        if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
        if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
        lp->spx_status = 12;
        return(2);
      }
      else {
        for(j = 1; j <= lp->columns; j++) {
       for(ix = lp->col_end[j - 1]; ix < lp->col_end[j]; ix++) {
         i = lp->mat[ix].row_nr;
         value = lp->mat[ix].value;
            if(lp->ch_sign[i])
              value = -value;
            if(lp->scaling_used)
              value /= lp->scale[i] * lp->scale[lp->rows + j];
            counts[i]++;
         if(lp->mat[ix].value < 0)
           signs[i]--;
         else
           signs[i]++;
         bound = get_upbo(lp, j);
         if(uppers[i] < lp->infinite) {
           if(bound >= lp->infinite)
                uppers[i] = lp->infinite;
           else
      uppers[i] += value*bound;
         }
         bound = get_lowbo(lp, j);
         if(lowers[i] > -lp->infinite) {
           if(bound <= -lp->infinite)
                lowers[i] = -lp->infinite;
           else if(!is_semicont(lp, j))
      lowers[i] += value*bound;
         }
       }
     }
        do {
     nn = 0;
     for(j = lp->columns; j > 0; j--) {
       if(lp->col_end[j] == lp->col_end[j - 1]) {
       if(lp->sos_count > 0 && SOS_is_member(lp, 0, j))
                report(lp, 4, "presolve found empty variable %d as member of a SOS", j);
       else {
                del_column(lp, j);
      nv++;
    nn++;
              }
       }
          }
     for(i = lp->rows; i > 0; i--) {
       rowtype = (short) get_constr_type(lp, i);
       if(rowtype != 0)
         if(uppers[i]-get_rh(lp, i) > lp->infinite) {
                report(lp, 4, "presolve found upper bound infeasibility in row %d", i);
                if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
                if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
                if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
                if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
                return(2);
         }
         if(rowtype != 2)
         if(get_rh(lp, i)-lowers[i] < -lp->infinite) {
                report(lp, 4, "presolve found lower bound infeasibility in row %d", i);
                if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
                if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
                if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
                if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
                return(2);
           }
       j = counts[i];
       if(j == 0 || ((abs(signs[i]) == counts[i]) && (fabs(uppers[i]-lowers[i]) < lp->epsel))) {
         del_constraint(lp, i);
       for(ix = i; ix <= lp->rows; ix++) {
                counts[ix] = counts[ix + 1];
  signs[ix] = signs[ix + 1];
  lowers[ix] = lowers[ix + 1];
  uppers[ix] = uppers[ix + 1];
              }
              nc++;
           nn++;
       }
            else if(j == 1) {
        for(j = 1; j <= lp->columns; j++)
   if(get_mat_raw(lp, i, j) != 0)
     break;
        status = tighten_bounds(lp, i, j, counts[i], lowers, uppers, &nt);
        if(status == 2) {
                nn = 0;
  break;
       }
       del_constraint(lp,i);
       for(ix = i; ix <= lp->rows; ix++) {
                counts[ix] = counts[ix + 1];
  signs[ix] = signs[ix + 1];
  lowers[ix] = lowers[ix + 1];
  uppers[ix] = uppers[ix + 1];
              }
              nb++;
           nn++;
       }
          }
        } while (nn > 0);
        if(fabs(uppers[0]-lowers[0]) < lp->epsel)
          report(lp, 4, "presolve identified optimal solution");
        if(nc)
          report(lp, 4, "presolve removed %d empty or redundant rows",nc);
        if(nb)
          report(lp, 4, "presolve converted %d singleton rows to bounds",nb);
        if(nt)
          report(lp, 4, "presolve tightened %d bounds",nt);
        if(nv)
          report(lp, 4, "presolve removed %d empty columns",nv);
        free(counts);
        free(signs);
        free(lowers);
        free(uppers);
      }
    }
  }
  return(status);
}

canonical_original_code:
int presolve(struct _lprec *lp)
{
  int i; int j; int ix; int nn; int nc; int nv; int nb; int ns; int nt;
  int *counts = ((void *)0); int *signs = ((void *)0);
  double *uppers = ((void *)0); double *lowers = ((void *)0); double value; double bound;
  short status; short rowtype;
  status = 5;
  if(lp->do_presolve == status)
    return(status);
  if(lp->do_presolve) {
    if(lp->trace || lp->debug)
      report(lp, 6, "Entered presolve at iteration %d",lp->total_iter);
    lp->orig_rows = lp->rows;
    nv = 0;
    nc = 0;
    nb = 0;
    ns = 0;
    nt = 0;
    for(i = 1; i <= lp->sos_count; i++) {
      nn = SOS_infeasible(lp, i);
      if(nn > 0) {
        report(lp, 4, "presolve found SOS %d (type %d) to be range-infeasible on variable %d",
                  i, SOS_get_type(lp, i), nn);
 status = 2;
 ns++;
      }
    }
    if(ns <= 0) {
      ix = ((lp->rows) > (lp->columns) ? (lp->rows) : (lp->columns));
      if ((((((lp->rows + 1) == 0) || ((counts = calloc((unsigned long)(lp->rows + 1), sizeof(*counts))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*counts), 207, "presolve.c"), (counts = (void *) 0) : counts ) == ((void *)0)) ||
          (((((lp->rows + 1) == 0) || ((signs = calloc((unsigned long)(lp->rows + 1), sizeof(*signs))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*signs), 208, "presolve.c"), (signs = (void *) 0) : signs ) == ((void *)0)) ||
          (((((ix + 1) == 0) || ((uppers = calloc((unsigned long)(ix + 1), sizeof(*uppers))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (ix + 1) * sizeof(*uppers), 209, "presolve.c"), (uppers = (void *) 0) : uppers ) == ((void *)0)) ||
          (((((lp->rows + 1) == 0) || ((lowers = calloc((unsigned long)(lp->rows + 1), sizeof(*lowers))) == ((void *)0))) ? (void *) report(((void *)0), 1, "calloc of %d bytes failed on line %d of file %s", (lp->rows + 1) * sizeof(*lowers), 210, "presolve.c"), (lowers = (void *) 0) : lowers ) == ((void *)0))) {
        if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
        if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
        if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
        if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
        lp->spx_status = 12;
        return(2);
      }
      else {
        for(j = 1; j <= lp->columns; j++) {
       for(ix = lp->col_end[j - 1]; ix < lp->col_end[j]; ix++) {
         i = lp->mat[ix].row_nr;
         value = lp->mat[ix].value;
            if(lp->ch_sign[i])
              value = -value;
            if(lp->scaling_used)
              value /= lp->scale[i] * lp->scale[lp->rows + j];
            counts[i]++;
         if(lp->mat[ix].value < 0)
           signs[i]--;
         else
           signs[i]++;
         bound = get_upbo(lp, j);
         if(uppers[i] < lp->infinite) {
           if(bound >= lp->infinite)
                uppers[i] = lp->infinite;
           else
      uppers[i] += value*bound;
         }
         bound = get_lowbo(lp, j);
         if(lowers[i] > -lp->infinite) {
           if(bound <= -lp->infinite)
                lowers[i] = -lp->infinite;
           else if(!is_semicont(lp, j))
      lowers[i] += value*bound;
         }
       }
     }
        do {
     nn = 0;
     for(j = lp->columns; j > 0; j--) {
       if(lp->col_end[j] == lp->col_end[j - 1]) {
       if(lp->sos_count > 0 && SOS_is_member(lp, 0, j))
                report(lp, 4, "presolve found empty variable %d as member of a SOS", j);
       else {
                del_column(lp, j);
      nv++;
    nn++;
              }
       }
          }
     for(i = lp->rows; i > 0; i--) {
       rowtype = (short) get_constr_type(lp, i);
       if(rowtype != 0)
         if(uppers[i]-get_rh(lp, i) > lp->infinite) {
                report(lp, 4, "presolve found upper bound infeasibility in row %d", i);
                if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
                if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
                if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
                if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
                return(2);
         }
         if(rowtype != 2)
         if(get_rh(lp, i)-lowers[i] < -lp->infinite) {
                report(lp, 4, "presolve found lower bound infeasibility in row %d", i);
                if (lowers != ((void *)0)) {free(lowers), lowers = ((void *)0);} else;
                if (uppers != ((void *)0)) {free(uppers), uppers = ((void *)0);} else;
                if (signs != ((void *)0)) {free(signs), signs = ((void *)0);} else;
                if (counts != ((void *)0)) {free(counts), counts = ((void *)0);} else;
                return(2);
           }
       j = counts[i];
       if(j == 0 || ((abs(signs[i]) == counts[i]) && (fabs(uppers[i]-lowers[i]) < lp->epsel))) {
         del_constraint(lp, i);
       for(ix = i; ix <= lp->rows; ix++) {
                counts[ix] = counts[ix + 1];
  signs[ix] = signs[ix + 1];
  lowers[ix] = lowers[ix + 1];
  uppers[ix] = uppers[ix + 1];
              }
              nc++;
           nn++;
       }
            else if(j == 1) {
        for(j = 1; j <= lp->columns; j++)
   if(get_mat_raw(lp, i, j) != 0)
     break;
        status = tighten_bounds(lp, i, j, counts[i], lowers, uppers, &nt);
        if(status == 2) {
                nn = 0;
  break;
       }
       del_constraint(lp,i);
       for(ix = i; ix <= lp->rows; ix++) {
                counts[ix] = counts[ix + 1];
  signs[ix] = signs[ix + 1];
  lowers[ix] = lowers[ix + 1];
  uppers[ix] = uppers[ix + 1];
              }
              nb++;
           nn++;
       }
          }
        } while (nn > 0);
        if(fabs(uppers[0]-lowers[0]) < lp->epsel)
          report(lp, 4, "presolve identified optimal solution");
        if(nc)
          report(lp, 4, "presolve removed %d empty or redundant rows",nc);
        if(nb)
          report(lp, 4, "presolve converted %d singleton rows to bounds",nb);
        if(nt)
          report(lp, 4, "presolve tightened %d bounds",nt);
        if(nv)
          report(lp, 4, "presolve removed %d empty columns",nv);
        free(counts);
        free(signs);
        free(lowers);
        free(uppers);
      }
    }
  }
  return(status);
}

variable_types: ix int

variable_types: nn int

variable_types: nc int

variable_types: nv int

variable_types: nb int

variable_types: ns int

variable_types: nt int

variable_types:
counts
int *

variable_types:
signs
int *

variable_types:
uppers
double *

variable_types:
lowers
double *

variable_types: value double

variable_types: bound double

variable_types: status short

variable_types: rowtype short


hashval

original_code:
static int hashval(const char *string, int size)
{
  unsigned int result = 0, tmp;
  for(; *string; string++) {
    result = (result << sizeof(unsigned int)) + *string;
    if((tmp = result & (((unsigned int)0xF0) << ((sizeof(unsigned int) - 1) * 8))) != 0) {
      result ^= tmp >> (sizeof(unsigned int) * 6);
      result ^= tmp;
    }
  }
  return(result % size);
}

canonical_original_code:
static int hashval(char *string, int size)
{
  unsigned int result = 0; unsigned int tmp;
  for(; *string; string++) {
    result = (result << sizeof(unsigned int)) + *string;
    if((tmp = result & (((unsigned int)0xF0) << ((sizeof(unsigned int) - 1) * 8))) != 0) {
      result ^= tmp >> (sizeof(unsigned int) * 6);
      result ^= tmp;
    }
  }
  return(result % size);
}

variable_types:
string
char *

variable_types: size int

variable_types:
result
unsigned int

variable_types:
tmp
unsigned int


decompiled_code:
void __fastcall free_hash_table(void *ptr)
{
__int64 v1; // r12
__int64 v2; // rbx
void **v3; // rbp

if ( *((int *)ptr + 2) > 0 )
{
v1 = 0LL;
do
{
v2 = *(_QWORD *)(*(_QWORD *)ptr + 8 * v1);
while ( v2 )
{
v3 = (void **)v2;
v2 = *(_QWORD *)(v2 + 8);
free(*v3);
free(v3);
}
++v1;
}
while ( *((_DWORD *)ptr + 2) > (int)v1 );
}
free(*(void **)ptr);
free(ptr);
}

original_code:
void free_hash_table(hashstruct *ht)
{
  int i;
  hashelem *hp, *thp;
  for(i = 0; i < ht->size; i++) {
    hp = ht->table[i];
    while(hp != ((void *)0)) {
      thp = hp;
      hp = hp->next;
      free(thp->name);
      free(thp);
    }
  }
  free(ht->table);
  free(ht);
}

canonical_original_code:
void free_hash_table(struct _hashstruct *ht)
{
  int i;
  struct _hashelem *hp; struct _hashelem *thp;
  for(i = 0; i < ht->size; i++) {
    hp = ht->table[i];
    while(hp != ((void *)0)) {
      thp = hp;
      hp = hp->next;
      free(thp->name);
      free(thp);
    }
  }
  free(ht->table);
  free(ht);
}

variable_types: struct _hashstruct { struct _hashelem { char *name; struct _hashelem *next; struct _column { int row; double value; struct _column *next; } *col; struct _bound { double upbo; double lowbo; } *bnd; int must_be_int; int index; } **table; int size; } *

variable_types: i int


findhash

decompiled_code:
__int64 __fastcall findhash(char *s1, __int64 a2)
{
__int64 i; // rbx

for ( i = *(_QWORD *)(*(_QWORD *)a2 + 8LL * (int)hashval(s1, *(_DWORD *)(a2 + 8))); i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(s1, *(const char **)i) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1, __int64 a2)
{
__int64 i; // rbx

for ( i = *(_QWORD *)(*(_QWORD *)a2 + 8LL * (int)func0(s1, *(_DWORD *)(a2 + 8))); i; i = *(_QWORD *)(i + 8) )
{
if ( !strcmp(s1, *(const char **)i) )
break;
}
return i;
}

original_code:
hashelem *findhash(const char *name, hashstruct *ht)
{
  hashelem *h_tab_p;
  for(h_tab_p = ht->table[hashval(name, ht->size)];
      h_tab_p != ((void *)0);
      h_tab_p = h_tab_p->next)
    if(strcmp(name, h_tab_p->name) == 0)
      break;
  return(h_tab_p);
}

canonical_original_code:
struct _hashelem *findhash(char *name, struct _hashstruct *ht)
{
  struct _hashelem *h_tab_p;
  for(h_tab_p = ht->table[hashval(name, ht->size)];
      h_tab_p != ((void *)0);
      h_tab_p = h_tab_p->next)
    if(strcmp(name, h_tab_p->name) == 0)
      break;
  return(h_tab_p);
}

variable_types:
name
char *

variable_types: struct _hashstruct { struct _hashelem **table; int size; } *

variable_types: struct _hashelem { char *name; struct _hashelem *next; struct _column { int row; double value; struct _column *next; } *col; struct _bound { double upbo; double lowbo; } *bnd; int must_be_int; int index; } *


decompiled_code:
int press_ret()
{
printf("[return]");
return getchar();
}

canonical_decompiled_code:
int func0()
{
printf("[return]");
return getchar();
}

original_code:
void press_ret(void)
{
  printf("[return]");
  getchar();
}

canonical_original_code:
void press_ret()
{
  printf("[return]");
  getchar();
}


maximumValue

repo: l-urence/smith-waterman

original_code:
position maximumValue(int *matrix, int dim) {
  int maxValue = 0;
  position max;
  int i, j;
  for (i=0; i<dim; i++) {
    for (j=0; j<dim; j++) {
      if (matrix[j+i*dim] > maxValue) {
        maxValue = matrix[j+i*dim];
        max.i = i;
        max.j = j;
      }
    }
  }
  return max;
}

canonical_original_code:
struct position maximumValue(int *matrix, int dim) {
  int maxValue = 0;
  struct position max;
  int i; int j;
  for (i=0; i<dim; i++) {
    for (j=0; j<dim; j++) {
      if (matrix[j+i*dim] > maxValue) {
        maxValue = matrix[j+i*dim];
        max.i = i;
        max.j = j;
      }
    }
  }
  return max;
}

variable_types:
matrix
int *

variable_types: dim int

variable_types: maxValue int

variable_types:
max
struct position { int i; int j; }

variable_types: j int

return_type: struct position { int i; int j; }


printMatrix

decompiled_code:
int __fastcall printMatrix(__int64 a1, int a2)
{
__int64 v2; // rbp
int i; // er12
unsigned int *v4; // rbx

if ( a2 > 0 )
{
v2 = a1 + 4LL * (unsigned int)(a2 - 1) + 4;
for ( i = 0; i != a2; ++i )
{
v4 = (unsigned int *)(-4LL * (unsigned int)a2 + v2);
do
printf("%i ", *v4++);
while ( v4 != (unsigned int *)v2 );
putchar(10);
v2 += 4LL * a2;
}
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, int a2)
{
__int64 v2; // rbp
int i; // er12
unsigned int *v4; // rbx

if ( a2 > 0 )
{
v2 = a1 + 4LL * (unsigned int)(a2 - 1) + 4;
for ( i = 0; i != a2; ++i )
{
v4 = (unsigned int *)(-4LL * (unsigned int)a2 + v2);
do
printf("%i ", *v4++);
while ( v4 != (unsigned int *)v2 );
putchar(10);
v2 += 4LL * a2;
}
}
return putchar(10);
}

original_code:
void printMatrix(int *matrix, int dim) {
  int i, j;
  for (i=0; i<dim; i++) {
    for (j=0; j<dim; j++) {
      printf("%i ", matrix[j+i*dim]);
    }
    printf("\n");
  }
  printf("\n");
}

canonical_original_code:
void printMatrix(int *matrix, int dim) {
  int i; int j;
  for (i=0; i<dim; i++) {
    for (j=0; j<dim; j++) {
      printf("%i ", matrix[j+i*dim]);
    }
    printf("\n");
  }
  printf("\n");
}


match

decompiled_code:
__int64 __fastcall match(char a1, char a2)
{
return 3 * (unsigned int)(a1 == a2) - 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, char a2)
{
return 3 * (unsigned int)(a1 == a2) - 1;
}

original_code:
int match(char ai, char bj) {
  if (ai == bj) {
    return 2;
  } else {
    return -1;
  }
}

variable_types: ai char

variable_types: bj char


findMaximum

decompiled_code:
__int64 __fastcall findMaximum(__int64 a1, __int64 a2, int a3, int a4, char a5, char a6, int a7)
{
int v8; // er13
int v9; // ebx
__int64 result; // rax
int v11; // edx
int v12; // ebx
int v13; // edx

v8 = a4 - 1;
v9 = a7 * (a3 - 1);
result = *(_DWORD *)(a1 + 4LL * (a4 - 1 + v9)) + (unsigned int)match(a5, a6);
if ( (int)result <= 0 )
result = 0LL;
else
*(_DWORD *)(a2 + 4LL * (a4 + v9 + a7)) = 2;
v11 = *(_DWORD *)(a1 + 4LL * (v9 + a4)) - 1;
if ( (int)result < v11 )
{
*(_DWORD *)(a2 + 4LL * (a4 + v9 + a7)) = 1;
result = (unsigned int)v11;
}
v12 = a7 + v9;
v13 = *(_DWORD *)(a1 + 4LL * (v12 + v8)) - 1;
if ( (int)result < v13 )
{
*(_DWORD *)(a2 + 4LL * (v12 + a4)) = 3;
result = (unsigned int)v13;
}
if ( !(_DWORD)result )
*(_DWORD *)(a2 + 4LL * (v12 + a4)) = 0;
*(_DWORD *)(a1 + 4LL * (a4 + v12)) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, int a3, int a4, char a5, char a6, int a7)
{
int v8; // er13
int v9; // ebx
__int64 result; // rax
int v11; // edx
int v12; // ebx
int v13; // edx

v8 = a4 - 1;
v9 = a7 * (a3 - 1);
result = *(_DWORD *)(a1 + 4LL * (a4 - 1 + v9)) + (unsigned int)func0(a5, a6);
if ( (int)result <= 0 )
result = 0LL;
else
*(_DWORD *)(a2 + 4LL * (a4 + v9 + a7)) = 2;
v11 = *(_DWORD *)(a1 + 4LL * (v9 + a4)) - 1;
if ( (int)result < v11 )
{
*(_DWORD *)(a2 + 4LL * (a4 + v9 + a7)) = 1;
result = (unsigned int)v11;
}
v12 = a7 + v9;
v13 = *(_DWORD *)(a1 + 4LL * (v12 + v8)) - 1;
if ( (int)result < v13 )
{
*(_DWORD *)(a2 + 4LL * (v12 + a4)) = 3;
result = (unsigned int)v13;
}
if ( !(_DWORD)result )
*(_DWORD *)(a2 + 4LL * (v12 + a4)) = 0;
*(_DWORD *)(a1 + 4LL * (a4 + v12)) = result;
return result;
}

original_code:
void findMaximum(int *matrix, int *memory, int i, int j, char a, char b, int dim) {
  int max = 0;
  int mm = matrix[(j-1)+(i-1)*dim] + match(a, b);
  if (mm > max) {
    max = mm;
    memory[j+i*dim] = NORTH_WEST;
  }
  int md = matrix[j+(i-1)*dim] + -1;
  if (md > max) {
    max = md;
    memory[j+i*dim] = NORTH;
  }
  int mi = matrix[(j-1)+i*dim] + -1;
  if (mi > max) {
    max = mi;
    memory[j+i*dim] = WEST;
  }
  if (max == 0) {
    memory[j+i*dim] = CENTER;
  }
  matrix[j+i*dim] = max;
}

variable_types:
memory
int *

variable_types: a char

variable_types: b char

variable_types: max int

variable_types: mm int

variable_types: md int

variable_types: mi int


validateSubMatrix

original_code:
void validateSubMatrix(int *matrix, int *memory, int i, int j, const char *s1,
    const char *s2, int sub, int dim) {
  int ii, jj;
  for (ii = i; ii < sub + i; ++ii) {
    for (jj = j; jj < sub + j; ++jj)
      findMaximum(matrix, memory, ii+1, jj+1, s1[jj], s2[ii], dim);
  }
}

canonical_original_code:
void validateSubMatrix(int *matrix, int *memory, int i, int j, char *s1, char *s2, int sub, int dim) {
  int ii; int jj;
  for (ii = i; ii < sub + i; ++ii) {
    for (jj = j; jj < sub + j; ++jj)
      findMaximum(matrix, memory, ii+1, jj+1, s1[jj], s2[ii], dim);
  }
}

variable_types: i int

variable_types: sub int

variable_types: ii int

variable_types: jj int


printAlignments

original_code:
void printAlignments(swResult *result)
{
  int i;
  for (i=result->length-1; i>=0; i--)
    printf("%c", result->resultB[i]);
    printf("\n");
  for (i=result->length-1; i >= 0; i--) {
    if (result->resultA[i] == result->resultB[i])
      printf("%s", ":");
    else
      printf("%s"," ");
  }
  printf("\n");
  for (i=result->length-1; i>=0; i--)
    printf("%c", result->resultA[i]);
  printf("\n\n");
}

canonical_original_code:
void printAlignments(struct swResult *result)
{
  int i;
  for (i=result->length-1; i>=0; i--)
    printf("%c", result->resultB[i]);
    printf("\n");
  for (i=result->length-1; i >= 0; i--) {
    if (result->resultA[i] == result->resultB[i])
      printf("%s", ":");
    else
      printf("%s"," ");
  }
  printf("\n");
  for (i=result->length-1; i>=0; i--)
    printf("%c", result->resultA[i]);
  printf("\n\n");
}

variable_types: struct swResult { char *resultA; char *resultB; int length; } *


getNextPosition

decompiled_code:
unsigned __int64 __fastcall getNextPosition(unsigned int a1, __int64 a2, int a3, __int64 a4)
{
int v4; // edx
unsigned __int64 result; // rax

v4 = *(_DWORD *)(a4 + 4LL * (int)(a2 + a1 * a3));
switch ( v4 )
{
case 2:
return (a1 - 1) | ((unsigned __int64)(unsigned int)(a2 - 1) << 32);
case 1:
return (a2 << 32) | (a1 - 1);
case 3:
return a1 | ((unsigned __int64)(unsigned int)(a2 - 1) << 32);
}
result = -1LL;
if ( !v4 )
result = (a2 << 32) | a1;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(unsigned int a1, __int64 a2, int a3, __int64 a4)
{
int v4; // edx
unsigned __int64 result; // rax

v4 = *(_DWORD *)(a4 + 4LL * (int)(a2 + a1 * a3));
switch ( v4 )
{
case 2:
return (a1 - 1) | ((unsigned __int64)(unsigned int)(a2 - 1) << 32);
case 1:
return (a2 << 32) | (a1 - 1);
case 3:
return a1 | ((unsigned __int64)(unsigned int)(a2 - 1) << 32);
}
result = -1LL;
if ( !v4 )
result = (a2 << 32) | a1;
return result;
}

original_code:
position getNextPosition(int i, int j, int dim, int *memory) {
  const int direction = memory[j+i*dim];
  if (direction == NORTH_WEST) {
    return (position) {i-1, j-1};
  }
  if (direction == NORTH) {
    return (position) {i-1, j};
  }
  if (direction == WEST) {
    return (position) {i, j-1};
  }
  if (direction == CENTER) {
    return (position) {i, j};
  }
  return (position) {-1, -1};
}

canonical_original_code:
struct position getNextPosition(int i, int j, int dim, int *memory) {
  int direction = memory[j+i*dim];
  if (direction == NORTH_WEST) {
    return (struct position) {i-1, j-1};
  }
  if (direction == NORTH) {
    return (struct position) {i-1, j};
  }
  if (direction == WEST) {
    return (struct position) {i, j-1};
  }
  if (direction == CENTER) {
    return (struct position) {i, j};
  }
  return (struct position) {-1, -1};
}

variable_types: dim int

variable_types: direction int


sw

original_code:
void sw(const char *s1, const char *s2, const int sub, int verbose) {
  const int m = ((int) strlen(s2));
  const int n = ((int) strlen(s1));
  int dim = m + 1;
  int *matrix = initMatrix(dim);
  int *memory = initMatrix(dim);
  if (m % sub != 0 && n % sub != 0) return;
  int max = n / sub;
  int slice, j;
  for (slice = 0; slice < 2 * max - 1; ++slice) {
    int z = slice < max ? 0 : slice - max + 1;
    for (j = z; j <= slice - z; ++j) {
      validateSubMatrix(matrix, memory, j*sub, (slice - j)*sub, s1, s2, sub, dim);
    }
  }
  swResult *result = traceback(s1, s2, memory, matrix);
  if (verbose > 0)
    printAlignments(result);
  free(result->resultA);
  free(result->resultB);
  free(result);
  free(memory);
  free(matrix);
}

canonical_original_code:
void sw(char *s1, char *s2, int sub, int verbose) {
  int m = ((int) strlen(s2));
  int n = ((int) strlen(s1));
  int dim = m + 1;
  int *matrix = initMatrix(dim);
  int *memory = initMatrix(dim);
  if (m % sub != 0 && n % sub != 0) return;
  int max = n / sub;
  int slice; int j;
  for (slice = 0; slice < 2 * max - 1; ++slice) {
    int z = slice < max ? 0 : slice - max + 1;
    for (j = z; j <= slice - z; ++j) {
      validateSubMatrix(matrix, memory, j*sub, (slice - j)*sub, s1, s2, sub, dim);
    }
  }
  struct swResult *result = traceback(s1, s2, memory, matrix);
  if (verbose > 0)
    printAlignments(result);
  free(result->resultA);
  free(result->resultB);
  free(result);
  free(memory);
  free(matrix);
}

variable_types: verbose int

variable_types: m int

variable_types: n int

variable_types:
matrix
int *

variable_types: slice int

variable_types: j int

variable_types: z int

user_defined_types: struct swResult { char *resultA; char *resultB; int length; }


printHelp

decompiled_code:
int printHelp()
{
puts("usage: sw -f file [-d device] [-s size]");
puts(" --verbose print out the alignments");
puts(" -l --length \t Set the random string length.");
puts(" -d --device \t Set the openCL device [gpu/cpu]. Default: cpu.");
puts(" -r --runs \t The the number of iterations");
return puts(" -s --sub \t Sets the dimension of the submatrix");
}

canonical_decompiled_code:
int func0()
{
puts("usage: sw -f file [-d device] [-s size]");
puts(" --verbose print out the alignments");
puts(" -l --length \t Set the random string length.");
puts(" -d --device \t Set the openCL device [gpu/cpu]. Default: cpu.");
puts(" -r --runs \t The the number of iterations");
return puts(" -s --sub \t Sets the dimension of the submatrix");
}

original_code:
void printHelp()
{
  printf("usage: sw -f file [-d device] [-s size]\n");
  printf("     --verbose print out the alignments\n");
  printf("  -l --length \t Set the random string length.\n");
  printf("  -d --device \t Set the openCL device [gpu/cpu]. Default: cpu.\n");
  printf("  -r --runs   \t The the number of iterations\n");
  printf("  -s --sub    \t Sets the dimension of the submatrix\n");
}


printError

decompiled_code:
void __fastcall __noreturn printError(const char *a1)
{
puts(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(const char *a1)
{
puts(a1);
exit(1);
}

original_code:
void printError(char *message)
{
  printf("%s\n", message);
  exit(1);
}

variable_types:
message
char *


getDiagonalLength

decompiled_code:
__int64 __fastcall getDiagonalLength(int a1, int a2)
{
int v2; // edi
__int64 result; // rax

v2 = a1 - a2;
result = (unsigned int)(v2 - a2 + 1);
if ( a2 <= 0 )
result = (unsigned int)(v2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
int v2; // edi
__int64 result; // rax

v2 = a1 - a2;
result = (unsigned int)(v2 - a2 + 1);
if ( a2 <= 0 )
result = (unsigned int)(v2 + 1);
return result;
}

original_code:
int getDiagonalLength(int slice, int z, int sub) {
  int i = z;
  int j = slice - z;
  if (z <= 0)
    return j + 1;
  return j - i + 1;
}


removeNewLine

decompiled_code:
char *__fastcall removeNewLine(char *s)
{
char *v1; // rax
char *result; // rax

v1 = strchr(s, 10);
if ( v1 )
*v1 = 0;
result = strchr(s, 13);
if ( result )
*result = 0;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *s)
{
char *v1; // rax
char *result; // rax

v1 = strchr(s, 10);
if ( v1 )
*v1 = 0;
result = strchr(s, 13);
if ( result )
*result = 0;
return result;
}

original_code:
void removeNewLine(char *string)
{
  char *c = strchr(string, '\n');
  if (c)
    *c = '\0';
  c = strchr(string, '\r');
  if (c)
    *c = '\0';
}

variable_types:
string
char *

variable_types:
c
char *


search

decompiled_code:
__int64 __fastcall search(__int64 a1, unsigned int a2, unsigned int a3, int a4)
{
unsigned int v4; // ebx
int v6; // ecx

v4 = a3;
printf("Index %d\n", a3);
v6 = (a4 + 1) / 2;
if ( v4 && *(_DWORD *)(a1 + 4LL * (int)v4 - 4) > *(_DWORD *)(a1 + 4LL * (int)v4) )
return (unsigned int)search(a1, a2, v4 - v6);
if ( a2 - 1 != v4 && *(_DWORD *)(a1 + 4LL * (int)v4 + 4) > *(_DWORD *)(a1 + 4LL * (int)v4) )
v4 = search(a1, a2, v4 + v6);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, unsigned int a3, int a4)
{
unsigned int v4; // ebx
int v6; // ecx

v4 = a3;
printf("Index %d\n", a3);
v6 = (a4 + 1) / 2;
if ( v4 && *(_DWORD *)(a1 + 4LL * (int)v4 - 4) > *(_DWORD *)(a1 + 4LL * (int)v4) )
return (unsigned int)func7(a1, a2, v4 - v6);
if ( a2 - 1 != v4 && *(_DWORD *)(a1 + 4LL * (int)v4 + 4) > *(_DWORD *)(a1 + 4LL * (int)v4) )
v4 = func7(a1, a2, v4 + v6);
return v4;
}

original_code:
int search(int values[], int count, int index, int step) {
 printf ("Index %d\n", index);
 int next_step = (step + 1) / 2;
 if (index != 0 && values[index - 1] > values[index]) {
  return search(values, count, index - next_step, next_step);
 } else if (index != count -1 && values[index + 1] > values[index]) {
  return search(values, count, index + next_step, next_step);
 } else {
  return index;
 }
}

variable_types:
values
int []

variable_types: count int

variable_types: index int

variable_types: step int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 i; // rbx
__int64 v5; // rdx
unsigned int v6; // eax
int v8[6]; // [rsp+0h] [rbp-18h] BYREF

v3 = time(0LL);
printf("Seed: %u\n", v3);
srand(v3);
puts("Input:");
for ( i = 0LL; i != 4; ++i )
{
v5 = (unsigned int)(rand() % 4);
v8[i] = v5;
printf("%8d: %d\n", (unsigned int)i, v5);
}
v6 = search((__int64)v8, 4u, 2u, 2);
if ( v6 == -1 )
puts("No peak found");
else
printf("Peak found at index %d: %d\n", v6, (unsigned int)v8[v6]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebx
__int64 i; // rbx
__int64 v5; // rdx
unsigned int v6; // eax
int v8[6]; // [rsp+0h] [rbp-18h] BYREF

v3 = time(0LL);
printf("Seed: %u\n", v3);
srand(v3);
puts("Input:");
for ( i = 0LL; i != 4; ++i )
{
v5 = (unsigned int)(rand() % 4);
v8[i] = v5;
printf("%8d: %d\n", (unsigned int)i, v5);
}
v6 = func7((__int64)v8, 4u, 2u, 2);
if ( v6 == -1 )
puts("No peak found");
else
printf("Peak found at index %d: %d\n", v6, (unsigned int)v8[v6]);
return 0;
}

original_code:
int main (void) {
 int result;
 unsigned seed = (unsigned)time(((void *)0));
 int count = 4;
 int limit = 4;
 int values[count];
 int index;
 printf ("Seed: %u\n", seed);
 srand(seed);
 printf ("Input:\n");
 for (index = 0; index < count; index++) {
  values[index] = rand() % limit;
  printf ("%8d: %d\n", index, values[index]);
 }
 result = search(values, count, count / 2, count / 2);
 if (result != -1) {
  printf ("Peak found at index %d: %d\n", result, values[result]);
 } else {
  printf ("No peak found\n");
 }
 return 0;
}

canonical_original_code:
int main() {
 int result;
 unsigned int seed = (unsigned)time(((void *)0));
 int count = 4;
 int limit = 4;
 int values[-1];
 int index;
 printf ("Seed: %u\n", seed);
 srand(seed);
 printf ("Input:\n");
 for (index = 0; index < count; index++) {
  values[index] = rand() % limit;
  printf ("%8d: %d\n", index, values[index]);
 }
 result = search(values, count, count / 2, count / 2);
 if (result != -1) {
  printf ("Peak found at index %d: %d\n", result, values[result]);
 } else {
  printf ("No peak found\n");
 }
 return 0;
}

variable_types: result int

variable_types:
seed
unsigned int

variable_types: limit int

variable_types:
values
int [-1]


odd

decompiled_code:
_BOOL8 __fastcall odd(unsigned int a1)
{
return ((a1 + (a1 >> 31)) & 0xFFFFFFFE) != a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(unsigned int a1)
{
return ((a1 + (a1 >> 31)) & 0xFFFFFFFE) != a1;
}

original_code:
int odd(int number)
{
 if ((number / 2) * 2 == number) {
  return 0;
 } else {
  return 1;
 }
}

variable_types: number int


binary

decompiled_code:
int __fastcall binary(unsigned int a1)
{
char *v2; // rbx
char *v3; // rbp
int result; // eax
char v5; // [rsp+8h] [rbp-30h] BYREF
char v6[4]; // [rsp+Ch] [rbp-2Ch] BYREF
__int64 v7; // [rsp+10h] [rbp-28h] BYREF

v2 = v6;
v3 = v6;
do
{
v3[3] = odd(a1);
a1 >>= 1;
--v3;
}
while ( v3 != &v5 );
do
result = printf("%d", (unsigned int)*v2++);
while ( v2 != (char *)&v7 );
return result;
}

canonical_decompiled_code:
int __fastcall func8(unsigned int a1)
{
char *v2; // rbx
char *v3; // rbp
int result; // eax
char v5; // [rsp+8h] [rbp-30h] BYREF
char v6[4]; // [rsp+Ch] [rbp-2Ch] BYREF
__int64 v7; // [rsp+10h] [rbp-28h] BYREF

v2 = v6;
v3 = v6;
do
{
v3[3] = func7(a1);
a1 >>= 1;
--v3;
}
while ( v3 != &v5 );
do
result = printf("%d", (unsigned int)*v2++);
while ( v2 != (char *)&v7 );
return result;
}

original_code:
void binary(unsigned int number)
{
 int index;
 char result[4];
 for (index = sizeof(result) - 1; index >= 0; index--) {
  result[index] = (char)odd(number);
  number = number / 2;
 }
 for (index = 0; index < sizeof(result); index++) {
  printf("%d", result[index]);
 }
}

variable_types:
number
unsigned int

variable_types:
result
char [4]


base

decompiled_code:
int __fastcall base(unsigned int a1, unsigned int a2)
{
char *v2; // rbx
char *v3; // rcx
unsigned int v4; // er8
int result; // eax
char v6; // [rsp+8h] [rbp-20h] BYREF
char v7[4]; // [rsp+Ch] [rbp-1Ch] BYREF
__int64 v8; // [rsp+10h] [rbp-18h] BYREF

v2 = v7;
v3 = v7;
do
{
v4 = a1;
a1 /= a2;
v3[3] = v4 % a2;
--v3;
}
while ( v3 != &v6 );
do
result = printf("%d", (unsigned int)*v2++);
while ( v2 != (char *)&v8 );
return result;
}

canonical_decompiled_code:
int __fastcall func9(unsigned int a1, unsigned int a2)
{
char *v2; // rbx
char *v3; // rcx
unsigned int v4; // er8
int result; // eax
char v6; // [rsp+8h] [rbp-20h] BYREF
char v7[4]; // [rsp+Ch] [rbp-1Ch] BYREF
__int64 v8; // [rsp+10h] [rbp-18h] BYREF

v2 = v7;
v3 = v7;
do
{
v4 = a1;
a1 /= a2;
v3[3] = v4 % a2;
--v3;
}
while ( v3 != &v6 );
do
result = printf("%d", (unsigned int)*v2++);
while ( v2 != (char *)&v8 );
return result;
}

original_code:
void base(unsigned int number, unsigned int base)
{
 int index;
 unsigned int new, remainder;
 char result[4];
 for (index = sizeof(result) - 1; index >= 0; index--) {
  new = number / base;
  remainder = number - (new * base);
  result[index] = (char)remainder;
  number = new;
 }
 for (index = 0; index < sizeof(result); index++) {
  printf("%d", result[index]);
 }
}

canonical_original_code:
void base(unsigned int number, unsigned int base)
{
 int index;
 unsigned int new; unsigned int remainder;
 char result[4];
 for (index = sizeof(result) - 1; index >= 0; index--) {
  new = number / base;
  remainder = number - (new * base);
  result[index] = (char)remainder;
  number = new;
 }
 for (index = 0; index < sizeof(result); index++) {
  printf("%d", result[index]);
 }
}

variable_types:
base
unsigned int

variable_types:
new
unsigned int

variable_types:
remainder
unsigned int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx
unsigned int j; // ebx
unsigned int v5; // ebp
unsigned int k; // ebx

for ( i = 0; i != 10; ++i )
{
printf("%d is ", i);
if ( odd(i) )
printf("ODD");
else
printf("EVEN");
putchar(10);
}
putchar(10);
for ( j = 0; j != 10; ++j )
{
printf("%d == 0x", j);
binary(j);
putchar(10);
}
putchar(10);
v5 = 2;
while ( 1 )
{
for ( k = 0; k != 11; ++k )
{
printf("%d in base 10 is ", k);
base(k, v5);
printf(" in base %d", v5);
putchar(10);
}
putchar(10);
if ( ++v5 == 11 )
{
putchar(10);
exit(0);
}
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx
unsigned int j; // ebx
unsigned int v5; // ebp
unsigned int k; // ebx

for ( i = 0; i != 10; ++i )
{
printf("%d is ", i);
if ( func7(i) )
printf("ODD");
else
printf("EVEN");
putchar(10);
}
putchar(10);
for ( j = 0; j != 10; ++j )
{
printf("%d == 0x", j);
func8(j);
putchar(10);
}
putchar(10);
v5 = 2;
while ( 1 )
{
for ( k = 0; k != 11; ++k )
{
printf("%d in base 10 is ", k);
func9(k, v5);
printf(" in base %d", v5);
putchar(10);
}
putchar(10);
if ( ++v5 == 11 )
{
putchar(10);
exit(0);
}
}
}

original_code:
int main()
{
 unsigned int number;
 for (number = 0; number < 10; number++) {
  printf("%d is ", number);
  if (1 == odd(number)) {
   printf("ODD");
  } else {
   printf("EVEN");
  }
  printf("\n");
 }
 printf("\n");
 for (number = 0; number < 10; number++) {
  printf("%d == 0x", number);
  binary(number);
  printf("\n");
 }
 printf("\n");
 unsigned int b;
 for (b = 2; b < 11; b++) {
  for (number = 0; number < 11; number++) {
   printf("%d in base 10 is ", number);
   base(number, b);
   printf(" in base %d", b);
   printf("\n");
  }
  printf("\n");
 }
 printf("\n");
 exit(0);
}

variable_types:
b
unsigned int


decompiled_code:
__int64 __fastcall mark_multiples(int a1)
{
__int64 result; // rax

result = (unsigned int)(2 * a1);
if ( (int)result <= 999 )
{
result = (int)result;
do
{
numbers[result] = 0;
result += a1;
}
while ( (int)result <= 999 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
__int64 result; // rax

result = (unsigned int)(2 * a1);
if ( (int)result <= 999 )
{
result = (int)result;
do
{
numbers[result] = 0;
result += a1;
}
while ( (int)result <= 999 );
}
return result;
}

original_code:
void mark_multiples(int num)
{
 int ii = num;
 int primes = (sizeof(numbers)/sizeof(*(numbers)));
 for (ii = num + num; ii < primes; ii += num) {
  numbers[ii] = 0;
 }
}

variable_types: num int

variable_types: ii int

variable_types: primes int


decompiled_code:
__int64 __fastcall get_next_prime(int a1)
{
__int64 v1; // rdi
__int64 result; // rax

v1 = a1 + 1;
do
{
result = (unsigned int)v1;
if ( numbers[v1] )
break;
result = (unsigned int)++v1;
}
while ( (_DWORD)v1 != 1000 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
__int64 v1; // rdi
__int64 result; // rax

v1 = a1 + 1;
do
{
result = (unsigned int)v1;
if ( numbers[v1] )
break;
result = (unsigned int)++v1;
}
while ( (_DWORD)v1 != 1000 );
return result;
}

original_code:
int get_next_prime(int num)
{
 int answer;
 int primes = (sizeof(numbers)/sizeof(*(numbers)));
 answer = num + 1;
 while (numbers[answer] == 0) {
  answer = answer + 1;
  if (answer == primes)
   break;
 }
 return answer;
}

variable_types: answer int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int *v3; // rax
int i; // ebx
__int64 v5; // rbx

v3 = numbers;
do
*v3++ = 1;
while ( v3 != (int *)&end );
numbers[0] = 0;
dword_404064 = 0;
for ( i = 2; i <= 999; i = get_next_prime(i) )
mark_multiples(i);
v5 = 0LL;
while ( 1 )
{
if ( numbers[v5] == 1 )
printf("%d\n", (unsigned int)v5);
if ( ++v5 == 1000 )
exit(0);
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int *v3; // rax
int i; // ebx
__int64 v5; // rbx

v3 = numbers;
do
*v3++ = 1;
while ( v3 != (int *)&end );
numbers[0] = 0;
dword_404064 = 0;
for ( i = 2; i <= 999; i = func8(i) )
func7(i);
v5 = 0LL;
while ( 1 )
{
if ( numbers[v5] == 1 )
printf("%d\n", (unsigned int)v5);
if ( ++v5 == 1000 )
exit(0);
}
}

original_code:
int main()
{
 int ii, next_prime;
 int primes = (sizeof(numbers)/sizeof(*(numbers)));
 for (ii = 0; ii < primes; ii++) {
  numbers[ii] = 1;
 }
 numbers[0] = 0;
 numbers[1] = 0;
 next_prime = 2;
 do {
  mark_multiples(next_prime);
  next_prime = get_next_prime(next_prime);
 }
 while (next_prime < primes);
 for (ii = 0; ii < primes; ii++) {
  if (1 == numbers[ii]) {
   printf("%d\n", ii);
  }
 }
 exit(0);
}

canonical_original_code:
int main()
{
 int ii; int next_prime;
 int primes = (sizeof(numbers)/sizeof(*(numbers)));
 for (ii = 0; ii < primes; ii++) {
  numbers[ii] = 1;
 }
 numbers[0] = 0;
 numbers[1] = 0;
 next_prime = 2;
 do {
  mark_multiples(next_prime);
  next_prime = get_next_prime(next_prime);
 }
 while (next_prime < primes);
 for (ii = 0; ii < primes; ii++) {
  if (1 == numbers[ii]) {
   printf("%d\n", ii);
  }
 }
 exit(0);
}


mean

decompiled_code:
__int64 __fastcall mean(int a1, int a2)
{
return (unsigned int)((a1 + a2) / 2);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2)
{
return (unsigned int)((a1 + a2) / 2);
}

original_code:
int mean(int a, int b)
{
 return (a + b) / 2;
}

variable_types: a int

variable_types: b int


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax

v3 = mean(7, 9);
printf("The mean of %d and %d is %d\n", 7LL, 9LL, v3);
exit(0);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax

v3 = func7(7, 9);
printf("The mean of %d and %d is %d\n", 7LL, 9LL, v3);
exit(0);
}

original_code:
int main()
{
 int i, j;
 int answer;
 i = 7;
 j = 9;
 answer = mean(i, j);
 printf("The mean of %d and %d is %d\n", i, j, answer);
 exit(0);
}

canonical_original_code:
int main()
{
 int i; int j;
 int answer;
 i = 7;
 j = 9;
 answer = mean(i, j);
 printf("The mean of %d and %d is %d\n", i, j, answer);
 exit(0);
}

variable_types: i int

variable_types: j int


parseinput

decompiled_code:
__int64 __fastcall parseinput(unsigned int a1)
{
__int64 result; // rax
int v3; // esi
int v4; // edi

result = 0LL;
if ( a1 != 274 )
{
if ( !buf_0 )
buf_0 = g_array_new();
if ( stdscr__NCURSES6_TINFO_5_0_19991023 )
{
v3 = stdscr__NCURSES6_TINFO_5_0_19991023->_curx;
v4 = stdscr__NCURSES6_TINFO_5_0_19991023->_maxy + 1;
}
else
{
v3 = -1;
v4 = -1;
}
mvprintw(v4 - 1, v3, "%c", a1);
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
__int64 result; // rax
int v3; // esi
int v4; // edi

result = 0LL;
if ( a1 != 274 )
{
if ( !buf_0 )
buf_0 = g_array_new();
if ( stdscr__NCURSES6_TINFO_5_0_19991023 )
{
v3 = stdscr__NCURSES6_TINFO_5_0_19991023->_curx;
v4 = stdscr__NCURSES6_TINFO_5_0_19991023->_maxy + 1;
}
else
{
v3 = -1;
v4 = -1;
}
mvprintw(v4 - 1, v3, "%c", a1);
wrefresh(stdscr__NCURSES6_TINFO_5_0_19991023);
result = 1LL;
}
return result;
}

original_code:
int parseinput(int ch) {
 static GArray *buf = 0;
 int x, y, mx, my;
 switch(ch) {
  case (0410 +(10)):
   return 0;
  case '\n':
  default:
   if(!buf) buf = g_array_new(0, 0, 1);
   (y = ((0 != (const void *)((stdscr))) ? (stdscr)->_cury : (-1)), x = ((0 != (const void *)((stdscr))) ? (stdscr)->_curx : (-1)));
   (my = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), mx = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
   mvprintw(my - 1, x, "%c", ch);
 }
 wrefresh(stdscr);
 return 1;
}

canonical_original_code:
int parseinput(int ch) {
 static struct _GArray *buf = 0;
 int x; int y; int mx; int my;
 switch(ch) {
  case (0410 +(10)):
   return 0;
  case '\n':
  default:
   if(!buf) buf = g_array_new(0, 0, 1);
   (y = ((0 != (void *)((stdscr))) ? (stdscr)->_cury : (-1)), x = ((0 != (void *)((stdscr))) ? (stdscr)->_curx : (-1)));
   (my = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), mx = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
   mvprintw(my - 1, x, "%c", ch);
 }
 wrefresh(stdscr);
 return 1;
}

variable_types: ch int

variable_types: struct _GArray { char *data; unsigned int len; } *

variable_types: x int

variable_types: y int

variable_types: mx int

variable_types: my int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax

initscr();
noecho();
keypad(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
do
v3 = wgetch(stdscr__NCURSES6_TINFO_5_0_19991023);
while ( (unsigned int)parseinput(v3) );
endwin();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax

initscr();
noecho();
keypad(stdscr__NCURSES6_TINFO_5_0_19991023, 1);
do
v3 = wgetch(stdscr__NCURSES6_TINFO_5_0_19991023);
while ( (unsigned int)func7(v3) );
endwin();
return 0;
}

original_code:
int main(int argc, char** argv) {
 initscr();
 noecho();
 keypad(stdscr, 1);
 while(parseinput(wgetch(stdscr)));
 endwin();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 initscr();
 noecho();
 keypad(stdscr, 1);
 while(parseinput(wgetch(stdscr)));
 endwin();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **