decompiled_code:
void __fastcall binmat_multiply_slow(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
unsigned int v5; // er15
unsigned int i; // er14
__int64 v7; // r13
unsigned int v8; // ebp
unsigned __int8 v9; // bl
unsigned int v10; // ebx

v5 = 0;
if ( a4 )
{
while ( 1 )
{
for ( i = 0; ; ++i )
{
v7 = 0LL;
v8 = 0;
do
{
v9 = binmat_getbit(a2, a4, v5, v8);
v7 += (unsigned __int8)binmat_getbit(a3, a4, v8, i) * v9;
v10 = v8++;
}
while ( a4 != v8 );
binmat_setbit(a1, v8, v5, i, v7 != 0);
if ( i == v10 )
break;
}
if ( v5 == v10 )
break;
++v5;
}
}
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
unsigned int v5; // er15
unsigned int i; // er14
__int64 v7; // r13
unsigned int v8; // ebp
unsigned __int8 v9; // bl
unsigned int v10; // ebx

v5 = 0;
if ( a4 )
{
while ( 1 )
{
for ( i = 0; ; ++i )
{
v7 = 0LL;
v8 = 0;
do
{
v9 = func2(a2, a4, v5, v8);
v7 += (unsigned __int8)func2(a3, a4, v8, i) * v9;
v10 = v8++;
}
while ( a4 != v8 );
func3(a1, v8, v5, i, v7 != 0);
if ( i == v10 )
break;
}
if ( v5 == v10 )
break;
++v5;
}
}
}

original_code:
void binmat_multiply_slow(binmat_data_t *output, const binmat_data_t *a, const binmat_data_t *b, binmat_index_t n) {
 binmat_index_t row;
 binmat_index_t col;
 binmat_index_t k;
 for (row = 0; row < n; row++) {
  for (col = 0; col < n; col++) {
   binmat_data_t temp = 0;
   for (k = 0; k < n; k++) {
    temp += binmat_getbit(a, n, row, k) * binmat_getbit(b, n, k, col);
   }
   binmat_setbit(output, n, row, col, temp ? 1 : 0);
  }
 }
}

canonical_original_code:
void binmat_multiply_slow(unsigned long long *output, unsigned long long *a, unsigned long long *b, unsigned int n) {
 unsigned int row;
 unsigned int col;
 unsigned int k;
 for (row = 0; row < n; row++) {
  for (col = 0; col < n; col++) {
   unsigned long long temp = 0;
   for (k = 0; k < n; k++) {
    temp += binmat_getbit(a, n, row, k) * binmat_getbit(b, n, k, col);
   }
   binmat_setbit(output, n, row, col, temp ? 1 : 0);
  }
 }
}

variable_types:
k
unsigned int

variable_types:
temp
unsigned long long


repo: devkev/binmat

original_code:
void binmat_multiply(binmat_data_t *output, const binmat_data_t *a, const binmat_data_t *b, binmat_index_t n) {
 binmat_index_t row;
 binmat_index_t col;
 binmat_index_t k;
 binmat_index_t arowoffset;
 binmat_index_t bcoloffset;
 binmat_index_t colchunk;
 binmat_index_t chunkbit;
 binmat_data_t result;
 binmat_data_t r;
 binmat_data_t this;
 binmat_data_t mask;
 char s_result[(1) * ((sizeof(binmat_data_t))*8) + 1];
 char s_r[(1) * ((sizeof(binmat_data_t))*8) + 1];
 char s_r2[(1) * ((sizeof(binmat_data_t))*8) + 1];
 char s_this[(1) * ((sizeof(binmat_data_t))*8) + 1];
 char s_mask[(1) * ((sizeof(binmat_data_t))*8) + 1];
 ;
 for (k = 0; k < n*( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ); k++) {
  output[k] = 0;
 }
 ;
 for (row = 0, arowoffset = 0; row < n; row++, arowoffset += ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 )) {
  ;
  col = 0;
  bcoloffset = 0;
  ;
  ;
  for (colchunk = 0; colchunk < ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ); colchunk++) {
   ;
   result = 0;
   ;
   for (chunkbit = 0; chunkbit < ((sizeof(binmat_data_t))*8) && col < n; chunkbit++, col++, bcoloffset += ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 )) {
    ;
    r = 0;
    ;
    for (k = 0; k < ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ) - 1; k++) {
     ;
     this = a[arowoffset + k] & b[bcoloffset + k];
     r |= a[arowoffset + k] & b[bcoloffset + k];
    }
    ;
    this = a[arowoffset + k] & b[bcoloffset + k] & ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((binmat_data_t)(zero - 1)) : ((one << ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((sizeof(binmat_data_t))*8) : (n)%((sizeof(binmat_data_t))*8) )) - 1) );
    r |= a[arowoffset + k] & b[bcoloffset + k] & ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((binmat_data_t)(zero - 1)) : ((one << ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((sizeof(binmat_data_t))*8) : (n)%((sizeof(binmat_data_t))*8) )) - 1) );
    ;
    this = r;
    for (k = 0; k < ((sizeof(binmat_data_t))*8); k++) {
     this >>= 1;
     r |= this;
    }
    r &= 1U;
    r <<= chunkbit;
    result |= r;
   }
   ;
   ;
   output[arowoffset + colchunk] = result;
  }
  ;
 }
 ;
}

canonical_original_code:
void binmat_multiply(unsigned long long *output, unsigned long long *a, unsigned long long *b, unsigned int n) {
 unsigned int row;
 unsigned int col;
 unsigned int k;
 unsigned int arowoffset;
 unsigned int bcoloffset;
 unsigned int colchunk;
 unsigned int chunkbit;
 unsigned long long result;
 unsigned long long r;
 unsigned long long this;
 unsigned long long mask;
 char s_result[-1];
 char s_r[-1];
 char s_r2[-1];
 char s_this[-1];
 char s_mask[-1];
 ;
 for (k = 0; k < n*( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ); k++) {
  output[k] = 0;
 }
 ;
 for (row = 0, arowoffset = 0; row < n; row++, arowoffset += ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 )) {
  ;
  col = 0;
  bcoloffset = 0;
  ;
  ;
  for (colchunk = 0; colchunk < ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ); colchunk++) {
   ;
   result = 0;
   ;
   for (chunkbit = 0; chunkbit < ((sizeof(binmat_data_t))*8) && col < n; chunkbit++, col++, bcoloffset += ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 )) {
    ;
    r = 0;
    ;
    for (k = 0; k < ( ((n)%((sizeof(binmat_data_t))*8)==0) ? (n)/((sizeof(binmat_data_t))*8) : (n)/((sizeof(binmat_data_t))*8) + 1 ) - 1; k++) {
     ;
     this = a[arowoffset + k] & b[bcoloffset + k];
     r |= a[arowoffset + k] & b[bcoloffset + k];
    }
    ;
    this = a[arowoffset + k] & b[bcoloffset + k] & ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((binmat_data_t)(zero - 1)) : ((one << ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((sizeof(binmat_data_t))*8) : (n)%((sizeof(binmat_data_t))*8) )) - 1) );
    r |= a[arowoffset + k] & b[bcoloffset + k] & ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((binmat_data_t)(zero - 1)) : ((one << ( ((n)%((sizeof(binmat_data_t))*8)==0) ? ((sizeof(binmat_data_t))*8) : (n)%((sizeof(binmat_data_t))*8) )) - 1) );
    ;
    this = r;
    for (k = 0; k < ((sizeof(binmat_data_t))*8); k++) {
     this >>= 1;
     r |= this;
    }
    r &= 1U;
    r <<= chunkbit;
    result |= r;
   }
   ;
   ;
   output[arowoffset + colchunk] = result;
  }
  ;
 }
 ;
}

variable_types:
output
unsigned long long *

variable_types:
a
unsigned long long *

variable_types:
b
unsigned long long *

variable_types:
n
unsigned int

variable_types:
row
unsigned int

variable_types:
col
unsigned int

variable_types:
arowoffset
unsigned int

variable_types:
bcoloffset
unsigned int

variable_types:
colchunk
unsigned int

variable_types:
chunkbit
unsigned int

variable_types:
result
unsigned long long

variable_types:
r
unsigned long long

variable_types:
this
unsigned long long

variable_types:
mask
unsigned long long

return_type: void


decompiled_code:
void __fastcall binmat_power(void *a1, const void *a2, __int64 a3, unsigned int a4, unsigned int a5)
{
int v8; // ebx
int v9; // ebp
int v10; // [rsp+0h] [rbp-54h]
void *ptr; // [rsp+4h] [rbp-50h]
__int64 v12[9]; // [rsp+Ch] [rbp-48h]

if ( a5 )
{
if ( a5 == 1 )
{
binmat_copy(a1, a2, a4);
}
else
{
v8 = ((unsigned __int8)a5 ^ 1) & 1;
v10 = 1 - v8;
v12[0] = (__int64)a1;
ptr = binmat_alloc(a4);
v12[1] = (__int64)ptr;
binmat_multiply(v12[1 - v8], (__int64)a2, a3, a4);
if ( a5 > 2 )
{
v9 = 2;
while ( 1 )
{
binmat_multiply(v12[v8], v12[v10], a3, a4);
++v9;
v10 = v8;
if ( a5 == v9 )
break;
v8 = 1 - v8;
}
}
free(ptr);
}
}
}

original_code:
void binmat_power(binmat_data_t *output, const binmat_data_t *a, const binmat_data_t *trans, binmat_index_t n, unsigned int pow) {
 binmat_index_t i;
 binmat_data_t *temp[2];
 unsigned int which = 1 - pow % 2;
 unsigned int other = 1 - which;
 ;
 if (pow == 0) {
  ;
 } else if (pow == 1) {
  ;
  binmat_copy(output, a, n);
 } else {
  ;
  temp[0] = output;
  temp[1] = binmat_alloc(n);
  ;
  ;
  binmat_multiply(temp[other], a, trans, n);
  ;
  for (i = 2; i < pow; i++) {
   ;
   binmat_multiply(temp[which], temp[other], trans, n);
   other = which;
   which = 1 - which;
  }
  ;
  free(temp[1]);
 }
 ;
}

canonical_original_code:
void binmat_power(unsigned long long *output, unsigned long long *a, unsigned long long *trans, unsigned int n, unsigned int pow) {
 unsigned int i;
 unsigned long long *temp[2];
 unsigned int which = 1 - pow % 2;
 unsigned int other = 1 - which;
 ;
 if (pow == 0) {
  ;
 } else if (pow == 1) {
  ;
  binmat_copy(output, a, n);
 } else {
  ;
  temp[0] = output;
  temp[1] = binmat_alloc(n);
  ;
  ;
  binmat_multiply(temp[other], a, trans, n);
  ;
  for (i = 2; i < pow; i++) {
   ;
   binmat_multiply(temp[which], temp[other], trans, n);
   other = which;
   which = 1 - which;
  }
  ;
  free(temp[1]);
 }
 ;
}

variable_types:
trans
unsigned long long *

variable_types:
pow
unsigned int

variable_types:
i
unsigned int

variable_types:
temp
unsigned long long *[2]

variable_types:
which
unsigned int

variable_types:
other
unsigned int


decompiled_code:
void __fastcall binmat_power_slow(void *a1, const void *a2, unsigned int a3, unsigned int a4)
{
void *v6; // rbp
int v7; // er15

v6 = binmat_alloc(a3);
if ( a4 )
{
if ( a4 == 1 )
{
binmat_copy(a1, a2, a3);
}
else
{
binmat_multiply_slow((__int64)a1, (__int64)a2, (__int64)a2, a3);
if ( a4 > 2 )
{
v7 = 2;
do
{
binmat_multiply_slow((__int64)v6, (__int64)a1, (__int64)a2, a3);
binmat_copy(a1, v6, a3);
++v7;
}
while ( a4 != v7 );
}
}
}
free(v6);
}

original_code:
void binmat_power_slow(binmat_data_t *output, const binmat_data_t *a, binmat_index_t n, unsigned int pow) {
 unsigned int i;
 binmat_data_t *temp = binmat_alloc(n);
 if (pow == 0) {
 } else if (pow == 1) {
  binmat_copy(output, a, n);
 } else {
  binmat_multiply_slow(output, a, a, n);
  for (i = 2; i < pow; i++) {
   binmat_multiply_slow(temp, output, a, n);
   binmat_copy(output, temp, n);
  }
 }
 free(temp);
}

canonical_original_code:
void binmat_power_slow(unsigned long long *output, unsigned long long *a, unsigned int n, unsigned int pow) {
 unsigned int i;
 unsigned long long *temp = binmat_alloc(n);
 if (pow == 0) {
 } else if (pow == 1) {
  binmat_copy(output, a, n);
 } else {
  binmat_multiply_slow(output, a, a, n);
  for (i = 2; i < pow; i++) {
   binmat_multiply_slow(temp, output, a, n);
   binmat_copy(output, temp, n);
  }
 }
 free(temp);
}

variable_types:
output
unsigned long long *

variable_types:
a
unsigned long long *

variable_types:
n
unsigned int

variable_types:
temp
unsigned long long *


repo: devsim/pisces

decompiled_code:
const char *alloc_pt()
{
int v0; // ebx
const char *result; // rax
_DWORD *v2; // rdx
int v3; // edi
__int64 v4; // rax
int i; // eax

v0 = np;
result = "Too many points generated";
if ( np <= 2999 )
{
*((_QWORD *)&pt + v0) = malloc(0x40uLL);
v2 = (_DWORD *)*((_QWORD *)&pt + np);
result = "Out of storage in alloc_pt";
if ( v2 )
{
*v2 = LC2;
v3 = np;
v4 = np;
*(_DWORD *)(*((_QWORD *)&pt + np) + 4LL) = LC2;
*(_DWORD *)(*((_QWORD *)&pt + v4) + 16LL) = 0;
*(_DWORD *)(*((_QWORD *)&pt + v4) + 20LL) = 0;
for ( i = 0; i != 10; ++i )
*(_DWORD *)(*((_QWORD *)&pt + v3) + 4LL * i + 24) = -1;
np = v3 + 1;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
const char *func0()
{
int v0; // ebx
const char *result; // rax
_DWORD *v2; // rdx
int v3; // edi
__int64 v4; // rax
int i; // eax

v0 = np;
result = "Too many points generated";
if ( np <= 2999 )
{
*((_QWORD *)&pt + v0) = malloc(0x40uLL);
v2 = (_DWORD *)*((_QWORD *)&pt + np);
result = "Out of storage in alloc_pt";
if ( v2 )
{
*v2 = LC2;
v3 = np;
v4 = np;
*(_DWORD *)(*((_QWORD *)&pt + np) + 4LL) = LC2;
*(_DWORD *)(*((_QWORD *)&pt + v4) + 16LL) = 0;
*(_DWORD *)(*((_QWORD *)&pt + v4) + 20LL) = 0;
for ( i = 0; i != 10; ++i )
*(_DWORD *)(*((_QWORD *)&pt + v3) + 4LL * i + 24) = -1;
np = v3 + 1;
result = 0LL;
}
}
return result;
}

original_code:
char *alloc_pt()
{
    int j;
    if (np+1 > 3000) return ("Too many points generated");
    pt[np] = (pt_typ *) malloc (sizeof (pt_typ));
    if (!pt[np]) return ("Out of storage in alloc_pt");
    pt[ np ]->cord[ 0 ] = 1.0e38;
    pt[ np ]->cord[ 1 ] = 1.0e38;
    pt[ np ]->flags = 0;
    pt[ np ]->nn = 0;
    for (j = 0; j < 10; j++)
 pt[ np]->nd[ j] = -1;
    np++;
    return(0);
}

canonical_original_code:
char *alloc_pt()
{
    int j;
    if (np+1 > 3000) return ("Too many points generated");
    pt[np] = (struct pt_str *) malloc (sizeof (pt_typ));
    if (!pt[np]) return ("Out of storage in alloc_pt");
    pt[ np ]->cord[ 0 ] = 1.0e38;
    pt[ np ]->cord[ 1 ] = 1.0e38;
    pt[ np ]->flags = 0;
    pt[ np ]->nn = 0;
    for (j = 0; j < 10; j++)
 pt[ np]->nd[ j] = -1;
    np++;
    return(0);
}

variable_types: j int

return_type: char *

user_defined_types: struct pt_str { float cord[2]; float cordo[2]; int flags; int nn; int nd[10]; }


decompiled_code:
const char *alloc_nd()
{
int v0; // ebx
const char *v1; // rdx
int v3; // eax
__int64 v4; // rcx
__int64 i; // rax
unsigned int v6; // ecx

v0 = nn;
v1 = "Too many nodes generated";
if ( nn <= 2998 )
{
*((_QWORD *)&nd + v0) = malloc(0x120uLL);
v3 = nn;
v4 = *((_QWORD *)&nd + nn);
v1 = "Out of storage in alloc_nd";
if ( v4 )
{
*(_DWORD *)(v4 + 280) = -1;
*(_DWORD *)(*((_QWORD *)&nd + v3) + 240LL) = -1;
*(_DWORD *)(*((_QWORD *)&nd + v3) + 264LL) = 0;
*(_QWORD *)(*((_QWORD *)&nd + v3) + 272LL) = 0LL;
*(double *)(*((_QWORD *)&nd + v3) + 248LL) = (double)process_step;
*(_QWORD *)(*((_QWORD *)&nd + v3) + 256LL) = total;
for ( i = 0LL; i != 30; ++i )
{
v6 = *((_DWORD *)&soltoimp + i);
if ( v6 <= 0x12 && ((1LL << v6) & 0x43C3F) != 0 )
*(_QWORD *)(*((_QWORD *)&nd + nn) + 8LL * (int)i) = LC5;
else
*(_QWORD *)(*((_QWORD *)&nd + nn) + 8LL * (int)i) = 0LL;
}
++nn;
v1 = 0LL;
}
}
return v1;
}

canonical_decompiled_code:
const char *func1()
{
int v0; // ebx
const char *v1; // rdx
int v3; // eax
__int64 v4; // rcx
__int64 i; // rax
unsigned int v6; // ecx

v0 = nn;
v1 = "Too many nodes generated";
if ( nn <= 2998 )
{
*((_QWORD *)&nd + v0) = malloc(0x120uLL);
v3 = nn;
v4 = *((_QWORD *)&nd + nn);
v1 = "Out of storage in alloc_nd";
if ( v4 )
{
*(_DWORD *)(v4 + 280) = -1;
*(_DWORD *)(*((_QWORD *)&nd + v3) + 240LL) = -1;
*(_DWORD *)(*((_QWORD *)&nd + v3) + 264LL) = 0;
*(_QWORD *)(*((_QWORD *)&nd + v3) + 272LL) = 0LL;
*(double *)(*((_QWORD *)&nd + v3) + 248LL) = (double)process_step;
*(_QWORD *)(*((_QWORD *)&nd + v3) + 256LL) = total;
for ( i = 0LL; i != 30; ++i )
{
v6 = *((_DWORD *)&soltoimp + i);
if ( v6 <= 0x12 && ((1LL << v6) & 0x43C3F) != 0 )
*(_QWORD *)(*((_QWORD *)&nd + nn) + 8LL * (int)i) = LC5;
else
*(_QWORD *)(*((_QWORD *)&nd + nn) + 8LL * (int)i) = 0LL;
}
++nn;
v1 = 0LL;
}
}
return v1;
}

original_code:
char *alloc_nd()
{
    int j;
    if (nn + 1 >= 3000) return("Too many nodes generated");
    nd[nn] = (nd_typ *) malloc (sizeof (nd_typ));
    if (!nd[nn]) return ("Out of storage in alloc_nd");
    nd[ nn ]->pt = -1;
    nd[ nn ]->mater = -1;
    nd[ nn ]->ne = 0;
    nd[ nn ]->tri = 0;
    nd[ nn ]->step = process_step;
    nd[ nn ]->time = total;
    for (j = 0; j < 30; j++) {
 switch ( soltoimp[j] ) {
 case 2:
 case 5 :
 case 3 :
 case 4:
 case 1 :
 case 0 :
 case 10:
 case 11:
 case 12 :
 case 13:
 case 18:
     nd[nn]->sol[j] = 1.0e5;
     break;
 default:
     nd[nn]->sol[j] = 0.0;
     break;
 }
    }
    nn++;
    return(0);
}

canonical_original_code:
char *alloc_nd()
{
    int j;
    if (nn + 1 >= 3000) return("Too many nodes generated");
    nd[nn] = (struct nd_str *) malloc (sizeof (nd_typ));
    if (!nd[nn]) return ("Out of storage in alloc_nd");
    nd[ nn ]->pt = -1;
    nd[ nn ]->mater = -1;
    nd[ nn ]->ne = 0;
    nd[ nn ]->tri = 0;
    nd[ nn ]->step = process_step;
    nd[ nn ]->time = total;
    for (j = 0; j < 30; j++) {
 switch ( soltoimp[j] ) {
 case 2:
 case 5 :
 case 3 :
 case 4:
 case 1 :
 case 0 :
 case 10:
 case 11:
 case 12 :
 case 13:
 case 18:
     nd[nn]->sol[j] = 1.0e5;
     break;
 default:
     nd[nn]->sol[j] = 0.0;
     break;
 }
    }
    nn++;
    return(0);
}

user_defined_types: struct nd_str { double sol[30]; int mater; double step; double time; int ne; int *tri; int pt; }


original_code:
char *alloc_tri()
{
    int j;
    if (ne + 1 >= 6000) return("Too many triangles generated");
    tri[ne] = (tri_typ *) calloc (1, sizeof (tri_typ));
    if (!tri[ne]) return ("Out of storage in alloc_tri");
    for (j = 0; j < 3; j++) {
 tri[ ne ]->nd [ j ] = tri[ ne ]->nd0 [ j ] = -1;
 tri[ ne ]->nb [ j ] = tri[ ne ]->nb0 [ j ] = -1;
 tri[ ne ]->ehed[j] = tri[ ne ]->d[j] = tri[ ne ]->earea[j] = 1.0e38;
 tri[ ne ]->sig[ j ] = 0;
    }
    tri[ne]->fath = -32767;
    tri[ne]->son = -32767;
    tri[ne]->level = 0;
    ne++;
    return(0);
}

canonical_original_code:
char *alloc_tri()
{
    int j;
    if (ne + 1 >= 6000) return("Too many triangles generated");
    tri[ne] = (struct tri_str *) calloc (1, sizeof (tri_typ));
    if (!tri[ne]) return ("Out of storage in alloc_tri");
    for (j = 0; j < 3; j++) {
 tri[ ne ]->nd [ j ] = tri[ ne ]->nd0 [ j ] = -1;
 tri[ ne ]->nb [ j ] = tri[ ne ]->nb0 [ j ] = -1;
 tri[ ne ]->ehed[j] = tri[ ne ]->d[j] = tri[ ne ]->earea[j] = 1.0e38;
 tri[ ne ]->sig[ j ] = 0;
    }
    tri[ne]->fath = -32767;
    tri[ne]->son = -32767;
    tri[ne]->level = 0;
    ne++;
    return(0);
}

user_defined_types: struct tri_str { int nd[3]; int nb[3]; int nd0[3]; int nb0[3]; float ehed[3]; float d[3]; float earea[3]; float sig[3]; int regnum; int fath; int son; int level; }


waste

original_code:
int waste()
{
    int ie, save_ne = ne, new_tri[6000],
 in, save_nn = nn, new_nd[3000],
 ip, save_np = np, new_pt[3000],
 j;
    tri_typ *tswap; nd_typ *nswap; pt_typ *pswap;
    for (ne = 0, ie = 0; ie < save_ne; ie++)
 if ((tri[ie]->regnum == (-32767))) {
     new_tri[ie] = -1; dis_1tri (&tri[ie]);
     }
 else {
     new_tri [ie] = ne;
     tswap = tri[ ie]; tri[ie] = 0; tri[ ne++] = tswap;
     }
    for (nn = 0, in = 0; in < save_nn; in++)
 if ((nd [in]->mater == (-32767))) {
     new_nd[in] = -1; dis_1nd (&nd[in]);
     }
 else {
     new_nd[in] = nn;
     nswap = nd[ in]; nd[ in] = 0; nd[ nn++] = nswap;
     }
    for (np = 0, ip = 0; ip < save_np; ip++)
 if ((pt [ip]->flags == (-32767))) {
     new_pt[ip] = -1; dis_1pt (&pt[ip]);
     }
 else {
     new_pt[ip] = np;
     pswap = pt[ ip]; pt[ ip] = 0; pt[np++] = pswap;
     }
    for (ie = 0; ie < ne; ie++)
 for (j=0; j < 3; j++) {
     if ((tri[ie]->nd[j] = new_nd[ tri[ie]->nd[j] ]) < 0)
  panic("pointer to zombie node");
     if (tri[ie]->nb[j] >= 0)
  if ((tri[ie]->nb[j] = new_tri[ tri[ie]->nb[j] ]) < 0)
      panic("pointer to zombie triangle");
 }
    for (in = 0; in < nn; in++)
 if ((nd[in]->pt = new_pt[ nd[in]->pt ]) < 0)
     panic("pointer to zombie point");
    for (ip = 0; ip < np; ip++)
 for (j=0; j < pt[ip]->nn; j++)
 if ((pt[ip]->nd[j]= new_nd[ pt[ip]->nd[j] ]) < 0)
     panic("pointer to zombie node");
    init_tri0();
    return (ne != save_ne || nn != save_nn || np != save_np);
}

canonical_original_code:
int waste()
{
    int ie; int save_ne = ne; int new_tri[6000]; int in; int save_nn = nn; int new_nd[3000]; int ip; int save_np = np; int new_pt[3000]; int j;
    struct tri_str *tswap; struct nd_str *nswap; struct pt_str *pswap;
    for (ne = 0, ie = 0; ie < save_ne; ie++)
 if ((tri[ie]->regnum == (-32767))) {
     new_tri[ie] = -1; dis_1tri (&tri[ie]);
     }
 else {
     new_tri [ie] = ne;
     tswap = tri[ ie]; tri[ie] = 0; tri[ ne++] = tswap;
     }
    for (nn = 0, in = 0; in < save_nn; in++)
 if ((nd [in]->mater == (-32767))) {
     new_nd[in] = -1; dis_1nd (&nd[in]);
     }
 else {
     new_nd[in] = nn;
     nswap = nd[ in]; nd[ in] = 0; nd[ nn++] = nswap;
     }
    for (np = 0, ip = 0; ip < save_np; ip++)
 if ((pt [ip]->flags == (-32767))) {
     new_pt[ip] = -1; dis_1pt (&pt[ip]);
     }
 else {
     new_pt[ip] = np;
     pswap = pt[ ip]; pt[ ip] = 0; pt[np++] = pswap;
     }
    for (ie = 0; ie < ne; ie++)
 for (j=0; j < 3; j++) {
     if ((tri[ie]->nd[j] = new_nd[ tri[ie]->nd[j] ]) < 0)
  panic("pointer to zombie node");
     if (tri[ie]->nb[j] >= 0)
  if ((tri[ie]->nb[j] = new_tri[ tri[ie]->nb[j] ]) < 0)
      panic("pointer to zombie triangle");
 }
    for (in = 0; in < nn; in++)
 if ((nd[in]->pt = new_pt[ nd[in]->pt ]) < 0)
     panic("pointer to zombie point");
    for (ip = 0; ip < np; ip++)
 for (j=0; j < pt[ip]->nn; j++)
 if ((pt[ip]->nd[j]= new_nd[ pt[ip]->nd[j] ]) < 0)
     panic("pointer to zombie node");
    init_tri0();
    return (ne != save_ne || nn != save_nn || np != save_np);
}

variable_types: ie int

variable_types: in int

variable_types: ip int

variable_types: struct tri_str { int nd[3]; int nb[3]; int nd0[3]; int nb0[3]; float ehed[3]; float d[3]; float earea[3]; float sig[3]; int regnum; int fath; int son; int level; } *

variable_types: struct nd_str { double sol[30]; int mater; double step; double time; int ne; int *tri; int pt; } *

variable_types: struct pt_str { float cord[2]; float cordo[2]; int flags; int nn; int nd[10]; } *

return_type: int


getvects

decompiled_code:
__int64 __fastcall getvects(float *a1, float *a2, int *a3, unsigned __int8 a4)
{
int v5; // edx
unsigned int v6; // er8
int v7; // ecx

v5 = a4;
v6 = 0;
if ( a4 != 0xFF )
{
v7 = 2;
if ( v5 > 99 )
{
v5 -= 100;
v7 = 3;
}
*a3 = v7;
*a1 = (float)(v5 % 10);
*a2 = (float)(v5 / 10);
v6 = 1;
}
return v6;
}

original_code:
static int getvects(float *x, float *y, int *pen, char cvect)
 {
 int v;
 v = cvect & 0377;
 if (v == 255) return (0);
 if (v >= 100) { *pen = 3; v -= 100; }
 else *pen = 2;
 *x = (float) (v % 10);
 *y = (float) (v / 10);
 return (1);
 }

variable_types:
x
float *

variable_types:
y
float *

variable_types:
pen
int *

variable_types: cvect char

variable_types: v int


original_code:
void symbl2(double x0, double y0, char cbuf[], int cnt, double hsize, double wsize, double angle, double hornt, double wornt)
 {
  float xstart, ystart;
 float xplot , yplot ;
 float xvect , yvect ;
 int pen;
 float xscale, yscale ;
 float Xinc;
 int ipnt;
 int doretn = 0 ;
 int i;
 if (cnt == 0 || hsize <= 0.0 || wsize <= 0.0)
  return;
 if (cnt < 0) {
  cnt = -cnt ;
  doretn = 1 ;
  }
 gplot2(98, 2, 0., 0.) ;
 xscale = wsize / curfont->sym_wid;
 yscale = hsize / curfont->sym_hit;
 Xinc = wsize ;
 xstart = x0 - (float)cnt * wsize * wornt;
 ystart = y0 - hsize * hornt;
 (gplot2(15,0,x0,y0),gplot2(17,0,angle,0.));
 for (i=0; i<cnt; i++) {
  ipnt = curfont->sym_locs[(int) *cbuf++];
  while (getvects(&xvect,&yvect,&pen, curfont->sym_vect[ipnt++]) )
   {
   yvect -= curfont->sym_dis;
   xplot = xstart + (xvect * xscale);
   yplot = ystart + (yvect * yscale);
   gplot2(pen, 0, xplot, yplot);
   }
  xstart += Xinc;
  }
 (gplot2(15,0,x0,y0),gplot2(17,0,-angle,0.));
 if (doretn) gplot2(3 , 0, x0 , y0) ;
 gplot2(98, -2, 0., 0.) ;
 }

canonical_original_code:
void symbl2(double x0, double y0, char cbuf[], int cnt, double hsize, double wsize, double angle, double hornt, double wornt)
 {
  float xstart; float ystart;
 float xplot; float yplot;
 float xvect; float yvect;
 int pen;
 float xscale; float yscale;
 float Xinc;
 int ipnt;
 int doretn = 0;
 int i;
 if (cnt == 0 || hsize <= 0.0 || wsize <= 0.0)
  return;
 if (cnt < 0) {
  cnt = -cnt ;
  doretn = 1 ;
  }
 gplot2(98, 2, 0., 0.) ;
 xscale = wsize / curfont->sym_wid;
 yscale = hsize / curfont->sym_hit;
 Xinc = wsize ;
 xstart = x0 - (float)cnt * wsize * wornt;
 ystart = y0 - hsize * hornt;
 (gplot2(15,0,x0,y0),gplot2(17,0,angle,0.));
 for (i=0; i<cnt; i++) {
  ipnt = curfont->sym_locs[(int) *cbuf++];
  while (getvects(&xvect,&yvect,&pen, curfont->sym_vect[ipnt++]) )
   {
   yvect -= curfont->sym_dis;
   xplot = xstart + (xvect * xscale);
   yplot = ystart + (yvect * yscale);
   gplot2(pen, 0, xplot, yplot);
   }
  xstart += Xinc;
  }
 (gplot2(15,0,x0,y0),gplot2(17,0,-angle,0.));
 if (doretn) gplot2(3 , 0, x0 , y0) ;
 gplot2(98, -2, 0., 0.) ;
 }

variable_types:
cbuf
char []

variable_types: cnt int

variable_types: hsize double

variable_types: wsize double

variable_types: angle double

variable_types: hornt double

variable_types: wornt double

variable_types: xstart float

variable_types: ystart float

variable_types: xplot float

variable_types: yplot float

variable_types: xvect float

variable_types: yvect float

variable_types: pen int

variable_types: xscale float

variable_types: yscale float

variable_types: Xinc float

variable_types: ipnt int

variable_types: doretn int

variable_types: i int


decompiled_code:
char *GP_init()
{
char *result; // rax

inited = 1;
result = &byte_592;
do
{
*result = 0;
result += 24;
}
while ( result != (char *)&unk_892 );
return result;
}

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

inited = 1;
result = &byte_592;
do
{
*result = 0;
result += 24;
}
while ( result != (char *)&unk_892 );
return result;
}

original_code:
static void
GP_init ()
{
 int i ;
 inited = 1 ;
 for (i = 0 ; i < 32; ) iobufs[i++].io_flg = 0 ;
 }

canonical_original_code:
static void GP_init()
{
 int i;
 inited = 1 ;
 for (i = 0 ; i < 32; ) iobufs[i++].io_flg = 0 ;
 }


decompiled_code:
__int64 x_kludge()
{
int v0; // eax
__int64 result; // rax

v0 = *(_DWORD *)(g_ivar1 + 8);
if ( v0 == 15 )
{
if ( rot_todo_2 )
{
gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, 0.0);
yrot_1 = 0;
xrot_0 = 0;
rot_todo_2 = 0;
}
if ( ang_todo_4 )
{
result = gp_xfrm(15LL, 0LL, *(float *)g_fvar1, *(float *)(g_fvar1 + 4), *(float *)&arot_3);
arot_3 = 0;
ang_todo_4 = 0;
}
else
{
result = g_fvar1;
xrot_0 = *(_DWORD *)g_fvar1;
yrot_1 = *(_DWORD *)(g_fvar1 + 4);
rot_todo_2 = 1;
}
}
else if ( v0 == 17 )
{
if ( ang_todo_4 )
{
gp_xfrm(15LL, 0LL, 0.0, 0.0, *(float *)&arot_3);
arot_3 = 0;
ang_todo_4 = 0;
}
if ( rot_todo_2 )
{
result = gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, *(float *)g_fvar1);
yrot_1 = 0;
xrot_0 = 0;
rot_todo_2 = 0;
}
else
{
result = g_fvar1;
arot_3 = *(_DWORD *)g_fvar1;
ang_todo_4 = 1;
}
}
else
{
result = ang_todo_4 | (unsigned int)rot_todo_2;
if ( ang_todo_4 | rot_todo_2 )
{
result = gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, *(float *)&arot_3);
arot_3 = 0;
yrot_1 = 0;
xrot_0 = 0;
ang_todo_4 = 0;
rot_todo_2 = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
__int64 result; // rax

v0 = *(_DWORD *)(g_ivar1 + 8);
if ( v0 == 15 )
{
if ( rot_todo_2 )
{
gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, 0.0);
yrot_1 = 0;
xrot_0 = 0;
rot_todo_2 = 0;
}
if ( ang_todo_4 )
{
result = gp_xfrm(15LL, 0LL, *(float *)g_fvar1, *(float *)(g_fvar1 + 4), *(float *)&arot_3);
arot_3 = 0;
ang_todo_4 = 0;
}
else
{
result = g_fvar1;
xrot_0 = *(_DWORD *)g_fvar1;
yrot_1 = *(_DWORD *)(g_fvar1 + 4);
rot_todo_2 = 1;
}
}
else if ( v0 == 17 )
{
if ( ang_todo_4 )
{
gp_xfrm(15LL, 0LL, 0.0, 0.0, *(float *)&arot_3);
arot_3 = 0;
ang_todo_4 = 0;
}
if ( rot_todo_2 )
{
result = gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, *(float *)g_fvar1);
yrot_1 = 0;
xrot_0 = 0;
rot_todo_2 = 0;
}
else
{
result = g_fvar1;
arot_3 = *(_DWORD *)g_fvar1;
ang_todo_4 = 1;
}
}
else
{
result = ang_todo_4 | (unsigned int)rot_todo_2;
if ( ang_todo_4 | rot_todo_2 )
{
result = gp_xfrm(15LL, 0LL, *(float *)&xrot_0, *(float *)&yrot_1, *(float *)&arot_3);
arot_3 = 0;
yrot_1 = 0;
xrot_0 = 0;
ang_todo_4 = 0;
rot_todo_2 = 0;
}
}
return result;
}

original_code:
static void
x_kludge()
 {
 static int rot_todo = 0 , ang_todo = 0;
 static float xrot=0.0, yrot=0.0, arot=0.0;
 switch (g_ivar1[( 2 << 0)]) {
 case 17:
  if (ang_todo) {
   gp_xfrm(15,0,0.0,0.0, arot) ;
   arot = 0.0 ; ang_todo = 0 ;
   }
  if (rot_todo) {
   gp_xfrm(15,0,xrot,yrot, g_fvar1[( 0 << 0)]);
   xrot = yrot = 0.0;
   rot_todo = 0;
   }
  else {
   arot = g_fvar1[( 0 << 0)];
   ang_todo = 1;
   }
  break ;
 case 15:
  if (rot_todo) {
   gp_xfrm(15,0, xrot, yrot, 0.0) ;
   xrot = yrot = 0.0 ; rot_todo = 0 ;
   }
  if (ang_todo) {
   gp_xfrm(15,0,g_fvar1[( 0 << 0)],g_fvar1[( 1 << 0)], arot);
   arot = 0.0;
   ang_todo = 0;
   }
  else {
   xrot = g_fvar1[( 0 << 0)];
   yrot = g_fvar1[( 1 << 0)];
   rot_todo = 1;
   }
  break;
 default:
  if (rot_todo || ang_todo) {
   gp_xfrm(15,0, xrot,yrot,arot);
   xrot = yrot = arot = 0.0 ;
   rot_todo = ang_todo = 0;
   }
  break ;
  }
 }

canonical_original_code:
static void x_kludge()
 {
 static int rot_todo = 0; static int ang_todo = 0;
 static float xrot = 0.0; static float yrot = 0.0; static float arot = 0.0;
 switch (g_ivar1[( 2 << 0)]) {
 case 17:
  if (ang_todo) {
   gp_xfrm(15,0,0.0,0.0, arot) ;
   arot = 0.0 ; ang_todo = 0 ;
   }
  if (rot_todo) {
   gp_xfrm(15,0,xrot,yrot, g_fvar1[( 0 << 0)]);
   xrot = yrot = 0.0;
   rot_todo = 0;
   }
  else {
   arot = g_fvar1[( 0 << 0)];
   ang_todo = 1;
   }
  break ;
 case 15:
  if (rot_todo) {
   gp_xfrm(15,0, xrot, yrot, 0.0) ;
   xrot = yrot = 0.0 ; rot_todo = 0 ;
   }
  if (ang_todo) {
   gp_xfrm(15,0,g_fvar1[( 0 << 0)],g_fvar1[( 1 << 0)], arot);
   arot = 0.0;
   ang_todo = 0;
   }
  else {
   xrot = g_fvar1[( 0 << 0)];
   yrot = g_fvar1[( 1 << 0)];
   rot_todo = 1;
   }
  break;
 default:
  if (rot_todo || ang_todo) {
   gp_xfrm(15,0, xrot,yrot,arot);
   xrot = yrot = arot = 0.0 ;
   rot_todo = ang_todo = 0;
   }
  break ;
  }
 }

variable_types: xrot float

variable_types: yrot float

variable_types: arot float


decompiled_code:
__int64 gp_setup()
{
char *v0; // rbx
int v1; // edx
int v2; // eax
__int64 v3; // rax
int v4; // eax
int v5; // edx
int v6; // eax
float v7; // xmm0_4
float v8; // xmm1_4
float v9; // xmm0_4
float v10; // xmm1_4
__int64 result; // rax

v0 = getenv("DEFPDEV");
if ( !v0 )
{
v0 = getenv("TERM");
if ( !v0 )
v0 = "default";
}
if ( g_devset || (int)gp_pdev(v0, 0LL) >= 0 )
{
if ( g_filset || (int)gp_pfil(&unk_52B, 0LL) >= 0 )
{
if ( g_caps[0] )
{
v1 = g_caps[5] - 1;
v2 = g_caps[7] - 1;
if ( v1 <= 0 )
v1 = 1;
g_caps[5] = v1;
if ( v2 <= 0 )
v2 = 1;
g_caps[7] = v2;
if ( g_caps[4] <= 0 )
g_caps[4] = 1;
if ( g_caps[6] <= 0 )
g_caps[6] = 1;
*g_ivar1 = g_caps[5];
*(_DWORD *)(g_ivar1 + 4LL) = g_caps[7];
alu12((unsigned int)g_caps[96]);
v3 = g_ivar1;
if ( (int)*g_ivar1 > 0 )
g_caps[5] = *g_ivar1;
v4 = *(_DWORD *)(v3 + 4);
if ( v4 > 0 )
g_caps[7] = v4;
if ( g_xshint > 0.0 && g_yshint > 0.0 )
{
v5 = (int)(float)(g_xshint * (float)g_caps[4]);
v6 = (int)(float)(g_yshint * (float)g_caps[6]);
if ( g_caps[5] > v5 && v5 > 0 )
g_caps[5] = v5;
if ( g_caps[7] > v6 && v6 > 0 )
g_caps[7] = v6;
}
sv_igpo = g_caps[1];
if ( *(float *)&g_caps[25] < 0.0 )
g_caps[25] = 0;
if ( *(float *)&g_caps[26] < 0.0 )
g_caps[26] = 0;
v7 = (float)(g_caps[5] - g_caps[12]) / (float)g_caps[4];
v8 = *(float *)&g_caps[27];
if ( v8 > v7 || v8 < 0.0 )
*(float *)&g_caps[27] = v7;
v9 = (float)(g_caps[7] - g_caps[13]) / (float)g_caps[6];
v10 = *(float *)&g_caps[28];
if ( v10 > v9 || v10 < 0.0 )
*(float *)&g_caps[28] = v9;
AdjustClip(31LL, 42LL, 0.0);
AdjustClip(32LL, 42LL, 0.0);
}
something = 0;
g_allset = 1;
result = 0LL;
}
else
{
g_caps[0] = 0;
fprintf(stdout, "** Error ** (%s) ", "gp_setup");
fwrite("can't open plot output file", 1uLL, 0x1BuLL, stdout);
fputc(10, stdout);
g_allset = 1;
result = 0xFFFFFFFFLL;
}
}
else
{
g_caps[0] = 0;
fprintf(stdout, "** Error ** (%s) ", "gp_setup");
fprintf(stdout, "can't find plot device '%s'", v0);
fputc(10, stdout);
g_allset = 1;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
int v1; // edx
int v2; // eax
__int64 v3; // rax
int v4; // eax
int v5; // edx
int v6; // eax
float v7; // xmm0_4
float v8; // xmm1_4
float v9; // xmm0_4
float v10; // xmm1_4
__int64 result; // rax

v0 = getenv("DEFPDEV");
if ( !v0 )
{
v0 = getenv("TERM");
if ( !v0 )
v0 = "default";
}
if ( g_devset || (int)gp_pdev(v0, 0LL) >= 0 )
{
if ( g_filset || (int)gp_pfil(&unk_52B, 0LL) >= 0 )
{
if ( g_caps[0] )
{
v1 = g_caps[5] - 1;
v2 = g_caps[7] - 1;
if ( v1 <= 0 )
v1 = 1;
g_caps[5] = v1;
if ( v2 <= 0 )
v2 = 1;
g_caps[7] = v2;
if ( g_caps[4] <= 0 )
g_caps[4] = 1;
if ( g_caps[6] <= 0 )
g_caps[6] = 1;
*g_ivar1 = g_caps[5];
*(_DWORD *)(g_ivar1 + 4LL) = g_caps[7];
alu12((unsigned int)g_caps[96]);
v3 = g_ivar1;
if ( (int)*g_ivar1 > 0 )
g_caps[5] = *g_ivar1;
v4 = *(_DWORD *)(v3 + 4);
if ( v4 > 0 )
g_caps[7] = v4;
if ( g_xshint > 0.0 && g_yshint > 0.0 )
{
v5 = (int)(float)(g_xshint * (float)g_caps[4]);
v6 = (int)(float)(g_yshint * (float)g_caps[6]);
if ( g_caps[5] > v5 && v5 > 0 )
g_caps[5] = v5;
if ( g_caps[7] > v6 && v6 > 0 )
g_caps[7] = v6;
}
sv_igpo = g_caps[1];
if ( *(float *)&g_caps[25] < 0.0 )
g_caps[25] = 0;
if ( *(float *)&g_caps[26] < 0.0 )
g_caps[26] = 0;
v7 = (float)(g_caps[5] - g_caps[12]) / (float)g_caps[4];
v8 = *(float *)&g_caps[27];
if ( v8 > v7 || v8 < 0.0 )
*(float *)&g_caps[27] = v7;
v9 = (float)(g_caps[7] - g_caps[13]) / (float)g_caps[6];
v10 = *(float *)&g_caps[28];
if ( v10 > v9 || v10 < 0.0 )
*(float *)&g_caps[28] = v9;
AdjustClip(31LL, 42LL, 0.0);
AdjustClip(32LL, 42LL, 0.0);
}
something = 0;
g_allset = 1;
result = 0LL;
}
else
{
g_caps[0] = 0;
fprintf(stdout, "** Error ** (%s) ", "gp_setup");
fwrite("can't open plot output file", 1uLL, 0x1BuLL, stdout);
fputc(10, stdout);
g_allset = 1;
result = 0xFFFFFFFFLL;
}
}
else
{
g_caps[0] = 0;
fprintf(stdout, "** Error ** (%s) ", "gp_setup");
fprintf(stdout, "can't find plot device '%s'", v0);
fputc(10, stdout);
g_allset = 1;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
gp_setup()
 {
 char *defdev ;
 char *getenv();
 float val ;
 char *rotnam = "gp_setup";
 if ( !(defdev = getenv("DEFPDEV")) && !(defdev = getenv("TERM")) )
  defdev = "default";
 if (!g_devset && gp_pdev(defdev, 0) <0) {
  g_caps.dev_type = 0;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "can't find plot device '%s'", defdev ), fprintf(stdout, "\n");
  g_allset = 1;
  return(-1);
  }
 if (!g_filset && gp_pfil("", 0) <0) {
  g_caps.dev_type = 0;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "can't open plot output file" ), fprintf(stdout, "\n");
  g_allset = 1;
  return(-1);
  }
 if (g_caps.dev_type != 0) {
  g_caps.PIXX-- ;
  g_caps.PIXY-- ;
  if (g_caps.PIXX <= 0) g_caps.PIXX = 1;
  if (g_caps.PIXY <= 0) g_caps.PIXY = 1;
  if (g_caps.PUNX <= 0) g_caps.PUNX = 1;
  if (g_caps.PUNY <= 0) g_caps.PUNY = 1;
  g_ivar1[( 0 << 0)] = g_caps.PIXX ;
  g_ivar1[( 1 << 0)] = g_caps.PIXY ;
  (void)alu12(g_caps.INIT) ;
  if (g_ivar1[( 0 << 0)] > 0) g_caps.PIXX = g_ivar1[( 0 << 0)] ;
  if (g_ivar1[( 1 << 0)] > 0) g_caps.PIXY = g_ivar1[( 1 << 0)] ;
  if (g_xshint > 0.0 && g_yshint > 0.0) {
   int px = g_xshint * g_caps.PUNX ;
   int py = g_yshint * g_caps.PUNY ;
   if (px < g_caps.PIXX && px > 0) g_caps.PIXX = px ;
   if (py < g_caps.PIXY && py > 0) g_caps.PIXY = py ;
   }
  sv_igpo = g_caps.IGPO ;
  if (g_caps.CLPLX < 0.0) g_caps.CLPLX = 0.0;
  if (g_caps.CLPLY < 0.0) g_caps.CLPLY = 0.0;
  val = (float)(g_caps.PIXX - g_caps.ORGX) / (float)g_caps.PUNX ;
  if (g_caps.CLPHX > val || g_caps.CLPHX < 0.0) g_caps.CLPHX = val ;
  val = (float)(g_caps.PIXY - g_caps.ORGY) / (float)g_caps.PUNY ;
  if (g_caps.CLPHY > val || g_caps.CLPHY < 0.0) g_caps.CLPHY = val ;
  AdjustClip(31, 42, 0., 0. ) ;
  AdjustClip(32, 42, 0., 0. ) ;
  }
 something = 0;
 g_allset = 1;
 return(0);
 }

canonical_original_code:
int gp_setup()
 {
 char *defdev;
 char *getenv();
 float val;
 char *rotnam = "gp_setup";
 if ( !(defdev = getenv("DEFPDEV")) && !(defdev = getenv("TERM")) )
  defdev = "default";
 if (!g_devset && gp_pdev(defdev, 0) <0) {
  g_caps.dev_type = 0;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "can't find plot device '%s'", defdev ), fprintf(stdout, "\n");
  g_allset = 1;
  return(-1);
  }
 if (!g_filset && gp_pfil("", 0) <0) {
  g_caps.dev_type = 0;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "can't open plot output file" ), fprintf(stdout, "\n");
  g_allset = 1;
  return(-1);
  }
 if (g_caps.dev_type != 0) {
  g_caps.PIXX-- ;
  g_caps.PIXY-- ;
  if (g_caps.PIXX <= 0) g_caps.PIXX = 1;
  if (g_caps.PIXY <= 0) g_caps.PIXY = 1;
  if (g_caps.PUNX <= 0) g_caps.PUNX = 1;
  if (g_caps.PUNY <= 0) g_caps.PUNY = 1;
  g_ivar1[( 0 << 0)] = g_caps.PIXX ;
  g_ivar1[( 1 << 0)] = g_caps.PIXY ;
  (void)alu12(g_caps.INIT) ;
  if (g_ivar1[( 0 << 0)] > 0) g_caps.PIXX = g_ivar1[( 0 << 0)] ;
  if (g_ivar1[( 1 << 0)] > 0) g_caps.PIXY = g_ivar1[( 1 << 0)] ;
  if (g_xshint > 0.0 && g_yshint > 0.0) {
   int px = g_xshint * g_caps.PUNX;
   int py = g_yshint * g_caps.PUNY;
   if (px < g_caps.PIXX && px > 0) g_caps.PIXX = px ;
   if (py < g_caps.PIXY && py > 0) g_caps.PIXY = py ;
   }
  sv_igpo = g_caps.IGPO ;
  if (g_caps.CLPLX < 0.0) g_caps.CLPLX = 0.0;
  if (g_caps.CLPLY < 0.0) g_caps.CLPLY = 0.0;
  val = (float)(g_caps.PIXX - g_caps.ORGX) / (float)g_caps.PUNX ;
  if (g_caps.CLPHX > val || g_caps.CLPHX < 0.0) g_caps.CLPHX = val ;
  val = (float)(g_caps.PIXY - g_caps.ORGY) / (float)g_caps.PUNY ;
  if (g_caps.CLPHY > val || g_caps.CLPHY < 0.0) g_caps.CLPHY = val ;
  AdjustClip(31, 42, 0., 0. ) ;
  AdjustClip(32, 42, 0., 0. ) ;
  }
 something = 0;
 g_allset = 1;
 return(0);
 }

variable_types:
defdev
char *

variable_types:
getenv
char *()

variable_types: val float

variable_types:
rotnam
char *

variable_types: px int

variable_types: py int


decompiled_code:
__int64 hard_work()
{
unsigned int v0; // ebx

if ( g_caps[0] == 1 )
{
v0 = g_caps[94];
if ( *(_DWORD *)(g_ivar1 + 8LL) == 2 )
v0 = g_caps[93];
if ( !something && v0 != -1 )
{
alu12(g_caps[98]);
something = 1;
}
alu12(v0);
}
else
{
v0 = -1;
if ( *(_DWORD *)(g_ivar1 + 8LL) == 2 )
{
something = 1;
prast(
(unsigned int)*g_ivar1,
*(unsigned int *)(g_ivar1 + 4LL),
(unsigned int)*g_ivar0,
*(unsigned int *)(g_ivar0 + 4LL));
}
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // ebx

if ( g_caps[0] == 1 )
{
v0 = g_caps[94];
if ( *(_DWORD *)(g_ivar1 + 8LL) == 2 )
v0 = g_caps[93];
if ( !something && v0 != -1 )
{
alu12(g_caps[98]);
something = 1;
}
alu12(v0);
}
else
{
v0 = -1;
if ( *(_DWORD *)(g_ivar1 + 8LL) == 2 )
{
something = 1;
prast(
(unsigned int)*g_ivar1,
*(unsigned int *)(g_ivar1 + 4LL),
(unsigned int)*g_ivar0,
*(unsigned int *)(g_ivar0 + 4LL));
}
}
return v0;
}

original_code:
int
hard_work ()
{
 int this_ent = (int)-1 ;
 if (g_caps.dev_type == 0x01) {
  this_ent = (g_ivar1[( 2 << 0)] == 2 ? g_caps.DRAW : g_caps.MOVE);
  if (!something && this_ent != (int)-1) {
   (void)alu12(g_caps.PLOP);
   something = 1;
   }
  (void)alu12(this_ent);
  }
 else {
  if (g_ivar1[( 2 << 0)] == 2) {
   something = 1 ;
   prast(g_ivar1[( 0 << 0)], g_ivar1[( 1 << 0)], g_ivar0[( 0 << 0)], g_ivar0[( 1 << 0)]);
   }
  }
 return this_ent ;
 }

canonical_original_code:
int hard_work()
{
 int this_ent = (int)-1;
 if (g_caps.dev_type == 0x01) {
  this_ent = (g_ivar1[( 2 << 0)] == 2 ? g_caps.DRAW : g_caps.MOVE);
  if (!something && this_ent != (int)-1) {
   (void)alu12(g_caps.PLOP);
   something = 1;
   }
  (void)alu12(this_ent);
  }
 else {
  if (g_ivar1[( 2 << 0)] == 2) {
   something = 1 ;
   prast(g_ivar1[( 0 << 0)], g_ivar1[( 1 << 0)], g_ivar0[( 0 << 0)], g_ivar0[( 1 << 0)]);
   }
  }
 return this_ent ;
 }


decompiled_code:
__int64 gp_work()
{
int v0; // edx
int v1; // ebx
int v2; // edx
__int64 result; // rax
char v4[8]; // [rsp+8h] [rbp-20h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h] BYREF
int v6; // [rsp+18h] [rbp-10h] BYREF
int v7; // [rsp+1Ch] [rbp-Ch]

v6 = *g_fvar1;
v7 = *(_DWORD *)(g_fvar1 + 4LL);
v0 = *(_DWORD *)(g_ivar1 + 8LL);
if ( (unsigned int)(v0 - 2) > 1 && v0 != 38 )
return simp_work((float *)&v6, (float *)&P0);
if ( g_logclp )
{
v1 = fclip(&v5, v4, &v6, &P0, &g_logbox);
if ( v1 < 0 )
{
l_wentout_6 = 1;
result = (unsigned int)l_lastok_5;
if ( l_lastok_5 )
result = *(_DWORD *)(g_ivar1 + 8LL) != 3;
l_lastok_5 = result;
}
else
{
if ( l_wentout_6 )
{
v2 = 3;
if ( l_lastok_5 )
v2 = *(_DWORD *)(g_ivar1 + 8LL);
phys_work((__int64)v4, (__int64)&l_Plast_4, v2);
l_wentout_6 = 0;
l_lastok_5 = 0;
}
if ( v1 > 0 )
{
l_Plast_4 = v5;
l_lastok_5 = *(_DWORD *)(g_ivar1 + 8LL) != 3;
l_wentout_6 = 1;
}
result = phys_work((__int64)&v5, (__int64)v4, *(_DWORD *)(g_ivar1 + 8LL));
}
}
else
{
result = phys_work((__int64)&v6, (__int64)&P0, v0);
}
P0 = v6;
dword_C7C = v7;
return result;
}

canonical_decompiled_code:
__int64 func5()
{
int v0; // edx
int v1; // ebx
int v2; // edx
__int64 result; // rax
char v4[8]; // [rsp+8h] [rbp-20h] BYREF
__int64 v5; // [rsp+10h] [rbp-18h] BYREF
int v6; // [rsp+18h] [rbp-10h] BYREF
int v7; // [rsp+1Ch] [rbp-Ch]

v6 = *g_fvar1;
v7 = *(_DWORD *)(g_fvar1 + 4LL);
v0 = *(_DWORD *)(g_ivar1 + 8LL);
if ( (unsigned int)(v0 - 2) > 1 && v0 != 38 )
return func3((float *)&v6, (float *)&P0);
if ( g_logclp )
{
v1 = fclip(&v5, v4, &v6, &P0, &g_logbox);
if ( v1 < 0 )
{
l_wentout_6 = 1;
result = (unsigned int)l_lastok_5;
if ( l_lastok_5 )
result = *(_DWORD *)(g_ivar1 + 8LL) != 3;
l_lastok_5 = result;
}
else
{
if ( l_wentout_6 )
{
v2 = 3;
if ( l_lastok_5 )
v2 = *(_DWORD *)(g_ivar1 + 8LL);
func4((__int64)v4, (__int64)&l_Plast_4, v2);
l_wentout_6 = 0;
l_lastok_5 = 0;
}
if ( v1 > 0 )
{
l_Plast_4 = v5;
l_lastok_5 = *(_DWORD *)(g_ivar1 + 8LL) != 3;
l_wentout_6 = 1;
}
result = func4((__int64)&v5, (__int64)v4, *(_DWORD *)(g_ivar1 + 8LL));
}
}
else
{
result = func4((__int64)&v6, (__int64)&P0, v0);
}
P0 = v6;
dword_C7C = v7;
return result;
}

original_code:
int
gp_work ()
{
 struct _fpoint2d P1 ;
 struct _fpoint2d Pa, Pb ;
 int nclip ;
 static struct _fpoint2d l_Plast ;
 static int l_wentout = 0 ;
 static int l_lastok = 0 ;
 char *rotnam = "gp_work";
 P1.x = g_fvar1[( 0 << 0)] ;
 P1.y = g_fvar1[( 1 << 0)] ;
 if (((g_ivar1[( 2 << 0)])==2 || (g_ivar1[( 2 << 0)])==3 || (g_ivar1[( 2 << 0)])==38)) {
  if (g_logclp) {
   nclip = fclip(&Pa, &Pb, &P1, &P0, g_logbox) ;
   if (nclip < 0) {
    l_wentout = 1 ;
    l_lastok = l_lastok && (g_ivar1[( 2 << 0)] != 3) ;
    goto see_ya ;
    }
   if (l_wentout) {
    int l_cmd = g_ivar1[( 2 << 0)] ;
    if (!l_lastok) l_cmd = 3 ;
    phys_work(&Pb, &l_Plast, l_cmd) ;
    l_lastok = l_wentout = 0 ;
    }
   if (nclip > 0) {
    l_Plast = Pa ;
    l_lastok = g_ivar1[( 2 << 0)] != 3 ;
    l_wentout = 1 ;
    }
   phys_work(&Pa, &Pb, g_ivar1[( 2 << 0)]) ;
   }
  else {
   phys_work(&P1, &P0, g_ivar1[( 2 << 0)]) ;
   }
     see_ya:
  P0.x = P1.x ;
  P0.y = P1.y ;
  }
 else simp_work(&P1, &P0);
 }

canonical_original_code:
int gp_work()
{
 struct _fpoint2d P1;
 struct _fpoint2d Pa; struct _fpoint2d Pb;
 int nclip;
 static struct _fpoint2d l_Plast;
 static int l_wentout = 0;
 static int l_lastok = 0;
 char *rotnam = "gp_work";
 P1.x = g_fvar1[( 0 << 0)] ;
 P1.y = g_fvar1[( 1 << 0)] ;
 if (((g_ivar1[( 2 << 0)])==2 || (g_ivar1[( 2 << 0)])==3 || (g_ivar1[( 2 << 0)])==38)) {
  if (g_logclp) {
   nclip = fclip(&Pa, &Pb, &P1, &P0, g_logbox) ;
   if (nclip < 0) {
    l_wentout = 1 ;
    l_lastok = l_lastok && (g_ivar1[( 2 << 0)] != 3) ;
    goto see_ya ;
    }
   if (l_wentout) {
    int l_cmd = g_ivar1[( 2 << 0)];
    if (!l_lastok) l_cmd = 3 ;
    phys_work(&Pb, &l_Plast, l_cmd) ;
    l_lastok = l_wentout = 0 ;
    }
   if (nclip > 0) {
    l_Plast = Pa ;
    l_lastok = g_ivar1[( 2 << 0)] != 3 ;
    l_wentout = 1 ;
    }
   phys_work(&Pa, &Pb, g_ivar1[( 2 << 0)]) ;
   }
  else {
   phys_work(&P1, &P0, g_ivar1[( 2 << 0)]) ;
   }
     see_ya:
  P0.x = P1.x ;
  P0.y = P1.y ;
  }
 else simp_work(&P1, &P0);
 }

variable_types:
Pa
struct _fpoint2d { float x; }

variable_types:
Pb
struct _fpoint2d { float x; }

variable_types: nclip int


decompiled_code:
__int64 save_work()
{
__int64 result; // rax
__int64 v1; // rdi

result = g_ivar1;
if ( *(int *)(g_ivar1 + 8LL) <= 99 )
{
v1 = g_caps[112];
if ( (_DWORD)v1 == -1 )
{
if ( first_0 )
gpwrhed(lu_oplt);
gpwrite(
lu_oplt,
*(unsigned int *)(g_ivar1 + 8LL),
*(unsigned int *)(g_ivar1 + 12LL),
*g_fvar1,
*(float *)(g_fvar1 + 4LL));
}
else
{
alu12(v1);
}
if ( first_0 )
first_0 = 0;
result = g_ivar1;
if ( *(_DWORD *)(g_ivar1 + 8LL) == 99 )
{
result = gp_setdn();
first_0 = 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
__int64 v1; // rdi

result = g_ivar1;
if ( *(int *)(g_ivar1 + 8LL) <= 99 )
{
v1 = g_caps[112];
if ( (_DWORD)v1 == -1 )
{
if ( first_0 )
gpwrhed(lu_oplt);
gpwrite(
lu_oplt,
*(unsigned int *)(g_ivar1 + 8LL),
*(unsigned int *)(g_ivar1 + 12LL),
*g_fvar1,
*(float *)(g_fvar1 + 4LL));
}
else
{
alu12(v1);
}
if ( first_0 )
first_0 = 0;
result = g_ivar1;
if ( *(_DWORD *)(g_ivar1 + 8LL) == 99 )
{
result = gp_setdn();
first_0 = 1;
}
}
return result;
}

original_code:
int
save_work ()
{
 static int first = 1 ;
 if (g_ivar1[( 2 << 0)] >= 100) return;
 if (g_caps.SFORM == (int)-1) {
  if (first) (void)gpwrhed(lu_oplt) ;
  (void)gpwrite(lu_oplt, g_ivar1[( 2 << 0)],g_ivar1[( 3 << 0)],g_fvar1[( 0 << 0)],g_fvar1[( 1 << 0)]);
  }
 else {
  (void)alu12(g_caps.SFORM);
  }
 if (first) first = 0 ;
 if (g_ivar1[( 2 << 0)] == 99) {
  gp_setdn() ;
  first = 1 ;
  }
 }

canonical_original_code:
int save_work()
{
 static int first = 1;
 if (g_ivar1[( 2 << 0)] >= 100) return;
 if (g_caps.SFORM == (int)-1) {
  if (first) (void)gpwrhed(lu_oplt) ;
  (void)gpwrite(lu_oplt, g_ivar1[( 2 << 0)],g_ivar1[( 3 << 0)],g_fvar1[( 0 << 0)],g_fvar1[( 1 << 0)]);
  }
 else {
  (void)alu12(g_caps.SFORM);
  }
 if (first) first = 0 ;
 if (g_ivar1[( 2 << 0)] == 99) {
  gp_setdn() ;
  first = 1 ;
  }
 }

variable_types: first int


ifloor

decompiled_code:
__int64 __fastcall ifloor(float a1)
{
__int64 result; // rax

if ( a1 < 0.0 )
result = (unsigned int)((int)a1 - 1);
else
result = (unsigned int)(int)a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(float a1)
{
__int64 result; // rax

if ( a1 < 0.0 )
result = (unsigned int)((int)a1 - 1);
else
result = (unsigned int)(int)a1;
return result;
}

original_code:
static int ifloor(float x)
{
    return ( (x >= 0)? (int) x : -1 + (int) x );
}

variable_types: x float


iceil

decompiled_code:
__int64 __fastcall iceil(float a1)
{
__int64 result; // rax

if ( a1 <= 0.0 )
result = (unsigned int)(int)a1;
else
result = (unsigned int)((int)a1 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(float a1)
{
__int64 result; // rax

if ( a1 <= 0.0 )
result = (unsigned int)(int)a1;
else
result = (unsigned int)((int)a1 + 1);
return result;
}

original_code:
static int iceil(float x)
{
    return( (x > 0)? 1 + (int) x : (int) x );
}


original_code:
int axtcs2(double fmin, double fmax, int lexpnd, int llog, float *axmin, float *axmax, float *axdel, int *ntics)
{
      int iaxlen, i, idim = 4 ;
      static int itic[] = { 3, 4, 4, 4};
      float scal;
      static float del[] = {0.2, 0.5, 1.0, 2.0};
      static float edge[] = {1.5, 3.5, 7.5, 100.};
if (llog) {
    if (fmin <= 0) fmin = 1e-38;
    if (fmax <= 0) fmax = 1e-38;
    fmin = (log(fmin)/ln10) ;
    fmax = (log(fmax)/ln10) ;
}
if (fmax < fmin) {
    scal = fmin;
    fmin = fmax;
    fmax = scal;
} else if (fmin == fmax) {
    if (fmin > 0) {
 fmax = 2*fmin;
 fmin = 0;
    } else if (fmin == 0) {
 fmin = -1;
 fmax = 1;
    } else {
 fmax = 0;
 fmin = 2*fmin;
    }
}
  if(!llog) {
      *axdel = fmax-fmin;
      i = ifloor ((log(*axdel)/ln10));
      scal = exp (i*ln10);
      iaxlen = ifloor (*axdel/scal);
      for (i=0; i < idim-1; i++)
 if (iaxlen <= edge[i]) break;
      *axdel = scal*del[i];
      *ntics = itic[i];
      if (lexpnd) {
         *axmin = ifloor(fmin/ *axdel);
         *axmax = iceil (fmax/ *axdel);
      } else {
         *axmin = iceil (fmin/ *axdel);
         *axmax = ifloor(fmax/ *axdel);
      }
      *axmin *= *axdel;
      *axmax *= *axdel;
      return(0);
  } else {
    fmin -= 1e-6*(fmax-fmin);
    fmax += 1e-6*(fmax-fmin);
    if (lexpnd) {
         *axmax = iceil (fmax);
         *axmin = ifloor(fmin);
      } else {
         *axmax = ifloor(fmax);
         *axmin = iceil (fmin);
      }
      if(*axmax - *axmin + 1 <= 5) {
         *ntics = -1;
      } else {
         *ntics = -2;
      }
      *axmax = exp (*axmax * ln10);
      *axmin = exp (*axmin * ln10);
      *axdel = 10.0;
      return(0);
  }
}

canonical_original_code:
int axtcs2(double fmin, double fmax, int lexpnd, int llog, float *axmin, float *axmax, float *axdel, int *ntics)
{
      int iaxlen; int i; int idim = 4;
      static int itic[] = { 3, 4, 4, 4};
      float scal;
      static float del[] = {0.2, 0.5, 1.0, 2.0};
      static float edge[] = {1.5, 3.5, 7.5, 100.};
if (llog) {
    if (fmin <= 0) fmin = 1e-38;
    if (fmax <= 0) fmax = 1e-38;
    fmin = (log(fmin)/ln10) ;
    fmax = (log(fmax)/ln10) ;
}
if (fmax < fmin) {
    scal = fmin;
    fmin = fmax;
    fmax = scal;
} else if (fmin == fmax) {
    if (fmin > 0) {
 fmax = 2*fmin;
 fmin = 0;
    } else if (fmin == 0) {
 fmin = -1;
 fmax = 1;
    } else {
 fmax = 0;
 fmin = 2*fmin;
    }
}
  if(!llog) {
      *axdel = fmax-fmin;
      i = ifloor ((log(*axdel)/ln10));
      scal = exp (i*ln10);
      iaxlen = ifloor (*axdel/scal);
      for (i=0; i < idim-1; i++)
 if (iaxlen <= edge[i]) break;
      *axdel = scal*del[i];
      *ntics = itic[i];
      if (lexpnd) {
         *axmin = ifloor(fmin/ *axdel);
         *axmax = iceil (fmax/ *axdel);
      } else {
         *axmin = iceil (fmin/ *axdel);
         *axmax = ifloor(fmax/ *axdel);
      }
      *axmin *= *axdel;
      *axmax *= *axdel;
      return(0);
  } else {
    fmin -= 1e-6*(fmax-fmin);
    fmax += 1e-6*(fmax-fmin);
    if (lexpnd) {
         *axmax = iceil (fmax);
         *axmin = ifloor(fmin);
      } else {
         *axmax = ifloor(fmax);
         *axmin = iceil (fmin);
      }
      if(*axmax - *axmin + 1 <= 5) {
         *ntics = -1;
      } else {
         *ntics = -2;
      }
      *axmax = exp (*axmax * ln10);
      *axmin = exp (*axmin * ln10);
      *axdel = 10.0;
      return(0);
  }
}

variable_types: fmin double

variable_types: fmax double

variable_types: lexpnd int

variable_types: llog int

variable_types:
axmin
float *

variable_types:
axmax
float *

variable_types:
axdel
float *

variable_types:
ntics
int *

variable_types: iaxlen int

variable_types: idim int

variable_types:
itic
int []

variable_types: scal float

variable_types:
del
float []

variable_types:
edge
float []


decompiled_code:
__int64 gp_setcap()
{
int v0; // ebx
int *v1; // rax
int v2; // eax
int *v3; // rdx
__int64 result; // rax
_DWORD *v5; // rbx
int v6; // eax
int *v7; // rdx
int v8; // eax
int *v9; // rdx
int v10; // eax
int *v11; // rdx
int v12; // eax
int v13; // eax
int *v14; // rdx
int v15; // eax
int v16; // ecx
int v17; // eax
int v18[3]; // [rsp+Ch] [rbp-Ch] BYREF

tcp = (__int64)&Tcap;
if ( Tcap < 0 )
goto LABEL_10;
v0 = 0;
v1 = &Tcap;
do
{
if ( (unsigned int)pgetflag(*((_QWORD *)v1 + 1)) )
{
g_caps[0] = *(_DWORD *)tcp;
++v0;
}
v1 = (int *)(tcp + 16);
tcp = (__int64)v1;
}
while ( *v1 >= 0 );
if ( v0 )
{
if ( v0 != 1 )
{
result = 0xFFFFFFFFLL;
if ( v0 > 1 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("can only have one of: VECT, RAST, SAVE", 1uLL, 0x26uLL, stdout);
fputc(10, stdout);
result = 0xFFFFFFFFLL;
}
return result;
}
}
else
{
LABEL_10:
if ( !(unsigned int)pgetflag("NULL") )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("must have one of: VECT, RAST, SAVE", 1uLL, 0x22uLL, stdout);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
g_caps[0] = 0;
}
bcp = (__int64)&Bcap;
v2 = Bcap;
if ( Bcap >= 0 )
{
v3 = &Bcap;
do
{
if ( (g_caps[0] & v2) != 0 || v2 == 15 )
{
v5 = (_DWORD *)*((_QWORD *)v3 + 2);
*v5 = pgetflag(*((_QWORD *)v3 + 1));
}
v3 = (int *)(bcp + 24);
bcp = (__int64)v3;
v2 = *v3;
}
while ( *v3 >= 0 );
}
icp = (__int64)&Icap;
v6 = Icap;
if ( Icap >= 0 )
{
v7 = &Icap;
do
{
if ( (g_caps[0] & v6) != 0 || v6 == 15 )
{
if ( (int)pgetnum(*((_QWORD *)v7 + 1), v18) < 0 )
**(_DWORD **)(icp + 16) = *(_DWORD *)(icp + 24);
else
**(_DWORD **)(icp + 16) = (int)(*(float *)v18 + 0.00001);
}
v7 = (int *)(icp + 32);
icp = (__int64)v7;
v6 = *v7;
}
while ( *v7 >= 0 );
}
fcp = (__int64)&Fcap;
v8 = Fcap;
if ( Fcap >= 0 )
{
v9 = &Fcap;
do
{
if ( (g_caps[0] & v8) != 0 || v8 == 15 )
{
if ( (int)pgetnum(*((_QWORD *)v9 + 1), v18) < 0 )
**(_DWORD **)(fcp + 16) = *(_DWORD *)(fcp + 24);
else
**(_DWORD **)(fcp + 16) = v18[0];
}
v9 = (int *)(fcp + 32);
fcp = (__int64)v9;
v8 = *v9;
}
while ( *v9 >= 0 );
}
scp = (__int64)&Scap;
v10 = Scap;
if ( Scap >= 0 )
{
v11 = &Scap;
do
{
if ( (g_caps[0] & v10) != 0 || v10 == 15 )
{
v12 = pgetstr(*((_QWORD *)v11 + 1), *((_QWORD *)v11 + 2));
if ( v12 <= 0 )
strcpy(*(char **)(scp + 16), *(const char **)(scp + 24));
else
*(_BYTE *)(*(_QWORD *)(scp + 16) + v12) = 0;
}
v11 = (int *)(scp + 32);
scp = (__int64)v11;
v10 = *v11;
}
while ( *v11 >= 0 );
}
g_poff = 0;
g_ioff = 0;
if ( (int)stab_mk((unsigned int)stabsiz, (unsigned int)stabent) < 0 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("PANIC: Can't allocate a symbol table! No room.", 1uLL, 0x2EuLL, stdout);
fputc(10, stdout);
}
pcp = (__int64)&Pcap;
v13 = Pcap;
if ( Pcap >= 0 )
{
v14 = &Pcap;
do
{
if ( (g_caps[0] & v13) != 0 )
{
v15 = pgetprg(*((_QWORD *)v14 + 1), g_prog, &g_poff, g_idat, &g_ioff);
if ( v15 <= 0 )
v15 = *(_DWORD *)(pcp + 24);
**(_DWORD **)(pcp + 16) = v15;
}
v14 = (int *)(pcp + 32);
pcp = (__int64)v14;
v13 = *v14;
}
while ( *v14 >= 0 );
}
if ( g_poff > 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, "PANIC: plotcap program too big! MAXPROG=%d", g_poff);
fputc(10, stdout);
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, " Talk to the maintainer; MAXPROG>%d", 1024LL);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
if ( g_ioff > 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, "PANIC: plotcap character data too big! MAXIDAT=%d", g_ioff);
fputc(10, stdout);
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, " Talk to the maintainer; MAXIDAT>%d", 1024LL);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
v16 = g_caps[11];
if ( (unsigned int)v16 > 8 )
{
g_caps[11] = 0;
result = 0LL;
if ( g_caps[0] != 2 )
return result;
v17 = 0;
LABEL_65:
g_caps[8] = v17;
return 0LL;
}
result = 0LL;
if ( g_caps[0] == 2 )
{
if ( v16 <= 0 )
v17 = 0;
else
v17 = g_caps[5] / v16;
goto LABEL_65;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // ebx
int *v1; // rax
int v2; // eax
int *v3; // rdx
__int64 result; // rax
_DWORD *v5; // rbx
int v6; // eax
int *v7; // rdx
int v8; // eax
int *v9; // rdx
int v10; // eax
int *v11; // rdx
int v12; // eax
int v13; // eax
int *v14; // rdx
int v15; // eax
int v16; // ecx
int v17; // eax
int v18[3]; // [rsp+Ch] [rbp-Ch] BYREF

tcp = (__int64)&Tcap;
if ( Tcap < 0 )
goto LABEL_10;
v0 = 0;
v1 = &Tcap;
do
{
if ( (unsigned int)pgetflag(*((_QWORD *)v1 + 1)) )
{
g_caps[0] = *(_DWORD *)tcp;
++v0;
}
v1 = (int *)(tcp + 16);
tcp = (__int64)v1;
}
while ( *v1 >= 0 );
if ( v0 )
{
if ( v0 != 1 )
{
result = 0xFFFFFFFFLL;
if ( v0 > 1 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("can only have one of: VECT, RAST, SAVE", 1uLL, 0x26uLL, stdout);
fputc(10, stdout);
result = 0xFFFFFFFFLL;
}
return result;
}
}
else
{
LABEL_10:
if ( !(unsigned int)pgetflag("NULL") )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("must have one of: VECT, RAST, SAVE", 1uLL, 0x22uLL, stdout);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
g_caps[0] = 0;
}
bcp = (__int64)&Bcap;
v2 = Bcap;
if ( Bcap >= 0 )
{
v3 = &Bcap;
do
{
if ( (g_caps[0] & v2) != 0 || v2 == 15 )
{
v5 = (_DWORD *)*((_QWORD *)v3 + 2);
*v5 = pgetflag(*((_QWORD *)v3 + 1));
}
v3 = (int *)(bcp + 24);
bcp = (__int64)v3;
v2 = *v3;
}
while ( *v3 >= 0 );
}
icp = (__int64)&Icap;
v6 = Icap;
if ( Icap >= 0 )
{
v7 = &Icap;
do
{
if ( (g_caps[0] & v6) != 0 || v6 == 15 )
{
if ( (int)pgetnum(*((_QWORD *)v7 + 1), v18) < 0 )
**(_DWORD **)(icp + 16) = *(_DWORD *)(icp + 24);
else
**(_DWORD **)(icp + 16) = (int)(*(float *)v18 + 0.00001);
}
v7 = (int *)(icp + 32);
icp = (__int64)v7;
v6 = *v7;
}
while ( *v7 >= 0 );
}
fcp = (__int64)&Fcap;
v8 = Fcap;
if ( Fcap >= 0 )
{
v9 = &Fcap;
do
{
if ( (g_caps[0] & v8) != 0 || v8 == 15 )
{
if ( (int)pgetnum(*((_QWORD *)v9 + 1), v18) < 0 )
**(_DWORD **)(fcp + 16) = *(_DWORD *)(fcp + 24);
else
**(_DWORD **)(fcp + 16) = v18[0];
}
v9 = (int *)(fcp + 32);
fcp = (__int64)v9;
v8 = *v9;
}
while ( *v9 >= 0 );
}
scp = (__int64)&Scap;
v10 = Scap;
if ( Scap >= 0 )
{
v11 = &Scap;
do
{
if ( (g_caps[0] & v10) != 0 || v10 == 15 )
{
v12 = pgetstr(*((_QWORD *)v11 + 1), *((_QWORD *)v11 + 2));
if ( v12 <= 0 )
strcpy(*(char **)(scp + 16), *(const char **)(scp + 24));
else
*(_BYTE *)(*(_QWORD *)(scp + 16) + v12) = 0;
}
v11 = (int *)(scp + 32);
scp = (__int64)v11;
v10 = *v11;
}
while ( *v11 >= 0 );
}
g_poff = 0;
g_ioff = 0;
if ( (int)stab_mk((unsigned int)stabsiz, (unsigned int)stabent) < 0 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fwrite("PANIC: Can't allocate a symbol table! No room.", 1uLL, 0x2EuLL, stdout);
fputc(10, stdout);
}
pcp = (__int64)&Pcap;
v13 = Pcap;
if ( Pcap >= 0 )
{
v14 = &Pcap;
do
{
if ( (g_caps[0] & v13) != 0 )
{
v15 = pgetprg(*((_QWORD *)v14 + 1), g_prog, &g_poff, g_idat, &g_ioff);
if ( v15 <= 0 )
v15 = *(_DWORD *)(pcp + 24);
**(_DWORD **)(pcp + 16) = v15;
}
v14 = (int *)(pcp + 32);
pcp = (__int64)v14;
v13 = *v14;
}
while ( *v14 >= 0 );
}
if ( g_poff > 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, "PANIC: plotcap program too big! MAXPROG=%d", g_poff);
fputc(10, stdout);
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, " Talk to the maintainer; MAXPROG>%d", 1024LL);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
if ( g_ioff > 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, "PANIC: plotcap character data too big! MAXIDAT=%d", g_ioff);
fputc(10, stdout);
fprintf(stdout, "** Error ** (%s) ", "gp_setcap");
fprintf(stdout, " Talk to the maintainer; MAXIDAT>%d", 1024LL);
fputc(10, stdout);
return 0xFFFFFFFFLL;
}
v16 = g_caps[11];
if ( (unsigned int)v16 > 8 )
{
g_caps[11] = 0;
result = 0LL;
if ( g_caps[0] != 2 )
return result;
v17 = 0;
LABEL_65:
g_caps[8] = v17;
return 0LL;
}
result = 0LL;
if ( g_caps[0] == 2 )
{
if ( v16 <= 0 )
v17 = 0;
else
v17 = g_caps[5] / v16;
goto LABEL_65;
}
return result;
}

original_code:
int
gp_setcap()
 {
 int tcnt ;
 float val;
 int ival, n;
 int nbytes ;
 char *rotnam = "gp_setcap";
 tcnt = 0;
 tcp = Tcap;
 while (tcp->ptyp >= 0) {
  if (pgetflag(tcp->nam)) {
   g_caps.dev_type = tcp->ptyp;
   tcnt++;
   }
  tcp++;
  }
 if (tcnt == 0 && pgetflag("NULL")) { g_caps.dev_type = 0; tcnt = 1; }
 if (tcnt != 1) {
  if (tcnt == 0) fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "must have one of: VECT, RAST, SAVE" ), fprintf(stdout, "\n");
  if (tcnt > 1) fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "can only have one of: VECT, RAST, SAVE" ), fprintf(stdout, "\n");
  return(-1);
  }
 bcp = Bcap;
 while (bcp->ptyp >= 0) {
  if ((bcp->ptyp & g_caps.dev_type) || bcp->ptyp == 0x0f) {
   *(bcp->loc) = pgetflag( bcp->nam );
   }
  bcp++ ;
  }
 icp = Icap;
 while (icp->ptyp >= 0) {
  if ((icp->ptyp & g_caps.dev_type) || icp->ptyp == 0x0f) {
   if (pgetnum(icp->nam,&val) < 0) *(icp->loc) = icp->def;
   else *(icp->loc) = (int) (val + .00001);
   }
  icp++ ;
  }
 fcp = Fcap;
 while (fcp->ptyp >= 0) {
  if ((fcp->ptyp & g_caps.dev_type) || fcp->ptyp == 0x0f) {
   if (pgetnum(fcp->nam,&val) < 0) *(fcp->loc) = fcp->def;
   else *(fcp->loc) = val;
   }
  fcp++ ;
  }
 scp = Scap;
 while (scp->ptyp >= 0) {
  if ((scp->ptyp & g_caps.dev_type) || scp->ptyp == 0x0f) {
   if ((n=pgetstr(scp->nam,scp->loc)) >0) scp->loc[n] = 0;
   else strcpy(scp->loc, scp->def);
   }
  scp++ ;
  }
 g_poff = 0;
 g_ioff = 0;
 if (stab_mk(stabsiz, stabent) < 0) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "PANIC: Can't allocate a symbol table! No room." ), fprintf(stdout, "\n") ;
  }
 pcp = Pcap;
 while (pcp->ptyp >= 0) {
  if (pcp->ptyp & g_caps.dev_type) {
   ival = pgetprg(pcp->nam, g_prog, &g_poff,
       g_idat, &g_ioff) ;
   if (ival > 0) *pcp->loc = ival;
   else *(pcp->loc) = pcp->def;
   }
  pcp++;
  }
 if (g_poff > 1024) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "PANIC: plotcap program too big! MAXPROG=%d", g_poff ), fprintf(stdout, "\n") ;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "       Talk to the maintainer; MAXPROG>%d", 1024 ), fprintf(stdout, "\n");
  return -1 ;
  }
 if (g_ioff > 1024) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "PANIC: plotcap character data too big! MAXIDAT=%d", g_ioff ), fprintf(stdout, "\n") ;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "       Talk to the maintainer; MAXIDAT>%d", 1024 ), fprintf(stdout, "\n");
  return -1 ;
  }
 if (g_caps.RPXB < 0 || g_caps.RPXB > 8) g_caps.RPXB = 0;
 if (g_caps.dev_type == 0x02) {
  if (g_caps.RPXB > 0) nbytes = g_caps.PIXX / g_caps.RPXB;
  else nbytes = 0;
  g_caps.BFSZ = nbytes ;
  }
 if (g_caps.dev_type == 0x01) {
  g_caps.BFSZ = g_caps.BFSZ ;
  }
 return(0);
 }

canonical_original_code:
int gp_setcap()
 {
 int tcnt;
 float val;
 int ival; int n;
 int nbytes;
 char *rotnam = "gp_setcap";
 tcnt = 0;
 tcp = Tcap;
 while (tcp->ptyp >= 0) {
  if (pgetflag(tcp->nam)) {
   g_caps.dev_type = tcp->ptyp;
   tcnt++;
   }
  tcp++;
  }
 if (tcnt == 0 && pgetflag("NULL")) { g_caps.dev_type = 0; tcnt = 1; }
 if (tcnt != 1) {
  if (tcnt == 0) fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "must have one of: VECT, RAST, SAVE" ), fprintf(stdout, "\n");
  if (tcnt > 1) fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "can only have one of: VECT, RAST, SAVE" ), fprintf(stdout, "\n");
  return(-1);
  }
 bcp = Bcap;
 while (bcp->ptyp >= 0) {
  if ((bcp->ptyp & g_caps.dev_type) || bcp->ptyp == 0x0f) {
   *(bcp->loc) = pgetflag( bcp->nam );
   }
  bcp++ ;
  }
 icp = Icap;
 while (icp->ptyp >= 0) {
  if ((icp->ptyp & g_caps.dev_type) || icp->ptyp == 0x0f) {
   if (pgetnum(icp->nam,&val) < 0) *(icp->loc) = icp->def;
   else *(icp->loc) = (int) (val + .00001);
   }
  icp++ ;
  }
 fcp = Fcap;
 while (fcp->ptyp >= 0) {
  if ((fcp->ptyp & g_caps.dev_type) || fcp->ptyp == 0x0f) {
   if (pgetnum(fcp->nam,&val) < 0) *(fcp->loc) = fcp->def;
   else *(fcp->loc) = val;
   }
  fcp++ ;
  }
 scp = Scap;
 while (scp->ptyp >= 0) {
  if ((scp->ptyp & g_caps.dev_type) || scp->ptyp == 0x0f) {
   if ((n=pgetstr(scp->nam,scp->loc)) >0) scp->loc[n] = 0;
   else strcpy(scp->loc, scp->def);
   }
  scp++ ;
  }
 g_poff = 0;
 g_ioff = 0;
 if (stab_mk(stabsiz, stabent) < 0) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "%s", "PANIC: Can't allocate a symbol table! No room." ), fprintf(stdout, "\n") ;
  }
 pcp = Pcap;
 while (pcp->ptyp >= 0) {
  if (pcp->ptyp & g_caps.dev_type) {
   ival = pgetprg(pcp->nam, g_prog, &g_poff,
       g_idat, &g_ioff) ;
   if (ival > 0) *pcp->loc = ival;
   else *(pcp->loc) = pcp->def;
   }
  pcp++;
  }
 if (g_poff > 1024) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "PANIC: plotcap program too big! MAXPROG=%d", g_poff ), fprintf(stdout, "\n") ;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "       Talk to the maintainer; MAXPROG>%d", 1024 ), fprintf(stdout, "\n");
  return -1 ;
  }
 if (g_ioff > 1024) {
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "PANIC: plotcap character data too big! MAXIDAT=%d", g_ioff ), fprintf(stdout, "\n") ;
  fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "       Talk to the maintainer; MAXIDAT>%d", 1024 ), fprintf(stdout, "\n");
  return -1 ;
  }
 if (g_caps.RPXB < 0 || g_caps.RPXB > 8) g_caps.RPXB = 0;
 if (g_caps.dev_type == 0x02) {
  if (g_caps.RPXB > 0) nbytes = g_caps.PIXX / g_caps.RPXB;
  else nbytes = 0;
  g_caps.BFSZ = nbytes ;
  }
 if (g_caps.dev_type == 0x01) {
  g_caps.BFSZ = g_caps.BFSZ ;
  }
 return(0);
 }

variable_types: tcnt int

variable_types: val float

variable_types: ival int

variable_types: n int

variable_types: nbytes int

variable_types:
rotnam
char *


decompiled_code:
void get_solval()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
char *get_solval( )
{
}

canonical_original_code:
char *get_solval()
{
}


vfunc

decompiled_code:
void vfunc()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
char *vfunc( )
{
}

canonical_original_code:
char *vfunc()
{
}


decompiled_code:
int gp_area()
{
__int64 v0; // rdx
int result; // eax
__int64 v2; // rcx
__int64 v3; // rdx
int v4; // ebp
__int64 v5; // r12
__int64 v6; // rbx
float v7; // er13
int v8; // er12
float v9; // xmm0_4
float v10; // ebx
__int64 v11; // rax

v0 = g_ivar1;
result = *(_DWORD *)(g_ivar1 + 12LL);
if ( result == 1 )
{
result = aloc;
if ( aloc <= 1023 )
{
LABEL_4:
v2 = g_fvar1;
v3 = result;
alist[2 * result++] = *g_fvar1;
aloc = result;
dword_8E4[2 * v3] = *(float *)(v2 + 4);
return result;
}
++aloc;
if ( result == 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_area");
fprintf(stdout, "too many points in polygon (max %d)", 1024LL);
result = fputc(10, stdout);
}
}
else
{
if ( result <= 1 )
{
if ( result )
return result;
goto LABEL_4;
}
result -= 2;
if ( (unsigned int)result <= 1 )
{
result = aloc;
if ( aloc > 2 )
{
if ( aloc > 1024 )
aloc = 1024;
v4 = g_lintyp;
*(_DWORD *)(g_ivar1 + 8LL) = 33;
*(_DWORD *)(v0 + 12) = 1;
gp_work();
v5 = curpat;
v6 = 2LL * curpat;
v7 = *(float *)&apats[3 * curpat];
gpa_pass(COERCE_FLOAT(LODWORD(v7) ^ LC3));
gpa_draw(dword_728[v5 + v6], v7);
v8 = curpat;
v9 = *(float *)&apats[3 * curpat];
v10 = *(float *)&dword_724[3 * curpat];
if ( v9 != v10 )
{
gpa_pass(v9);
gpa_pass(COERCE_FLOAT(LODWORD(v10) ^ LC3));
gpa_draw(dword_728[3 * v8], v10);
}
v11 = g_ivar1;
*(_DWORD *)(g_ivar1 + 8LL) = 33;
*(_DWORD *)(v11 + 12) = v4;
result = gp_work();
aloc = 0;
}
else
{
aloc = 0;
}
}
}
return result;
}

canonical_decompiled_code:
int func5()
{
__int64 v0; // rdx
int result; // eax
__int64 v2; // rcx
__int64 v3; // rdx
int v4; // ebp
__int64 v5; // r12
__int64 v6; // rbx
float v7; // er13
int v8; // er12
float v9; // xmm0_4
float v10; // ebx
__int64 v11; // rax

v0 = g_ivar1;
result = *(_DWORD *)(g_ivar1 + 12LL);
if ( result == 1 )
{
result = aloc;
if ( aloc <= 1023 )
{
LABEL_4:
v2 = g_fvar1;
v3 = result;
alist[2 * result++] = *g_fvar1;
aloc = result;
dword_8E4[2 * v3] = *(float *)(v2 + 4);
return result;
}
++aloc;
if ( result == 1024 )
{
fprintf(stdout, "** Error ** (%s) ", "gp_area");
fprintf(stdout, "too many points in polygon (max %d)", 1024LL);
result = fputc(10, stdout);
}
}
else
{
if ( result <= 1 )
{
if ( result )
return result;
goto LABEL_4;
}
result -= 2;
if ( (unsigned int)result <= 1 )
{
result = aloc;
if ( aloc > 2 )
{
if ( aloc > 1024 )
aloc = 1024;
v4 = g_lintyp;
*(_DWORD *)(g_ivar1 + 8LL) = 33;
*(_DWORD *)(v0 + 12) = 1;
gp_work();
v5 = curpat;
v6 = 2LL * curpat;
v7 = *(float *)&apats[3 * curpat];
func3(COERCE_FLOAT(LODWORD(v7) ^ LC3));
func4(dword_728[v5 + v6], v7);
v8 = curpat;
v9 = *(float *)&apats[3 * curpat];
v10 = *(float *)&dword_724[3 * curpat];
if ( v9 != v10 )
{
func3(v9);
func3(COERCE_FLOAT(LODWORD(v10) ^ LC3));
func4(dword_728[3 * v8], v10);
}
v11 = g_ivar1;
*(_DWORD *)(g_ivar1 + 8LL) = 33;
*(_DWORD *)(v11 + 12) = v4;
result = gp_work();
aloc = 0;
}
else
{
aloc = 0;
}
}
}
return result;
}

original_code:
void gp_area()
 {
 int lin_sav ;
 char *rotnam = "gp_area" ;
 switch (g_ivar1[( 3 << 0)]) {
 case 0:
  aloc = 0 ;
 case 1:
  if (aloc >= 1024) {
   if (aloc++ == 1024)
    fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "too many points in polygon (max %d)", 1024 ), fprintf(stdout, "\n") ;
   break ;
   }
  alist[aloc ].x = g_fvar1[( 0 << 0)] ;
  alist[aloc++].y = g_fvar1[( 1 << 0)] ;
  break ;
 case 3:
 case 2:
  if (aloc < 3) { aloc = 0 ; break ; }
  if (aloc > 1024) aloc = 1024 ;
  lin_sav = g_lintyp ;
  g_ivar1[( 2 << 0)] = 33 ;
  g_ivar1[( 3 << 0)] = 1 ;
  gp_work() ;
  gpa_pass(-apats[curpat].ar_rot1) ;
  gpa_draw( apats[curpat].ar_spc, apats[curpat].ar_rot1 ) ;
  if (apats[curpat].ar_rot1 != apats[curpat].ar_rot2) {
      gpa_pass( apats[curpat].ar_rot1) ;
      gpa_pass(-apats[curpat].ar_rot2) ;
      gpa_draw( apats[curpat].ar_spc, apats[curpat].ar_rot2 ) ;
      }
  g_ivar1[( 2 << 0)] = 33 ;
  g_ivar1[( 3 << 0)] = lin_sav ;
  gp_work() ;
  aloc = 0 ;
  break ;
  }
 }

canonical_original_code:
void gp_area()
 {
 int lin_sav;
 char *rotnam = "gp_area";
 switch (g_ivar1[( 3 << 0)]) {
 case 0:
  aloc = 0 ;
 case 1:
  if (aloc >= 1024) {
   if (aloc++ == 1024)
    fprintf(stdout,"** Error ** (%s) ", rotnam), fprintf(stdout, "too many points in polygon (max %d)", 1024 ), fprintf(stdout, "\n") ;
   break ;
   }
  alist[aloc ].x = g_fvar1[( 0 << 0)] ;
  alist[aloc++].y = g_fvar1[( 1 << 0)] ;
  break ;
 case 3:
 case 2:
  if (aloc < 3) { aloc = 0 ; break ; }
  if (aloc > 1024) aloc = 1024 ;
  lin_sav = g_lintyp ;
  g_ivar1[( 2 << 0)] = 33 ;
  g_ivar1[( 3 << 0)] = 1 ;
  gp_work() ;
  gpa_pass(-apats[curpat].ar_rot1) ;
  gpa_draw( apats[curpat].ar_spc, apats[curpat].ar_rot1 ) ;
  if (apats[curpat].ar_rot1 != apats[curpat].ar_rot2) {
      gpa_pass( apats[curpat].ar_rot1) ;
      gpa_pass(-apats[curpat].ar_rot2) ;
      gpa_draw( apats[curpat].ar_spc, apats[curpat].ar_rot2 ) ;
      }
  g_ivar1[( 2 << 0)] = 33 ;
  g_ivar1[( 3 << 0)] = lin_sav ;
  gp_work() ;
  aloc = 0 ;
  break ;
  }
 }


nwstrc

decompiled_code:
char *__fastcall nwstrc(char *src, __int64 a2)
{
char *v2; // rbp
int v3; // esi
char *v4; // rax

v2 = (char *)malloc(a2 + 1);
strncpy(v2, src, (int)a2);
v3 = a2 - 1;
if ( v3 >= 0 )
{
v4 = &v2[v3];
do
{
if ( *v4 != 32 )
break;
--v4;
--v3;
}
while ( v3 >= 0 );
}
v2[v3 + 1] = 0;
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(char *src, __int64 a2)
{
char *v2; // rbp
int v3; // esi
char *v4; // rax

v2 = (char *)malloc(a2 + 1);
strncpy(v2, src, (int)a2);
v3 = a2 - 1;
if ( v3 >= 0 )
{
v4 = &v2[v3];
do
{
if ( *v4 != 32 )
break;
--v4;
--v3;
}
while ( v3 >= 0 );
}
v2[v3 + 1] = 0;
return v2;
}

original_code:
static char *
nwstrc(char *fstr, long fsiz)
 {
 char *bp ;
 int l ;
 bp = malloc(fsiz + 1) ;
 strncpy(bp, fstr, (int)fsiz) ;
 for (l = fsiz -1; l >= 0; l--)
  if (bp[l] != ' ') break ;
 bp[l+1] = '\0' ;
 return bp ;
 }

canonical_original_code:
static char *nwstrc(char *fstr, long fsiz)
 {
 char *bp;
 int l;
 bp = malloc(fsiz + 1) ;
 strncpy(bp, fstr, (int)fsiz) ;
 for (l = fsiz -1; l >= 0; l--)
  if (bp[l] != ' ') break ;
 bp[l+1] = '\0' ;
 return bp ;
 }

variable_types:
fstr
char *

variable_types: fsiz long

variable_types:
bp
char *

variable_types: l int


iceil

decompiled_code:
__int64 __fastcall iceil(double a1)
{
if ( a1 >= 0.0 )
a1 = a1 + 0.999999999999;
return (unsigned int)(int)a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(double a1)
{
if ( a1 >= 0.0 )
a1 = a1 + 0.999999999999;
return (unsigned int)(int)a1;
}

canonical_original_code:
static int iceil(float x)
{
    return( (x > 0)? 1 + (int) x : (int) x );
}

variable_types: x float


vfunc

decompiled_code:
const char *__fastcall vfunc(__int64 a1, int a2, int *a3)
{
const char *result; // rax
float *v4; // rax
double v5; // xmm1_8
int v6; // er15
void **v7; // r14
__int64 v8; // r13
__int64 v9; // rax
double *v10; // rdx
__int64 v11; // rax
float v12; // xmm0_4
__int64 v13; // rbx
double v14; // xmm2_8
double v15; // xmm2_8
__int64 v16; // rax
float v17; // xmm0_4
char v18[24000]; // [rsp+0h] [rbp-61B8h] BYREF
void *v19[30]; // [rsp+5DC0h] [rbp-3F8h] BYREF
void *v20[30]; // [rsp+5EB0h] [rbp-308h] BYREF
void *v21[30]; // [rsp+5FA0h] [rbp-218h] BYREF
void *ptr[37]; // [rsp+6090h] [rbp-128h] BYREF

if ( a2 != 2 )
{
if ( a2 > 2 )
{
if ( (unsigned int)(a2 - 3) <= 1 )
{
RoughGrad(a2, a1);
return 0LL;
}
}
else if ( a2 == 1 )
{
result = "Active can only be taken of an impurity value";
if ( a3[2] == 256 )
{
if ( last_temp == 0.0 )
{
result = "The value is not available unless a temperature has been given\n";
}
else
{
v6 = *((_DWORD *)&imptosol + *a3);
init_pseudo((unsigned int)a2, last_temp);
comp_mat(last_temp);
if ( n_imp > 0 )
{
v7 = ptr;
v8 = 0LL;
do
{
*v7 = malloc(8LL * (nn + 1));
v21[v8] = malloc(8LL * (nn + 1));
v19[v8] = malloc(8LL * (nn + 1));
v20[v8] = malloc(8LL * (nn + 1));
if ( nn > 0 )
{
v9 = 0LL;
do
{
*((_QWORD *)*v7 + v9) = *(_QWORD *)(*((_QWORD *)&nd + v9) + 8LL * (int)v8);
++v9;
}
while ( nn > (int)v9 );
}
++v8;
++v7;
}
while ( n_imp > (int)v8 );
}
get_active(1LL, ptr, v18, v19, v21, v20, last_temp, v19);
if ( nn > 0 )
{
v10 = (double *)v21[v6];
v11 = 0LL;
do
{
v12 = v10[v11];
*(float *)(a1 + 4 * v11++) = v12;
}
while ( nn > (int)v11 );
}
if ( n_imp <= 0 )
{
result = 0LL;
}
else
{
v13 = 0LL;
do
{
free(ptr[v13]);
free(v21[v13]);
free(v19[v13]);
free(v20[v13++]);
}
while ( n_imp > (int)v13 );
result = 0LL;
}
}
}
return result;
}
fprintf(stderr, "Internal error: unknown vector function %d\n", (unsigned int)a2);
return 0LL;
}
result = 0LL;
if ( nn > 0 )
{
v4 = (float *)a1;
v5 = 0.0;
while ( 1 )
{
v15 = *v4;
if ( *v4 < 0.0 )
*(_QWORD *)&v15 ^= LC43;
v14 = fmax(v15, v5);
v5 = v14;
if ( v4 == (float *)(a1 + 4LL * (unsigned int)(nn - 1)) )
break;
++v4;
}
if ( v14 == 0.0 )
{
result = 0LL;
}
else
{
v16 = 0LL;
do
{
v17 = *(float *)(a1 + 4 * v16) / v14;
*(float *)(a1 + 4 * v16++) = v17;
}
while ( nn > (int)v16 );
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func4(__int64 a1, int a2, int *a3)
{
const char *result; // rax
float *v4; // rax
double v5; // xmm1_8
int v6; // er15
void **v7; // r14
__int64 v8; // r13
__int64 v9; // rax
double *v10; // rdx
__int64 v11; // rax
float v12; // xmm0_4
__int64 v13; // rbx
double v14; // xmm2_8
double v15; // xmm2_8
__int64 v16; // rax
float v17; // xmm0_4
char v18[24000]; // [rsp+0h] [rbp-61B8h] BYREF
void *v19[30]; // [rsp+5DC0h] [rbp-3F8h] BYREF
void *v20[30]; // [rsp+5EB0h] [rbp-308h] BYREF
void *v21[30]; // [rsp+5FA0h] [rbp-218h] BYREF
void *ptr[37]; // [rsp+6090h] [rbp-128h] BYREF

if ( a2 != 2 )
{
if ( a2 > 2 )
{
if ( (unsigned int)(a2 - 3) <= 1 )
{
func3(a2, a1);
return 0LL;
}
}
else if ( a2 == 1 )
{
result = "Active can only be taken of an impurity value";
if ( a3[2] == 256 )
{
if ( last_temp == 0.0 )
{
result = "The value is not available unless a temperature has been given\n";
}
else
{
v6 = *((_DWORD *)&imptosol + *a3);
init_pseudo((unsigned int)a2, last_temp);
comp_mat(last_temp);
if ( n_imp > 0 )
{
v7 = ptr;
v8 = 0LL;
do
{
*v7 = malloc(8LL * (nn + 1));
v21[v8] = malloc(8LL * (nn + 1));
v19[v8] = malloc(8LL * (nn + 1));
v20[v8] = malloc(8LL * (nn + 1));
if ( nn > 0 )
{
v9 = 0LL;
do
{
*((_QWORD *)*v7 + v9) = *(_QWORD *)(*((_QWORD *)&nd + v9) + 8LL * (int)v8);
++v9;
}
while ( nn > (int)v9 );
}
++v8;
++v7;
}
while ( n_imp > (int)v8 );
}
get_active(1LL, ptr, v18, v19, v21, v20, last_temp, v19);
if ( nn > 0 )
{
v10 = (double *)v21[v6];
v11 = 0LL;
do
{
v12 = v10[v11];
*(float *)(a1 + 4 * v11++) = v12;
}
while ( nn > (int)v11 );
}
if ( n_imp <= 0 )
{
result = 0LL;
}
else
{
v13 = 0LL;
do
{
free(ptr[v13]);
free(v21[v13]);
free(v19[v13]);
free(v20[v13++]);
}
while ( n_imp > (int)v13 );
result = 0LL;
}
}
}
return result;
}
fprintf(stderr, "Internal error: unknown vector function %d\n", (unsigned int)a2);
return 0LL;
}
result = 0LL;
if ( nn > 0 )
{
v4 = (float *)a1;
v5 = 0.0;
while ( 1 )
{
v15 = *v4;
if ( *v4 < 0.0 )
*(_QWORD *)&v15 ^= LC43;
v14 = fmax(v15, v5);
v5 = v14;
if ( v4 == (float *)(a1 + 4LL * (unsigned int)(nn - 1)) )
break;
++v4;
}
if ( v14 == 0.0 )
{
result = 0LL;
}
else
{
v16 = 0LL;
do
{
v17 = *(float *)(a1 + 4 * v16) / v14;
*(float *)(a1 + 4 * v16++) = v17;
}
while ( nn > (int)v16 );
result = 0LL;
}
}
return result;
}


repo: deyimsf/journal

decompiled_code:
void *List_create()
{
return calloc(1uLL, 0x18uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(1uLL, 0x18uLL);
}

original_code:
List *
List_create()
{
 return calloc(1, sizeof(List));
}

canonical_original_code:
struct List *List_create()
{
 return calloc(1, sizeof(List));
}

return_type: struct List { int count; struct ListNode { struct ListNode *next; struct ListNode *prev; void *value; } *first; struct ListNode *last; } *

user_defined_types: struct List { int count; struct ListNode *first; struct ListNode *last; }


decompiled_code:
void __fastcall List_destroy(void *ptr)
{
_QWORD *i; // rbx
void *v3; // rdi
void *v4; // rdi

for ( i = (_QWORD *)*((_QWORD *)ptr + 1); i; i = (_QWORD *)*i )
{
v4 = (void *)i[1];
if ( v4 )
{
free(v4);
i[1] = 0LL;
}
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
free(v3);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
_QWORD *i; // rbx
void *v3; // rdi
void *v4; // rdi

for ( i = (_QWORD *)*((_QWORD *)ptr + 1); i; i = (_QWORD *)*i )
{
v4 = (void *)i[1];
if ( v4 )
{
free(v4);
i[1] = 0LL;
}
}
v3 = (void *)*((_QWORD *)ptr + 2);
if ( v3 )
free(v3);
free(ptr);
}

original_code:
void
List_destroy(List *list)
{
 ListNode *_node = ((void *)0); ListNode *cur = ((void *)0); for(cur = _node = list->first; _node != ((void *)0); cur = _node = _node->next){
  if(cur->prev) {
   free(cur->prev);
   cur->prev=((void *)0);
  }
 }
 if(list->last){
  free(list->last);
  list->last = ((void *)0);
 }
 free(list);
}

canonical_original_code:
void List_destroy(struct List *list)
{
 struct ListNode *_node = ((void *)0); struct ListNode *cur = ((void *)0); for(cur = _node = list->first; _node != ((void *)0); cur = _node = _node->next){
  if(cur->prev) {
   free(cur->prev);
   cur->prev=((void *)0);
  }
 }
 if(list->last){
  free(list->last);
  list->last = ((void *)0);
 }
 free(list);
}

variable_types: struct List { int count; struct ListNode { struct ListNode *next; struct ListNode *prev; void *value; } *first; struct ListNode *last; } *


decompiled_code:
void __fastcall List_clear_destroy(void *ptr)
{
List_clear((__int64)ptr);
List_destroy(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
func2((__int64)ptr);
func1(ptr);
}

original_code:
void
List_clear_destroy(List *list)
{
 List_clear(list);
 List_destroy(list);
}

canonical_original_code:
void List_clear_destroy(struct List *list)
{
 List_clear(list);
 List_destroy(list);
}

user_defined_types: struct ListNode { struct ListNode *next; struct ListNode *prev; void *value; }


original_code:
void *
List_remove(List *list, ListNode *node)
{
 void *result = ((void *)0);
 if(node == list->first && node == list->last) {
  list->first = ((void *)0);
  list->last = ((void *)0);
 } else if(node == list->first) {
  list->first = node->next;
  node->next->prev = ((void *)0);
 } else if(node == list->last) {
  list->last = node->prev;
  node->prev->next = ((void *)0);
 } else {
  ListNode *before = node->prev;
  ListNode *after = node->next;
  before->next = after;
  after->prev = before;
 }
 list->count--;
 result = node->value;
 free(node);
 node = ((void *)0);
 return result;
}

canonical_original_code:
void *List_remove(struct List *list, struct ListNode *node)
{
 void *result = ((void *)0);
 if(node == list->first && node == list->last) {
  list->first = ((void *)0);
  list->last = ((void *)0);
 } else if(node == list->first) {
  list->first = node->next;
  node->next->prev = ((void *)0);
 } else if(node == list->last) {
  list->last = node->prev;
  node->prev->next = ((void *)0);
 } else {
  struct ListNode *before = node->prev;
  struct ListNode *after = node->next;
  before->next = after;
  after->prev = before;
 }
 list->count--;
 result = node->value;
 free(node);
 node = ((void *)0);
 return result;
}

variable_types:
node
struct ListNode *

variable_types:
result
void *

variable_types: struct ListNode { struct ListNode *next; struct ListNode *prev; void *value; } *

return_type: void *


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

result = *(_QWORD *)(a1 + 16);
if ( result )
result = List_remove(a1, *(__int64 **)(a1 + 16));
return result;
}

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

result = *(_QWORD *)(a1 + 16);
if ( result )
result = func4(a1, *(__int64 **)(a1 + 16));
return result;
}

original_code:
void *
List_pop(List *list)
{
 ListNode *node = list->last;
 if(node == ((void *)0)){
  return ((void *)0);
 }
 return List_remove(list, node);
}

canonical_original_code:
void *List_pop(struct List *list)
{
 struct ListNode *node = list->last;
 if(node == ((void *)0)){
  return ((void *)0);
 }
 return List_remove(list, node);
}


fail

decompiled_code:
void __noreturn fail(char *format, ...)
{
int *v1; // rbx
int v2; // er13
char *v3; // rax
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

va_start(arg, format);
v1 = _errno_location();
v2 = *v1;
fprintf(stderr, "%s: ", program);
vfprintf(stderr, format, arg);
if ( v2 )
{
v3 = strerror(*v1);
fprintf(stderr, ": %s", v3);
}
putc(10, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func2(char *format, ...)
{
int *v1; // rbx
int v2; // er13
char *v3; // rax
gcc_va_list arg; // [rsp+8h] [rbp-F0h] BYREF

va_start(arg, format);
v1 = _errno_location();
v2 = *v1;
fprintf(stderr, "%s: ", program);
vfprintf(stderr, format, arg);
if ( v2 )
{
v3 = strerror(*v1);
fprintf(stderr, ": %s", v3);
}
putc(10, stderr);
exit(1);
}

original_code:
void
fail(char *format, ...)
{
    int error;
    va_list ap;
    error = (*__errno_location ());
    fprintf(stderr, "%s: ", program);
    __builtin_va_start(ap,format);
    vfprintf(stderr, format, ap);
    __builtin_va_end(ap);
    if (error)
 fprintf(stderr, ": %s", strerror((*__errno_location ())));
    putc('\n', stderr);
    exit(1);
}

canonical_original_code:
void fail(char *format, ...)
{
    int error;
    __builtin_va_list ap;
    error = (*__errno_location ());
    fprintf(stderr, "%s: ", program);
    __builtin_va_start(ap,format);
    vfprintf(stderr, format, ap);
    __builtin_va_end(ap);
    if (error)
 fprintf(stderr, ": %s", strerror((*__errno_location ())));
    putc('\n', stderr);
    exit(1);
}

variable_types:
format
char *

variable_types: error int


touid

decompiled_code:
__int64 __fastcall touid(const char *a1)
{
struct passwd *v1; // rax
unsigned int v2; // ebp
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v1 = getpwnam(a1);
if ( v1 )
return v1->pw_uid;
v2 = strtol(a1, &endptr, 0);
if ( !v2 && endptr == a1 )
fail("cannot find uid for %s", a1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
struct passwd *v1; // rax
unsigned int v2; // ebp
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v1 = getpwnam(a1);
if ( v1 )
return v1->pw_uid;
v2 = strtol(a1, &endptr, 0);
if ( !v2 && endptr == a1 )
func2("cannot find uid for %s", a1);
return v2;
}

original_code:
static uid_t
touid(char *owner)
{
    struct passwd *pw;
    uid_t uid;
    char *cp;
    pw = getpwnam(owner);
    if (pw)
 return pw->pw_uid;
    uid = strtol(owner, &cp, 0);
    if (uid == 0 && cp == owner)
 fail("cannot find uid for %s", owner);
    return uid;
}

canonical_original_code:
static unsigned int touid(char *owner)
{
    struct passwd *pw;
    unsigned int uid;
    char *cp;
    pw = getpwnam(owner);
    if (pw)
 return pw->pw_uid;
    uid = strtol(owner, &cp, 0);
    if (uid == 0 && cp == owner)
 fail("cannot find uid for %s", owner);
    return uid;
}

variable_types:
owner
char *

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

variable_types:
uid
unsigned int

variable_types:
cp
char *

return_type: unsigned int


togid

decompiled_code:
__int64 __fastcall togid(const char *a1)
{
struct group *v1; // rax
unsigned int v2; // ebp
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v1 = getgrnam(a1);
if ( v1 )
return v1->gr_gid;
v2 = strtol(a1, &endptr, 0);
if ( !v2 && endptr == a1 )
fail("cannot find gid for %s", a1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
struct group *v1; // rax
unsigned int v2; // ebp
char *endptr; // [rsp+8h] [rbp-20h] BYREF

v1 = getgrnam(a1);
if ( v1 )
return v1->gr_gid;
v2 = strtol(a1, &endptr, 0);
if ( !v2 && endptr == a1 )
func2("cannot find gid for %s", a1);
return v2;
}

original_code:
static gid_t
togid(char *group)
{
    struct group *gr;
    gid_t gid;
    char *cp;
    gr = getgrnam(group);
    if (gr)
 return gr->gr_gid;
    gid = strtol(group, &cp, 0);
    if (gid == 0 && cp == group)
 fail("cannot find gid for %s", group);
    return gid;
}

canonical_original_code:
static unsigned int togid(char *group)
{
    struct group *gr;
    unsigned int gid;
    char *cp;
    gr = getgrnam(group);
    if (gr)
 return gr->gr_gid;
    gid = strtol(group, &cp, 0);
    if (gid == 0 && cp == group)
 fail("cannot find gid for %s", group);
    return gid;
}

variable_types:
group
char *

variable_types: struct group { char *gr_name; char *gr_passwd; unsigned int gr_gid; char **gr_mem; } *

variable_types:
gid
unsigned int


xmalloc

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

result = malloc(a1);
if ( !result )
fail("cannot allocate %u bytes", a1);
return result;
}

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

result = malloc(a1);
if ( !result )
func2("cannot allocate %u bytes", a1);
return result;
}

original_code:
void *
xmalloc(size_t size)
{
    void *p = malloc(size);
    if (!p)
 fail("cannot allocate %u bytes", size);
    return p;
}

canonical_original_code:
void *xmalloc(unsigned long size)
{
    void *p = malloc(size);
    if (!p)
 fail("cannot allocate %u bytes", size);
    return p;
}

variable_types:
size
unsigned long

variable_types:
p
void *


xstrdup

decompiled_code:
char *__fastcall xstrdup(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)xmalloc(v1 + 1);
return strcpy(v2, src);
}

canonical_decompiled_code:
char *__fastcall func6(char *src)
{
size_t v1; // rax
char *v2; // rax

v1 = strlen(src);
v2 = (char *)func5(v1 + 1);
return strcpy(v2, src);
}

original_code:
char *
xstrdup(char *s)
{
    return strcpy((char*)xmalloc(strlen(s) + 1), s);
}

canonical_original_code:
char *xstrdup(char *s)
{
    return strcpy((char *)xmalloc(strlen(s) + 1), s);
}

variable_types:
s
char *


reversepath

decompiled_code:
char *__fastcall reversepath(_BYTE *a1, const char *a2, int a3, char *a4)
{
char *v5; // r13
char *v6; // r12
char *src; // [rsp+8h] [rbp-1E0h]
struct stat v10; // [rsp+20h] [rbp-1C8h] BYREF
char v11[312]; // [rsp+B0h] [rbp-138h] BYREF

v5 = strcpy(&a4[-a3 + 4095], a2);
while ( 1 )
{
a1 = getcomponent(a1, v11);
if ( !a1 )
break;
if ( strcmp(v11, ".") )
{
if ( !strcmp(v11, "..") )
{
if ( stat(".", &v10) < 0 )
fail("cannot stat current directory");
src = ino2name(v10.st_ino);
v6 = &v5[~(__int64)(int)strlen(src)];
strcpy(v6, src);
*(v5 - 1) = 47;
free(src);
xchdir("..");
v5 = v6;
}
else
{
v5 -= 3;
*(_WORD *)v5 = 11822;
v5[2] = 47;
xchdir(v11);
}
}
}
return strcpy(a4, v5);
}

canonical_decompiled_code:
char *__fastcall func11(_BYTE *a1, const char *a2, int a3, char *a4)
{
char *v5; // r13
char *v6; // r12
char *src; // [rsp+8h] [rbp-1E0h]
struct stat v10; // [rsp+20h] [rbp-1C8h] BYREF
char v11[312]; // [rsp+B0h] [rbp-138h] BYREF

v5 = strcpy(&a4[-a3 + 4095], a2);
while ( 1 )
{
a1 = getcomponent(a1, v11);
if ( !a1 )
break;
if ( strcmp(v11, ".") )
{
if ( !strcmp(v11, "..") )
{
if ( stat(".", &v10) < 0 )
func2("cannot stat current directory");
src = func7(v10.st_ino);
v6 = &v5[~(__int64)(int)strlen(src)];
strcpy(v6, src);
*(v5 - 1) = 47;
free(src);
func9("..");
v5 = v6;
}
else
{
v5 -= 3;
*(_WORD *)v5 = 11822;
v5[2] = 47;
func9(v11);
}
}
}
return strcpy(a4, v5);
}

original_code:
void
reversepath(char *inpath, char *name, int len, char *outpath)
{
    char *cp, *cp2;
    char buf[256];
    struct stat sb;
    cp = strcpy(outpath + 4096 - (len + 1), name);
    cp2 = inpath;
    while ((cp2 = getcomponent(cp2, buf)) != 0) {
 if (strcmp(buf, ".") == 0)
     continue;
 if (strcmp(buf, "..") == 0) {
     if (stat(".", &sb) < 0)
  fail("cannot stat current directory");
     name = ino2name(sb.st_ino, "..");
     len = strlen(name);
     cp -= len + 1;
     strcpy(cp, name);
     cp[len] = '/';
     free(name);
     xchdir("..");
 } else {
     cp -= 3;
     strncpy(cp, "../", 3);
     xchdir(buf);
 }
    }
    strcpy(outpath, cp);
}

canonical_original_code:
void reversepath(char *inpath, char *name, int len, char *outpath)
{
    char *cp; char *cp2;
    char buf[256];
    struct stat sb;
    cp = strcpy(outpath + 4096 - (len + 1), name);
    cp2 = inpath;
    while ((cp2 = getcomponent(cp2, buf)) != 0) {
 if (strcmp(buf, ".") == 0)
     continue;
 if (strcmp(buf, "..") == 0) {
     if (stat(".", &sb) < 0)
  fail("cannot stat current directory");
     name = ino2name(sb.st_ino, "..");
     len = strlen(name);
     cp -= len + 1;
     strcpy(cp, name);
     cp[len] = '/';
     free(name);
     xchdir("..");
 } else {
     cp -= 3;
     strncpy(cp, "../", 3);
     xchdir(buf);
 }
    }
    strcpy(outpath, cp);
}

variable_types:
inpath
char *

variable_types:
name
char *

variable_types: len int

variable_types:
outpath
char *

variable_types:
buf
char [256]

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }