CountDevices

decompiled_code:
__int64 CountDevices()
{
int v0; // er12
int v1; // eax
int v2; // eax
int v3; // eax
bool v4; // zf

if ( (parms & 1) != 0 )
fwrite("Counting devices\n", 1uLL, 0x11uLL, stderr);
syncJTAGs();
SelectShiftIR();
x = 0;
do
{
send_cmd(1, 0);
++x;
}
while ( x <= 198 );
i = 0;
v0 = 0;
do
{
send_cmd(0, 0);
x = v1;
if ( !v1 )
break;
++v0;
++i;
}
while ( i <= 198 );
if ( IRTotalRegSize != v0 )
fwrite("\nERROR IR SIZE FROM BSDL MISMATCH FROM JTAG\n", 1uLL, 0x2CuLL, stderr);
x = 0;
do
{
send_cmd(1, 0);
++x;
}
while ( x <= 198 );
ExitShift();
SelectShiftDR();
x = 0;
do
{
send_cmd(0, 0);
++x;
}
while ( x <= 198 );
if ( (parms & 1) != 0 )
fwrite("FLUSH DR\n", 1uLL, 9uLL, stderr);
x = 0;
if ( !v0 )
goto LABEL_23;
do
{
send_cmd(1, 0);
v4 = v3 == 0;
i = v3;
v2 = x;
if ( !v4 )
break;
v2 = x + 1;
x = v2;
}
while ( v2 < v0 );
if ( v2 == v0 )
{
LABEL_23:
x = 0;
if ( (parms & 1) == 0 )
goto LABEL_22;
LABEL_24:
fprintf(stderr, "(IR REG SIZE:(0's) %d vs (1's) %d)\n", (unsigned int)i, (unsigned int)v0);
goto LABEL_22;
}
if ( (parms & 1) != 0 )
goto LABEL_24;
LABEL_22:
fprintf(stderr, "Devices found: %d\n", (unsigned int)x);
ExitShift();
return (unsigned int)x;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // er12
int v1; // eax
int v2; // eax
int v3; // eax
bool v4; // zf

if ( (parms & 1) != 0 )
fwrite("Counting devices\n", 1uLL, 0x11uLL, stderr);
syncJTAGs();
SelectShiftIR();
x = 0;
do
{
func2(1, 0);
++x;
}
while ( x <= 198 );
i = 0;
v0 = 0;
do
{
func2(0, 0);
x = v1;
if ( !v1 )
break;
++v0;
++i;
}
while ( i <= 198 );
if ( IRTotalRegSize != v0 )
fwrite("\nERROR IR SIZE FROM BSDL MISMATCH FROM JTAG\n", 1uLL, 0x2CuLL, stderr);
x = 0;
do
{
func2(1, 0);
++x;
}
while ( x <= 198 );
ExitShift();
SelectShiftDR();
x = 0;
do
{
func2(0, 0);
++x;
}
while ( x <= 198 );
if ( (parms & 1) != 0 )
fwrite("FLUSH DR\n", 1uLL, 9uLL, stderr);
x = 0;
if ( !v0 )
goto LABEL_23;
do
{
func2(1, 0);
v4 = v3 == 0;
i = v3;
v2 = x;
if ( !v4 )
break;
v2 = x + 1;
x = v2;
}
while ( v2 < v0 );
if ( v2 == v0 )
{
LABEL_23:
x = 0;
if ( (parms & 1) == 0 )
goto LABEL_22;
LABEL_24:
fprintf(stderr, "(IR REG SIZE:(0's) %d vs (1's) %d)\n", (unsigned int)i, (unsigned int)v0);
goto LABEL_22;
}
if ( (parms & 1) != 0 )
goto LABEL_24;
LABEL_22:
fprintf(stderr, "Devices found: %d\n", (unsigned int)x);
ExitShift();
return (unsigned int)x;
}

original_code:
int CountDevices()
{
 if((parms & 0x01) == 0x01)
  fprintf(stderr,"Counting devices\n");
 int tIRLen = 0;
 syncJTAGs();
 SelectShiftIR();
 for(x=0;x<199;x++) send_cmd(1,0);
 for(i=0;i<199;i++)
  {
  x = send_cmd(0,0);
  if(!x) break;
  tIRLen++;
 }
 if(tIRLen != IRTotalRegSize)
  fprintf(stderr,"\nERROR IR SIZE FROM BSDL MISMATCH FROM JTAG\n");
 for(x=0;x<199;x++) send_cmd(1,0);
 ExitShift();
 SelectShiftDR();
 for(x=0;x<199;x++) send_cmd(0,0);
 if((parms & 0x01) == 0x01)
  fprintf(stderr,"FLUSH DR\n");
 for(x=0;x<tIRLen;x++)
 {
  i = send_cmd(1,0);
  if(i) break;
 }
 if(x==tIRLen) x = 0;
 if((parms & 0x01) == 0x01)
  fprintf(stderr,"(IR REG SIZE:(0's) %d vs (1's) %d)\n",i,tIRLen);
 fprintf(stderr,"Devices found: %d\n",x);
 ExitShift();
 return x;
}

variable_types: tIRLen int


help

repo: XenoKrelian/RpiJtag

decompiled_code:
size_t help()
{
return fwrite(
"Usage: rpjtag [options]\n"
" -h Print help\n"
"\t-D\t Debug info\n"
"\t-b\t\tuse BDSL file(s) use , as between multiple files\n"
"\t\t\tonly needed if program doesn't know IDCODE->BDSL file\n"
"\n",
1uLL,
0xB1uLL,
stderr);
}

canonical_decompiled_code:
size_t func9()
{
return fwrite(
"Usage: rpjtag [options]\n"
" -h Print help\n"
"\t-D\t Debug info\n"
"\t-b\t\tuse BDSL file(s) use , as between multiple files\n"
"\t\t\tonly needed if program doesn't know IDCODE->BDSL file\n"
"\n",
1uLL,
0xB1uLL,
stderr);
}

original_code:
void help()
{
 fprintf(stderr,
 "Usage: rpjtag [options]\n"
 "   -h      Print help\n"
 "	-D	    Debug info\n"
 "	-b		use BDSL file(s) use , as between multiple files\n"
 "			only needed if program doesn't know IDCODE->BDSL file\n"
 "\n");
}

return_type: void


decompiled_code:
void setup_io()
{
int v0; // eax
_DWORD *v1; // rax
int v2; // edx
int *v3; // rax
int v4; // edx

v0 = open("/dev/mem", 1052674);
mem_fd = v0;
if ( v0 < 0 )
{
puts("can't open /dev/mem ");
exit(-1);
}
gpio_map = mmap(0LL, 0x1000uLL, 3, 1, v0, 538968064LL);
close(mem_fd);
v1 = gpio_map;
if ( gpio_map == (void *)-1LL )
{
printf(aMmapError, 0xFFFFFFFFLL);
exit(-1);
}
v2 = *(_DWORD *)gpio_map;
gpio = (__int64)gpio_map;
BYTE1(v2) &= 0x8Fu;
*(_DWORD *)gpio_map = v2;
*v1 &= 0xC7FFFFFF;
*v1 &= 0xFF1FFFFF;
*v1 &= 0xF8FFFFFF;
nop_sleep(125LL);
if ( (parms & 1) != 0 )
fprintf(
stderr,
"INITIAL PORT STATUS TMS %d, TCK %d, TDI %d, TDO %d\n",
(*(_DWORD *)(gpio + 52) >> 9) & 1,
(*(_DWORD *)(gpio + 52) >> 4) & 1,
(*(_DWORD *)(gpio + 52) >> 7) & 1,
(*(_DWORD *)(gpio + 52) >> 8) & 1);
v3 = (int *)gpio;
*(_DWORD *)gpio |= 0x200000u;
*v3 |= 0x8000000u;
v4 = *v3;
BYTE1(v4) = BYTE1(*v3) | 0x10;
*v3 = v4;
if ( (parms & 1) != 0 )
fprintf(
stderr,
"READY PORT STATUS TMS %d, TCK %d, TDI %d, TDO %d\n",
((unsigned int)v3[13] >> 9) & 1,
((unsigned int)v3[13] >> 4) & 1,
((unsigned int)v3[13] >> 7) & 1,
((unsigned int)v3[13] >> 8) & 1);
nop_sleep(125LL);
}

canonical_decompiled_code:
void func10()
{
int v0; // eax
_DWORD *v1; // rax
int v2; // edx
int *v3; // rax
int v4; // edx

v0 = open("/dev/mem", 1052674);
mem_fd = v0;
if ( v0 < 0 )
{
puts("can't open /dev/mem ");
exit(-1);
}
gpio_map = mmap(0LL, 0x1000uLL, 3, 1, v0, 538968064LL);
close(mem_fd);
v1 = gpio_map;
if ( gpio_map == (void *)-1LL )
{
printf(aMmapError, 0xFFFFFFFFLL);
exit(-1);
}
v2 = *(_DWORD *)gpio_map;
gpio = (__int64)gpio_map;
BYTE1(v2) &= 0x8Fu;
*(_DWORD *)gpio_map = v2;
*v1 &= 0xC7FFFFFF;
*v1 &= 0xFF1FFFFF;
*v1 &= 0xF8FFFFFF;
func1(125LL);
if ( (parms & 1) != 0 )
fprintf(
stderr,
"INITIAL PORT STATUS TMS %d, TCK %d, TDI %d, TDO %d\n",
(*(_DWORD *)(gpio + 52) >> 9) & 1,
(*(_DWORD *)(gpio + 52) >> 4) & 1,
(*(_DWORD *)(gpio + 52) >> 7) & 1,
(*(_DWORD *)(gpio + 52) >> 8) & 1);
v3 = (int *)gpio;
*(_DWORD *)gpio |= 0x200000u;
*v3 |= 0x8000000u;
v4 = *v3;
BYTE1(v4) = BYTE1(*v3) | 0x10;
*v3 = v4;
if ( (parms & 1) != 0 )
fprintf(
stderr,
"READY PORT STATUS TMS %d, TCK %d, TDI %d, TDO %d\n",
((unsigned int)v3[13] >> 9) & 1,
((unsigned int)v3[13] >> 4) & 1,
((unsigned int)v3[13] >> 7) & 1,
((unsigned int)v3[13] >> 8) & 1);
func1(125LL);
}


decompiled_code:
void __fastcall load_bdsl_files(const char *a1)
{
int v2; // eax
int v3; // ebp
__int64 v4; // r12
char *v5; // r14
int i; // eax
int v7; // er15
char *v8; // rax
char v9; // r13
char *v10; // rdi

v2 = strlen(a1);
x = 0;
if ( v2 <= 0 )
{
v5 = 0LL;
}
else
{
v3 = v2;
v4 = 0LL;
v5 = 0LL;
for ( i = 0; i < v3; x = i )
{
v9 = a1[i];
if ( v9 == 44 )
{
v10 = v5;
v4 = 0LL;
v5 = 0LL;
read_bdsl_file(v10, fileCounter);
++fileCounter;
}
else
{
v7 = v4 + 1;
v8 = (char *)realloc(v5, (int)v4 + 1);
if ( v8 )
{
v8[v4] = v9;
v5 = v8;
v4 = v7;
}
else
{
v4 = v7;
free(v5);
fwrite("Error (re)allocating memory", 1uLL, 0x1BuLL, stderr);
}
}
i = x + 1;
}
}
read_bdsl_file(v5, fileCounter);
free(v5);
x = 0;
::i = 0;
n = 0;
}

canonical_decompiled_code:
void __fastcall func1(const char *a1)
{
int v2; // eax
int v3; // ebp
__int64 v4; // r12
char *v5; // r14
int i; // eax
int v7; // er15
char *v8; // rax
char v9; // r13
char *v10; // rdi

v2 = strlen(a1);
x = 0;
if ( v2 <= 0 )
{
v5 = 0LL;
}
else
{
v3 = v2;
v4 = 0LL;
v5 = 0LL;
for ( i = 0; i < v3; x = i )
{
v9 = a1[i];
if ( v9 == 44 )
{
v10 = v5;
v4 = 0LL;
v5 = 0LL;
func0(v10, fileCounter);
++fileCounter;
}
else
{
v7 = v4 + 1;
v8 = (char *)realloc(v5, (int)v4 + 1);
if ( v8 )
{
v8[v4] = v9;
v5 = v8;
v4 = v7;
}
else
{
v4 = v7;
free(v5);
fwrite("Error (re)allocating memory", 1uLL, 0x1BuLL, stderr);
}
}
i = x + 1;
}
}
func0(v5, fileCounter);
free(v5);
x = 0;
::i = 0;
n = 0;
}

original_code:
void load_bdsl_files(char *bdslfiles)
{
 int strlength = strlen(bdslfiles);
 char *temp = ((void *)0);
 char *temp2 = ((void *)0);
 int wordCounter = 0;
    for(x=0;x<strlength;x++)
 {
  if(bdslfiles[x] == ',' || x==strlength)
  {
   read_bdsl_file(temp,fileCounter);
   fileCounter++;
   wordCounter = 0;
   temp=((void *)0);
  }else{
   temp2 = (char*)realloc(temp,(wordCounter+1)*sizeof(char));
   if(temp2!=((void *)0))
   {
    temp=temp2;
    temp[wordCounter] = bdslfiles[x];
   }else{
    free(temp);
    fprintf(stderr,"Error (re)allocating memory");
   }
   wordCounter++;
  }
 }
 read_bdsl_file(temp,fileCounter);
 free(temp);
 x=0;
 i=0;
 n=0;
}

canonical_original_code:
void load_bdsl_files(char *bdslfiles)
{
 int strlength = strlen(bdslfiles);
 char *temp = ((void *)0);
 char *temp2 = ((void *)0);
 int wordCounter = 0;
    for(x=0;x<strlength;x++)
 {
  if(bdslfiles[x] == ',' || x==strlength)
  {
   read_bdsl_file(temp,fileCounter);
   fileCounter++;
   wordCounter = 0;
   temp=((void *)0);
  }else{
   temp2 = (char *)realloc(temp,(wordCounter+1)*sizeof(char));
   if(temp2!=((void *)0))
   {
    temp=temp2;
    temp[wordCounter] = bdslfiles[x];
   }else{
    free(temp);
    fprintf(stderr,"Error (re)allocating memory");
   }
   wordCounter++;
  }
 }
 read_bdsl_file(temp,fileCounter);
 free(temp);
 x=0;
 i=0;
 n=0;
}

variable_types:
bdslfiles
char *

variable_types: strlength int

variable_types:
temp
char *

variable_types: wordCounter int


checkStatusReg

decompiled_code:
__int64 checkStatusReg()
{
unsigned int v0; // eax

syncJTAGs();
SelectShiftIR();
send_cmdWord_msb_last(16325LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
n = 0;
do
{
send_cmd(0LL, 0LL);
++n;
}
while ( n <= 30 );
send_cmdWord_msb_first(0xFFFFFFFFLL, 0LL, 32LL);
send_cmdWord_msb_first(2862175590LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 0LL, 32LL);
send_cmdWord_msb_first(671145986LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 1LL, 32LL);
n = 0;
do
{
send_cmd(0LL, 1LL);
++n;
}
while ( n <= 2 );
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
send_cmdWord_msb_last(16324LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
fwrite("\nSTAT: ", 1uLL, 7uLL, stderr);
n = 0;
do
{
v0 = send_cmd(0LL, 0LL);
fprintf(stderr, "%d", v0);
++n;
}
while ( n <= 31 );
fputc(10, stderr);
return UpdateState(1LL, 0LL);
}

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

syncJTAGs();
SelectShiftIR();
send_cmdWord_msb_last(16325LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
n = 0;
do
{
send_cmd(0LL, 0LL);
++n;
}
while ( n <= 30 );
send_cmdWord_msb_first(0xFFFFFFFFLL, 0LL, 32LL);
send_cmdWord_msb_first(2862175590LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 0LL, 32LL);
send_cmdWord_msb_first(671145986LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 0LL, 32LL);
send_cmdWord_msb_first(0x20000000LL, 1LL, 32LL);
n = 0;
do
{
send_cmd(0LL, 1LL);
++n;
}
while ( n <= 2 );
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
send_cmdWord_msb_last(16324LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
fwrite("\nSTAT: ", 1uLL, 7uLL, stderr);
n = 0;
do
{
v0 = send_cmd(0LL, 0LL);
fprintf(stderr, "%d", v0);
++n;
}
while ( n <= 31 );
fputc(10, stderr);
return UpdateState(1LL, 0LL);
}

original_code:
void checkStatusReg()
{
 unsigned int DYMMYWORD = 0xFFFFFFFF;
 unsigned int NOOP = 0x20000000;
 unsigned int SYNCWORD = 0xAA995566;
 unsigned int STATUS_REG = 0x2800E002;
 syncJTAGs();
 SelectShiftIR();
 send_cmdWord_msb_last(0x3FC5,1,14);
 send_cmd(0,1);
 send_cmd(0,1);
 send_cmd(0,0);
 send_cmd(0,0);
 for(n=0;n<31;n++) send_cmd(0,0);
 send_cmdWord_msb_first(DYMMYWORD,0,32);
 send_cmdWord_msb_first(SYNCWORD,0,32);
 send_cmdWord_msb_first(NOOP,0,32);
 send_cmdWord_msb_first(STATUS_REG,0,32);
 send_cmdWord_msb_first(NOOP,0,32);
 send_cmdWord_msb_first(NOOP,1,32);
 for(n=0;n<3;n++) send_cmd(0,1);
 send_cmd(0,0);
 send_cmd(0,0);
 send_cmdWord_msb_last(0x3FC4,1,14);
 send_cmd(0,1);
 send_cmd(0,1);
 send_cmd(0,0);
 send_cmd(0,0);
 fprintf(stderr,"\nSTAT: ");
 for(n=0;n<32;n++)
 {
   fprintf(stderr,"%d",send_cmd(0,0));
 }
 fprintf(stderr,"\n");
 UpdateState(0x001,0);
}

variable_types:
DYMMYWORD
unsigned int

variable_types:
NOOP
unsigned int

variable_types:
SYNCWORD
unsigned int


checkUserId

decompiled_code:
__int64 __fastcall checkUserId(int a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

syncJTAGs();
SelectShiftIR();
send_cmdWord_msb_last(16328LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
jtag_read_data(v2, 32LL);
if ( a1 )
fprintf(stderr, "\nUserID After programming: %08X", v2[0]);
else
fprintf(stderr, "\nUserID Before programming: %08X", v2[0]);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
return send_cmd(0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
unsigned int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

syncJTAGs();
SelectShiftIR();
send_cmdWord_msb_last(16328LL, 1LL, 14LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
send_cmd(0LL, 0LL);
jtag_read_data(v2, 32LL);
if ( a1 )
fprintf(stderr, "\nUserID After programming: %08X", v2[0]);
else
fprintf(stderr, "\nUserID Before programming: %08X", v2[0]);
send_cmd(0LL, 1LL);
send_cmd(0LL, 0LL);
return send_cmd(0LL, 0LL);
}

original_code:
void checkUserId(int x)
{
 syncJTAGs();
 SelectShiftIR();
 send_cmdWord_msb_last(0x3FC8,1,14);
 send_cmd(0,1);
 send_cmd(0,1);
 send_cmd(0,0);
 send_cmd(0,0);
 int data;
 jtag_read_data((char *)&data,32);
 if(!x)
  fprintf(stderr,"\nUserID Before programming: %08X",data);
 else
  fprintf(stderr,"\nUserID After programming: %08X",data);
 send_cmd(0,1);
 send_cmd(0,0);
 send_cmd(0,0);
}

variable_types: x int

variable_types: data int


repo: Xfennec/progress

decompiled_code:
__int64 __fastcall set_hlist_size(double a1)
{
double v1; // xmm0_8
__m128d v2; // xmm3
__m128d v3; // xmm1
__int64 result; // rax

v1 = 10.0 / a1;
if ( COERCE_DOUBLE(*(_QWORD *)&v1 & LC2) < 4.503599627370496e15 )
{
v2.m128d_f64[0] = v1;
v3.m128d_f64[0] = (double)(int)v1;
*(_QWORD *)&v1 = COERCE_UNSIGNED_INT64(v3.m128d_f64[0] + COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v2, v3) & LC3)) | ~LC2 & *(_QWORD *)&v1;
}
result = (unsigned int)(int)v1;
if ( (int)result < 2 )
result = (unsigned int)max_hlist_size;
max_hlist_size = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1)
{
double v1; // xmm0_8
__m128d v2; // xmm3
__m128d v3; // xmm1
__int64 result; // rax

v1 = 10.0 / a1;
if ( COERCE_DOUBLE(*(_QWORD *)&v1 & LC2) < 4.503599627370496e15 )
{
v2.m128d_f64[0] = v1;
v3.m128d_f64[0] = (double)(int)v1;
*(_QWORD *)&v1 = COERCE_UNSIGNED_INT64(v3.m128d_f64[0] + COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v2, v3) & LC3)) | ~LC2 & *(_QWORD *)&v1;
}
result = (unsigned int)(int)v1;
if ( (int)result < 2 )
result = (unsigned int)max_hlist_size;
max_hlist_size = result;
return result;
}

original_code:
void set_hlist_size(double throughput_wait_secs) {
   int new_size;
   new_size = ceil(10.0 / throughput_wait_secs);
   max_hlist_size = (new_size > 1) ? new_size : max_hlist_size;
}


decompiled_code:
__int64 __fastcall add_to_hlist(__int64 a1, _QWORD **a2, int a3, int a4)
{
_QWORD *v5; // r12
_QWORD *v6; // rax
__int64 result; // rax
_QWORD *v8; // rax
_QWORD *v9; // rax

v5 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
if ( max_hlist_size == a3 )
{
v6 = (_QWORD *)**a2;
v6[1] = 0LL;
(*a2)[1] = *(_QWORD *)a1;
**a2 = 0LL;
*(_QWORD *)a1 = *a2;
*a2 = v6;
**(_QWORD **)(*(_QWORD *)a1 + 8LL) = *(_QWORD *)a1;
result = 0LL;
LABEL_4:
*(_DWORD *)(*(_QWORD *)a1 + 16LL) = a4;
return result;
}
v8 = malloc(0x18uLL);
if ( v8 )
{
v8[1] = v5;
*v8 = 0LL;
*(_QWORD *)a1 = v8;
*v5 = v8;
result = 1LL;
goto LABEL_4;
}
}
else
{
v9 = malloc(0x18uLL);
*(_QWORD *)a1 = v9;
if ( v9 )
{
*a2 = v9;
v9[1] = 0LL;
*v9 = 0LL;
result = 1LL;
goto LABEL_4;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD **a2, int a3, int a4)
{
_QWORD *v5; // r12
_QWORD *v6; // rax
__int64 result; // rax
_QWORD *v8; // rax
_QWORD *v9; // rax

v5 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
if ( max_hlist_size == a3 )
{
v6 = (_QWORD *)**a2;
v6[1] = 0LL;
(*a2)[1] = *(_QWORD *)a1;
**a2 = 0LL;
*(_QWORD *)a1 = *a2;
*a2 = v6;
**(_QWORD **)(*(_QWORD *)a1 + 8LL) = *(_QWORD *)a1;
result = 0LL;
LABEL_4:
*(_DWORD *)(*(_QWORD *)a1 + 16LL) = a4;
return result;
}
v8 = malloc(0x18uLL);
if ( v8 )
{
v8[1] = v5;
*v8 = 0LL;
*(_QWORD *)a1 = v8;
*v5 = v8;
result = 1LL;
goto LABEL_4;
}
}
else
{
v9 = malloc(0x18uLL);
*(_QWORD *)a1 = v9;
if ( v9 )
{
*a2 = v9;
v9[1] = 0LL;
*v9 = 0LL;
result = 1LL;
goto LABEL_4;
}
}
return 0LL;
}

original_code:
int add_to_hlist(hlist **begin, hlist **end, int size, int value) {
   int ret;
   if (*begin == ((void *)0)) {
       if ((*begin = malloc(sizeof(hlist))) == ((void *)0))
           return 0;
       *end = *begin;
       (*begin)->next = ((void *)0);
       (*begin)->prev = ((void *)0);
       ret = 1;
   }
   else if (size == max_hlist_size) {
       hlist *tmp = (*end)->prev;
       tmp->next = ((void *)0);
       (*end)->next = *begin;
       (*end)->prev = ((void *)0);
       *begin = *end;
       *end = tmp;
       (*begin)->next->prev = *begin;
       ret = 0;
   }
   else {
       hlist *new = malloc(sizeof(hlist));
       if (!new)
           return 0;
       new->next = *begin;
       new->prev = ((void *)0);
       *begin = new;
       (*begin)->next->prev = *begin;
       ret = 1;
   }
   (*begin)->value = value;
   return ret;
}

canonical_original_code:
int add_to_hlist(struct hlist **begin, struct hlist **end, int size, int value) {
   int ret;
   if (*begin == ((void *)0)) {
       if ((*begin = malloc(sizeof(hlist))) == ((void *)0))
           return 0;
       *end = *begin;
       (*begin)->next = ((void *)0);
       (*begin)->prev = ((void *)0);
       ret = 1;
   }
   else if (size == max_hlist_size) {
       struct hlist *tmp = (*end)->prev;
       tmp->next = ((void *)0);
       (*end)->next = *begin;
       (*end)->prev = ((void *)0);
       *begin = *end;
       *end = tmp;
       (*begin)->next->prev = *begin;
       ret = 0;
   }
   else {
       struct hlist *new = malloc(sizeof(hlist));
       if (!new)
           return 0;
       new->next = *begin;
       new->prev = ((void *)0);
       *begin = new;
       (*begin)->next->prev = *begin;
       ret = 1;
   }
   (*begin)->value = value;
   return ret;
}

variable_types: struct hlist { struct hlist *prev; struct hlist *next; int value; } **

variable_types:
end
struct hlist **

variable_types: size int

variable_types: value int

variable_types: ret int

return_type: int


decompiled_code:
unsigned __int64 __fastcall get_hlist_average(__int64 a1, int a2)
{
unsigned __int64 v2; // rax
__int64 v3; // rdx

if ( !a1 )
return 0LL;
v2 = 0LL;
do
{
v3 = *(int *)(a1 + 16);
a1 = *(_QWORD *)(a1 + 8);
v2 += v3;
}
while ( a1 );
return v2 / a2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(__int64 a1, int a2)
{
unsigned __int64 v2; // rax
__int64 v3; // rdx

if ( !a1 )
return 0LL;
v2 = 0LL;
do
{
v3 = *(int *)(a1 + 16);
a1 = *(_QWORD *)(a1 + 8);
v2 += v3;
}
while ( a1 );
return v2 / a2;
}

original_code:
int get_hlist_average(hlist *begin, int size) {
   unsigned long long avg = 0;
   while (begin) {
      avg += begin->value;
      begin = begin->next;
   }
   return avg / size;
}

canonical_original_code:
int get_hlist_average(struct hlist *begin, int size) {
   unsigned long long avg = 0;
   while (begin) {
      avg += begin->value;
      begin = begin->next;
   }
   return avg / size;
}

variable_types: struct hlist { struct hlist *prev; struct hlist *next; int value; } *

variable_types:
avg
unsigned long long


decompiled_code:
int __fastcall format_size(unsigned __int64 a1, char *a2)
{
const char *v2; // r9
unsigned __int64 v3; // rcx
float v4; // xmm0_4
int result; // eax
int i; // eax

v2 = (const char *)&unk_D8;
v3 = 0x1000000000000000LL;
if ( a1 <= 0xFFFFFFFFFFFFFFFLL )
{
v3 = 0x4000000000000LL;
for ( i = 1; i != 7; ++i )
{
if ( a1 >= v3 )
{
v2 = (const char *)*(&sizes + i);
goto LABEL_2;
}
v3 >>= 10;
}
result = 48;
*(_WORD *)a2 = 48;
}
else
{
LABEL_2:
if ( a1 % v3 )
{
if ( (a1 & 0x8000000000000000LL) != 0LL )
v4 = (float)(int)(a1 & 1 | (a1 >> 1)) + (float)(int)(a1 & 1 | (a1 >> 1));
else
v4 = (float)(int)a1;
result = sprintf(a2, "%.1f %s", (float)(v4 / (float)(int)v3), v2);
}
else
{
result = sprintf(a2, "%lu %s", a1 / v3, v2);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned __int64 a1, char *a2)
{
const char *v2; // r9
unsigned __int64 v3; // rcx
float v4; // xmm0_4
int result; // eax
int i; // eax

v2 = (const char *)&unk_D8;
v3 = 0x1000000000000000LL;
if ( a1 <= 0xFFFFFFFFFFFFFFFLL )
{
v3 = 0x4000000000000LL;
for ( i = 1; i != 7; ++i )
{
if ( a1 >= v3 )
{
v2 = (const char *)*(&sizes + i);
goto LABEL_2;
}
v3 >>= 10;
}
result = 48;
*(_WORD *)a2 = 48;
}
else
{
LABEL_2:
if ( a1 % v3 )
{
if ( (a1 & 0x8000000000000000LL) != 0LL )
v4 = (float)(int)(a1 & 1 | (a1 >> 1)) + (float)(int)(a1 & 1 | (a1 >> 1));
else
v4 = (float)(int)a1;
result = sprintf(a2, "%.1f %s", (float)(v4 / (float)(int)v3), v2);
}
else
{
result = sprintf(a2, "%lu %s", a1 / v3, v2);
}
}
return result;
}

original_code:
void format_size(uint64_t size, char *result)
{
uint64_t multiplier;
int i;
multiplier = exbibytes;
for (i = 0 ; i < (sizeof(sizes)/sizeof(*(sizes))) ; i++, multiplier /= 1024) {
    if (size < multiplier)
        continue;
    if (size % multiplier == 0)
        sprintf(result, "%" "l" "u" " %s", size / multiplier, sizes[i]);
    else
        sprintf(result, "%.1f %s", (float) size / multiplier, sizes[i]);
    return;
}
strcpy(result, "0");
return;
}

canonical_original_code:
void format_size(unsigned long size, char *result)
{
unsigned long multiplier;
int i;
multiplier = exbibytes;
for (i = 0 ; i < (sizeof(sizes)/sizeof(*(sizes))) ; i++, multiplier /= 1024) {
    if (size < multiplier)
        continue;
    if (size % multiplier == 0)
        sprintf(result, "%" "l" "u" " %s", size / multiplier, sizes[i]);
    else
        sprintf(result, "%.1f %s", (float) size / multiplier, sizes[i]);
    return;
}
strcpy(result, "0");
return;
}

variable_types:
size
unsigned long

variable_types:
result
char *

variable_types:
multiplier
unsigned long

variable_types: i int


statsdSend

repo: Xiol/Ifrit

decompiled_code:
void __fastcall statsdSend(__int64 a1, const void *a2, int a3)
{
if ( sendto(*(_DWORD *)a1, a2, a3, 0, (const struct sockaddr *)(a1 + 4), 0x10u) == -1 )
perror("sendto failed.");
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, const void *a2, int a3)
{
if ( sendto(*(_DWORD *)a1, a2, a3, 0, (const struct sockaddr *)(a1 + 4), 0x10u) == -1 )
perror("sendto failed.");
}

original_code:
void statsdSend(statsdConnection *c, const char *buf, int buflen) {
    if (sendto(c->socket, buf, buflen, 0, (const struct sockaddr *)&c->si_dest, sizeof(c->si_dest)) == -1) {
        perror("sendto failed.");
    }
}

canonical_original_code:
void statsdSend(struct statsdConnection *c, char *buf, int buflen) {
    if (sendto(c->socket, buf, buflen, 0, (struct sockaddr *)&c->si_dest, sizeof(c->si_dest)) == -1) {
        perror("sendto failed.");
    }
}

variable_types: struct statsdConnection { int socket; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } si_dest; } *

variable_types:
buf
char *

variable_types: buflen int

user_defined_types: struct statsdConnection { int socket; struct sockaddr_in si_dest; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }


statsdClose

decompiled_code:
void __fastcall statsdClose(void *ptr)
{
int v2; // edi

v2 = *(_DWORD *)ptr;
if ( v2 != -1 )
close(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
int v2; // edi

v2 = *(_DWORD *)ptr;
if ( v2 != -1 )
close(v2);
free(ptr);
}

original_code:
void statsdClose(statsdConnection *c) {
    if (c->socket != -1) {
        close(c->socket);
    }
    free(c);
}

canonical_original_code:
void statsdClose(struct statsdConnection *c) {
    if (c->socket != -1) {
        close(c->socket);
    }
    free(c);
}


printUsage

repo: Xonar/LGBinExtractor

decompiled_code:
int printUsage()
{
return printf(
"BinExtractor - A tool for extracting LG Bin Firmware files\n"
"\n"
"Usage :\n"
"\t%-20s%s\n"
"\t%-20s%s\n"
"\t%-20s%s\n"
"\t%-20s%s\n",
"-daph file",
"Display Header Information",
"-dgpt file",
"Display GPT Header Information",
"-extract file",
"Split Bin into Partitions",
"-ebh file",
"Extract Bin Header from file");
}

canonical_decompiled_code:
int func5()
{
return printf(
"BinExtractor - A tool for extracting LG Bin Firmware files\n"
"\n"
"Usage :\n"
"\t%-20s%s\n"
"\t%-20s%s\n"
"\t%-20s%s\n"
"\t%-20s%s\n",
"-daph file",
"Display Header Information",
"-dgpt file",
"Display GPT Header Information",
"-extract file",
"Split Bin into Partitions",
"-ebh file",
"Extract Bin Header from file");
}

original_code:
void printUsage()
{
  printf(
      "BinExtractor - A tool for extracting LG Bin Firmware files\n\nUsage :\n\t%-20s%s\n\t%-20s%s\n\t%-20s%s\n\t%-20s%s\n",
      "-daph file", "Display Header Information", "-dgpt file",
      "Display GPT Header Information", "-extract file", "Split Bin into Partitions",
      "-ebh file", "Extract Bin Header from file");
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp
int v5; // er12

if ( argc <= 0 )
goto LABEL_11;
v3 = argv;
if ( **argv != 45 )
{
--argc;
v3 = argv + 1;
}
if ( argc != 2 )
goto LABEL_11;
v4 = *v3;
v5 = strcmp("-ebh", *v3);
if ( !v5 )
{
if ( (unsigned __int8)canOpenFile(v3[1]) )
{
extractBinHeaderFile((char *)v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-daph", v4);
if ( !v5 )
{
if ( (unsigned __int8)canOpenFile(v3[1]) )
{
displayAP(v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-dgpt", v4);
if ( !v5 )
{
if ( (unsigned __int8)canOpenFile(v3[1]) )
{
displayGPT(v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-extract", v4);
if ( v5 )
{
LABEL_11:
v5 = 0;
printUsage();
return v5;
}
if ( (unsigned __int8)canOpenFile(v3[1]) )
{
splitBinFile(v3[1]);
return v5;
}
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
const char *v4; // rbp
int v5; // er12

if ( argc <= 0 )
goto LABEL_11;
v3 = argv;
if ( **argv != 45 )
{
--argc;
v3 = argv + 1;
}
if ( argc != 2 )
goto LABEL_11;
v4 = *v3;
v5 = strcmp("-ebh", *v3);
if ( !v5 )
{
if ( (unsigned __int8)func6(v3[1]) )
{
func4((char *)v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-daph", v4);
if ( !v5 )
{
if ( (unsigned __int8)func6(v3[1]) )
{
func2(v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-dgpt", v4);
if ( !v5 )
{
if ( (unsigned __int8)func6(v3[1]) )
{
func1(v3[1]);
return v5;
}
return 1;
}
v5 = strcmp("-extract", v4);
if ( v5 )
{
LABEL_11:
v5 = 0;
func5();
return v5;
}
if ( (unsigned __int8)func6(v3[1]) )
{
func3(v3[1]);
return v5;
}
return 1;
}

original_code:
int main(int argc, char* args[])
{
  if(argc > 0 && **args != '-')
  {
    argc--;
    args++;
  }
  if(argc == 2)
  {
    if(strcmp("-ebh", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        extractBinHeaderFile(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-daph", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        displayAP(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-dgpt", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        displayGPT(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-extract", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        splitBinFile(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else printUsage();
  }
  else printUsage();
  return 0;
}

canonical_original_code:
int main(int argc, char *args[])
{
  if(argc > 0 && **args != '-')
  {
    argc--;
    args++;
  }
  if(argc == 2)
  {
    if(strcmp("-ebh", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        extractBinHeaderFile(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-daph", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        displayAP(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-dgpt", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        displayGPT(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else if(strcmp("-extract", args[0]) == 0)
    {
      if(canOpenFile(args[1]))
      {
        splitBinFile(args[1]);
      }
      else
      {
        return 1;
      }
    }
    else printUsage();
  }
  else printUsage();
  return 0;
}

variable_types: argc int

variable_types:
args
char *[]


repo: Xsoda/struct

decompiled_code:
__int64 __fastcall my_isprint(unsigned int a1)
{
unsigned int v1; // er12

v1 = 46;
if ( (unsigned __int8)(a1 - 1) <= 0x7Du && ((*_ctype_b_loc())[(char)a1] & 0x4000) != 0 )
v1 = a1;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned int v1; // er12

v1 = 46;
if ( (unsigned __int8)(a1 - 1) <= 0x7Du && ((*_ctype_b_loc())[(char)a1] & 0x4000) != 0 )
v1 = a1;
return v1;
}

original_code:
char my_isprint(char c)
{
    if (c < 127 && c > 0 && ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISprint))
        return c;
    else
        return '.';
}

canonical_original_code:
char my_isprint(char c)
{
    if (c < 127 && c > 0 && ((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISprint))
        return c;
    else
        return '.';
}

variable_types: c char

return_type: char


original_code:
void print_hex(unsigned char *blob, int len)
{
    int i, j;
    len = len > 0 ? len : 0;
    if (len)
    {
        printf("OFFSET  HEX BYTES    ASCII\n");
        printf("------  -----------  -----\n");
        for (j = 0; j < len; j += 4)
        {
            printf(" %.04d   ", j / 4 * 4);
            for (i = j; i < j + 4 && i < len; i++)
                printf("%02x ", blob[i]);
            for (; i < j + 4; i++)
                printf("   ");
            printf(" ");
            for (i = j; i < j + 4 && i < len; i++)
                printf("%c", my_isprint(blob[i]));
            printf("\n");
        }
    }
}

canonical_original_code:
void print_hex(unsigned char *blob, int len)
{
    int i; int j;
    len = len > 0 ? len : 0;
    if (len)
    {
        printf("OFFSET  HEX BYTES    ASCII\n");
        printf("------  -----------  -----\n");
        for (j = 0; j < len; j += 4)
        {
            printf(" %.04d   ", j / 4 * 4);
            for (i = j; i < j + 4 && i < len; i++)
                printf("%02x ", blob[i]);
            for (; i < j + 4; i++)
                printf("   ");
            printf(" ");
            for (i = j; i < j + 4 && i < len; i++)
                printf("%c", my_isprint(blob[i]));
            printf("\n");
        }
    }
}

variable_types:
blob
unsigned char *

variable_types: len int

variable_types: j int


original_code:
int main()
{
    int len;
    char blob_pack[35];
    uint64_t magic;
    unsigned char buf[200] = {0};
    char *str1 = ((void *)0), *str2 = ((void *)0), *blob = ((void *)0);
 for (len = 0; len < sizeof(blob_pack); len++)
  blob_pack[len] = 0xCD;
    strcpy(&blob_pack[8], "Xsoda");
    len = struct_pack(buf, "!Q2so", 0x58736F6461000000LL,"Xsodaaaa", "Hello, World!", blob_pack, 20);
    printf("pack success, length: %d\n", len);
    print_hex(buf, len);
    struct_unpack(buf, "!Q2so", &magic, &str1, &str2, &blob, &len);
    printf("-------------------------------------------\n");
    printf("unpack 1: %s\n", str1);
    printf("unpack 2: %s\n", str2);
    printf("-------------------------------------------\n");
    print_hex((unsigned char *)blob, len);
    free(str1);
    free(str2);
    free(blob);
    system("pause");
    return 1;
}

canonical_original_code:
int main()
{
    int len;
    char blob_pack[35];
    unsigned long magic;
    unsigned char buf[200] = {0};
    char *str1 = ((void *)0); char *str2 = ((void *)0); char *blob = ((void *)0);
 for (len = 0; len < sizeof(blob_pack); len++)
  blob_pack[len] = 0xCD;
    strcpy(&blob_pack[8], "Xsoda");
    len = struct_pack(buf, "!Q2so", 0x58736F6461000000LL,"Xsodaaaa", "Hello, World!", blob_pack, 20);
    printf("pack success, length: %d\n", len);
    print_hex(buf, len);
    struct_unpack(buf, "!Q2so", &magic, &str1, &str2, &blob, &len);
    printf("-------------------------------------------\n");
    printf("unpack 1: %s\n", str1);
    printf("unpack 2: %s\n", str2);
    printf("-------------------------------------------\n");
    print_hex((unsigned char *)blob, len);
    free(str1);
    free(str2);
    free(blob);
    system("pause");
    return 1;
}

variable_types:
magic
unsigned long

variable_types:
buf
unsigned char [200]

variable_types:
blob
char *


repo: Yahia-Mohammad/s-can

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
while ( byte_4040B0 )
;
while ( 1 )
{
currentStateFunction(argc, argv, envp);
while ( byte_4040B0 )
;
}
}

original_code:
int main(int argc, char** argv) {
    while(1) {
        switch(globalController.controllerMode) {
            case 0:
                (*currentStateFunction)();
                break;
            case 1:
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
        }
    }
    return (0);
}

canonical_original_code:
int main(int argc, char **argv) {
    while(1) {
        switch(globalController.controllerMode) {
            case 0:
                (*currentStateFunction)();
                break;
            case 1:
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
        }
    }
    return (0);
}

variable_types:
argv
char **


stateArbitrationControl

decompiled_code:
char stateArbitrationControl()
{
char v0; // dl
__int16 v1; // cx
char v2; // r9
char v3; // di
char result; // al
char v5; // al
char v6; // cl
char v7; // cl

byte_4040C0 = 1;
if ( byte_4040AB )
{
result = byte_4040BD;
extended_9 = 2;
identifierCounter_7 = 0;
identifier_6 = 0;
endSection_5 = 0;
byte_4040AB = 0;
word_4040BE = 256;
bitCounter_8 = 1;
if ( !byte_4040BD )
{
v6 = 2;
v3 = 1;
localCRC = 0;
v0 = 0;
goto LABEL_25;
}
v3 = 1;
v0 = 0;
localCRC = 17817;
}
else
{
v0 = bitCounter_8;
v1 = 2 * localCRC;
v2 = byte_4040BD;
v3 = ++bitCounter_8;
if ( (unsigned __int8)byte_4040BD << 14 != (localCRC & 0x4000) )
v1 = (2 * localCRC) ^ 0x4599;
localCRC = v1;
if ( identifierCounter_7 )
{
--identifierCounter_7;
identifier_6 = (unsigned __int8)byte_4040BD + 2 * identifier_6;
}
if ( v3 == 12 )
{
result = extended_9;
byte_4040A9 = byte_4040BD;
if ( extended_9 != 1 )
{
LABEL_8:
if ( result )
goto LABEL_12;
v5 = globalController;
if ( (unsigned __int8)(v0 - 14) < 4u )
v5 = 2 * globalController;
result = (v2 == 0) + v5;
globalController = result;
if ( v3 != 18 )
{
LABEL_12:
if ( !endSection_5 )
return result;
LABEL_19:
if ( byte_4040A9 == 1 )
{
globalController = 0;
if ( nodeFilters != identifier_6 )
{
LABEL_33:
result = (char)off_404078[0];
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404078[0];
return result;
}
}
else if ( nodeFilters != identifier_6 )
{
goto LABEL_22;
}
byte_4040AA = 0;
LABEL_22:
if ( !byte_4040A9 )
{
result = (char)off_404070[0];
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404070[0];
return result;
}
goto LABEL_33;
}
LABEL_31:
endSection_5 = 1;
goto LABEL_19;
}
v7 = globalController;
result = byte_4040BD;
if ( (unsigned __int8)(v0 - 44) > 3u )
{
globalController += byte_4040BD == 0;
goto LABEL_12;
}
goto LABEL_29;
}
result = byte_4040BD;
if ( v3 == 13 )
{
extended_9 = byte_4040BD;
if ( byte_4040BD != 1 )
goto LABEL_8;
identifierCounter_7 = 18;
v7 = globalController;
if ( (unsigned __int8)(v0 - 44) > 3u )
goto LABEL_12;
goto LABEL_29;
}
}
v6 = extended_9;
if ( extended_9 != 1 )
{
LABEL_25:
v2 = result;
result = v6;
goto LABEL_8;
}
v7 = globalController;
if ( v3 != 42 )
{
if ( (unsigned __int8)(v0 - 44) > 3u )
{
LABEL_30:
globalController = (result == 0) + v7;
if ( v3 != 48 )
goto LABEL_12;
goto LABEL_31;
}
LABEL_29:
v7 *= 2;
goto LABEL_30;
}
byte_4040A9 = result;
globalController += result == 0;
if ( endSection_5 )
goto LABEL_19;
return result;
}

canonical_decompiled_code:
char func6()
{
char v0; // dl
__int16 v1; // cx
char v2; // r9
char v3; // di
char result; // al
char v5; // al
char v6; // cl
char v7; // cl

byte_4040C0 = 1;
if ( byte_4040AB )
{
result = byte_4040BD;
extended_9 = 2;
identifierCounter_7 = 0;
identifier_6 = 0;
endSection_5 = 0;
byte_4040AB = 0;
word_4040BE = 256;
bitCounter_8 = 1;
if ( !byte_4040BD )
{
v6 = 2;
v3 = 1;
localCRC = 0;
v0 = 0;
goto LABEL_25;
}
v3 = 1;
v0 = 0;
localCRC = 17817;
}
else
{
v0 = bitCounter_8;
v1 = 2 * localCRC;
v2 = byte_4040BD;
v3 = ++bitCounter_8;
if ( (unsigned __int8)byte_4040BD << 14 != (localCRC & 0x4000) )
v1 = (2 * localCRC) ^ 0x4599;
localCRC = v1;
if ( identifierCounter_7 )
{
--identifierCounter_7;
identifier_6 = (unsigned __int8)byte_4040BD + 2 * identifier_6;
}
if ( v3 == 12 )
{
result = extended_9;
byte_4040A9 = byte_4040BD;
if ( extended_9 != 1 )
{
LABEL_8:
if ( result )
goto LABEL_12;
v5 = globalController;
if ( (unsigned __int8)(v0 - 14) < 4u )
v5 = 2 * globalController;
result = (v2 == 0) + v5;
globalController = result;
if ( v3 != 18 )
{
LABEL_12:
if ( !endSection_5 )
return result;
LABEL_19:
if ( byte_4040A9 == 1 )
{
globalController = 0;
if ( nodeFilters != identifier_6 )
{
LABEL_33:
result = (char)off_404078[0];
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404078[0];
return result;
}
}
else if ( nodeFilters != identifier_6 )
{
goto LABEL_22;
}
byte_4040AA = 0;
LABEL_22:
if ( !byte_4040A9 )
{
result = (char)off_404070[0];
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404070[0];
return result;
}
goto LABEL_33;
}
LABEL_31:
endSection_5 = 1;
goto LABEL_19;
}
v7 = globalController;
result = byte_4040BD;
if ( (unsigned __int8)(v0 - 44) > 3u )
{
globalController += byte_4040BD == 0;
goto LABEL_12;
}
goto LABEL_29;
}
result = byte_4040BD;
if ( v3 == 13 )
{
extended_9 = byte_4040BD;
if ( byte_4040BD != 1 )
goto LABEL_8;
identifierCounter_7 = 18;
v7 = globalController;
if ( (unsigned __int8)(v0 - 44) > 3u )
goto LABEL_12;
goto LABEL_29;
}
}
v6 = extended_9;
if ( extended_9 != 1 )
{
LABEL_25:
v2 = result;
result = v6;
goto LABEL_8;
}
v7 = globalController;
if ( v3 != 42 )
{
if ( (unsigned __int8)(v0 - 44) > 3u )
{
LABEL_30:
globalController = (result == 0) + v7;
if ( v3 != 48 )
goto LABEL_12;
goto LABEL_31;
}
LABEL_29:
v7 *= 2;
goto LABEL_30;
}
byte_4040A9 = result;
globalController += result == 0;
if ( endSection_5 )
goto LABEL_19;
return result;
}

original_code:
void stateArbitrationControl() {
    static uint8_t extended = 0;
    static uint8_t bitCounter = 0;
    static uint8_t identifierCounter = 11;
    static uint32_t identifier = 0;
    static uint8_t endSection = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        extended = 2;
        bitCounter = 0;
        identifierCounter = 0;
        identifier = 0;
        endSection = 0;
        localCRC = 0;
        globalController.initializeState = 0;
        if(((localCRC)&((uint16_t) (0x1 << 14)))^((0) << 14)) { (localCRC)<<=1; (localCRC)^=(uint16_t)0x4599; }else (localCRC)<<=1;;
        globalSync.lstBit = 0;
        globalSync.bitRepetitionCount = 1;
    }
    uint8_t i;
    bitCounter++;
    if(((localCRC)&((uint16_t) (0x1 << 14)))^((globalSync.nxtBit) << 14)) { (localCRC)<<=1; (localCRC)^=(uint16_t)0x4599; }else (localCRC)<<=1;;
    if(identifierCounter != 0) {
        (identifier)<<=1; (identifier)+=(globalSync.nxtBit);;
        identifierCounter--;
    }
    if(bitCounter == 12)
        globalController.RTR = globalSync.nxtBit;
    if(bitCounter == 13) {
        extended = globalSync.nxtBit;
        if(extended == 1)
            identifierCounter = 18;
    }
    if(extended == 1) {
        if(bitCounter == 42)
            globalController.RTR = globalSync.nxtBit;
        if((bitCounter >= 45) && (bitCounter <= 48))
            (globalController.dataLength)<<=1; (globalController.dataLength)+=(!globalSync.nxtBit);;
        if(bitCounter == 48)
            endSection = 1;
    }
    if(extended == 0) {
        if((bitCounter >= 15) && (bitCounter <= 18 ))
            (globalController.dataLength)<<=1; (globalController.dataLength)+=(!globalSync.nxtBit);;
        if(bitCounter == 18)
            endSection = 1;
    }
    if(endSection) {
        if(globalController.RTR == 1)
            globalController.dataLength = 0;
        for(i = 0; i < 1; i++)
            if(nodeFilters[i] == identifier) {
                globalController.matchedFilterIndex = i; break;
            }
        if(globalController.RTR)
            currentStateFunction = stateFunction[3];
        else
            currentStateFunction = stateFunction[2];
        globalController.initializeState = 1;
    }
}

canonical_original_code:
void stateArbitrationControl() {
    static unsigned char extended = 0;
    static unsigned char bitCounter = 0;
    static unsigned char identifierCounter = 11;
    static unsigned int identifier = 0;
    static unsigned char endSection = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        extended = 2;
        bitCounter = 0;
        identifierCounter = 0;
        identifier = 0;
        endSection = 0;
        localCRC = 0;
        globalController.initializeState = 0;
        if(((localCRC)&((unsigned short) (0x1 << 14)))^((0) << 14)) { (localCRC)<<=1; (localCRC)^=(unsigned short)0x4599; }else (localCRC)<<=1;;
        globalSync.lstBit = 0;
        globalSync.bitRepetitionCount = 1;
    }
    unsigned char i;
    bitCounter++;
    if(((localCRC)&((unsigned short) (0x1 << 14)))^((globalSync.nxtBit) << 14)) { (localCRC)<<=1; (localCRC)^=(unsigned short)0x4599; }else (localCRC)<<=1;;
    if(identifierCounter != 0) {
        (identifier)<<=1; (identifier)+=(globalSync.nxtBit);;
        identifierCounter--;
    }
    if(bitCounter == 12)
        globalController.RTR = globalSync.nxtBit;
    if(bitCounter == 13) {
        extended = globalSync.nxtBit;
        if(extended == 1)
            identifierCounter = 18;
    }
    if(extended == 1) {
        if(bitCounter == 42)
            globalController.RTR = globalSync.nxtBit;
        if((bitCounter >= 45) && (bitCounter <= 48))
            (globalController.dataLength)<<=1; (globalController.dataLength)+=(!globalSync.nxtBit);;
        if(bitCounter == 48)
            endSection = 1;
    }
    if(extended == 0) {
        if((bitCounter >= 15) && (bitCounter <= 18 ))
            (globalController.dataLength)<<=1; (globalController.dataLength)+=(!globalSync.nxtBit);;
        if(bitCounter == 18)
            endSection = 1;
    }
    if(endSection) {
        if(globalController.RTR == 1)
            globalController.dataLength = 0;
        for(i = 0; i < 1; i++)
            if(nodeFilters[i] == identifier) {
                globalController.matchedFilterIndex = i; break;
            }
        if(globalController.RTR)
            currentStateFunction = stateFunction[3];
        else
            currentStateFunction = stateFunction[2];
        globalController.initializeState = 1;
    }
}

variable_types:
extended
unsigned char

variable_types:
bitCounter
unsigned char

variable_types:
identifierCounter
unsigned char

variable_types:
identifier
unsigned int

variable_types:
endSection
unsigned char

variable_types:
i
unsigned char


stateCRC

decompiled_code:
unsigned __int64 stateCRC()
{
char v0; // dl
int v1; // ecx
unsigned __int64 result; // rax

byte_4040C0 = 1;
if ( byte_4040AB )
{
byte_4040AB = 0;
v0 = 1;
v1 = 0;
LABEL_3:
bitCounter_2 = v0;
result = v1 + (unsigned int)(unsigned __int8)byte_4040BD;
receivedCRC = v1 + (unsigned __int8)byte_4040BD;
return result;
}
result = (unsigned __int8)bitCounter_2;
if ( (unsigned __int8)bitCounter_2 <= 0xFu )
{
v0 = bitCounter_2 + 1;
if ( bitCounter_2 == 15 )
{
result = (unsigned __int64)off_404080[0];
byte_4040AE = 1;
bitCounter_2 = 16;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404080[0];
return result;
}
v1 = 2 * (unsigned __int16)receivedCRC;
goto LABEL_3;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 func7()
{
char v0; // dl
int v1; // ecx
unsigned __int64 result; // rax

byte_4040C0 = 1;
if ( byte_4040AB )
{
byte_4040AB = 0;
v0 = 1;
v1 = 0;
LABEL_3:
bitCounter_2 = v0;
result = v1 + (unsigned int)(unsigned __int8)byte_4040BD;
receivedCRC = v1 + (unsigned __int8)byte_4040BD;
return result;
}
result = (unsigned __int8)bitCounter_2;
if ( (unsigned __int8)bitCounter_2 <= 0xFu )
{
v0 = bitCounter_2 + 1;
if ( bitCounter_2 == 15 )
{
result = (unsigned __int64)off_404080[0];
byte_4040AE = 1;
bitCounter_2 = 16;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404080[0];
return result;
}
v1 = 2 * (unsigned __int16)receivedCRC;
goto LABEL_3;
}
return result;
}

original_code:
void stateCRC() {
    static uint8_t bitCounter = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        bitCounter = 0;
        receivedCRC = 0;
        globalController.initializeState = 0;
    }
    if(bitCounter <= 15) {
        if(bitCounter < 15) {
            (receivedCRC)<<=1; (receivedCRC)+=(globalSync.nxtBit);;
        }
        else {
            globalController.delimiterCRC = 1;
            currentStateFunction = stateFunction[4];
        }
        bitCounter++;
    }
}

canonical_original_code:
void stateCRC() {
    static unsigned char bitCounter = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        bitCounter = 0;
        receivedCRC = 0;
        globalController.initializeState = 0;
    }
    if(bitCounter <= 15) {
        if(bitCounter < 15) {
            (receivedCRC)<<=1; (receivedCRC)+=(globalSync.nxtBit);;
        }
        else {
            globalController.delimiterCRC = 1;
            currentStateFunction = stateFunction[4];
        }
        bitCounter++;
    }
}


stateEOF

original_code:
void stateEOF() {
    static uint8_t bitCounter = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        bitCounter = 0;
        globalController.initializeState = 0;
    }
    if(globalSync.nxtBit != 1) {
        globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
    }
    else
        bitCounter++;
    if(bitCounter == 7) {
    }
}

canonical_original_code:
void stateEOF() {
    static unsigned char bitCounter = 0;
    globalSync.processedLastBit = 1;
    if(globalController.initializeState) {
        bitCounter = 0;
        globalController.initializeState = 0;
    }
    if(globalSync.nxtBit != 1) {
        globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
    }
    else
        bitCounter++;
    if(bitCounter == 7) {
    }
}


stateSuspend

decompiled_code:
void stateSuspend()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void stateSuspend() {
}

canonical_original_code:
void stateSuspend() {
}


Initialize

decompiled_code:
__int64 Initialize()
{
__int64 result; // rax

result = (unsigned int)(unsigned __int8)byte_4040BB - 2;
byte_4040BC = byte_4040BB - 2;
return result;
}

canonical_decompiled_code:
__int64 func10()
{
__int64 result; // rax

result = (unsigned int)(unsigned __int8)byte_4040BB - 2;
byte_4040BC = byte_4040BB - 2;
return result;
}

original_code:
void Initialize() {
    globalSync.relativeJumpWidth = globalSync.jumpWidth - 2;
}


interruptBitTiming

decompiled_code:
void interruptBitTiming()
{
char v0; // al
char v1; // al
char v2; // al

v0 = bitState + 1;
if ( bitState == 2 )
v0 = 0;
bitState = v0;
updateCapture();
if ( bitState == 2 )
{
getSample();
byte_4040C0 = 0;
if ( byte_4040B0 )
{
if ( byte_4040B0 != 2 )
{
if ( !bitState )
goto LABEL_7;
return;
}
if ( byte_404104 )
goto LABEL_34;
if ( !byte_404107 )
{
if ( byte_4040BD == 1 )
{
byte_404107 = 1;
byte_404104 = 8;
}
LABEL_34:
if ( !bitState )
goto LABEL_14;
return;
}
if ( byte_404106 )
++globalError;
else
++word_404102;
byte_4040B0 = 0;
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404098;
}
else
{
if ( (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404068[0] == currentStateFunction
|| currentStateFunction == (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404070[0]
|| currentStateFunction == (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404078[0] )
{
v2 = HIBYTE(word_4040BE);
if ( HIBYTE(word_4040BE) )
{
if ( (_BYTE)word_4040BE == byte_4040BD )
{
++HIBYTE(word_4040BE);
if ( v2 == 5 )
byte_404106 = 0;
}
else
{
if ( HIBYTE(word_4040BE) == 5 )
{
HIBYTE(word_4040BE) = 0;
return;
}
HIBYTE(word_4040BE) = 1;
}
byte_404104 = 6;
byte_4040B0 = 2;
return;
}
LOBYTE(word_4040BE) = byte_4040BD;
HIBYTE(word_4040BE) = 1;
}
if ( byte_4040AD )
{
receivedCRC = (unsigned __int8)byte_4040BD + 2 * receivedCRC;
localCRC &= 0x7FFFu;
if ( receivedCRC != localCRC )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AD = 0;
return;
}
if ( byte_4040AE )
{
if ( byte_4040BD != 1 )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AE = 0;
byte_4040AC = 1;
return;
}
if ( byte_4040AF )
{
if ( byte_4040BD != 1 )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AF = 0;
return;
}
}
if ( !bitState )
goto LABEL_6;
return;
}
if ( !bitState )
{
v1 = byte_4040B0;
if ( byte_4040B0 )
{
LABEL_13:
if ( v1 != 2 )
goto LABEL_7;
LABEL_14:
if ( byte_404104 )
--byte_404104;
goto LABEL_7;
}
LABEL_6:
if ( byte_4040AC )
{
LABEL_7:
putBit();
return;
}
putBit();
byte_4040AC = 0;
v1 = byte_4040B0;
goto LABEL_13;
}
}

canonical_decompiled_code:
void func17()
{
char v0; // al
char v1; // al
char v2; // al

v0 = bitState + 1;
if ( bitState == 2 )
v0 = 0;
bitState = v0;
func13();
if ( bitState == 2 )
{
func11();
byte_4040C0 = 0;
if ( byte_4040B0 )
{
if ( byte_4040B0 != 2 )
{
if ( !bitState )
goto LABEL_7;
return;
}
if ( byte_404104 )
goto LABEL_34;
if ( !byte_404107 )
{
if ( byte_4040BD == 1 )
{
byte_404107 = 1;
byte_404104 = 8;
}
LABEL_34:
if ( !bitState )
goto LABEL_14;
return;
}
if ( byte_404106 )
++globalError;
else
++word_404102;
byte_4040B0 = 0;
byte_4040AB = 1;
currentStateFunction = (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404098;
}
else
{
if ( (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404068[0] == currentStateFunction
|| currentStateFunction == (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404070[0]
|| currentStateFunction == (__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))off_404078[0] )
{
v2 = HIBYTE(word_4040BE);
if ( HIBYTE(word_4040BE) )
{
if ( (_BYTE)word_4040BE == byte_4040BD )
{
++HIBYTE(word_4040BE);
if ( v2 == 5 )
byte_404106 = 0;
}
else
{
if ( HIBYTE(word_4040BE) == 5 )
{
HIBYTE(word_4040BE) = 0;
return;
}
HIBYTE(word_4040BE) = 1;
}
byte_404104 = 6;
byte_4040B0 = 2;
return;
}
LOBYTE(word_4040BE) = byte_4040BD;
HIBYTE(word_4040BE) = 1;
}
if ( byte_4040AD )
{
receivedCRC = (unsigned __int8)byte_4040BD + 2 * receivedCRC;
localCRC &= 0x7FFFu;
if ( receivedCRC != localCRC )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AD = 0;
return;
}
if ( byte_4040AE )
{
if ( byte_4040BD != 1 )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AE = 0;
byte_4040AC = 1;
return;
}
if ( byte_4040AF )
{
if ( byte_4040BD != 1 )
{
byte_404106 = 0;
byte_404104 = 6;
byte_4040B0 = 2;
}
byte_4040AF = 0;
return;
}
}
if ( !bitState )
goto LABEL_6;
return;
}
if ( !bitState )
{
v1 = byte_4040B0;
if ( byte_4040B0 )
{
LABEL_13:
if ( v1 != 2 )
goto LABEL_7;
LABEL_14:
if ( byte_404104 )
--byte_404104;
goto LABEL_7;
}
LABEL_6:
if ( byte_4040AC )
{
LABEL_7:
func12();
return;
}
func12();
byte_4040AC = 0;
v1 = byte_4040B0;
goto LABEL_13;
}
}

original_code:
void interruptBitTiming() {
    if(bitState == 2)
        bitState = 0;
    else
        bitState++;
    updateCapture(0);
    if(bitState == 2) {
        getSample();
        globalSync.processedLastBit = 0;
        if(globalController.controllerMode == 0) {
            if((currentStateFunction == stateFunction[1]) || (currentStateFunction == stateFunction[2]) || (currentStateFunction == stateFunction[3]))
            {
                if(globalSync.bitRepetitionCount != 0)
                {
                    if(globalSync.lstBit == globalSync.nxtBit)
                            globalSync.bitRepetitionCount++;
                    else
                        if(globalSync.bitRepetitionCount == 5) {
                            globalSync.bitRepetitionCount = 0;
                            return;
                        }
                        else
                            globalSync.bitRepetitionCount = 1;
                    if(globalSync.bitRepetitionCount == 6)
                        globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                        return;
                }
                globalSync.lstBit = globalSync.nxtBit;
                globalSync.bitRepetitionCount++;
            }
            if(globalController.matchCRC) {
                (receivedCRC)<<=1; (receivedCRC)+=(globalSync.nxtBit);;
                localCRC &= ~(1 << 15);
                if(localCRC != receivedCRC) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.matchCRC = 0;
                return;
            }
            if(globalController.delimiterCRC) {
                if(globalSync.nxtBit != 1) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.delimiterCRC = 0;
                globalController.generateACK = 1;
                return;
            }
            if(globalController.delimiterACK) {
                if(globalSync.nxtBit != 1) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.delimiterACK = 0;
                return;
            }
        }
        if(globalController.controllerMode == 2) {
            if(globalError.bitCounter == 0) {
                if(globalError.busSubState == 0) {
                    if(globalSync.nxtBit == 1) {
                        globalError.busSubState = 1;
                        globalError.bitCounter = 8;
                    }
                }
                else {
                    if(globalError.lastControllerState == 0)
                        globalError.receiveCounter++;
                    else
                        globalError.transmitCounter++;
                    globalController.controllerMode = 0;
                    currentStateFunction = stateFunction[7];
                    globalController.initializeState = 1;
                }
            }
        }
    }
    if(bitState == 0) {
        uint8_t outputBit = 1;
        if(globalController.controllerMode == 0) {
            if(globalController.generateACK == 0) {
                putBit(0);
                globalController.generateACK = 0;
            }
        }
        if(globalController.controllerMode == 2) {
            if(globalError.bitCounter) {
                outputBit = (globalError.busSubState) ? globalError.errorState : 1;
                globalError.bitCounter--;
            }
        }
        putBit(outputBit);
    }
}

canonical_original_code:
void interruptBitTiming() {
    if(bitState == 2)
        bitState = 0;
    else
        bitState++;
    updateCapture(0);
    if(bitState == 2) {
        getSample();
        globalSync.processedLastBit = 0;
        if(globalController.controllerMode == 0) {
            if((currentStateFunction == stateFunction[1]) || (currentStateFunction == stateFunction[2]) || (currentStateFunction == stateFunction[3]))
            {
                if(globalSync.bitRepetitionCount != 0)
                {
                    if(globalSync.lstBit == globalSync.nxtBit)
                            globalSync.bitRepetitionCount++;
                    else
                        if(globalSync.bitRepetitionCount == 5) {
                            globalSync.bitRepetitionCount = 0;
                            return;
                        }
                        else
                            globalSync.bitRepetitionCount = 1;
                    if(globalSync.bitRepetitionCount == 6)
                        globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                        return;
                }
                globalSync.lstBit = globalSync.nxtBit;
                globalSync.bitRepetitionCount++;
            }
            if(globalController.matchCRC) {
                (receivedCRC)<<=1; (receivedCRC)+=(globalSync.nxtBit);;
                localCRC &= ~(1 << 15);
                if(localCRC != receivedCRC) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.matchCRC = 0;
                return;
            }
            if(globalController.delimiterCRC) {
                if(globalSync.nxtBit != 1) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.delimiterCRC = 0;
                globalController.generateACK = 1;
                return;
            }
            if(globalController.delimiterACK) {
                if(globalSync.nxtBit != 1) {
                    globalError.lastControllerState = (0);globalError.bitCounter = 6;globalController.controllerMode = 2;;
                }
                globalController.delimiterACK = 0;
                return;
            }
        }
        if(globalController.controllerMode == 2) {
            if(globalError.bitCounter == 0) {
                if(globalError.busSubState == 0) {
                    if(globalSync.nxtBit == 1) {
                        globalError.busSubState = 1;
                        globalError.bitCounter = 8;
                    }
                }
                else {
                    if(globalError.lastControllerState == 0)
                        globalError.receiveCounter++;
                    else
                        globalError.transmitCounter++;
                    globalController.controllerMode = 0;
                    currentStateFunction = stateFunction[7];
                    globalController.initializeState = 1;
                }
            }
        }
    }
    if(bitState == 0) {
        unsigned char outputBit = 1;
        if(globalController.controllerMode == 0) {
            if(globalController.generateACK == 0) {
                putBit(0);
                globalController.generateACK = 0;
            }
        }
        if(globalController.controllerMode == 2) {
            if(globalError.bitCounter) {
                outputBit = (globalError.busSubState) ? globalError.errorState : 1;
                globalError.bitCounter--;
            }
        }
        putBit(outputBit);
    }
}

variable_types:
outputBit
unsigned char


interruptOnChange

decompiled_code:
void interruptOnChange()
{
;
}

canonical_decompiled_code:
void func18()
{
;
}

original_code:
void interruptOnChange() {
    switch(bitState) {
        if(currentStateFunction == stateFunction[0]) {
            bitState = 0;
            updateCapture(0);
            resetTimer();
        }
        else
            switch(bitState) {
                case 0:
                    if((getTimer()) <= globalSync.jumpWidth) {
                        updateCapture(0);
                        resetTimer();
                    }
                break;
                case 1:
                    if(globalSync.relativeJumpWidth > 0)
                        if((getTimer()) < globalSync.relativeJumpWidth) {
                            bitState = 0;
                            updateCapture(0);
                            resetTimer();
                        }
                        else
                            updateCapture(globalSync.jumpWidth);
                break;
                case 2:
                    updateCapture((int8_t)(-globalSync.jumpWidth));
                break;
                default:
                break;
            }
    }
}

canonical_original_code:
void interruptOnChange() {
    switch(bitState) {
        if(currentStateFunction == stateFunction[0]) {
            bitState = 0;
            updateCapture(0);
            resetTimer();
        }
        else
            switch(bitState) {
                case 0:
                    if((getTimer()) <= globalSync.jumpWidth) {
                        updateCapture(0);
                        resetTimer();
                    }
                break;
                case 1:
                    if(globalSync.relativeJumpWidth > 0)
                        if((getTimer()) < globalSync.relativeJumpWidth) {
                            bitState = 0;
                            updateCapture(0);
                            resetTimer();
                        }
                        else
                            updateCapture(globalSync.jumpWidth);
                break;
                case 2:
                    updateCapture((char)(-globalSync.jumpWidth));
                break;
                default:
                break;
            }
    }
}


decompiled_code:
__int64 __fastcall contient_terme(_DWORD *a1, _DWORD *a2)
{
int v3; // edi
__int64 result; // rax
_QWORD *v5; // rbp

if ( a1 )
{
if ( a2 )
{
if ( *a2 == 1 )
{
v3 = *a1;
if ( v3 == 1 )
{
result = a1[2] == a2[2];
}
else if ( v3 != 2 && (unsigned int)est_fonction() && (v5 = (_QWORD *)*((_QWORD *)a1 + 1)) != 0LL )
{
do
{
result = contient_terme(*v5, a2);
v5 = (_QWORD *)v5[1];
}
while ( v5 && !(_DWORD)result );
}
else
{
result = 0LL;
}
}
else
{
fwrite(&unk_8F8, 1uLL, 0x4DuLL, stderr);
result = 0LL;
}
}
else
{
fwrite(&unk_8A8, 1uLL, 0x4FuLL, stderr);
result = 0LL;
}
}
else
{
fwrite(&unk_850, 1uLL, 0x57uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_DWORD *a1, _DWORD *a2)
{
int v3; // edi
__int64 result; // rax
_QWORD *v5; // rbp

if ( a1 )
{
if ( a2 )
{
if ( *a2 == 1 )
{
v3 = *a1;
if ( v3 == 1 )
{
result = a1[2] == a2[2];
}
else if ( v3 != 2 && (unsigned int)est_fonction() && (v5 = (_QWORD *)*((_QWORD *)a1 + 1)) != 0LL )
{
do
{
result = func0(*v5, a2);
v5 = (_QWORD *)v5[1];
}
while ( v5 && !(_DWORD)result );
}
else
{
result = 0LL;
}
}
else
{
fwrite(&unk_8F8, 1uLL, 0x4DuLL, stderr);
result = 0LL;
}
}
else
{
fwrite(&unk_8A8, 1uLL, 0x4FuLL, stderr);
result = 0LL;
}
}
else
{
fwrite(&unk_850, 1uLL, 0x57uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
int contient_terme(Terme conteneur, Terme t)
{
 if (conteneur == ((void *)0))
 {
  fprintf(stderr, "*** erreur : contient_terme() - le paramètre 'conteneur' ne devrait jamais être nul.\n");
  return 0;
 }
 else if (t == ((void *)0))
 {
  fprintf(stderr, "*** erreur : contient_terme() - le paramètre 't' ne devrait jamais être nul.\n");
  return 0;
 }
 else if (t->type_terme != Variable)
 {
  fprintf(stderr, "*** erreur : contient_terme() - le terme 't' devrait être de type Variable.\n");
  return 0;
 }
 int found = 0;
 if (conteneur->type_terme == Variable)
 {
  if (conteneur->contenu_terme.val == t->contenu_terme.val)
   found = 1;
 }
 else if (conteneur->type_terme == Constante)
 {
 }
 else if (est_fonction(conteneur->type_terme))
 {
  Argument args = conteneur->contenu_terme.arguments;
  while (args != ((void *)0) && found == 0)
  {
   found = contient_terme(args->terme_argument, t);
   args = args->suivant;
  }
 }
 return found;
}

canonical_original_code:
int contient_terme(struct terme_s *conteneur, struct terme_s *t)
{
 if (conteneur == ((void *)0))
 {
  fprintf(stderr, "*** erreur : contient_terme() - le paramètre 'conteneur' ne devrait jamais être nul.\n");
  return 0;
 }
 else if (t == ((void *)0))
 {
  fprintf(stderr, "*** erreur : contient_terme() - le paramètre 't' ne devrait jamais être nul.\n");
  return 0;
 }
 else if (t->type_terme != Variable)
 {
  fprintf(stderr, "*** erreur : contient_terme() - le terme 't' devrait être de type Variable.\n");
  return 0;
 }
 int found = 0;
 if (conteneur->type_terme == Variable)
 {
  if (conteneur->contenu_terme.val == t->contenu_terme.val)
   found = 1;
 }
 else if (conteneur->type_terme == Constante)
 {
 }
 else if (est_fonction(conteneur->type_terme))
 {
  struct argument_s *args = conteneur->contenu_terme.arguments;
  while (args != ((void *)0) && found == 0)
  {
   found = contient_terme(args->terme_argument, t);
   args = args->suivant;
  }
 }
 return found;
}

variable_types: struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } *

variable_types:
t
struct terme_s *

variable_types: found int

variable_types: struct argument_s { struct terme_s { int type_terme; union { int val; struct argument_s *arguments; } contenu_terme; } *terme_argument; struct argument_s *suivant; } *


decompiled_code:
__int64 __fastcall compter_arguments(unsigned int *a1)
{
__int64 v1; // rax
unsigned int i; // er8

if ( a1 )
{
if ( (unsigned int)est_fonction(*a1) )
{
v1 = *((_QWORD *)a1 + 1);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 8);
}
else
{
fwrite(&unk_9A0, 1uLL, 0x50uLL, stderr);
i = -1;
}
}
else
{
fwrite(&unk_948, 1uLL, 0x52uLL, stderr);
i = -1;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
__int64 v1; // rax
unsigned int i; // er8

if ( a1 )
{
if ( (unsigned int)est_fonction(*a1) )
{
v1 = *((_QWORD *)a1 + 1);
for ( i = 0; v1; ++i )
v1 = *(_QWORD *)(v1 + 8);
}
else
{
fwrite(&unk_9A0, 1uLL, 0x50uLL, stderr);
i = -1;
}
}
else
{
fwrite(&unk_948, 1uLL, 0x52uLL, stderr);
i = -1;
}
return i;
}

original_code:
int compter_arguments(Terme t)
{
 if (t == ((void *)0))
 {
  fprintf(stderr, "*** erreur : compter_arguments() - le paramètre 't' ne devrait jamais être nul.\n");
  return -1;
 }
 else if (!est_fonction(t->type_terme))
 {
  fprintf(stderr, "*** erreur : compter_arguments() - le terme 't' devrait être de type Fonction.\n");
  return -1;
 }
 int compteur = 0;
 Argument args = t->contenu_terme.arguments;
 while (args)
 {
  args = args->suivant;
  compteur++;
 }
 return compteur;
}

canonical_original_code:
int compter_arguments(struct terme_s *t)
{
 if (t == ((void *)0))
 {
  fprintf(stderr, "*** erreur : compter_arguments() - le paramètre 't' ne devrait jamais être nul.\n");
  return -1;
 }
 else if (!est_fonction(t->type_terme))
 {
  fprintf(stderr, "*** erreur : compter_arguments() - le terme 't' devrait être de type Fonction.\n");
  return -1;
 }
 int compteur = 0;
 struct argument_s *args = t->contenu_terme.arguments;
 while (args)
 {
  args = args->suivant;
  compteur++;
 }
 return compteur;
}

variable_types: compteur int

user_defined_types: struct terme_s { int type_terme; union { int val; struct argument_s *arguments; } contenu_terme; }

user_defined_types: struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; }


decompiled_code:
__int64 __fastcall id_fonction(_DWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)est_fonction((unsigned int)*a1) )
return (unsigned int)(*a1 - 30);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( (unsigned int)est_fonction((unsigned int)*a1) )
return (unsigned int)(*a1 - 30);
return 0xFFFFFFFFLL;
}

original_code:
int id_fonction(const Terme t)
{
 int id = -1;
 if (t && est_fonction(t->type_terme))
 {
  id = t->type_terme - Fonction;
 }
 return id;
}

canonical_original_code:
int id_fonction(struct terme_s *t)
{
 int id = -1;
 if (t && est_fonction(t->type_terme))
 {
  id = t->type_terme - Fonction;
 }
 return id;
}

variable_types: id int


decompiled_code:
__int64 __fastcall traiter_equation(__int64 a1, unsigned int **a2, __int64 *a3, _QWORD *a4)
{
unsigned int *v6; // r15
unsigned int *v7; // r14
__int64 v8; // rdi
__int64 *v9; // rax
unsigned int v10; // er13
__int64 v12; // rdi
__int64 v13; // rax
_QWORD *v14; // rbp
__int64 v15; // rax
__int64 v16; // rbx
signed int v17; // eax
__int64 v18; // rax
_QWORD *v19; // rbp
__int64 v20; // rax
__int64 v21; // rbx

if ( !a1 )
{
v10 = -2;
fwrite(&unk_B78, 1uLL, 0x51uLL, stderr);
return v10;
}
if ( !a2 )
{
v10 = -2;
fwrite(&unk_BD0, 1uLL, 0x51uLL, stderr);
return v10;
}
if ( !a3 )
{
v10 = -2;
fwrite(&unk_C28, 1uLL, 0x57uLL, stderr);
return v10;
}
if ( !a4 )
{
v10 = -2;
fwrite(&unk_C80, 1uLL, 0x58uLL, stderr);
return v10;
}
v6 = *a2;
v7 = a2[1];
*a3 = 0LL;
*a4 = 0LL;
v8 = *v6;
if ( (_DWORD)v8 == 1 )
{
v12 = *v7;
if ( (_DWORD)v12 == 1 )
{
v17 = v7[2];
v10 = 0;
if ( v6[2] == v17 )
return v10;
if ( (int)v6[2] >= v17 )
{
v18 = creer_equation();
*a3 = v18;
v19 = (_QWORD *)v18;
v20 = copie_terme(v7);
v21 = *a3;
*v19 = v20;
*(_QWORD *)(v21 + 8) = copie_terme(v6);
return v10;
}
}
else if ( (_DWORD)v12 != 2 )
{
if ( (unsigned int)est_fonction(v12) )
{
v10 = contient_terme(v7, v6);
if ( !v10 )
{
*a4 = copie_equation(a2);
return v10;
}
}
else
{
v8 = *v6;
if ( (_DWORD)v8 != 1 )
goto LABEL_6;
}
return (unsigned int)-1;
}
v10 = 0;
*a4 = copie_equation(a2);
return v10;
}
LABEL_6:
if ( *v7 == 1 )
{
v13 = creer_equation();
v10 = 0;
*a3 = v13;
v14 = (_QWORD *)v13;
v15 = copie_terme(v7);
v16 = *a3;
*v14 = v15;
*(_QWORD *)(v16 + 8) = copie_terme(v6);
return v10;
}
if ( (_DWORD)v8 == 2 && *v7 == 2 )
return (unsigned int)-(v6[2] != v7[2]);
if ( !(unsigned int)est_fonction(v8) || !(unsigned int)est_fonction(*v7) )
return (unsigned int)-1;
v9 = decapsuler_fonctions(v6, v7);
*a3 = (__int64)v9;
return (unsigned int)-(v9 == 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int **a2, __int64 *a3, _QWORD *a4)
{
unsigned int *v6; // r15
unsigned int *v7; // r14
__int64 v8; // rdi
__int64 *v9; // rax
unsigned int v10; // er13
__int64 v12; // rdi
__int64 v13; // rax
_QWORD *v14; // rbp
__int64 v15; // rax
__int64 v16; // rbx
signed int v17; // eax
__int64 v18; // rax
_QWORD *v19; // rbp
__int64 v20; // rax
__int64 v21; // rbx

if ( !a1 )
{
v10 = -2;
fwrite(&unk_B78, 1uLL, 0x51uLL, stderr);
return v10;
}
if ( !a2 )
{
v10 = -2;
fwrite(&unk_BD0, 1uLL, 0x51uLL, stderr);
return v10;
}
if ( !a3 )
{
v10 = -2;
fwrite(&unk_C28, 1uLL, 0x57uLL, stderr);
return v10;
}
if ( !a4 )
{
v10 = -2;
fwrite(&unk_C80, 1uLL, 0x58uLL, stderr);
return v10;
}
v6 = *a2;
v7 = a2[1];
*a3 = 0LL;
*a4 = 0LL;
v8 = *v6;
if ( (_DWORD)v8 == 1 )
{
v12 = *v7;
if ( (_DWORD)v12 == 1 )
{
v17 = v7[2];
v10 = 0;
if ( v6[2] == v17 )
return v10;
if ( (int)v6[2] >= v17 )
{
v18 = creer_equation();
*a3 = v18;
v19 = (_QWORD *)v18;
v20 = copie_terme(v7);
v21 = *a3;
*v19 = v20;
*(_QWORD *)(v21 + 8) = copie_terme(v6);
return v10;
}
}
else if ( (_DWORD)v12 != 2 )
{
if ( (unsigned int)est_fonction(v12) )
{
v10 = func0(v7, v6);
if ( !v10 )
{
*a4 = copie_equation(a2);
return v10;
}
}
else
{
v8 = *v6;
if ( (_DWORD)v8 != 1 )
goto LABEL_6;
}
return (unsigned int)-1;
}
v10 = 0;
*a4 = copie_equation(a2);
return v10;
}
LABEL_6:
if ( *v7 == 1 )
{
v13 = creer_equation();
v10 = 0;
*a3 = v13;
v14 = (_QWORD *)v13;
v15 = copie_terme(v7);
v16 = *a3;
*v14 = v15;
*(_QWORD *)(v16 + 8) = copie_terme(v6);
return v10;
}
if ( (_DWORD)v8 == 2 && *v7 == 2 )
return (unsigned int)-(v6[2] != v7[2]);
if ( !(unsigned int)est_fonction(v8) || !(unsigned int)est_fonction(*v7) )
return (unsigned int)-1;
v9 = decapsuler_fonctions(v6, v7);
*a3 = (__int64)v9;
return (unsigned int)-(v9 == 0LL);
}

original_code:
int traiter_equation(const Solutions s, const Equation *e, Equation **dansSys, Equation **dansSolu)
{
 if (s == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 's' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (e == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'e' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (dansSys == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'dansSys' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (dansSolu == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'dansSolu' ne devrait jamais être nul.\n");
  return -2;
 }
 *dansSys = ((void *)0);
 *dansSolu = ((void *)0);
 int flag = 0;
 Terme t_gauche = e->terme_gauche;
 Terme t_droit = e->terme_droit;
 if (t_gauche->type_terme == Variable && t_droit->type_terme == Variable)
 {
  if (t_gauche->contenu_terme.val == t_droit->contenu_terme.val)
  {
  }
  else
  {
   if (t_gauche->contenu_terme.val < t_droit->contenu_terme.val)
   {
    *dansSolu = copie_equation(e);
   }
   else
   {
    *dansSys = creer_equation();
    (*dansSys)->terme_gauche = copie_terme(t_droit);
    (*dansSys)->terme_droit = copie_terme(t_gauche);
   }
  }
 }
 else if (t_gauche->type_terme == Variable && t_droit->type_terme == Constante)
 {
  *dansSolu = copie_equation(e);
 }
 else if (t_gauche->type_terme == Variable && est_fonction(t_droit->type_terme))
 {
  if (contient_terme(t_droit, t_gauche))
  {
   flag = -1;
  }
  else
  {
   *dansSolu = copie_equation(e);
  }
 }
 else if (t_gauche->type_terme != Variable && t_droit->type_terme == Variable)
 {
  *dansSys = creer_equation();
  (*dansSys)->terme_gauche = copie_terme(t_droit);
  (*dansSys)->terme_droit = copie_terme(t_gauche);
 }
 else if (t_gauche->type_terme != Variable && t_droit->type_terme != Variable)
 {
  if (t_gauche->type_terme == Constante && t_droit->type_terme == Constante)
  {
   if (t_gauche->contenu_terme.val == t_droit->contenu_terme.val)
   {
   }
   else
   {
    flag = -1;
   }
  }
  else if (est_fonction(t_gauche->type_terme) && est_fonction(t_droit->type_terme))
  {
   *dansSys = decapsuler_fonctions(t_gauche, t_droit);
   if (*dansSys == ((void *)0))
   {
    flag = -1;
   }
  }
  else
  {
   flag = -1;
  }
 }
 else
 {
  flag = -1;
 }
 return flag;
}

canonical_original_code:
int traiter_equation(struct { struct terme_s **array; unsigned int size; } *s, struct equation_s *e, struct equation_s **dansSys, struct equation_s **dansSolu)
{
 if (s == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 's' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (e == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'e' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (dansSys == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'dansSys' ne devrait jamais être nul.\n");
  return -2;
 }
 else if (dansSolu == ((void *)0))
 {
  fprintf(stderr, "*** erreur : traiter_equation() - le paramètre 'dansSolu' ne devrait jamais être nul.\n");
  return -2;
 }
 *dansSys = ((void *)0);
 *dansSolu = ((void *)0);
 int flag = 0;
 struct terme_s *t_gauche = e->terme_gauche;
 struct terme_s *t_droit = e->terme_droit;
 if (t_gauche->type_terme == Variable && t_droit->type_terme == Variable)
 {
  if (t_gauche->contenu_terme.val == t_droit->contenu_terme.val)
  {
  }
  else
  {
   if (t_gauche->contenu_terme.val < t_droit->contenu_terme.val)
   {
    *dansSolu = copie_equation(e);
   }
   else
   {
    *dansSys = creer_equation();
    (*dansSys)->terme_gauche = copie_terme(t_droit);
    (*dansSys)->terme_droit = copie_terme(t_gauche);
   }
  }
 }
 else if (t_gauche->type_terme == Variable && t_droit->type_terme == Constante)
 {
  *dansSolu = copie_equation(e);
 }
 else if (t_gauche->type_terme == Variable && est_fonction(t_droit->type_terme))
 {
  if (contient_terme(t_droit, t_gauche))
  {
   flag = -1;
  }
  else
  {
   *dansSolu = copie_equation(e);
  }
 }
 else if (t_gauche->type_terme != Variable && t_droit->type_terme == Variable)
 {
  *dansSys = creer_equation();
  (*dansSys)->terme_gauche = copie_terme(t_droit);
  (*dansSys)->terme_droit = copie_terme(t_gauche);
 }
 else if (t_gauche->type_terme != Variable && t_droit->type_terme != Variable)
 {
  if (t_gauche->type_terme == Constante && t_droit->type_terme == Constante)
  {
   if (t_gauche->contenu_terme.val == t_droit->contenu_terme.val)
   {
   }
   else
   {
    flag = -1;
   }
  }
  else if (est_fonction(t_gauche->type_terme) && est_fonction(t_droit->type_terme))
  {
   *dansSys = decapsuler_fonctions(t_gauche, t_droit);
   if (*dansSys == ((void *)0))
   {
    flag = -1;
   }
  }
  else
  {
   flag = -1;
  }
 }
 else
 {
  flag = -1;
 }
 return flag;
}

variable_types: struct { struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } **array; unsigned int size; } *

variable_types: struct equation_s { struct terme_s *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; } *

variable_types:
dansSys
struct equation_s **

variable_types:
dansSolu
struct equation_s **

variable_types: flag int


decompiled_code:
__int64 __fastcall ranger_solutions(_QWORD *a1, __int64 a2)
{
__int64 v3; // rbx
_DWORD *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbp
__int64 *v7; // r13
__int64 result; // rax

if ( !a1 )
return fwrite(&unk_CE0, 1uLL, 0x51uLL, stderr);
v3 = a2;
if ( !a2 )
return fwrite(&unk_D38, 1uLL, 0x51uLL, stderr);
do
{
v4 = *(_DWORD **)v3;
if ( !*(_QWORD *)v3 )
_assert_fail("e->terme_gauche != NULL", "resolution.c", 0x180u, "ranger_solutions");
v5 = *(_QWORD *)(v3 + 8);
if ( !v5 )
_assert_fail("e->terme_droit != NULL", "resolution.c", 0x181u, "ranger_solutions");
if ( *v4 != 1 )
{
fwrite(&unk_DC0, 1uLL, 0x90uLL, stderr);
abort();
}
v6 = 8LL * (int)v4[2];
v7 = (__int64 *)(v6 - 8 + *a1);
if ( *v7 )
{
fwrite("*** warning: erasing previously set solution\n", 1uLL, 0x2DuLL, stderr);
destroy_terme(*(_QWORD *)(*a1 + v6 - 8));
v5 = *(_QWORD *)(v3 + 8);
v7 = (__int64 *)(*a1 + v6 - 8);
}
result = copie_terme(v5);
v3 = *(_QWORD *)(v3 + 16);
*v7 = result;
}
while ( v3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1, __int64 a2)
{
__int64 v3; // rbx
_DWORD *v4; // rax
__int64 v5; // rdi
__int64 v6; // rbp
__int64 *v7; // r13
__int64 result; // rax

if ( !a1 )
return fwrite(&unk_CE0, 1uLL, 0x51uLL, stderr);
v3 = a2;
if ( !a2 )
return fwrite(&unk_D38, 1uLL, 0x51uLL, stderr);
do
{
v4 = *(_DWORD **)v3;
if ( !*(_QWORD *)v3 )
_assert_fail("e->terme_gauche != NULL", "resolution.c", 0x180u, "ranger_solutions");
v5 = *(_QWORD *)(v3 + 8);
if ( !v5 )
_assert_fail("e->terme_droit != NULL", "resolution.c", 0x181u, "ranger_solutions");
if ( *v4 != 1 )
{
fwrite(&unk_DC0, 1uLL, 0x90uLL, stderr);
abort();
}
v6 = 8LL * (int)v4[2];
v7 = (__int64 *)(v6 - 8 + *a1);
if ( *v7 )
{
fwrite("*** warning: erasing previously set solution\n", 1uLL, 0x2DuLL, stderr);
destroy_terme(*(_QWORD *)(*a1 + v6 - 8));
v5 = *(_QWORD *)(v3 + 8);
v7 = (__int64 *)(*a1 + v6 - 8);
}
result = copie_terme(v5);
v3 = *(_QWORD *)(v3 + 16);
*v7 = result;
}
while ( v3 );
return result;
}

original_code:
void ranger_solutions(Solutions s, const Equation *e)
{
 if (s == ((void *)0))
 {
  fprintf(stderr, "*** erreur : ranger_solutions() - le paramètre 's' ne devrait jamais être nul.\n");
  return;
 }
 else if (e == ((void *)0))
 {
  fprintf(stderr, "*** erreur : ranger_solutions() - le paramètre 'e' ne devrait jamais être nul.\n");
  return;
 }
 while (e)
 {
  ((void) sizeof ((e->terme_gauche != ((void *)0)) ? 1 : 0), __extension__ ({ if (e->terme_gauche != ((void *)0)) ; else __assert_fail ("e->terme_gauche != NULL", "resolution.c", 384, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((e->terme_droit != ((void *)0)) ? 1 : 0), __extension__ ({ if (e->terme_droit != ((void *)0)) ; else __assert_fail ("e->terme_droit != NULL", "resolution.c", 385, __extension__ __PRETTY_FUNCTION__); }));
  if (e->terme_gauche->type_terme == Variable)
  {
   int i = e->terme_gauche->contenu_terme.val;
   if (s->array[i-1])
   {
    fprintf(stderr, "*** warning: erasing previously set solution\n");
    destroy_terme(s->array[i-1]);
   }
   s->array[i-1] = copie_terme(e->terme_droit);
  }
  else
  {
   fprintf(stderr, "*** erreur : en train d'essayer de ranger une équation avec un terme gauche de type différent de Variable. Comportement inconsistent. Arrêt.\n");
   abort();
  }
  e = e->suivant;
 }
}

canonical_original_code:
void ranger_solutions(struct { struct terme_s **array; unsigned int size; } *s, struct equation_s *e)
{
 if (s == ((void *)0))
 {
  fprintf(stderr, "*** erreur : ranger_solutions() - le paramètre 's' ne devrait jamais être nul.\n");
  return;
 }
 else if (e == ((void *)0))
 {
  fprintf(stderr, "*** erreur : ranger_solutions() - le paramètre 'e' ne devrait jamais être nul.\n");
  return;
 }
 while (e)
 {
  ((void) sizeof ((e->terme_gauche != ((void *)0)) ? 1 : 0), __extension__ ({ if (e->terme_gauche != ((void *)0)) ; else __assert_fail ("e->terme_gauche != NULL", "resolution.c", 384, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((e->terme_droit != ((void *)0)) ? 1 : 0), __extension__ ({ if (e->terme_droit != ((void *)0)) ; else __assert_fail ("e->terme_droit != NULL", "resolution.c", 385, __extension__ __PRETTY_FUNCTION__); }));
  if (e->terme_gauche->type_terme == Variable)
  {
   int i = e->terme_gauche->contenu_terme.val;
   if (s->array[i-1])
   {
    fprintf(stderr, "*** warning: erasing previously set solution\n");
    destroy_terme(s->array[i-1]);
   }
   s->array[i-1] = copie_terme(e->terme_droit);
  }
  else
  {
   fprintf(stderr, "*** erreur : en train d'essayer de ranger une équation avec un terme gauche de type différent de Variable. Comportement inconsistent. Arrêt.\n");
   abort();
  }
  e = e->suivant;
 }
}

variable_types: i int

user_defined_types: struct equation_s { struct terme_s *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; }


decompiled_code:
// attributes: thunk
_QWORD *creer_equation()
{
return creer_systeme();
}

canonical_decompiled_code:
_QWORD *func1()
{
return func0();
}

original_code:
Equation *creer_equation(void)
{
 return creer_systeme();
}

canonical_original_code:
struct equation_s *creer_equation()
{
 return creer_systeme();
}

return_type: struct equation_s { struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; } *


decompiled_code:
_QWORD *creer_terme()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
*(_DWORD *)result = 0;
result[1] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func2()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
*(_DWORD *)result = 0;
result[1] = 0LL;
return result;
}

original_code:
Terme creer_terme(void)
{
 Terme te;
 te = (Terme)malloc(sizeof(*te));
 if(te == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  te->type_terme = 0;
  te->contenu_terme.arguments = (Argument)((void *)0);
  te->contenu_terme.val = 0;
 }
 return te;
}

canonical_original_code:
struct terme_s *creer_terme()
{
 struct terme_s *te;
 te = (struct terme_s *)malloc(sizeof(*te));
 if(te == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  te->type_terme = 0;
  te->contenu_terme.arguments = (Argument)((void *)0);
  te->contenu_terme.val = 0;
 }
 return te;
}

return_type: struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } *


decompiled_code:
_QWORD *creer_argument()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
result[1] = 0LL;
*result = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func3()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
result[1] = 0LL;
*result = 0LL;
return result;
}

original_code:
Argument creer_argument(void)
{
 Argument a;
 a = (Argument)malloc(sizeof(*a));
 if(a == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  a->suivant=((void *)0);
  a->terme_argument=((void *)0);
 }
 return a;
}

canonical_original_code:
struct argument_s *creer_argument()
{
 struct argument_s *a;
 a = (struct argument_s *)malloc(sizeof(*a));
 if(a == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  a->suivant=((void *)0);
  a->terme_argument=((void *)0);
 }
 return a;
}

return_type: struct argument_s { struct terme_s { int type_terme; union { int val; struct argument_s *arguments; } contenu_terme; } *terme_argument; struct argument_s *suivant; } *


decompiled_code:
_DWORD *creer_solutions()
{
_DWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
*(_QWORD *)result = 0LL;
result[2] = 0;
return result;
}

canonical_decompiled_code:
_DWORD *func4()
{
_DWORD *result; // rax

result = malloc(0x10uLL);
if ( !result )
{
fwrite("malloc error\n", 1uLL, 0xDuLL, stderr);
abort();
}
*(_QWORD *)result = 0LL;
result[2] = 0;
return result;
}

original_code:
Solutions creer_solutions(void)
{
 Solutions sol;
 sol = (Solutions)malloc(sizeof(*sol));
 if (sol == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  sol->array = ((void *)0);
  sol->size = 0;
 }
 return sol;
}

canonical_original_code:
struct { struct terme_s **array; unsigned int size; } *creer_solutions()
{
 struct { struct terme_s **array; unsigned int size; } *sol;
 sol = (struct { struct terme_s **array; unsigned int size; } *)malloc(sizeof(*sol));
 if (sol == ((void *)0))
 {
  fprintf(stderr, "malloc error\n");
  abort();
 }
 else
 {
  sol->array = ((void *)0);
  sol->size = 0;
 }
 return sol;
}

return_type: struct { struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } **array; unsigned int size; } *


decompiled_code:
__int64 __fastcall initialiser_solutions(__int64 a1, unsigned int a2)
{
void *v3; // rdi
void *v4; // rax
__int64 result; // rax

if ( a1 )
{
v3 = *(void **)a1;
if ( v3 )
free(v3);
*(_DWORD *)(a1 + 8) = a2;
v4 = malloc(8LL * a2);
*(_QWORD *)a1 = v4;
if ( a2 )
memset(v4, 0, 8LL * a2);
result = 1LL;
}
else
{
fwrite(&unk_5C0, 1uLL, 0x56uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, unsigned int a2)
{
void *v3; // rdi
void *v4; // rax
__int64 result; // rax

if ( a1 )
{
v3 = *(void **)a1;
if ( v3 )
free(v3);
*(_DWORD *)(a1 + 8) = a2;
v4 = malloc(8LL * a2);
*(_QWORD *)a1 = v4;
if ( a2 )
memset(v4, 0, 8LL * a2);
result = 1LL;
}
else
{
fwrite(&unk_5C0, 1uLL, 0x56uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int initialiser_solutions(Solutions s, unsigned n)
{
 if(s == ((void *)0))
 {
  fprintf(stderr,"*** erreur : initialiser_solutions() - Le paramètre 's' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (s->array)
   free(s->array);
  s->size = n;
  s->array = (Terme *)malloc(n * sizeof(Terme));
  unsigned i;
  for (i = 0; i < n;i++)
   s->array[i] = ((void *)0);
   return 1;
 }
}

canonical_original_code:
int initialiser_solutions(struct { struct terme_s **array; unsigned int size; } *s, unsigned int n)
{
 if(s == ((void *)0))
 {
  fprintf(stderr,"*** erreur : initialiser_solutions() - Le paramètre 's' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (s->array)
   free(s->array);
  s->size = n;
  s->array = (struct terme_s **)malloc(n * sizeof(Terme));
  unsigned int i;
  for (i = 0; i < n;i++)
   s->array[i] = ((void *)0);
   return 1;
 }
}

variable_types:
n
unsigned int

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall destroy_argument(void **a1)
{
void *v2; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( v2 && (unsigned int)destroy_terme(v2) == -1 || a1[1] && (unsigned int)destroy_argument() == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
free(a1);
result = 1LL;
}
}
else
{
fwrite(&unk_710, 1uLL, 0x53uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(void **a1)
{
void *v2; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
if ( v2 && (unsigned int)func7(v2) == -1 || a1[1] && (unsigned int)func6() == -1 )
{
result = 0xFFFFFFFFLL;
}
else
{
free(a1);
result = 1LL;
}
}
else
{
fwrite(&unk_710, 1uLL, 0x53uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int destroy_argument(Argument arg)
{
 if(arg == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_argument() - Le paramètre 'arg' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (arg->terme_argument)
  {
   if(destroy_terme(arg->terme_argument)==-1)
   {
    return -1;
   }
  }
  if (arg->suivant)
  {
   if(destroy_argument(arg->suivant)==-1)
   {
    return -1;
   }
  }
  free (arg);
  return 1;
 }
}

canonical_original_code:
int destroy_argument(struct argument_s *arg)
{
 if(arg == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_argument() - Le paramètre 'arg' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (arg->terme_argument)
  {
   if(destroy_terme(arg->terme_argument)==-1)
   {
    return -1;
   }
  }
  if (arg->suivant)
  {
   if(destroy_argument(arg->suivant)==-1)
   {
    return -1;
   }
  }
  free (arg);
  return 1;
 }
}


decompiled_code:
__int64 __fastcall destroy_terme(void *ptr)
{
void **v2; // rdi
__int64 result; // rax

if ( ptr )
{
if ( (unsigned int)(*(_DWORD *)ptr - 30) > 3
|| (v2 = (void **)*((_QWORD *)ptr + 1)) == 0LL
|| (result = destroy_argument(v2), (_DWORD)result != -1) )
{
free(ptr);
result = 1LL;
}
}
else
{
fwrite(&unk_768, 1uLL, 0x52uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *ptr)
{
void **v2; // rdi
__int64 result; // rax

if ( ptr )
{
if ( (unsigned int)(*(_DWORD *)ptr - 30) > 3
|| (v2 = (void **)*((_QWORD *)ptr + 1)) == 0LL
|| (result = func6(v2), (_DWORD)result != -1) )
{
free(ptr);
result = 1LL;
}
}
else
{
fwrite(&unk_768, 1uLL, 0x52uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int destroy_terme(Terme terme)
{
 if(terme == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_terme() - Le paramètre 'terme' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (terme->type_terme >= 30 &&
   terme->type_terme <= 33 &&
   terme->contenu_terme.arguments != ((void *)0))
   if(destroy_argument(terme->contenu_terme.arguments)==-1)
   {
    return -1;
   }
  free(terme);
  return 1;
 }
}

canonical_original_code:
int destroy_terme(struct terme_s *terme)
{
 if(terme == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_terme() - Le paramètre 'terme' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if (terme->type_terme >= 30 &&
   terme->type_terme <= 33 &&
   terme->contenu_terme.arguments != ((void *)0))
   if(destroy_argument(terme->contenu_terme.arguments)==-1)
   {
    return -1;
   }
  free(terme);
  return 1;
 }
}


decompiled_code:
__int64 __fastcall destroy_equation(void **a1)
{
__int64 result; // rax

if ( a1 )
{
result = destroy_systeme(a1);
if ( (_DWORD)result != -1 )
result = 1LL;
}
else
{
fwrite(&unk_818, 1uLL, 0x51uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(void **a1)
{
__int64 result; // rax

if ( a1 )
{
result = func8(a1);
if ( (_DWORD)result != -1 )
result = 1LL;
}
else
{
fwrite(&unk_818, 1uLL, 0x51uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int destroy_equation(Equation *e)
{
 if(e == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_equation() - Le paramètre 'e' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if(destroy_systeme(e)==-1)
  {
   return -1;
  }
  return 1;
 }
}

canonical_original_code:
int destroy_equation(struct equation_s *e)
{
 if(e == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_equation() - Le paramètre 'e' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  if(destroy_systeme(e)==-1)
  {
   return -1;
  }
  return 1;
 }
}

variable_types: struct equation_s { struct terme_s { int type_terme; union { int val; struct argument_s { struct terme_s *terme_argument; struct argument_s *suivant; } *arguments; } contenu_terme; } *terme_gauche; struct terme_s *terme_droit; struct equation_s *suivant; } *


decompiled_code:
__int64 __fastcall destroy_solutions(void *ptr)
{
__int64 v1; // rbp
char *v2; // r8
__int64 v4; // rbp
__int64 v5; // rbx
void *v6; // rdi
__int64 result; // rax

if ( ptr )
{
v1 = *((unsigned int *)ptr + 2);
v2 = *(char **)ptr;
if ( (_DWORD)v1 )
{
v4 = 8 * v1;
v5 = 0LL;
do
{
v6 = *(void **)&v2[v5];
if ( v6 )
{
result = destroy_terme(v6);
if ( (_DWORD)result == -1 )
return result;
v2 = *(char **)ptr;
}
v5 += 8LL;
}
while ( v5 != v4 );
}
free(v2);
free(ptr);
result = 1LL;
}
else
{
fwrite(&unk_870, 1uLL, 0x54uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *ptr)
{
__int64 v1; // rbp
char *v2; // r8
__int64 v4; // rbp
__int64 v5; // rbx
void *v6; // rdi
__int64 result; // rax

if ( ptr )
{
v1 = *((unsigned int *)ptr + 2);
v2 = *(char **)ptr;
if ( (_DWORD)v1 )
{
v4 = 8 * v1;
v5 = 0LL;
do
{
v6 = *(void **)&v2[v5];
if ( v6 )
{
result = func7(v6);
if ( (_DWORD)result == -1 )
return result;
v2 = *(char **)ptr;
}
v5 += 8LL;
}
while ( v5 != v4 );
}
free(v2);
free(ptr);
result = 1LL;
}
else
{
fwrite(&unk_870, 1uLL, 0x54uLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int destroy_solutions(Solutions sol)
{
 if(sol == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_solutions() - Le paramètre 'sol' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  unsigned size = sol->size;
  unsigned i;
  for (i = 0;i < size; i++)
  {
   if (sol->array[i])
   {
    if(destroy_terme(sol->array[i])==-1)
    {
     return -1;
    }
   }
  }
  free(sol->array);
  free(sol);
  return 1;
 }
}

canonical_original_code:
int destroy_solutions(struct { struct terme_s **array; unsigned int size; } *sol)
{
 if(sol == ((void *)0))
 {
  fprintf(stderr,"*** erreur : destroy_solutions() - Le paramètre 'sol' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  unsigned int size = sol->size;
  unsigned int i;
  for (i = 0;i < size; i++)
  {
   if (sol->array[i])
   {
    if(destroy_terme(sol->array[i])==-1)
    {
     return -1;
    }
   }
  }
  free(sol->array);
  free(sol);
  return 1;
 }
}

variable_types:
size
unsigned int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
test_types(argc, argv, envp);
test_text();
test_donnees();
test_parser();
test_affichage();
test_construction();
test_representant();
test_resolution();
return 0;
}

original_code:
int main (int argc, const char * argv[])
{
 test_types();
 test_text();
 test_donnees();
 test_parser();
 test_affichage();
 test_construction();
 test_representant();
 test_resolution();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 test_types();
 test_text();
 test_donnees();
 test_parser();
 test_affichage();
 test_construction();
 test_representant();
 test_resolution();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
__int64 __fastcall text_obtenir_taille(__int64 a1)
{
if ( a1 )
return *(unsigned int *)(a1 + 8);
fwrite(&unk_AD8, 1uLL, 0x54uLL, stderr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( a1 )
return *(unsigned int *)(a1 + 8);
fwrite(&unk_AD8, 1uLL, 0x54uLL, stderr);
return 0LL;
}

original_code:
unsigned text_obtenir_taille(const Text t)
{
 if(t == ((void *)0))
 {
  fprintf(stderr,"*** erreur : text_obtenir_taille() - Le paramètre 't' ne devrait jamais être nul.\n");
  return 0;
 }
 else
 {
  return (unsigned)t->length;
 }
}

canonical_original_code:
unsigned int text_obtenir_taille(struct Text *t)
{
 if(t == ((void *)0))
 {
  fprintf(stderr,"*** erreur : text_obtenir_taille() - Le paramètre 't' ne devrait jamais être nul.\n");
  return 0;
 }
 else
 {
  return (unsigned int)t->length;
 }
}

variable_types: struct Text { char *data; unsigned long length; } *

return_type: unsigned int


decompiled_code:
__int64 __fastcall text_destroy(void *ptr)
{
__int64 result; // rax

if ( ptr )
{
free(*(void **)ptr);
free(ptr);
result = 1LL;
}
else
{
fwrite(&unk_D28, 1uLL, 0x4DuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
__int64 result; // rax

if ( ptr )
{
free(*(void **)ptr);
free(ptr);
result = 1LL;
}
else
{
fwrite(&unk_D28, 1uLL, 0x4DuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int text_destroy(Text t)
{
 if(t == ((void *)0))
 {
  fprintf(stderr,"*** erreur : text_destroy() - Le paramètre 't' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  free (t->data);
  free (t);
  return 1;
 }
}

canonical_original_code:
int text_destroy(struct Text *t)
{
 if(t == ((void *)0))
 {
  fprintf(stderr,"*** erreur : text_destroy() - Le paramètre 't' ne devrait jamais être nul.\n");
  return -1;
 }
 else
 {
  free (t->data);
  free (t);
  return 1;
 }
}

user_defined_types: struct Text { char *data; unsigned long length; }