original_code:
double umfzl_usolve
(
    NumericType *Numeric,
    DoubleComplex X [ ],
    long Pattern [ ]
)
{
    DoubleComplex xk ;
    DoubleComplex *xp, *D, *Uval ;
    long k, deg, j, *ip, col, *Upos, *Uilen, pos,
 *Uip, n, ulen, up, newUchain, npiv, n1, *Ui ;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    n = Numeric->n_row ;
    npiv = Numeric->npiv ;
    Upos = Numeric->Upos ;
    Uilen = Numeric->Uilen ;
    Uip = Numeric->Uip ;
    D = Numeric->D ;
    n1 = Numeric->n1 ;
    for (k = n-1 ; k >= npiv ; k--)
    {
 ;
 xk = X [k] ;
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
    }
    deg = Numeric->ulen ;
    if (deg > 0)
    {
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     Pattern [j] = Numeric->Upattern [j] ;
 }
    }
    for (k = npiv-1 ; k >= n1 ; k--)
    {
 up = Uip [k] ;
 ulen = Uilen [k] ;
 newUchain = (up < 0) ;
 if (newUchain)
 {
     up = -up ;
     xp = (DoubleComplex *) (Numeric->Memory + up + (((((sizeof (long) * (ulen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
 }
 else
 {
     xp = (DoubleComplex *) (Numeric->Memory + up) ;
 }
 xk = X [k] ;
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     ;
     { ; (xk).component [0] -= (X [Pattern [j]]).component [0] * (*xp).component [0] - (X [Pattern [j]]).component [1] * (*xp).component [1] ; (xk).component [1] -= (X [Pattern [j]]).component [1] * (*xp).component [0] + (X [Pattern [j]]).component [0] * (*xp).component [1] ; } ;
     xp++ ;
 }
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
 if (k == n1) break ;
 if (newUchain)
 {
     deg = ulen ;
     ;
     ;
     ip = (long *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  col = *ip++ ;
  ;
  ;
  Pattern [j] = col ;
     }
 }
 else
 {
     deg -= ulen ;
     ;
     ;
     pos = Upos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 deg = Uilen [k] ;
 xk = X [k] ;
 ;
 if (deg > 0)
 {
     up = Uip [k] ;
     Ui = (long *) (Numeric->Memory + up) ;
     up += (((((sizeof (long) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Uval = (DoubleComplex *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  ;
  { ; (xk).component [0] -= (X [Ui [j]]).component [0] * (Uval [j]).component [0] - (X [Ui [j]]).component [1] * (Uval [j]).component [1] ; (xk).component [1] -= (X [Ui [j]]).component [1] * (Uval [j]).component [0] + (X [Ui [j]]).component [0] * (Uval [j]).component [1] ; } ;
     }
 }
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
    }
    return (9. * ((double) n) + 8. * ((double) Numeric->unz));
}

canonical_original_code:
double umfzl_usolve(struct NumericType *Numeric, struct DoubleComplex X[], long Pattern[])
{
    struct DoubleComplex xk;
    struct DoubleComplex *xp; struct DoubleComplex *D; struct DoubleComplex *Uval;
    long k; long deg; long j; long *ip; long col; long *Upos; long *Uilen; long pos; long *Uip; long n; long ulen; long up; long newUchain; long npiv; long n1; long *Ui;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    n = Numeric->n_row ;
    npiv = Numeric->npiv ;
    Upos = Numeric->Upos ;
    Uilen = Numeric->Uilen ;
    Uip = Numeric->Uip ;
    D = Numeric->D ;
    n1 = Numeric->n1 ;
    for (k = n-1 ; k >= npiv ; k--)
    {
 ;
 xk = X [k] ;
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
    }
    deg = Numeric->ulen ;
    if (deg > 0)
    {
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     Pattern [j] = Numeric->Upattern [j] ;
 }
    }
    for (k = npiv-1 ; k >= n1 ; k--)
    {
 up = Uip [k] ;
 ulen = Uilen [k] ;
 newUchain = (up < 0) ;
 if (newUchain)
 {
     up = -up ;
     xp = (struct DoubleComplex *) (Numeric->Memory + up + (((((sizeof (long) * (ulen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
 }
 else
 {
     xp = (struct DoubleComplex *) (Numeric->Memory + up) ;
 }
 xk = X [k] ;
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     ;
     { ; (xk).component [0] -= (X [Pattern [j]]).component [0] * (*xp).component [0] - (X [Pattern [j]]).component [1] * (*xp).component [1] ; (xk).component [1] -= (X [Pattern [j]]).component [1] * (*xp).component [0] + (X [Pattern [j]]).component [0] * (*xp).component [1] ; } ;
     xp++ ;
 }
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
 if (k == n1) break ;
 if (newUchain)
 {
     deg = ulen ;
     ;
     ;
     ip = (long *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  col = *ip++ ;
  ;
  ;
  Pattern [j] = col ;
     }
 }
 else
 {
     deg -= ulen ;
     ;
     ;
     pos = Upos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 deg = Uilen [k] ;
 xk = X [k] ;
 ;
 if (deg > 0)
 {
     up = Uip [k] ;
     Ui = (long *) (Numeric->Memory + up) ;
     up += (((((sizeof (long) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Uval = (struct DoubleComplex *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  ;
  { ; (xk).component [0] -= (X [Ui [j]]).component [0] * (Uval [j]).component [0] - (X [Ui [j]]).component [1] * (Uval [j]).component [1] ; (xk).component [1] -= (X [Ui [j]]).component [1] * (Uval [j]).component [0] + (X [Ui [j]]).component [0] * (Uval [j]).component [1] ; } ;
     }
 }
 { (void) umfpack_divcomplex ((xk).component [0], (xk).component [1], (D [k]).component [0], (D [k]).component [1], &((X [k]).component [0]), &((X [k]).component [1])) ; } ;
    }
    return (9. * ((double) n) + 8. * ((double) Numeric->unz));
}

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:
X
struct DoubleComplex []

variable_types:
Pattern
long []

variable_types: k long

variable_types: deg long

variable_types: j long

variable_types:
ip
long *

variable_types: col long

variable_types:
Upos
long *

variable_types:
Uilen
long *

variable_types: pos long

variable_types:
Uip
long *

variable_types: n long

variable_types: ulen long

variable_types: up long

variable_types: newUchain long

variable_types: npiv long

variable_types:
Ui
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:
_QWORD *reset_count_flag()
{
__int64 *v0; // rdx
_QWORD *result; // rax
__int64 v2; // r8
__int64 v3; // r9
int v4; // edx
_QWORD *v5; // rsi
__int64 v6; // rdi
__int64 v7; // rdx
int v8; // eax
__int64 v9; // rdx
__int64 v10; // rcx
__int64 v11; // rax
__int64 v12; // rcx

v0 = (__int64 *)*FPGA;
result = *(_QWORD **)(*FPGA + 8LL);
if ( result )
{
v2 = *v0;
v3 = *v0 + 8LL * (_QWORD)result;
do
{
result = *(_QWORD **)v2;
v4 = *(_DWORD *)(*(_QWORD *)v2 + 16LL);
if ( v4 > 0 )
{
result = (_QWORD *)result[1];
v5 = result + 1;
v6 = (__int64)&result[(unsigned int)(v4 - 1) + 1];
while ( 1 )
{
v7 = *result;
v8 = *(_DWORD *)(*result + 24LL);
if ( v8 > 0 )
{
v9 = *(_QWORD *)(v7 + 16);
v10 = (unsigned int)(v8 - 1);
v11 = v9 + 8;
v12 = v9 + 8 + 8 * v10;
while ( 1 )
{
*(_DWORD *)(*(_QWORD *)v9 + 96LL) = 0;
v9 = v11;
if ( v12 == v11 )
break;
v11 += 8LL;
}
}
result = v5;
if ( v5 == (_QWORD *)v6 )
break;
++v5;
}
}
v2 += 8LL;
}
while ( v2 != v3 );
}
return result;
}

original_code:
void reset_count_flag(void) {
    t_blocklist* blocklist = FPGA->blocklist;
    int block_index;
    for(block_index = 0; block_index < blocklist->num_blocks; block_index++) {
        t_block* block = blocklist->array_of_blocks[block_index];
        int pin_index;
        for(pin_index = 0; pin_index < block->num_pins; pin_index++) {
            t_pin* pin = block->array_of_pins[pin_index];
            int adjacent_wire_index;
            for(adjacent_wire_index = 0; adjacent_wire_index < pin->num_adjacent_wires; adjacent_wire_index++) {
                t_wire* wire = pin->array_of_adjacent_wires[adjacent_wire_index];
                wire->counted = 0;
            }
        }
    }
}

canonical_original_code:
void reset_count_flag() {
    struct s_blocklist *blocklist = FPGA->blocklist;
    int block_index;
    for(block_index = 0; block_index < blocklist->num_blocks; block_index++) {
        struct s_block *block = blocklist->array_of_blocks[block_index];
        int pin_index;
        for(pin_index = 0; pin_index < block->num_pins; pin_index++) {
            struct s_pin *pin = block->array_of_pins[pin_index];
            int adjacent_wire_index;
            for(adjacent_wire_index = 0; adjacent_wire_index < pin->num_adjacent_wires; adjacent_wire_index++) {
                struct s_wire *wire = pin->array_of_adjacent_wires[adjacent_wire_index];
                wire->counted = 0;
            }
        }
    }
}

variable_types: struct s_blocklist { struct s_block { int x_coord; int y_coord; struct s_pin { struct s_block *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_pins; int num_pins; } **array_of_blocks; unsigned long num_blocks; } *

variable_types: struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } *

variable_types: struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } *

return_type: void

user_defined_types: struct s_blocklist { struct s_block **array_of_blocks; unsigned long num_blocks; }

user_defined_types: struct s_pin { struct s_block *block; int pin_num; struct s_wire **array_of_adjacent_wires; int num_adjacent_wires; struct s_net *associated_net; }

user_defined_types: struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL label_type; double label_value; int counted; }


original_code:
int count_overused_resources(void) {
    reset_count_flag();
    int resource_overuse_count = 0;
    t_blocklist* blocklist = FPGA->blocklist;
    int block_index;
    for(block_index = 0; block_index < blocklist->num_blocks; block_index++) {
        t_block* block = blocklist->array_of_blocks[block_index];
        int pin_index;
        for(pin_index = 0; pin_index < block->num_pins; pin_index++) {
            t_pin* pin = block->array_of_pins[pin_index];
            int adjacent_wire_index;
            for(adjacent_wire_index = 0; adjacent_wire_index < pin->num_adjacent_wires; adjacent_wire_index++) {
                t_wire* wire = pin->array_of_adjacent_wires[adjacent_wire_index];
                if(wire->counted == 0) {
                    if(wire->occupancy > 1) {
                        resource_overuse_count++;
                        wire->counted++;
                    }
                }
            }
        }
    }
    return resource_overuse_count;
}

canonical_original_code:
int count_overused_resources() {
    reset_count_flag();
    int resource_overuse_count = 0;
    struct s_blocklist *blocklist = FPGA->blocklist;
    int block_index;
    for(block_index = 0; block_index < blocklist->num_blocks; block_index++) {
        struct s_block *block = blocklist->array_of_blocks[block_index];
        int pin_index;
        for(pin_index = 0; pin_index < block->num_pins; pin_index++) {
            struct s_pin *pin = block->array_of_pins[pin_index];
            int adjacent_wire_index;
            for(adjacent_wire_index = 0; adjacent_wire_index < pin->num_adjacent_wires; adjacent_wire_index++) {
                struct s_wire *wire = pin->array_of_adjacent_wires[adjacent_wire_index];
                if(wire->counted == 0) {
                    if(wire->occupancy > 1) {
                        resource_overuse_count++;
                        wire->counted++;
                    }
                }
            }
        }
    }
    return resource_overuse_count;
}

variable_types: struct s_block { int x_coord; int y_coord; struct s_pin { struct s_block *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_pins; int num_pins; } *

return_type: int

user_defined_types: struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; }


decompiled_code:
double __fastcall calc_Pfac(int a1)
{
double result; // xmm0_8

result = *(double *)&LC0;
if ( a1 != 1 )
result = (double)(2 * a1 - 2);
return result;
}

canonical_decompiled_code:
double __fastcall func2(int a1)
{
double result; // xmm0_8

result = *(double *)&LC0;
if ( a1 != 1 )
result = (double)(2 * a1 - 2);
return result;
}

original_code:
double calc_Pfac(int routing_iteration) {
    double Pfac;
    if(routing_iteration == 1) {
        Pfac = 1;
    } else {
        Pfac = 1 * ((routing_iteration - 1)*2);
    }
    return Pfac;
}

variable_types: Pfac double

return_type: double


decompiled_code:
double __fastcall calc_Rfac(int a1)
{
double v1; // xmm0_8

v1 = pow(0.1, (double)(a1 - 1));
return v1 + v1 + 1.0;
}

canonical_decompiled_code:
double __fastcall func3(int a1)
{
double v1; // xmm0_8

v1 = pow(0.1, (double)(a1 - 1));
return v1 + v1 + 1.0;
}

original_code:
double calc_Rfac(int routing_iteration) {
    double Rfac;
    Rfac = 1.0 + 2.00*pow(0.1, routing_iteration-1);
    return Rfac;
}

variable_types: Rfac double


decompiled_code:
void __fastcall update_cost_for_wire(__int64 a1, int a2)
{
double v2; // xmm1_8
double v3; // xmm0_8
double v4; // xmm2_8
double v5; // xmm1_8
double v6; // xmm0_8

calc_Rfac(a2);
if ( a2 == 1 )
{
*(_QWORD *)(a1 + 64) = LC0;
*(_QWORD *)(a1 + 72) = LC0;
}
else
{
v2 = *(double *)(a1 + 56);
v3 = calc_Pfac(a2);
v4 = v2 + 1.0;
v5 = v2 * 0.5 + *(double *)(a1 + 72);
*(double *)(a1 + 72) = v5;
v6 = v3 * v4 + 1.0;
*(double *)(a1 + 64) = v6;
if ( v5 < 0.0 )
_assert_fail("wire->history_cost >= 0", "SRC/base/pathfinder.c", 0xEAu, "update_cost_for_wire");
if ( v6 < 0.0 )
_assert_fail("wire->present_cost >= 0", "SRC/base/pathfinder.c", 0xEBu, "update_cost_for_wire");
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, int a2)
{
double v2; // xmm1_8
double v3; // xmm0_8
double v4; // xmm2_8
double v5; // xmm1_8
double v6; // xmm0_8

func3(a2);
if ( a2 == 1 )
{
*(_QWORD *)(a1 + 64) = LC0;
*(_QWORD *)(a1 + 72) = LC0;
}
else
{
v2 = *(double *)(a1 + 56);
v3 = func2(a2);
v4 = v2 + 1.0;
v5 = v2 * 0.5 + *(double *)(a1 + 72);
*(double *)(a1 + 72) = v5;
v6 = v3 * v4 + 1.0;
*(double *)(a1 + 64) = v6;
if ( v5 < 0.0 )
_assert_fail("wire->history_cost >= 0", "SRC/base/pathfinder.c", 0xEAu, "update_cost_for_wire");
if ( v6 < 0.0 )
_assert_fail("wire->present_cost >= 0", "SRC/base/pathfinder.c", 0xEBu, "update_cost_for_wire");
}
}

original_code:
void update_cost_for_wire(t_wire* wire, int routing_iteration) {
    double Hfac = 0.5;
    double Pfac = calc_Pfac(routing_iteration);
    double Rfac = calc_Rfac(routing_iteration);
    if (routing_iteration == 1) {
        wire->present_cost = 1.0;
        wire->history_cost = 1.0;
    } else {
        wire->present_cost = 1 + (wire->occupancy + 1)*Pfac;
        wire->history_cost = wire->history_cost + wire->occupancy*Hfac;
    }
    ((void) sizeof ((wire->history_cost >= 0) ? 1 : 0), __extension__ ({ if (wire->history_cost >= 0) ; else __assert_fail ("wire->history_cost >= 0", "SRC/base/pathfinder.c", 234, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((wire->present_cost >= 0) ? 1 : 0), __extension__ ({ if (wire->present_cost >= 0) ; else __assert_fail ("wire->present_cost >= 0", "SRC/base/pathfinder.c", 235, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void update_cost_for_wire(struct s_wire *wire, int routing_iteration) {
    double Hfac = 0.5;
    double Pfac = calc_Pfac(routing_iteration);
    double Rfac = calc_Rfac(routing_iteration);
    if (routing_iteration == 1) {
        wire->present_cost = 1.0;
        wire->history_cost = 1.0;
    } else {
        wire->present_cost = 1 + (wire->occupancy + 1)*Pfac;
        wire->history_cost = wire->history_cost + wire->occupancy*Hfac;
    }
    ((void) sizeof ((wire->history_cost >= 0) ? 1 : 0), __extension__ ({ if (wire->history_cost >= 0) ; else __assert_fail ("wire->history_cost >= 0", "SRC/base/pathfinder.c", 234, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((wire->present_cost >= 0) ? 1 : 0), __extension__ ({ if (wire->present_cost >= 0) ; else __assert_fail ("wire->present_cost >= 0", "SRC/base/pathfinder.c", 235, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: Hfac double

user_defined_types: enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 }

user_defined_types: struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; }

user_defined_types: struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; }


decompiled_code:
void __fastcall update_costs_for_net(__int64 a1, int a2)
{
__int64 v3; // rbx
__int64 v4; // rdi

if ( *(int *)(a1 + 32) > 0 )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8 * v3++);
update_cost_for_wire(v4, a2);
}
while ( *(_DWORD *)(a1 + 32) > (int)v3 );
}
}

original_code:
void update_costs_for_net(t_net* net, int routing_iteration) {
    int wire_index;
    for(wire_index = 0; wire_index < net->num_associated_wires; wire_index++) {
        t_wire* wire = net->associated_wires[wire_index];
        update_cost_for_wire(wire, routing_iteration);
    }
}

canonical_original_code:
void update_costs_for_net(struct s_net *net, int routing_iteration) {
    int wire_index;
    for(wire_index = 0; wire_index < net->num_associated_wires; wire_index++) {
        struct s_wire *wire = net->associated_wires[wire_index];
        update_cost_for_wire(wire, routing_iteration);
    }
}

variable_types: struct s_net { struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net *associated_net; } *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *


original_code:
void copy_net(t_net* tmp_net, t_net* routed_net) {
    tmp_net->source_pin = routed_net->source_pin;
    tmp_net->sink_pin = routed_net->sink_pin;
    tmp_net->net_num = routed_net->net_num;
    tmp_net->num_associated_wires = routed_net->num_associated_wires;
    int wire_index;
    for(wire_index = 0; wire_index < tmp_net->num_associated_wires; wire_index++) {
        tmp_net->associated_wires[wire_index] = routed_net->associated_wires[wire_index];
    }
}

canonical_original_code:
void copy_net(struct s_net *tmp_net, struct s_net *routed_net) {
    tmp_net->source_pin = routed_net->source_pin;
    tmp_net->sink_pin = routed_net->sink_pin;
    tmp_net->net_num = routed_net->net_num;
    tmp_net->num_associated_wires = routed_net->num_associated_wires;
    int wire_index;
    for(wire_index = 0; wire_index < tmp_net->num_associated_wires; wire_index++) {
        tmp_net->associated_wires[wire_index] = routed_net->associated_wires[wire_index];
    }
}


decompiled_code:
__int64 pathfinder_route()
{
unsigned int v0; // er13
_QWORD *v1; // r12
int v2; // er14
unsigned __int64 v3; // rbx
__int64 v4; // rbp
int v5; // ebp
int v6; // ebx
__int64 v7; // rax
float v8; // xmm0_4
float v9; // xmm0_4
__int64 v11; // rdx
double v12; // [rsp+8h] [rbp-30h]

v0 = 0;
v1 = *(_QWORD **)(FPGA + 16LL);
start_interactive_graphics();
do
{
printf("--------------- ROUTING ITERATION %d START ---------------\n", ++v0);
v12 = calc_Pfac(v0);
Rfac = calc_Rfac(v0);
printf("Updating cost for wire: Hfac: %.2f Pfac: %.2f Rfac: %.2f\n", *(double *)&LC2, v12, *(double *)&Rfac);
update_costs(v0);
printf("Routing nets");
v2 = clock();
if ( v1[1] )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*v1 + 8 * v3);
copy_net(v1[2], v4);
rip_up_net(v4);
putchar(46);
fflush(stdout);
if ( !(unsigned int)try_route_net(v4, 0LL) )
{
puts("\n\tError: could not route net");
_assert_fail("0", "SRC/base/pathfinder.c", 0x43u, "pathfinder_route");
}
++v3;
update_costs(v0);
}
while ( v1[1] > v3 );
}
putchar(10);
v5 = clock();
v6 = count_overused_resources();
printf("--------------- ROUTING ITERATION %d END ---------------\n", v0);
printf("\t%d resources overused\n", (unsigned int)v6);
if ( interactive_graphics )
start_interactive_graphics();
v7 = v1[1];
if ( v7 < 0 )
{
v11 = v1[1] & 1LL | (v1[1] >> 1);
v8 = (float)(int)v11 + (float)(int)v11;
}
else
{
v8 = (float)(int)v7;
}
v9 = v8 / (((double)v5 - (double)v2) * 0.000001);
printf("\tProcessed %.2f nets per second\n", v9);
}
while ( v6 > 0 );
printf("\nRouting Completed after %d iterations\n", v0);
start_interactive_graphics();
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // er13
_QWORD *v1; // r12
int v2; // er14
unsigned __int64 v3; // rbx
__int64 v4; // rbp
int v5; // ebp
int v6; // ebx
__int64 v7; // rax
float v8; // xmm0_4
float v9; // xmm0_4
__int64 v11; // rdx
double v12; // [rsp+8h] [rbp-30h]

v0 = 0;
v1 = *(_QWORD **)(FPGA + 16LL);
start_interactive_graphics();
do
{
printf("--------------- ROUTING ITERATION %d START ---------------\n", ++v0);
v12 = func2(v0);
Rfac = func3(v0);
printf("Updating cost for wire: Hfac: %.2f Pfac: %.2f Rfac: %.2f\n", *(double *)&LC2, v12, *(double *)&Rfac);
update_costs(v0);
printf("Routing nets");
v2 = clock();
if ( v1[1] )
{
v3 = 0LL;
do
{
v4 = *(_QWORD *)(*v1 + 8 * v3);
func6(v1[2], v4);
rip_up_net(v4);
putchar(46);
fflush(stdout);
if ( !(unsigned int)try_route_net(v4, 0LL) )
{
puts("\n\tError: could not route net");
_assert_fail("0", "SRC/base/pathfinder.c", 0x43u, "pathfinder_route");
}
++v3;
update_costs(v0);
}
while ( v1[1] > v3 );
}
putchar(10);
v5 = clock();
v6 = func1();
printf("--------------- ROUTING ITERATION %d END ---------------\n", v0);
printf("\t%d resources overused\n", (unsigned int)v6);
if ( interactive_graphics )
start_interactive_graphics();
v7 = v1[1];
if ( v7 < 0 )
{
v11 = v1[1] & 1LL | (v1[1] >> 1);
v8 = (float)(int)v11 + (float)(int)v11;
}
else
{
v8 = (float)(int)v7;
}
v9 = v8 / (((double)v5 - (double)v2) * 0.000001);
printf("\tProcessed %.2f nets per second\n", v9);
}
while ( v6 > 0 );
printf("\nRouting Completed after %d iterations\n", v0);
start_interactive_graphics();
return v0;
}

original_code:
int pathfinder_route(void) {
    int routing_iteration = 0;
    int overused_resource_count;
    t_netlist* netlist = FPGA->netlist;
    start_interactive_graphics();
    while(routing_iteration == 0 || overused_resource_count > 0) {
        routing_iteration++;
        printf("--------------- ROUTING ITERATION %d START ---------------\n", routing_iteration);
        double Hfac = 0.5;
        double Pfac = calc_Pfac(routing_iteration);
        Rfac = calc_Rfac(routing_iteration);
        printf("Updating cost for wire: Hfac: %.2f Pfac: %.2f Rfac: %.2f\n", Hfac, Pfac, Rfac);
        update_costs(routing_iteration);
        printf("Routing nets");
        clock_t cstart = clock();
        int net_index;
        for(net_index = 0; net_index < netlist->num_nets; net_index++) {
            t_net* net_to_route = netlist->array_of_nets[net_index];
            copy_net(netlist->tmp_net, net_to_route);
            rip_up_net(net_to_route);
            printf(".");
            fflush(stdout);
            if (try_route_net(net_to_route, 0)) {
            } else {
                printf("\n\tError: could not route net\n");
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "SRC/base/pathfinder.c", 67, __extension__ __PRETTY_FUNCTION__); }));
            }
            update_costs(routing_iteration);
        }
        printf("\n");
        clock_t cend = clock();
        overused_resource_count = count_overused_resources();
        printf("---------------  ROUTING ITERATION %d END  ---------------\n", routing_iteration);
        printf("\t%d resources overused\n", overused_resource_count);
        if(interactive_graphics) {
            start_interactive_graphics();
        }
        float nets_per_sec = ((float) netlist->num_nets) / (((double)cend - (double)cstart)* 1.0e-6);
        printf("\tProcessed %.2f nets per second\n", nets_per_sec);
    }
    printf("\nRouting Completed after %d iterations\n", routing_iteration);
    start_interactive_graphics();
    return routing_iteration;
}

canonical_original_code:
int pathfinder_route() {
    int routing_iteration = 0;
    int overused_resource_count;
    struct s_netlist *netlist = FPGA->netlist;
    start_interactive_graphics();
    while(routing_iteration == 0 || overused_resource_count > 0) {
        routing_iteration++;
        printf("--------------- ROUTING ITERATION %d START ---------------\n", routing_iteration);
        double Hfac = 0.5;
        double Pfac = calc_Pfac(routing_iteration);
        Rfac = calc_Rfac(routing_iteration);
        printf("Updating cost for wire: Hfac: %.2f Pfac: %.2f Rfac: %.2f\n", Hfac, Pfac, Rfac);
        update_costs(routing_iteration);
        printf("Routing nets");
        long cstart = clock();
        int net_index;
        for(net_index = 0; net_index < netlist->num_nets; net_index++) {
            struct s_net *net_to_route = netlist->array_of_nets[net_index];
            copy_net(netlist->tmp_net, net_to_route);
            rip_up_net(net_to_route);
            printf(".");
            fflush(stdout);
            if (try_route_net(net_to_route, 0)) {
            } else {
                printf("\n\tError: could not route net\n");
                ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "SRC/base/pathfinder.c", 67, __extension__ __PRETTY_FUNCTION__); }));
            }
            update_costs(routing_iteration);
        }
        printf("\n");
        long cend = clock();
        overused_resource_count = count_overused_resources();
        printf("---------------  ROUTING ITERATION %d END  ---------------\n", routing_iteration);
        printf("\t%d resources overused\n", overused_resource_count);
        if(interactive_graphics) {
            start_interactive_graphics();
        }
        float nets_per_sec = ((float) netlist->num_nets) / (((double)cend - (double)cstart)* 1.0e-6);
        printf("\tProcessed %.2f nets per second\n", nets_per_sec);
    }
    printf("\nRouting Completed after %d iterations\n", routing_iteration);
    start_interactive_graphics();
    return routing_iteration;
}

variable_types: struct s_netlist { struct s_net { struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net *associated_net; } *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } **array_of_nets; unsigned long num_nets; struct s_net *tmp_net; } *

variable_types: cstart long

variable_types: cend long

user_defined_types: struct s_netlist { struct s_net **array_of_nets; unsigned long num_nets; struct s_net *tmp_net; }


original_code:
long umfdl_mem_alloc_tail_block
(
    NumericType *Numeric,
    long nunits
)
{
    long 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:
long umfdl_mem_alloc_tail_block(struct NumericType *Numeric, long nunits)
{
    long bigsize; long 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; 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: nunits long

variable_types: bigsize 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; double *D; long do_recip; double *Rs; long n_row; long tail_usage; long maxnrows; }


original_code:
double
umfdi_lhsolve
(
    NumericType *Numeric,
    double X [ ],
    int Pattern [ ]
)
{
    double xk ;
    double *xp, *Lval ;
    int k, deg, *ip, j, row, *Lpos, *Lilen, kstart, kend, *Lip, llen,
 lp, pos, npiv, n1, *Li ;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    npiv = Numeric->npiv ;
    Lpos = Numeric->Lpos ;
    Lilen = Numeric->Lilen ;
    Lip = Numeric->Lip ;
    kstart = npiv ;
    n1 = Numeric->n1 ;
    for (kend = npiv-1 ; kend >= n1 ; kend = kstart-1)
    {
 kstart = kend ;
 while (kstart >= 0 && Lip [kstart] > 0)
 {
     kstart-- ;
 }
 deg = 0 ;
 ;
 for (k = kstart ; k <= kend ; k++)
 {
     ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  ;
  ;
  Pattern [pos] = Pattern [--deg] ;
     }
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     ip = (int *) (Numeric->Memory + lp) ;
     llen = Lilen [k] ;
     for (j = 0 ; j < llen ; j++)
     {
  row = *ip++ ;
  ;
  ;
  Pattern [deg++] = row ;
     }
 }
 ;
 for (k = kend ; k >= kstart ; k--)
 {
     ;
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     llen = Lilen [k] ;
     xp = (double *) (Numeric->Memory + lp + (((((sizeof (int) * (llen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     xk = X [k] ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
  xp++ ;
     }
     X [k] = xk ;
     deg -= llen ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 ;
 deg = Lilen [k] ;
 if (deg > 0)
 {
     xk = X [k] ;
     lp = Lip [k] ;
     Li = (int *) (Numeric->Memory + lp) ;
     lp += (((((sizeof (int) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Lval = (double *) (Numeric->Memory + lp) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Li [j]]) * (Lval [j]) ; } ;
     }
     X [k] = xk ;
 }
    }
    return (2. * ((double) Numeric->lnz)) ;
}

canonical_original_code:
double umfdi_lhsolve(struct NumericType *Numeric, double X[], int Pattern[])
{
    double xk;
    double *xp; double *Lval;
    int k; int deg; int *ip; int j; int row; int *Lpos; int *Lilen; int kstart; int kend; int *Lip; int llen; int lp; int pos; int npiv; int n1; int *Li;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    npiv = Numeric->npiv ;
    Lpos = Numeric->Lpos ;
    Lilen = Numeric->Lilen ;
    Lip = Numeric->Lip ;
    kstart = npiv ;
    n1 = Numeric->n1 ;
    for (kend = npiv-1 ; kend >= n1 ; kend = kstart-1)
    {
 kstart = kend ;
 while (kstart >= 0 && Lip [kstart] > 0)
 {
     kstart-- ;
 }
 deg = 0 ;
 ;
 for (k = kstart ; k <= kend ; k++)
 {
     ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  ;
  ;
  Pattern [pos] = Pattern [--deg] ;
     }
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     ip = (int *) (Numeric->Memory + lp) ;
     llen = Lilen [k] ;
     for (j = 0 ; j < llen ; j++)
     {
  row = *ip++ ;
  ;
  ;
  Pattern [deg++] = row ;
     }
 }
 ;
 for (k = kend ; k >= kstart ; k--)
 {
     ;
     lp = Lip [k] ;
     if (k == kstart)
     {
  lp = -lp ;
     }
     ;
     llen = Lilen [k] ;
     xp = (double *) (Numeric->Memory + lp + (((((sizeof (int) * (llen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     xk = X [k] ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
  xp++ ;
     }
     X [k] = xk ;
     deg -= llen ;
     pos = Lpos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 ;
 deg = Lilen [k] ;
 if (deg > 0)
 {
     xk = X [k] ;
     lp = Lip [k] ;
     Li = (int *) (Numeric->Memory + lp) ;
     lp += (((((sizeof (int) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Lval = (double *) (Numeric->Memory + lp) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  { (xk) -= (X [Li [j]]) * (Lval [j]) ; } ;
     }
     X [k] = xk ;
 }
    }
    return (2. * ((double) Numeric->lnz)) ;
}

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:
X
double []

variable_types:
Pattern
int []

variable_types: xk double

variable_types:
xp
double *

variable_types:
Lval
double *

variable_types: k int

variable_types: deg int

variable_types:
ip
int *

variable_types: j int

variable_types: row int

variable_types:
Lpos
int *

variable_types:
Lilen
int *

variable_types: kstart int

variable_types: kend int

variable_types:
Lip
int *

variable_types: llen int

variable_types: lp int

variable_types: pos int

variable_types: npiv int

variable_types:
Li
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; }


decompiled_code:
void *__fastcall my_calloc(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
{
printf("Error: calloc of size %ux%u bytes failed\n", (unsigned int)a1, (unsigned int)a2);
_assert_fail("0", "SRC/base/util.c", 0x1Eu, "my_calloc");
}
return result;
}

canonical_decompiled_code:
void *__fastcall func2(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
{
printf("Error: calloc of size %ux%u bytes failed\n", (unsigned int)a1, (unsigned int)a2);
_assert_fail("0", "SRC/base/util.c", 0x1Eu, "my_calloc");
}
return result;
}

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 *

return_type: void *


decompiled_code:
__int64 __fastcall get_block_index(int a1, int a2)
{
return (unsigned int)(*(_DWORD *)(FPGA + 28LL) * (a2 - 1) + a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
return (unsigned int)(*(_DWORD *)(FPGA + 28LL) * (a2 - 1) + a1 - 1);
}

original_code:
int get_block_index(int x_coord, int y_coord) {
    return (FPGA->grid_size * (y_coord - 1)) + (x_coord - 1);
}


decompiled_code:
__int64 __fastcall get_block(int a1, int a2)
{
int v2; // eax

v2 = get_block_index(a1, a2);
if ( (unsigned __int64)v2 >= *(_QWORD *)(*FPGA + 8LL) )
_assert_fail("index < FPGA->blocklist->num_blocks", "SRC/base/util.c", 0x46u, "get_block");
return *(_QWORD *)(*(_QWORD *)*FPGA + 8LL * v2);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
int v2; // eax

v2 = func3(a1, a2);
if ( (unsigned __int64)v2 >= *(_QWORD *)(*FPGA + 8LL) )
_assert_fail("index < FPGA->blocklist->num_blocks", "SRC/base/util.c", 0x46u, "get_block");
return *(_QWORD *)(*(_QWORD *)*FPGA + 8LL * v2);
}

original_code:
t_block* get_block(int x_coord, int y_coord) {
    int index = get_block_index(x_coord, y_coord);
    ((void) sizeof ((index < FPGA->blocklist->num_blocks) ? 1 : 0), __extension__ ({ if (index < FPGA->blocklist->num_blocks) ; else __assert_fail ("index < FPGA->blocklist->num_blocks", "SRC/base/util.c", 70, __extension__ __PRETTY_FUNCTION__); }));
    return FPGA->blocklist->array_of_blocks[index];
}

canonical_original_code:
struct s_block *get_block(int x_coord, int y_coord) {
    int index = get_block_index(x_coord, y_coord);
    ((void) sizeof ((index < FPGA->blocklist->num_blocks) ? 1 : 0), __extension__ ({ if (index < FPGA->blocklist->num_blocks) ; else __assert_fail ("index < FPGA->blocklist->num_blocks", "SRC/base/util.c", 70, __extension__ __PRETTY_FUNCTION__); }));
    return FPGA->blocklist->array_of_blocks[index];
}

variable_types: index int

return_type: struct s_block { int x_coord; int y_coord; struct s_pin { struct s_block *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_pins; int num_pins; } *


decompiled_code:
__int64 __fastcall get_block_pin(int a1, int a2, int a3)
{
int v3; // ebx
__int64 v4; // rax

if ( a3 <= 0 )
_assert_fail("pin_num > 0", "SRC/base/util.c", 0x4Fu, "get_block_pin");
v3 = a3 - 1;
v4 = get_block(a1, a2);
if ( *(_DWORD *)(v4 + 16) <= v3 )
_assert_fail("pin_num < block->num_pins", "SRC/base/util.c", 0x54u, "get_block_pin");
return *(_QWORD *)(*(_QWORD *)(v4 + 8) + 8LL * v3);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2, int a3)
{
int v3; // ebx
__int64 v4; // rax

if ( a3 <= 0 )
_assert_fail("pin_num > 0", "SRC/base/util.c", 0x4Fu, "get_block_pin");
v3 = a3 - 1;
v4 = func4(a1, a2);
if ( *(_DWORD *)(v4 + 16) <= v3 )
_assert_fail("pin_num < block->num_pins", "SRC/base/util.c", 0x54u, "get_block_pin");
return *(_QWORD *)(*(_QWORD *)(v4 + 8) + 8LL * v3);
}

original_code:
t_pin* get_block_pin(int x_coord, int y_coord, int pin_num) {
    ((void) sizeof ((pin_num > 0) ? 1 : 0), __extension__ ({ if (pin_num > 0) ; else __assert_fail ("pin_num > 0", "SRC/base/util.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    pin_num -= 1;
    t_block* block = get_block(x_coord, y_coord);
    ((void) sizeof ((pin_num < block->num_pins) ? 1 : 0), __extension__ ({ if (pin_num < block->num_pins) ; else __assert_fail ("pin_num < block->num_pins", "SRC/base/util.c", 84, __extension__ __PRETTY_FUNCTION__); }));
    return block->array_of_pins[pin_num];
}

canonical_original_code:
struct s_pin *get_block_pin(int x_coord, int y_coord, int pin_num) {
    ((void) sizeof ((pin_num > 0) ? 1 : 0), __extension__ ({ if (pin_num > 0) ; else __assert_fail ("pin_num > 0", "SRC/base/util.c", 79, __extension__ __PRETTY_FUNCTION__); }));
    pin_num -= 1;
    struct s_block *block = get_block(x_coord, y_coord);
    ((void) sizeof ((pin_num < block->num_pins) ? 1 : 0), __extension__ ({ if (pin_num < block->num_pins) ; else __assert_fail ("pin_num < block->num_pins", "SRC/base/util.c", 84, __extension__ __PRETTY_FUNCTION__); }));
    return block->array_of_pins[pin_num];
}

variable_types: struct s_block { int x_coord; int y_coord; struct s_pin { struct s_block *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_pins; int num_pins; } *

return_type: struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } *


decompiled_code:
__int64 __fastcall get_sb_index(int a1, int a2)
{
return (unsigned int)(a2 + a1 * (*(_DWORD *)(FPGA + 28LL) + 1));
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
return (unsigned int)(a2 + a1 * (*(_DWORD *)(FPGA + 28LL) + 1));
}

original_code:
int get_sb_index(int x_coord, int y_coord) {
    return ((FPGA->grid_size + 1)*(x_coord) + y_coord);
}


decompiled_code:
__int64 __fastcall get_starting_pin_index_for_side(__int64 a1, int a2)
{
return (unsigned int)(2 * a2);
}

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

original_code:
int get_starting_pin_index_for_side(t_block* block, t_SIDE block_side) {
    return 2*block_side;
}

canonical_original_code:
int get_starting_pin_index_for_side(struct s_block *block, enum e_SIDE block_side) {
    return 2*block_side;
}

variable_types: enum e_SIDE { RIGHT=0, TOP=1, LEFT=2, BOTTOM=3 }


decompiled_code:
int __fastcall dump_wire(__int64 a1)
{
int result; // eax

if ( a1 )
result = printf(
" Wire %d (%d,%d)<-->(%d,%d) %p\n",
*(unsigned int *)(a1 + 48),
***(unsigned int ***)(a1 + 8),
*(unsigned int *)(**(_QWORD **)(a1 + 8) + 4LL),
**(unsigned int **)(*(_QWORD *)(a1 + 8) + 8LL),
*(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) + 4LL),
(const void *)a1);
else
result = puts(" Wire: NULL");
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1)
{
int result; // eax

if ( a1 )
result = printf(
" Wire %d (%d,%d)<-->(%d,%d) %p\n",
*(unsigned int *)(a1 + 48),
***(unsigned int ***)(a1 + 8),
*(unsigned int *)(**(_QWORD **)(a1 + 8) + 4LL),
**(unsigned int **)(*(_QWORD *)(a1 + 8) + 8LL),
*(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) + 4LL),
(const void *)a1);
else
result = puts(" Wire: NULL");
return result;
}

original_code:
void dump_wire(t_wire* wire) {
    if (wire == ((void *)0)) {
        printf("    Wire: NULL\n");
    } else {
        printf("    Wire %d (%d,%d)<-->(%d,%d) %p\n", wire->wire_num, wire->array_of_adjacent_switchblocks[0]->x_coord, wire->array_of_adjacent_switchblocks[0]->y_coord, wire->array_of_adjacent_switchblocks[1]->x_coord, wire->array_of_adjacent_switchblocks[1]->y_coord, wire);
    }
}

canonical_original_code:
void dump_wire(struct s_wire *wire) {
    if (wire == ((void *)0)) {
        printf("    Wire: NULL\n");
    } else {
        printf("    Wire %d (%d,%d)<-->(%d,%d) %p\n", wire->wire_num, wire->array_of_adjacent_switchblocks[0]->x_coord, wire->array_of_adjacent_switchblocks[0]->y_coord, wire->array_of_adjacent_switchblocks[1]->x_coord, wire->array_of_adjacent_switchblocks[1]->y_coord, wire);
    }
}

variable_types: struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock { int x_coord; int y_coord; struct s_wire ***adjacency_list; int *num_adjacencies; int *occupancy_list; } **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } *


decompiled_code:
__int64 __fastcall dump_switchblock(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // rdi

printf("SB: (%d,%d)\n", *a1, a1[1]);
result = FPGA;
if ( *(int *)(FPGA + 24LL) > 0 )
{
v3 = 0LL;
do
{
printf(" W %d Connectivity\n", (unsigned int)v3);
result = FPGA;
if ( *(int *)(FPGA + 32LL) >= 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3) + 8 * v4++);
dump_wire(v5);
result = FPGA;
}
while ( *(_DWORD *)(FPGA + 32LL) >= (int)v4 );
}
++v3;
}
while ( *(_DWORD *)(result + 24) > (int)v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int *a1)
{
__int64 result; // rax
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // rdi

printf("SB: (%d,%d)\n", *a1, a1[1]);
result = FPGA;
if ( *(int *)(FPGA + 24LL) > 0 )
{
v3 = 0LL;
do
{
printf(" W %d Connectivity\n", (unsigned int)v3);
result = FPGA;
if ( *(int *)(FPGA + 32LL) >= 0 )
{
v4 = 0LL;
do
{
v5 = *(_QWORD *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8 * v3) + 8 * v4++);
func8(v5);
result = FPGA;
}
while ( *(_DWORD *)(FPGA + 32LL) >= (int)v4 );
}
++v3;
}
while ( *(_DWORD *)(result + 24) > (int)v3 );
}
return result;
}

original_code:
void dump_switchblock(t_switchblock* sb) {
    printf("SB: (%d,%d)\n", sb->x_coord, sb->y_coord);
    int sb_wire_cnt;
    for(sb_wire_cnt=0; sb_wire_cnt < FPGA->W; sb_wire_cnt++) {
        printf("  W %d Connectivity\n", sb_wire_cnt);
        int chan_wire_cnt;
        for(chan_wire_cnt=0; chan_wire_cnt < FPGA->Fs+1; chan_wire_cnt++) {
            t_wire* wire = sb->adjacency_list[sb_wire_cnt][chan_wire_cnt];
            dump_wire(wire);
        }
    }
}

canonical_original_code:
void dump_switchblock(struct s_switchblock *sb) {
    printf("SB: (%d,%d)\n", sb->x_coord, sb->y_coord);
    int sb_wire_cnt;
    for(sb_wire_cnt=0; sb_wire_cnt < FPGA->W; sb_wire_cnt++) {
        printf("  W %d Connectivity\n", sb_wire_cnt);
        int chan_wire_cnt;
        for(chan_wire_cnt=0; chan_wire_cnt < FPGA->Fs+1; chan_wire_cnt++) {
            struct s_wire *wire = sb->adjacency_list[sb_wire_cnt][chan_wire_cnt];
            dump_wire(wire);
        }
    }
}

variable_types: struct s_switchblock { int x_coord; int y_coord; struct s_wire { int channel_x_coord; int channel_y_coord; struct s_switchblock **array_of_adjacent_switchblocks; int num_switchblocks; struct s_pin { struct s_block { int x_coord; int y_coord; struct s_pin **array_of_pins; int num_pins; } *block; int pin_num; struct s_wire **array_of_adjacent_wires; int num_adjacent_wires; struct s_net { struct s_pin *source_pin; struct s_pin *sink_pin; int net_num; struct s_wire **associated_wires; int num_associated_wires; } *associated_net; } **array_of_adjacent_pins; int num_adjacent_pins; int channel_pair_num; struct s_wire *reservoir_wire; int wire_num; double occupancy; double present_cost; double history_cost; enum e_ROUTING_LABEL { NONE=-1, TARGET=0, SOURCE=1, USED=2, CURRENT_EXPANSION=3 } label_type; double label_value; int counted; } ***adjacency_list; int *num_adjacencies; int *occupancy_list; } *


decompiled_code:
_BOOL8 __fastcall is_vertical_wire(__int64 a1)
{
return ***(_DWORD ***)(a1 + 8) == **(_DWORD **)(*(_QWORD *)(a1 + 8) + 8LL);
}

original_code:
t_boolean is_vertical_wire(t_wire* wire) {
    t_switchblock* sb_0 = wire->array_of_adjacent_switchblocks[0];
    t_switchblock* sb_1 = wire->array_of_adjacent_switchblocks[1];
    if(sb_0->x_coord == sb_1->x_coord) {
        return TRUE;
    } else {
        return FALSE;
    }
}

canonical_original_code:
enum e_boolean is_vertical_wire(struct s_wire *wire) {
    struct s_switchblock *sb_0 = wire->array_of_adjacent_switchblocks[0];
    struct s_switchblock *sb_1 = wire->array_of_adjacent_switchblocks[1];
    if(sb_0->x_coord == sb_1->x_coord) {
        return TRUE;
    } else {
        return FALSE;
    }
}

return_type: enum e_boolean { FALSE=0, TRUE=1 }


decompiled_code:
_BOOL8 __fastcall is_positive_wire(__int64 a1, _DWORD *a2)
{
_DWORD *v2; // rcx
_BOOL8 result; // rax

if ( is_vertical_wire(a1) )
result = a2[1] < v2[1];
else
result = *a2 < *v2;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(__int64 a1, _DWORD *a2)
{
_DWORD *v2; // rcx
_BOOL8 result; // rax

if ( func10(a1) )
result = a2[1] < v2[1];
else
result = *a2 < *v2;
return result;
}

original_code:
t_boolean is_positive_wire(t_wire* wire, t_switchblock* sb) {
    t_switchblock* sb_1 = wire->array_of_adjacent_switchblocks[1];
    if (is_vertical_wire(wire)) {
        if(sb->y_coord < sb_1->y_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        if(sb->x_coord < sb_1->x_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}

canonical_original_code:
enum e_boolean is_positive_wire(struct s_wire *wire, struct s_switchblock *sb) {
    struct s_switchblock *sb_1 = wire->array_of_adjacent_switchblocks[1];
    if (is_vertical_wire(wire)) {
        if(sb->y_coord < sb_1->y_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        if(sb->x_coord < sb_1->x_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}

variable_types:
sb
struct s_switchblock *


decompiled_code:
// attributes: thunk
_BOOL8 __fastcall is_positive_wire_from_block(__int64 a1, _DWORD *a2)
{
return is_positive_wire(a1, a2);
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(__int64 a1, _DWORD *a2)
{
return func11(a1, a2);
}

original_code:
t_boolean is_positive_wire_from_block(t_wire* wire, t_switchblock* sb) {
    t_switchblock* sb_1 = wire->array_of_adjacent_switchblocks[1];
    if (is_vertical_wire(wire)) {
        if(sb->y_coord < sb_1->y_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        if(sb->x_coord < sb_1->x_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}

canonical_original_code:
enum e_boolean is_positive_wire_from_block(struct s_wire *wire, struct s_switchblock *sb) {
    struct s_switchblock *sb_1 = wire->array_of_adjacent_switchblocks[1];
    if (is_vertical_wire(wire)) {
        if(sb->y_coord < sb_1->y_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    } else {
        if(sb->x_coord < sb_1->x_coord) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}


decompiled_code:
__int64 __fastcall short_wire_name(__int64 a1)
{
char s[56]; // [rsp+0h] [rbp-38h] BYREF

snprintf(
s,
0x28uLL,
"(%d,%d)<-->(%d,%d) #%d",
***(unsigned int ***)(a1 + 8),
*(unsigned int *)(**(_QWORD **)(a1 + 8) + 4LL),
**(unsigned int **)(*(_QWORD *)(a1 + 8) + 8LL),
*(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL) + 4LL),
*(unsigned int *)(a1 + 48));
return 0LL;
}

original_code:
char* short_wire_name(t_wire* wire) {
    char buf[40];
    snprintf(buf, sizeof(buf), "(%d,%d)<-->(%d,%d) #%d",
             wire->array_of_adjacent_switchblocks[0]->x_coord, wire->array_of_adjacent_switchblocks[0]->y_coord,
             wire->array_of_adjacent_switchblocks[1]->x_coord, wire->array_of_adjacent_switchblocks[1]->y_coord,
             wire->wire_num);
    return buf;
}

canonical_original_code:
char *short_wire_name(struct s_wire *wire) {
    char buf[40];
    snprintf(buf, sizeof(buf), "(%d,%d)<-->(%d,%d) #%d",
             wire->array_of_adjacent_switchblocks[0]->x_coord, wire->array_of_adjacent_switchblocks[0]->y_coord,
             wire->array_of_adjacent_switchblocks[1]->x_coord, wire->array_of_adjacent_switchblocks[1]->y_coord,
             wire->wire_num);
    return buf;
}

variable_types:
buf
char [40]

return_type: char *


decompiled_code:
void *__fastcall my_malloc(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
printf("Error: malloc of size %u bytes failed\n", (unsigned int)a1);
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
printf("Error: malloc of size %u bytes failed\n", (unsigned int)a1);
exit(1);
}
return result;
}

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 *result; // rax

result = realloc(a1, a2);
if ( !result )
{
printf("Error: realloc of size %u bytes failed\n", (unsigned int)a2);
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1, size_t a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
{
printf("Error: realloc of size %u bytes failed\n", (unsigned int)a2);
exit(1);
}
return result;
}

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:
long umfdl_build_tuples
(
    NumericType *Numeric,
    WorkType *Work
)
{
    long e, nrows, ncols, nel, *Rows, *Cols, row, col, n_row, n_col, *E,
 *Row_tuples, *Row_degree, *Row_tlen,
 *Col_tuples, *Col_degree, *Col_tlen, n1 ;
    Element *ep ;
    Unit *p ;
    Tuple tuple, *tp ;
    E = Work->E ;
    Col_degree = Numeric->Cperm ;
    Row_degree = Numeric->Rperm ;
    Row_tuples = Numeric->Uip ;
    Row_tlen = Numeric->Uilen ;
    Col_tuples = Numeric->Lip ;
    Col_tlen = Numeric->Lilen ;
    n_row = Work->n_row ;
    n_col = Work->n_col ;
    nel = Work->nel ;
    n1 = Work->n1 ;
    ;
    for (row = n1 ; row < n_row ; row++)
    {
 if ((Row_degree [row] >= 0))
 {
     Row_tuples [row] = umfdl_mem_alloc_tail_block (Numeric,
  (((((sizeof (Tuple) * ((((4) > ((Row_tlen [row]) + 1)) ? (4) : ((Row_tlen [row]) + 1))))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     if (!Row_tuples [row])
     {
  ;
  return ((0)) ;
     }
     Row_tlen [row] = 0 ;
 }
    }
    for (col = n_col-1 ; col >= n1 ; col--)
    {
 if ((Col_degree [col] >= 0))
 {
     Col_tuples [col] = umfdl_mem_alloc_tail_block (Numeric,
  (((((sizeof (Tuple) * ((((4) > ((Col_tlen [col]) + 1)) ? (4) : ((Col_tlen [col]) + 1))))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     if (!Col_tuples [col])
     {
  ;
  return ((0)) ;
     }
     Col_tlen [col] = 0 ;
 }
    }
    for (e = 1 ; e <= nel ; e++)
    {
 ;
 ;
 p = Numeric->Memory + E [e] ;
 { { ; ; ; ep = (Element *) p ; p += (((((sizeof (Element) * (1))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ; Cols = (long *) p ; } ; ncols = ep->ncols ; Rows = Cols + ncols ; } ;
 nrows = ep->nrows ;
 ;
 ;
 ;
 tuple.e = e ;
 for (tuple.f = 0 ; tuple.f < ncols ; tuple.f++)
 {
     col = Cols [tuple.f] ;
     ;
     ;
     ;
     tp = ((Tuple *) (Numeric->Memory + Col_tuples [col]))
  + Col_tlen [col]++ ;
     *tp = tuple ;
 }
 for (tuple.f = 0 ; tuple.f < nrows ; tuple.f++)
 {
     row = Rows [tuple.f] ;
     ;
     ;
     ;
     tp = ((Tuple *) (Numeric->Memory + Row_tuples [row]))
  + Row_tlen [row]++ ;
     *tp = tuple ;
 }
    }
    ;
    return ((1)) ;
}

canonical_original_code:
long umfdl_build_tuples(struct NumericType *Numeric, struct WorkType *Work)
{
    long e; long nrows; long ncols; long nel; long *Rows; long *Cols; long row; long col; long n_row; long n_col; long *E; long *Row_tuples; long *Row_degree; long *Row_tlen; long *Col_tuples; long *Col_degree; long *Col_tlen; long n1;
    struct Element *ep;
    union Unit_union *p;
    struct Tuple tuple; struct Tuple *tp;
    E = Work->E ;
    Col_degree = Numeric->Cperm ;
    Row_degree = Numeric->Rperm ;
    Row_tuples = Numeric->Uip ;
    Row_tlen = Numeric->Uilen ;
    Col_tuples = Numeric->Lip ;
    Col_tlen = Numeric->Lilen ;
    n_row = Work->n_row ;
    n_col = Work->n_col ;
    nel = Work->nel ;
    n1 = Work->n1 ;
    ;
    for (row = n1 ; row < n_row ; row++)
    {
 if ((Row_degree [row] >= 0))
 {
     Row_tuples [row] = umfdl_mem_alloc_tail_block (Numeric,
  (((((sizeof (Tuple) * ((((4) > ((Row_tlen [row]) + 1)) ? (4) : ((Row_tlen [row]) + 1))))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     if (!Row_tuples [row])
     {
  ;
  return ((0)) ;
     }
     Row_tlen [row] = 0 ;
 }
    }
    for (col = n_col-1 ; col >= n1 ; col--)
    {
 if ((Col_degree [col] >= 0))
 {
     Col_tuples [col] = umfdl_mem_alloc_tail_block (Numeric,
  (((((sizeof (Tuple) * ((((4) > ((Col_tlen [col]) + 1)) ? (4) : ((Col_tlen [col]) + 1))))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
     if (!Col_tuples [col])
     {
  ;
  return ((0)) ;
     }
     Col_tlen [col] = 0 ;
 }
    }
    for (e = 1 ; e <= nel ; e++)
    {
 ;
 ;
 p = Numeric->Memory + E [e] ;
 { { ; ; ; ep = (struct Element *) p ; p += (((((sizeof (Element) * (1))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ; Cols = (long *) p ; } ; ncols = ep->ncols ; Rows = Cols + ncols ; } ;
 nrows = ep->nrows ;
 ;
 ;
 ;
 tuple.e = e ;
 for (tuple.f = 0 ; tuple.f < ncols ; tuple.f++)
 {
     col = Cols [tuple.f] ;
     ;
     ;
     ;
     tp = ((struct Tuple *) (Numeric->Memory + Col_tuples [col]))
  + Col_tlen [col]++ ;
     *tp = tuple ;
 }
 for (tuple.f = 0 ; tuple.f < nrows ; tuple.f++)
 {
     row = Rows [tuple.f] ;
     ;
     ;
     ;
     tp = ((struct Tuple *) (Numeric->Memory + Row_tuples [row]))
  + Row_tlen [row]++ ;
     *tp = tuple ;
 }
    }
    ;
    return ((1)) ;
}

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: struct WorkType { long *E; double *Wx; long *Wp; long *Lpattern; long *Diagonal_map; long n_row; long *Front_new1strow; long Pivrow[64]; double *Flublock; long *Frows; } *

variable_types: e long

variable_types: nrows long

variable_types: ncols long

variable_types: nel long

variable_types:
Rows
long *

variable_types:
Cols
long *

variable_types: row long

variable_types: col long

variable_types:
E
long *

variable_types:
ep
struct Element { long cdeg; } *

variable_types:
tuple
struct Tuple { long e; }

variable_types:
tp
struct Tuple { long e; } *


original_code:
cholmod_sparse *cholmod_l_ssmult
(
    cholmod_sparse *A,
    cholmod_sparse *B,
    int stype,
    int values,
    int sorted,
    cholmod_common *Common
)
{
    double bjt ;
    double *Ax, *Bx, *Cx, *W ;
    long *Ap, *Anz, *Ai, *Bp, *Bnz, *Bi, *Cp, *Ci, *Flag ;
    cholmod_sparse *C, *A2, *B2, *A3, *B3, *C2 ;
    long apacked, bpacked, j, i, pa, paend, pb, pbend, ncol, mark, cnz, t, p,
 nrow, anz, bnz, do_swap_and_transpose, n1, n2 ;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    { if ((A) == ((void *)0)) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 71, "argument missing", Common) ; } return (((void *)0)) ; } } ;
    { if ((B) == ((void *)0)) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 72, "argument missing", Common) ; } return (((void *)0)) ; } } ;
    values = values &&
 (A->xtype != 0) && (B->xtype != 0) ;
    { if ((A)->xtype < (0) || (A)->xtype > (values ? 1 : 3) || ((A)->xtype != 0 && ((A)->x) == ((void *)0)) || ((A)->xtype == 3 && ((A)->z) == ((void *)0))) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 75, "invalid xtype", Common) ; } return (((void *)0)) ; } } ;
    { if ((B)->xtype < (0) || (B)->xtype > (values ? 1 : 3) || ((B)->xtype != 0 && ((B)->x) == ((void *)0)) || ((B)->xtype == 3 && ((B)->z) == ((void *)0))) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 77, "invalid xtype", Common) ; } return (((void *)0)) ; } } ;
    if (A->ncol != B->nrow)
    {
 cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 82, "A and B inner dimensions must match", Common) ;
 return (((void *)0)) ;
    }
    Common->status = 0 ;
    if (A->nrow <= 1)
    {
 sorted = 0 ;
    }
    if (sorted)
    {
 n1 = (((A->nrow) > (B->ncol)) ? (A->nrow) : (B->ncol)) ;
    }
    else
    {
 n1 = A->nrow ;
    }
    n2 = (((A->ncol) > (A->nrow)) ? ((((A->ncol) > (B->nrow)) ? ((((A->ncol) > (B->ncol)) ? (A->ncol) : (B->ncol))) : ((((B->nrow) > (B->ncol)) ? (B->nrow) : (B->ncol))))) : ((((A->nrow) > (B->nrow)) ? ((((A->nrow) > (B->ncol)) ? (A->nrow) : (B->ncol))) : ((((B->nrow) > (B->ncol)) ? (B->nrow) : (B->ncol)))))) ;
    cholmod_l_allocate_work (n1, n2, values ? n1 : 0, Common) ;
    if (Common->status < 0)
    {
 return (((void *)0)) ;
    }
    ;
    A2 = ((void *)0) ;
    B2 = ((void *)0) ;
    if (A->stype)
    {
 A2 = cholmod_l_copy (A, 0, values, Common) ;
 if (Common->status < 0)
 {
     ;
     return (((void *)0)) ;
 }
 A = A2 ;
    }
    if (B->stype)
    {
 B2 = cholmod_l_copy (B, 0, values, Common) ;
 if (Common->status < 0)
 {
     cholmod_l_free_sparse (&A2, Common) ;
     ;
     return (((void *)0)) ;
 }
 B = B2 ;
    }
    ;
    ;
    Ap = A->p ;
    Anz = A->nz ;
    Ai = A->i ;
    Ax = A->x ;
    apacked = A->packed ;
    Bp = B->p ;
    Bnz = B->nz ;
    Bi = B->i ;
    Bx = B->x ;
    bpacked = B->packed ;
    nrow = A->nrow ;
    ncol = B->ncol ;
    W = Common->Xwork ;
    Flag = Common->Flag ;
    cnz = 0 ;
    for (j = 0 ; j < ncol ; j++)
    {
 { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
 mark = Common->mark ;
 pb = Bp [j] ;
 pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
 for ( ; pb < pbend ; pb++)
 {
     t = Bi [pb] ;
     pa = Ap [t] ;
     paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
     for ( ; pa < paend ; pa++)
     {
  i = Ai [pa] ;
  if (Flag [i] != mark)
  {
      Flag [i] = mark ;
      cnz++ ;
  }
     }
 }
 if (cnz < 0)
 {
     break ;
 }
    }
    { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
    mark = Common->mark ;
    if (cnz < 0)
    {
 cholmod_l_error ((-3), "../MatrixOps/cholmod_ssmult.c", 224, "problem too large", Common) ;
 cholmod_l_free_sparse (&A2, Common) ;
 cholmod_l_free_sparse (&B2, Common) ;
 ;
 return (((void *)0)) ;
    }
    do_swap_and_transpose = 0 ;
    if (sorted)
    {
 anz = cholmod_l_nnz (A, Common) ;
 bnz = cholmod_l_nnz (B, Common) ;
 do_swap_and_transpose = (anz + bnz < cnz) ;
 if (do_swap_and_transpose)
 {
     A3 = cholmod_l_ptranspose (A, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&A2, Common) ;
     A2 = A3 ;
     if (Common->status < 0)
     {
  cholmod_l_free_sparse (&A2, Common) ;
  cholmod_l_free_sparse (&B2, Common) ;
  ;
  return (((void *)0)) ;
     }
     B3 = cholmod_l_ptranspose (B, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&B2, Common) ;
     B2 = B3 ;
     if (Common->status < 0)
     {
  cholmod_l_free_sparse (&A2, Common) ;
  cholmod_l_free_sparse (&B2, Common) ;
  ;
  return (((void *)0)) ;
     }
     A = B2 ;
     B = A2 ;
     Ap = A->p ;
     Anz = A->nz ;
     Ai = A->i ;
     Ax = A->x ;
     apacked = A->packed ;
     Bp = B->p ;
     Bnz = B->nz ;
     Bi = B->i ;
     Bx = B->x ;
     bpacked = B->packed ;
     nrow = A->nrow ;
     ncol = B->ncol ;
 }
    }
    C = cholmod_l_allocate_sparse (nrow, ncol, cnz, 0, 1, 0,
     values ? A->xtype : 0, Common) ;
    if (Common->status < 0)
    {
 cholmod_l_free_sparse (&A2, Common) ;
 cholmod_l_free_sparse (&B2, Common) ;
 ;
 return (((void *)0)) ;
    }
    Cp = C->p ;
    Ci = C->i ;
    Cx = C->x ;
    cnz = 0 ;
    if (values)
    {
 for (j = 0 ; j < ncol ; j++)
 {
     { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
     mark = Common->mark ;
     Cp [j] = cnz ;
     pb = Bp [j] ;
     pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
     for ( ; pb < pbend ; pb++)
     {
  t = Bi [pb] ;
  bjt = Bx [pb] ;
  pa = Ap [t] ;
  paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
  for ( ; pa < paend ; pa++)
  {
      i = Ai [pa] ;
      if (Flag [i] != mark)
      {
   Flag [i] = mark ;
   Ci [cnz++] = i ;
      }
      W [i] += Ax [pa] * bjt ;
  }
     }
     for (p = Cp [j] ; p < cnz ; p++)
     {
  i = Ci [p] ;
  Cx [p] = W [i] ;
  W [i] = 0 ;
     }
 }
    }
    else
    {
 for (j = 0 ; j < ncol ; j++)
 {
     { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
     mark = Common->mark ;
     Cp [j] = cnz ;
     pb = Bp [j] ;
     pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
     for ( ; pb < pbend ; pb++)
     {
  t = Bi [pb] ;
  pa = Ap [t] ;
  paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
  for ( ; pa < paend ; pa++)
  {
      i = Ai [pa] ;
      if (Flag [i] != mark)
      {
   Flag [i] = mark ;
   Ci [cnz++] = i ;
      }
  }
     }
 }
    }
    Cp [ncol] = cnz ;
    ;
    cholmod_l_free_sparse (&A2, Common) ;
    cholmod_l_free_sparse (&B2, Common) ;
    { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
    ;
    if (stype > 0)
    {
 (void) cholmod_l_band_inplace (0, ncol, values, C, Common) ;
 C->stype = 1 ;
    }
    else if (stype < 0)
    {
 (void) cholmod_l_band_inplace (-nrow, 0, values, C, Common) ;
 C->stype = -1 ;
    }
    ;
    if (sorted)
    {
 if (do_swap_and_transpose)
 {
     C2 = cholmod_l_ptranspose (C, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&C, Common) ;
     if (Common->status < 0)
     {
  ;
  return (((void *)0)) ;
     }
     C = C2 ;
 }
 else
 {
     if (!cholmod_l_sort (C, Common))
     {
  cholmod_l_free_sparse (&C, Common) ;
  ;
  return (((void *)0)) ;
     }
 }
    }
    ;
    ;
    return (C) ;
}

canonical_original_code:
struct cholmod_sparse_struct *cholmod_l_ssmult(struct cholmod_sparse_struct *A, struct cholmod_sparse_struct *B, int stype, int values, int sorted, struct cholmod_common_struct *Common)
{
    double bjt;
    double *Ax; double *Bx; double *Cx; double *W;
    long *Ap; long *Anz; long *Ai; long *Bp; long *Bnz; long *Bi; long *Cp; long *Ci; long *Flag;
    struct cholmod_sparse_struct *C; struct cholmod_sparse_struct *A2; struct cholmod_sparse_struct *B2; struct cholmod_sparse_struct *A3; struct cholmod_sparse_struct *B3; struct cholmod_sparse_struct *C2;
    long apacked; long bpacked; long j; long i; long pa; long paend; long pb; long pbend; long ncol; long mark; long cnz; long t; long p; long nrow; long anz; long bnz; long do_swap_and_transpose; long n1; long n2;
    { if (Common == ((void *)0)) { return (((void *)0)) ; } if (Common->itype != 2 || Common->dtype != 0) { Common->status = (-4) ; return (((void *)0)) ; } } ;
    { if ((A) == ((void *)0)) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 71, "argument missing", Common) ; } return (((void *)0)) ; } } ;
    { if ((B) == ((void *)0)) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 72, "argument missing", Common) ; } return (((void *)0)) ; } } ;
    values = values &&
 (A->xtype != 0) && (B->xtype != 0) ;
    { if ((A)->xtype < (0) || (A)->xtype > (values ? 1 : 3) || ((A)->xtype != 0 && ((A)->x) == ((void *)0)) || ((A)->xtype == 3 && ((A)->z) == ((void *)0))) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 75, "invalid xtype", Common) ; } return (((void *)0)) ; } } ;
    { if ((B)->xtype < (0) || (B)->xtype > (values ? 1 : 3) || ((B)->xtype != 0 && ((B)->x) == ((void *)0)) || ((B)->xtype == 3 && ((B)->z) == ((void *)0))) { if (Common->status != (-2)) { cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 77, "invalid xtype", Common) ; } return (((void *)0)) ; } } ;
    if (A->ncol != B->nrow)
    {
 cholmod_l_error ((-4), "../MatrixOps/cholmod_ssmult.c", 82, "A and B inner dimensions must match", Common) ;
 return (((void *)0)) ;
    }
    Common->status = 0 ;
    if (A->nrow <= 1)
    {
 sorted = 0 ;
    }
    if (sorted)
    {
 n1 = (((A->nrow) > (B->ncol)) ? (A->nrow) : (B->ncol)) ;
    }
    else
    {
 n1 = A->nrow ;
    }
    n2 = (((A->ncol) > (A->nrow)) ? ((((A->ncol) > (B->nrow)) ? ((((A->ncol) > (B->ncol)) ? (A->ncol) : (B->ncol))) : ((((B->nrow) > (B->ncol)) ? (B->nrow) : (B->ncol))))) : ((((A->nrow) > (B->nrow)) ? ((((A->nrow) > (B->ncol)) ? (A->nrow) : (B->ncol))) : ((((B->nrow) > (B->ncol)) ? (B->nrow) : (B->ncol)))))) ;
    cholmod_l_allocate_work (n1, n2, values ? n1 : 0, Common) ;
    if (Common->status < 0)
    {
 return (((void *)0)) ;
    }
    ;
    A2 = ((void *)0) ;
    B2 = ((void *)0) ;
    if (A->stype)
    {
 A2 = cholmod_l_copy (A, 0, values, Common) ;
 if (Common->status < 0)
 {
     ;
     return (((void *)0)) ;
 }
 A = A2 ;
    }
    if (B->stype)
    {
 B2 = cholmod_l_copy (B, 0, values, Common) ;
 if (Common->status < 0)
 {
     cholmod_l_free_sparse (&A2, Common) ;
     ;
     return (((void *)0)) ;
 }
 B = B2 ;
    }
    ;
    ;
    Ap = A->p ;
    Anz = A->nz ;
    Ai = A->i ;
    Ax = A->x ;
    apacked = A->packed ;
    Bp = B->p ;
    Bnz = B->nz ;
    Bi = B->i ;
    Bx = B->x ;
    bpacked = B->packed ;
    nrow = A->nrow ;
    ncol = B->ncol ;
    W = Common->Xwork ;
    Flag = Common->Flag ;
    cnz = 0 ;
    for (j = 0 ; j < ncol ; j++)
    {
 { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
 mark = Common->mark ;
 pb = Bp [j] ;
 pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
 for ( ; pb < pbend ; pb++)
 {
     t = Bi [pb] ;
     pa = Ap [t] ;
     paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
     for ( ; pa < paend ; pa++)
     {
  i = Ai [pa] ;
  if (Flag [i] != mark)
  {
      Flag [i] = mark ;
      cnz++ ;
  }
     }
 }
 if (cnz < 0)
 {
     break ;
 }
    }
    { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
    mark = Common->mark ;
    if (cnz < 0)
    {
 cholmod_l_error ((-3), "../MatrixOps/cholmod_ssmult.c", 224, "problem too large", Common) ;
 cholmod_l_free_sparse (&A2, Common) ;
 cholmod_l_free_sparse (&B2, Common) ;
 ;
 return (((void *)0)) ;
    }
    do_swap_and_transpose = 0 ;
    if (sorted)
    {
 anz = cholmod_l_nnz (A, Common) ;
 bnz = cholmod_l_nnz (B, Common) ;
 do_swap_and_transpose = (anz + bnz < cnz) ;
 if (do_swap_and_transpose)
 {
     A3 = cholmod_l_ptranspose (A, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&A2, Common) ;
     A2 = A3 ;
     if (Common->status < 0)
     {
  cholmod_l_free_sparse (&A2, Common) ;
  cholmod_l_free_sparse (&B2, Common) ;
  ;
  return (((void *)0)) ;
     }
     B3 = cholmod_l_ptranspose (B, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&B2, Common) ;
     B2 = B3 ;
     if (Common->status < 0)
     {
  cholmod_l_free_sparse (&A2, Common) ;
  cholmod_l_free_sparse (&B2, Common) ;
  ;
  return (((void *)0)) ;
     }
     A = B2 ;
     B = A2 ;
     Ap = A->p ;
     Anz = A->nz ;
     Ai = A->i ;
     Ax = A->x ;
     apacked = A->packed ;
     Bp = B->p ;
     Bnz = B->nz ;
     Bi = B->i ;
     Bx = B->x ;
     bpacked = B->packed ;
     nrow = A->nrow ;
     ncol = B->ncol ;
 }
    }
    C = cholmod_l_allocate_sparse (nrow, ncol, cnz, 0, 1, 0,
     values ? A->xtype : 0, Common) ;
    if (Common->status < 0)
    {
 cholmod_l_free_sparse (&A2, Common) ;
 cholmod_l_free_sparse (&B2, Common) ;
 ;
 return (((void *)0)) ;
    }
    Cp = C->p ;
    Ci = C->i ;
    Cx = C->x ;
    cnz = 0 ;
    if (values)
    {
 for (j = 0 ; j < ncol ; j++)
 {
     { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
     mark = Common->mark ;
     Cp [j] = cnz ;
     pb = Bp [j] ;
     pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
     for ( ; pb < pbend ; pb++)
     {
  t = Bi [pb] ;
  bjt = Bx [pb] ;
  pa = Ap [t] ;
  paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
  for ( ; pa < paend ; pa++)
  {
      i = Ai [pa] ;
      if (Flag [i] != mark)
      {
   Flag [i] = mark ;
   Ci [cnz++] = i ;
      }
      W [i] += Ax [pa] * bjt ;
  }
     }
     for (p = Cp [j] ; p < cnz ; p++)
     {
  i = Ci [p] ;
  Cx [p] = W [i] ;
  W [i] = 0 ;
     }
 }
    }
    else
    {
 for (j = 0 ; j < ncol ; j++)
 {
     { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
     mark = Common->mark ;
     Cp [j] = cnz ;
     pb = Bp [j] ;
     pbend = (bpacked) ? (Bp [j+1]) : (pb + Bnz [j]) ;
     for ( ; pb < pbend ; pb++)
     {
  t = Bi [pb] ;
  pa = Ap [t] ;
  paend = (apacked) ? (Ap [t+1]) : (pa + Anz [t]) ;
  for ( ; pa < paend ; pa++)
  {
      i = Ai [pa] ;
      if (Flag [i] != mark)
      {
   Flag [i] = mark ;
   Ci [cnz++] = i ;
      }
  }
     }
 }
    }
    Cp [ncol] = cnz ;
    ;
    cholmod_l_free_sparse (&A2, Common) ;
    cholmod_l_free_sparse (&B2, Common) ;
    { Common->mark++ ; if (Common->mark <= 0) { Common->mark = (-1) ; cholmod_l_clear_flag (Common) ; } } ;
    ;
    if (stype > 0)
    {
 (void) cholmod_l_band_inplace (0, ncol, values, C, Common) ;
 C->stype = 1 ;
    }
    else if (stype < 0)
    {
 (void) cholmod_l_band_inplace (-nrow, 0, values, C, Common) ;
 C->stype = -1 ;
    }
    ;
    if (sorted)
    {
 if (do_swap_and_transpose)
 {
     C2 = cholmod_l_ptranspose (C, values, ((void *)0), ((void *)0), 0, Common) ;
     cholmod_l_free_sparse (&C, Common) ;
     if (Common->status < 0)
     {
  ;
  return (((void *)0)) ;
     }
     C = C2 ;
 }
 else
 {
     if (!cholmod_l_sort (C, Common))
     {
  cholmod_l_free_sparse (&C, Common) ;
  ;
  return (((void *)0)) ;
     }
 }
    }
    ;
    ;
    return (C) ;
}

variable_types:
A
struct cholmod_sparse_struct *

variable_types:
B
struct cholmod_sparse_struct *

variable_types: stype int

variable_types: values int

variable_types: sorted int

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

variable_types: bjt double

variable_types:
Ax
double *

variable_types:
Bx
double *

variable_types:
Cx
double *

variable_types:
W
double *

variable_types:
Ap
long *

variable_types:
Anz
long *

variable_types:
Ai
long *

variable_types:
Bp
long *

variable_types:
Bnz
long *

variable_types:
Bi
long *

variable_types:
Cp
long *

variable_types:
Ci
long *

variable_types:
Flag
long *

variable_types: struct cholmod_sparse_struct { unsigned long nrow; unsigned long ncol; unsigned long nzmax; void *p; void *i; void *nz; void *x; void *z; int stype; int itype; int xtype; int dtype; int sorted; int packed; } *

variable_types: apacked long

variable_types: bpacked long

variable_types: j long

variable_types: i long

variable_types: pa long

variable_types: paend long

variable_types: pb long

variable_types: pbend long

variable_types: ncol long

variable_types: mark long

variable_types: cnz long

variable_types: t long

variable_types: p long

variable_types: nrow long

variable_types: anz long

variable_types: bnz long

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:
double umfdl_usolve
(
    NumericType *Numeric,
    double X [ ],
    long Pattern [ ]
)
{
    double xk ;
    double *xp, *D, *Uval ;
    long k, deg, j, *ip, col, *Upos, *Uilen, pos,
 *Uip, n, ulen, up, newUchain, npiv, n1, *Ui ;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    n = Numeric->n_row ;
    npiv = Numeric->npiv ;
    Upos = Numeric->Upos ;
    Uilen = Numeric->Uilen ;
    Uip = Numeric->Uip ;
    D = Numeric->D ;
    n1 = Numeric->n1 ;
    for (k = n-1 ; k >= npiv ; k--)
    {
 ;
 xk = X [k] ;
 { (X [k]) = (xk) / (D [k]) ; } ;
    }
    deg = Numeric->ulen ;
    if (deg > 0)
    {
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     Pattern [j] = Numeric->Upattern [j] ;
 }
    }
    for (k = npiv-1 ; k >= n1 ; k--)
    {
 up = Uip [k] ;
 ulen = Uilen [k] ;
 newUchain = (up < 0) ;
 if (newUchain)
 {
     up = -up ;
     xp = (double *) (Numeric->Memory + up + (((((sizeof (long) * (ulen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
 }
 else
 {
     xp = (double *) (Numeric->Memory + up) ;
 }
 xk = X [k] ;
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     ;
     { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
     xp++ ;
 }
 { (X [k]) = (xk) / (D [k]) ; } ;
 if (k == n1) break ;
 if (newUchain)
 {
     deg = ulen ;
     ;
     ;
     ip = (long *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  col = *ip++ ;
  ;
  ;
  Pattern [j] = col ;
     }
 }
 else
 {
     deg -= ulen ;
     ;
     ;
     pos = Upos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 deg = Uilen [k] ;
 xk = X [k] ;
 ;
 if (deg > 0)
 {
     up = Uip [k] ;
     Ui = (long *) (Numeric->Memory + up) ;
     up += (((((sizeof (long) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Uval = (double *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  ;
  { (xk) -= (X [Ui [j]]) * (Uval [j]) ; } ;
     }
 }
 { (X [k]) = (xk) / (D [k]) ; } ;
    }
    return (1. * ((double) n) + 2. * ((double) Numeric->unz));
}

canonical_original_code:
double umfdl_usolve(struct NumericType *Numeric, double X[], long Pattern[])
{
    double xk;
    double *xp; double *D; double *Uval;
    long k; long deg; long j; long *ip; long col; long *Upos; long *Uilen; long pos; long *Uip; long n; long ulen; long up; long newUchain; long npiv; long n1; long *Ui;
    if (Numeric->n_row != Numeric->n_col) return (0.) ;
    n = Numeric->n_row ;
    npiv = Numeric->npiv ;
    Upos = Numeric->Upos ;
    Uilen = Numeric->Uilen ;
    Uip = Numeric->Uip ;
    D = Numeric->D ;
    n1 = Numeric->n1 ;
    for (k = n-1 ; k >= npiv ; k--)
    {
 ;
 xk = X [k] ;
 { (X [k]) = (xk) / (D [k]) ; } ;
    }
    deg = Numeric->ulen ;
    if (deg > 0)
    {
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     Pattern [j] = Numeric->Upattern [j] ;
 }
    }
    for (k = npiv-1 ; k >= n1 ; k--)
    {
 up = Uip [k] ;
 ulen = Uilen [k] ;
 newUchain = (up < 0) ;
 if (newUchain)
 {
     up = -up ;
     xp = (double *) (Numeric->Memory + up + (((((sizeof (long) * (ulen))) + (sizeof (Unit)) - 1) / (sizeof (Unit))))) ;
 }
 else
 {
     xp = (double *) (Numeric->Memory + up) ;
 }
 xk = X [k] ;
 for (j = 0 ; j < deg ; j++)
 {
     ;
     ;
     ;
     { (xk) -= (X [Pattern [j]]) * (*xp) ; } ;
     xp++ ;
 }
 { (X [k]) = (xk) / (D [k]) ; } ;
 if (k == n1) break ;
 if (newUchain)
 {
     deg = ulen ;
     ;
     ;
     ip = (long *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  col = *ip++ ;
  ;
  ;
  Pattern [j] = col ;
     }
 }
 else
 {
     deg -= ulen ;
     ;
     ;
     pos = Upos [k] ;
     if (pos != (-1))
     {
  ;
  ;
  Pattern [deg++] = Pattern [pos] ;
  Pattern [pos] = k ;
     }
 }
    }
    for (k = n1 - 1 ; k >= 0 ; k--)
    {
 deg = Uilen [k] ;
 xk = X [k] ;
 ;
 if (deg > 0)
 {
     up = Uip [k] ;
     Ui = (long *) (Numeric->Memory + up) ;
     up += (((((sizeof (long) * (deg))) + (sizeof (Unit)) - 1) / (sizeof (Unit)))) ;
     Uval = (double *) (Numeric->Memory + up) ;
     for (j = 0 ; j < deg ; j++)
     {
  ;
  ;
  ;
  ;
  { (xk) -= (X [Ui [j]]) * (Uval [j]) ; } ;
     }
 }
 { (X [k]) = (xk) / (D [k]) ; } ;
    }
    return (1. * ((double) n) + 2. * ((double) Numeric->unz));
}

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:
X
double []

variable_types:
Pattern
long []

variable_types: xk double

variable_types:
xp
double *

variable_types:
D
double *

variable_types:
Uval
double *

variable_types: k long

variable_types: deg long

variable_types:
ip
long *

variable_types: col long

variable_types:
Upos
long *

variable_types:
Uilen
long *

variable_types: pos long

variable_types:
Uip
long *

variable_types: n long

variable_types: ulen long

variable_types: up long

variable_types: newUchain long

variable_types: npiv long

variable_types:
Ui
long *


decompiled_code:
__int64 __fastcall cholmod_add_size_t(__int64 a1, __int64 a2, int *a3)
{
__int64 result; // rax
_BOOL8 v4; // rsi
int v5; // ecx

result = a2 + a1;
v4 = __CFADD__(a2, a1);
if ( !*a3 || (v5 = 1, v4) )
{
v5 = 0;
result = 0LL;
}
*a3 = v5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, int *a3)
{
__int64 result; // rax
_BOOL8 v4; // rsi
int v5; // ecx

result = a2 + a1;
v4 = __CFADD__(a2, a1);
if ( !*a3 || (v5 = 1, v4) )
{
v5 = 0;
result = 0LL;
}
*a3 = v5;
return result;
}

original_code:
size_t cholmod_add_size_t (size_t a, size_t b, int *ok)
{
    size_t s = a + b ;
    (*ok) = (*ok) && (s >= a) ;
    return ((*ok) ? s : 0) ;
}

canonical_original_code:
unsigned long cholmod_add_size_t(unsigned long a, unsigned long b, int *ok)
{
    unsigned long s = a + b;
    (*ok) = (*ok) && (s >= a) ;
    return ((*ok) ? s : 0) ;
}

variable_types:
a
unsigned long

variable_types:
b
unsigned long

variable_types:
ok
int *

variable_types:
s
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall cholmod_mult_size_t(unsigned __int64 a1, unsigned __int64 a2, _DWORD *a3)
{
__int64 v3; // r8
bool v4; // al
bool v5; // cf

if ( !*a3 )
return 0LL;
v3 = 0LL;
while ( 1 )
{
if ( (a2 & 1) != 0 )
{
v5 = __CFADD__(a1, v3);
v3 += a1;
*a3 = !v5;
}
if ( a2 <= 1 )
break;
v4 = 2 * a1 >= a1 && *a3 != 0;
*a3 = v4;
if ( !v4 )
return 0LL;
a2 >>= 1;
a1 *= 2LL;
}
return v3;
}

original_code:
size_t cholmod_mult_size_t (size_t a, size_t k, int *ok)
{
    size_t p = 0, s ;
    while (*ok)
    {
 if (k % 2)
 {
     p = p + a ;
     (*ok) = (*ok) && (p >= a) ;
 }
 k = k / 2 ;
 if (!k) return (p) ;
 s = a + a ;
 (*ok) = (*ok) && (s >= a) ;
 a = s ;
    }
    return (0) ;
}

canonical_original_code:
unsigned long cholmod_mult_size_t(unsigned long a, unsigned long k, int *ok)
{
    unsigned long p = 0; unsigned long s;
    while (*ok)
    {
 if (k % 2)
 {
     p = p + a ;
     (*ok) = (*ok) && (p >= a) ;
 }
 k = k / 2 ;
 if (!k) return (p) ;
 s = a + a ;
 (*ok) = (*ok) && (s >= a) ;
 a = s ;
    }
    return (0) ;
}

variable_types:
k
unsigned long

variable_types:
p
unsigned long