decompiled_code:
__int64 __fastcall umfdl_report_vector(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v9; // r15
__int64 v10; // rbx
__int64 v11; // r12
__int64 i; // rbx
__int64 v14; // rdi

if ( a4 <= 3 && a5 == 0 )
return 0LL;
if ( amd_printf )
{
amd_printf("dense vector, n = %ld. ", a1);
if ( !a5 )
{
LABEL_7:
if ( amd_printf )
amd_printf("\n");
goto LABEL_9;
}
}
else if ( !a5 )
{
LABEL_9:
if ( a4 == 4 )
{
v9 = 10LL;
if ( a1 <= 10 )
v9 = a1;
v10 = 0LL;
if ( a1 > 0 )
{
do
print_value_constprop_0(v10++, a2);
while ( v9 > v10 );
}
if ( a1 > v9 )
{
if ( amd_printf )
amd_printf(" ...\n");
print_value_constprop_0(a1 - 1, a2);
}
}
else if ( a4 > 4 && a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
{
v14 = i;
print_value_constprop_0(v14, a2);
}
}
if ( !amd_printf )
return 0LL;
amd_printf(" dense vector ");
goto LABEL_17;
}
if ( a2 )
{
if ( a1 >= 0 )
{
if ( a4 <= 3 )
{
LABEL_17:
if ( amd_printf )
amd_printf("OK\n\n");
return 0LL;
}
goto LABEL_7;
}
v11 = -6LL;
if ( amd_printf )
amd_printf("ERROR: length of vector is < 0\n\n");
}
else
{
v11 = -5LL;
if ( amd_printf )
amd_printf("ERROR: vector not present\n\n");
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
__int64 v9; // r15
__int64 v10; // rbx
__int64 v11; // r12
__int64 i; // rbx
__int64 v14; // rdi

if ( a4 <= 3 && a5 == 0 )
return 0LL;
if ( amd_printf )
{
amd_printf("dense vector, n = %ld. ", a1);
if ( !a5 )
{
LABEL_7:
if ( amd_printf )
amd_printf("\n");
goto LABEL_9;
}
}
else if ( !a5 )
{
LABEL_9:
if ( a4 == 4 )
{
v9 = 10LL;
if ( a1 <= 10 )
v9 = a1;
v10 = 0LL;
if ( a1 > 0 )
{
do
func0(v10++, a2);
while ( v9 > v10 );
}
if ( a1 > v9 )
{
if ( amd_printf )
amd_printf(" ...\n");
func0(a1 - 1, a2);
}
}
else if ( a4 > 4 && a1 > 0 )
{
for ( i = 0LL; i != a1; ++i )
{
v14 = i;
func0(v14, a2);
}
}
if ( !amd_printf )
return 0LL;
amd_printf(" dense vector ");
goto LABEL_17;
}
if ( a2 )
{
if ( a1 >= 0 )
{
if ( a4 <= 3 )
{
LABEL_17:
if ( amd_printf )
amd_printf("OK\n\n");
return 0LL;
}
goto LABEL_7;
}
v11 = -6LL;
if ( amd_printf )
amd_printf("ERROR: length of vector is < 0\n\n");
}
else
{
v11 = -5LL;
if ( amd_printf )
amd_printf("ERROR: vector not present\n\n");
}
return v11;
}

original_code:
long umfdl_report_vector
(
    long n,
    const double Xx [ ],
    const double Xz [ ],
    long prl,
    long user,
    long scalar
)
{
    long n2, i ;
    if (user || prl >= 4)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("dense vector, n = ""%" "ld"". ", n) ; } ;
    }
    if (user)
    {
 if (!Xx)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: vector not present\n\n") ; } ;
     return ((-5)) ;
 }
 if (n < 0)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: length of vector is < 0\n\n") ; } ;
     return ((-6)) ;
 }
    }
    if (user || prl >= 4)
    {
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
    }
    if (prl == 4)
    {
 n2 = (((10) < (n)) ? (10) : (n)) ;
 for (i = 0 ; i < n2 ; i++)
 {
     print_value (i, Xx, Xz, scalar) ;
 }
 if (n2 < n)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("    ...\n") ; } ;
     print_value (n-1, Xx, Xz, scalar) ;
 }
    }
    else if (prl > 4)
    {
 for (i = 0 ; i < n ; i++)
 {
     print_value (i, Xx, Xz, scalar) ;
 }
    }
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    dense vector ") ; } ; } } ;
    if (user || prl >= 4)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("OK\n\n") ; } ;
    }
    return ((0)) ;
}

canonical_original_code:
long umfdl_report_vector(long n, double Xx[], double Xz[], long prl, long user, long scalar)
{
    long n2; long i;
    if (user || prl >= 4)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("dense vector, n = ""%" "ld"". ", n) ; } ;
    }
    if (user)
    {
 if (!Xx)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: vector not present\n\n") ; } ;
     return ((-5)) ;
 }
 if (n < 0)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("ERROR: length of vector is < 0\n\n") ; } ;
     return ((-6)) ;
 }
    }
    if (user || prl >= 4)
    {
 { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("\n") ; } ; } } ;
    }
    if (prl == 4)
    {
 n2 = (((10) < (n)) ? (10) : (n)) ;
 for (i = 0 ; i < n2 ; i++)
 {
     print_value (i, Xx, Xz, scalar) ;
 }
 if (n2 < n)
 {
     { if (amd_printf != ((void *)0)) (void) amd_printf ("    ...\n") ; } ;
     print_value (n-1, Xx, Xz, scalar) ;
 }
    }
    else if (prl > 4)
    {
 for (i = 0 ; i < n ; i++)
 {
     print_value (i, Xx, Xz, scalar) ;
 }
    }
    { if (prl >= (4)) { { if (amd_printf != ((void *)0)) (void) amd_printf ("    dense vector ") ; } ; } } ;
    if (user || prl >= 4)
    {
 { if (amd_printf != ((void *)0)) (void) amd_printf ("OK\n\n") ; } ;
    }
    return ((0)) ;
}

variable_types:
Xx
double []

variable_types:
Xz
double []

variable_types: prl long

variable_types: user long

variable_types: scalar long


decompiled_code:
_BOOL8 __fastcall check_args(__int64 a1)
{
return *(_QWORD *)(a1 + 8) != 0LL;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(__int64 a1)
{
return *(_QWORD *)(a1 + 8) != 0LL;
}

original_code:
int check_args(struct arguments* args) {
    if (args->netlist_file == ((void *)0)) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int check_args(struct arguments *args) {
    if (args->netlist_file == ((void *)0)) {
        return 0;
    }
    return 1;
}

variable_types: struct arguments { int verbose; char *netlist_file; int interactive_graphics; int opt_reservoirs; } *

return_type: int


decompiled_code:
void __fastcall set_default_args(__int64 a1)
{
*(_DWORD *)a1 = 0;
*(_QWORD *)(a1 + 8) = 0LL;
*(_QWORD *)(a1 + 16) = 0LL;
}

original_code:
void set_default_args(struct arguments* args) {
    args->verbose = 0;
    args->netlist_file = ((void *)0);
    args->interactive_graphics = 0;
    args->opt_reservoirs = 0;
}

canonical_original_code:
void set_default_args(struct arguments *args) {
    args->verbose = 0;
    args->netlist_file = ((void *)0);
    args->interactive_graphics = 0;
    args->opt_reservoirs = 0;
}

return_type: void

user_defined_types: struct arguments { int verbose; char *netlist_file; int interactive_graphics; int opt_reservoirs; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char **v3; // rdx
unsigned int v4; // ecx
int *v5; // r8
void *v6; // r9
int v8; // [rsp+0h] [rbp-28h] BYREF
const char *v9; // [rsp+8h] [rbp-20h]
int v10; // [rsp+10h] [rbp-18h]
int v11; // [rsp+14h] [rbp-14h]

set_default_args((__int64)&v8);
argp_parse(&argp, argc, v3, v4, v5, v6);
if ( v9 )
printf("Netlist file: %s\n", v9);
else
puts("No netlist file provided");
if ( v10 )
{
puts("Interactive Graphics Enabled");
interactive_graphics = 1;
}
else
{
interactive_graphics = 0;
}
if ( v11 )
{
puts("Optimizing Reservoirs");
opt_reservoirs = 1;
}
else
{
opt_reservoirs = 0;
}
verbose = v8 != 0;
parse_netlist(v9);
*(_DWORD *)(FPGA + 32) = 3;
init_graphics("kroute graphics");
generate_rr_graph();
verify_rr_graph();
pathfinder_route();
verify_routed_netlist();
evaluate_qor();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char **v3; // rdx
unsigned int v4; // ecx
int *v5; // r8
void *v6; // r9
int v8; // [rsp+0h] [rbp-28h] BYREF
const char *v9; // [rsp+8h] [rbp-20h]
int v10; // [rsp+10h] [rbp-18h]
int v11; // [rsp+14h] [rbp-14h]

func2((__int64)&v8);
argp_parse(&argp, argc, v3, v4, v5, v6);
if ( v9 )
printf("Netlist file: %s\n", v9);
else
puts("No netlist file provided");
if ( v10 )
{
puts("Interactive Graphics Enabled");
interactive_graphics = 1;
}
else
{
interactive_graphics = 0;
}
if ( v11 )
{
puts("Optimizing Reservoirs");
opt_reservoirs = 1;
}
else
{
opt_reservoirs = 0;
}
verbose = v8 != 0;
parse_netlist(v9);
*(_DWORD *)(FPGA + 32) = 3;
init_graphics("kroute graphics");
generate_rr_graph();
verify_rr_graph();
pathfinder_route();
verify_routed_netlist();
evaluate_qor();
return 0;
}

original_code:
int main (int argc, char** argv) {
    struct arguments args;
    set_default_args(&args);
    argp_parse(&argp, argc, argv, 0, 0, &args);
    if (args.netlist_file == ((void *)0)) {
        printf("No netlist file provided\n");
    } else {
        printf("Netlist file: %s\n", args.netlist_file);
    }
    if (args.interactive_graphics) {
        printf("Interactive Graphics Enabled\n");
        interactive_graphics = 1;
    } else {
        interactive_graphics = 0;
    }
    if (args.opt_reservoirs) {
        printf("Optimizing Reservoirs\n");
        opt_reservoirs = 1;
    } else {
        opt_reservoirs = 0;
    }
    if (args.verbose) {
        verbose = 1;
    } else {
        verbose = 0;
    }
    parse_netlist(args.netlist_file);
    FPGA->Fs = 3;
    init_graphics("kroute graphics");
    generate_rr_graph();
    verify_rr_graph();
    pathfinder_route();
    verify_routed_netlist();
    evaluate_qor();
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
    struct arguments args;
    set_default_args(&args);
    argp_parse(&argp, argc, argv, 0, 0, &args);
    if (args.netlist_file == ((void *)0)) {
        printf("No netlist file provided\n");
    } else {
        printf("Netlist file: %s\n", args.netlist_file);
    }
    if (args.interactive_graphics) {
        printf("Interactive Graphics Enabled\n");
        interactive_graphics = 1;
    } else {
        interactive_graphics = 0;
    }
    if (args.opt_reservoirs) {
        printf("Optimizing Reservoirs\n");
        opt_reservoirs = 1;
    } else {
        opt_reservoirs = 0;
    }
    if (args.verbose) {
        verbose = 1;
    } else {
        verbose = 0;
    }
    parse_netlist(args.netlist_file);
    FPGA->Fs = 3;
    init_graphics("kroute graphics");
    generate_rr_graph();
    verify_rr_graph();
    pathfinder_route();
    verify_routed_netlist();
    evaluate_qor();
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct arguments { int verbose; char *netlist_file; int interactive_graphics; int opt_reservoirs; }


original_code:
void umfdl_scale
(
    long n,
    double pivot,
    double X [ ]
)
{
    double x ;
    double s ;
    long i ;
    { (s) = ((((pivot) < 0.)) ? -(pivot) : (pivot)) ; } ;
    if (s < 1e-12 || ((pivot) != (pivot)))
    {
 for (i = 0 ; i < n ; i++)
 {
     x = X [i] ;
     if (((x) != 0.))
     {
  { (X [i]) = (x) / (pivot) ; } ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     x = X [i] ;
     { (X [i]) = (x) / (pivot) ; } ;
 }
    }
}

canonical_original_code:
void umfdl_scale(long n, double pivot, double X[])
{
    double x;
    double s;
    long i;
    { (s) = ((((pivot) < 0.)) ? -(pivot) : (pivot)) ; } ;
    if (s < 1e-12 || ((pivot) != (pivot)))
    {
 for (i = 0 ; i < n ; i++)
 {
     x = X [i] ;
     if (((x) != 0.))
     {
  { (X [i]) = (x) / (pivot) ; } ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     x = X [i] ;
     { (X [i]) = (x) / (pivot) ; } ;
 }
    }
}

variable_types: n long

variable_types: pivot double

variable_types:
X
double []

variable_types: x double

variable_types: s double

variable_types: i long


original_code:
int umfpack_di_col_to_triplet
(
    int n_col,
    const int Ap [ ],
    int Tj [ ]
)
{
    int nz, j, p, p1, p2, length ;
    if (!Ap || !Tj)
    {
 return ((-5)) ;
    }
    if (n_col <= 0)
    {
 return ((-6)) ;
    }
    if (Ap [0] != 0)
    {
 return ((-8)) ;
    }
    nz = Ap [n_col] ;
    if (nz < 0)
    {
 return ((-8)) ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 p1 = Ap [j] ;
 p2 = Ap [j+1] ;
 length = p2 - p1 ;
 if (length < 0 || p2 > nz)
 {
     return ((-8)) ;
 }
 for (p = p1 ; p < p2 ; p++)
 {
     Tj [p] = j ;
 }
    }
    return ((0)) ;
}

canonical_original_code:
int umfpack_di_col_to_triplet(int n_col, int Ap[], int Tj[])
{
    int nz; int j; int p; int p1; int p2; int length;
    if (!Ap || !Tj)
    {
 return ((-5)) ;
    }
    if (n_col <= 0)
    {
 return ((-6)) ;
    }
    if (Ap [0] != 0)
    {
 return ((-8)) ;
    }
    nz = Ap [n_col] ;
    if (nz < 0)
    {
 return ((-8)) ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 p1 = Ap [j] ;
 p2 = Ap [j+1] ;
 length = p2 - p1 ;
 if (length < 0 || p2 > nz)
 {
     return ((-8)) ;
 }
 for (p = p1 ; p < p2 ; p++)
 {
     Tj [p] = j ;
 }
    }
    return ((0)) ;
}

variable_types:
Ap
int []

variable_types:
Tj
int []

variable_types: nz int

variable_types: j int

variable_types: p int

variable_types: length int


original_code:
int amd_post_tree
(
    int root,
    int k,
    int Child [ ],
    const int Sibling [ ],
    int Order [ ],
    int Stack [ ]
)
{
    int f, head, h, i ;
    head = 0 ;
    Stack [0] = root ;
    while (head >= 0)
    {
 ;
 i = Stack [head] ;
 ;
 ;
 if (Child [i] != (-1))
 {
     for (f = Child [i] ; f != (-1) ; f = Sibling [f])
     {
  head++ ;
  ;
  ;
     }
     h = head ;
     ;
     for (f = Child [i] ; f != (-1) ; f = Sibling [f])
     {
  ;
  Stack [h--] = f ;
  ;
  ;
     }
     ;
     Child [i] = (-1) ;
 }
 else
 {
     head-- ;
     ;
     Order [i] = k++ ;
     ;
 }
    }
    return (k) ;
}

canonical_original_code:
int amd_post_tree(int root, int k, int Child[], int Sibling[], int Order[], int Stack[])
{
    int f; int head; int h; int i;
    head = 0 ;
    Stack [0] = root ;
    while (head >= 0)
    {
 ;
 i = Stack [head] ;
 ;
 ;
 if (Child [i] != (-1))
 {
     for (f = Child [i] ; f != (-1) ; f = Sibling [f])
     {
  head++ ;
  ;
  ;
     }
     h = head ;
     ;
     for (f = Child [i] ; f != (-1) ; f = Sibling [f])
     {
  ;
  Stack [h--] = f ;
  ;
  ;
     }
     ;
     Child [i] = (-1) ;
 }
 else
 {
     head-- ;
     ;
     Order [i] = k++ ;
     ;
 }
    }
    return (k) ;
}

variable_types: root int

variable_types: k int

variable_types:
Child
int []

variable_types:
Sibling
int []

variable_types:
Order
int []

variable_types:
Stack
int []

variable_types: f int

variable_types: head int

variable_types: h int

variable_types: i int


original_code:
int umfzi_triplet_map_x
(
    int n_row,
    int n_col,
    int nz,
    const int Ti [ ],
    const int Tj [ ],
    int Ap [ ],
    int Ai [ ],
    int Rp [ ],
    int Rj [ ],
    int W [ ],
    int RowCount [ ]
    , const double Tx [ ]
    , double Ax [ ]
    , double Rx [ ]
    , const double Tz [ ]
    , double Az [ ]
    , double Rz [ ]
    , int Map [ ]
    , int Map2 [ ]
)
{
    int i, j, k, p, cp, p1, p2, pdest, pj ;
    int duplicates ;
    int split = ((Tz) != (double *) ((void *)0)) && ((Az) != (double *) ((void *)0)) && ((Rz) != (double *) ((void *)0)) ;
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
 if (split)
 {
     Rx [p] = Tx [k] ;
     Rz [p] = Tz [k] ;
 }
 else
 {
     Rx [2*p ] = Tx [2*k ] ;
     Rx [2*p+1] = Tx [2*k+1] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
  if (split)
  {
      Rx [pj] += Rx [p] ;
      Rz [pj] += Rz [p] ;
  }
  else
  {
      Rx[2*pj ] += Rx[2*p ] ;
      Rx[2*pj+1] += Rx[2*p+1] ;
  }
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
      if (split)
      {
   Rx [pdest] = Rx [p] ;
   Rz [pdest] = Rz [p] ;
      }
      else
      {
   Rx [2*pdest ] = Rx [2*p ] ;
   Rx [2*pdest+1] = Rx [2*p+1] ;
      }
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
     if (split)
     {
  Ax [cp] = Rx [p] ;
  Az [cp] = Rz [p] ;
     }
     else
     {
  Ax [2*cp ] = Rx [2*p ] ;
  Ax [2*cp+1] = Rx [2*p+1] ;
     }
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

canonical_original_code:
int umfzi_triplet_map_x(int n_row, int n_col, int nz, int Ti[], int Tj[], int Ap[], int Ai[], int Rp[], int Rj[], int W[], int RowCount[], double Tx[], double Ax[], double Rx[], double Tz[], double Az[], double Rz[], int Map[], int Map2[])
{
    int i; int j; int k; int p; int cp; int p1; int p2; int pdest; int pj;
    int duplicates;
    int split = ((Tz) != (double *) ((void *)0)) && ((Az) != (double *) ((void *)0)) && ((Rz) != (double *) ((void *)0));
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
 if (split)
 {
     Rx [p] = Tx [k] ;
     Rz [p] = Tz [k] ;
 }
 else
 {
     Rx [2*p ] = Tx [2*k ] ;
     Rx [2*p+1] = Tx [2*k+1] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
  if (split)
  {
      Rx [pj] += Rx [p] ;
      Rz [pj] += Rz [p] ;
  }
  else
  {
      Rx[2*pj ] += Rx[2*p ] ;
      Rx[2*pj+1] += Rx[2*p+1] ;
  }
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
      if (split)
      {
   Rx [pdest] = Rx [p] ;
   Rz [pdest] = Rz [p] ;
      }
      else
      {
   Rx [2*pdest ] = Rx [2*p ] ;
   Rx [2*pdest+1] = Rx [2*p+1] ;
      }
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
     if (split)
     {
  Ax [cp] = Rx [p] ;
  Az [cp] = Rz [p] ;
     }
     else
     {
  Ax [2*cp ] = Rx [2*p ] ;
  Ax [2*cp+1] = Rx [2*p+1] ;
     }
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

variable_types:
Ti
int []

variable_types:
Ai
int []

variable_types:
Rp
int []

variable_types:
Rj
int []

variable_types:
W
int []

variable_types:
RowCount
int []

variable_types:
Tx
double []

variable_types:
Ax
double []

variable_types:
Rx
double []

variable_types:
Tz
double []

variable_types:
Az
double []

variable_types:
Rz
double []

variable_types:
Map
int []

variable_types: cp int

variable_types: pdest int

variable_types: pj int

variable_types: duplicates int

variable_types: split int


original_code:
int umfzi_valid_symbolic
(
    SymbolicType *Symbolic
)
{
    if (!Symbolic)
    {
 return ((0)) ;
    }
    if (Symbolic->valid != 40927)
    {
 return ((0)) ;
    }
    if (!Symbolic->Cperm_init || !Symbolic->Rperm_init ||
 !Symbolic->Front_npivcol || !Symbolic->Front_1strow ||
 !Symbolic->Front_leftmostdesc ||
 !Symbolic->Front_parent || !Symbolic->Chain_start ||
 !Symbolic->Chain_maxrows || !Symbolic->Chain_maxcols ||
 Symbolic->n_row <= 0 || Symbolic->n_col <= 0)
    {
 return ((0)) ;
    }
    return ((1)) ;
}

canonical_original_code:
int umfzi_valid_symbolic(struct SymbolicType *Symbolic)
{
    if (!Symbolic)
    {
 return ((0)) ;
    }
    if (Symbolic->valid != 40927)
    {
 return ((0)) ;
    }
    if (!Symbolic->Cperm_init || !Symbolic->Rperm_init ||
 !Symbolic->Front_npivcol || !Symbolic->Front_1strow ||
 !Symbolic->Front_leftmostdesc ||
 !Symbolic->Front_parent || !Symbolic->Chain_start ||
 !Symbolic->Chain_maxrows || !Symbolic->Chain_maxcols ||
 Symbolic->n_row <= 0 || Symbolic->n_col <= 0)
    {
 return ((0)) ;
    }
    return ((1)) ;
}

variable_types: struct SymbolicType { double num_mem_usage_est; int valid; } *


decompiled_code:
__int64 __fastcall umf_i_free(__int64 a1)
{
if ( a1 )
amd_free();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( a1 )
amd_free();
return 0LL;
}

original_code:
void *umf_i_free
(
    void *p
)
{
    ;
    if (p)
    {
 amd_free (p) ;
    }
    return ((void *) ((void *)0)) ;
}

canonical_original_code:
void *umf_i_free(void *p)
{
    ;
    if (p)
    {
 amd_free (p) ;
    }
    return ((void *) ((void *)0)) ;
}

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall umfzl_mem_alloc_head_block(_QWORD *a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx
__int64 v4; // rsi
__int64 v5; // rsi

result = a1[14];
if ( a1[15] - result < a2 )
return 0LL;
v3 = a1[38];
v4 = result + a2;
a1[14] = v4;
v5 = a1[36] + v4;
if ( v5 < v3 )
v5 = v3;
a1[38] = v5;
return result;
}

original_code:
long umfzl_mem_alloc_head_block
(
    NumericType *Numeric,
    long nunits
)
{
    long p, usage ;
    ;
    ;
    ;
    if (nunits > (Numeric->itail - Numeric->ihead))
    {
 ;
 return (0) ;
    }
    p = Numeric->ihead ;
    Numeric->ihead += nunits ;
    ;
    usage = Numeric->ihead + Numeric->tail_usage ;
    Numeric->max_usage = (((Numeric->max_usage) > (usage)) ? (Numeric->max_usage) : (usage)) ;
    return (p) ;
}

canonical_original_code:
long umfzl_mem_alloc_head_block(struct NumericType *Numeric, long nunits)
{
    long p; long usage;
    ;
    ;
    ;
    if (nunits > (Numeric->itail - Numeric->ihead))
    {
 ;
 return (0) ;
    }
    p = Numeric->ihead ;
    Numeric->ihead += nunits ;
    ;
    usage = Numeric->ihead + Numeric->tail_usage ;
    Numeric->max_usage = (((Numeric->max_usage) > (usage)) ? (Numeric->max_usage) : (usage)) ;
    return (p) ;
}

variable_types: struct NumericType { double flops; long scale; long valid; union Unit_union { struct { long size; } header; double xxxxxx; } *Memory; long ihead; long *Rperm; long ulen; struct DoubleComplex { double component[2]; } *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; } *

variable_types: nunits long

variable_types: p long

variable_types: usage long

return_type: long

user_defined_types: struct NumericType { double flops; long scale; long valid; union Unit_union *Memory; long ihead; long *Rperm; long ulen; struct DoubleComplex *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; }


decompiled_code:
__int64 __fastcall umfpack_zl_report_vector(__int64 a1, __int64 a2, __int64 a3, double *a4)
{
unsigned __int64 v4; // rcx
__int64 result; // rax

if ( a4 && (v4 = (unsigned int)(int)*a4, v4 > 2) )
result = umfzl_report_vector(a1, a2, a3, v4, 1LL, 0LL);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, double *a4)
{
unsigned __int64 v4; // rcx
__int64 result; // rax

if ( a4 && (v4 = (unsigned int)(int)*a4, v4 > 2) )
result = umfzl_report_vector(a1, a2, a3, v4, 1LL, 0LL);
else
result = 0LL;
return result;
}

original_code:
long umfpack_zl_report_vector
(
    long n,
    const double Xx [ ],
    const double Xz [ ],
    const double Control [20]
)
{
    long prl ;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    return (umfzl_report_vector (n, Xx, Xz, prl, (1), (0))) ;
}

canonical_original_code:
long umfpack_zl_report_vector(long n, double Xx[], double Xz[], double Control[20])
{
    long prl;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    return (umfzl_report_vector (n, Xx, Xz, prl, (1), (0))) ;
}

variable_types: n long

variable_types:
Xx
double []

variable_types:
Xz
double []

variable_types:
Control
double [20]

variable_types: prl long


original_code:
long amd_l_valid
(
    long n_row,
    long n_col,
    const long Ap [ ],
    const long Ai [ ]
)
{
    long nz, j, p1, p2, ilast, i, p, result = 0 ;
    if (n_row < 0 || n_col < 0 || Ap == ((void *)0) || Ai == ((void *)0))
    {
 return (-2) ;
    }
    nz = Ap [n_col] ;
    if (Ap [0] != 0 || nz < 0)
    {
 ;
 return (-2) ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 p1 = Ap [j] ;
 p2 = Ap [j+1] ;
 ;
 if (p1 > p2)
 {
     ;
     return (-2) ;
 }
 ilast = (-1) ;
 for (p = p1 ; p < p2 ; p++)
 {
     i = Ai [p] ;
     ;
     if (i < 0 || i >= n_row)
     {
  ;
  return (-2) ;
     }
     if (i <= ilast)
     {
  ;
  result = 1 ;
     }
     ilast = i ;
 }
    }
    return (result) ;
}

canonical_original_code:
long amd_l_valid(long n_row, long n_col, long Ap[], long Ai[])
{
    long nz; long j; long p1; long p2; long ilast; long i; long p; long result = 0;
    if (n_row < 0 || n_col < 0 || Ap == ((void *)0) || Ai == ((void *)0))
    {
 return (-2) ;
    }
    nz = Ap [n_col] ;
    if (Ap [0] != 0 || nz < 0)
    {
 ;
 return (-2) ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 p1 = Ap [j] ;
 p2 = Ap [j+1] ;
 ;
 if (p1 > p2)
 {
     ;
     return (-2) ;
 }
 ilast = (-1) ;
 for (p = p1 ; p < p2 ; p++)
 {
     i = Ai [p] ;
     ;
     if (i < 0 || i >= n_row)
     {
  ;
  return (-2) ;
     }
     if (i <= ilast)
     {
  ;
  result = 1 ;
     }
     ilast = i ;
 }
    }
    return (result) ;
}

variable_types:
Ap
long []

variable_types:
Ai
long []

variable_types: nz long

variable_types: j long

variable_types: ilast long

variable_types: i long

variable_types: result long


decompiled_code:
__int64 __fastcall cholmod_error(int a1, __int64 a2, __int64 a3, const char *a4, __int64 a5)
{
int v6; // eax
__int64 result; // rax
void (*v8)(const char *, ...); // r8
int v9; // eax
void (__fastcall *v10)(_QWORD, __int64); // rax

if ( !a5 )
return 0LL;
if ( *(_QWORD *)(a5 + 2016) )
{
*(_DWORD *)(a5 + 2028) = -4;
result = 0LL;
}
else
{
v6 = *(_DWORD *)(a5 + 160);
*(_DWORD *)(a5 + 2028) = a1;
if ( !v6 )
{
v8 = *(void (**)(const char *, ...))(a5 + 152);
if ( v8 )
{
v9 = *(_DWORD *)(a5 + 140);
if ( a1 <= 0 || v9 <= 1 )
{
if ( v9 > 0 )
{
v8("CHOLMOD error: %s\n", a4);
fflush(stdout);
fflush(stderr);
}
}
else
{
v8("CHOLMOD warning: %s\n", a4);
fflush(stdout);
fflush(stderr);
}
}
v10 = *(void (__fastcall **)(_QWORD, __int64))(a5 + 168);
if ( v10 )
v10((unsigned int)a1, a2);
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, __int64 a3, const char *a4, __int64 a5)
{
int v6; // eax
__int64 result; // rax
void (*v8)(const char *, ...); // r8
int v9; // eax
void (__fastcall *v10)(_QWORD, __int64); // rax

if ( !a5 )
return 0LL;
if ( *(_QWORD *)(a5 + 2016) )
{
*(_DWORD *)(a5 + 2028) = -4;
result = 0LL;
}
else
{
v6 = *(_DWORD *)(a5 + 160);
*(_DWORD *)(a5 + 2028) = a1;
if ( !v6 )
{
v8 = *(void (**)(const char *, ...))(a5 + 152);
if ( v8 )
{
v9 = *(_DWORD *)(a5 + 140);
if ( a1 <= 0 || v9 <= 1 )
{
if ( v9 > 0 )
{
v8("CHOLMOD error: %s\n", a4);
fflush(stdout);
fflush(stderr);
}
}
else
{
v8("CHOLMOD warning: %s\n", a4);
fflush(stdout);
fflush(stderr);
}
}
v10 = *(void (__fastcall **)(_QWORD, __int64))(a5 + 168);
if ( v10 )
v10((unsigned int)a1, a2);
}
result = 1LL;
}
return result;
}

original_code:
int cholmod_error
(
    int status,
    const char *file,
    int line,
    const char *message,
    cholmod_common *Common
)
{
    { if (Common == ((void *)0)) { return (0) ; } if (Common->itype != 0 || Common->dtype != 0) { Common->status = (-4) ; return (0) ; } } ;
    Common->status = status ;
    if (!(Common->try_catch))
    {
 if (Common->print_function != ((void *)0))
 {
     if (status > 0 && Common->print > 1)
     {
  (Common->print_function) ("CHOLMOD warning: %s\n", message) ;
  fflush (stdout) ;
  fflush (stderr) ;
     }
     else if (Common->print > 0)
     {
  (Common->print_function) ("CHOLMOD error: %s\n", message) ;
  fflush (stdout) ;
  fflush (stderr) ;
     }
 }
 if (Common->error_handler != ((void *)0))
 {
     Common->error_handler (status, file, line, message) ;
 }
    }
    return (1) ;
}

canonical_original_code:
int cholmod_error(int status, char *file, int line, char *message, struct cholmod_common_struct *Common)
{
    { if (Common == ((void *)0)) { return (0) ; } if (Common->itype != 0 || Common->dtype != 0) { Common->status = (-4) ; return (0) ; } } ;
    Common->status = status ;
    if (!(Common->try_catch))
    {
 if (Common->print_function != ((void *)0))
 {
     if (status > 0 && Common->print > 1)
     {
  (Common->print_function) ("CHOLMOD warning: %s\n", message) ;
  fflush (stdout) ;
  fflush (stderr) ;
     }
     else if (Common->print > 0)
     {
  (Common->print_function) ("CHOLMOD error: %s\n", message) ;
  fflush (stdout) ;
  fflush (stderr) ;
     }
 }
 if (Common->error_handler != ((void *)0))
 {
     Common->error_handler (status, file, line, message) ;
 }
    }
    return (1) ;
}

variable_types: status int

variable_types:
file
char *

variable_types: line int

variable_types:
message
char *

variable_types: struct cholmod_common_struct { double dbound; double grow0; double grow1; unsigned long grow2; unsigned long maxrank; double supernodal_switch; int supernodal; int final_asis; int final_super; int final_ll; int final_pack; int final_monotonic; int final_resymbol; double zrelax[3]; unsigned long nrelax[3]; int prefer_zomplex; int prefer_upper; int quick_return_if_not_posdef; int print; int precise; int (*print_function)(char *, ...); int try_catch; void (*error_handler)(int status, char *file, int line, char *message); int nmethods; int current; int selected; struct cholmod_method_struct { double lnz; double fl; double prune_dense; double prune_dense2; double nd_oksep; double other_1[4]; unsigned long nd_small; unsigned long other_2[4]; int aggressive; int order_for_lu; int nd_compress; int nd_camd; int nd_components; int ordering; unsigned long other_3[4]; } method[-1]; int postorder; void *(*malloc_memory)(unsigned long); void *(*realloc_memory)(void *, unsigned long); void (*free_memory)(void *); void *(*calloc_memory)(unsigned long, unsigned long); int (*complex_divide)(double ax, double az, double bx, double bz, double *cx, double *cz); double (*hypotenuse)(double x, double y); double metis_memory; double metis_dswitch; unsigned long metis_nswitch; unsigned long nrow; long mark; unsigned long iworksize; unsigned long xworksize; void *Flag; void *Head; void *Xwork; void *Iwork; int itype; int dtype; int no_workspace_reallocate; int status; double fl; double lnz; double anz; double modfl; unsigned long malloc_count; unsigned long memory_usage; unsigned long memory_inuse; double nrealloc_col; double nrealloc_factor; double ndbounds_hit; double rowfacfl; double aatfl; double other1[10]; double SPQR_xstat[4]; double SPQR_grain; double SPQR_small; long SPQR_istat[10]; long other2[6]; int other3[10]; int prefer_binary; int default_nesdis; int called_nd; int blas_ok; int SPQR_shrink; int SPQR_nthreads; unsigned long other4[16]; void *other5[16]; } *

user_defined_types: struct cholmod_common_struct { double dbound; double grow0; double grow1; unsigned long grow2; unsigned long maxrank; double supernodal_switch; int supernodal; int final_asis; int final_super; int final_ll; int final_pack; int final_monotonic; int final_resymbol; double zrelax[3]; unsigned long nrelax[3]; int prefer_zomplex; int prefer_upper; int quick_return_if_not_posdef; int print; int precise; int (*print_function)(char *, ...); int try_catch; void (*error_handler)(int status, char *file, int line, char *message); int nmethods; int current; int selected; struct cholmod_method_struct method[-1]; int postorder; void *(*malloc_memory)(unsigned long); void *(*realloc_memory)(void *, unsigned long); void (*free_memory)(void *); void *(*calloc_memory)(unsigned long, unsigned long); int (*complex_divide)(double ax, double az, double bx, double bz, double *cx, double *cz); double (*hypotenuse)(double x, double y); double metis_memory; double metis_dswitch; unsigned long metis_nswitch; unsigned long nrow; long mark; unsigned long iworksize; unsigned long xworksize; void *Flag; void *Head; void *Xwork; void *Iwork; int itype; int dtype; int no_workspace_reallocate; int status; double fl; double lnz; double anz; double modfl; unsigned long malloc_count; unsigned long memory_usage; unsigned long memory_inuse; double nrealloc_col; double nrealloc_factor; double ndbounds_hit; double rowfacfl; double aatfl; double other1[10]; double SPQR_xstat[4]; double SPQR_grain; double SPQR_small; long SPQR_istat[10]; long other2[6]; int other3[10]; int prefer_binary; int default_nesdis; int called_nd; int blas_ok; int SPQR_shrink; int SPQR_nthreads; unsigned long other4[16]; void *other5[16]; }


original_code:
int umfdi_triplet_map_nox
(
    int n_row,
    int n_col,
    int nz,
    const int Ti [ ],
    const int Tj [ ],
    int Ap [ ],
    int Ai [ ],
    int Rp [ ],
    int Rj [ ],
    int W [ ],
    int RowCount [ ]
    , int Map [ ]
    , int Map2 [ ]
)
{
    int i, j, k, p, cp, p1, p2, pdest, pj ;
    int duplicates ;
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

canonical_original_code:
int umfdi_triplet_map_nox(int n_row, int n_col, int nz, int Ti[], int Tj[], int Ap[], int Ai[], int Rp[], int Rj[], int W[], int RowCount[], int Map[], int Map2[])
{
    int i; int j; int k; int p; int cp; int p1; int p2; int pdest; int pj;
    int duplicates;
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

variable_types: nz int

variable_types:
Ti
int []

variable_types:
Tj
int []

variable_types:
Ap
int []

variable_types:
Ai
int []

variable_types:
Rp
int []

variable_types:
Rj
int []

variable_types:
W
int []

variable_types:
RowCount
int []

variable_types:
Map
int []

variable_types: i int

variable_types: j int

variable_types: k int

variable_types: p int

variable_types: cp int

variable_types: pdest int

variable_types: pj int

variable_types: duplicates int


original_code:
int umfdi_mem_alloc_tail_block
(
    NumericType *Numeric,
    int nunits
)
{
    int bigsize, usage ;
    Unit *p, *pnext, *pbig ;
    ;
    ;
    bigsize = 0 ;
    pbig = (Unit *) ((void *)0) ;
    ;
    if (Numeric->ibig != (-1))
    {
 ;
 ;
 pbig = Numeric->Memory + Numeric->ibig ;
 bigsize = -pbig->header.size ;
 ;
 ;
    }
    if (pbig && bigsize >= nunits)
    {
 p = pbig ;
 pnext = p + 1 + bigsize ;
 ;
 ;
 ;
 bigsize -= nunits + 1 ;
 if (bigsize < 4)
 {
     p->header.size = -p->header.size ;
     ;
     Numeric->ibig = (-1) ;
 }
 else
 {
     p->header.size = nunits ;
     Numeric->ibig += nunits + 1 ;
     pbig = Numeric->Memory + Numeric->ibig ;
     pbig->header.size = -bigsize ;
     pbig->header.prevsize = nunits ;
     pnext->header.prevsize = bigsize ;
     ;
 }
    }
    else
    {
 pnext = Numeric->Memory + Numeric->itail ;
 ;
 if ((nunits + 1) > (Numeric->itail - Numeric->ihead))
 {
     ;
     return (0) ;
 }
 Numeric->itail -= (nunits + 1) ;
 p = Numeric->Memory + Numeric->itail ;
 p->header.size = nunits ;
 p->header.prevsize = 0 ;
 pnext->header.prevsize = nunits ;
 ;
    }
    Numeric->tail_usage += p->header.size + 1 ;
    usage = Numeric->ihead + Numeric->tail_usage ;
    Numeric->max_usage = (((Numeric->max_usage) > (usage)) ? (Numeric->max_usage) : (usage)) ;
    return ((p - Numeric->Memory) + 1) ;
}

canonical_original_code:
int umfdi_mem_alloc_tail_block(struct NumericType *Numeric, int nunits)
{
    int bigsize; int usage;
    union Unit_union *p; union Unit_union *pnext; union Unit_union *pbig;
    ;
    ;
    bigsize = 0 ;
    pbig = (union Unit_union *) ((void *)0) ;
    ;
    if (Numeric->ibig != (-1))
    {
 ;
 ;
 pbig = Numeric->Memory + Numeric->ibig ;
 bigsize = -pbig->header.size ;
 ;
 ;
    }
    if (pbig && bigsize >= nunits)
    {
 p = pbig ;
 pnext = p + 1 + bigsize ;
 ;
 ;
 ;
 bigsize -= nunits + 1 ;
 if (bigsize < 4)
 {
     p->header.size = -p->header.size ;
     ;
     Numeric->ibig = (-1) ;
 }
 else
 {
     p->header.size = nunits ;
     Numeric->ibig += nunits + 1 ;
     pbig = Numeric->Memory + Numeric->ibig ;
     pbig->header.size = -bigsize ;
     pbig->header.prevsize = nunits ;
     pnext->header.prevsize = bigsize ;
     ;
 }
    }
    else
    {
 pnext = Numeric->Memory + Numeric->itail ;
 ;
 if ((nunits + 1) > (Numeric->itail - Numeric->ihead))
 {
     ;
     return (0) ;
 }
 Numeric->itail -= (nunits + 1) ;
 p = Numeric->Memory + Numeric->itail ;
 p->header.size = nunits ;
 p->header.prevsize = 0 ;
 pnext->header.prevsize = nunits ;
 ;
    }
    Numeric->tail_usage += p->header.size + 1 ;
    usage = Numeric->ihead + Numeric->tail_usage ;
    Numeric->max_usage = (((Numeric->max_usage) > (usage)) ? (Numeric->max_usage) : (usage)) ;
    return ((p - Numeric->Memory) + 1) ;
}

variable_types: struct NumericType { double flops; int scale; int valid; union Unit_union { struct { int size; } header; double xxxxxx; } *Memory; int ihead; int *Rperm; int ulen; double *D; int do_recip; double *Rs; int n_row; int tail_usage; int maxnrows; } *

variable_types: nunits int

variable_types: bigsize int

variable_types: usage int

user_defined_types: struct NumericType { double flops; int scale; int valid; union Unit_union *Memory; int ihead; int *Rperm; int ulen; double *D; int do_recip; double *Rs; int n_row; int tail_usage; int maxnrows; }


original_code:
void umf_l_set_stats
(
    double Info [ ],
    SymbolicType *Symbolic,
    double max_usage,
    double num_mem_size,
    double flops,
    double lnz,
    double unz,
    double maxfrsize,
    double ulen,
    double npiv,
    double maxnrows,
    double maxncols,
    long scale,
    long prefer_diagonal,
    long what
)
{
    double sym_size, work_usage, nn, n_row, n_col, n_inner, num_On_size1,
 num_On_size2, num_usage, sym_maxncols, sym_maxnrows, elen, n1 ;
    n_col = Symbolic->n_col ;
    n_row = Symbolic->n_row ;
    n1 = Symbolic->n1 ;
    nn = (((n_row) > (n_col)) ? (n_row) : (n_col)) ;
    n_inner = (((n_row) < (n_col)) ? (n_row) : (n_col)) ;
    sym_maxncols = (((Symbolic->maxncols + Symbolic->nb) < (n_col)) ? (Symbolic->maxncols + Symbolic->nb) : (n_col)) ;
    sym_maxnrows = (((Symbolic->maxnrows + Symbolic->nb) < (n_row)) ? (Symbolic->maxnrows + Symbolic->nb) : (n_row)) ;
    elen = (n_col - n1) + (n_row - n1) + (((n_col - n1) < (n_row - n1)) ? (n_col - n1) : (n_row - n1)) + 1 ;
    sym_size = umfdl_symbolic_usage (Symbolic->n_row, Symbolic->n_col,
 Symbolic->nchains, Symbolic->nfr, Symbolic->esize, prefer_diagonal) ;
    num_On_size1 =
 (ceil ((sizeof (NumericType) * ((double) 1)) / sizeof (Unit)))
 + (ceil ((sizeof (double) * ((double) n_inner+1)) / sizeof (Unit)))
 + 4 * (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + 4 * (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + (scale ? (ceil ((sizeof (double) * ((double) n_row)) / sizeof (Unit))) : 0) ;
    num_On_size2 =
 (ceil ((sizeof (NumericType) * ((double) 1)) / sizeof (Unit)))
 + (ceil ((sizeof (double) * ((double) n_inner+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + 6 * (ceil ((sizeof (long) * ((double) npiv+1)) / sizeof (Unit)))
 + (scale ? (ceil ((sizeof (double) * ((double) n_row)) / sizeof (Unit))) : 0) ;
    ;
    Info [46 + what] = max_usage ;
    Info [47 + what] = num_mem_size ;
    Info [40 + what] =
 num_On_size2
 + num_mem_size
 + (ceil ((sizeof (long) * ((double) ulen+1)) / sizeof (Unit))) ;
    ;
    ;
    ;
    Info [48 + what] = maxfrsize ;
    Info [49 + what] = maxnrows ;
    Info [50 + what] = maxncols ;
    ;
    ;
    work_usage =
 2 * (ceil ((sizeof (double) * ((double) sym_maxnrows + 1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) nn + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) (((n_col) > (sym_maxnrows)) ? (n_col) : (sym_maxnrows)) + 1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) sym_maxnrows + 1)) / sizeof (Unit)))
 + 3 * (ceil ((sizeof (long) * ((double) sym_maxncols + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) (((sym_maxnrows) > (sym_maxncols)) ? (sym_maxnrows) : (sym_maxncols)) + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) elen)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) Symbolic->nfr + 1)) / sizeof (Unit)))
 + ((n_row == n_col) ? (2 * (ceil ((sizeof (long) * ((double) nn)) / sizeof (Unit)))) : 0) ;
    num_usage =
 sym_size
 + num_On_size1
 + work_usage
 + max_usage ;
    Info [41 + what] =
 (((Symbolic->peak_sym_usage) > (num_usage)) ? (Symbolic->peak_sym_usage) : (num_usage)) ;
    Info [42 + what] = flops ;
    Info [43 + what] = lnz ;
    Info [44 + what] = unz ;
}

canonical_original_code:
void umf_l_set_stats(double Info[], struct SymbolicType *Symbolic, double max_usage, double num_mem_size, double flops, double lnz, double unz, double maxfrsize, double ulen, double npiv, double maxnrows, double maxncols, long scale, long prefer_diagonal, long what)
{
    double sym_size; double work_usage; double nn; double n_row; double n_col; double n_inner; double num_On_size1; double num_On_size2; double num_usage; double sym_maxncols; double sym_maxnrows; double elen; double n1;
    n_col = Symbolic->n_col ;
    n_row = Symbolic->n_row ;
    n1 = Symbolic->n1 ;
    nn = (((n_row) > (n_col)) ? (n_row) : (n_col)) ;
    n_inner = (((n_row) < (n_col)) ? (n_row) : (n_col)) ;
    sym_maxncols = (((Symbolic->maxncols + Symbolic->nb) < (n_col)) ? (Symbolic->maxncols + Symbolic->nb) : (n_col)) ;
    sym_maxnrows = (((Symbolic->maxnrows + Symbolic->nb) < (n_row)) ? (Symbolic->maxnrows + Symbolic->nb) : (n_row)) ;
    elen = (n_col - n1) + (n_row - n1) + (((n_col - n1) < (n_row - n1)) ? (n_col - n1) : (n_row - n1)) + 1 ;
    sym_size = umfdl_symbolic_usage (Symbolic->n_row, Symbolic->n_col,
 Symbolic->nchains, Symbolic->nfr, Symbolic->esize, prefer_diagonal) ;
    num_On_size1 =
 (ceil ((sizeof (NumericType) * ((double) 1)) / sizeof (Unit)))
 + (ceil ((sizeof (double) * ((double) n_inner+1)) / sizeof (Unit)))
 + 4 * (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + 4 * (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + (scale ? (ceil ((sizeof (double) * ((double) n_row)) / sizeof (Unit))) : 0) ;
    num_On_size2 =
 (ceil ((sizeof (NumericType) * ((double) 1)) / sizeof (Unit)))
 + (ceil ((sizeof (double) * ((double) n_inner+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + 6 * (ceil ((sizeof (long) * ((double) npiv+1)) / sizeof (Unit)))
 + (scale ? (ceil ((sizeof (double) * ((double) n_row)) / sizeof (Unit))) : 0) ;
    ;
    Info [46 + what] = max_usage ;
    Info [47 + what] = num_mem_size ;
    Info [40 + what] =
 num_On_size2
 + num_mem_size
 + (ceil ((sizeof (long) * ((double) ulen+1)) / sizeof (Unit))) ;
    ;
    ;
    ;
    Info [48 + what] = maxfrsize ;
    Info [49 + what] = maxnrows ;
    Info [50 + what] = maxncols ;
    ;
    ;
    work_usage =
 2 * (ceil ((sizeof (double) * ((double) sym_maxnrows + 1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) n_row+1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) n_col+1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) nn + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) (((n_col) > (sym_maxnrows)) ? (n_col) : (sym_maxnrows)) + 1)) / sizeof (Unit)))
 + 2 * (ceil ((sizeof (long) * ((double) sym_maxnrows + 1)) / sizeof (Unit)))
 + 3 * (ceil ((sizeof (long) * ((double) sym_maxncols + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) (((sym_maxnrows) > (sym_maxncols)) ? (sym_maxnrows) : (sym_maxncols)) + 1)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) elen)) / sizeof (Unit)))
 + (ceil ((sizeof (long) * ((double) Symbolic->nfr + 1)) / sizeof (Unit)))
 + ((n_row == n_col) ? (2 * (ceil ((sizeof (long) * ((double) nn)) / sizeof (Unit)))) : 0) ;
    num_usage =
 sym_size
 + num_On_size1
 + work_usage
 + max_usage ;
    Info [41 + what] =
 (((Symbolic->peak_sym_usage) > (num_usage)) ? (Symbolic->peak_sym_usage) : (num_usage)) ;
    Info [42 + what] = flops ;
    Info [43 + what] = lnz ;
    Info [44 + what] = unz ;
}

variable_types:
Info
double []

variable_types: struct SymbolicType { double num_mem_usage_est; long valid; } *

variable_types: flops double

variable_types: lnz double

variable_types: unz double

variable_types: maxfrsize double

variable_types: ulen double

variable_types: npiv double

variable_types: maxnrows double

variable_types: maxncols double

variable_types: scale long

variable_types: what long

variable_types: nn double

variable_types: elen double


decompiled_code:
__int64 __fastcall umfpack_zi_report_vector(__int64 a1, __int64 a2, __int64 a3, double *a4)
{
__int64 v4; // rcx
__int64 result; // rax

if ( a4 && (v4 = (unsigned int)(int)*a4, (int)v4 > 2) )
result = umfzi_report_vector(a1, a2, a3, v4, 1LL, 0LL);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, double *a4)
{
__int64 v4; // rcx
__int64 result; // rax

if ( a4 && (v4 = (unsigned int)(int)*a4, (int)v4 > 2) )
result = umfzi_report_vector(a1, a2, a3, v4, 1LL, 0LL);
else
result = 0LL;
return result;
}

original_code:
int umfpack_zi_report_vector
(
    int n,
    const double Xx [ ],
    const double Xz [ ],
    const double Control [20]
)
{
    int prl ;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    return (umfzi_report_vector (n, Xx, Xz, prl, (1), (0))) ;
}

canonical_original_code:
int umfpack_zi_report_vector(int n, double Xx[], double Xz[], double Control[20])
{
    int prl;
    prl = ((Control != (double *) ((void *)0)) ? (((Control [0]) != (Control [0])) ? 1 : Control [0]) : 1) ;
    if (prl <= 2)
    {
 return ((0)) ;
    }
    return (umfzi_report_vector (n, Xx, Xz, prl, (1), (0))) ;
}

variable_types: n int

variable_types:
Xx
double []

variable_types:
Xz
double []

variable_types:
Control
double [20]

variable_types: prl int


original_code:
int umfpack_di_scale
(
    double Xx [ ],
    const double Bx [ ],
    void *NumericHandle
)
{
    NumericType *Numeric ;
    int n, i ;
    double *Rs ;
    Numeric = (NumericType *) NumericHandle ;
    if (!umfdi_valid_numeric (Numeric))
    {
 return ((-3)) ;
    }
    n = Numeric->n_row ;
    Rs = Numeric->Rs ;
    if (!Xx || !Bx)
    {
 return ((-5)) ;
    }
    if (Rs != (double *) ((void *)0))
    {
 if (Numeric->do_recip)
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] * Rs [i] ;
     }
 }
 else
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] / Rs [i] ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     Xx [i] = Bx [i] ;
 }
    }
    return ((0)) ;
}

canonical_original_code:
int umfpack_di_scale(double Xx[], double Bx[], void *NumericHandle)
{
    struct NumericType *Numeric;
    int n; int i;
    double *Rs;
    Numeric = (struct NumericType *) NumericHandle ;
    if (!umfdi_valid_numeric (Numeric))
    {
 return ((-3)) ;
    }
    n = Numeric->n_row ;
    Rs = Numeric->Rs ;
    if (!Xx || !Bx)
    {
 return ((-5)) ;
    }
    if (Rs != (double *) ((void *)0))
    {
 if (Numeric->do_recip)
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] * Rs [i] ;
     }
 }
 else
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] / Rs [i] ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     Xx [i] = Bx [i] ;
 }
    }
    return ((0)) ;
}

variable_types:
Bx
double []

variable_types:
NumericHandle
void *

variable_types: struct NumericType { double flops; int scale; int valid; union Unit_union { struct { int size; } header; double xxxxxx; } *Memory; int ihead; int *Rperm; int ulen; double *D; int do_recip; double *Rs; int n_row; int tail_usage; int maxnrows; } *

variable_types: i int

variable_types:
Rs
double *


original_code:
long umfpack_dl_scale
(
    double Xx [ ],
    const double Bx [ ],
    void *NumericHandle
)
{
    NumericType *Numeric ;
    long n, i ;
    double *Rs ;
    Numeric = (NumericType *) NumericHandle ;
    if (!umfdl_valid_numeric (Numeric))
    {
 return ((-3)) ;
    }
    n = Numeric->n_row ;
    Rs = Numeric->Rs ;
    if (!Xx || !Bx)
    {
 return ((-5)) ;
    }
    if (Rs != (double *) ((void *)0))
    {
 if (Numeric->do_recip)
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] * Rs [i] ;
     }
 }
 else
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] / Rs [i] ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     Xx [i] = Bx [i] ;
 }
    }
    return ((0)) ;
}

canonical_original_code:
long umfpack_dl_scale(double Xx[], double Bx[], void *NumericHandle)
{
    struct NumericType *Numeric;
    long n; long i;
    double *Rs;
    Numeric = (struct NumericType *) NumericHandle ;
    if (!umfdl_valid_numeric (Numeric))
    {
 return ((-3)) ;
    }
    n = Numeric->n_row ;
    Rs = Numeric->Rs ;
    if (!Xx || !Bx)
    {
 return ((-5)) ;
    }
    if (Rs != (double *) ((void *)0))
    {
 if (Numeric->do_recip)
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] * Rs [i] ;
     }
 }
 else
 {
     for (i = 0 ; i < n ; i++)
     {
  Xx [i] = Bx [i] / Rs [i] ;
     }
 }
    }
    else
    {
 for (i = 0 ; i < n ; i++)
 {
     Xx [i] = Bx [i] ;
 }
    }
    return ((0)) ;
}

variable_types: struct NumericType { double flops; long scale; long valid; union Unit_union { struct { long size; } header; double xxxxxx; } *Memory; long ihead; long *Rperm; long ulen; double *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; } *

variable_types: n long

variable_types: i long

user_defined_types: struct NumericType { double flops; long scale; long valid; union Unit_union *Memory; long ihead; long *Rperm; long ulen; double *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; }


original_code:
int umfzi_triplet_map_nox
(
    int n_row,
    int n_col,
    int nz,
    const int Ti [ ],
    const int Tj [ ],
    int Ap [ ],
    int Ai [ ],
    int Rp [ ],
    int Rj [ ],
    int W [ ],
    int RowCount [ ]
    , int Map [ ]
    , int Map2 [ ]
)
{
    int i, j, k, p, cp, p1, p2, pdest, pj ;
    int duplicates ;
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

canonical_original_code:
int umfzi_triplet_map_nox(int n_row, int n_col, int nz, int Ti[], int Tj[], int Ap[], int Ai[], int Rp[], int Rj[], int W[], int RowCount[], int Map[], int Map2[])
{
    int i; int j; int k; int p; int cp; int p1; int p2; int pdest; int pj;
    int duplicates;
    for (i = 0 ; i < n_row ; i++)
    {
 W [i] = 0 ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 i = Ti [k] ;
 j = Tj [k] ;
 if (i < 0 || i >= n_row || j < 0 || j >= n_col)
 {
     return ((-8)) ;
 }
 W [i]++ ;
    }
    Rp [0] = 0 ;
    for (i = 0 ; i < n_row ; i++)
    {
 Rp [i+1] = Rp [i] + W [i] ;
 W [i] = Rp [i] ;
    }
    for (k = 0 ; k < nz ; k++)
    {
 p = W [Ti [k]]++ ;
 Map [k] = p ;
 Rj [p] = Tj [k] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = (-1) ;
    }
    duplicates = (0) ;
    for (i = 0 ; i < n_row ; i++)
    {
 p1 = Rp [i] ;
 p2 = Rp [i+1] ;
 pdest = p1 ;
 for (p = p1 ; p < p2 ; p++)
 {
     j = Rj [p] ;
     ;
     pj = W [j] ;
     if (pj >= p1)
     {
  ;
  ;
  Map2 [p] = pj ;
  duplicates = (1) ;
     }
     else
     {
  W [j] = pdest ;
  Map2 [p] = pdest ;
  if (pdest != p)
  {
      Rj [pdest] = j ;
  }
  pdest++ ;
     }
 }
 RowCount [i] = pdest - p1 ;
    }
    if (duplicates)
    {
 for (k = 0 ; k < nz ; k++)
 {
     Map [k] = Map2 [Map [k]] ;
 }
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = 0 ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     j = Rj [p] ;
     ;
     W [j]++ ;
 }
    }
    Ap [0] = 0 ;
    for (j = 0 ; j < n_col ; j++)
    {
 Ap [j+1] = Ap [j] + W [j] ;
    }
    for (j = 0 ; j < n_col ; j++)
    {
 W [j] = Ap [j] ;
    }
    for (i = 0 ; i < n_row ; i++)
    {
 for (p = Rp [i] ; p < Rp [i] + RowCount [i] ; p++)
 {
     cp = W [Rj [p]]++ ;
     Map2 [p] = cp ;
     Ai [cp] = i ;
 }
    }
    for (k = 0 ; k < nz ; k++)
    {
 Map [k] = Map2 [Map [k]] ;
    }
    return ((0)) ;
}

variable_types: nz int

variable_types:
Ti
int []

variable_types:
Tj
int []

variable_types:
Ap
int []

variable_types:
Ai
int []

variable_types:
Rp
int []

variable_types:
Rj
int []

variable_types:
W
int []

variable_types:
RowCount
int []

variable_types:
Map
int []

variable_types: j int

variable_types: k int

variable_types: p int

variable_types: cp int

variable_types: pdest int

variable_types: pj int

variable_types: duplicates int


decompiled_code:
void *__fastcall my_calloc(size_t a1, size_t a2)
{
void *v3; // [rsp+18h] [rbp-8h]

v3 = calloc(a1, a2);
if ( !v3 )
die("Error: calloc of size %ux%u bytes failed\n", (unsigned int)a1, (unsigned int)a2);
return v3;
}

canonical_decompiled_code:
void *__fastcall func2(size_t a1, size_t a2)
{
void *v3; // [rsp+18h] [rbp-8h]

v3 = calloc(a1, a2);
if ( !v3 )
func8("Error: calloc of size %ux%u bytes failed\n", (unsigned int)a1, (unsigned int)a2);
return v3;
}

original_code:
void* my_calloc(size_t num_items, size_t size_of_item) {
    void* retval = calloc(num_items, size_of_item);
    if (retval == ((void *)0)) {
        printf("Error: calloc of size %ux%u bytes failed\n", (unsigned int) num_items, (unsigned int) size_of_item);
        ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "SRC/base/util.c", 30, __extension__ __PRETTY_FUNCTION__); }));
        exit(1);
    }
    return retval;
}

canonical_original_code:
void *my_calloc(unsigned long num_items, unsigned long size_of_item) {
    void *retval = calloc(num_items, size_of_item);
    if (retval == ((void *)0)) {
        printf("Error: calloc of size %ux%u bytes failed\n", (unsigned int) num_items, (unsigned int) size_of_item);
        ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "SRC/base/util.c", 30, __extension__ __PRETTY_FUNCTION__); }));
        exit(1);
    }
    return retval;
}

variable_types:
retval
void *


decompiled_code:
void *__fastcall my_malloc(size_t a1)
{
void *v2; // [rsp+18h] [rbp-8h]

v2 = malloc(a1);
if ( !v2 )
die("Error: malloc of size %u bytes failed\n", (unsigned int)a1);
return v2;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1)
{
void *v2; // [rsp+18h] [rbp-8h]

v2 = malloc(a1);
if ( !v2 )
func8("Error: malloc of size %u bytes failed\n", (unsigned int)a1);
return v2;
}

original_code:
void* my_malloc(size_t size) {
    void* retval = malloc(size);
    if (retval == ((void *)0)) {
        printf("Error: malloc of size %u bytes failed\n", (unsigned int) size);
        exit(1);
    }
    return retval;
}

canonical_original_code:
void *my_malloc(unsigned long size) {
    void *retval = malloc(size);
    if (retval == ((void *)0)) {
        printf("Error: malloc of size %u bytes failed\n", (unsigned int) size);
        exit(1);
    }
    return retval;
}

variable_types:
size
unsigned long


decompiled_code:
void *__fastcall my_realloc(void *a1, size_t a2)
{
void *v3; // [rsp+18h] [rbp-8h]

v3 = realloc(a1, a2);
if ( !v3 && a2 )
die("Error: realloc of size %u bytes failed\n", (unsigned int)a2);
return v3;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *v3; // [rsp+18h] [rbp-8h]

v3 = realloc(a1, a2);
if ( !v3 && a2 )
func8("Error: realloc of size %u bytes failed\n", (unsigned int)a2);
return v3;
}

original_code:
void* my_realloc(void* ptr, size_t size) {
    void* retval = realloc(ptr, size);
    if (retval == ((void *)0)) {
        printf("Error: realloc of size %u bytes failed\n", (unsigned int) size);
        exit(1);
    }
    return retval;
}

canonical_original_code:
void *my_realloc(void *ptr, unsigned long size) {
    void *retval = realloc(ptr, size);
    if (retval == ((void *)0)) {
        printf("Error: realloc of size %u bytes failed\n", (unsigned int) size);
        exit(1);
    }
    return retval;
}

variable_types:
ptr
void *


original_code:
void set_default_args(struct arguments* args) {
    args->verbose = 0;
    args->netlist_file = ((void *)0);
    args->interactive_graphics = 0;
    args->opt_reservoirs = 0;
}

canonical_original_code:
void set_default_args(struct arguments *args) {
    args->verbose = 0;
    args->netlist_file = ((void *)0);
    args->interactive_graphics = 0;
    args->opt_reservoirs = 0;
}

variable_types: struct arguments { int verbose; char *netlist_file; int interactive_graphics; int opt_reservoirs; } *


canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 8) != 0LL;
}

original_code:
int check_args(struct arguments* args) {
    if (args->netlist_file == ((void *)0)) {
        return 0;
    }
    return 1;
}

canonical_original_code:
int check_args(struct arguments *args) {
    if (args->netlist_file == ((void *)0)) {
        return 0;
    }
    return 1;
}


decompiled_code:
int __fastcall evaluate_qor(double a1)
{
double v2; // [rsp+8h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-8h]

v4 = *(_QWORD *)(g_CHIP + 16LL);
evaluate_objective();
v2 = calc_hpwl_netlist(v4);
puts("\nQoR:");
printf(" Objective Fn: %.2f\n", a1);
return printf(" Total HPWL : %.2f\n", v2);
}

canonical_decompiled_code:
int __fastcall func0(double a1)
{
double v2; // [rsp+8h] [rbp-18h]
__int64 v4; // [rsp+18h] [rbp-8h]

v4 = *(_QWORD *)(g_CHIP + 16LL);
func3();
v2 = func1(v4);
puts("\nQoR:");
printf(" Objective Fn: %.2f\n", a1);
return printf(" Total HPWL : %.2f\n", v2);
}

original_code:
void evaluate_qor(void) {
    printf("\nQOR RESULTS:\n");
    int total_num_segs = print_wire_seg_stats();
    float phi = evaluate_phi(total_num_segs);
    printf("  Reservoir Optimization:\n");
    printf("\tPHI: %.1f segs\t(%.2f of total # segs)\n", phi, (phi/total_num_segs));
}

canonical_original_code:
void evaluate_qor() {
    printf("\nQOR RESULTS:\n");
    int total_num_segs = print_wire_seg_stats();
    float phi = evaluate_phi(total_num_segs);
    printf("  Reservoir Optimization:\n");
    printf("\tPHI: %.1f segs\t(%.2f of total # segs)\n", phi, (phi/total_num_segs));
}

variable_types: phi float


track

repo: knight-rider/ptx

decompiled_code:
__int64 __fastcall track(unsigned int a1)
{
int v1; // eax
int v2; // ebp
__int64 result; // rax
__int16 v4[2]; // [rsp+0h] [rbp-128h] BYREF
__int64 v5; // [rsp+4h] [rbp-124h]
__int64 v6; // [rsp+Ch] [rbp-11Ch]
char s[264]; // [rsp+20h] [rbp-108h] BYREF

v4[0] = 0x2000;
v5 = 0x200000000LL;
v6 = 0x400000001LL;
sprintf(s, "/dev/dvb/adapter%d/demux0", a1);
v1 = open(s, 2);
if ( v1 < 0 )
{
perror("open");
result = 0xFFFFFFFFLL;
}
else
{
v2 = v1;
if ( ioctl(v1, 0x40146F2CuLL, v4) >= 0 )
{
while ( 1 )
sleep(3u);
}
perror("ioctl DMX_SET_PES_FILTER");
close(v2);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
int v1; // eax
int v2; // ebp
__int64 result; // rax
__int16 v4[2]; // [rsp+0h] [rbp-128h] BYREF
__int64 v5; // [rsp+4h] [rbp-124h]
__int64 v6; // [rsp+Ch] [rbp-11Ch]
char s[264]; // [rsp+20h] [rbp-108h] BYREF

v4[0] = 0x2000;
v5 = 0x200000000LL;
v6 = 0x400000001LL;
sprintf(s, "/dev/dvb/adapter%d/demux0", a1);
v1 = open(s, 2);
if ( v1 < 0 )
{
perror("open");
result = 0xFFFFFFFFLL;
}
else
{
v2 = v1;
if ( ioctl(v1, 0x40146F2CuLL, v4) >= 0 )
{
while ( 1 )
sleep(3u);
}
perror("ioctl DMX_SET_PES_FILTER");
close(v2);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int track(int adapter_nr)
{
 char file[256];
 int fd;
 struct dmx_pes_filter_params filter;
 filter.pid = 0x2000;
 filter.input = DMX_IN_FRONTEND;
 filter.output = DMX_OUT_TS_TAP;
 filter.pes_type = DMX_PES_VIDEO0;
 filter.flags = 4;
 sprintf(file, "/dev/dvb/adapter%d/demux0", adapter_nr);
 if ((fd = open(file, 02)) < 0) {
  perror("open");
  return -1;
 }
 if (ioctl(fd, (((1U) << (((0 +8)+8)+14)) | ((('o')) << (0 +8)) | (((44)) << 0) | ((((sizeof(struct dmx_pes_filter_params)))) << ((0 +8)+8))), &filter) < 0) {
  perror("ioctl DMX_SET_PES_FILTER");
  close(fd);
  return -1;
 }
 while (1)
  sleep(3);
}

variable_types:
file
char [256]

variable_types: fd int

variable_types: struct dmx_pes_filter_params { unsigned short pid; enum dmx_input { DMX_IN_FRONTEND=0, DMX_IN_DVR=1 } input; enum dmx_output { DMX_OUT_DECODER=0, DMX_OUT_TAP=1, DMX_OUT_TS_TAP=2, DMX_OUT_TSDEMUX_TAP=3 } output; enum dmx_ts_pes { DMX_PES_AUDIO0=0, DMX_PES_VIDEO0=1, DMX_PES_TELETEXT0=2, DMX_PES_SUBTITLE0=3, DMX_PES_PCR0=4, DMX_PES_AUDIO1=5, DMX_PES_VIDEO1=6, DMX_PES_TELETEXT1=7, DMX_PES_SUBTITLE1=8, DMX_PES_PCR1=9, DMX_PES_AUDIO2=10, DMX_PES_VIDEO2=11, DMX_PES_TELETEXT2=12, DMX_PES_SUBTITLE2=13, DMX_PES_PCR2=14, DMX_PES_AUDIO3=15, DMX_PES_VIDEO3=16, DMX_PES_TELETEXT3=17, DMX_PES_SUBTITLE3=18, DMX_PES_PCR3=19, DMX_PES_OTHER=20 } pes_type; unsigned int flags; }

user_defined_types: struct dmx_pes_filter_params { unsigned short pid; enum dmx_input input; enum dmx_output output; enum dmx_ts_pes pes_type; unsigned int flags; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
__int64 v4; // rax
int v5; // ebp
unsigned int v6; // ebx
unsigned int *v8; // rbx
const char *v9; // rcx
__int64 v10; // rdx
FILE **v11; // rbx
const char *v12; // rcx
__int64 v13; // rdx

if ( argc <= 2 )
{
v8 = (unsigned int *)&isdbs_channels;
fprintf(_bss_start, "Usage: %s adapter_no channel_id\n", *argv);
fwrite("\nSatellite channels:\n", 1uLL, 0x15uLL, _bss_start);
do
{
v9 = (const char *)*((_QWORD *)v8 + 1);
v10 = *v8;
v8 += 6;
fprintf(_bss_start, " %d\t%s\n", v10, v9);
}
while ( v8 != (unsigned int *)&unk_4042F8 );
v11 = (FILE **)&isdbt_channels;
fwrite("\nTerrestrial channels:\n", 1uLL, 0x17uLL, _bss_start);
do
{
v12 = (const char *)v11[1];
v13 = *(unsigned int *)v11;
v11 += 3;
fprintf(_bss_start, " %d\t%s\n", v13, v12);
}
while ( v11 != &_bss_start );
}
else
{
v3 = strtol(argv[1], 0LL, 0);
v4 = strtol(argv[2], 0LL, 10);
v5 = search(v3, v4);
if ( v5 >= 0 )
{
v6 = track(v3);
close(v5);
return v6 >> 31;
}
}
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
__int64 v4; // rax
int v5; // ebp
unsigned int v6; // ebx
unsigned int *v8; // rbx
const char *v9; // rcx
__int64 v10; // rdx
FILE **v11; // rbx
const char *v12; // rcx
__int64 v13; // rdx

if ( argc <= 2 )
{
v8 = (unsigned int *)&isdbs_channels;
fprintf(_bss_start, "Usage: %s adapter_no channel_id\n", *argv);
fwrite("\nSatellite channels:\n", 1uLL, 0x15uLL, _bss_start);
do
{
v9 = (const char *)*((_QWORD *)v8 + 1);
v10 = *v8;
v8 += 6;
fprintf(_bss_start, " %d\t%s\n", v10, v9);
}
while ( v8 != (unsigned int *)&unk_4042F8 );
v11 = (FILE **)&isdbt_channels;
fwrite("\nTerrestrial channels:\n", 1uLL, 0x17uLL, _bss_start);
do
{
v12 = (const char *)v11[1];
v13 = *(unsigned int *)v11;
v11 += 3;
fprintf(_bss_start, " %d\t%s\n", v13, v12);
}
while ( v11 != &_bss_start );
}
else
{
v3 = strtol(argv[1], 0LL, 0);
v4 = strtol(argv[2], 0LL, 10);
v5 = func7(v3, v4);
if ( v5 >= 0 )
{
v6 = func8(v3);
close(v5);
return v6 >> 31;
}
}
return 1;
}

original_code:
int main(int argc, char *argv[]) {
 int adapter_nr, channel_id, fd, i, ret;
 if (argc <= 2) {
  fprintf(stderr, "Usage: %s adapter_no channel_id\n", argv[0]);
  fprintf(stderr, "\nSatellite channels:\n");
  for (i = 0; i < (sizeof(isdbs_channels) / sizeof((isdbs_channels)[0])); i++)
   fprintf(stderr, "  %d	%s\n", isdbs_channels[i].id, isdbs_channels[i].name);
  fprintf(stderr, "\nTerrestrial channels:\n");
  for (i = 0; i < (sizeof(isdbt_channels) / sizeof((isdbt_channels)[0])); i++)
   fprintf(stderr, "  %d	%s\n", isdbt_channels[i].id, isdbt_channels[i].name);
  return 1;
 }
 adapter_nr = strtol(argv[1], ((void *)0), 0);
 channel_id = strtol(argv[2], ((void *)0), 10);
 fd = search(adapter_nr, channel_id);
 if (fd < 0)
  return 1;
 ret = track(adapter_nr);
 close(fd);
 return ret < 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
 int adapter_nr; int channel_id; int fd; int i; int ret;
 if (argc <= 2) {
  fprintf(stderr, "Usage: %s adapter_no channel_id\n", argv[0]);
  fprintf(stderr, "\nSatellite channels:\n");
  for (i = 0; i < (sizeof(isdbs_channels) / sizeof((isdbs_channels)[0])); i++)
   fprintf(stderr, "  %d	%s\n", isdbs_channels[i].id, isdbs_channels[i].name);
  fprintf(stderr, "\nTerrestrial channels:\n");
  for (i = 0; i < (sizeof(isdbt_channels) / sizeof((isdbt_channels)[0])); i++)
   fprintf(stderr, "  %d	%s\n", isdbt_channels[i].id, isdbt_channels[i].name);
  return 1;
 }
 adapter_nr = strtol(argv[1], ((void *)0), 0);
 channel_id = strtol(argv[2], ((void *)0), 10);
 fd = search(adapter_nr, channel_id);
 if (fd < 0)
  return 1;
 ret = track(adapter_nr);
 close(fd);
 return ret < 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: i int

variable_types: ret int


decompiled_code:
void sigint_handler()
{
cont = 0;
}

canonical_decompiled_code:
void func7()
{
cont = 0;
}

original_code:
static void sigint_handler(int signo)
{
 cont = 0;
}

variable_types: signo int


decompiled_code:
unsigned __int64 __fastcall pts_diff(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax

v2 = a1;
if ( a1 < a2 )
v2 = a1 + 0x25800000000LL;
return v2 - a2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v2; // rax

v2 = a1;
if ( a1 < a2 )
v2 = a1 + 0x25800000000LL;
return v2 - a2;
}

original_code:
uint64_t
pts_diff(uint64_t a, uint64_t b)
{
 if (a < b)
  a += ((1UL << 32) << 1) * 300;
 return a - b;
}

canonical_original_code:
unsigned long pts_diff(unsigned long a, unsigned long b)
{
 if (a < b)
  a += ((1UL << 32) << 1) * 300;
 return a - b;
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long

return_type: unsigned long


canonical_original_code:
unsigned long get_pts(unsigned char *p)
{
 return (((unsigned long)(p[0] & 0x0e) << 29) | ((unsigned long)p[1] << 22) |
  ((unsigned long)(p[2] & 0xfe) << 14) | ((unsigned long)p[3] << 7) |
  ((unsigned long)p[4] >> 1));
}

variable_types:
p
unsigned char *


repo: knneth/nnedi

variable_types:
cpu
unsigned int

variable_types:
eax
unsigned int

variable_types:
ebx
unsigned int

variable_types:
ecx
unsigned int

variable_types:
edx
unsigned int

variable_types:
vendor
unsigned int [4]

variable_types: cache int

variable_types: family int

variable_types: model int

variable_types:
buf
unsigned int [4]

variable_types: max int

variable_types: j int

return_type: unsigned int


decompiled_code:
__int64 nnedi_cpu_num_processors()
{
int v0; // eax
unsigned int v1; // er8
unsigned int i; // edx
unsigned int v3; // eax
char v4; // cl
cpu_set_t v6; // [rsp+0h] [rbp-88h] BYREF

memset(&v6, 0, sizeof(v6));
v0 = sched_getaffinity(0, 0x80uLL, &v6);
v1 = 1;
if ( !v0 )
{
v1 = 0;
for ( i = 0; i != 1024; ++i )
{
v3 = i;
v4 = i;
v1 += ((int)*((unsigned __int8 *)v6.__bits + (v3 >> 3)) >> (v4 & 7)) & 1;
}
}
return v1;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
unsigned int v1; // er8
unsigned int i; // edx
unsigned int v3; // eax
char v4; // cl
cpu_set_t v6; // [rsp+0h] [rbp-88h] BYREF

memset(&v6, 0, sizeof(v6));
v0 = sched_getaffinity(0, 0x80uLL, &v6);
v1 = 1;
if ( !v0 )
{
v1 = 0;
for ( i = 0; i != 1024; ++i )
{
v3 = i;
v4 = i;
v1 += ((int)*((unsigned __int8 *)v6.__bits + (v3 >> 3)) >> (v4 & 7)) & 1;
}
}
return v1;
}

original_code:
int nnedi_cpu_num_processors( void )
{
    cpu_set_t p_aff;
    memset( &p_aff, 0, sizeof(p_aff) );
    if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) )
        return 1;
    int np = 0;
    for( unsigned int bit = 0; bit < 8 * sizeof(p_aff); bit++ )
        np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
    return np;
}

canonical_original_code:
int nnedi_cpu_num_processors()
{
    struct cpu_set_t p_aff;
    memset( &p_aff, 0, sizeof(p_aff) );
    if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) )
        return 1;
    int np = 0;
    for( unsigned int bit = 0; bit < 8 * sizeof(p_aff); bit++ )
        np += (((unsigned char *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
    return np;
}

variable_types: struct cpu_set_t { unsigned long __bits[-1]; }

variable_types: np int

variable_types:
bit
unsigned int


add

decompiled_code:
int __fastcall add(void *src, __int64 a2)
{
int v2; // er12
int v3; // ebp
int v4; // ebx
__int64 v5; // r15
int result; // eax
_QWORD *v7; // rbp
_DWORD *v8; // rbx
size_t v9; // r12
void *v10; // rax
int v11; // [rsp+Ch] [rbp-3Ch]

v2 = 0;
v11 = length;
v3 = length - 1;
if ( length - 1 >= 0 )
{
while ( 1 )
{
while ( 1 )
{
v4 = (v2 + v3) >> 1;
v5 = *(_QWORD *)(a2 + 8LL * v4);
result = strcmp(*(const char **)v5, (const char *)src);
if ( result >= 0 )
break;
v2 = v4 + 1;
if ( v3 < v4 + 1 )
goto LABEL_7;
}
if ( !result )
break;
v3 = v4 - 1;
if ( v4 - 1 < v2 )
goto LABEL_7;
}
++*(_DWORD *)(v5 + 8);
}
else
{
LABEL_7:
if ( v11 > 99999999 )
{
result = fprintf(stderr, "No more memory, cannot add: %s\n", (const char *)src);
}
else
{
v7 = (_QWORD *)(a2 + 8LL * v2);
memmove(v7 + 1, v7, 8LL * (v11 - v2));
v8 = malloc(0x10uLL);
v9 = (int)(strlen((const char *)src) + 1);
v10 = malloc(v9);
v8[2] = 1;
*(_QWORD *)v8 = v10;
result = (unsigned int)memcpy(v10, src, v9);
*v7 = v8;
++length;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(void *src, __int64 a2)
{
int v2; // er12
int v3; // ebp
int v4; // ebx
__int64 v5; // r15
int result; // eax
_QWORD *v7; // rbp
_DWORD *v8; // rbx
size_t v9; // r12
void *v10; // rax
int v11; // [rsp+Ch] [rbp-3Ch]

v2 = 0;
v11 = length;
v3 = length - 1;
if ( length - 1 >= 0 )
{
while ( 1 )
{
while ( 1 )
{
v4 = (v2 + v3) >> 1;
v5 = *(_QWORD *)(a2 + 8LL * v4);
result = strcmp(*(const char **)v5, (const char *)src);
if ( result >= 0 )
break;
v2 = v4 + 1;
if ( v3 < v4 + 1 )
goto LABEL_7;
}
if ( !result )
break;
v3 = v4 - 1;
if ( v4 - 1 < v2 )
goto LABEL_7;
}
++*(_DWORD *)(v5 + 8);
}
else
{
LABEL_7:
if ( v11 > 99999999 )
{
result = fprintf(stderr, "No more memory, cannot add: %s\n", (const char *)src);
}
else
{
v7 = (_QWORD *)(a2 + 8LL * v2);
memmove(v7 + 1, v7, 8LL * (v11 - v2));
v8 = malloc(0x10uLL);
v9 = (int)(strlen((const char *)src) + 1);
v10 = malloc(v9);
v8[2] = 1;
*(_QWORD *)v8 = v10;
result = (unsigned int)memcpy(v10, src, v9);
*v7 = v8;
++length;
}
}
return result;
}

original_code:
void add(char *buf, struct ITEM **list) {
 int min=0, max=length-1, found=0, mid=0, l;
 struct ITEM *item;
 while(max >= min) {
  mid = (min + max) / 2;
  if( strcmp(list[mid]->word, buf) < 0 ) {
   min = mid + 1;
  } else if(strcmp(list[mid]->word, buf) > 0) {
   max = mid - 1;
  } else {
   found = 1;
   break;
  }
 }
 if(found) {
  list[mid]->num ++;
  return;
 }
 if(length >= 100000000) {
  fprintf(stderr, "No more memory, cannot add: %s\n", buf);
  return;
 }
 memmove(list+min+1, list+min, (length-min) * sizeof(struct ITEM*));
 item = (struct ITEM*)malloc(sizeof(struct ITEM));
 l = strlen(buf) + 1;
 item->word = (char*)malloc(l);
 item->num = 1;
 memcpy(item->word, buf, l);
 list[min] = item;
 length++;
 return;
}

canonical_original_code:
void add(char *buf, struct ITEM **list) {
 int min = 0; int max = length-1; int found = 0; int mid = 0; int l;
 struct ITEM *item;
 while(max >= min) {
  mid = (min + max) / 2;
  if( strcmp(list[mid]->word, buf) < 0 ) {
   min = mid + 1;
  } else if(strcmp(list[mid]->word, buf) > 0) {
   max = mid - 1;
  } else {
   found = 1;
   break;
  }
 }
 if(found) {
  list[mid]->num ++;
  return;
 }
 if(length >= 100000000) {
  fprintf(stderr, "No more memory, cannot add: %s\n", buf);
  return;
 }
 memmove(list+min+1, list+min, (length-min) * sizeof(struct ITEM *));
 item = (struct ITEM *)malloc(sizeof(struct ITEM));
 l = strlen(buf) + 1;
 item->word = (char *)malloc(l);
 item->num = 1;
 memcpy(item->word, buf, l);
 list[min] = item;
 length++;
 return;
}

variable_types:
buf
char *

variable_types: struct ITEM { char *word; unsigned int num; } **

variable_types: min int

variable_types: found int

variable_types: mid int

variable_types: l int


primeTimes

repo: ko/inpro

variable_types:
s
char *

variable_types: i int

variable_types: product int

variable_types:
primes
int [26]


isAnagram

decompiled_code:
__int64 __fastcall isAnagram(const char *a1, const char *a2)
{
int v2; // ebx
__int64 result; // rax

v2 = primeTimes(a1);
if ( v2 == (unsigned int)primeTimes(a2) )
{
printf("'%s' and '%s' are anagrams\n", a1, a2);
result = 0LL;
}
else
{
printf("'%s' and '%s' are not anagrams\n", a1, a2);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1, const char *a2)
{
int v2; // ebx
__int64 result; // rax

v2 = func7(a1);
if ( v2 == (unsigned int)func7(a2) )
{
printf("'%s' and '%s' are anagrams\n", a1, a2);
result = 0LL;
}
else
{
printf("'%s' and '%s' are not anagrams\n", a1, a2);
result = 1LL;
}
return result;
}

original_code:
int isAnagram(char * s1, char * s2) {
    if (primeTimes(s1) == primeTimes(s2)) {
        printf("'%s' and '%s' are anagrams\n", s1, s2);
        return 0;
    } else {
        printf("'%s' and '%s' are not anagrams\n", s1, s2);
        return 1;
    }
}

canonical_original_code:
int isAnagram(char *s1, char *s2) {
    if (primeTimes(s1) == primeTimes(s2)) {
        printf("'%s' and '%s' are anagrams\n", s1, s2);
        return 0;
    } else {
        printf("'%s' and '%s' are not anagrams\n", s1, s2);
        return 1;
    }
}


main

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

isAnagram("hello", "holle", envp);
isAnagram("holle", "holl", v3);
isAnagram("ad", "bc", v4);
return 0;
}

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

func8("hello", "holle", envp);
func8("holle", "holl", v3);
func8("ad", "bc", v4);
return 0;
}

original_code:
int main(void) {
    char * s1 = "hello";
    char * s2 = "holle";
    char * s3 = "holl";
    char * s4 = "ad";
    char * s5 = "bc";
    isAnagram(s1, s2);
    isAnagram(s2, s3);
    isAnagram(s4, s5);
}

canonical_original_code:
int main() {
    char *s1 = "hello";
    char *s2 = "holle";
    char *s3 = "holl";
    char *s4 = "ad";
    char *s5 = "bc";
    isAnagram(s1, s2);
    isAnagram(s2, s3);
    isAnagram(s4, s5);
}


init

decompiled_code:
int __fastcall init(_QWORD *a1)
{
_QWORD *v1; // rax
int i; // ebx
_QWORD *v3; // rbp

v1 = a1;
if ( a1 )
{
for ( i = 1; i != 6; ++i )
{
v3 = v1;
v1 = malloc(0x10uLL);
*(_DWORD *)v1 = i;
v3[1] = v1;
}
v1[1] = 0LL;
}
else
{
LODWORD(v1) = fprintf(stderr, "%s:%d:head is null\n", "init", 17LL);
}
return (int)v1;
}

canonical_decompiled_code:
int __fastcall func7(_QWORD *a1)
{
_QWORD *v1; // rax
int i; // ebx
_QWORD *v3; // rbp

v1 = a1;
if ( a1 )
{
for ( i = 1; i != 6; ++i )
{
v3 = v1;
v1 = malloc(0x10uLL);
*(_DWORD *)v1 = i;
v3[1] = v1;
}
v1[1] = 0LL;
}
else
{
LODWORD(v1) = fprintf(stderr, "%s:%d:head is null\n", "init", 17LL);
}
return (int)v1;
}

original_code:
void init(LIST_ITEM * head) {
    int i;
    LIST_ITEM * current;
    if (head == ((void *)0)) {
        fprintf(stderr, "%s:%d:head is null\n", __FUNCTION__, 17);
        return;
    }
    current = head;
    for (i = 1; i <= 5; i++) {
        LIST_ITEM * item = malloc(sizeof(LIST_ITEM));
        item->val = i;
        current->next = item;
        current = item;
    }
    current->next = ((void *)0);
}

canonical_original_code:
void init(struct list_item *head) {
    int i;
    struct list_item *current;
    if (head == ((void *)0)) {
        fprintf(stderr, "%s:%d:head is null\n", __FUNCTION__, 17);
        return;
    }
    current = head;
    for (i = 1; i <= 5; i++) {
        struct list_item *item = malloc(sizeof(LIST_ITEM));
        item->val = i;
        current->next = item;
        current = item;
    }
    current->next = ((void *)0);
}

variable_types: struct list_item { int val; struct list_item *next; } *


decompiled_code:
int __fastcall print_list(unsigned int *a1)
{
unsigned int i; // ebx
__int64 v3; // rcx

for ( i = 0; i != 5; ++i )
{
v3 = i;
printf("%s:%d list[%d]->val = %d\n", "print_list", 40LL, v3, *a1);
a1 = (unsigned int *)*((_QWORD *)a1 + 1);
}
return printf("%s:%d list[%d]->val = %d\n", "print_list", 44LL, 5LL, *a1);
}

canonical_decompiled_code:
int __fastcall func8(unsigned int *a1)
{
unsigned int i; // ebx
__int64 v3; // rcx

for ( i = 0; i != 5; ++i )
{
v3 = i;
printf("%s:%d list[%d]->val = %d\n", "print_list", 40LL, v3, *a1);
a1 = (unsigned int *)*((_QWORD *)a1 + 1);
}
return printf("%s:%d list[%d]->val = %d\n", "print_list", 44LL, 5LL, *a1);
}

original_code:
void print_list(LIST_ITEM * head) {
    int i;
    LIST_ITEM * current = head;
    for (i = 0; i < 5; i++) {
        printf("%s:%d list[%d]->val = %d\n", __FUNCTION__, 40,
                                             i, current->val);
        current = current->next;
    }
    printf("%s:%d list[%d]->val = %d\n", __FUNCTION__, 44,
                                         i, current->val);
}

canonical_original_code:
void print_list(struct list_item *head) {
    int i;
    struct list_item *current = head;
    for (i = 0; i < 5; i++) {
        printf("%s:%d list[%d]->val = %d\n", __FUNCTION__, 40,
                                             i, current->val);
        current = current->next;
    }
    printf("%s:%d list[%d]->val = %d\n", __FUNCTION__, 44,
                                         i, current->val);
}

user_defined_types: struct list_item { int val; struct list_item *next; }


decompiled_code:
int __fastcall print_list_r(unsigned int *a1)
{
int result; // eax

if ( a1 )
{
print_list_r(*((_QWORD *)a1 + 1));
result = fprintf(stdout, "%s:%d: node->val = %d\n", "print_list_r", 56LL, *a1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(unsigned int *a1)
{
int result; // eax

if ( a1 )
{
func9(*((_QWORD *)a1 + 1));
result = fprintf(stdout, "%s:%d: node->val = %d\n", "print_list_r", 56LL, *a1);
}
return result;
}

original_code:
void print_list_r(LIST_ITEM * node) {
    if (node == ((void *)0)) {
        return;
    }
    print_list_r(node->next);
    fprintf(stdout, "%s:%d: node->val = %d\n", __FUNCTION__, 56,
                                               node->val);
}

canonical_original_code:
void print_list_r(struct list_item *node) {
    if (node == ((void *)0)) {
        return;
    }
    print_list_r(node->next);
    fprintf(stdout, "%s:%d: node->val = %d\n", __FUNCTION__, 56,
                                               node->val);
}


decompiled_code:
int __fastcall reverse_recurse(__int64 *a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *a1;
if ( *a1 )
{
v4[0] = *(_QWORD *)(v1 + 8);
if ( v4[0] )
{
reverse_recurse(v4);
*(_QWORD *)(*(_QWORD *)(v1 + 8) + 8LL) = v1;
v2 = v4[0];
*(_QWORD *)(v1 + 8) = 0LL;
*a1 = v2;
}
else
{
LODWORD(v2) = fprintf(stderr, "%s:%d list is single element\n", "reverse_recurse", 111LL);
}
}
else
{
LODWORD(v2) = fprintf(stderr, "%s:%d head null\n", "reverse_recurse", 102LL);
}
return v2;
}

canonical_decompiled_code:
int __fastcall func11(__int64 *a1)
{
__int64 v1; // rbx
__int64 v2; // rax
__int64 v4[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = *a1;
if ( *a1 )
{
v4[0] = *(_QWORD *)(v1 + 8);
if ( v4[0] )
{
func11(v4);
*(_QWORD *)(*(_QWORD *)(v1 + 8) + 8LL) = v1;
v2 = v4[0];
*(_QWORD *)(v1 + 8) = 0LL;
*a1 = v2;
}
else
{
LODWORD(v2) = fprintf(stderr, "%s:%d list is single element\n", "reverse_recurse", 111LL);
}
}
else
{
LODWORD(v2) = fprintf(stderr, "%s:%d head null\n", "reverse_recurse", 102LL);
}
return v2;
}

original_code:
void reverse_recurse(LIST_ITEM ** head) {
    LIST_ITEM * first;
    LIST_ITEM * other;
    if (*head == ((void *)0)) {
        fprintf(stderr, "%s:%d head null\n", __FUNCTION__, 102);
        return;
    }
    first = *head;
    other = first->next;
    if (other == ((void *)0)) {
        fprintf(stderr, "%s:%d list is single element\n", __FUNCTION__,
                                                          111);
        return;
    }
    reverse_recurse(&other);
    first->next->next = first;
    first->next = ((void *)0);
    *head = other;
}

canonical_original_code:
void reverse_recurse(struct list_item **head) {
    struct list_item *first;
    struct list_item *other;
    if (*head == ((void *)0)) {
        fprintf(stderr, "%s:%d head null\n", __FUNCTION__, 102);
        return;
    }
    first = *head;
    other = first->next;
    if (other == ((void *)0)) {
        fprintf(stderr, "%s:%d list is single element\n", __FUNCTION__,
                                                          111);
        return;
    }
    reverse_recurse(&other);
    first->next->next = first;
    first->next = ((void *)0);
    *head = other;
}

variable_types: struct list_item { int val; struct list_item *next; } **


reverse

decompiled_code:
// attributes: thunk
int __fastcall reverse(__int64 *a1)
{
return reverse_recurse(a1);
}

canonical_decompiled_code:
int __fastcall func12(__int64 *a1)
{
return func11(a1);
}

original_code:
void reverse(LIST_ITEM ** head) {
    reverse_recurse (head);
}

canonical_original_code:
void reverse(struct list_item **head) {
    reverse_recurse (head);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_DWORD *v3; // rax
_DWORD *v5; // [rsp+8h] [rbp-10h] BYREF

printf("%s: hi\n", "main");
v3 = malloc(0x10uLL);
*v3 = 0;
v5 = v3;
init(v3);
reverse(&v5);
print_list(v5);
print_list_r(v5);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_DWORD *v3; // rax
_DWORD *v5; // [rsp+8h] [rbp-10h] BYREF

printf("%s: hi\n", "main");
v3 = malloc(0x10uLL);
*v3 = 0;
v5 = v3;
func7(v3);
func12(&v5);
func8(v5);
func9(v5);
return 0;
}

original_code:
int main(void) {
    printf("%s: hi\n", __FUNCTION__);
    LIST_ITEM * list_head = malloc (sizeof(LIST_ITEM));
    list_head->val = 0;
    ((void) sizeof ((list_head) ? 1 : 0), __extension__ ({ if (list_head) ; else __assert_fail ("list_head", "reverse.c", 145, __extension__ __PRETTY_FUNCTION__); }));
    init(list_head);
    reverse(&list_head);
    print_list(list_head);
    print_list_r(list_head);
}

canonical_original_code:
int main() {
    printf("%s: hi\n", __FUNCTION__);
    struct list_item *list_head = malloc (sizeof(LIST_ITEM));
    list_head->val = 0;
    ((void) sizeof ((list_head) ? 1 : 0), __extension__ ({ if (list_head) ; else __assert_fail ("list_head", "reverse.c", 145, __extension__ __PRETTY_FUNCTION__); }));
    init(list_head);
    reverse(&list_head);
    print_list(list_head);
    print_list_r(list_head);
}


show

repo: kobronson/isi-life

decompiled_code:
int __fastcall show(__int64 a1, int a2, int a3)
{
__int64 v3; // r14
int v4; // er12
__int64 v5; // r15
int v8; // [rsp+Ch] [rbp-3Ch]

if ( a2 > 0 )
{
v3 = 0LL;
v8 = a3 + 1;
while ( 1 )
{
v5 = 1LL;
if ( a3 > 0 )
break;
LABEL_11:
if ( ++v3 == a2 )
return wrefresh(stdscr);
}
while ( 1 )
{
v4 = v3 + 1;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8 * v5 - 8) + 4 * v3) )
break;
if ( wmove(my_win, v5, v4) == -1 )
{
LABEL_7:
if ( v8 == ++v5 )
goto LABEL_11;
}
else
{
++v5;
waddch(my_win, 0x20uLL);
if ( v8 == v5 )
goto LABEL_11;
}
}
if ( wmove(my_win, v5, v4) != -1 )
waddch(my_win, HIDWORD(acs_map[48]));
goto LABEL_7;
}
return wrefresh(stdscr);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, int a2, int a3)
{
__int64 v3; // r14
int v4; // er12
__int64 v5; // r15
int v8; // [rsp+Ch] [rbp-3Ch]

if ( a2 > 0 )
{
v3 = 0LL;
v8 = a3 + 1;
while ( 1 )
{
v5 = 1LL;
if ( a3 > 0 )
break;
LABEL_11:
if ( ++v3 == a2 )
return wrefresh(stdscr);
}
while ( 1 )
{
v4 = v3 + 1;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8 * v5 - 8) + 4 * v3) )
break;
if ( wmove(my_win, v5, v4) == -1 )
{
LABEL_7:
if ( v8 == ++v5 )
goto LABEL_11;
}
else
{
++v5;
waddch(my_win, 0x20uLL);
if ( v8 == v5 )
goto LABEL_11;
}
}
if ( wmove(my_win, v5, v4) != -1 )
waddch(my_win, HIDWORD(acs_map[48]));
goto LABEL_7;
}
return wrefresh(stdscr);
}

original_code:
void show(unsigned **world, int width, int height)
{
 for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) world[y][x] ? (wmove((my_win),(y+1),(x+1)) == (-1) ? (-1) : waddch((my_win),((acs_map[(unsigned char)(('a'))])))) : (wmove((my_win),(y+1),(x+1)) == (-1) ? (-1) : waddch((my_win),(' '))) ;
 wrefresh(stdscr);
}

canonical_original_code:
void show(unsigned int **world, int width, int height)
{
 for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) world[y][x] ? (wmove((my_win),(y+1),(x+1)) == (-1) ? (-1) : waddch((my_win),((acs_map[(unsigned char)(('a'))])))) : (wmove((my_win),(y+1),(x+1)) == (-1) ? (-1) : waddch((my_win),(' '))) ;
 wrefresh(stdscr);
}

variable_types:
world
unsigned int **

variable_types: width int

variable_types: height int

variable_types: x int

variable_types: y int


evolution

original_code:
void evolution(unsigned **world, int width, int height)
{
 unsigned new[height][width];
 for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) {
  int n = 0;
  for (int y1 = y - 1; y1 <= y + 1; y1++)
   for (int x1 = x - 1; x1 <= x + 1; x1++)
    if (world[(y1 + height) % height][(x1 + width) % width])
     n++;
  if (world[y][x]) n--;
  new[y][x] = (n == 3 || (n == 2 && world[y][x]));
 }
 for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) world[y][x] = new[y][x];
}

canonical_original_code:
void evolution(unsigned int **world, int width, int height)
{
 unsigned int new[-1][-1];
 for (int y = 0; y < height; y++) for (int x = 0; x < width; x++) {
  int n = 0;
  for (int y1 = y - 1; y1 <= y + 1; y1++)
   for (int x1 = x - 1; x1 <= x + 1; x1++)
    if (world[(y1 + height) % height][(x1 + width) % width])
     n++;
  if (world[y][x]) n--;
  new[y][x] = (n == 3 || (n == 2 && world[y][x]));
 }
 for (int x = 0; x < width; x++) for (int y = 0; y < height; y++) world[y][x] = new[y][x];
}

variable_types:
new
unsigned int [-1][-1]

variable_types: n int


decompiled_code:
__int64 __fastcall run_step(__int64 *a1, int a2, int a3)
{
show((__int64)a1, a2, a3);
return evolution(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, int a2, int a3)
{
func0((__int64)a1, a2, a3);
return func1(a1, a2, a3);
}

original_code:
void run_step(unsigned **world,int width, int height)
{
 show(world, width, height);
 evolution(world, width, height);
}

canonical_original_code:
void run_step(unsigned int **world, int width, int height)
{
 show(world, width, height);
 evolution(world, width, height);
}