decompiled_code:
int ex2_10()
{
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

strcpy(v1, "JAMES IN UPPERCASE\n");
printf("%s", v1);
lowerString((unsigned __int8 *)v1);
return printf("%s", v1);
}

canonical_decompiled_code:
int func1()
{
char v1[40]; // [rsp+0h] [rbp-28h] BYREF

strcpy(v1, "JAMES IN UPPERCASE\n");
printf("%s", v1);
func0((unsigned __int8 *)v1);
return printf("%s", v1);
}

original_code:
void ex2_10(){
 char word[] = "JAMES IN UPPERCASE\n";
 printf("%s", word);
 lowerString(word);
 printf("%s", word);
}


bitCountOriginal

decompiled_code:
__int64 __fastcall bitCountOriginal(unsigned int a1)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)result - (((a1 & 1) == 0) - 1);
a1 >>= 1;
}
while ( a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
__int64 result; // rax

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)result - (((a1 & 1) == 0) - 1);
a1 >>= 1;
}
while ( a1 );
return result;
}

original_code:
int bitCountOriginal(unsigned x){
 int b;
 for(b = 0; x != 0; x >>= 1)
  if(x & 01)
   b++;
 return b;
}

canonical_original_code:
int bitCountOriginal(unsigned int x){
 int b;
 for(b = 0; x != 0; x >>= 1)
  if(x & 01)
   b++;
 return b;
}

variable_types:
x
unsigned int

variable_types: b int

return_type: int


decompiled_code:
int ex2_9()
{
unsigned int v0; // eax

v0 = bitCountOriginal(0xFFFFFFFu);
return printf("First value %d, Second value %d\n", v0, v0);
}

canonical_decompiled_code:
int func3()
{
unsigned int v0; // eax

v0 = func2(0xFFFFFFFu);
return printf("First value %d, Second value %d\n", v0, v0);
}

original_code:
void ex2_9(){
 unsigned int first = bitCountOriginal(0xFFFFFFF);
 unsigned int second = bitCountOriginal(0xFFFFFFF);
 printf("First value %d, Second value %d\n", first, second);
}

variable_types:
first
unsigned int

variable_types:
second
unsigned int

return_type: void


bitCountNew

decompiled_code:
__int64 __fastcall bitCountNew(int a1)
{
unsigned int v1; // edx

if ( !a1 )
return 0;
v1 = 0;
do
{
++v1;
a1 &= a1 - 1;
}
while ( a1 );
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
unsigned int v1; // edx

if ( !a1 )
return 0;
v1 = 0;
do
{
++v1;
a1 &= a1 - 1;
}
while ( a1 );
return v1;
}

original_code:
int bitCountNew(unsigned x){
 int b;
 for(b = 0; x != 0; x &= (x-1))
  b++;
 return b;
}

canonical_original_code:
int bitCountNew(unsigned int x){
 int b;
 for(b = 0; x != 0; x &= (x-1))
  b++;
 return b;
}


rightRotate

decompiled_code:
__int64 __fastcall rightRotate(unsigned int a1, char a2)
{
return a1 >> a2;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int a1, char a2)
{
return a1 >> a2;
}

original_code:
unsigned int rightRotate(unsigned int x, int number){
 return x >> number;
}

variable_types: number int

return_type: unsigned int


invertBits

original_code:
unsigned int invertBits(unsigned int x, int position, int number){
 unsigned int xValue = x;
 x = x & (~0 << position);
 x = x | ~(~0 << (position - number));
 xValue = (~xValue & ~(~0 << number));
 xValue = xValue << (position - number);
 return x | xValue;
}

variable_types: position int

variable_types:
xValue
unsigned int


setBits

original_code:
unsigned int setBits(unsigned int x, int position, int number, unsigned int value){
 x = x & (~0 << position);
 x = x | ~(~0 << (position - number));
 value = value & ~(~0 << number);
 value = value << (position - number);
 return x | value;
}

variable_types:
value
unsigned int


getBits

decompiled_code:
__int64 __fastcall getBits(unsigned int a1, char a2, char a3)
{
return (a1 >> (a2 - a3)) & ~(-1 << a3);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, char a2, char a3)
{
return (a1 >> (a2 - a3)) & ~(-1 << a3);
}

original_code:
unsigned int getBits(unsigned int x, int position, int number){
 return ( x >> ( position - number )) & ~ ( ~ 0 << number);
}


printBinary

decompiled_code:
int __fastcall printBinary(unsigned int a1)
{
char *v1; // rax
char *v2; // rdx
__int64 v3; // rax
int v4; // edx
unsigned int v5; // ecx
char *v6; // rbx
char *v7; // rbp
char v9; // [rsp+1h] [rbp-119h] BYREF
char v10[256]; // [rsp+2h] [rbp-118h] BYREF
char v11; // [rsp+102h] [rbp-18h] BYREF

v1 = v10;
do
*v1++ = 0;
while ( v1 != &v11 );
if ( a1 )
{
v2 = v10;
do
{
*v2++ = (a1 & 1) + 48;
a1 >>= 1;
}
while ( a1 );
}
if ( v10[0] )
{
v3 = 0LL;
do
{
v4 = v3;
v5 = v3++;
}
while ( v10[v3] );
if ( v4 >= 0 )
{
v6 = &v10[v4];
v7 = &v9 + v4 - v5;
do
putchar(*v6--);
while ( v7 != v6 );
}
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func9(unsigned int a1)
{
char *v1; // rax
char *v2; // rdx
__int64 v3; // rax
int v4; // edx
unsigned int v5; // ecx
char *v6; // rbx
char *v7; // rbp
char v9; // [rsp+1h] [rbp-119h] BYREF
char v10[256]; // [rsp+2h] [rbp-118h] BYREF
char v11; // [rsp+102h] [rbp-18h] BYREF

v1 = v10;
do
*v1++ = 0;
while ( v1 != &v11 );
if ( a1 )
{
v2 = v10;
do
{
*v2++ = (a1 & 1) + 48;
a1 >>= 1;
}
while ( a1 );
}
if ( v10[0] )
{
v3 = 0LL;
do
{
v4 = v3;
v5 = v3++;
}
while ( v10[v3] );
if ( v4 >= 0 )
{
v6 = &v10[v4];
v7 = &v9 + v4 - v5;
do
putchar(*v6--);
while ( v7 != v6 );
}
}
return putchar(10);
}

original_code:
void printBinary(unsigned int input){
 int MAXLENGTH = 256;
 char binaryString[MAXLENGTH];
 int i;
 for(i = 0; i < MAXLENGTH; i++)
  binaryString[i] = '\0';
 i = 0;
 while(input){
  binaryString[i] = '0' + (input & 1);
  input >>= 1;
  i++;
 }
 i = 0;
 while(binaryString[i] != '\0'){
  i++;
 }
 while(--i >= 0){
  printf("%c", binaryString[i]);
 }
 printf("\n");
}

canonical_original_code:
void printBinary(unsigned int input){
 int MAXLENGTH = 256;
 char binaryString[-1];
 int i;
 for(i = 0; i < MAXLENGTH; i++)
  binaryString[i] = '\0';
 i = 0;
 while(input){
  binaryString[i] = '0' + (input & 1);
  input >>= 1;
  i++;
 }
 i = 0;
 while(binaryString[i] != '\0'){
  i++;
 }
 while(--i >= 0){
  printf("%c", binaryString[i]);
 }
 printf("\n");
}

variable_types:
input
unsigned int

variable_types: MAXLENGTH int

variable_types:
binaryString
char [-1]

variable_types: i int


decompiled_code:
int ex2_8()
{
unsigned int v0; // eax

printBinary(8u);
v0 = rightRotate(8u, 2);
return printBinary(v0);
}

canonical_decompiled_code:
int func10()
{
unsigned int v0; // eax

func9(8u);
v0 = func5(8u, 2);
return func9(v0);
}

original_code:
void ex2_8(){
 unsigned int value = 8;
 printBinary(value);
 value = rightRotate(value, 2);
 printBinary(value);
}


decompiled_code:
int ex2_7()
{
unsigned int v0; // eax

printBinary(0xFu);
v0 = invertBits(15, 3, 2);
return printBinary(v0);
}

canonical_decompiled_code:
int func11()
{
unsigned int v0; // eax

func9(0xFu);
v0 = func6(15, 3, 2);
return func9(v0);
}

original_code:
void ex2_7(){
 unsigned int value = 0xF;
 printBinary(value);
 value = invertBits(value, 3, 2);
 printBinary(value);
}


decompiled_code:
int ex2_6()
{
unsigned int v0; // eax

printBinary(0xFu);
v0 = setBits(15, 4, 2, 2);
return printBinary(v0);
}

canonical_decompiled_code:
int func12()
{
unsigned int v0; // eax

func9(0xFu);
v0 = func7(15, 4, 2, 2);
return func9(v0);
}

original_code:
void ex2_6(){
 unsigned int value = 0xF;
 unsigned int value2 = 2;
 printBinary(value);
 value = setBits(value, 4, 2, value2);
 printBinary(value);
}


decompiled_code:
__int64 __fastcall ex2_5(char *a1, char *a2)
{
char v3; // cl
__int64 v4; // rdi
unsigned int v5; // er10
char *v6; // rdx
char v7; // al

v3 = *a1;
if ( !*a1 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v5 = v4;
v6 = a2 + 1;
v7 = *a2;
if ( *a2 )
break;
LABEL_6:
v3 = a1[++v4];
if ( !v3 )
return (unsigned int)-1;
}
while ( v3 != v7 )
{
v7 = *v6++;
if ( !v7 )
goto LABEL_6;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func13(char *a1, char *a2)
{
char v3; // cl
__int64 v4; // rdi
unsigned int v5; // er10
char *v6; // rdx
char v7; // al

v3 = *a1;
if ( !*a1 )
return (unsigned int)-1;
v4 = 0LL;
while ( 1 )
{
v5 = v4;
v6 = a2 + 1;
v7 = *a2;
if ( *a2 )
break;
LABEL_6:
v3 = a1[++v4];
if ( !v3 )
return (unsigned int)-1;
}
while ( v3 != v7 )
{
v7 = *v6++;
if ( !v7 )
goto LABEL_6;
}
return v5;
}

original_code:
int ex2_5(char s1[], char s2[]){
 int position = -1;
 char temp, temp2;
 int i, j;
 for(i = 0; (temp = s1[i]) && temp != '\0'; i++){
  for(j = 0; (temp2 = s2[j]) && temp2 != '\0'; j++){
   if(temp == temp2)
    return position = i;
  }
 }
 return position;
}

canonical_original_code:
int ex2_5(char s1[], char s2[]){
 int position = -1;
 char temp; char temp2;
 int i; int j;
 for(i = 0; (temp = s1[i]) && temp != '\0'; i++){
  for(j = 0; (temp2 = s2[j]) && temp2 != '\0'; j++){
   if(temp == temp2)
    return position = i;
  }
 }
 return position;
}

variable_types: temp char

variable_types: j int


original_code:
void ex2_3(char myString[]){
 char hexDigits[] = "0123456789ABCDEF";
 float result = 0.0f;
 int counter = 0;
 while(myString[counter++] != '\0'){}
 counter--;
 int i;
 for(i = 0; counter-- > 0; i++){
  int j;
  if(myString[counter] == 'x' || myString[counter] == 'X')
   break;
  for(j = 0; j <= 16; j++){
   if(tolower(hexDigits[j]) == tolower(myString[counter])){
    float base = pow(16, i);
    if(base)
     result += base*j;
    else
     result += j;
   }
  }
 }
 printf("Result: %f\n", result);
}

variable_types:
myString
char []

variable_types:
hexDigits
char []

variable_types: result float

variable_types: counter int

variable_types: base float


decompiled_code:
int ex2_2()
{
char *v0; // rbx
char *v1; // rax
char *v2; // rbp
char v3; // al
char v5[9]; // [rsp+6h] [rbp-32h] BYREF
char v6; // [rsp+Fh] [rbp-29h] BYREF
char v7[40]; // [rsp+10h] [rbp-28h] BYREF

v0 = v5;
v1 = v5;
do
*v1++ = 0;
while ( v1 != v7 );
v2 = v5;
do
{
v3 = getchar();
if ( v3 != -1 && v3 != 10 )
*v2 = v3;
++v2;
}
while ( v2 != &v6 );
do
putchar(*v0++);
while ( v0 != v7 );
return putchar(10);
}

canonical_decompiled_code:
int func16()
{
char *v0; // rbx
char *v1; // rax
char *v2; // rbp
char v3; // al
char v5[9]; // [rsp+6h] [rbp-32h] BYREF
char v6; // [rsp+Fh] [rbp-29h] BYREF
char v7[40]; // [rsp+10h] [rbp-28h] BYREF

v0 = v5;
v1 = v5;
do
*v1++ = 0;
while ( v1 != v7 );
v2 = v5;
do
{
v3 = getchar();
if ( v3 != -1 && v3 != 10 )
*v2 = v3;
++v2;
}
while ( v2 != &v6 );
do
putchar(*v0++);
while ( v0 != v7 );
return putchar(10);
}

original_code:
void ex2_2(){
 int lim = 10;
 char myString[lim];
 int i;
 char c;
 for(i = 0; i < lim; i++)
  myString[i] = '\0';
 for(i = 0; i < lim-1; ++i){
  if((c = getchar()) != '\n'){
   if(c != (-1))
    myString[i] = c;
  }
 }
 for(i = 0; i < lim; i++)
  printf("%c",myString[i]);
 printf("\n");
}

canonical_original_code:
void ex2_2(){
 int lim = 10;
 char myString[-1];
 int i;
 char c;
 for(i = 0; i < lim; i++)
  myString[i] = '\0';
 for(i = 0; i < lim-1; ++i){
  if((c = getchar()) != '\n'){
   if(c != (-1))
    myString[i] = c;
  }
 }
 for(i = 0; i < lim; i++)
  printf("%c",myString[i]);
 printf("\n");
}

variable_types: lim int

variable_types:
myString
char [-1]

variable_types: c char


decompiled_code:
int ex2_1()
{
printf("Unsigned char\tMax:%hhu\n", 255LL);
printf("Signed char\tMin:%hhd\tMax:%hhd\n", 4294967168LL, 127LL);
printf("Unsigned int\tMax:%u\n", 0xFFFFFFFFLL);
printf("Signed int\tMin:%u\tMax:%d\n", 0x80000000LL, 0x7FFFFFFFLL);
printf("Unsigned short\tMax:%hu\n", 0xFFFFLL);
printf("Signed short\tMin:%hd\tMax:%hd\n", 4294934528LL, 0x7FFFLL);
printf("Unsigned long\tMax:%lu\n", -1LL);
printf("Signed long\tMin:%ld\tMax:%ld\n", 0x8000000000000000LL, 0x7FFFFFFFFFFFFFFFLL);
printf("Unsigned long long\tMax:%llu\n", -1LL);
printf("Signed long long\tMin:%lld\tMax:%lld\n", 0x8000000000000000LL, 0x7FFFFFFFFFFFFFFFLL);
return printf("Float MIN:%E\tMAX:%E\n", *(double *)&LC16, *(double *)&LC15);
}

canonical_decompiled_code:
int func17()
{
printf("Unsigned char\tMax:%hhu\n", 255LL);
printf("Signed char\tMin:%hhd\tMax:%hhd\n", 4294967168LL, 127LL);
printf("Unsigned int\tMax:%u\n", 0xFFFFFFFFLL);
printf("Signed int\tMin:%u\tMax:%d\n", 0x80000000LL, 0x7FFFFFFFLL);
printf("Unsigned short\tMax:%hu\n", 0xFFFFLL);
printf("Signed short\tMin:%hd\tMax:%hd\n", 4294934528LL, 0x7FFFLL);
printf("Unsigned long\tMax:%lu\n", -1LL);
printf("Signed long\tMin:%ld\tMax:%ld\n", 0x8000000000000000LL, 0x7FFFFFFFFFFFFFFFLL);
printf("Unsigned long long\tMax:%llu\n", -1LL);
printf("Signed long long\tMin:%lld\tMax:%lld\n", 0x8000000000000000LL, 0x7FFFFFFFFFFFFFFFLL);
return printf("Float MIN:%E\tMAX:%E\n", *(double *)&LC16, *(double *)&LC15);
}

original_code:
void ex2_1(){
 printf("Unsigned char\tMax:%hhu\n",(0x7f * 2 + 1));
 printf("Signed char\tMin:%hhd\tMax:%hhd\n", (-0x7f - 1), 0x7f);
 printf("Unsigned int\tMax:%u\n", (0x7fffffff * 2U + 1U));
 printf("Signed int\tMin:%u\tMax:%d\n", (-0x7fffffff - 1), 0x7fffffff);
 printf("Unsigned short\tMax:%hu\n", (0x7fff * 2 + 1));
 printf("Signed short\tMin:%hd\tMax:%hd\n", (-0x7fff - 1), 0x7fff);
 printf("Unsigned long\tMax:%lu\n", (0x7fffffffffffffffL * 2UL + 1UL));
 printf("Signed long\tMin:%ld\tMax:%ld\n", (-0x7fffffffffffffffL - 1L), 0x7fffffffffffffffL);
 printf("Unsigned long long\tMax:%llu\n", (0x7fffffffffffffffLL * 2ULL + 1ULL));
 printf("Signed long long\tMin:%lld\tMax:%lld\n", (-0x7fffffffffffffffLL - 1LL), 0x7fffffffffffffffLL);
 printf("Float MIN:%E\tMAX:%E\n", 1.17549435082228750796873653722224568e-38F, 3.40282346638528859811704183484516925e+38F);
}


decompiled_code:
__int64 getcharch8()
{
__int64 result; // rax
char buf[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( read(0, buf, 1uLL) == 1 )
result = (unsigned __int8)buf[0];
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
char buf[9]; // [rsp+Fh] [rbp-9h] BYREF

if ( read(0, buf, 1uLL) == 1 )
result = (unsigned __int8)buf[0];
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int getcharch8(void){
  char c;
  return (read(0, &c, 1) == 1) ? (unsigned char) c : (-1);
}

canonical_original_code:
int getcharch8(){
  char c;
  return (read(0, &c, 1) == 1) ? (unsigned char) c : (-1);
}


inputtooutput

decompiled_code:
ssize_t inputtooutput()
{
ssize_t result; // rax
_BYTE v1[120]; // [rsp+0h] [rbp-78h] BYREF

while ( 1 )
{
result = read(0, v1, 0x64uLL);
if ( (int)result <= 0 )
break;
write(1, v1, (int)result);
}
return result;
}

canonical_decompiled_code:
ssize_t func1()
{
ssize_t result; // rax
_BYTE v1[120]; // [rsp+0h] [rbp-78h] BYREF

while ( 1 )
{
result = read(0, v1, 0x64uLL);
if ( (int)result <= 0 )
break;
write(1, v1, (int)result);
}
return result;
}

original_code:
void inputtooutput(void){
  char buffer[100];
  int n;
  while((n = read(0, buffer, 100)) > 0){
    write(1, buffer, n);
  }
}

canonical_original_code:
void inputtooutput(){
  char buffer[100];
  int n;
  while((n = read(0, buffer, 100)) > 0){
    write(1, buffer, n);
  }
}

variable_types:
buffer
char [100]

variable_types: n int


main

canonical_name: main

repo: JamesBirchall/sdltutorials

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
SDL_Init();
SDL_Quit();
return 0;
}

original_code:
int main(int argc, char **argv){
  SDL_Init( 0x0000FFFF );
  SDL_Quit();
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


repo: JamesDillon/C-Misc

original_code:
void bubble_sort(int numbers[], int elements)
{
   int k, i;
   for ( i = elements; i > 0; i--)
   {
      for (k = 1; k <= elements; k++)
      {
         if (numbers[k - 1] > numbers[k])
         {
            numbers[k - 1] ^= numbers[k];
            numbers[k] ^= numbers[k - 1];
            numbers[k - 1] ^= numbers[k];
         }
      }
   }
}

canonical_original_code:
void bubble_sort(int numbers[], int elements)
{
   int k; int i;
   for ( i = elements; i > 0; i--)
   {
      for (k = 1; k <= elements; k++)
      {
         if (numbers[k - 1] > numbers[k])
         {
            numbers[k - 1] ^= numbers[k];
            numbers[k] ^= numbers[k - 1];
            numbers[k - 1] ^= numbers[k];
         }
      }
   }
}

variable_types:
numbers
int []

variable_types: elements int

variable_types: k int


original_code:
int main(int argc, char *argv[])
{
   int numbers[] = { 4, 5, 3, 1, 6, 8, 23, 53, 2, 5 };
   int number_of_elements = 10;
   int i;
   bubble_sort(numbers, number_of_elements);
   for (i = 0; i <= 10; i++)
   {
      printf("%d\t", numbers[i]);
   }
   return 0;
}

variable_types:
argv
char *[]

variable_types: i int


sort

original_code:
int sort(int arr[], int size)
{
   int largestIndex = 0;
   int j;
   for (j = 1; j < size; j++)
   {
      if (arr[largestIndex] < arr[j])
      {
         largestIndex = j;
      }
   }
   return arr[largestIndex];
}

variable_types:
arr
int []

variable_types: size int

variable_types: largestIndex int

variable_types: j int


main

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

v5[0] = 1;
v5[1] = 5;
v5[2] = 7;
v5[3] = 3;
v5[4] = 5;
v3 = sort((__int64)v5, 5);
printf("The biggest is: %d\n", v3);
return 0;
}

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

v5[0] = 1;
v5[1] = 5;
v5[2] = 7;
v5[3] = 3;
v5[4] = 5;
v3 = func7((__int64)v5, 5);
printf("The biggest is: %d\n", v3);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
   int arr[5] = { 1, 5, 7, 3, 5};
   printf("The biggest is: %d\n", sort(arr, 5));
   return 0;
}

variable_types:
arr
int [5]


getfreeframe

repo: Japumba/Operativos

decompiled_code:
__int64 getfreeframe()
{
int v0; // edx
_DWORD *i; // rax

v0 = framesbegin;
if ( framesbegin >= systemframetablesize + framesbegin )
{
v0 = -1;
}
else
{
for ( i = (_DWORD *)(systemframetable + 24LL * framesbegin); *i; i += 6 )
{
if ( ++v0 == systemframetablesize + framesbegin )
return (unsigned int)-1;
}
*i = 1;
if ( systemframetablesize + framesbegin <= v0 )
v0 = -1;
else
*(_DWORD *)(systemframetable + 24LL * v0) = 1;
}
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // edx
_DWORD *i; // rax

v0 = framesbegin;
if ( framesbegin >= systemframetablesize + framesbegin )
{
v0 = -1;
}
else
{
for ( i = (_DWORD *)(systemframetable + 24LL * framesbegin); *i; i += 6 )
{
if ( ++v0 == systemframetablesize + framesbegin )
return (unsigned int)-1;
}
*i = 1;
if ( systemframetablesize + framesbegin <= v0 )
v0 = -1;
else
*(_DWORD *)(systemframetable + 24LL * v0) = 1;
}
return (unsigned int)v0;
}

original_code:
int getfreeframe()
{
    int i;
    for(i=framesbegin;i<systemframetablesize+framesbegin;i++)
        if(!systemframetable[i].assigned)
        {
            systemframetable[i].assigned=1;
            break;
        }
    if(i<systemframetablesize+framesbegin)
        systemframetable[i].assigned=1;
    else
        i=-1;
    return(i);
}


pagefault

decompiled_code:
__int64 __fastcall pagefault(int a1)
{
__int64 result; // rax
__int64 v2; // rcx

countframesassigned();
result = getfreeframe();
if ( (_DWORD)result != -1 )
{
v2 = 5LL * (a1 >> 12);
processpagetable[2 * v2] = 1;
processpagetable[2 * v2 + 2] = result;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
__int64 v2; // rcx

countframesassigned();
result = func0();
if ( (_DWORD)result != -1 )
{
v2 = 5LL * (a1 >> 12);
processpagetable[2 * v2] = 1;
processpagetable[2 * v2 + 2] = result;
result = 1LL;
}
return result;
}

original_code:
int pagefault(char *vaddress)
{
    int i;
    int frame;
    int pag_a_expulsar;
    int pag_del_proceso;
    pag_del_proceso=(int) vaddress>>12;
    i=countframesassigned();
    frame=getfreeframe();
    if(frame==-1)
    {
        return(-1);
    }
    processpagetable[pag_del_proceso].presente=1;
    processpagetable[pag_del_proceso].framenumber=frame;
    return(1);
}

variable_types:
vaddress
char *

variable_types: frame int


createsem

decompiled_code:
int __fastcall createsem(key_t a1)
{
return semget(a1, 1, 950);
}

canonical_decompiled_code:
int __fastcall func7(key_t a1)
{
return semget(a1, 1, 950);
}

original_code:
int createsem(key_t key)
{
 int semid;
 return semid = semget(key, 1, 0666 | 01000);
}

canonical_original_code:
int createsem(int key)
{
 int semid;
 return semid = semget(key, 1, 0666 | 01000);
}

variable_types: key int

variable_types: semid int


seminit

decompiled_code:
int __fastcall seminit(int a1, unsigned int a2)
{
return semctl(a1, 0, 16, a2);
}

canonical_decompiled_code:
int __fastcall func8(int a1, unsigned int a2)
{
return semctl(a1, 0, 16, a2);
}

original_code:
void seminit(int semid, int val)
{
 union semnum arg;
 arg.val = val;
 semctl(semid, 0, 16, arg);
}

variable_types: val int

variable_types: union semnum { int val; struct semid_ds { struct ipc_perm { int __key; unsigned int uid; unsigned int gid; unsigned int cuid; unsigned int cgid; unsigned short mode; unsigned short __pad1; unsigned short __seq; unsigned short __pad2; unsigned long __glibc_reserved1; unsigned long __glibc_reserved2; } sem_perm; long sem_otime; unsigned long __glibc_reserved1; long sem_ctime; unsigned long __glibc_reserved2; unsigned long sem_nsems; unsigned long __glibc_reserved3; unsigned long __glibc_reserved4; } *buf; unsigned short *array; }

user_defined_types: union semnum { int val; struct semid_ds *buf; unsigned short *array; }

user_defined_types: struct semid_ds { struct ipc_perm sem_perm; long sem_otime; unsigned long __glibc_reserved1; long sem_ctime; unsigned long __glibc_reserved2; unsigned long sem_nsems; unsigned long __glibc_reserved3; unsigned long __glibc_reserved4; }


semwait

decompiled_code:
int __fastcall semwait(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = 0;
sops.sem_op = -1;
sops.sem_flg = 4096;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func9(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = 0;
sops.sem_op = -1;
sops.sem_flg = 4096;
return semop(a1, &sops, 1uLL);
}

original_code:
void semwait(int semid)
{
 struct sembuf buf;
 buf.sem_num = 0;
 buf.sem_op = -1;
 buf.sem_flg = 0x1000;
 semop(semid, &buf, 1);
}

variable_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


semsignal

decompiled_code:
int __fastcall semsignal(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = 0;
sops.sem_op = 1;
sops.sem_flg = 6144;
return semop(a1, &sops, 1uLL);
}

canonical_decompiled_code:
int __fastcall func10(int a1)
{
struct sembuf sops; // [rsp+Ah] [rbp-Eh] BYREF

sops.sem_num = 0;
sops.sem_op = 1;
sops.sem_flg = 6144;
return semop(a1, &sops, 1uLL);
}

original_code:
void semsignal(int semid)
{
 struct sembuf buf;
 buf.sem_num = 0;
 buf.sem_op = 1;
 buf.sem_flg = 0x1000 | 04000;
 semop(semid, &buf, 1);
}

user_defined_types: struct sembuf { unsigned short sem_num; short sem_op; short sem_flg; }


proceso

decompiled_code:
void __fastcall __noreturn proceso(int a1)
{
int v1; // ebx
int v2; // eax
int v3; // eax

v1 = 10;
do
{
semwait(semid);
printf("Entra %s", (&pais)[a1]);
fflush(_bss_start);
v2 = rand();
sleep(v2 % 3);
printf("- %s Sale\n", (&pais)[a1]);
semsignal(semid);
v3 = rand();
sleep(v3 % 3);
--v1;
}
while ( v1 );
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func11(int a1)
{
int v1; // ebx
int v2; // eax
int v3; // eax

v1 = 10;
do
{
func9(semid);
printf("Entra %s", (&pais)[a1]);
fflush(_bss_start);
v2 = rand();
sleep(v2 % 3);
printf("- %s Sale\n", (&pais)[a1]);
func10(semid);
v3 = rand();
sleep(v3 % 3);
--v1;
}
while ( v1 );
exit(0);
}

original_code:
void proceso(int i)
{
 int k;
 int l;
 for(k=0;k<10;k++)
 {
  semwait(semid);
  printf("Entra %s",pais[i]);
  fflush(stdout);
  sleep(rand()%3);
  printf("- %s Sale\n",pais[i]);
  semsignal(semid);
  sleep(rand()%3);
 }
 exit(0);
}

variable_types: l int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // edi
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

semid = createsem(1234);
if ( semid == -1 )
perror("Couldn't create semaphore :(");
seminit(semid, 1u);
v3 = getpid();
srand(v3);
v4 = fork();
if ( !v4 )
LABEL_9:
proceso(v4);
if ( !fork() )
{
v4 = 1;
goto LABEL_9;
}
if ( !fork() )
{
v4 = 2;
goto LABEL_9;
}
wait((__WAIT_STATUS)&stat_loc);
wait((__WAIT_STATUS)&stat_loc);
wait((__WAIT_STATUS)&stat_loc);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // edi
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

semid = func7(1234);
if ( semid == -1 )
perror("Couldn't create semaphore :(");
func8(semid, 1u);
v3 = getpid();
srand(v3);
v4 = fork();
if ( !v4 )
LABEL_9:
func11(v4);
if ( !fork() )
{
v4 = 1;
goto LABEL_9;
}
if ( !fork() )
{
v4 = 2;
goto LABEL_9;
}
wait((__WAIT_STATUS)&stat_loc);
wait((__WAIT_STATUS)&stat_loc);
wait((__WAIT_STATUS)&stat_loc);
return 0;
}

original_code:
int main()
{
 int pid;
 int status;
 int args[3];
 int i;
 void *thread_result;
 key_t key = 1234;
 semid = createsem(key);
 if(semid == -1) perror("Couldn't create semaphore :(");
 seminit(semid, 1);
 srand(getpid());
 for(i=0;i<3;i++)
 {
  pid=fork();
  if(pid==0)
   proceso(i);
 }
 for(i=0;i<3;i++)
  pid = wait(&status);
}

canonical_original_code:
int main()
{
 int pid;
 int status;
 int args[3];
 int i;
 void *thread_result;
 int key = 1234;
 semid = createsem(key);
 if(semid == -1) perror("Couldn't create semaphore :(");
 seminit(semid, 1);
 srand(getpid());
 for(i=0;i<3;i++)
 {
  pid=fork();
  if(pid==0)
   proceso(i);
 }
 for(i=0;i<3;i++)
  pid = wait(&status);
}

variable_types: pid int

variable_types: status int

variable_types:
args
int [3]


execExit

decompiled_code:
void __noreturn execExit()
{
exit(0);
}

canonical_decompiled_code:
void __noreturn func7()
{
exit(0);
}

original_code:
void execExit()
{
 exit(0);
}

canonical_original_code:
void execExit()
{
 exit(0);
}


execShutdown

decompiled_code:
int execShutdown()
{
return kill(initID, 9);
}

canonical_decompiled_code:
int func8()
{
return kill(initID, 9);
}

original_code:
void execShutdown()
{
 kill(initID, 9);
}


execGeneric

decompiled_code:
__pid_t __fastcall execGeneric(const char ***a1)
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

if ( !fork() )
{
execvp(**a1, (char *const *)*a1);
puts("ERROR EXECUTING PROGRAM");
}
return wait((__WAIT_STATUS)&stat_loc);
}

canonical_decompiled_code:
__pid_t __fastcall func9(const char ***a1)
{
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-Ch] BYREF

if ( !fork() )
{
execvp(**a1, (char *const *)*a1);
puts("ERROR EXECUTING PROGRAM");
}
return wait((__WAIT_STATUS)&stat_loc);
}

original_code:
void execGeneric(COMMAND *cmd)
{
 int pid;
 int status;
 pid = fork();
 if(pid == 0)
 {
  execvp(cmd->argv[0],cmd->argv);
  printf("ERROR EXECUTING PROGRAM\n");
 }
 wait(&status);
}

canonical_original_code:
void execGeneric(struct COMMAND *cmd)
{
 int pid;
 int status;
 pid = fork();
 if(pid == 0)
 {
  execvp(cmd->argv[0],cmd->argv);
  printf("ERROR EXECUTING PROGRAM\n");
 }
 wait(&status);
}

variable_types: struct COMMAND { char **argv; int args; int type; } *


executeCommand

decompiled_code:
int __fastcall executeCommand(const char ***a1)
{
int v1; // eax
int result; // eax

puts("!!!ATTEMPTING TO EXECUTE COMMAND");
if ( !a1 )
return puts("!!CANNOT EXECUTE COMMAND, NULL COMMAND");
v1 = *((_DWORD *)a1 + 3);
if ( v1 == 2 )
{
puts("!!!EXECUTING SHUTDOWN COMMAND");
result = execShutdown();
}
else if ( v1 == 3 )
{
printf("!!!EXECUTING GENERIC COMMAND WITH NAME: %s AND %i ARGUMENTS.\n", **a1, *((unsigned int *)a1 + 2));
result = execGeneric(a1);
}
else
{
if ( v1 == 1 )
{
puts("!!!EXECUTING EXIT COMMAND");
execExit();
}
result = puts("!!!COULDNT EXECUTE COMMAND. INVALID TYPE");
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(const char ***a1)
{
int v1; // eax
int result; // eax

puts("!!!ATTEMPTING TO EXECUTE COMMAND");
if ( !a1 )
return puts("!!CANNOT EXECUTE COMMAND, NULL COMMAND");
v1 = *((_DWORD *)a1 + 3);
if ( v1 == 2 )
{
puts("!!!EXECUTING SHUTDOWN COMMAND");
result = func8();
}
else if ( v1 == 3 )
{
printf("!!!EXECUTING GENERIC COMMAND WITH NAME: %s AND %i ARGUMENTS.\n", **a1, *((unsigned int *)a1 + 2));
result = func9(a1);
}
else
{
if ( v1 == 1 )
{
puts("!!!EXECUTING EXIT COMMAND");
func7();
}
result = puts("!!!COULDNT EXECUTE COMMAND. INVALID TYPE");
}
return result;
}

original_code:
void executeCommand(COMMAND *cmd)
{
 printf("!!!ATTEMPTING TO EXECUTE COMMAND\n");
 if(cmd == ((void *)0))
 {
  printf("!!CANNOT EXECUTE COMMAND, NULL COMMAND\n");
  return;
 }
 int type = cmd->type;
 switch(type)
 {
  case 1:
   printf("!!!EXECUTING EXIT COMMAND\n");
   execExit();
   break;
  case 2:
   printf("!!!EXECUTING SHUTDOWN COMMAND\n");
   execShutdown();
   break;
  case 3:
   printf("!!!EXECUTING GENERIC COMMAND WITH NAME: %s AND %i ARGUMENTS.\n", cmd->argv[0], cmd->args);
   execGeneric(cmd);
   break;
  default:
   printf("!!!COULDNT EXECUTE COMMAND. INVALID TYPE\n");
   break;
 }
}

canonical_original_code:
void executeCommand(struct COMMAND *cmd)
{
 printf("!!!ATTEMPTING TO EXECUTE COMMAND\n");
 if(cmd == ((void *)0))
 {
  printf("!!CANNOT EXECUTE COMMAND, NULL COMMAND\n");
  return;
 }
 int type = cmd->type;
 switch(type)
 {
  case 1:
   printf("!!!EXECUTING EXIT COMMAND\n");
   execExit();
   break;
  case 2:
   printf("!!!EXECUTING SHUTDOWN COMMAND\n");
   execShutdown();
   break;
  case 3:
   printf("!!!EXECUTING GENERIC COMMAND WITH NAME: %s AND %i ARGUMENTS.\n", cmd->argv[0], cmd->args);
   execGeneric(cmd);
   break;
  default:
   printf("!!!COULDNT EXECUTE COMMAND. INVALID TYPE\n");
   break;
 }
}

variable_types: type int

user_defined_types: struct COMMAND { char **argv; int args; int type; }


destroyCommand

decompiled_code:
void __fastcall destroyCommand(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func11(void *ptr)
{
free(*(void **)ptr);
free(ptr);
}

original_code:
void destroyCommand(COMMAND *cmd)
{
 free(cmd->argv);
 free(cmd);
}

canonical_original_code:
void destroyCommand(struct COMMAND *cmd)
{
 free(cmd->argv);
 free(cmd);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
const char ***v4; // rbx
char v6[256]; // [rsp-108h] [rbp-108h] BYREF
__int64 v7; // [rsp-8h] [rbp-8h]

if ( argc > 1 )
{
v7 = v3;
initID = atoi(argv[1]);
while ( 1 )
{
printf("sh> ");
gets();
printf("!!!COMMAND: %s\n", v6);
v4 = (const char ***)parseInput(v6);
executeCommand(v4);
destroyCommand(v4);
}
}
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
const char ***v4; // rbx
char v6[256]; // [rsp-108h] [rbp-108h] BYREF
__int64 v7; // [rsp-8h] [rbp-8h]

if ( argc > 1 )
{
v7 = v3;
initID = atoi(argv[1]);
while ( 1 )
{
printf("sh> ");
gets();
printf("!!!COMMAND: %s\n", v6);
v4 = (const char ***)parseInput(v6);
func10(v4);
func11(v4);
}
}
return 1;
}

original_code:
int main(int argc, char *argv[])
{
 if(argc < 2)
  return 1;
 initID = atoi(argv[1]);
 char input[256];
 COMMAND *command = ((void *)0);
 int args = 0;
 while(1)
 {
  printf("sh> ");
  gets(input);
  printf("!!!COMMAND: %s\n", input);
  command = parseInput(input);
  executeCommand(command);
  destroyCommand(command);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 if(argc < 2)
  return 1;
 initID = atoi(argv[1]);
 char input[256];
 struct COMMAND *command = ((void *)0);
 int args = 0;
 while(1)
 {
  printf("sh> ");
  gets(input);
  printf("!!!COMMAND: %s\n", input);
  command = parseInput(input);
  executeCommand(command);
  destroyCommand(command);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
input
char [256]

variable_types: args int


takeItem

decompiled_code:
int takeItem()
{
int v0; // eax
int sval[3]; // [rsp+Ch] [rbp-Ch] BYREF

sem_getvalue(&notEmpty, sval);
v0 = pthread_self();
return printf("<<<ITEM TAKEN by %i, [%i] items in buffer\n", (unsigned int)(v0 % 100), (unsigned int)sval[0]);
}

canonical_decompiled_code:
int func7()
{
int v0; // eax
int sval[3]; // [rsp+Ch] [rbp-Ch] BYREF

sem_getvalue(&notEmpty, sval);
v0 = pthread_self();
return printf("<<<ITEM TAKEN by %i, [%i] items in buffer\n", (unsigned int)(v0 % 100), (unsigned int)sval[0]);
}

original_code:
void takeItem()
{
 int i;
 sem_getvalue(&notEmpty, &i);
 printf("<<<ITEM TAKEN by %i, [%i] items in buffer\n", (((int)pthread_self())%100), i);
}

variable_types: i int


consumerRoutine

decompiled_code:
void __fastcall __noreturn consumerRoutine(void *a1)
{
int v1; // eax

while ( 1 )
{
v1 = rand();
sleep(v1 % 3 + 1);
sem_wait(&notEmpty);
sem_wait(&consumerMutex);
takeItem();
sem_post(&consumerMutex);
sem_post(&notFull);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
int v1; // eax

while ( 1 )
{
v1 = rand();
sleep(v1 % 3 + 1);
sem_wait(&notEmpty);
sem_wait(&consumerMutex);
func7();
sem_post(&consumerMutex);
sem_post(&notFull);
}
}

original_code:
void *consumerRoutine(void *arg)
{
 while(1)
 {
  sleep(rand() %3 + 1);
  sem_wait(&notEmpty);
  sem_wait(&consumerMutex);
  takeItem();
  sem_post(&consumerMutex);
  sem_post(&notFull);
 }
}

variable_types:
arg
void *

return_type: void *


placeItem

decompiled_code:
int placeItem()
{
int v0; // eax
int sval[3]; // [rsp+Ch] [rbp-Ch] BYREF

sem_getvalue(&notEmpty, sval);
v0 = pthread_self();
return printf(">>>ITEM PLACED by %i, [%i] items in buffer\n", (unsigned int)(v0 % 100), (unsigned int)(sval[0] + 1));
}

canonical_decompiled_code:
int func9()
{
int v0; // eax
int sval[3]; // [rsp+Ch] [rbp-Ch] BYREF

sem_getvalue(&notEmpty, sval);
v0 = pthread_self();
return printf(">>>ITEM PLACED by %i, [%i] items in buffer\n", (unsigned int)(v0 % 100), (unsigned int)(sval[0] + 1));
}

original_code:
void placeItem()
{
 int i;
 sem_getvalue(&notEmpty, &i);
 printf(">>>ITEM PLACED by %i, [%i] items in buffer\n", (((int)pthread_self())%100), i+1);
}


producerRoutine

decompiled_code:
void __fastcall __noreturn producerRoutine(void *a1)
{
int v1; // eax

while ( 1 )
{
v1 = rand();
sleep(v1 % 3 + 1);
sem_wait(&notFull);
sem_wait(&producerMutex);
placeItem();
sem_post(&producerMutex);
sem_post(&notEmpty);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func10(void *a1)
{
int v1; // eax

while ( 1 )
{
v1 = rand();
sleep(v1 % 3 + 1);
sem_wait(&notFull);
sem_wait(&producerMutex);
func9();
sem_post(&producerMutex);
sem_post(&notEmpty);
}
}

original_code:
void *producerRoutine(void *arg)
{
 while(1)
 {
  sleep(rand() %3 + 1);
  sem_wait(&notFull);
  sem_wait(&producerMutex);
  placeItem();
  sem_post(&producerMutex);
  sem_post(&notEmpty);
 }
}


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int i; // eax
int j; // eax
int sval[3]; // [rsp+Ch] [rbp-Ch] BYREF

sem_init(&notEmpty, 0, 0);
sem_init(&notFull, 0, 5u);
sem_init(&producerMutex, 0, 1u);
sem_init(&consumerMutex, 0, 1u);
sem_getvalue(&notFull, sval);
printf("SEM VALUE: %i\n", (unsigned int)sval[0]);
sval[0] = 0;
for ( i = 0; i <= 1; sval[0] = i )
{
pthread_create(&producer + i, 0LL, (void *(*)(void *))producerRoutine, sval);
i = sval[0] + 1;
}
sval[0] = 0;
for ( j = 0; j <= 0; sval[0] = j )
{
pthread_create(&consumer + j, 0LL, (void *(*)(void *))consumerRoutine, sval);
j = sval[0] + 1;
}
while ( 1 )
;
}

original_code:
int main(int argc, char *args[])
{
 int i;
 sem_init(&notEmpty, 0, 0);
 sem_init(&notFull, 0, 5);
 sem_init(&producerMutex, 0, 1);
 sem_init(&consumerMutex, 0, 1);
 sem_getvalue(&notFull,&i);
 printf("SEM VALUE: %i\n", i);
 for(i = 0; i < 2; i++)
  pthread_create(&producer[i], ((void *)0), producerRoutine, &i);
 for(i = 0; i < 1; i++)
  pthread_create(&consumer[i], ((void *)0), consumerRoutine, &i);
 while(1);
 return 0;
}

variable_types:
args
char *[]


blackandwhite

decompiled_code:
__int64 __fastcall blackandwhite(int a1)
{
return (unsigned int)(int)((double)BYTE2(a1) * 0.11 + (double)(unsigned __int8)a1 * 0.3 + (double)BYTE1(a1) * 0.59);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
return (unsigned int)(int)((double)BYTE2(a1) * 0.11 + (double)(unsigned __int8)a1 * 0.3 + (double)BYTE1(a1) * 0.59);
}

original_code:
unsigned char blackandwhite(PIXEL p)
{
 return((unsigned char) (0.3*((float)p.red)+
 0.59*((float)p.green)+0.11*((float)p.blue)));
}

canonical_original_code:
unsigned char blackandwhite(struct PIXEL p)
{
 return((unsigned char) (0.3*((float)p.red)+
 0.59*((float)p.green)+0.11*((float)p.blue)));
}

variable_types: struct PIXEL { unsigned char red; unsigned char green; unsigned char blue; }

return_type: unsigned char


processBMP

original_code:
void *processBMP(void *arg)
{
 int i,j;
 int count=0;
 PIXEL *pfte,*pdst;
 PIXEL *v0,*v1,*v2,*v3,*v4,*v5,*v6,*v7;
 int imageRows,imageCols;
 int numThread = *(int *)arg;
 imageRows = (&imagenfte)->infoheader.rows;
 imageCols = (&imagenfte)->infoheader.cols;
 for(i=1+numThread;i<imageRows-1;i+=8)
  for(j=1;j<imageCols-1;j++)
  {
  pfte=(&imagenfte)->pixel+imageCols*i+j;
  v0=pfte-imageCols-1;
  v1=pfte-imageCols;
  v2=pfte-imageCols+1;
  v3=pfte-1;
  v4=pfte+1;
  v5=pfte+imageCols-1;
  v6=pfte+imageCols;
  v7=pfte+imageCols+1;
  pdst=(&imagendst)->pixel+imageCols*i+j;
  if(abs(blackandwhite(*pfte)-blackandwhite(*v0))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v1))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v2))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v3))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v4))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v5))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v6))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v7))>16)
  {
  pdst->red=0;
  pdst->green=0;
  pdst->blue=0;
  }
  else
  {
  pdst->red=255;
  pdst->green=255;
  pdst->blue=255;
  }
 }
}

canonical_original_code:
void *processBMP(void *arg)
{
 int i; int j;
 int count = 0;
 struct PIXEL *pfte; struct PIXEL *pdst;
 struct PIXEL *v0; struct PIXEL *v1; struct PIXEL *v2; struct PIXEL *v3; struct PIXEL *v4; struct PIXEL *v5; struct PIXEL *v6; struct PIXEL *v7;
 int imageRows; int imageCols;
 int numThread = *(int *)arg;
 imageRows = (&imagenfte)->infoheader.rows;
 imageCols = (&imagenfte)->infoheader.cols;
 for(i=1+numThread;i<imageRows-1;i+=8)
  for(j=1;j<imageCols-1;j++)
  {
  pfte=(&imagenfte)->pixel+imageCols*i+j;
  v0=pfte-imageCols-1;
  v1=pfte-imageCols;
  v2=pfte-imageCols+1;
  v3=pfte-1;
  v4=pfte+1;
  v5=pfte+imageCols-1;
  v6=pfte+imageCols;
  v7=pfte+imageCols+1;
  pdst=(&imagendst)->pixel+imageCols*i+j;
  if(abs(blackandwhite(*pfte)-blackandwhite(*v0))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v1))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v2))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v3))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v4))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v5))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v6))>16 ||
   abs(blackandwhite(*pfte)-blackandwhite(*v7))>16)
  {
  pdst->red=0;
  pdst->green=0;
  pdst->blue=0;
  }
  else
  {
  pdst->red=255;
  pdst->green=255;
  pdst->blue=255;
  }
 }
}

variable_types: j int

variable_types: count int

variable_types: struct PIXEL { unsigned char red; unsigned char green; unsigned char blue; } *

variable_types: imageRows int

variable_types: imageCols int

variable_types: numThread int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char *v4; // rax
size_t v5; // rax
char *v6; // rbp
__int64 i; // rbx
__pid_t *v8; // rbx
int v9; // eax
int v11[8]; // [rsp+0h] [rbp-98h] BYREF
char v12; // [rsp+20h] [rbp-78h] BYREF
int stat_loc; // [rsp+2Ch] [rbp-6Ch] BYREF
char dest[104]; // [rsp+30h] [rbp-68h] BYREF

v3 = clock();
v4 = strtok(filename, ".");
strcpy(dest, v4);
v5 = strlen(filename);
*(_DWORD *)&filename[v5] = 1886216750;
*(_BYTE *)(v5 + 4210836) = 0;
strcpy(&dest[strlen(dest)], "_P.bmp");
printf("Archivo fuente %s\n", filename);
printf("Archivo destino %s\n", dest);
if ( loadBMP(filename, &imagenfte) == -1 )
{
fwrite("Error al abrir imagen\n", 1uLL, 0x16uLL, stderr);
exit(1);
}
printf(
"Procesando imagen de: Renglones = %d, Columnas = %d\n",
(unsigned int)dword_404118,
(unsigned int)dword_404114);
printf("Paralelizando usando %i threads\n", 8LL);
threadID = (__int64)malloc(0x20uLL);
imagendst = (__int128)_mm_load_si128((const __m128i *)&imagenfte);
xmmword_4040D0 = (__int128)_mm_load_si128((const __m128i *)&unk_404110);
xmmword_4040E0 = (__int128)_mm_load_si128((const __m128i *)&xmmword_404120);
qword_4040F0 = qword_404130;
stat_loc = 0;
qword_4040F8 = (__int64)malloc(3 * dword_404114 * (__int64)dword_404118);
v6 = (char *)malloc(0x2625A00uLL) + 5000000;
for ( i = 0LL; i != 8; ++i )
{
*(_DWORD *)(threadID + 4 * i) = i;
v11[i] = clone((int (*)(void *))processBMP, v6, 1792, (void *)(threadID + 4 * i));
v6 += 5000000;
}
v8 = v11;
do
waitpid(*v8++, &stat_loc, 0x40000000);
while ( v8 != (__pid_t *)&v12 );
if ( saveBMP(dest, &imagendst) == -1 )
{
fwrite("Error al escribir imagen\n", 1uLL, 0x19uLL, stderr);
exit(1);
}
v9 = clock();
printf("Tiempo %3.6f segundos\n", (float)((float)((float)v9 - (float)v3) / 1000000.0));
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char *v4; // rax
size_t v5; // rax
char *v6; // rbp
__int64 i; // rbx
__pid_t *v8; // rbx
int v9; // eax
int v11[8]; // [rsp+0h] [rbp-98h] BYREF
char v12; // [rsp+20h] [rbp-78h] BYREF
int stat_loc; // [rsp+2Ch] [rbp-6Ch] BYREF
char dest[104]; // [rsp+30h] [rbp-68h] BYREF

v3 = clock();
v4 = strtok(filename, ".");
strcpy(dest, v4);
v5 = strlen(filename);
*(_DWORD *)&filename[v5] = 1886216750;
*(_BYTE *)(v5 + 4210836) = 0;
strcpy(&dest[strlen(dest)], "_P.bmp");
printf("Archivo fuente %s\n", filename);
printf("Archivo destino %s\n", dest);
if ( func7(filename, &imagenfte) == -1 )
{
fwrite("Error al abrir imagen\n", 1uLL, 0x16uLL, stderr);
exit(1);
}
printf(
"Procesando imagen de: Renglones = %d, Columnas = %d\n",
(unsigned int)dword_404118,
(unsigned int)dword_404114);
printf("Paralelizando usando %i threads\n", 8LL);
threadID = (__int64)malloc(0x20uLL);
imagendst = (__int128)_mm_load_si128((const __m128i *)&imagenfte);
xmmword_4040D0 = (__int128)_mm_load_si128((const __m128i *)&unk_404110);
xmmword_4040E0 = (__int128)_mm_load_si128((const __m128i *)&xmmword_404120);
qword_4040F0 = qword_404130;
stat_loc = 0;
qword_4040F8 = (__int64)malloc(3 * dword_404114 * (__int64)dword_404118);
v6 = (char *)malloc(0x2625A00uLL) + 5000000;
for ( i = 0LL; i != 8; ++i )
{
*(_DWORD *)(threadID + 4 * i) = i;
v11[i] = clone((int (*)(void *))processBMP, v6, 1792, (void *)(threadID + 4 * i));
v6 += 5000000;
}
v8 = v11;
do
waitpid(*v8++, &stat_loc, 0x40000000);
while ( v8 != (__pid_t *)&v12 );
if ( func8(dest, &imagendst) == -1 )
{
fwrite("Error al escribir imagen\n", 1uLL, 0x19uLL, stderr);
exit(1);
}
v9 = clock();
printf("Tiempo %3.6f segundos\n", (float)((float)((float)v9 - (float)v3) / 1000000.0));
return 0;
}

original_code:
int main()
{
 int res, i, j;
 clock_t t_inicial,t_final;
 char namedest[80];
 t_inicial=clock();
 strcpy(namedest,strtok(filename,"."));
 strcat(filename,".bmp");
 strcat(namedest,"_P.bmp");
 printf("Archivo fuente %s\n",filename);
 printf("Archivo destino %s\n",namedest);
 res=loadBMP(filename,&imagenfte);
 if(res==-1)
 {
  fprintf(stderr,"Error al abrir imagen\n");
  exit(1);
 }
 printf("Procesando imagen de: Renglones = %d, Columnas = %d\n",imagenfte.infoheader.rows,imagenfte.infoheader.cols);
 printf("Paralelizando usando %i threads\n", 8);
 threadID = (int *) malloc(sizeof(int)*8);
 memcpy(&imagendst, &imagenfte, sizeof(IMAGE)-sizeof(PIXEL *));
 int imageRows = (&imagenfte)->infoheader.rows;
 int imageCols = (&imagenfte)->infoheader.cols;
 int status=0;
 (&imagendst)->pixel=(PIXEL *)malloc(sizeof(PIXEL)*imageRows*imageCols);
 int pids[8];
 char *stack;
 stack = malloc(5000000*8);
 for(i=1;i<8 +1;i++)
 {
  threadID[i-1] = i-1;
  pids[i-1] = clone(processBMP,stack + 5000000*i,0x00000200|0x00000400|0x00000100,(void*)&threadID[i-1]);
 }
 for(j=0;j<8;j++)
 {
  waitpid(pids[j], &status, 0x40000000);
 }
 res=saveBMP(namedest,&imagendst);
 if(res==-1)
 {
  fprintf(stderr,"Error al escribir imagen\n");
  exit(1);
 }
 t_final=clock();
 printf("Tiempo %3.6f segundos\n",((float) t_final- (float)t_inicial)/((__clock_t) 1000000));
}

canonical_original_code:
int main()
{
 int res; int i; int j;
 long t_inicial; long t_final;
 char namedest[80];
 t_inicial=clock();
 strcpy(namedest,strtok(filename,"."));
 strcat(filename,".bmp");
 strcat(namedest,"_P.bmp");
 printf("Archivo fuente %s\n",filename);
 printf("Archivo destino %s\n",namedest);
 res=loadBMP(filename,&imagenfte);
 if(res==-1)
 {
  fprintf(stderr,"Error al abrir imagen\n");
  exit(1);
 }
 printf("Procesando imagen de: Renglones = %d, Columnas = %d\n",imagenfte.infoheader.rows,imagenfte.infoheader.cols);
 printf("Paralelizando usando %i threads\n", 8);
 threadID = (int *) malloc(sizeof(int)*8);
 memcpy(&imagendst, &imagenfte, sizeof(IMAGE)-sizeof(struct PIXEL *));
 int imageRows = (&imagenfte)->infoheader.rows;
 int imageCols = (&imagenfte)->infoheader.cols;
 int status = 0;
 (&imagendst)->pixel=(struct PIXEL *)malloc(sizeof(PIXEL)*imageRows*imageCols);
 int pids[8];
 char *stack;
 stack = malloc(5000000*8);
 for(i=1;i<8 +1;i++)
 {
  threadID[i-1] = i-1;
  pids[i-1] = clone(processBMP,stack + 5000000*i,0x00000200|0x00000400|0x00000100,(void *)&threadID[i-1]);
 }
 for(j=0;j<8;j++)
 {
  waitpid(pids[j], &status, 0x40000000);
 }
 res=saveBMP(namedest,&imagendst);
 if(res==-1)
 {
  fprintf(stderr,"Error al escribir imagen\n");
  exit(1);
 }
 t_final=clock();
 printf("Tiempo %3.6f segundos\n",((float) t_final- (float)t_inicial)/((long) 1000000));
}

variable_types: res int

variable_types:
namedest
char [80]

variable_types: status int

variable_types:
pids
int [8]

variable_types:
stack
char *

user_defined_types: struct PIXEL { unsigned char red; unsigned char green; unsigned char blue; }


ctrlC

repo: JavaIsBad/SyncThread

decompiled_code:
void ctrlC()
{
fini = 1;
}

canonical_decompiled_code:
void func0()
{
fini = 1;
}

original_code:
void ctrlC(int signum){
    fini=0==0;
}

canonical_original_code:
void ctrlC(int signum){
    fini=0==0;
}

variable_types: signum int


erreur

decompiled_code:
void __fastcall __noreturn erreur(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
static inline void erreur(const char* err){
    perror(err);
    exit(1);
}

canonical_original_code:
static inline void erreur(char *err){
    perror(err);
    exit(1);
}

variable_types:
err
char *


randouze

decompiled_code:
__int64 __fastcall randouze(unsigned int *a1)
{
return (unsigned int)(int)(float)((float)((float)rand_r(a1) * 4.6566129e-10) * 255.0);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1)
{
return (unsigned int)(int)(float)((float)((float)rand_r(a1) * 4.6566129e-10) * 255.0);
}

original_code:
int randouze(unsigned int *seed){
    return (int) (((float)rand_r(seed)/2147483647)*255);
}

variable_types:
seed
unsigned int *


ajoutbuff

decompiled_code:
int __fastcall ajoutbuff(int a1)
{
int v1; // edx

sem_wait(&ecriture);
sem_wait(&AccesDenied);
v1 = finBuff;
buff[finBuff] = a1;
finBuff = (v1 + 1) % 0xAu;
sem_post(&AccesDenied);
return sem_post(&lecture);
}

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

sem_wait(&ecriture);
sem_wait(&AccesDenied);
v1 = finBuff;
buff[finBuff] = a1;
finBuff = (v1 + 1) % 0xAu;
sem_post(&AccesDenied);
return sem_post(&lecture);
}

original_code:
void ajoutbuff(int nbr){
    sem_wait(&ecriture);
    sem_wait(&AccesDenied);
    buff[finBuff]=nbr;
    finBuff=(finBuff+1)%10;
    sem_post(&AccesDenied);
    sem_post(&lecture);
}

variable_types: nbr int


retirerbuff

decompiled_code:
__int64 retirerbuff()
{
__int64 v0; // rbx

sem_wait(&lecture);
sem_wait(&AccesDenied2);
v0 = buff[debutBuff];
if ( (_DWORD)v0 == -1 )
sem_post(&lecture);
else
debutBuff = (debutBuff + 1) % 0xAu;
sem_post(&AccesDenied2);
sem_post(&ecriture);
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx

sem_wait(&lecture);
sem_wait(&AccesDenied2);
v0 = buff[debutBuff];
if ( (_DWORD)v0 == -1 )
sem_post(&lecture);
else
debutBuff = (debutBuff + 1) % 0xAu;
sem_post(&AccesDenied2);
sem_post(&ecriture);
return (unsigned int)v0;
}

original_code:
int retirerbuff(){
    int nbr;
    sem_wait(&lecture);
    sem_wait(&AccesDenied2);
    nbr=buff[debutBuff];
    if(nbr!=-1)
        debutBuff=(debutBuff+1)%10;
    else
        sem_post(&lecture);
    sem_post(&AccesDenied2);
    sem_post(&ecriture);
    return nbr;
}


setHandler

decompiled_code:
int __fastcall setHandler(void (*a1)(int), int a2)
{
int result; // eax
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v3.sa_handler = a1;
v3.sa_flags = 0;
result = sigfillset(&v3.sa_mask);
if ( !result )
result = sigaction(a2, &v3, 0LL);
return result;
}

canonical_decompiled_code:
int __fastcall func5(void (*a1)(int), int a2)
{
int result; // eax
struct sigaction v3; // [rsp+0h] [rbp-A8h] BYREF

v3.sa_handler = a1;
v3.sa_flags = 0;
result = sigfillset(&v3.sa_mask);
if ( !result )
result = sigaction(a2, &v3, 0LL);
return result;
}

original_code:
int setHandler(void (*handler)(int), int signum){
    struct sigaction s;
    int retfunct;
    s.__sigaction_handler.sa_handler=handler;
    s.sa_flags=0;
    retfunct=sigfillset(&s.sa_mask);
    if(retfunct==0)
        retfunct=sigaction(signum, &s, ((void *)0));
    return retfunct;
}

variable_types:
handler
void (*)(int)

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

variable_types: retfunct int

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
int v4; // ebp
int v5; // ebp
int v6; // ebp
int v7; // ebp
char *v8; // r14
void *v9; // rax
void *v10; // r15
pthread_t *v11; // rbx
pthread_t *v12; // rbx
pthread_t *v13; // rbx
__int64 v14; // r12
unsigned int v15; // ebp
__int64 v16; // rbx
__int64 v17; // r14
unsigned int v18; // er13
int v19; // ebx
int v20; // ebx
int v21; // ebx
int v23; // [rsp+8h] [rbp-50h]
int v24; // [rsp+Ch] [rbp-4Ch]
void *thread_return[8]; // [rsp+18h] [rbp-40h] BYREF

if ( setHandler((void (*)(int))ctrlC, 2) )
erreur("Impossible de creer le handler pour ^C");
if ( argc != 3 )
{
fprintf(
stderr,
"Utilisation : %s nbr_producteurs nbr_consommateurs\n0<=nbr_producteurs et 1<=nbr_consommateurs",
*argv);
exit(1);
}
v3 = atoi(argv[1]);
v24 = v3;
v23 = atoi(argv[2]);
if ( v23 <= 0 || v3 < 0 )
{
*_errno_location() = 22;
erreur("Le nombre de consommateurs doit etre d'au moins 1 et il doit y avoir au minimum 0 producteurs");
}
v4 = sem_init(&AccesDenied, 0, 1u);
v5 = sem_init(&AccesDenied2, 0, 1u) + v4;
v6 = sem_init(&lecture, 0, 0) + v5;
v7 = sem_init(&ecriture, 0, 0xAu) + v6;
if ( v7 )
erreur("sem_init");
v8 = (char *)malloc(8LL * v3);
v9 = malloc(8LL * v23);
v10 = v9;
if ( !v8 || !v9 )
{
perror("malloc");
if ( v8 )
free(v8);
if ( v10 )
free(v10);
exit(1);
}
if ( v24 > 0 )
{
v11 = (pthread_t *)v8;
do
{
if ( pthread_create(v11, 0LL, (void *(*)(void *))producteur, 0LL) )
erreur("pthread_create");
++v11;
}
while ( v11 != (pthread_t *)&v8[8 * v24] );
}
v12 = (pthread_t *)v10;
do
{
if ( pthread_create(v12, 0LL, (void *(*)(void *))consommateur, 0LL) )
erreur("pthread_create");
++v7;
++v12;
}
while ( v23 > v7 );
if ( v24 <= 0 )
{
v14 = 0LL;
v15 = 0;
}
else
{
v13 = (pthread_t *)v8;
v14 = 0LL;
v15 = 0;
do
{
if ( pthread_join(*v13, thread_return) )
erreur("pthread_join");
v15 += *(_DWORD *)thread_return[0];
v14 += *((_QWORD *)thread_return[0] + 1);
free(thread_return[0]);
++v13;
}
while ( &v8[8 * v24] != (char *)v13 );
}
puts("\nFin prod");
free(v8);
ajoutbuff(-1);
v16 = 0LL;
v17 = 0LL;
v18 = 0;
do
{
if ( pthread_join(*((_QWORD *)v10 + v16), thread_return) )
erreur("pthread_join");
v18 += *(_DWORD *)thread_return[0];
v17 += *((_QWORD *)thread_return[0] + 1);
free(thread_return[0]);
++v16;
}
while ( v23 > (int)v16 );
puts("Fin conso");
free(v10);
v19 = sem_destroy(&AccesDenied);
v20 = sem_destroy(&AccesDenied2) + v19;
v21 = sem_destroy(&lecture) + v20;
if ( sem_destroy(&ecriture) + v21 )
erreur("sem_destroy");
printf(format, (unsigned int)v24, v15, v14, (unsigned int)v23, v18, v17);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er15
int v4; // ebp
int v5; // ebp
int v6; // ebp
int v7; // ebp
char *v8; // r14
void *v9; // rax
void *v10; // r15
pthread_t *v11; // rbx
pthread_t *v12; // rbx
pthread_t *v13; // rbx
__int64 v14; // r12
unsigned int v15; // ebp
__int64 v16; // rbx
__int64 v17; // r14
unsigned int v18; // er13
int v19; // ebx
int v20; // ebx
int v21; // ebx
int v23; // [rsp+8h] [rbp-50h]
int v24; // [rsp+Ch] [rbp-4Ch]
void *thread_return[8]; // [rsp+18h] [rbp-40h] BYREF

if ( func5((void (*)(int))ctrlC, 2) )
func1("Impossible de creer le handler pour ^C");
if ( argc != 3 )
{
fprintf(
stderr,
"Utilisation : %s nbr_producteurs nbr_consommateurs\n0<=nbr_producteurs et 1<=nbr_consommateurs",
*argv);
exit(1);
}
v3 = atoi(argv[1]);
v24 = v3;
v23 = atoi(argv[2]);
if ( v23 <= 0 || v3 < 0 )
{
*_errno_location() = 22;
func1("Le nombre de consommateurs doit etre d'au moins 1 et il doit y avoir au minimum 0 producteurs");
}
v4 = sem_init(&AccesDenied, 0, 1u);
v5 = sem_init(&AccesDenied2, 0, 1u) + v4;
v6 = sem_init(&lecture, 0, 0) + v5;
v7 = sem_init(&ecriture, 0, 0xAu) + v6;
if ( v7 )
func1("sem_init");
v8 = (char *)malloc(8LL * v3);
v9 = malloc(8LL * v23);
v10 = v9;
if ( !v8 || !v9 )
{
perror("malloc");
if ( v8 )
free(v8);
if ( v10 )
free(v10);
exit(1);
}
if ( v24 > 0 )
{
v11 = (pthread_t *)v8;
do
{
if ( pthread_create(v11, 0LL, (void *(*)(void *))producteur, 0LL) )
func1("pthread_create");
++v11;
}
while ( v11 != (pthread_t *)&v8[8 * v24] );
}
v12 = (pthread_t *)v10;
do
{
if ( pthread_create(v12, 0LL, (void *(*)(void *))consommateur, 0LL) )
func1("pthread_create");
++v7;
++v12;
}
while ( v23 > v7 );
if ( v24 <= 0 )
{
v14 = 0LL;
v15 = 0;
}
else
{
v13 = (pthread_t *)v8;
v14 = 0LL;
v15 = 0;
do
{
if ( pthread_join(*v13, thread_return) )
func1("pthread_join");
v15 += *(_DWORD *)thread_return[0];
v14 += *((_QWORD *)thread_return[0] + 1);
free(thread_return[0]);
++v13;
}
while ( &v8[8 * v24] != (char *)v13 );
}
puts("\nFin prod");
free(v8);
func3(-1);
v16 = 0LL;
v17 = 0LL;
v18 = 0;
do
{
if ( pthread_join(*((_QWORD *)v10 + v16), thread_return) )
func1("pthread_join");
v18 += *(_DWORD *)thread_return[0];
v17 += *((_QWORD *)thread_return[0] + 1);
free(thread_return[0]);
++v16;
}
while ( v23 > (int)v16 );
puts("Fin conso");
free(v10);
v19 = sem_destroy(&AccesDenied);
v20 = sem_destroy(&AccesDenied2) + v19;
v21 = sem_destroy(&lecture) + v20;
if ( sem_destroy(&ecriture) + v21 )
func1("sem_destroy");
printf(format, (unsigned int)v24, v15, v14, (unsigned int)v23, v18, v17);
return 0;
}

original_code:
int main (int argc, char ** argv){
    int nbprod=0, nbconso=0;
    unsigned int prodAproduit=0, consoAmanger=0;
    unsigned long int sommeProd=0, sommeMiam=0;
    int i, retval;
    struct nblu_somme *lu;
    pthread_t *prod, *conso;
    retval=setHandler(ctrlC, 2);
    if(retval!=0)
        erreur("Impossible de creer le handler pour ^C");
    if(argc != 3){
        fprintf(stderr,"Utilisation : %s nbr_producteurs nbr_consommateurs\n0<=nbr_producteurs et 1<=nbr_consommateurs",argv[0]);
        exit(1);
    }
    nbprod=atoi(argv[1]);
    nbconso=atoi(argv[2]);
    if(nbconso==0 || nbconso<0 || nbprod<0){
        (*__errno_location ())=22;
        erreur("Le nombre de consommateurs doit etre d'au moins 1 et il doit y avoir au minimum 0 producteurs");
    }
    retval=sem_init(&AccesDenied, 0, 1);
    retval+=sem_init(&AccesDenied2, 0, 1);
    retval+=sem_init(&lecture, 0, 0);
    retval+=sem_init(&ecriture, 0, 10);
    if(retval!=0)
        erreur("sem_init");
    prod=(pthread_t *) malloc(nbprod*sizeof(pthread_t));
    conso=(pthread_t *) malloc(nbconso*sizeof(pthread_t));
    if(prod==((void *)0) || conso==((void *)0)){
        perror("malloc");
        if(prod!=((void *)0))
            free(prod);
        if(conso!=((void *)0))
            free(conso);
        exit(1);
    }
    for(i=0; i<nbprod; i++){
        retval=pthread_create(&prod[i], ((void *)0), producteur, ((void *)0));
        if(retval!=0)
            erreur("pthread_create");
    }
    for(i=0; i<nbconso; i++){
        retval=pthread_create(&conso[i], ((void *)0), consommateur, ((void *)0));
        if(retval!=0)
            erreur("pthread_create");
    }
    for(i=0; i<nbprod; i++){
        retval=pthread_join(prod[i], (void**) &lu);
        if(retval!=0)
            erreur("pthread_join");
        prodAproduit+=lu->nblu;
        sommeProd+=lu->total;
        free(lu);
    }
    printf("\nFin prod\n");
    free(prod);
    ajoutbuff(-1);
    for(i=0; i<nbconso; i++){
        retval=pthread_join(conso[i], (void**) &lu);
        if(retval!=0)
            erreur("pthread_join");
        consoAmanger+=lu->nblu;
        sommeMiam+=lu->total;
        free(lu);
    }
    printf("Fin conso\n");
    free(conso);
    retval=sem_destroy(&AccesDenied);
    retval+=sem_destroy(&AccesDenied2);
    retval+=sem_destroy(&lecture);
    retval+=sem_destroy(&ecriture);
    if(retval!=0)
        erreur("sem_destroy");
    printf("Les %d producteurs ont produit %d            valeurs pour une somme de %ld.\n            Les %d consommateurs ont consommés %d            valeurs pour une somme de %ld.\n",
            nbprod, prodAproduit, sommeProd,
            nbconso, consoAmanger, sommeMiam);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv){
    int nbprod = 0; int nbconso = 0;
    unsigned int prodAproduit = 0; unsigned int consoAmanger = 0;
    unsigned long sommeProd = 0; unsigned long sommeMiam = 0;
    int i; int retval;
    struct nblu_somme *lu;
    unsigned long *prod; unsigned long *conso;
    retval=setHandler(ctrlC, 2);
    if(retval!=0)
        erreur("Impossible de creer le handler pour ^C");
    if(argc != 3){
        fprintf(stderr,"Utilisation : %s nbr_producteurs nbr_consommateurs\n0<=nbr_producteurs et 1<=nbr_consommateurs",argv[0]);
        exit(1);
    }
    nbprod=atoi(argv[1]);
    nbconso=atoi(argv[2]);
    if(nbconso==0 || nbconso<0 || nbprod<0){
        (*__errno_location ())=22;
        erreur("Le nombre de consommateurs doit etre d'au moins 1 et il doit y avoir au minimum 0 producteurs");
    }
    retval=sem_init(&AccesDenied, 0, 1);
    retval+=sem_init(&AccesDenied2, 0, 1);
    retval+=sem_init(&lecture, 0, 0);
    retval+=sem_init(&ecriture, 0, 10);
    if(retval!=0)
        erreur("sem_init");
    prod=(unsigned long *) malloc(nbprod*sizeof(pthread_t));
    conso=(unsigned long *) malloc(nbconso*sizeof(pthread_t));
    if(prod==((void *)0) || conso==((void *)0)){
        perror("malloc");
        if(prod!=((void *)0))
            free(prod);
        if(conso!=((void *)0))
            free(conso);
        exit(1);
    }
    for(i=0; i<nbprod; i++){
        retval=pthread_create(&prod[i], ((void *)0), producteur, ((void *)0));
        if(retval!=0)
            erreur("pthread_create");
    }
    for(i=0; i<nbconso; i++){
        retval=pthread_create(&conso[i], ((void *)0), consommateur, ((void *)0));
        if(retval!=0)
            erreur("pthread_create");
    }
    for(i=0; i<nbprod; i++){
        retval=pthread_join(prod[i], (void **) &lu);
        if(retval!=0)
            erreur("pthread_join");
        prodAproduit+=lu->nblu;
        sommeProd+=lu->total;
        free(lu);
    }
    printf("\nFin prod\n");
    free(prod);
    ajoutbuff(-1);
    for(i=0; i<nbconso; i++){
        retval=pthread_join(conso[i], (void **) &lu);
        if(retval!=0)
            erreur("pthread_join");
        consoAmanger+=lu->nblu;
        sommeMiam+=lu->total;
        free(lu);
    }
    printf("Fin conso\n");
    free(conso);
    retval=sem_destroy(&AccesDenied);
    retval+=sem_destroy(&AccesDenied2);
    retval+=sem_destroy(&lecture);
    retval+=sem_destroy(&ecriture);
    if(retval!=0)
        erreur("sem_destroy");
    printf("Les %d producteurs ont produit %d            valeurs pour une somme de %ld.\n            Les %d consommateurs ont consommés %d            valeurs pour une somme de %ld.\n",
            nbprod, prodAproduit, sommeProd,
            nbconso, consoAmanger, sommeMiam);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: nbprod int

variable_types: nbconso int

variable_types:
prodAproduit
unsigned int

variable_types:
consoAmanger
unsigned int

variable_types:
sommeProd
unsigned long

variable_types:
sommeMiam
unsigned long

variable_types: i int

variable_types: retval int

variable_types: struct nblu_somme { unsigned int nblu; unsigned long total; } *

variable_types:
prod
unsigned long *

variable_types:
conso
unsigned long *


Ninit

repo: Jeanhwea/Compiler

decompiled_code:
size_t Ninit()
{
size_t result; // rax

strcpy(nspace, "J");
result = strlen(nspace);
nspacelen = result;
return result;
}

canonical_decompiled_code:
size_t func0()
{
size_t result; // rax

strcpy(nspace, "J");
result = strlen(nspace);
nspacelen = result;
return result;
}

original_code:
void Ninit(void)
{
 strcpy(nspace,"J");
 nspacelen = strlen(nspace);
}

canonical_original_code:
void Ninit()
{
 strcpy(nspace,"J");
 nspacelen = strlen(nspace);
}


Npush

decompiled_code:
size_t __fastcall Npush(char *src)
{
size_t result; // rax

*(_WORD *)&nspace[strlen(nspace)] = 95;
strcat(nspace, src);
result = strlen(nspace);
nspacelen = result;
return result;
}

canonical_decompiled_code:
size_t __fastcall func1(char *src)
{
size_t result; // rax

*(_WORD *)&nspace[strlen(nspace)] = 95;
strcat(nspace, src);
result = strlen(nspace);
nspacelen = result;
return result;
}

original_code:
void Npush(char *name)
{
 strcat(nspace,"_");
 strcat(nspace, name);
 nspacelen = strlen(nspace);
}

variable_types:
name
char *


Npop

decompiled_code:
__int64 Npop()
{
__int64 v0; // rax

LODWORD(v0) = nspacelen - 1;
if ( nspacelen - 1 < 0 )
return 0LL;
v0 = (int)v0;
while ( nspace[v0] != 95 )
{
if ( (int)--v0 < 0 )
return 0LL;
}
nspace[(int)v0] = 0;
nspacelen = strlen(nspace);
return 1LL;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax

LODWORD(v0) = nspacelen - 1;
if ( nspacelen - 1 < 0 )
return 0LL;
v0 = (int)v0;
while ( nspace[v0] != 95 )
{
if ( (int)--v0 < 0 )
return 0LL;
}
nspace[(int)v0] = 0;
nspacelen = strlen(nspace);
return 1LL;
}

original_code:
BOOL Npop(void)
{
 int i;
 for (i = nspacelen - 1; i >= 0; i--) {
  if (nspace[i] == '_') {
   nspace[i] = '\0';
   nspacelen = strlen(nspace);
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int Npop()
{
 int i;
 for (i = nspacelen - 1; i >= 0; i--) {
  if (nspace[i] == '_') {
   nspace[i] = '\0';
   nspacelen = strlen(nspace);
   return 1;
  }
 }
 return 0;
}


Nappend

decompiled_code:
char *__fastcall Nappend(char *src)
{
int v1; // eax
char *v2; // rax
char *v3; // rbx

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(nspacelen + v1 + 2);
v3 = v2;
if ( v2 )
{
strcpy(v2, nspace);
*(_WORD *)&v3[strlen(v3)] = 95;
strcat(v3, src);
}
else
{
fwrite("OUTOFMEM: in Nappend\n", 1uLL, 0x15uLL, errlist);
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func3(char *src)
{
int v1; // eax
char *v2; // rax
char *v3; // rbx

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(nspacelen + v1 + 2);
v3 = v2;
if ( v2 )
{
strcpy(v2, nspace);
*(_WORD *)&v3[strlen(v3)] = 95;
strcat(v3, src);
}
else
{
fwrite("OUTOFMEM: in Nappend\n", 1uLL, 0x15uLL, errlist);
}
return v3;
}

original_code:
char *Nappend(char *name)
{
 int n;
 char *t;
 if (name == ((void *)0)) {
  return ((void *)0);
 }
 n = strlen(name);
 t = (char *) malloc((n+nspacelen+2)*sizeof(char));
 if (t == ((void *)0)) {
  fprintf(errlist, "OUTOFMEM: in Nappend\n");
  return ((void *)0);
 }
 strcpy(t, nspace);
 strcat(t, "_");
 strcat(t, name);
 return t;
}

variable_types: n int

variable_types:
t
char *

return_type: char *


signature

decompiled_code:
const char *__fastcall signature(__int64 a1, __int64 *a2)
{
__int64 *v2; // rbp
const char *v3; // rbx
int v4; // eax
int v5; // edx
__int64 *v6; // rcx
__int64 i; // rax
char *v8; // rax
const char *v9; // r12
__int64 v10; // rbx
unsigned int v11; // eax
char *v12; // rax

if ( !a1 )
return 0LL;
v2 = a2;
v3 = *(const char **)(a1 + 8);
v4 = strlen(v3);
v5 = v4;
if ( a2 )
{
v6 = a2;
do
{
for ( i = *v6; i; i = *(_QWORD *)(i + 8) )
v5 += 3;
v6 = (__int64 *)v6[1];
}
while ( v6 );
v8 = (char *)malloc(v5 + 1);
v9 = v8;
if ( v8 )
{
strcpy(v8, v3);
while ( 1 )
{
v10 = *v2;
if ( *v2 )
break;
LABEL_21:
v2 = (__int64 *)v2[1];
if ( !v2 )
return v9;
}
while ( 1 )
{
v11 = **(_DWORD **)v10;
if ( v11 == 12 )
{
*(_DWORD *)&v9[strlen(v9)] = 5392676;
}
else if ( v11 > 0xC )
{
if ( v11 != 13 )
goto LABEL_20;
*(_DWORD *)&v9[strlen(v9)] = 5391140;
}
else if ( v11 == 10 )
{
*(_DWORD *)&v9[strlen(v9)] = 5654820;
}
else
{
if ( v11 != 11 )
{
LABEL_20:
fwrite("NSPACE BUG:87\n", 1uLL, 0xEuLL, errlist);
goto LABEL_13;
}
*(_DWORD *)&v9[strlen(v9)] = 5653284;
}
LABEL_13:
v10 = *(_QWORD *)(v10 + 8);
if ( !v10 )
goto LABEL_21;
}
}
}
else
{
v12 = (char *)malloc(v4 + 1);
v9 = v12;
if ( v12 )
{
strcpy(v12, v3);
return v9;
}
}
fwrite("OUTOFMEM: in funLabel\n", 1uLL, 0x16uLL, errlist);
return 0LL;
}

canonical_decompiled_code:
const char *__fastcall func4(__int64 a1, __int64 *a2)
{
__int64 *v2; // rbp
const char *v3; // rbx
int v4; // eax
int v5; // edx
__int64 *v6; // rcx
__int64 i; // rax
char *v8; // rax
const char *v9; // r12
__int64 v10; // rbx
unsigned int v11; // eax
char *v12; // rax

if ( !a1 )
return 0LL;
v2 = a2;
v3 = *(const char **)(a1 + 8);
v4 = strlen(v3);
v5 = v4;
if ( a2 )
{
v6 = a2;
do
{
for ( i = *v6; i; i = *(_QWORD *)(i + 8) )
v5 += 3;
v6 = (__int64 *)v6[1];
}
while ( v6 );
v8 = (char *)malloc(v5 + 1);
v9 = v8;
if ( v8 )
{
strcpy(v8, v3);
while ( 1 )
{
v10 = *v2;
if ( *v2 )
break;
LABEL_21:
v2 = (__int64 *)v2[1];
if ( !v2 )
return v9;
}
while ( 1 )
{
v11 = **(_DWORD **)v10;
if ( v11 == 12 )
{
*(_DWORD *)&v9[strlen(v9)] = 5392676;
}
else if ( v11 > 0xC )
{
if ( v11 != 13 )
goto LABEL_20;
*(_DWORD *)&v9[strlen(v9)] = 5391140;
}
else if ( v11 == 10 )
{
*(_DWORD *)&v9[strlen(v9)] = 5654820;
}
else
{
if ( v11 != 11 )
{
LABEL_20:
fwrite("NSPACE BUG:87\n", 1uLL, 0xEuLL, errlist);
goto LABEL_13;
}
*(_DWORD *)&v9[strlen(v9)] = 5653284;
}
LABEL_13:
v10 = *(_QWORD *)(v10 + 8);
if ( !v10 )
goto LABEL_21;
}
}
}
else
{
v12 = (char *)malloc(v4 + 1);
v9 = v12;
if ( v12 )
{
strcpy(v12, v3);
return v9;
}
}
fwrite("OUTOFMEM: in funLabel\n", 1uLL, 0x16uLL, errlist);
return 0LL;
}

original_code:
char *signature(IdentSP idp, ParaListSP plp)
{
 int n;
 char *t;
 ParaListSP p;
 ParaDefSP q;
 if (idp == ((void *)0)) {
  return ((void *)0);
 }
 n = strlen(idp->name);
 for (p = plp; p != ((void *)0); p = p->next) {
  for (q = p->pdp; q != ((void *)0); q = q->next) {
   n += 3;
  }
 }
 t = (char *) malloc((n+1)*sizeof(char));
 if (t == ((void *)0)) {
  fprintf(errlist, "OUTOFMEM: in funLabel\n");
  return ((void *)0);
 }
 strcpy(t,idp->name);
 for (p = plp; p != ((void *)0); p = p->next) {
  for (q = p->pdp; q != ((void *)0); q = q->next) {
   switch (q->idp->type) {
   case Int_Para_Val_Ident_t:
    strcat(t,"$IV");
    break;
   case Int_Para_Ref_Ident_t:
    strcat(t,"$IR");
    break;
   case Char_Para_Val_Ident_t:
    strcat(t,"$CV");
    break;
   case Char_Para_Ref_Ident_t:
    strcat(t,"$CR");
    break;
   default:
    fprintf(errlist, "NSPACE BUG:87\n");
   }
  }
 }
 return t;
}

canonical_original_code:
char *signature(struct _IdentS *idp, struct _ParaListS *plp)
{
 int n;
 char *t;
 struct _ParaListS *p;
 struct _ParaDefS *q;
 if (idp == ((void *)0)) {
  return ((void *)0);
 }
 n = strlen(idp->name);
 for (p = plp; p != ((void *)0); p = p->next) {
  for (q = p->pdp; q != ((void *)0); q = q->next) {
   n += 3;
  }
 }
 t = (char *) malloc((n+1)*sizeof(char));
 if (t == ((void *)0)) {
  fprintf(errlist, "OUTOFMEM: in funLabel\n");
  return ((void *)0);
 }
 strcpy(t,idp->name);
 for (p = plp; p != ((void *)0); p = p->next) {
  for (q = p->pdp; q != ((void *)0); q = q->next) {
   switch (q->idp->type) {
   case Int_Para_Val_Ident_t:
    strcat(t,"$IV");
    break;
   case Int_Para_Ref_Ident_t:
    strcat(t,"$IR");
    break;
   case Char_Para_Val_Ident_t:
    strcat(t,"$CV");
    break;
   case Char_Para_Ref_Ident_t:
    strcat(t,"$CR");
    break;
   default:
    fprintf(errlist, "NSPACE BUG:87\n");
   }
  }
 }
 return t;
}

variable_types: struct _ParaListS { struct _ParaDefS { struct _IdentS *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *

variable_types: struct _ParaListS { struct _ParaDefS { struct _IdentS { enum Ident_t { Init_Ident_t=0, Proc_Ident_t=1, Int_Fun_Ident_t=2, Char_Fun_Ident_t=3, Int_Const_Ident_t=4, Char_Const_Ident_t=5, Int_Var_Ident_t=6, Char_Var_Ident_t=7, IntArr_Var_Ident_t=8, CharArr_Var_Ident_t=9, Int_Para_Val_Ident_t=10, Char_Para_Val_Ident_t=11, Int_Para_Ref_Ident_t=12, Char_Para_Ref_Ident_t=13 } type; char *name; int val; int length; int line; } *idp; struct _ParaDefS *next; } *pdp; struct _ParaListS *next; } *

user_defined_types: struct _IdentS { enum Ident_t type; char *name; int val; int length; int line; }

user_defined_types: struct _ParaListS { struct _ParaDefS *pdp; struct _ParaListS *next; }


Indent

decompiled_code:
int Indent()
{
int v0; // ebx
int result; // eax

if ( indentno > 0 )
{
v0 = 0;
do
{
if ( ShowAST )
result = fputc(9, astlist);
++v0;
}
while ( indentno > v0 );
}
return result;
}

canonical_decompiled_code:
int func0()
{
int v0; // ebx
int result; // eax

if ( indentno > 0 )
{
v0 = 0;
do
{
if ( ShowAST )
result = fputc(9, astlist);
++v0;
}
while ( indentno > v0 );
}
return result;
}

original_code:
static void Indent(void)
{
  int i;
  for (i = 0; i < indentno; i++) {
    if (ShowAST)
      fprintf(astlist, "\t");
  }
}

canonical_original_code:
static void Indent()
{
  int i;
  for (i = 0; i < indentno; i++) {
    if (ShowAST)
      fprintf(astlist, "\t");
  }
}


copyString

decompiled_code:
char *__fastcall copyString(char *src)
{
int v1; // eax
char *v2; // rax
char *v3; // rbp

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
v3 = v2;
if ( v2 )
strcpy(v2, src);
else
fprintf(errlist, "Out of memory error at line %d\n", lineno);
return v3;
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
int v1; // eax
char *v2; // rax
char *v3; // rbp

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
v3 = v2;
if ( v2 )
strcpy(v2, src);
else
fprintf(errlist, "Out of memory error at line %d\n", lineno);
return v3;
}

original_code:
char *copyString(char *s)
{
  int n;
  char *t;
  if (s == ((void *)0)) {
    return ((void *)0);
  }
  n = strlen(s) + 1;
  t = (char *) malloc(n * sizeof(char));
  if (t == ((void *)0)) {
    fprintf(errlist, "Out of memory error at line %d\n", lineno);
  } else {
    strcpy(t, s);
  }
  return t;
}

variable_types:
s
char *


headPr

decompiled_code:
int __fastcall headPr(const char *a1)
{
int result; // eax

result = Indent();
++indentno;
if ( ShowAST )
result = fprintf(astlist, "<%s>\n", a1);
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
int result; // eax

result = func0();
++indentno;
if ( ShowAST )
result = fprintf(astlist, "<%s>\n", a1);
return result;
}

original_code:
void headPr(char *cont)
{
  Indent();
  indentno += 1;
  if (ShowAST)
    fprintf(astlist, "<%s>\n", cont);
}

variable_types:
cont
char *


innerIntPr

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

if ( ShowAST )
result = fprintf(astlist, "%d\n", a1);
return result;
}

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

if ( ShowAST )
result = fprintf(astlist, "%d\n", a1);
return result;
}

original_code:
void innerIntPr(int val)
{
  if (ShowAST)
    fprintf(astlist, "%d\n", val);
}

variable_types: val int


innerCharPr

decompiled_code:
int __fastcall innerCharPr(char a1)
{
int result; // eax

if ( ShowAST )
result = fprintf(astlist, "%c\n", (unsigned int)a1);
return result;
}

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

if ( ShowAST )
result = fprintf(astlist, "%c\n", (unsigned int)a1);
return result;
}

original_code:
void innerCharPr(char val)
{
  if (ShowAST)
    fprintf(astlist, "%c\n", val);
}

variable_types: val char


tailPr

decompiled_code:
int __fastcall tailPr(const char *a1)
{
int result; // eax

--indentno;
result = Indent();
if ( ShowAST )
result = fprintf(astlist, "</%s>\n", a1);
return result;
}

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

--indentno;
result = func0();
if ( ShowAST )
result = fprintf(astlist, "</%s>\n", a1);
return result;
}

original_code:
void tailPr(char *cont)
{
  indentno -= 1;
  Indent();
  if (ShowAST)
    fprintf(astlist, "</%s>\n", cont);
}


printBitsmap

decompiled_code:
int __fastcall printBitsmap(unsigned __int16 *a1)
{
unsigned __int16 *v1; // rbx

v1 = a1;
do
{
fprintf(code, "%04x ", *v1);
v1 += 2;
}
while ( v1 != a1 + 16 );
return fputc(10, code);
}

canonical_decompiled_code:
int __fastcall func10(unsigned __int16 *a1)
{
unsigned __int16 *v1; // rbx

v1 = a1;
do
{
fprintf(code, "%04x ", *v1);
v1 += 2;
}
while ( v1 != a1 + 16 );
return fputc(10, code);
}

original_code:
void printBitsmap(int bm[])
{
  int i;
  for (i = 0; i < 8; i++) {
    fprintf(code, "%04x ", bm[i] & 0xffff);
  }
  fprintf(code, "\n");
}

variable_types:
bm
int []


ioasm

decompiled_code:
size_t ioasm()
{
fwrite("SECTION .DATA\n", 1uLL, 0xEuLL, asmlist);
fprintf(asmlist, "\tfmt_int_r: DB \"%%d\", 0\n");
fprintf(asmlist, "\tfmt_int_w: DB \"%%d\", 10, 0\n");
fprintf(asmlist, "\tfmt_char_r: DB 10, \"%%c\", 0\n");
fprintf(asmlist, "\tfmt_char_w: DB \"%%c\", 10, 0\n");
fprintf(asmlist, "\tfmt_string: DB \"%%s\", 10, 0\n\n");
fwrite("SECTION .TEXT\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tEXTERN\tscanf, printf\n", 1uLL, 0x16uLL, asmlist);
fwrite("\tGLOBAL\tscan_int, scan_char\n", 1uLL, 0x1CuLL, asmlist);
fwrite("\tGLOBAL\tprint_int, print_char, print_string\n\n", 1uLL, 0x2DuLL, asmlist);
fwrite("scan_int:\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tsub\tesp, 0x4\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tlea\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_int_r\n", 1uLL, 0x10uLL, asmlist);
fwrite("\tcall\tscanf\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tmov\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tmov\tesp, ebp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpop\tebp\n", 1uLL, 9uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("scan_char:\n", 1uLL, 0xBuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tsub\tesp, 0x4\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tlea\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_char_r\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tscanf\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tmov\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_int:\n", 1uLL, 0xBuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_int_w\n", 1uLL, 0x10uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_char:\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_char_w\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_string:\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_string\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
return fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
}

canonical_decompiled_code:
size_t func11()
{
fwrite("SECTION .DATA\n", 1uLL, 0xEuLL, asmlist);
fprintf(asmlist, "\tfmt_int_r: DB \"%%d\", 0\n");
fprintf(asmlist, "\tfmt_int_w: DB \"%%d\", 10, 0\n");
fprintf(asmlist, "\tfmt_char_r: DB 10, \"%%c\", 0\n");
fprintf(asmlist, "\tfmt_char_w: DB \"%%c\", 10, 0\n");
fprintf(asmlist, "\tfmt_string: DB \"%%s\", 10, 0\n\n");
fwrite("SECTION .TEXT\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tEXTERN\tscanf, printf\n", 1uLL, 0x16uLL, asmlist);
fwrite("\tGLOBAL\tscan_int, scan_char\n", 1uLL, 0x1CuLL, asmlist);
fwrite("\tGLOBAL\tprint_int, print_char, print_string\n\n", 1uLL, 0x2DuLL, asmlist);
fwrite("scan_int:\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tsub\tesp, 0x4\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tlea\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_int_r\n", 1uLL, 0x10uLL, asmlist);
fwrite("\tcall\tscanf\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tmov\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tmov\tesp, ebp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpop\tebp\n", 1uLL, 9uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("scan_char:\n", 1uLL, 0xBuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tsub\tesp, 0x4\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tlea\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_char_r\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tscanf\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tmov\teax, [ebp - 4]\n", 1uLL, 0x14uLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_int:\n", 1uLL, 0xBuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_int_w\n", 1uLL, 0x10uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_char:\n", 1uLL, 0xCuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_char_w\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
fwrite("print_string:\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\tebp\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tmov\tebp, esp\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tpush\teax\n", 1uLL, 0xAuLL, asmlist);
fwrite("\tpush\tfmt_string\n", 1uLL, 0x11uLL, asmlist);
fwrite("\tcall\tprintf\n", 1uLL, 0xDuLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\tpop\tecx\n", 1uLL, 9uLL, asmlist);
fwrite("\txor\teax, eax\n", 1uLL, 0xEuLL, asmlist);
fwrite("\tleave\n", 1uLL, 7uLL, asmlist);
return fwrite("\tret\n\n", 1uLL, 6uLL, asmlist);
}

original_code:
void ioasm(void)
{
  fprintf(asmlist, "SECTION .DATA\n");
  fprintf(asmlist, "\tfmt_int_r:  DB \"%%d\", 0\n");
  fprintf(asmlist, "\tfmt_int_w:  DB \"%%d\", 10, 0\n");
  fprintf(asmlist, "\tfmt_char_r: DB 10, \"%%c\", 0\n");
  fprintf(asmlist, "\tfmt_char_w: DB \"%%c\", 10, 0\n");
  fprintf(asmlist, "\tfmt_string: DB \"%%s\", 10, 0\n\n");
  fprintf(asmlist, "SECTION .TEXT\n");
  fprintf(asmlist, "\tEXTERN\tscanf, printf\n");
  fprintf(asmlist, "\tGLOBAL\tscan_int, scan_char\n");
  fprintf(asmlist, "\tGLOBAL\tprint_int, print_char, print_string\n\n");
  fprintf(asmlist, "scan_int:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tsub\tesp, 0x4\n");
  fprintf(asmlist, "\tlea\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_int_r\n");
  fprintf(asmlist, "\tcall\tscanf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tmov\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tmov\tesp, ebp\n");
  fprintf(asmlist, "\tpop\tebp\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "scan_char:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tsub\tesp, 0x4\n");
  fprintf(asmlist, "\tlea\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_char_r\n");
  fprintf(asmlist, "\tcall\tscanf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tmov\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_int:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_int_w\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_char:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_char_w\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_string:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_string\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
}

canonical_original_code:
void ioasm()
{
  fprintf(asmlist, "SECTION .DATA\n");
  fprintf(asmlist, "\tfmt_int_r:  DB \"%%d\", 0\n");
  fprintf(asmlist, "\tfmt_int_w:  DB \"%%d\", 10, 0\n");
  fprintf(asmlist, "\tfmt_char_r: DB 10, \"%%c\", 0\n");
  fprintf(asmlist, "\tfmt_char_w: DB \"%%c\", 10, 0\n");
  fprintf(asmlist, "\tfmt_string: DB \"%%s\", 10, 0\n\n");
  fprintf(asmlist, "SECTION .TEXT\n");
  fprintf(asmlist, "\tEXTERN\tscanf, printf\n");
  fprintf(asmlist, "\tGLOBAL\tscan_int, scan_char\n");
  fprintf(asmlist, "\tGLOBAL\tprint_int, print_char, print_string\n\n");
  fprintf(asmlist, "scan_int:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tsub\tesp, 0x4\n");
  fprintf(asmlist, "\tlea\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_int_r\n");
  fprintf(asmlist, "\tcall\tscanf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tmov\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tmov\tesp, ebp\n");
  fprintf(asmlist, "\tpop\tebp\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "scan_char:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tsub\tesp, 0x4\n");
  fprintf(asmlist, "\tlea\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_char_r\n");
  fprintf(asmlist, "\tcall\tscanf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tmov\teax, [ebp - 4]\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_int:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_int_w\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_char:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_char_w\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
  fprintf(asmlist, "print_string:\n");
  fprintf(asmlist, "\tpush\tebp\n");
  fprintf(asmlist, "\tmov\tebp, esp\n");
  fprintf(asmlist, "\tpush\teax\n");
  fprintf(asmlist, "\tpush\tfmt_string\n");
  fprintf(asmlist, "\tcall\tprintf\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\tpop\tecx\n");
  fprintf(asmlist, "\txor\teax, eax\n");
  fprintf(asmlist, "\tleave\n");
  fprintf(asmlist, "\tret\n\n");
}


lexError

decompiled_code:
void __fastcall __noreturn lexError(int a1)
{
fprintf(errlist, "lex error:%d: ", lineno);
fprintf(errlist, "%s\n", ERRVEC[a1]);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(int a1)
{
fprintf(errlist, "lex error:%d: ", lineno);
fprintf(errlist, "%s\n", ERRVEC[a1]);
exit(1);
}

original_code:
void lexError(ERRNO errno)
{
 fprintf(errlist, "lex error:%d: ", lineno);
 fprintf(errlist, "%s\n", ERRVEC[errno]);
 exit(1);
}

canonical_original_code:
void lexError(int errno)
{
 fprintf(errlist, "lex error:%d: ", lineno);
 fprintf(errlist, "%s\n", ERRVEC[errno]);
 exit(1);
}

variable_types: errno int


syntaxError

decompiled_code:
int __fastcall syntaxError(int a1, unsigned int a2, int a3, const char *a4)
{
int result; // eax

fprintf(errlist, "syntax error:%d: ", a2);
if ( a4 )
result = fprintf(errlist, "%s%s\n", ERRVEC[a1], a4);
else
result = fprintf(errlist, "%s\n", ERRVEC[a1]);
if ( a3 )
exit(1);
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, unsigned int a2, int a3, const char *a4)
{
int result; // eax

fprintf(errlist, "syntax error:%d: ", a2);
if ( a4 )
result = fprintf(errlist, "%s%s\n", ERRVEC[a1], a4);
else
result = fprintf(errlist, "%s\n", ERRVEC[a1]);
if ( a3 )
exit(1);
return result;
}

original_code:
void syntaxError(ERRNO errno, int lineno, BOOL fatal, char *msg)
{
 fprintf(errlist, "syntax error:%d: ", lineno);
 if (msg != ((void *)0)) {
  fprintf(errlist, "%s%s\n", ERRVEC[errno], msg);
 } else {
  fprintf(errlist, "%s\n", ERRVEC[errno]);
 }
 if (fatal) {
  exit(1);
 }
}

canonical_original_code:
void syntaxError(int errno, int lineno, int fatal, char *msg)
{
 fprintf(errlist, "syntax error:%d: ", lineno);
 if (msg != ((void *)0)) {
  fprintf(errlist, "%s%s\n", ERRVEC[errno], msg);
 } else {
  fprintf(errlist, "%s\n", ERRVEC[errno]);
 }
 if (fatal) {
  exit(1);
 }
}

variable_types: lineno int

variable_types: fatal int

variable_types:
msg
char *


semanticError

decompiled_code:
int __fastcall semanticError(int a1, unsigned int a2, int a3, const char *a4)
{
int result; // eax

fprintf(errlist, "semantic error:%d: ", a2);
if ( a4 )
result = fprintf(errlist, "%s%s\n", ERRVEC[a1], a4);
else
result = fprintf(errlist, "%s\n", ERRVEC[a1]);
if ( a3 )
exit(1);
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, unsigned int a2, int a3, const char *a4)
{
int result; // eax

fprintf(errlist, "semantic error:%d: ", a2);
if ( a4 )
result = fprintf(errlist, "%s%s\n", ERRVEC[a1], a4);
else
result = fprintf(errlist, "%s\n", ERRVEC[a1]);
if ( a3 )
exit(1);
return result;
}

original_code:
void semanticError(ERRNO errno, int lineno, BOOL fatal, char *msg)
{
 fprintf(errlist, "semantic error:%d: ", lineno);
 if (msg != ((void *)0)) {
  fprintf(errlist, "%s%s\n", ERRVEC[errno], msg);
 } else {
  fprintf(errlist, "%s\n", ERRVEC[errno]);
 }
 if (fatal) {
  exit(1);
 }
}

canonical_original_code:
void semanticError(int errno, int lineno, int fatal, char *msg)
{
 fprintf(errlist, "semantic error:%d: ", lineno);
 if (msg != ((void *)0)) {
  fprintf(errlist, "%s%s\n", ERRVEC[errno], msg);
 } else {
  fprintf(errlist, "%s\n", ERRVEC[errno]);
 }
 if (fatal) {
  exit(1);
 }
}