main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
__int64 v5; // rdi
_BYTE v6[32]; // [rsp+0h] [rbp-48h] BYREF
__int64 v7[3]; // [rsp+20h] [rbp-28h] BYREF
unsigned int v8; // [rsp+38h] [rbp-10h]
int v9; // [rsp+3Ch] [rbp-Ch]

getParams(v7, (unsigned int)argc, argv);
v3 = v8;
if ( v8 )
{
LABEL_7:
v5 = v3;
v3 = 1;
printECode(v5);
return v3;
}
if ( !v9 )
{
printf("%s", HELPMSG);
return v3;
}
if ( v9 == 1 )
{
v3 = locale((char *)v7[2]);
if ( !v3 )
{
InitList(v6);
v3 = loadFile(v6, v7[0]);
if ( !v3 )
{
sortList(v6);
saveFile(v6, v7[1]);
DisposeList(v6);
return v3;
}
}
goto LABEL_7;
}
return v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
__int64 v5; // rdi
_BYTE v6[32]; // [rsp+0h] [rbp-48h] BYREF
__int64 v7[3]; // [rsp+20h] [rbp-28h] BYREF
unsigned int v8; // [rsp+38h] [rbp-10h]
int v9; // [rsp+3Ch] [rbp-Ch]

func8(v7, (unsigned int)argc, argv);
v3 = v8;
if ( v8 )
{
LABEL_7:
v5 = v3;
v3 = 1;
func7(v5);
return v3;
}
if ( !v9 )
{
printf("%s", HELPMSG);
return v3;
}
if ( v9 == 1 )
{
v3 = func16((char *)v7[2]);
if ( !v3 )
{
func9(v6);
v3 = func12(v6, v7[0]);
if ( !v3 )
{
func15(v6);
func13(v6, v7[1]);
func11(v6);
return v3;
}
}
goto LABEL_7;
}
return v3;
}

original_code:
int main(int argc, char *argv[])
{
 tList L;
 TParams params = getParams(argc, argv);
 if (params.ecode != EOK)
 {
  printECode(params.ecode);
  return 1;
 }
 int ecode = EOK;
 if (params.state == CHELP) printf("%s", HELPMSG);
 else if(params.state == CSORT)
 {
  if((ecode = locale(params.loc)) == EOK)
  {
   InitList(&L);
   if((ecode = loadFile(&L, params.filename1)) == EOK)
   {
    sortList(&L);
    saveFile(&L, params.filename2);
    DisposeList(&L);
   }
  }
 }
 if (ecode != EOK)
 {
  printECode(ecode);
  return 1;
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct tList L;
 struct params params = getParams(argc, argv);
 if (params.ecode != EOK)
 {
  printECode(params.ecode);
  return 1;
 }
 int ecode = EOK;
 if (params.state == CHELP) printf("%s", HELPMSG);
 else if(params.state == CSORT)
 {
  if((ecode = locale(params.loc)) == EOK)
  {
   InitList(&L);
   if((ecode = loadFile(&L, params.filename1)) == EOK)
   {
    sortList(&L);
    saveFile(&L, params.filename2);
    DisposeList(&L);
   }
  }
 }
 if (ecode != EOK)
 {
  printECode(ecode);
  return 1;
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct tList { struct tElem { struct tElem *lptr; struct tElem *rptr; int *data; } *Act; struct tElem *First; struct tElem *Last; int length; }

variable_types: struct params { char *filename1; char *filename2; char *loc; int ecode; int state; }

variable_types: ecode int


printECode

repo: kzaklova/FIT

decompiled_code:
int __fastcall printECode(unsigned int a1)
{
if ( a1 >= 8 )
a1 = 8;
return fputs((&ECODEMSG)[a1], _bss_start);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1)
{
if ( a1 >= 8 )
a1 = 8;
return fputs((&ECODEMSG)[a1], _bss_start);
}

original_code:
void printECode(int ecode)
{
 if (ecode < EOK || ecode > EALLOC)
 { ecode = EUNKNOWN; }
 fprintf(stderr, "%s", ECODEMSG[ecode]);
}

return_type: void


strInit

decompiled_code:
__int64 __fastcall strInit(_QWORD *a1)
{
_BYTE *v1; // rax

v1 = malloc(8uLL);
*a1 = v1;
if ( !v1 )
return 1LL;
*v1 = 0;
a1[1] = 0x800000000LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
_BYTE *v1; // rax

v1 = malloc(8uLL);
*a1 = v1;
if ( !v1 )
return 1LL;
*v1 = 0;
a1[1] = 0x800000000LL;
return 0LL;
}

original_code:
int strInit(string *s)
{
   if ((s->str = (char*) malloc(8)) == ((void *)0))
      return 1;
   s->str[0] = '\0';
   s->length = 0;
   s->allocSize = 8;
   return 0;
}

canonical_original_code:
int strInit(struct string *s)
{
   if ((s->str = (char *) malloc(8)) == ((void *)0))
      return 1;
   s->str[0] = '\0';
   s->length = 0;
   s->allocSize = 8;
   return 0;
}

variable_types: struct string { char *str; int length; int allocSize; } *

return_type: int


strFree

decompiled_code:
void __fastcall strFree(void **a1)
{
free(*a1);
}

canonical_decompiled_code:
void __fastcall func1(void **a1)
{
free(*a1);
}

original_code:
void strFree(string *s)
{
   free(s->str);
}

canonical_original_code:
void strFree(struct string *s)
{
   free(s->str);
}

user_defined_types: struct string { char *str; int length; int allocSize; }


strAddChar

original_code:
int strAddChar(string *s1, char c)
{
   if (s1->length + 1 >= s1->allocSize)
   {
      if ((s1->str = (char*) realloc(s1->str, s1->length + 8)) == ((void *)0))
         return 1;
      s1->allocSize = s1->length + 8;
   }
   s1->str[s1->length] = c;
   s1->length++;
   s1->str[s1->length] = '\0';
   return 0;
}

canonical_original_code:
int strAddChar(struct string *s1, char c)
{
   if (s1->length + 1 >= s1->allocSize)
   {
      if ((s1->str = (char *) realloc(s1->str, s1->length + 8)) == ((void *)0))
         return 1;
      s1->allocSize = s1->length + 8;
   }
   s1->str[s1->length] = c;
   s1->length++;
   s1->str[s1->length] = '\0';
   return 0;
}

variable_types: c char


strCopyString

decompiled_code:
__int64 __fastcall strCopyString(__int64 a1, __int64 a2)
{
int v3; // er12
void *v4; // rdi
void *v5; // rax

v3 = *(_DWORD *)(a2 + 8);
v4 = *(void **)a1;
if ( *(_DWORD *)(a1 + 12) > v3 )
goto LABEL_4;
v5 = realloc(v4, v3 + 1);
*(_QWORD *)a1 = v5;
v4 = v5;
if ( v5 )
{
*(_DWORD *)(a1 + 12) = v3 + 1;
LABEL_4:
strcpy((char *)v4, *(const char **)a2);
*(_DWORD *)(a1 + 8) = v3;
return 0LL;
}
return 1LL;
}

original_code:
int strCopyString(string *s1, string *s2)
{
   int newLength = s2->length;
   if (newLength >= s1->allocSize)
   {
      if ((s1->str = (char*) realloc(s1->str, newLength + 1)) == ((void *)0))
         return 1;
      s1->allocSize = newLength + 1;
   }
   strcpy(s1->str, s2->str);
   s1->length = newLength;
   return 0;
}

canonical_original_code:
int strCopyString(struct string *s1, struct string *s2)
{
   int newLength = s2->length;
   if (newLength >= s1->allocSize)
   {
      if ((s1->str = (char *) realloc(s1->str, newLength + 1)) == ((void *)0))
         return 1;
      s1->allocSize = newLength + 1;
   }
   strcpy(s1->str, s2->str);
   s1->length = newLength;
   return 0;
}

variable_types: newLength int


strCmpString

decompiled_code:
int __fastcall strCmpString(const char **a1, const char **a2)
{
return strcmp(*a1, *a2);
}

canonical_decompiled_code:
int __fastcall func4(const char **a1, const char **a2)
{
return strcmp(*a1, *a2);
}

original_code:
int strCmpString(string *s1, string *s2)
{
   return strcmp(s1->str, s2->str);
}

canonical_original_code:
int strCmpString(struct string *s1, struct string *s2)
{
   return strcmp(s1->str, s2->str);
}


strCmpConstStr

decompiled_code:
int __fastcall strCmpConstStr(const char **a1, const char *a2)
{
return strcmp(*a1, a2);
}

canonical_decompiled_code:
int __fastcall func5(const char **a1, const char *a2)
{
return strcmp(*a1, a2);
}

original_code:
int strCmpConstStr(string *s1, char* s2)
{
   return strcmp(s1->str, s2);
}

canonical_original_code:
int strCmpConstStr(struct string *s1, char *s2)
{
   return strcmp(s1->str, s2);
}


strGetStr

decompiled_code:
__int64 __fastcall strGetStr(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
char *strGetStr(string *s)
{
   return s->str;
}

canonical_original_code:
char *strGetStr(struct string *s)
{
   return s->str;
}

return_type: char *


strGetLength

decompiled_code:
__int64 __fastcall strGetLength(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int strGetLength(string *s)
{
   return s->length;
}

canonical_original_code:
int strGetLength(struct string *s)
{
   return s->length;
}


strprint

decompiled_code:
int __fastcall strprint(const char **a1)
{
return printf("%s", *a1);
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
return printf("%s", *a1);
}

original_code:
void strprint(string *s)
{
printf ("%s",s->str);
}

canonical_original_code:
void strprint(struct string *s)
{
printf ("%s",s->str);
}


prepareToken

decompiled_code:
_BOOL8 __fastcall prepareToken(_QWORD *a1)
{
void *v1; // rax
_BOOL8 result; // rax

v1 = malloc(0x10uLL);
*a1 = v1;
if ( v1 )
result = (unsigned int)strInit(v1) != 0;
else
result = 1LL;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_QWORD *a1)
{
void *v1; // rax
_BOOL8 result; // rax

v1 = malloc(0x10uLL);
*a1 = v1;
if ( v1 )
result = (unsigned int)strInit(v1) != 0;
else
result = 1LL;
return result;
}

original_code:
int prepareToken(string **token) {
 if ((*token = malloc(sizeof(string))) != ((void *)0)) {
  if (!strInit(*token))
   return 0;
 }
 return 1;
}

canonical_original_code:
int prepareToken(struct string **token) {
 if ((*token = malloc(sizeof(string))) != ((void *)0)) {
  if (!strInit(*token))
   return 0;
 }
 return 1;
}

variable_types: struct string { char *str; int length; int allocSize; } **


InitStream

decompiled_code:
struct _IO_FILE *InitStream()
{
struct _IO_FILE *result; // rax

if ( !stream )
{
result = stdout;
stream = stdout;
}
return result;
}

canonical_decompiled_code:
struct _IO_FILE *func0()
{
struct _IO_FILE *result; // rax

if ( !stream )
{
result = stdout;
stream = stdout;
}
return result;
}

original_code:
static void InitStream()
{
  if (stream == ((void *)0))
    stream = stdout;
}


decompiled_code:
size_t __fastcall print_indent(__int64 a1)
{
int v1; // ebx

InitStream();
fprintf(stream, "%2d", *(unsigned int *)(a1 + 560));
v1 = *(_DWORD *)(a1 + 560);
if ( v1 > 49 )
{
fwrite(" *** too deep ***", 1uLL, 0x11uLL, stream);
}
else if ( v1 > 0 )
{
do
{
fwrite("--", 1uLL, 2uLL, stream);
--v1;
}
while ( v1 );
}
return fwrite("> ", 1uLL, 2uLL, stream);
}

canonical_decompiled_code:
size_t __fastcall func1(__int64 a1)
{
int v1; // ebx

func0();
fprintf(stream, "%2d", *(unsigned int *)(a1 + 560));
v1 = *(_DWORD *)(a1 + 560);
if ( v1 > 49 )
{
fwrite(" *** too deep ***", 1uLL, 0x11uLL, stream);
}
else if ( v1 > 0 )
{
do
{
fwrite("--", 1uLL, 2uLL, stream);
--v1;
}
while ( v1 );
}
return fwrite("> ", 1uLL, 2uLL, stream);
}

original_code:
static void print_indent(lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "%2d", lp->Level);
  if(lp->Level < 50)
    for(i = lp->Level; i > 0; i--)
      fprintf(stream, "--");
  else
    fprintf(stream, " *** too deep ***");
  fprintf(stream, "> ");
}

canonical_original_code:
static void print_indent(struct _lprec *lp)
{
  int i;
  InitStream();
  fprintf(stream, "%2d", lp->Level);
  if(lp->Level < 50)
    for(i = lp->Level; i > 0; i--)
      fprintf(stream, "--");
  else
    fprintf(stream, " *** too deep ***");
  fprintf(stream, "> ");
}

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; } *

variable_types: i int

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; }


report

decompiled_code:
__int64 report(__int64 a1, __int16 a2, const char *a3, ...)
{
__int16 v3; // ax
gcc_va_list arg; // [rsp+8h] [rbp-1E0h] BYREF
char s[256]; // [rsp+20h] [rbp-1C8h] BYREF

va_start(arg, a3);
if ( !a1 )
goto LABEL_6;
v3 = *(_WORD *)(a1 + 8);
if ( !*(_QWORD *)(a1 + 648) )
{
if ( a2 > v3 )
return 0LL;
LABEL_6:
vfprintf(stderr, a3, arg);
fputc(10, stderr);
if ( !a2 )
raise(6);
return 0LL;
}
if ( a2 > v3 )
return 0LL;
vsprintf(s, a3, arg);
(*(void (__fastcall **)(__int64, _QWORD, char *))(a1 + 648))(a1, *(_QWORD *)(a1 + 656), s);
return 0LL;
}

canonical_decompiled_code:
__int64 func2(__int64 a1, __int16 a2, const char *a3, ...)
{
__int16 v3; // ax
gcc_va_list arg; // [rsp+8h] [rbp-1E0h] BYREF
char s[256]; // [rsp+20h] [rbp-1C8h] BYREF

va_start(arg, a3);
if ( !a1 )
goto LABEL_6;
v3 = *(_WORD *)(a1 + 8);
if ( !*(_QWORD *)(a1 + 648) )
{
if ( a2 > v3 )
return 0LL;
LABEL_6:
vfprintf(stderr, a3, arg);
fputc(10, stderr);
if ( !a2 )
raise(6);
return 0LL;
}
if ( a2 > v3 )
return 0LL;
vsprintf(s, a3, arg);
(*(void (__fastcall **)(__int64, _QWORD, char *))(a1 + 648))(a1, *(_QWORD *)(a1 + 656), s);
return 0LL;
}

original_code:
int report(lprec *lp, short level, char *format, ...)
{
  va_list ap;
  __builtin_va_start(ap,format);
  if ((lp == ((void *)0)) || (lp->writelog == ((void *)0)))
  {
    if((lp == ((void *)0)) || (lp->verbose >= level))
    {
      vfprintf(stderr, format, ap);
      fputc('\n', stderr);
      if(level == 0)
        raise(6);
    }
  }
  else if(lp->writelog != ((void *)0))
  {
    if(lp->verbose >= level)
    {
      char buff[255];
      vsprintf(buff, format, ap);
      lp->writelog(lp, lp->loghandle, buff);
    }
  }
  __builtin_va_end(ap);
  return(0);
}

canonical_original_code:
int report(struct _lprec *lp, short level, char *format, ...)
{
  __builtin_va_list ap;
  __builtin_va_start(ap,format);
  if ((lp == ((void *)0)) || (lp->writelog == ((void *)0)))
  {
    if((lp == ((void *)0)) || (lp->verbose >= level))
    {
      vfprintf(stderr, format, ap);
      fputc('\n', stderr);
      if(level == 0)
        raise(6);
    }
  }
  else if(lp->writelog != ((void *)0))
  {
    if(lp->verbose >= level)
    {
      char buff[255];
      vsprintf(buff, format, ap);
      lp->writelog(lp, lp->loghandle, buff);
    }
  }
  __builtin_va_end(ap);
  return(0);
}

variable_types: level short

variable_types:
format
char *

variable_types:
buff
char [255]

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:
void __fastcall debug_print_solution(__int64 a1)
{
int v1; // ebp
__int64 v2; // r12
__int64 v3; // rsi
double v4; // xmm0_8
const char *v5; // rax

if ( *(_BYTE *)(a1 + 12) )
{
InitStream();
v1 = *(_DWORD *)(a1 + 20) + 1;
if ( v1 <= *(_DWORD *)(a1 + 36) )
{
v2 = 8LL * v1;
do
{
print_indent(a1);
v3 = (unsigned int)(v1 - *(_DWORD *)(a1 + 20));
++v1;
v4 = *(double *)(*(_QWORD *)(a1 + 288) + v2);
v2 += 8LL;
v5 = (const char *)get_col_name(a1, v3);
fprintf(stream, "%-20s %g\n", v5, v4);
}
while ( *(_DWORD *)(a1 + 36) >= v1 );
}
}
}

original_code:
void debug_print_solution(lprec *lp)
{
  int i;
  if(lp->debug){
    InitStream();
    for (i = lp->rows + 1; i <= lp->sum; i++) {
      print_indent(lp);
      fprintf(stream, "%-20s %g\n", get_col_name(lp, i - lp->rows),
       (double)lp->solution[i]);
    }
  }
}

canonical_original_code:
void debug_print_solution(struct _lprec *lp)
{
  int i;
  if(lp->debug){
    InitStream();
    for (i = lp->rows + 1; i <= lp->sum; i++) {
      print_indent(lp);
      fprintf(stream, "%-20s %g\n", get_col_name(lp, i - lp->rows),
       (double)lp->solution[i]);
    }
  }
}


original_code:
void debug_print_bounds(lprec *lp, double *upbo, double *lowbo)
{
  int i;
  if(lp->debug){
    InitStream();
    for(i = lp->rows + 1; i <= lp->sum; i++) {
      if(lowbo[i] == upbo[i]) {
 print_indent(lp);
 fprintf(stream, "%s = %g\n", get_col_name(lp, i - lp->rows),
  (double)lowbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
      }
      else {
 if(lowbo[i] != 0) {
   print_indent(lp);
   fprintf(stream, "%s > %g\n", get_col_name(lp, i - lp->rows),
    (double)lowbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
 }
 if(upbo[i] != lp->infinite) {
   print_indent(lp);
   fprintf(stream, "%s < %g\n", get_col_name(lp, i - lp->rows),
    (double)upbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
 }
      }
    }
  }
}

canonical_original_code:
void debug_print_bounds(struct _lprec *lp, double *upbo, double *lowbo)
{
  int i;
  if(lp->debug){
    InitStream();
    for(i = lp->rows + 1; i <= lp->sum; i++) {
      if(lowbo[i] == upbo[i]) {
 print_indent(lp);
 fprintf(stream, "%s = %g\n", get_col_name(lp, i - lp->rows),
  (double)lowbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
      }
      else {
 if(lowbo[i] != 0) {
   print_indent(lp);
   fprintf(stream, "%s > %g\n", get_col_name(lp, i - lp->rows),
    (double)lowbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
 }
 if(upbo[i] != lp->infinite) {
   print_indent(lp);
   fprintf(stream, "%s < %g\n", get_col_name(lp, i - lp->rows),
    (double)upbo[i] * ((lp->scaling_used) ? lp->scale[i] : 1.0));
 }
      }
    }
  }
}

variable_types:
upbo
double *

variable_types:
lowbo
double *


decompiled_code:
int debug_print(__int64 a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( *(_BYTE *)(a1 + 12) )
{
InitStream();
print_indent(a1);
va_start(arg, a2);
vfprintf(stream, a2, arg);
result = fputc(10, stream);
}
return result;
}

canonical_decompiled_code:
int func5(__int64 a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( *(_BYTE *)(a1 + 12) )
{
func0();
func1(a1);
va_start(arg, a2);
vfprintf(stream, a2, arg);
result = fputc(10, stream);
}
return result;
}

original_code:
void debug_print(lprec *lp, char *format, ...)
{
  va_list ap;
  if(lp->debug) {
    InitStream();
    print_indent(lp);
    __builtin_va_start(ap,format);
    vfprintf(stream, format, ap);
    fputc('\n', stream);
    __builtin_va_end(ap);
  }
}

canonical_original_code:
void debug_print(struct _lprec *lp, char *format, ...)
{
  __builtin_va_list ap;
  if(lp->debug) {
    InitStream();
    print_indent(lp);
    __builtin_va_start(ap,format);
    vfprintf(stream, format, ap);
    fputc('\n', stream);
    __builtin_va_end(ap);
  }
}


decompiled_code:
int __fastcall print_str(const char *a1)
{
InitStream();
return fputs(a1, stream);
}

canonical_decompiled_code:
int __fastcall func6(const char *a1)
{
func0();
return fputs(a1, stream);
}

original_code:
void print_str(char *str)
{
  InitStream();
  fputs(str, stream);
}

variable_types:
str
char *


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]);
}


decompiled_code:
int __fastcall print_solution(__int64 a1)
{
size_t v1; // rdx
int v2; // ebx
__int64 v3; // rsi
int v4; // eax
const char *v5; // rax
double v7; // [rsp+8h] [rbp-20h]

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

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
size_t v1; // rdx
int v2; // ebx
__int64 v3; // rsi
int v4; // eax
const char *v5; // rax
double v7; // [rsp+8h] [rbp-20h]

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


decompiled_code:
int __fastcall print_constraints(__int64 a1)
{
size_t v1; // rdx
__int64 v2; // rsi
const char *v3; // rax
double v5; // [rsp+8h] [rbp-20h]

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

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
size_t v1; // rdx
__int64 v2; // rsi
const char *v3; // rax
double v5; // [rsp+8h] [rbp-20h]

func0();
fwrite("\nActual values of the constraints:\n", 1uLL, v1, stream);
if ( *(int *)(a1 + 20) > 0 )
{
v2 = 0LL;
do
{
v5 = *(double *)(*(_QWORD *)(a1 + 296) + 8 * (v2 + 1));
v3 = (const char *)get_row_name(a1, (unsigned int)(v2 + 1));
fprintf(stream, "%-20s %g\n", v3, v5);
++v2;
}
while ( *(_DWORD *)(a1 + 20) >= (int)v2 + 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)
{
size_t v1; // rdx
int v2; // eax
__int64 v3; // r12
int v4; // ebp
double v5; // xmm2_8
double v6; // xmm1_8
double v7; // xmm0_8
const char *v8; // rdx

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

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
size_t v1; // rdx
int v2; // eax
__int64 v3; // r12
int v4; // ebp
double v5; // xmm2_8
double v6; // xmm1_8
double v7; // xmm0_8
const char *v8; // rdx

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

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_row_name(a1, (unsigned int)v3);
else
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v2));
++v3;
fprintf(stream, "%-20s scaled at %g\n", v4, v5);
v2 = *(_DWORD *)(a1 + 20);
}
while ( v2 + *(_DWORD *)(a1 + 28) >= (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; // xmm0_8

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_row_name(a1, (unsigned int)v3);
else
v4 = (const char *)get_col_name(a1, (unsigned int)(v3 - v2));
++v3;
fprintf(stream, "%-20s scaled at %g\n", v4, v5);
v2 = *(_DWORD *)(a1 + 20);
}
while ( v2 + *(_DWORD *)(a1 + 28) >= (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)
{
_BOOL8 result; // rax

if ( stream && stream != stderr )
fclose(stream);
if ( filename )
{
stream = fopen(filename, "w");
result = stream != 0LL;
}
else
{
stream = stderr;
result = stderr != 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(char *filename)
{
_BOOL8 result; // rax

if ( stream && stream != stderr )
fclose(stream);
if ( filename )
{
stream = fopen(filename, "w");
result = stream != 0LL;
}
else
{
stream = stderr;
result = stderr != 0LL;
}
return result;
}

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 *


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, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
unsigned int v8; // er12
char v9; // al
__int64 v10; // r13
int v11; // eax
int v12; // er11
__int16 v13; // r14
int v14; // er12
unsigned int v15; // ebx
int v16; // ebp
unsigned int v17; // eax
int v19; // er12
int v20; // ebp
size_t v21; // rbx
__int64 v22; // rax
unsigned int i; // er13
__int64 v24; // rbp
__int64 j; // r12
double v26; // xmm0_8
double *v27; // rbx
double *v28; // rax
double v29; // xmm0_8
__int64 v30; // rax
__int64 v31; // rbx
__int64 v32; // rax
int *v33; // rax
int v34; // ecx
double v35; // xmm0_8
double v36; // xmm1_8
double *v37; // rax
double v38; // xmm2_8
unsigned int v39; // er14
int v40; // ebp
__int64 v41; // rbx
__int64 v42; // rax
int v43; // edx
int v44; // er15
__int64 v45; // r12
__int64 v46; // rbp
char *v47; // rbx
unsigned int *v48; // r12
double *v49; // r14
__int64 v50; // rax
double *v51; // rbp
unsigned int v52; // er13
__int64 v53; // r15
unsigned int v54; // edx
__int16 v55; // ax
double v56; // xmm4_8
double v57; // xmm5_8
signed int v58; // edx
__int64 v59; // rbx
int v60; // er15
signed int v61; // edx
__int64 v62; // rax
unsigned int v63; // er15
const char *v64; // rdx
__int64 v65; // r13
__int64 v66; // rcx
__int64 v67; // rax
unsigned int v68; // er15
double n; // [rsp+8h] [rbp-90h]
double nb; // [rsp+8h] [rbp-90h]
size_t na; // [rsp+8h] [rbp-90h]
__int64 v72; // [rsp+10h] [rbp-88h]
__int16 v73; // [rsp+10h] [rbp-88h]
__int64 v74; // [rsp+10h] [rbp-88h]
__int64 v75; // [rsp+10h] [rbp-88h]
double *v76; // [rsp+18h] [rbp-80h]
double *ptr; // [rsp+20h] [rbp-78h]
char *v78; // [rsp+28h] [rbp-70h]
int v79; // [rsp+30h] [rbp-68h]
unsigned int v80; // [rsp+38h] [rbp-60h]
__int16 v81; // [rsp+3Eh] [rbp-5Ah]
char *v82; // [rsp+40h] [rbp-58h]
unsigned int v83; // [rsp+48h] [rbp-50h]
unsigned int v84; // [rsp+4Ch] [rbp-4Ch]
unsigned int v85[15]; // [rsp+5Ch] [rbp-3Ch] BYREF

v8 = 5;
v9 = *(_BYTE *)(a1 + 18);
if ( v9 == 5 || !v9 )
return v8;
v10 = a1;
if ( *(_BYTE *)(a1 + 16) || *(_BYTE *)(a1 + 12) )
report(a1, 6LL, "Entered presolve at iteration %d", *(unsigned int *)(a1 + 276));
v11 = *(_DWORD *)(a1 + 20);
v12 = *(_DWORD *)(a1 + 704);
v85[0] = 0;
*(_DWORD *)(a1 + 488) = v11;
if ( v12 <= 0 )
{
v81 = 5;
}
else
{
v13 = 5;
v14 = 0;
v15 = 1;
do
{
v16 = SOS_infeasible(a1, v15);
if ( v16 > 0 )
{
++v14;
v13 = 2;
v17 = SOS_get_type(a1, v15);
report(
a1,
4LL,
"presolve found SOS %d (type %d) to be range-infeasible on variable %d",
v15,
v17,
(unsigned int)v16);
}
++v15;
}
while ( *(_DWORD *)(a1 + 704) >= (signed int)v15 );
v81 = v13;
if ( v14 )
return (unsigned int)v13;
v11 = *(_DWORD *)(a1 + 20);
}
v19 = *(_DWORD *)(a1 + 28);
v20 = v11;
v21 = v11 + 1;
if ( v19 >= v11 )
v20 = *(_DWORD *)(a1 + 28);
if ( v11 == -1 || (v82 = (char *)calloc(v11 + 1, 4uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v21, 207LL, "presolve.c");
goto LABEL_90;
}
v78 = (char *)calloc(v21, 4uLL);
if ( !v78 )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v21, 208LL, "presolve.c");
goto LABEL_89;
}
if ( v20 == -1 || (v76 = (double *)calloc(v20 + 1, 8uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8LL * (v20 + 1), 209LL, "presolve.c");
goto LABEL_88;
}
ptr = (double *)calloc(v21, 8uLL);
if ( !ptr )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8 * v21, 210LL, "presolve.c");
free(v76);
LABEL_88:
free(v78);
LABEL_89:
free(v82);
LABEL_90:
v8 = 2;
*(_WORD *)(a1 + 496) = 12;
return v8;
}
if ( v19 > 0 )
{
v22 = *(_QWORD *)(a1 + 80);
v72 = 4LL;
for ( i = 1; (int)i <= v19; ++i )
{
v24 = *(int *)(v22 + v72 - 4);
for ( j = 16 * v24; *(_DWORD *)(v22 + v72) > (int)v24; j += 16LL )
{
v28 = (double *)(j + *(_QWORD *)(a1 + 72));
v29 = v28[1];
v30 = *(int *)v28;
n = v29;
if ( *(_BYTE *)(*(_QWORD *)(a1 + 320) + v30) )
*(_QWORD *)&n = *(_QWORD *)&v29 ^ LC1;
v31 = v30;
if ( *(_BYTE *)(a1 + 328) )
{
a3 = *(double *)(*(_QWORD *)(a1 + 336) + 8LL * (int)(i + *(_DWORD *)(a1 + 20)))
* *(double *)(*(_QWORD *)(a1 + 336) + 8 * v30);
n = n / a3;
}
v32 = 4 * v30;
a5 = 0.0;
++*(_DWORD *)&v82[v32];
v33 = (int *)&v78[v32];
v34 = *v33 + 1;
if ( v29 < 0.0 )
v34 = *v33 - 1;
*v33 = v34;
v35 = get_upbo(a1, i, v29, a3, a4);
v36 = *(double *)(a1 + 400);
v37 = &v76[v31];
v38 = v76[v31];
if ( v36 > v38 )
{
if ( v35 >= v36 )
*v37 = v36;
else
*v37 = v35 * n + v38;
}
v26 = get_lowbo(a1, i);
v27 = &ptr[v31];
a4 = *v27;
a3 = v26;
*(_QWORD *)&a2 = *(_QWORD *)(a1 + 400) ^ LC1;
if ( *v27 > a2 )
{
if ( a2 < a3 )
{
if ( !(unsigned int)is_semicont(a1, i) )
{
a3 = a3 * n + *v27;
*v27 = a3;
}
}
else
{
*v27 = a2;
}
}
v22 = *(_QWORD *)(a1 + 80);
LODWORD(v24) = v24 + 1;
}
v19 = *(_DWORD *)(a1 + 28);
v72 += 4LL;
}
v10 = a1;
}
v83 = 0;
v84 = 0;
v80 = 0;
while ( 2 )
{
if ( v19 <= 0 )
{
v44 = *(_DWORD *)(v10 + 20);
if ( v44 > 0 )
{
v79 = 0;
goto LABEL_54;
}
break;
}
v39 = v84;
v40 = 0;
v41 = 4LL * v19;
do
{
while ( 1 )
{
v42 = *(_QWORD *)(v10 + 80);
v43 = *(_DWORD *)(v42 + v41);
v41 -= 4LL;
if ( v43 == *(_DWORD *)(v42 + v41) )
break;
LABEL_48:
if ( !--v19 )
goto LABEL_53;
}
if ( *(int *)(v10 + 704) > 0 && (unsigned int)SOS_is_member(v10, 0LL, (unsigned int)v19) )
{
report(v10, 4LL, "presolve found empty variable %d as member of a SOS", (unsigned int)v19);
goto LABEL_48;
}
++v39;
++v40;
del_column(v10, (unsigned int)v19--);
}
while ( v19 );
LABEL_53:
v44 = *(_DWORD *)(v10 + 20);
v79 = v40;
v84 = v39;
if ( v44 > 0 )
{
LABEL_54:
v45 = 4LL * v44;
v46 = v44;
v47 = &v78[v45];
v48 = (unsigned int *)&v82[v45];
v49 = &v76[v46];
v50 = v10;
v51 = &ptr[v46];
v52 = v44;
v53 = v50;
while ( 1 )
{
v55 = get_constr_type(v53, v52);
if ( !v55 )
goto LABEL_55;
v73 = v55;
nb = *v49;
a2 = get_rh(v53, v52, a2, *v49, a4, a5, v56, v57, a8);
a3 = nb - a2;
if ( nb - a2 > *(double *)(v53 + 400) )
{
v67 = v53;
v68 = v52;
v64 = "presolve found upper bound infeasibility in row %d";
v65 = v67;
v66 = v68;
goto LABEL_82;
}
if ( v73 != 2 )
{
LABEL_55:
a2 = get_rh(v53, v52, a2, a3, a4, a5, v56, v57, a8) - *v51;
*(_QWORD *)&a3 = *(_QWORD *)(v53 + 400) ^ LC1;
if ( a3 > a2 )
{
v62 = v53;
v63 = v52;
v64 = "presolve found lower bound infeasibility in row %d";
v65 = v62;
v66 = v63;
LABEL_82:
v8 = 2;
report(v65, 4LL, v64, v66);
free(ptr);
free(v76);
free(v78);
free(v82);
return v8;
}
}
v54 = *v48;
if ( *v48
&& (abs32(*(_DWORD *)v47) != v54
|| (a3 = *(double *)(v53 + 432), *(_QWORD *)&a2 = COERCE_UNSIGNED_INT64(*v49 - *v51) & LC3, a3 <= a2)) )
{
if ( v54 == 1 )
{
if ( *(int *)(v53 + 28) > 0 )
{
na = (size_t)v47;
v59 = v53;
v60 = 1;
do
{
a2 = get_mat_raw(v59, v52, (unsigned int)v60);
a8 = 0.0;
if ( a2 != 0.0 )
break;
++v60;
}
while ( *(_DWORD *)(v59 + 28) >= v60 );
v54 = v60;
v53 = v59;
v47 = (char *)na;
}
v81 = tighten_bounds_constprop_0(v53, v52, v54, (__int64)ptr, (__int64)v76, (int *)v85, a2, a3, a4, a5);
if ( v81 == 2 )
{
v10 = v53;
v8 = 2;
goto LABEL_94;
}
del_constraint(v53, v52);
v61 = *(_DWORD *)(v53 + 20);
if ( v61 >= (int)v52 )
{
v75 = v61 - v52 + 1LL;
memmove(v48, v48 + 1, 4 * v75);
memmove(v47, v47 + 4, 4 * v75);
memmove(v51, v51 + 1, 8 * v75);
memmove(v49, v49 + 1, 8 * v75);
}
++v83;
++v79;
}
}
else
{
del_constraint(v53, v52);
v58 = *(_DWORD *)(v53 + 20);
if ( v58 >= (int)v52 )
{
v74 = v58 - v52 + 1LL;
memmove(v48, v48 + 1, 4 * v74);
memmove(v47, v47 + 4, 4 * v74);
memmove(v51, v51 + 1, 8 * v74);
memmove(v49, v49 + 1, 8 * v74);
}
++v80;
++v79;
}
v47 -= 4;
--v49;
--v51;
--v48;
if ( !--v52 )
{
v10 = v53;
break;
}
}
}
if ( v79 )
{
v19 = *(_DWORD *)(v10 + 28);
continue;
}
break;
}
v8 = v81;
LABEL_94:
if ( *(double *)(v10 + 432) > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*v76 - *ptr) & LC3) )
report(v10, 4LL, "presolve identified optimal solution");
if ( v80 )
report(v10, 4LL, "presolve removed %d empty or redundant rows", v80);
if ( v83 )
report(v10, 4LL, "presolve converted %d singleton rows to bounds", v83);
if ( v85[0] )
report(v10, 4LL, "presolve tightened %d bounds", v85[0]);
if ( v84 )
report(v10, 4LL, "presolve removed %d empty columns", v84);
free(v82);
free(v78);
free(ptr);
free(v76);
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8)
{
unsigned int v8; // er12
char v9; // al
__int64 v10; // r13
int v11; // eax
int v12; // er11
__int16 v13; // r14
int v14; // er12
unsigned int v15; // ebx
int v16; // ebp
unsigned int v17; // eax
int v19; // er12
int v20; // ebp
size_t v21; // rbx
__int64 v22; // rax
unsigned int i; // er13
__int64 v24; // rbp
__int64 j; // r12
double v26; // xmm0_8
double *v27; // rbx
double *v28; // rax
double v29; // xmm0_8
__int64 v30; // rax
__int64 v31; // rbx
__int64 v32; // rax
int *v33; // rax
int v34; // ecx
double v35; // xmm0_8
double v36; // xmm1_8
double *v37; // rax
double v38; // xmm2_8
unsigned int v39; // er14
int v40; // ebp
__int64 v41; // rbx
__int64 v42; // rax
int v43; // edx
int v44; // er15
__int64 v45; // r12
__int64 v46; // rbp
char *v47; // rbx
unsigned int *v48; // r12
double *v49; // r14
__int64 v50; // rax
double *v51; // rbp
unsigned int v52; // er13
__int64 v53; // r15
unsigned int v54; // edx
__int16 v55; // ax
double v56; // xmm4_8
double v57; // xmm5_8
signed int v58; // edx
__int64 v59; // rbx
int v60; // er15
signed int v61; // edx
__int64 v62; // rax
unsigned int v63; // er15
const char *v64; // rdx
__int64 v65; // r13
__int64 v66; // rcx
__int64 v67; // rax
unsigned int v68; // er15
double n; // [rsp+8h] [rbp-90h]
double nb; // [rsp+8h] [rbp-90h]
size_t na; // [rsp+8h] [rbp-90h]
__int64 v72; // [rsp+10h] [rbp-88h]
__int16 v73; // [rsp+10h] [rbp-88h]
__int64 v74; // [rsp+10h] [rbp-88h]
__int64 v75; // [rsp+10h] [rbp-88h]
double *v76; // [rsp+18h] [rbp-80h]
double *ptr; // [rsp+20h] [rbp-78h]
char *v78; // [rsp+28h] [rbp-70h]
int v79; // [rsp+30h] [rbp-68h]
unsigned int v80; // [rsp+38h] [rbp-60h]
__int16 v81; // [rsp+3Eh] [rbp-5Ah]
char *v82; // [rsp+40h] [rbp-58h]
unsigned int v83; // [rsp+48h] [rbp-50h]
unsigned int v84; // [rsp+4Ch] [rbp-4Ch]
unsigned int v85[15]; // [rsp+5Ch] [rbp-3Ch] BYREF

v8 = 5;
v9 = *(_BYTE *)(a1 + 18);
if ( v9 == 5 || !v9 )
return v8;
v10 = a1;
if ( *(_BYTE *)(a1 + 16) || *(_BYTE *)(a1 + 12) )
report(a1, 6LL, "Entered presolve at iteration %d", *(unsigned int *)(a1 + 276));
v11 = *(_DWORD *)(a1 + 20);
v12 = *(_DWORD *)(a1 + 704);
v85[0] = 0;
*(_DWORD *)(a1 + 488) = v11;
if ( v12 <= 0 )
{
v81 = 5;
}
else
{
v13 = 5;
v14 = 0;
v15 = 1;
do
{
v16 = SOS_infeasible(a1, v15);
if ( v16 > 0 )
{
++v14;
v13 = 2;
v17 = SOS_get_type(a1, v15);
report(
a1,
4LL,
"presolve found SOS %d (type %d) to be range-infeasible on variable %d",
v15,
v17,
(unsigned int)v16);
}
++v15;
}
while ( *(_DWORD *)(a1 + 704) >= (signed int)v15 );
v81 = v13;
if ( v14 )
return (unsigned int)v13;
v11 = *(_DWORD *)(a1 + 20);
}
v19 = *(_DWORD *)(a1 + 28);
v20 = v11;
v21 = v11 + 1;
if ( v19 >= v11 )
v20 = *(_DWORD *)(a1 + 28);
if ( v11 == -1 || (v82 = (char *)calloc(v11 + 1, 4uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v21, 207LL, "presolve.c");
goto LABEL_90;
}
v78 = (char *)calloc(v21, 4uLL);
if ( !v78 )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 4 * v21, 208LL, "presolve.c");
goto LABEL_89;
}
if ( v20 == -1 || (v76 = (double *)calloc(v20 + 1, 8uLL)) == 0LL )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8LL * (v20 + 1), 209LL, "presolve.c");
goto LABEL_88;
}
ptr = (double *)calloc(v21, 8uLL);
if ( !ptr )
{
report(0LL, 1LL, "calloc of %d bytes failed on line %d of file %s", 8 * v21, 210LL, "presolve.c");
free(v76);
LABEL_88:
free(v78);
LABEL_89:
free(v82);
LABEL_90:
v8 = 2;
*(_WORD *)(a1 + 496) = 12;
return v8;
}
if ( v19 > 0 )
{
v22 = *(_QWORD *)(a1 + 80);
v72 = 4LL;
for ( i = 1; (int)i <= v19; ++i )
{
v24 = *(int *)(v22 + v72 - 4);
for ( j = 16 * v24; *(_DWORD *)(v22 + v72) > (int)v24; j += 16LL )
{
v28 = (double *)(j + *(_QWORD *)(a1 + 72));
v29 = v28[1];
v30 = *(int *)v28;
n = v29;
if ( *(_BYTE *)(*(_QWORD *)(a1 + 320) + v30) )
*(_QWORD *)&n = *(_QWORD *)&v29 ^ LC1;
v31 = v30;
if ( *(_BYTE *)(a1 + 328) )
{
a3 = *(double *)(*(_QWORD *)(a1 + 336) + 8LL * (int)(i + *(_DWORD *)(a1 + 20)))
* *(double *)(*(_QWORD *)(a1 + 336) + 8 * v30);
n = n / a3;
}
v32 = 4 * v30;
a5 = 0.0;
++*(_DWORD *)&v82[v32];
v33 = (int *)&v78[v32];
v34 = *v33 + 1;
if ( v29 < 0.0 )
v34 = *v33 - 1;
*v33 = v34;
v35 = get_upbo(a1, i, v29, a3, a4);
v36 = *(double *)(a1 + 400);
v37 = &v76[v31];
v38 = v76[v31];
if ( v36 > v38 )
{
if ( v35 >= v36 )
*v37 = v36;
else
*v37 = v35 * n + v38;
}
v26 = get_lowbo(a1, i);
v27 = &ptr[v31];
a4 = *v27;
a3 = v26;
*(_QWORD *)&a2 = *(_QWORD *)(a1 + 400) ^ LC1;
if ( *v27 > a2 )
{
if ( a2 < a3 )
{
if ( !(unsigned int)is_semicont(a1, i) )
{
a3 = a3 * n + *v27;
*v27 = a3;
}
}
else
{
*v27 = a2;
}
}
v22 = *(_QWORD *)(a1 + 80);
LODWORD(v24) = v24 + 1;
}
v19 = *(_DWORD *)(a1 + 28);
v72 += 4LL;
}
v10 = a1;
}
v83 = 0;
v84 = 0;
v80 = 0;
while ( 2 )
{
if ( v19 <= 0 )
{
v44 = *(_DWORD *)(v10 + 20);
if ( v44 > 0 )
{
v79 = 0;
goto LABEL_54;
}
break;
}
v39 = v84;
v40 = 0;
v41 = 4LL * v19;
do
{
while ( 1 )
{
v42 = *(_QWORD *)(v10 + 80);
v43 = *(_DWORD *)(v42 + v41);
v41 -= 4LL;
if ( v43 == *(_DWORD *)(v42 + v41) )
break;
LABEL_48:
if ( !--v19 )
goto LABEL_53;
}
if ( *(int *)(v10 + 704) > 0 && (unsigned int)SOS_is_member(v10, 0LL, (unsigned int)v19) )
{
report(v10, 4LL, "presolve found empty variable %d as member of a SOS", (unsigned int)v19);
goto LABEL_48;
}
++v39;
++v40;
del_column(v10, (unsigned int)v19--);
}
while ( v19 );
LABEL_53:
v44 = *(_DWORD *)(v10 + 20);
v79 = v40;
v84 = v39;
if ( v44 > 0 )
{
LABEL_54:
v45 = 4LL * v44;
v46 = v44;
v47 = &v78[v45];
v48 = (unsigned int *)&v82[v45];
v49 = &v76[v46];
v50 = v10;
v51 = &ptr[v46];
v52 = v44;
v53 = v50;
while ( 1 )
{
v55 = get_constr_type(v53, v52);
if ( !v55 )
goto LABEL_55;
v73 = v55;
nb = *v49;
a2 = get_rh(v53, v52, a2, *v49, a4, a5, v56, v57, a8);
a3 = nb - a2;
if ( nb - a2 > *(double *)(v53 + 400) )
{
v67 = v53;
v68 = v52;
v64 = "presolve found upper bound infeasibility in row %d";
v65 = v67;
v66 = v68;
goto LABEL_82;
}
if ( v73 != 2 )
{
LABEL_55:
a2 = get_rh(v53, v52, a2, a3, a4, a5, v56, v57, a8) - *v51;
*(_QWORD *)&a3 = *(_QWORD *)(v53 + 400) ^ LC1;
if ( a3 > a2 )
{
v62 = v53;
v63 = v52;
v64 = "presolve found lower bound infeasibility in row %d";
v65 = v62;
v66 = v63;
LABEL_82:
v8 = 2;
report(v65, 4LL, v64, v66);
free(ptr);
free(v76);
free(v78);
free(v82);
return v8;
}
}
v54 = *v48;
if ( *v48
&& (abs32(*(_DWORD *)v47) != v54
|| (a3 = *(double *)(v53 + 432), *(_QWORD *)&a2 = COERCE_UNSIGNED_INT64(*v49 - *v51) & LC3, a3 <= a2)) )
{
if ( v54 == 1 )
{
if ( *(int *)(v53 + 28) > 0 )
{
na = (size_t)v47;
v59 = v53;
v60 = 1;
do
{
a2 = get_mat_raw(v59, v52, (unsigned int)v60);
a8 = 0.0;
if ( a2 != 0.0 )
break;
++v60;
}
while ( *(_DWORD *)(v59 + 28) >= v60 );
v54 = v60;
v53 = v59;
v47 = (char *)na;
}
v81 = func0(v53, v52, v54, (__int64)ptr, (__int64)v76, (int *)v85, a2, a3, a4, a5);
if ( v81 == 2 )
{
v10 = v53;
v8 = 2;
goto LABEL_94;
}
del_constraint(v53, v52);
v61 = *(_DWORD *)(v53 + 20);
if ( v61 >= (int)v52 )
{
v75 = v61 - v52 + 1LL;
memmove(v48, v48 + 1, 4 * v75);
memmove(v47, v47 + 4, 4 * v75);
memmove(v51, v51 + 1, 8 * v75);
memmove(v49, v49 + 1, 8 * v75);
}
++v83;
++v79;
}
}
else
{
del_constraint(v53, v52);
v58 = *(_DWORD *)(v53 + 20);
if ( v58 >= (int)v52 )
{
v74 = v58 - v52 + 1LL;
memmove(v48, v48 + 1, 4 * v74);
memmove(v47, v47 + 4, 4 * v74);
memmove(v51, v51 + 1, 8 * v74);
memmove(v49, v49 + 1, 8 * v74);
}
++v80;
++v79;
}
v47 -= 4;
--v49;
--v51;
--v48;
if ( !--v52 )
{
v10 = v53;
break;
}
}
}
if ( v79 )
{
v19 = *(_DWORD *)(v10 + 28);
continue;
}
break;
}
v8 = v81;
LABEL_94:
if ( *(double *)(v10 + 432) > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(*v76 - *ptr) & LC3) )
report(v10, 4LL, "presolve identified optimal solution");
if ( v80 )
report(v10, 4LL, "presolve removed %d empty or redundant rows", v80);
if ( v83 )
report(v10, 4LL, "presolve converted %d singleton rows to bounds", v83);
if ( v85[0] )
report(v10, 4LL, "presolve tightened %d bounds", v85[0]);
if ( v84 )
report(v10, 4LL, "presolve removed %d empty columns", v84);
free(v82);
free(v78);
free(ptr);
free(v76);
return v8;
}

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

decompiled_code:
__int64 __fastcall hashval(_BYTE *a1, unsigned int a2)
{
int v2; // edx
unsigned int v3; // eax

v2 = (char)*a1;
if ( !*a1 )
return 0LL;
v3 = 0;
do
{
v3 = v2 + 16 * v3;
if ( (v3 & 0xF0000000) != 0 )
v3 = ((v3 & 0xF0000000) >> 24) ^ v3 & 0xFFFFFFF;
v2 = (char)*++a1;
}
while ( (_BYTE)v2 );
return v3 % a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1, unsigned int a2)
{
int v2; // edx
unsigned int v3; // eax

v2 = (char)*a1;
if ( !*a1 )
return 0LL;
v3 = 0;
do
{
v3 = v2 + 16 * v3;
if ( (v3 & 0xF0000000) != 0 )
v3 = ((v3 & 0xF0000000) >> 24) ^ v3 & 0xFFFFFFF;
v2 = (char)*++a1;
}
while ( (_BYTE)v2 );
return v3 % a2;
}

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)
{
int v2; // eax
_QWORD *v3; // rdi
__int64 v4; // r12
__int64 v5; // rbx
void **v6; // rbp

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

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
int v2; // eax
_QWORD *v3; // rdi
__int64 v4; // r12
__int64 v5; // rbx
void **v6; // rbp

v2 = *((_DWORD *)ptr + 2);
v3 = *(_QWORD **)ptr;
if ( v2 > 0 )
{
v4 = 0LL;
do
{
v5 = v3[v4];
if ( v5 )
{
do
{
v6 = (void **)v5;
v5 = *(_QWORD *)(v5 + 8);
free(*v6);
free(v6);
}
while ( v5 );
v3 = *(_QWORD **)ptr;
}
++v4;
}
while ( *((_DWORD *)ptr + 2) > (int)v4 );
}
free(v3);
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)
{
int v2; // eax
_QWORD *v3; // rcx
__int64 i; // r12

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

canonical_decompiled_code:
__int64 __fastcall func2(char *s1, __int64 a2)
{
int v2; // eax
_QWORD *v3; // rcx
__int64 i; // r12

v2 = func0(s1, *(_DWORD *)(a2 + 8));
for ( i = *(_QWORD *)(*v3 + 8LL * v2); 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; // r15
__int64 v4; // r14
int v5; // er12
__int64 v6; // rbp
unsigned int *v7; // rbx
__int64 v8; // rsi

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

canonical_decompiled_code:
int __fastcall func2(__int64 a1, int a2)
{
__int64 v2; // r15
__int64 v4; // r14
int v5; // er12
__int64 v6; // rbp
unsigned int *v7; // rbx
__int64 v8; // rsi

if ( a2 > 0 )
{
v2 = 4LL * a2;
v4 = -4LL * (unsigned int)a2;
v5 = 0;
v6 = a1 + 4LL * (unsigned int)(a2 - 1) + 4;
do
{
v7 = (unsigned int *)(v4 + v6);
do
{
v8 = *v7++;
printf("%i ", v8);
}
while ( v7 != (unsigned int *)v6 );
++v5;
v6 += v2;
putchar(10);
}
while ( a2 != v5 );
}
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, __int64 a3, __int64 a4, char a5, char a6, int a7)
{
int v8; // eax
int v9; // edx
int v10; // ecx
__int64 v11; // r10
int v12; // er11
int v13; // ebp
__int64 result; // rax
__int64 v15; // rdi
__int64 v16; // rsi
int v17; // edx
_DWORD *v18; // r8
_DWORD *v19; // rbx
int v20; // edx

v8 = match(a5, a6);
v13 = v9 + a7;
result = (unsigned int)(*(_DWORD *)(v11 + 4LL * (v12 + v9)) + v8);
v15 = v10 + v9 + a7;
v16 = 4 * v15;
if ( (int)result <= 0 )
result = 0LL;
else
*(_DWORD *)(a2 + 4 * v15) = 2;
v17 = *(_DWORD *)(v11 + 4LL * (v10 + v9));
v18 = (_DWORD *)(v11 + 4LL * (v13 + v12));
if ( (int)result < v17 - 1 )
{
v19 = (_DWORD *)(v16 + a2);
*v19 = 1;
result = (unsigned int)(*v18 - 1);
if ( v17 >= *v18 )
{
result = (unsigned int)(v17 - 1);
goto LABEL_6;
}
goto LABEL_5;
}
v20 = *v18 - 1;
if ( (int)result < v20 )
{
v19 = (_DWORD *)(v16 + a2);
result = (unsigned int)v20;
LABEL_5:
*v19 = 3;
LABEL_6:
*(_DWORD *)(v11 + 4 * v15) = result;
return result;
}
if ( (_DWORD)result )
goto LABEL_6;
*(_DWORD *)(a2 + 4 * v15) = 0;
*(_DWORD *)(v11 + 4 * v15) = 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, char a5, char a6, int a7)
{
int v8; // eax
int v9; // edx
int v10; // ecx
__int64 v11; // r10
int v12; // er11
int v13; // ebp
__int64 result; // rax
__int64 v15; // rdi
__int64 v16; // rsi
int v17; // edx
_DWORD *v18; // r8
_DWORD *v19; // rbx
int v20; // edx

v8 = func0(a5, a6);
v13 = v9 + a7;
result = (unsigned int)(*(_DWORD *)(v11 + 4LL * (v12 + v9)) + v8);
v15 = v10 + v9 + a7;
v16 = 4 * v15;
if ( (int)result <= 0 )
result = 0LL;
else
*(_DWORD *)(a2 + 4 * v15) = 2;
v17 = *(_DWORD *)(v11 + 4LL * (v10 + v9));
v18 = (_DWORD *)(v11 + 4LL * (v13 + v12));
if ( (int)result < v17 - 1 )
{
v19 = (_DWORD *)(v16 + a2);
*v19 = 1;
result = (unsigned int)(*v18 - 1);
if ( v17 >= *v18 )
{
result = (unsigned int)(v17 - 1);
goto LABEL_6;
}
goto LABEL_5;
}
v20 = *v18 - 1;
if ( (int)result < v20 )
{
v19 = (_DWORD *)(v16 + a2);
result = (unsigned int)v20;
LABEL_5:
*v19 = 3;
LABEL_6:
*(_DWORD *)(v11 + 4 * v15) = result;
return result;
}
if ( (_DWORD)result )
goto LABEL_6;
*(_DWORD *)(a2 + 4 * v15) = 0;
*(_DWORD *)(v11 + 4 * v15) = 0;
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 *