matchClear

decompiled_code:
__int64 __fastcall matchClear(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "clear", 5uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 36LL, v2, 0LL, 0LL);
*a2 += 5;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "clear", 5uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 36LL, v2, 0LL, 0LL);
*a2 += 5;
result = 1LL;
}
return result;
}

original_code:
int matchClear(token *tok, char **s)
{
 if (!strncasecmp(*s, "clear", 5))
 {
  tokenFill(tok, tokTypeClear, tokValueTypeNone, ((void *)0), 0);
  *s += 5;
  return 1;
 }
 return 0;
}

canonical_original_code:
int matchClear(struct token *tok, char **s)
{
 if (!strncasecmp(*s, "clear", 5))
 {
  tokenFill(tok, tokTypeClear, tokValueTypeNone, ((void *)0), 0);
  *s += 5;
  return 1;
 }
 return 0;
}


matchList

repo: PatrickHead/ucBasic

decompiled_code:
__int64 __fastcall matchList(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "list", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 38LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "list", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 38LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

original_code:
int matchList(token *tok, char **s)
{
 if (!strncasecmp(*s, "list", 4))
 {
  tokenFill(tok, tokTypeList, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}

canonical_original_code:
int matchList(struct token *tok, char **s)
{
 if (!strncasecmp(*s, "list", 4))
 {
  tokenFill(tok, tokTypeList, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}

variable_types: struct token { enum tokenType { tokTypeComma=0, tokTypeNumber=1, tokTypeEOL=2, tokTypeCharacterString=3, tokTypeColon=4, tokTypeDividedBy=5, tokTypeEquals=6, tokTypeFree=7, tokTypeFunctionCall=8, tokTypeFunctionPeek=9, tokTypeGosub=10, tokTypeGoto=11, tokTypeGreaterThan=12, tokTypeGreaterThanOrEquals=13, tokTypeIf=14, tokTypeInput=15, tokTypeLeftParenthesis=16, tokTypeLessThan=17, tokTypeLessThanOrEquals=18, tokTypeLet=19, tokTypeMinus=20, tokTypeNotEquals=21, tokTypePlus=22, tokTypePoke=23, tokTypePrint=24, tokTypeRemark=25, tokTypeReturn=26, tokTypeRightParenthesis=27, tokTypeSemicolon=28, tokTypeSize=29, tokTypeString=30, tokTypeDoubleQuote=31, tokTypeThen=32, tokTypeTimes=33, tokTypeVariable=34, tokTypeWhiteSpace=35, tokTypeClear=36, tokTypeRun=37, tokTypeList=38 } type; enum tokenValueType { tokValueTypeNone=0, tokValueTypeString=1, tokValueTypeCharacter=2, tokValueTypeNumber=3 } valueType; union { char *s; char c; int n; }; } *

variable_types:
s
char **

return_type: int

user_defined_types: struct token { enum tokenType type; enum tokenValueType valueType; union { char *s; char c; int n; }; }


matchRun

decompiled_code:
__int64 __fastcall matchRun(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "run", 3uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 37LL, v2, 0LL, 0LL);
*a2 += 3;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "run", 3uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 37LL, v2, 0LL, 0LL);
*a2 += 3;
result = 1LL;
}
return result;
}

original_code:
int matchRun(token *tok, char **s)
{
 if (!strncasecmp(*s, "run", 3))
 {
  tokenFill(tok, tokTypeRun, tokValueTypeNone, ((void *)0), 0);
  *s += 3;
  return 1;
 }
 return 0;
}

canonical_original_code:
int matchRun(struct token *tok, char **s)
{
 if (!strncasecmp(*s, "run", 3))
 {
  tokenFill(tok, tokTypeRun, tokValueTypeNone, ((void *)0), 0);
  *s += 3;
  return 1;
 }
 return 0;
}

user_defined_types: enum tokenType { tokTypeComma=0, tokTypeNumber=1, tokTypeEOL=2, tokTypeCharacterString=3, tokTypeColon=4, tokTypeDividedBy=5, tokTypeEquals=6, tokTypeFree=7, tokTypeFunctionCall=8, tokTypeFunctionPeek=9, tokTypeGosub=10, tokTypeGoto=11, tokTypeGreaterThan=12, tokTypeGreaterThanOrEquals=13, tokTypeIf=14, tokTypeInput=15, tokTypeLeftParenthesis=16, tokTypeLessThan=17, tokTypeLessThanOrEquals=18, tokTypeLet=19, tokTypeMinus=20, tokTypeNotEquals=21, tokTypePlus=22, tokTypePoke=23, tokTypePrint=24, tokTypeRemark=25, tokTypeReturn=26, tokTypeRightParenthesis=27, tokTypeSemicolon=28, tokTypeSize=29, tokTypeString=30, tokTypeDoubleQuote=31, tokTypeThen=32, tokTypeTimes=33, tokTypeVariable=34, tokTypeWhiteSpace=35, tokTypeClear=36, tokTypeRun=37, tokTypeList=38 }

user_defined_types: enum tokenValueType { tokValueTypeNone=0, tokValueTypeString=1, tokValueTypeCharacter=2, tokValueTypeNumber=3 }


matchSize

decompiled_code:
__int64 __fastcall matchSize(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "size", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 29LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "size", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 29LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

original_code:
int matchSize(token *tok, char **s)
{
 if (!strncasecmp(*s, "size", 4))
 {
  tokenFill(tok, tokTypeSize, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}

canonical_original_code:
int matchSize(struct token *tok, char **s)
{
 if (!strncasecmp(*s, "size", 4))
 {
  tokenFill(tok, tokTypeSize, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}


matchFree

decompiled_code:
__int64 __fastcall matchFree(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "free", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 7LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char **a2)
{
__int64 v2; // rdx
__int64 result; // rax

v2 = (unsigned int)strncasecmp(*a2, "free", 4uLL);
result = 0LL;
if ( !(_DWORD)v2 )
{
tokenFill(a1, 7LL, v2, 0LL, 0LL);
*a2 += 4;
result = 1LL;
}
return result;
}

original_code:
int matchFree(token *tok, char **s)
{
 if (!strncasecmp(*s, "free", 4))
 {
  tokenFill(tok, tokTypeFree, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}

canonical_original_code:
int matchFree(struct token *tok, char **s)
{
 if (!strncasecmp(*s, "free", 4))
 {
  tokenFill(tok, tokTypeFree, tokValueTypeNone, ((void *)0), 0);
  *s += 4;
  return 1;
 }
 return 0;
}


tbError

decompiled_code:
const char *__fastcall tbError(char a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "(00) OK";
break;
case 10:
result = "(10) FUNCTION ASSERTION FAILURE";
break;
case 11:
result = "(11) RELATIONAL OPERATOR ASSERTION FAILURE";
break;
case 20:
result = "(20) INVALID EXPRESSION";
break;
case 21:
result = "(21) UNMATCHED PARENTHESES";
break;
case 22:
result = "(22) MALFORMED LINE";
break;
case 23:
result = "(23) MISSING WHITESPACE";
break;
case 24:
result = "(24) MISSING ASSIGNMENT";
break;
case 25:
result = "(25) MISSING VARIABLE";
break;
case 28:
result = "(28) DIVIDE BY ZERO";
break;
case 29:
result = "(29) SYNTAX";
break;
case 30:
result = "(30) OUT OF MEMORY";
break;
case 40:
result = "(40) UNKNOWN LINE NUMBER";
break;
default:
result = "(??) UNKNOWN CODE";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(char a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "(00) OK";
break;
case 10:
result = "(10) FUNCTION ASSERTION FAILURE";
break;
case 11:
result = "(11) RELATIONAL OPERATOR ASSERTION FAILURE";
break;
case 20:
result = "(20) INVALID EXPRESSION";
break;
case 21:
result = "(21) UNMATCHED PARENTHESES";
break;
case 22:
result = "(22) MALFORMED LINE";
break;
case 23:
result = "(23) MISSING WHITESPACE";
break;
case 24:
result = "(24) MISSING ASSIGNMENT";
break;
case 25:
result = "(25) MISSING VARIABLE";
break;
case 28:
result = "(28) DIVIDE BY ZERO";
break;
case 29:
result = "(29) SYNTAX";
break;
case 30:
result = "(30) OUT OF MEMORY";
break;
case 40:
result = "(40) UNKNOWN LINE NUMBER";
break;
default:
result = "(??) UNKNOWN CODE";
break;
}
return result;
}

original_code:
char *tbError(unsigned char code)
{
 switch (code)
 {
  case 00:
   return "(00) OK";
  case 10:
   return "(10) FUNCTION ASSERTION FAILURE";
  case 11:
   return "(11) RELATIONAL OPERATOR ASSERTION FAILURE";
  case 20:
   return "(20) INVALID EXPRESSION";
  case 21:
   return "(21) UNMATCHED PARENTHESES";
  case 22:
   return "(22) MALFORMED LINE";
  case 23:
   return "(23) MISSING WHITESPACE";
  case 24:
   return "(24) MISSING ASSIGNMENT";
  case 25:
   return "(25) MISSING VARIABLE";
  case 28:
   return "(28) DIVIDE BY ZERO";
  case 29:
   return "(29) SYNTAX";
  case 30:
   return "(30) OUT OF MEMORY";
  case 40:
   return "(40) UNKNOWN LINE NUMBER";
  default:
   return "(\?\?) UNKNOWN CODE";
 }
 return "error";
}

variable_types:
code
unsigned char

return_type: char *


commandLine

decompiled_code:
void __noreturn commandLine()
{
FILE *v0; // rbp
char v1; // al
const char *v2; // rax
__int64 v3; // [rsp+0h] [rbp-98h] BYREF
char *v4; // [rsp+18h] [rbp-80h] BYREF
char s[120]; // [rsp+20h] [rbp-78h] BYREF

programSetLineNumber(0LL);
while ( 1 )
{
v4 = s;
memset(s, 0, 0x50uLL);
s[80] = 0;
fwrite("> ", 1uLL, 2uLL, stdout);
fflush(stdin);
fgets(s, 80, stdin);
if ( strlen(s) > 1 && !(unsigned int)parseCommand(&v3, &v4) )
{
fwrite("Error: ", 1uLL, 7uLL, stdout);
v0 = stdout;
v1 = errorGet();
v2 = tbError(v1);
fputs(v2, v0);
putchar(10);
}
errorSet(0LL);
}
}

canonical_decompiled_code:
void __noreturn func2()
{
FILE *v0; // rbp
char v1; // al
const char *v2; // rax
__int64 v3; // [rsp+0h] [rbp-98h] BYREF
char *v4; // [rsp+18h] [rbp-80h] BYREF
char s[120]; // [rsp+20h] [rbp-78h] BYREF

programSetLineNumber(0LL);
while ( 1 )
{
v4 = s;
memset(s, 0, 0x50uLL);
s[80] = 0;
fwrite("> ", 1uLL, 2uLL, stdout);
fflush(stdin);
fgets(s, 80, stdin);
if ( strlen(s) > 1 && !(unsigned int)parseCommand(&v3, &v4) )
{
fwrite("Error: ", 1uLL, 7uLL, stdout);
v0 = stdout;
v1 = errorGet();
v2 = func1(v1);
fputs(v2, v0);
putchar(10);
}
errorSet(0LL);
}
}

original_code:
int commandLine(char *p)
{
 char line[81];
 char *lp;
 token tok;
 programSetLineNumber(0);
 for (;;)
 {
  lp = line;
  memset(line, 0, 81);
  fputs("> ", stdout);
  fflush(stdin);
  fgets(line, 80, stdin);
  if ((strlen(line) > 1) && !parseCommand(&tok, &lp))
  {
   fputs("Error: ", stdout);
   fputs(tbError(errorGet()), stdout);
   putchar('\n');
  }
  errorSet(00);
 }
 return 1;
}

canonical_original_code:
int commandLine(char *p)
{
 char line[81];
 char *lp;
 struct token tok;
 programSetLineNumber(0);
 for (;;)
 {
  lp = line;
  memset(line, 0, 81);
  fputs("> ", stdout);
  fflush(stdin);
  fgets(line, 80, stdin);
  if ((strlen(line) > 1) && !parseCommand(&tok, &lp))
  {
   fputs("Error: ", stdout);
   fputs(tbError(errorGet()), stdout);
   putchar('\n');
  }
  errorSet(00);
 }
 return 1;
}

variable_types:
p
char *

variable_types:
line
char [81]

variable_types:
lp
char *

variable_types: struct token { enum tokenType { tokTypeComma=0, tokTypeNumber=1, tokTypeEOL=2, tokTypeCharacterString=3, tokTypeColon=4, tokTypeDividedBy=5, tokTypeEquals=6, tokTypeFree=7, tokTypeFunctionCall=8, tokTypeFunctionPeek=9, tokTypeGosub=10, tokTypeGoto=11, tokTypeGreaterThan=12, tokTypeGreaterThanOrEquals=13, tokTypeIf=14, tokTypeInput=15, tokTypeLeftParenthesis=16, tokTypeLessThan=17, tokTypeLessThanOrEquals=18, tokTypeLet=19, tokTypeMinus=20, tokTypeNotEquals=21, tokTypePlus=22, tokTypePoke=23, tokTypePrint=24, tokTypeRemark=25, tokTypeReturn=26, tokTypeRightParenthesis=27, tokTypeSemicolon=28, tokTypeSize=29, tokTypeString=30, tokTypeDoubleQuote=31, tokTypeThen=32, tokTypeTimes=33, tokTypeVariable=34, tokTypeWhiteSpace=35, tokTypeClear=36, tokTypeRun=37, tokTypeList=38 } type; enum tokenValueType { tokValueTypeNone=0, tokValueTypeString=1, tokValueTypeCharacter=2, tokValueTypeNumber=3 } valueType; union { char *s; char c; int n; }; }


main

canonical_name: main

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

v3 = (_BYTE *)programInit(argc, argv, envp);
if ( v3 )
{
v4 = v3;
if ( argc <= 1 || !(unsigned int)loadProgram(v3, argv[1]) )
commandLine(v4);
}
return -1;
}

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

v3 = (_BYTE *)programInit(argc, argv, envp);
if ( v3 )
{
v4 = v3;
if ( argc <= 1 || !(unsigned int)func0(v3, argv[1]) )
func2(v4);
}
return -1;
}

original_code:
int main(int argc, char **argv)
{
 char *program;
 program = programInit();
 if (!program) return -1;
 if (argc > 1) if (loadProgram(program, argv[1])) return -1;
 commandLine(program);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
program
char *


reverse

decompiled_code:
__int64 __fastcall reverse(const char *a1)
{
__int64 result; // rax
__int64 v2; // rdx
char v3; // cl

result = (unsigned int)strlen(a1) - 1;
if ( (int)result > 0 )
{
result = (int)result;
v2 = 0LL;
do
{
v3 = a1[v2];
a1[v2] = a1[result];
a1[result] = v3;
++v2;
--result;
}
while ( (int)v2 < (int)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
__int64 result; // rax
__int64 v2; // rdx
char v3; // cl

result = (unsigned int)strlen(a1) - 1;
if ( (int)result > 0 )
{
result = (int)result;
v2 = 0LL;
do
{
v3 = a1[v2];
a1[v2] = a1[result];
a1[result] = v3;
++v2;
--result;
}
while ( (int)v2 < (int)result );
}
return result;
}

original_code:
void reverse(char *s)
{
 int i, j;
 char c;
 for (i = 0, j = strlen(s)-1; i<j; i++, j--)
 {
  c = s[i];
  s[i] = s[j];
  s[j] = c;
 }
}

canonical_original_code:
void reverse(char *s)
{
 int i; int j;
 char c;
 for (i = 0, j = strlen(s)-1; i<j; i++, j--)
 {
  c = s[i];
  s[i] = s[j];
  s[j] = c;
 }
}

variable_types:
s
char *

variable_types: i int

variable_types: j int

variable_types: c char

return_type: void


rechercheSeq

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

result = tete_liste;
if ( tete_liste )
{
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 8);
}
return result;
}

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

result = tete_liste;
if ( tete_liste )
{
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 8);
}
return result;
}

original_code:
Sequence rechercheSeq(Code monCode)
 {
   Liste * courant = tete_liste;
   while (courant != ((void *)0) && courant->c != monCode)
   {
    courant=courant->next;
   }
   if (courant==((void *)0))
   {
    return ((void *)0);
   }
   else {
    return courant->p_s;
    }
 }

canonical_original_code:
char *rechercheSeq(int monCode)
 {
   struct Liste *courant = tete_liste;
   while (courant != ((void *)0) && courant->c != monCode)
   {
    courant=courant->next;
   }
   if (courant==((void *)0))
   {
    return ((void *)0);
   }
   else {
    return courant->p_s;
    }
 }

variable_types: monCode int

variable_types: struct Liste { int c; char *p_s; struct Liste *next; } *


Initialiser

decompiled_code:
_BYTE *Initialiser()
{
_QWORD *v0; // rbx
_BYTE *v1; // rax
int i; // ebp
_QWORD *v3; // r12
_BYTE *result; // rax

v0 = malloc(0x18uLL);
tete_liste = (__int64)v0;
*(_DWORD *)v0 = 0;
v1 = malloc(1uLL);
*v1 = 0;
v0[1] = v1;
v0[2] = 0LL;
for ( i = 1; i != 256; ++i )
{
v3 = v0;
v0 = malloc(0x18uLL);
*(_DWORD *)v0 = i;
result = malloc(1uLL);
*result = i;
v0[1] = result;
v3[2] = v0;
}
v0[2] = 0LL;
fin_liste = (__int64)v0;
return result;
}

canonical_decompiled_code:
_BYTE *func1()
{
_QWORD *v0; // rbx
_BYTE *v1; // rax
int i; // ebp
_QWORD *v3; // r12
_BYTE *result; // rax

v0 = malloc(0x18uLL);
tete_liste = (__int64)v0;
*(_DWORD *)v0 = 0;
v1 = malloc(1uLL);
*v1 = 0;
v0[1] = v1;
v0[2] = 0LL;
for ( i = 1; i != 256; ++i )
{
v3 = v0;
v0 = malloc(0x18uLL);
*(_DWORD *)v0 = i;
result = malloc(1uLL);
*result = i;
v0[1] = result;
v3[2] = v0;
}
v0[2] = 0LL;
fin_liste = (__int64)v0;
return result;
}

original_code:
void Initialiser()
 {
   int nb_alloue = 0;
   char * codeAscii = malloc(sizeof(char));
   *codeAscii=(char) nb_alloue;
   tete_liste = malloc(sizeof(Liste));
   Liste * courant;
   Liste * suivant;
   Sequence Adr_Seq;
   tete_liste->c=nb_alloue;
   Adr_Seq = (char *) malloc(sizeof(char));
   *Adr_Seq = (char) nb_alloue;
   tete_liste->p_s=Adr_Seq;
   tete_liste->next=((void *)0);
   courant = tete_liste;
   nb_alloue++;
   while (nb_alloue < 256)
   {
     suivant = malloc(sizeof(Liste));
     suivant->c=nb_alloue;
     Adr_Seq = (char *) malloc(sizeof(char));
     *Adr_Seq = (char) nb_alloue;
     *codeAscii=(char) nb_alloue;
     suivant->p_s=Adr_Seq;
     courant->next=suivant;
     courant=suivant;
     nb_alloue++;
   }
  suivant->next=((void *)0);
  fin_liste=courant;
 }

canonical_original_code:
void Initialiser()
 {
   int nb_alloue = 0;
   char *codeAscii = malloc(sizeof(char));
   *codeAscii=(char) nb_alloue;
   tete_liste = malloc(sizeof(Liste));
   struct Liste *courant;
   struct Liste *suivant;
   char *Adr_Seq;
   tete_liste->c=nb_alloue;
   Adr_Seq = (char *) malloc(sizeof(char));
   *Adr_Seq = (char) nb_alloue;
   tete_liste->p_s=Adr_Seq;
   tete_liste->next=((void *)0);
   courant = tete_liste;
   nb_alloue++;
   while (nb_alloue < 256)
   {
     suivant = malloc(sizeof(Liste));
     suivant->c=nb_alloue;
     Adr_Seq = (char *) malloc(sizeof(char));
     *Adr_Seq = (char) nb_alloue;
     *codeAscii=(char) nb_alloue;
     suivant->p_s=Adr_Seq;
     courant->next=suivant;
     courant=suivant;
     nb_alloue++;
   }
  suivant->next=((void *)0);
  fin_liste=courant;
 }

variable_types:
codeAscii
char *

user_defined_types: struct Liste { int c; char *p_s; struct Liste *next; }


CodeVersChaine

decompiled_code:
__int64 __fastcall CodeVersChaine(int a1, _DWORD *a2)
{
const char *v2; // rax

v2 = (const char *)rechercheSeq(a1);
*a2 = strlen(v2);
return rechercheSeq(a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, _DWORD *a2)
{
const char *v2; // rax

v2 = (const char *)func0(a1);
*a2 = strlen(v2);
return func0(a1);
}

original_code:
Sequence CodeVersChaine (Code code, int *longueur)
 {
  *longueur = strlen(rechercheSeq(code));
  return rechercheSeq(code);
 }

canonical_original_code:
char *CodeVersChaine(int code, int *longueur)
 {
  *longueur = strlen(rechercheSeq(code));
  return rechercheSeq(code);
 }

variable_types: code int

variable_types:
longueur
int *


EstPresent

decompiled_code:
_BOOL8 __fastcall EstPresent(int a1)
{
__int64 i; // rax

for ( i = tete_liste; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_DWORD *)i == a1 )
break;
}
return i != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(int a1)
{
__int64 i; // rax

for ( i = tete_liste; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_DWORD *)i == a1 )
break;
}
return i != 0;
}

original_code:
int EstPresent(Code code)
 {
  Liste * courant = tete_liste;
  while (courant!=((void *)0) && courant->c != code)
   courant = courant->next;
  return courant != ((void *)0);
 }

canonical_original_code:
int EstPresent(int code)
 {
  struct Liste *courant = tete_liste;
  while (courant!=((void *)0) && courant->c != code)
   courant = courant->next;
  return courant != ((void *)0);
 }


SequenceVersCode

decompiled_code:
__int64 __fastcall SequenceVersCode(char *s2)
{
unsigned int *v1; // rbx
__int64 result; // rax

v1 = (unsigned int *)tete_liste;
result = 0xFFFFFFFFLL;
if ( tete_liste )
{
while ( strcmp(*((const char **)v1 + 1), s2) )
{
v1 = (unsigned int *)*((_QWORD *)v1 + 2);
if ( !v1 )
return 0xFFFFFFFFLL;
}
result = *v1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s2)
{
unsigned int *v1; // rbx
__int64 result; // rax

v1 = (unsigned int *)tete_liste;
result = 0xFFFFFFFFLL;
if ( tete_liste )
{
while ( strcmp(*((const char **)v1 + 1), s2) )
{
v1 = (unsigned int *)*((_QWORD *)v1 + 2);
if ( !v1 )
return 0xFFFFFFFFLL;
}
result = *v1;
}
return result;
}

original_code:
Code SequenceVersCode (Sequence sequence)
 {
   Liste * courant = tete_liste;
   while (courant != ((void *)0) && strcmp(courant->p_s,sequence) != 0 )
   {
    courant=courant->next;
   }
   if (courant==((void *)0))
   {
    return -1;
   }
   else return courant->c;
 }

canonical_original_code:
int SequenceVersCode(char *sequence)
 {
   struct Liste *courant = tete_liste;
   while (courant != ((void *)0) && strcmp(courant->p_s,sequence) != 0 )
   {
    courant=courant->next;
   }
   if (courant==((void *)0))
   {
    return -1;
   }
   else return courant->c;
 }

variable_types:
sequence
char *


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

for ( result = tete_liste; result; result = *(_QWORD *)(result + 16) )
;
return result;
}

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

for ( result = tete_liste; result; result = *(_QWORD *)(result + 16) )
;
return result;
}

original_code:
void affiche_dico()
 {
  Liste * courant = tete_liste;
  while (courant != ((void *)0))
  {
   courant=courant->next;
  }
 }

canonical_original_code:
void affiche_dico()
 {
  struct Liste *courant = tete_liste;
  while (courant != ((void *)0))
  {
   courant=courant->next;
  }
 }


decompiled_code:
char *__fastcall char_to_string(char a1)
{
char *v1; // rbp

v1 = (char *)malloc(2uLL);
sprintf(v1, "%c%s", (unsigned int)a1, byte_168);
return v1;
}

canonical_decompiled_code:
char *__fastcall func0(char a1)
{
char *v1; // rbp

v1 = (char *)malloc(2uLL);
sprintf(v1, "%c%s", (unsigned int)a1, byte_168);
return v1;
}

original_code:
char * char_to_string(char c)
{
  char * chaine;
  chaine = malloc(sizeof(char)+1);
  sprintf(chaine, "%c%s", c, "\0");
  return chaine;
}

canonical_original_code:
char *char_to_string(char c)
{
  char *chaine;
  chaine = malloc(sizeof(char)+1);
  sprintf(chaine, "%c%s", c, "\0");
  return chaine;
}

variable_types:
chaine
char *


decompiled_code:
char *__fastcall int_to_string(unsigned int a1)
{
char *v1; // rbx

v1 = (char *)malloc(2uLL);
sprintf(v1, "%d%s", a1, byte_168);
return v1;
}

canonical_decompiled_code:
char *__fastcall func1(unsigned int a1)
{
char *v1; // rbx

v1 = (char *)malloc(2uLL);
sprintf(v1, "%d%s", a1, byte_168);
return v1;
}

original_code:
char * int_to_string(int i)
{
  char * chaine;
  chaine = malloc(sizeof(char)+1);
  sprintf(chaine, "%d%s", i, "\0");
  return chaine;
}

canonical_original_code:
char *int_to_string(int i)
{
  char *chaine;
  chaine = malloc(sizeof(char)+1);
  sprintf(chaine, "%d%s", i, "\0");
  return chaine;
}


decompiled_code:
int __fastcall ez430_print_config(unsigned __int8 *a1)
{
printf("Config descriptor size : %i\n", *a1);
printf("Config descriptor type : %i\n", a1[1]);
return printf("Number of supported interfaces : %i\n", a1[4]);
}

canonical_decompiled_code:
int __fastcall func1(unsigned __int8 *a1)
{
printf("Config descriptor size : %i\n", *a1);
printf("Config descriptor type : %i\n", a1[1]);
return printf("Number of supported interfaces : %i\n", a1[4]);
}

original_code:
static void ez430_print_config(struct libusb_config_descriptor *config)
{
 printf("Config descriptor size : %i\n", config->bLength);
 printf("Config descriptor type : %i\n", config->bDescriptorType);
 printf("Number of supported interfaces : %i\n", config->bNumInterfaces);
}

variable_types: struct libusb_config_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short wTotalLength; unsigned char bNumInterfaces; unsigned char bConfigurationValue; unsigned char iConfiguration; unsigned char bmAttributes; unsigned char MaxPower; struct libusb_interface { struct libusb_interface_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bInterfaceNumber; unsigned char bAlternateSetting; unsigned char bNumEndpoints; unsigned char bInterfaceClass; unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface; struct libusb_endpoint_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bEndpointAddress; unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval; unsigned char bRefresh; unsigned char bSynchAddress; unsigned char *extra; int extra_length; } *endpoint; unsigned char *extra; int extra_length; } *altsetting; int num_altsetting; } *interface; unsigned char *extra; int extra_length; } *

user_defined_types: struct libusb_config_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned short wTotalLength; unsigned char bNumInterfaces; unsigned char bConfigurationValue; unsigned char iConfiguration; unsigned char bmAttributes; unsigned char MaxPower; struct libusb_interface *interface; unsigned char *extra; int extra_length; }

user_defined_types: struct libusb_interface { struct libusb_interface_descriptor *altsetting; int num_altsetting; }

user_defined_types: struct libusb_interface_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bInterfaceNumber; unsigned char bAlternateSetting; unsigned char bNumEndpoints; unsigned char bInterfaceClass; unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface; struct libusb_endpoint_descriptor *endpoint; unsigned char *extra; int extra_length; }


decompiled_code:
int __fastcall ez430_print_endpoint_desc(unsigned __int8 *a1)
{
char v1; // al
int result; // eax

printf("Size of the descriptor : %i \n", *a1);
printf("Descriptor type: %i \n", a1[1]);
printf("Adress of the endpoint : %i \n", a1[2]);
printf("Endpoint attributes : %i \n", a1[3]);
printf("Endpoint Type :");
v1 = a1[3] & 3;
if ( v1 == 2 )
{
puts("BULK ENDPOINT");
}
else if ( (a1[3] & 3) == 3 )
{
puts("INT ENDPOINT");
}
else if ( v1 )
{
puts("ISOCHRONOUS ENDPOINT");
}
else
{
puts("CONTROL ENDPOINT");
}
printf("Endpoint direction : ");
if ( (a1[2] & 0x80u) != 0 )
result = puts("OUT");
else
result = puts("IN");
return result;
}

canonical_decompiled_code:
int __fastcall func2(unsigned __int8 *a1)
{
char v1; // al
int result; // eax

printf("Size of the descriptor : %i \n", *a1);
printf("Descriptor type: %i \n", a1[1]);
printf("Adress of the endpoint : %i \n", a1[2]);
printf("Endpoint attributes : %i \n", a1[3]);
printf("Endpoint Type :");
v1 = a1[3] & 3;
if ( v1 == 2 )
{
puts("BULK ENDPOINT");
}
else if ( (a1[3] & 3) == 3 )
{
puts("INT ENDPOINT");
}
else if ( v1 )
{
puts("ISOCHRONOUS ENDPOINT");
}
else
{
puts("CONTROL ENDPOINT");
}
printf("Endpoint direction : ");
if ( (a1[2] & 0x80u) != 0 )
result = puts("OUT");
else
result = puts("IN");
return result;
}

original_code:
static void ez430_print_endpoint_desc(const struct libusb_endpoint_descriptor
          *endpoint)
{
 printf("Size of the descriptor : %i \n", endpoint->bLength);
 printf("Descriptor type: %i \n", endpoint->bDescriptorType);
 printf("Adress of the endpoint : %i \n", endpoint->bEndpointAddress);
 printf("Endpoint attributes  : %i \n", endpoint->bmAttributes);
 printf("Endpoint Type :");
 int endpoint_type;
 endpoint_type = endpoint->bmAttributes & 0x3;
 switch (endpoint_type) {
 case LIBUSB_TRANSFER_TYPE_CONTROL:
  printf("CONTROL ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_BULK:
  printf("BULK ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_INTERRUPT:
  printf("INT ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
  printf("ISOCHRONOUS ENDPOINT\n");
  break;
 default:
  printf("Unknown endpoint type!\n");
  break;
 }
 printf("Endpoint direction : ");
 (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) ? printf("OUT\n") :
     printf("IN\n");
}

canonical_original_code:
static void ez430_print_endpoint_desc(struct libusb_endpoint_descriptor *endpoint)
{
 printf("Size of the descriptor : %i \n", endpoint->bLength);
 printf("Descriptor type: %i \n", endpoint->bDescriptorType);
 printf("Adress of the endpoint : %i \n", endpoint->bEndpointAddress);
 printf("Endpoint attributes  : %i \n", endpoint->bmAttributes);
 printf("Endpoint Type :");
 int endpoint_type;
 endpoint_type = endpoint->bmAttributes & 0x3;
 switch (endpoint_type) {
 case LIBUSB_TRANSFER_TYPE_CONTROL:
  printf("CONTROL ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_BULK:
  printf("BULK ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_INTERRUPT:
  printf("INT ENDPOINT\n");
  break;
 case LIBUSB_TRANSFER_TYPE_ISOCHRONOUS:
  printf("ISOCHRONOUS ENDPOINT\n");
  break;
 default:
  printf("Unknown endpoint type!\n");
  break;
 }
 printf("Endpoint direction : ");
 (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) ? printf("OUT\n") :
     printf("IN\n");
}

variable_types: struct libusb_endpoint_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bEndpointAddress; unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval; unsigned char bRefresh; unsigned char bSynchAddress; unsigned char *extra; int extra_length; } *


decompiled_code:
int __fastcall ez430_print_interface_desc(__int64 a1)
{
int result; // eax
__int64 v2; // rbx

printf("Number of endpoints : %i\n", *(unsigned __int8 *)(a1 + 4));
printf("USB-IF Class code : %x \n", *(unsigned __int8 *)(a1 + 5));
result = printf("USB-IF Subclass code : %x \n", *(unsigned __int8 *)(a1 + 6));
if ( *(_BYTE *)(a1 + 4) )
{
v2 = 0LL;
do
{
ez430_print_endpoint_desc((unsigned __int8 *)(*(_QWORD *)(a1 + 16) + 32 * v2++));
result = *(unsigned __int8 *)(a1 + 4);
}
while ( result > (int)v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
int result; // eax
__int64 v2; // rbx

printf("Number of endpoints : %i\n", *(unsigned __int8 *)(a1 + 4));
printf("USB-IF Class code : %x \n", *(unsigned __int8 *)(a1 + 5));
result = printf("USB-IF Subclass code : %x \n", *(unsigned __int8 *)(a1 + 6));
if ( *(_BYTE *)(a1 + 4) )
{
v2 = 0LL;
do
{
func2((unsigned __int8 *)(*(_QWORD *)(a1 + 16) + 32 * v2++));
result = *(unsigned __int8 *)(a1 + 4);
}
while ( result > (int)v2 );
}
return result;
}

original_code:
static void ez430_print_interface_desc(const struct libusb_interface_descriptor
           *interface)
{
 printf("Number of endpoints : %i\n", interface->bNumEndpoints);
 printf("USB-IF Class code : %x \n", interface->bInterfaceClass);
 printf("USB-IF Subclass code : %x \n", interface->bInterfaceSubClass);
 int i = 0;
 for (i = 0; i < interface->bNumEndpoints; i++) {
  ez430_print_endpoint_desc(&(interface->endpoint[i]));
 }
}

canonical_original_code:
static void ez430_print_interface_desc(struct libusb_interface_descriptor *interface)
{
 printf("Number of endpoints : %i\n", interface->bNumEndpoints);
 printf("USB-IF Class code : %x \n", interface->bInterfaceClass);
 printf("USB-IF Subclass code : %x \n", interface->bInterfaceSubClass);
 int i = 0;
 for (i = 0; i < interface->bNumEndpoints; i++) {
  ez430_print_endpoint_desc(&(interface->endpoint[i]));
 }
}

variable_types: struct libusb_interface_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bInterfaceNumber; unsigned char bAlternateSetting; unsigned char bNumEndpoints; unsigned char bInterfaceClass; unsigned char bInterfaceSubClass; unsigned char bInterfaceProtocol; unsigned char iInterface; struct libusb_endpoint_descriptor { unsigned char bLength; unsigned char bDescriptorType; unsigned char bEndpointAddress; unsigned char bmAttributes; unsigned short wMaxPacketSize; unsigned char bInterval; unsigned char bRefresh; unsigned char bSynchAddress; unsigned char *extra; int extra_length; } *endpoint; unsigned char *extra; int extra_length; } *


die

decompiled_code:
void __noreturn die(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}

canonical_decompiled_code:
void __noreturn func9(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
vfprintf(stderr, format, arg);
exit(1);
}

original_code:
void die(const char *format, ...)
{
        va_list args;
        __builtin_va_start(args,format);
        vfprintf(stderr, format, args);
        exit(1);
}

canonical_original_code:
void die(char *format, ...)
{
        __builtin_va_list args;
        __builtin_va_start(args,format);
        vfprintf(stderr, format, args);
        exit(1);
}

variable_types:
format
char *


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int v5; // ebx
unsigned __int16 v6; // r12
char *v7; // rax
int v8; // eax
char v9[76]; // [rsp+0h] [rbp-88h] BYREF
socklen_t addr_len; // [rsp+4Ch] [rbp-3Ch] BYREF
struct sockaddr addr; // [rsp+50h] [rbp-38h] BYREF
int optval[7]; // [rsp+6Ch] [rbp-1Ch] BYREF

v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
v4 = v3;
optval[0] = 1;
setsockopt(v3, 1, 2, optval, 4u);
*(_DWORD *)&addr.sa_data[10] = 0;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)_bswap_32(0);
*(_WORD *)addr.sa_data = _bswap_16(29372);
optval[0] = bind(v4, &addr, 0x10u);
if ( optval[0] >= 0 )
{
optval[0] = listen(v4, 5);
if ( optval[0] < 0 )
die("unable to listen on port %d\n", 29372LL);
while ( 1 )
{
puts("listening...");
addr_len = 16;
v5 = accept(v4, &addr, &addr_len);
if ( v5 < 0 )
break;
v6 = _bswap_16(*(__int16 *)addr.sa_data);
v7 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
printf("client connected %s:%d\n", v7, v6);
while ( 1 )
{
v8 = recv(v5, v9, 0x3FuLL, 0);
optval[0] = v8;
if ( v8 <= 0 )
break;
if ( (unsigned int)(v8 - 1) <= 0x3E )
{
v9[v8] = 0;
printf("%s", v9);
}
}
fflush(stdout);
puts("client seems to have disconnected...");
shutdown(v5, 2);
close(v5);
}
die("error while accepting incoming connection\n");
}
die("unable to bind to port %d\n", 29372LL);
}
die("unable to get network socket\n");
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // ebp
int v5; // ebx
unsigned __int16 v6; // r12
char *v7; // rax
int v8; // eax
char v9[76]; // [rsp+0h] [rbp-88h] BYREF
socklen_t addr_len; // [rsp+4Ch] [rbp-3Ch] BYREF
struct sockaddr addr; // [rsp+50h] [rbp-38h] BYREF
int optval[7]; // [rsp+6Ch] [rbp-1Ch] BYREF

v3 = socket(2, 1, 0);
if ( v3 >= 0 )
{
v4 = v3;
optval[0] = 1;
setsockopt(v3, 1, 2, optval, 4u);
*(_DWORD *)&addr.sa_data[10] = 0;
addr.sa_family = 2;
*(_QWORD *)&addr.sa_data[2] = (unsigned int)func7(0);
*(_WORD *)addr.sa_data = func8(29372);
optval[0] = bind(v4, &addr, 0x10u);
if ( optval[0] >= 0 )
{
optval[0] = listen(v4, 5);
if ( optval[0] < 0 )
func9("unable to listen on port %d\n", 29372LL);
while ( 1 )
{
puts("listening...");
addr_len = 16;
v5 = accept(v4, &addr, &addr_len);
if ( v5 < 0 )
break;
v6 = func8(*(__int16 *)addr.sa_data);
v7 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
printf("client connected %s:%d\n", v7, v6);
while ( 1 )
{
v8 = recv(v5, v9, 0x3FuLL, 0);
optval[0] = v8;
if ( v8 <= 0 )
break;
if ( (unsigned int)(v8 - 1) <= 0x3E )
{
v9[v8] = 0;
printf("%s", v9);
}
}
fflush(stdout);
puts("client seems to have disconnected...");
shutdown(v5, 2);
close(v5);
}
func9("error while accepting incoming connection\n");
}
func9("unable to bind to port %d\n", 29372LL);
}
func9("unable to get network socket\n");
}

original_code:
int main(int argc, char **argv)
{
 int i, serv, client;
 struct sockaddr_in addr;
 socklen_t len;
 char buf[64];
 serv = socket(2, SOCK_STREAM, 0);
 if (serv < 0) die("unable to get network socket\n");
 i = 1;
 setsockopt(serv, 1, 2, &i, sizeof(i));
 memset(&addr, 0, sizeof(addr));
 addr.sin_family = 2;
 addr.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
 addr.sin_port = htons(29372);
 i = bind(serv, (struct sockaddr *)&addr, sizeof(addr));
 if (i < 0) die("unable to bind to port %d\n", 29372);
 i = listen(serv, 5);
 if (i < 0) die("unable to listen on port %d\n", 29372);
 while (1) {
  printf("listening...\n");
  len = sizeof(addr);
  client = accept(serv, (struct sockaddr *)&addr, &len);
  if (client < 0) die("error while accepting incoming connection\n");
  printf("client connected %s:%d\n",
    inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)
  );
  while (1) {
   i = recv(client, buf, sizeof(buf)-1, 0);
   if (i < 1) break;
   if (i > 0 && i < sizeof(buf)) {
    buf[i] = 0;
    printf("%s", buf);
   }
  }
  fflush(stdout);
  printf("client seems to have disconnected...\n");
  shutdown(client, SHUT_RDWR);
  close(client);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int i; int serv; int client;
 struct sockaddr_in addr;
 unsigned int len;
 char buf[64];
 serv = socket(2, SOCK_STREAM, 0);
 if (serv < 0) die("unable to get network socket\n");
 i = 1;
 setsockopt(serv, 1, 2, &i, sizeof(i));
 memset(&addr, 0, sizeof(addr));
 addr.sin_family = 2;
 addr.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
 addr.sin_port = htons(29372);
 i = bind(serv, (struct sockaddr *)&addr, sizeof(addr));
 if (i < 0) die("unable to bind to port %d\n", 29372);
 i = listen(serv, 5);
 if (i < 0) die("unable to listen on port %d\n", 29372);
 while (1) {
  printf("listening...\n");
  len = sizeof(addr);
  client = accept(serv, (struct sockaddr *)&addr, &len);
  if (client < 0) die("error while accepting incoming connection\n");
  printf("client connected %s:%d\n",
    inet_ntoa(addr.sin_addr), ntohs(addr.sin_port)
  );
  while (1) {
   i = recv(client, buf, sizeof(buf)-1, 0);
   if (i < 1) break;
   if (i > 0 && i < sizeof(buf)) {
    buf[i] = 0;
    printf("%s", buf);
   }
  }
  fflush(stdout);
  printf("client seems to have disconnected...\n");
  shutdown(client, SHUT_RDWR);
  close(client);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: serv int

variable_types: client int

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

variable_types:
len
unsigned int

variable_types:
buf
char [64]

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

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


decompiled_code:
__int64 __fastcall cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, int a3)
{
int v4; // ecx
unsigned __int64 v5; // rbx
int v6; // edx
__int64 result; // rax
struct timespec v8; // [rsp+0h] [rbp-48h] BYREF
struct timeval v9; // [rsp+10h] [rbp-38h] BYREF
struct timeval tv; // [rsp+20h] [rbp-28h] BYREF

if ( a3 <= 0 )
{
pthread_cond_wait(cond, mutex);
result = 1000LL;
}
else
{
gettimeofday(&tv, 0LL);
v4 = a3 / 1000;
v5 = tv.tv_usec + 1000 * (a3 % 1000);
v8.tv_nsec = 1000 * (v5 % 0xF4240);
v8.tv_sec = tv.tv_sec + (int)(v5 / 0xF4240 + v4);
v6 = pthread_cond_timedwait(cond, mutex, &v8);
result = 1000LL;
if ( v6 != 110 )
{
gettimeofday(&v9, 0LL);
result = (unsigned int)((LODWORD(v9.tv_usec) - LODWORD(tv.tv_usec)) / 1000
+ 1000 * (LODWORD(v9.tv_sec) - LODWORD(tv.tv_sec)));
if ( (int)result < 0 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(pthread_cond_t *cond, pthread_mutex_t *mutex, int a3)
{
int v4; // ecx
unsigned __int64 v5; // rbx
int v6; // edx
__int64 result; // rax
struct timespec v8; // [rsp+0h] [rbp-48h] BYREF
struct timeval v9; // [rsp+10h] [rbp-38h] BYREF
struct timeval tv; // [rsp+20h] [rbp-28h] BYREF

if ( a3 <= 0 )
{
pthread_cond_wait(cond, mutex);
result = 1000LL;
}
else
{
gettimeofday(&tv, 0LL);
v4 = a3 / 1000;
v5 = tv.tv_usec + 1000 * (a3 % 1000);
v8.tv_nsec = 1000 * (v5 % 0xF4240);
v8.tv_sec = tv.tv_sec + (int)(v5 / 0xF4240 + v4);
v6 = pthread_cond_timedwait(cond, mutex, &v8);
result = 1000LL;
if ( v6 != 110 )
{
gettimeofday(&v9, 0LL);
result = (unsigned int)((LODWORD(v9.tv_usec) - LODWORD(tv.tv_usec)) / 1000
+ 1000 * (LODWORD(v9.tv_sec) - LODWORD(tv.tv_sec)));
if ( (int)result < 0 )
result = 0LL;
}
}
return result;
}

original_code:
static int
cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, int timeout)
{
 int tdiff;
 unsigned long sec, usec;
 struct timeval rtime1, rtime2;
 struct timespec ts;
 int retval;
 if (timeout > 0) {
  gettimeofday(&rtime1, ((void *)0));
  sec = rtime1.tv_sec;
  usec = rtime1.tv_usec;
  usec += timeout % 1000 * 1000;
  sec += (int)(timeout / 1000) + (int)(usec / 1000000);
  usec = usec % 1000000;
  ts.tv_nsec = usec * 1000;
  ts.tv_sec = sec;
  retval = pthread_cond_timedwait(cond, mutex, &ts);
  if (retval == 110) {
   return 1000;
  } else {
   gettimeofday(&rtime2, ((void *)0));
   tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 +
   (rtime2.tv_usec - rtime1.tv_usec) / 1000;
   if (tdiff <= 0) {
    return 0;
   }
   return tdiff;
  }
 } else {
  pthread_cond_wait(cond, mutex);
  return 1000;
 }
}

canonical_original_code:
static int cond_wait(union pthread_cond_t *cond, union pthread_mutex_t *mutex, int timeout)
{
 int tdiff;
 unsigned long sec; unsigned long usec;
 struct timeval rtime1; struct timeval rtime2;
 struct timespec ts;
 int retval;
 if (timeout > 0) {
  gettimeofday(&rtime1, ((void *)0));
  sec = rtime1.tv_sec;
  usec = rtime1.tv_usec;
  usec += timeout % 1000 * 1000;
  sec += (int)(timeout / 1000) + (int)(usec / 1000000);
  usec = usec % 1000000;
  ts.tv_nsec = usec * 1000;
  ts.tv_sec = sec;
  retval = pthread_cond_timedwait(cond, mutex, &ts);
  if (retval == 110) {
   return 1000;
  } else {
   gettimeofday(&rtime2, ((void *)0));
   tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 +
   (rtime2.tv_usec - rtime1.tv_usec) / 1000;
   if (tdiff <= 0) {
    return 0;
   }
   return tdiff;
  }
 } else {
  pthread_cond_wait(cond, mutex);
  return 1000;
 }
}

variable_types: union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } *

variable_types: union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } *

variable_types: timeout int

variable_types: tdiff int

variable_types:
sec
unsigned long

variable_types:
usec
unsigned long

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: retval int

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
char *__fastcall counting_sem_new(int a1)
{
char *v1; // rax
char *v2; // rbx

v1 = (char *)malloc(0x60uLL);
v2 = v1;
if ( v1 )
{
*(_DWORD *)v1 = a1;
pthread_cond_init((pthread_cond_t *)(v1 + 8), 0LL);
pthread_mutex_init((pthread_mutex_t *)(v2 + 56), 0LL);
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func1(int a1)
{
char *v1; // rax
char *v2; // rbx

v1 = (char *)malloc(0x60uLL);
v2 = v1;
if ( v1 )
{
*(_DWORD *)v1 = a1;
pthread_cond_init((pthread_cond_t *)(v1 + 8), 0LL);
pthread_mutex_init((pthread_mutex_t *)(v2 + 56), 0LL);
}
return v2;
}

original_code:
struct counting_sem * counting_sem_new(int count)
{
 struct counting_sem *sem;
 sem = (struct counting_sem *)malloc(sizeof(struct counting_sem));
 if (sem != ((void *)0)) {
  sem->c = count;
  pthread_cond_init(&(sem->cond), ((void *)0));
  pthread_mutex_init(&(sem->mutex), ((void *)0));
 }
 return sem;
}

canonical_original_code:
struct counting_sem *counting_sem_new(int count)
{
 struct counting_sem *sem;
 sem = (struct counting_sem *)malloc(sizeof(struct counting_sem));
 if (sem != ((void *)0)) {
  sem->c = count;
  pthread_cond_init(&(sem->cond), ((void *)0));
  pthread_mutex_init(&(sem->mutex), ((void *)0));
 }
 return sem;
}

variable_types: count int

variable_types: struct counting_sem { int c; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } *

user_defined_types: struct counting_sem { int c; union pthread_cond_t cond; union pthread_mutex_t mutex; }


decompiled_code:
void __fastcall counting_sem_free(void *ptr)
{
pthread_cond_destroy((pthread_cond_t *)((char *)ptr + 8));
pthread_mutex_destroy((pthread_mutex_t *)((char *)ptr + 56));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
pthread_cond_destroy((pthread_cond_t *)((char *)ptr + 8));
pthread_mutex_destroy((pthread_mutex_t *)((char *)ptr + 56));
free(ptr);
}

original_code:
void counting_sem_free(struct counting_sem *sem)
{
 pthread_cond_destroy(&(sem->cond));
 pthread_mutex_destroy(&(sem->mutex));
 free(sem);
}

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
__int64 __fastcall timedout_counting_sem_wait(__int64 a1, int a2)
{
pthread_mutex_t *v2; // r13
int v3; // eax
unsigned int v4; // ebx

v2 = (pthread_mutex_t *)(a1 + 56);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
v3 = *(_DWORD *)a1;
if ( *(int *)a1 <= 0 )
{
v4 = 0;
while ( 1 )
{
if ( a2 <= 0 )
{
cond_wait((pthread_cond_t *)(a1 + 8), v2, 0);
}
else
{
v4 = cond_wait((pthread_cond_t *)(a1 + 8), v2, a2);
if ( v4 == 1000 )
{
pthread_mutex_unlock(v2);
return v4;
}
}
v3 = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
goto LABEL_9;
}
}
v4 = 0;
LABEL_9:
*(_DWORD *)a1 = v3 - 1;
pthread_mutex_unlock(v2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
pthread_mutex_t *v2; // r13
int v3; // eax
unsigned int v4; // ebx

v2 = (pthread_mutex_t *)(a1 + 56);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
v3 = *(_DWORD *)a1;
if ( *(int *)a1 <= 0 )
{
v4 = 0;
while ( 1 )
{
if ( a2 <= 0 )
{
func0((pthread_cond_t *)(a1 + 8), v2, 0);
}
else
{
v4 = func0((pthread_cond_t *)(a1 + 8), v2, a2);
if ( v4 == 1000 )
{
pthread_mutex_unlock(v2);
return v4;
}
}
v3 = *(_DWORD *)a1;
if ( *(int *)a1 > 0 )
goto LABEL_9;
}
}
v4 = 0;
LABEL_9:
*(_DWORD *)a1 = v3 - 1;
pthread_mutex_unlock(v2);
return v4;
}

original_code:
int
timedout_counting_sem_wait(struct counting_sem *sem, int timeout)
{
 int time_needed = 0;
 pthread_mutex_lock(&(sem->mutex));
 while (sem->c <= 0) {
  if (timeout > 0) {
   time_needed = cond_wait(&(sem->cond), &(sem->mutex), timeout);
   if (time_needed == 1000) {
    pthread_mutex_unlock(&(sem->mutex));
    return 1000;
   }
  } else {
   cond_wait(&(sem->cond), &(sem->mutex), 0);
  }
 }
 sem->c--;
 pthread_mutex_unlock(&(sem->mutex));
 return time_needed;
}


decompiled_code:
__int64 __fastcall counting_sem_wait(__int64 a1)
{
pthread_mutex_t *v1; // rbp
int i; // eax

v1 = (pthread_mutex_t *)(a1 + 56);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
for ( i = *(_DWORD *)a1; *(int *)a1 <= 0; i = *(_DWORD *)a1 )
pthread_cond_wait((pthread_cond_t *)(a1 + 8), v1);
*(_DWORD *)a1 = i - 1;
pthread_mutex_unlock(v1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
pthread_mutex_t *v1; // rbp
int i; // eax

v1 = (pthread_mutex_t *)(a1 + 56);
pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
for ( i = *(_DWORD *)a1; *(int *)a1 <= 0; i = *(_DWORD *)a1 )
pthread_cond_wait((pthread_cond_t *)(a1 + 8), v1);
*(_DWORD *)a1 = i - 1;
pthread_mutex_unlock(v1);
return 0LL;
}

original_code:
int
counting_sem_wait(struct counting_sem *sem)
{
 pthread_mutex_lock(&(sem->mutex));
 while (sem->c <= 0) {
  pthread_cond_wait(&(sem->cond), &(sem->mutex));
 }
 sem->c--;
 pthread_mutex_unlock(&(sem->mutex));
 return 0;
}


decompiled_code:
int __fastcall counting_sem_signal(__int64 a1)
{
int v1; // eax

pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
v1 = *(_DWORD *)a1 + 1;
if ( v1 > 1 )
v1 = 1;
*(_DWORD *)a1 = v1;
pthread_cond_broadcast((pthread_cond_t *)(a1 + 8));
return pthread_mutex_unlock((pthread_mutex_t *)(a1 + 56));
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
int v1; // eax

pthread_mutex_lock((pthread_mutex_t *)(a1 + 56));
v1 = *(_DWORD *)a1 + 1;
if ( v1 > 1 )
v1 = 1;
*(_DWORD *)a1 = v1;
pthread_cond_broadcast((pthread_cond_t *)(a1 + 8));
return pthread_mutex_unlock((pthread_mutex_t *)(a1 + 56));
}

original_code:
void
counting_sem_signal(struct counting_sem *sem)
{
 pthread_mutex_lock(&(sem->mutex));
 sem->c++;
 if (sem->c > 1) {
  sem->c = 1;
 }
 pthread_cond_broadcast(&(sem->cond));
 pthread_mutex_unlock(&(sem->mutex));
}


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

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

original_code:
void destroy_cbuffer_t ( cbuffer_t* cbuffer )
{
    free(cbuffer->data);
 cbuffer->size=0;
 cbuffer->head=0;
    cbuffer->max_size=0;
    cbuffer->data=((void *)0);
    free(cbuffer);
}

canonical_original_code:
void destroy_cbuffer_t(struct cbuffer_t *cbuffer)
{
    free(cbuffer->data);
 cbuffer->size=0;
 cbuffer->head=0;
    cbuffer->max_size=0;
    cbuffer->data=((void *)0);
    free(cbuffer);
}

variable_types: struct cbuffer_t { void **data; unsigned int head; unsigned int size; unsigned int max_size; } *


decompiled_code:
__int64 __fastcall size_cbuffer_t(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

original_code:
int size_cbuffer_t ( cbuffer_t* cbuffer )
{
 return cbuffer->size ;
}

canonical_original_code:
int size_cbuffer_t(struct cbuffer_t *cbuffer)
{
 return cbuffer->size ;
}

user_defined_types: struct cbuffer_t { void **data; unsigned int head; unsigned int size; unsigned int max_size; }


decompiled_code:
_BOOL8 __fastcall is_full_cbuffer_t(__int64 a1)
{
return *(_DWORD *)(a1 + 12) == *(_DWORD *)(a1 + 16);
}

original_code:
int is_full_cbuffer_t ( cbuffer_t* cbuffer )
{
 return ( cbuffer->size == cbuffer->max_size ) ;
}

canonical_original_code:
int is_full_cbuffer_t(struct cbuffer_t *cbuffer)
{
 return ( cbuffer->size == cbuffer->max_size ) ;
}


decompiled_code:
_BOOL8 __fastcall is_empty_cbuffer_t(__int64 a1)
{
return *(_DWORD *)(a1 + 12) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_DWORD *)(a1 + 12) == 0;
}

original_code:
int is_empty_cbuffer_t ( cbuffer_t* cbuffer )
{
 return ( cbuffer->size == 0 ) ;
}

canonical_original_code:
int is_empty_cbuffer_t(struct cbuffer_t *cbuffer)
{
 return ( cbuffer->size == 0 ) ;
}


original_code:
void insert_cbuffer_t ( cbuffer_t* cbuffer, void* new_item )
{
 unsigned int pos=0;
 if ( cbuffer->size == cbuffer->max_size )
 {
  cbuffer->data[cbuffer->head]=new_item;
  if ( cbuffer->size !=0 )
   cbuffer->head= ( cbuffer->head+1 ) % cbuffer->max_size;
 }
 else
 {
  if ( cbuffer->max_size!=0 )
   pos= ( cbuffer->head+cbuffer->size ) % cbuffer->max_size;
  cbuffer->data[pos]=new_item;
  cbuffer->size++;
 }
}

canonical_original_code:
void insert_cbuffer_t(struct cbuffer_t *cbuffer, void *new_item)
{
 unsigned int pos = 0;
 if ( cbuffer->size == cbuffer->max_size )
 {
  cbuffer->data[cbuffer->head]=new_item;
  if ( cbuffer->size !=0 )
   cbuffer->head= ( cbuffer->head+1 ) % cbuffer->max_size;
 }
 else
 {
  if ( cbuffer->max_size!=0 )
   pos= ( cbuffer->head+cbuffer->size ) % cbuffer->max_size;
  cbuffer->data[pos]=new_item;
  cbuffer->size++;
 }
}

variable_types:
pos
unsigned int


decompiled_code:
__int64 __fastcall remove_cbuffer_t(_DWORD *a1)
{
int v1; // ecx
__int64 result; // rax

v1 = a1[3];
if ( v1 )
{
result = (unsigned int)(a1[2] + 1) / a1[4];
a1[2] = (unsigned int)(a1[2] + 1) % a1[4];
a1[3] = v1 - 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1)
{
int v1; // ecx
__int64 result; // rax

v1 = a1[3];
if ( v1 )
{
result = (unsigned int)(a1[2] + 1) / a1[4];
a1[2] = (unsigned int)(a1[2] + 1) % a1[4];
a1[3] = v1 - 1;
}
return result;
}

original_code:
void remove_cbuffer_t ( cbuffer_t* cbuffer)
{
if ( cbuffer->size > 0 )
        {
                cbuffer->head= ( cbuffer->head+1 ) % cbuffer->max_size;
                cbuffer->size--;
        }
}

canonical_original_code:
void remove_cbuffer_t(struct cbuffer_t *cbuffer)
{
if ( cbuffer->size > 0 )
        {
                cbuffer->head= ( cbuffer->head+1 ) % cbuffer->max_size;
                cbuffer->size--;
        }
}


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

result = 0LL;
if ( *(_DWORD *)(a1 + 12) )
result = *(_QWORD *)(*(_QWORD *)a1 + 8LL * *(unsigned int *)(a1 + 8));
return result;
}

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

result = 0LL;
if ( *(_DWORD *)(a1 + 12) )
result = *(_QWORD *)(*(_QWORD *)a1 + 8LL * *(unsigned int *)(a1 + 8));
return result;
}

original_code:
void* head_cbuffer_t ( cbuffer_t* cbuffer )
{
 if ( cbuffer->size > 0 )
                return cbuffer->data[cbuffer->head];
        else{
                return ((void *)0);
        }
}

canonical_original_code:
void *head_cbuffer_t(struct cbuffer_t *cbuffer)
{
 if ( cbuffer->size > 0 )
                return cbuffer->data[cbuffer->head];
        else{
                return ((void *)0);
        }
}

return_type: void *


decompiled_code:
__int64 get_nclients()
{
return (unsigned int)n_clients;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned int)n_clients;
}

original_code:
int get_nclients() {
 return n_clients;
}


decompiled_code:
__int64 *get_client_list()
{
return &clients;
}

canonical_decompiled_code:
__int64 *func3()
{
return &clients;
}

original_code:
pthread_t* get_client_list() {
 return clients;
}

canonical_original_code:
unsigned long *get_client_list() {
 return clients;
}

return_type: unsigned long *


decompiled_code:
void clear_client_list()
{
n_clients = -1;
}

canonical_decompiled_code:
void func4()
{
n_clients = -1;
}

original_code:
void clear_client_list() {
 n_clients=-1;
}


decompiled_code:
sem_t *var_cond_new()
{
sem_t *v0; // rax
sem_t *v1; // rbx

v0 = (sem_t *)malloc(0x50uLL);
v1 = v0;
if ( v0 )
{
if ( sem_init(v0, 0, 0) )
puts(s);
pthread_mutex_init((pthread_mutex_t *)(&v1[1].__align + 1), 0LL);
*(_DWORD *)v1[1].__size = 0;
}
return v1;
}

canonical_decompiled_code:
sem_t *func0()
{
sem_t *v0; // rax
sem_t *v1; // rbx

v0 = (sem_t *)malloc(0x50uLL);
v1 = v0;
if ( v0 )
{
if ( sem_init(v0, 0, 0) )
puts(s);
pthread_mutex_init((pthread_mutex_t *)(&v1[1].__align + 1), 0LL);
*(_DWORD *)v1[1].__size = 0;
}
return v1;
}

original_code:
struct mi_cond_var* var_cond_new( ) {
    struct mi_cond_var* vc =((void *)0);
    vc =(struct mi_cond_var*) malloc(sizeof(struct mi_cond_var));
    if (vc != ((void *)0)) {
        if ( sem_init(&(vc->sem),0,0) != 0 ) {
            printf("Error creando el semáforo de la variable condicional\n");
        }
        pthread_mutex_init(&(vc->mutex), ((void *)0));
        vc->c=0;
    }
    return vc;
}

canonical_original_code:
struct mi_cond_var *var_cond_new() {
    struct mi_cond_var *vc = ((void *)0);
    vc =(struct mi_cond_var *) malloc(sizeof(struct mi_cond_var));
    if (vc != ((void *)0)) {
        if ( sem_init(&(vc->sem),0,0) != 0 ) {
            printf("Error creando el semáforo de la variable condicional\n");
        }
        pthread_mutex_init(&(vc->mutex), ((void *)0));
        vc->c=0;
    }
    return vc;
}

variable_types: struct mi_cond_var { union sem_t { char __size[32]; long __align; } sem; int c; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } *

user_defined_types: struct mi_cond_var { union sem_t sem; int c; union pthread_mutex_t mutex; }


decompiled_code:
void __fastcall var_cond_free(void *ptr)
{
sem_destroy((sem_t *)ptr);
pthread_mutex_destroy((pthread_mutex_t *)ptr + 1);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
sem_destroy((sem_t *)ptr);
pthread_mutex_destroy((pthread_mutex_t *)ptr + 1);
free(ptr);
}

original_code:
void var_cond_free(struct mi_cond_var *vc) {
    sem_destroy(&(vc->sem));
 pthread_mutex_destroy(&(vc->mutex));
    free(vc);
}

user_defined_types: union sem_t { char __size[32]; long __align; }


decompiled_code:
int __fastcall var_cond_signal(sem_t *sem)
{
pthread_mutex_lock((pthread_mutex_t *)(&sem[1].__align + 1));
if ( SLODWORD(sem[1].__align) > 0 )
sem_post(sem);
return pthread_mutex_unlock((pthread_mutex_t *)(&sem[1].__align + 1));
}

canonical_decompiled_code:
int __fastcall func2(sem_t *sem)
{
pthread_mutex_lock((pthread_mutex_t *)(&sem[1].__align + 1));
if ( SLODWORD(sem[1].__align) > 0 )
sem_post(sem);
return pthread_mutex_unlock((pthread_mutex_t *)(&sem[1].__align + 1));
}

original_code:
void var_cond_signal(struct mi_cond_var *vc) {
 pthread_mutex_lock(&(vc->mutex));
    if ( vc->c > 0)
        sem_post(&(vc->sem));
 pthread_mutex_unlock(&(vc->mutex));
}


decompiled_code:
__int64 __fastcall var_cond_wait(sem_t *sem, pthread_mutex_t *mutex)
{
++*(_DWORD *)sem[1].__size;
pthread_mutex_unlock(mutex);
sem_wait(sem);
pthread_mutex_lock(mutex);
--*(_DWORD *)sem[1].__size;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(sem_t *sem, pthread_mutex_t *mutex)
{
++*(_DWORD *)sem[1].__size;
pthread_mutex_unlock(mutex);
sem_wait(sem);
pthread_mutex_lock(mutex);
--*(_DWORD *)sem[1].__size;
return 0LL;
}

original_code:
int var_cond_wait(struct mi_cond_var *vc, pthread_mutex_t* l) {
vc->c++;
pthread_mutex_unlock(l);
sem_wait(&(vc->sem));
pthread_mutex_lock(l);
vc->c--;
return 0;
   }

canonical_original_code:
int var_cond_wait(struct mi_cond_var *vc, union pthread_mutex_t *l) {
vc->c++;
pthread_mutex_unlock(l);
sem_wait(&(vc->sem));
pthread_mutex_lock(l);
vc->c--;
return 0;
   }

variable_types:
l
union pthread_mutex_t *


getServerThId

decompiled_code:
pthread_t getServerThId()
{
return server_id;
}

canonical_decompiled_code:
pthread_t func0()
{
return server_id;
}

canonical_original_code:
unsigned long getServerThId() {
 return server_id;
}

return_type: unsigned long


decompiled_code:
__int64 shutdown_server()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 result; // rax

serv_up = 0;
v0 = new_message(2LL);
if ( v0 )
{
v1 = v0;
mbox_post(mbox, v0);
counting_sem_wait(*(_QWORD *)(v1 + 16));
free_message(v1);
result = 0LL;
}
else
{
fwrite("Error when creating NONE message\n", 1uLL, 0x21uLL, logfile);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rax
__int64 v1; // rbx
__int64 result; // rax

serv_up = 0;
v0 = new_message(2LL);
if ( v0 )
{
v1 = v0;
mbox_post(mbox, v0);
counting_sem_wait(*(_QWORD *)(v1 + 16));
free_message(v1);
result = 0LL;
}
else
{
fwrite("Error when creating NONE message\n", 1uLL, 0x21uLL, logfile);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int shutdown_server() {
 message_t* msg;
 serv_up = 0;
 if ( ( msg=new_message(NONE ) ) == ((void *)0) ) {
  fprintf(logfile,"Error when creating NONE message\n");
  return -1;
 }
 mbox_post( mbox, msg);
 counting_sem_wait(msg->op_completed);
 if (msg != ((void *)0)) free_message(msg);
 return 0;
}

canonical_original_code:
int shutdown_server() {
 struct _message_ *msg;
 serv_up = 0;
 if ( ( msg=new_message(NONE ) ) == ((void *)0) ) {
  fprintf(logfile,"Error when creating NONE message\n");
  return -1;
 }
 mbox_post( mbox, msg);
 counting_sem_wait(msg->op_completed);
 if (msg != ((void *)0)) free_message(msg);
 return 0;
}

variable_types: struct _message_ { enum _message_types_ { RANDOM=0, TIME=1, NONE=2 } tipo; void *content; struct counting_sem { int c; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } cond; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } *op_completed; } *

user_defined_types: struct _message_ { enum _message_types_ tipo; void *content; struct counting_sem *op_completed; }


decompiled_code:
__int64 server_is_up()
{
return (unsigned __int8)serv_up;
}

canonical_decompiled_code:
__int64 func2()
{
return (unsigned __int8)serv_up;
}

original_code:
char server_is_up() {
 return serv_up;
}

canonical_original_code:
char server_is_up() {
 return serv_up;
}

return_type: char


decompiled_code:
__int64 __fastcall execute_random_service(__int64 a1)
{
unsigned int *v1; // rbx
unsigned int v2; // eax

v1 = *(unsigned int **)(a1 + 8);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = rand();
*v1 = v2;
fprintf(logfile, "Server random: %d\n", v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int *v1; // rbx
unsigned int v2; // eax

v1 = *(unsigned int **)(a1 + 8);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = rand();
*v1 = v2;
fprintf(logfile, "Server random: %d\n", v2);
return 0LL;
}

original_code:
int execute_random_service(message_t* msg) {
 if (msg->content == ((void *)0)) {
  return -1;
 }
 int* content = (int*) (msg->content);
 *content = rand();
 fprintf(logfile,"Server random: %d\n",*content);
  return 0;
}

canonical_original_code:
int execute_random_service(struct _message_ *msg) {
 if (msg->content == ((void *)0)) {
  return -1;
 }
 int *content = (int*) (msg->content);
 *content = rand();
 fprintf(logfile,"Server random: %d\n",*content);
  return 0;
}

variable_types:
content
int *

user_defined_types: enum _message_types_ { RANDOM=0, TIME=1, NONE=2 }


decompiled_code:
__int64 __fastcall excute_time_service(__int64 a1)
{
struct tm *v1; // rbx
char *v2; // rax
char *v3; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

time(&timer);
v1 = localtime(&timer);
v2 = asctime(v1);
fprintf(logfile, "SERVER: The current date and time are %s", v2);
v3 = asctime(v1);
strcpy(*(char **)(a1 + 8), v3);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
struct tm *v1; // rbx
char *v2; // rax
char *v3; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

time(&timer);
v1 = localtime(&timer);
v2 = asctime(v1);
fprintf(logfile, "SERVER: The current date and time are %s", v2);
v3 = asctime(v1);
strcpy(*(char **)(a1 + 8), v3);
return 0LL;
}

original_code:
int excute_time_service(message_t* msg) {
 struct tm *newtime;
    time_t ltime;
    time(&ltime);
    newtime = localtime(&ltime);
    fprintf(logfile,"SERVER: The current date and time are %s",asctime(newtime));
 strcpy((char*)msg->content, asctime(newtime));
 return 0;
}

canonical_original_code:
int excute_time_service(struct _message_ *msg) {
 struct tm *newtime;
    long ltime;
    time(&ltime);
    newtime = localtime(&ltime);
    fprintf(logfile,"SERVER: The current date and time are %s",asctime(newtime));
 strcpy((char *)msg->content, asctime(newtime));
 return 0;
}

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types: ltime long


decompiled_code:
int __fastcall SIGINT_handler(unsigned int a1)
{
pthread_t v1; // rax

v1 = pthread_self();
return fprintf(logfile, "thread %u: caught signal %d (SIGINT)\n", v1, a1);
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1)
{
pthread_t v1; // rax

v1 = pthread_self();
return fprintf(logfile, "thread %u: caught signal %d (SIGINT)\n", v1, a1);
}

original_code:
void SIGINT_handler(int signo) {
 pthread_t id;
    id = pthread_self();
    fprintf(logfile,"thread %u: caught signal %d (SIGINT)\n", (unsigned int) id, signo);
}

canonical_original_code:
void SIGINT_handler(int signo) {
 unsigned long id;
    id = pthread_self();
    fprintf(logfile,"thread %u: caught signal %d (SIGINT)\n", (unsigned int) id, signo);
}

variable_types: signo int

variable_types:
id
unsigned long


decompiled_code:
int my_pause()
{
*(_BYTE *)pause = 1;
pthread_mutex_lock(&lock);
while ( *(_BYTE *)pause == 1 )
pthread_cond_wait(&cond, &lock);
return pthread_mutex_unlock(&lock);
}

canonical_decompiled_code:
int func1()
{
*(_BYTE *)pause = 1;
pthread_mutex_lock(&lock);
while ( *(_BYTE *)pause == 1 )
pthread_cond_wait(&cond, &lock);
return pthread_mutex_unlock(&lock);
}

original_code:
void my_pause() {
 _pause = 1;
 pthread_mutex_lock(&lock);
    while(_pause==1) {
        pthread_cond_wait(&cond, &lock);
    }
    pthread_mutex_unlock(&lock);
}


decompiled_code:
void *__fastcall signal_handler_thread(void *a1)
{
sigset_t v2; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v3; // [rsp+80h] [rbp-A8h] BYREF

sigemptyset(&v2);
pthread_sigmask(2, &v2, 0LL);
v3.sa_handler = (__sighandler_t)SIGINT_handler;
v3.sa_flags = 0;
sigemptyset(&v3.sa_mask);
if ( sigaction(2, &v3, 0LL) )
{
printf("ERROR: can't install SIGINT signal handler");
}
else
{
while ( !finish_thread )
my_pause();
puts("Exiting signal_handler thread");
}
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1)
{
sigset_t v2; // [rsp+0h] [rbp-128h] BYREF
struct sigaction v3; // [rsp+80h] [rbp-A8h] BYREF

sigemptyset(&v2);
pthread_sigmask(2, &v2, 0LL);
v3.sa_handler = (__sighandler_t)SIGINT_handler;
v3.sa_flags = 0;
sigemptyset(&v3.sa_mask);
if ( sigaction(2, &v3, 0LL) )
{
printf("ERROR: can't install SIGINT signal handler");
}
else
{
while ( !finish_thread )
func1();
puts("Exiting signal_handler thread");
}
return 0LL;
}

original_code:
void* signal_handler_thread(void * c) {
 struct sigaction act;
 sigset_t set;
 sigemptyset(&set);
 pthread_sigmask(2,&set,((void *)0));
 act.__sigaction_handler.sa_handler = SIGINT_handler;
 act.sa_flags = 0;
 sigemptyset(&act.sa_mask);
 if (sigaction(2, &act, ((void *)0)) != 0) {
        printf("ERROR: can't install SIGINT signal handler");
  return ((void *)0);
 }
 while (!finish_thread) {
  my_pause();
 }
 printf("Exiting signal_handler thread\n");
 return ((void *)0);
}

canonical_original_code:
void *signal_handler_thread(void *c) {
 struct sigaction act;
 struct __sigset_t set;
 sigemptyset(&set);
 pthread_sigmask(2,&set,((void *)0));
 act.__sigaction_handler.sa_handler = SIGINT_handler;
 act.sa_flags = 0;
 sigemptyset(&act.sa_mask);
 if (sigaction(2, &act, ((void *)0)) != 0) {
        printf("ERROR: can't install SIGINT signal handler");
  return ((void *)0);
 }
 while (!finish_thread) {
  my_pause();
 }
 printf("Exiting signal_handler thread\n");
 return ((void *)0);
}

variable_types:
c
void *

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)(); }

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


decompiled_code:
int my_resume()
{
pthread_mutex_lock(&lock);
*(_BYTE *)pause = 0;
pthread_cond_signal(&cond);
return pthread_mutex_unlock(&lock);
}

canonical_decompiled_code:
int func3()
{
pthread_mutex_lock(&lock);
*(_BYTE *)pause = 0;
pthread_cond_signal(&cond);
return pthread_mutex_unlock(&lock);
}

original_code:
void my_resume() {
 pthread_mutex_lock(&lock);
 _pause=0;
 pthread_cond_signal(&cond);
 pthread_mutex_unlock(&lock);
}


decompiled_code:
void __fastcall mbox_free(void *ptr)
{
if ( ptr )
{
var_cond_free(*((_QWORD *)ptr + 1));
var_cond_free(*((_QWORD *)ptr + 2));
pthread_mutex_destroy(*((pthread_mutex_t **)ptr + 3));
free(*((void **)ptr + 3));
destroy_cbuffer_t(*(_QWORD *)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
if ( ptr )
{
var_cond_free(*((_QWORD *)ptr + 1));
var_cond_free(*((_QWORD *)ptr + 2));
pthread_mutex_destroy(*((pthread_mutex_t **)ptr + 3));
free(*((void **)ptr + 3));
destroy_cbuffer_t(*(_QWORD *)ptr);
free(ptr);
}
}

original_code:
void
mbox_free(struct sys_mbox *mbox)
{
  if ((mbox != ((void *)0)) ) {
    var_cond_free(mbox->hayElem);
    var_cond_free(mbox->hayHueco);
    pthread_mutex_destroy(mbox->mutex);
 free(mbox->mutex);
      destroy_cbuffer_t(mbox->cbuffer);
   free(mbox);
  }
}

variable_types: struct sys_mbox { struct cbuffer_t { void **data; unsigned int head; unsigned int size; unsigned int max_size; } *cbuffer; struct mi_cond_var { union sem_t { char __size[32]; long __align; } sem; int c; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } *hayElem; struct mi_cond_var *hayHueco; union pthread_mutex_t *mutex; } *

user_defined_types: struct sys_mbox { struct cbuffer_t *cbuffer; struct mi_cond_var *hayElem; struct mi_cond_var *hayHueco; union pthread_mutex_t *mutex; }


decompiled_code:
int __fastcall mbox_post(_QWORD *a1, __int64 a2)
{
pthread_mutex_lock((pthread_mutex_t *)a1[3]);
while ( (unsigned int)is_full_cbuffer_t(*a1) )
var_cond_wait(a1[2], a1[3]);
insert_cbuffer_t(*a1, a2);
var_cond_signal(a1[1]);
return pthread_mutex_unlock((pthread_mutex_t *)a1[3]);
}

canonical_decompiled_code:
int __fastcall func1(_QWORD *a1, __int64 a2)
{
pthread_mutex_lock((pthread_mutex_t *)a1[3]);
while ( (unsigned int)is_full_cbuffer_t(*a1) )
var_cond_wait(a1[2], a1[3]);
insert_cbuffer_t(*a1, a2);
var_cond_signal(a1[1]);
return pthread_mutex_unlock((pthread_mutex_t *)a1[3]);
}

original_code:
void
mbox_post( struct sys_mbox *mbox, void *msg)
{
    pthread_mutex_lock(mbox->mutex);
        while(is_full_cbuffer_t(mbox->cbuffer)) {
  var_cond_wait(mbox->hayHueco,mbox->mutex);
        }
        insert_cbuffer_t(mbox->cbuffer, msg);
               var_cond_signal(mbox->hayElem);
        pthread_mutex_unlock(mbox->mutex);
}

canonical_original_code:
void mbox_post(struct sys_mbox *mbox, void *msg)
{
    pthread_mutex_lock(mbox->mutex);
        while(is_full_cbuffer_t(mbox->cbuffer)) {
  var_cond_wait(mbox->hayHueco,mbox->mutex);
        }
        insert_cbuffer_t(mbox->cbuffer, msg);
               var_cond_signal(mbox->hayElem);
        pthread_mutex_unlock(mbox->mutex);
}

variable_types:
msg
void *


decompiled_code:
__int64 __fastcall mbox_fetch(_QWORD *a1)
{
__int64 v1; // rbp

pthread_mutex_lock((pthread_mutex_t *)a1[3]);
while ( (unsigned int)is_empty_cbuffer_t(*a1) )
var_cond_wait(a1[1], a1[3]);
v1 = head_cbuffer_t(*a1);
remove_cbuffer_t(*a1);
var_cond_signal(a1[2]);
pthread_mutex_unlock((pthread_mutex_t *)a1[3]);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
__int64 v1; // rbp

pthread_mutex_lock((pthread_mutex_t *)a1[3]);
while ( (unsigned int)is_empty_cbuffer_t(*a1) )
var_cond_wait(a1[1], a1[3]);
v1 = head_cbuffer_t(*a1);
remove_cbuffer_t(*a1);
var_cond_signal(a1[2]);
pthread_mutex_unlock((pthread_mutex_t *)a1[3]);
return v1;
}

original_code:
void*
mbox_fetch(struct sys_mbox *mbox)
{
   pthread_mutex_lock(mbox->mutex);
        while(is_empty_cbuffer_t(mbox->cbuffer)) {
               var_cond_wait(mbox->hayElem,mbox->mutex);
        }
        void *msg = head_cbuffer_t(mbox->cbuffer);
        remove_cbuffer_t(mbox->cbuffer);
                var_cond_signal(mbox->hayHueco);
        pthread_mutex_unlock(mbox->mutex);
 return msg;
}

canonical_original_code:
void *mbox_fetch(struct sys_mbox *mbox)
{
   pthread_mutex_lock(mbox->mutex);
        while(is_empty_cbuffer_t(mbox->cbuffer)) {
               var_cond_wait(mbox->hayElem,mbox->mutex);
        }
        void *msg = head_cbuffer_t(mbox->cbuffer);
        remove_cbuffer_t(mbox->cbuffer);
                var_cond_signal(mbox->hayHueco);
        pthread_mutex_unlock(mbox->mutex);
 return msg;
}


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
printf("Usage: %s [options]\n", a1);
puts("** Supported options **");
puts("-o <logfile>");
puts("-n <mailbox_size>");
puts("-s <default_nr_secs>");
puts("-m <default_nr_msgs>");
return puts("-c <default_client_type>");
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
printf("Usage: %s [options]\n", a1);
puts("** Supported options **");
puts("-o <logfile>");
puts("-n <mailbox_size>");
puts("-s <default_nr_secs>");
puts("-m <default_nr_msgs>");
return puts("-c <default_client_type>");
}

original_code:
static void usage(const char* program_name) {
 printf("Usage: %s [options]\n", program_name);
 printf("** Supported options **\n");
 printf("-o <logfile>\n");
 printf("-n <mailbox_size>\n");
 printf("-s <default_nr_secs>\n");
 printf("-m <default_nr_msgs>\n");
 printf("-c <default_client_type>\n");
}

canonical_original_code:
static void usage(char *program_name) {
 printf("Usage: %s [options]\n", program_name);
 printf("** Supported options **\n");
 printf("-o <logfile>\n");
 printf("-n <mailbox_size>\n");
 printf("-s <default_nr_secs>\n");
 printf("-m <default_nr_msgs>\n");
 printf("-c <default_client_type>\n");
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
char v4; // al
FILE *v5; // rax
__int64 v6; // rax
__int64 v7; // rbx
int v8; // ebp
int result; // eax
sigset_t v10; // [rsp+0h] [rbp-98h] BYREF

logfile = stdout;
v3 = 32;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "+ho:n:s:m:c:");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'c':
default_client_type = atoi(optarg);
if ( default_client_type > 1u )
{
fwrite("Values supported for default_client_type: {0,1}\n", 1uLL, 0x30uLL, stderr);
exit(1);
}
return result;
case 'h':
usage(*argv);
exit(0);
case 'm':
nr_msgs = atoi(optarg);
if ( nr_msgs <= 0 )
{
fwrite("nr_msgs be greater than zero\n", 1uLL, 0x1DuLL, stderr);
exit(1);
}
return result;
case 'n':
v3 = atoi(optarg);
if ( !v3 )
{
fwrite("Mailbox size must be greater than zero\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
return result;
case 'o':
v5 = fopen(optarg, "w");
if ( !v5 )
{
fwrite("Can't open logfile\n", 1uLL, 0x13uLL, stderr);
exit(1);
}
logfile = v5;
break;
case 's':
nr_secs = atoi(optarg);
if ( nr_secs <= 0 )
{
fwrite("nr_secs size must be greater than zero\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
return result;
default:
continue;
}
}
sigemptyset(&v10);
sigaddset(&v10, 1);
sigaddset(&v10, 2);
sigaddset(&v10, 10);
sigaddset(&v10, 12);
sigaddset(&v10, 14);
pthread_sigmask(0, &v10, 0LL);
v6 = mbox_new(v3);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)create_signal_handler(v6) )
{
fwrite("Error when creating signal handler\n", 1uLL, 0x23uLL, stderr);
v8 = -1;
}
else
{
v8 = create_server(v7);
if ( v8 )
{
fwrite("Error when creating server. \n", 1uLL, 0x1DuLL, stderr);
v8 = -1;
}
else
{
parse_commands_from_input(v7);
puts("MAIN: Shutting down...");
puts("Wait for clients to properly finish....");
wait_for_clients();
puts("ALL clients gone");
puts("Wait for server to finish...");
shutdown_server();
wait_for_server_is_down();
puts("Server down");
mbox_free(v7);
if ( logfile != stdout )
fclose(logfile);
puts("Good bye!!");
}
}
}
else
{
puts("Error when creating mbox.");
v8 = -1;
}
return v8;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // er12
char v4; // al
FILE *v5; // rax
__int64 v6; // rax
__int64 v7; // rbx
int v8; // ebp
int result; // eax
sigset_t v10; // [rsp+0h] [rbp-98h] BYREF

logfile = stdout;
v3 = 32;
while ( 1 )
{
v4 = getopt(argc, (char *const *)argv, "+ho:n:s:m:c:");
if ( v4 == -1 )
break;
switch ( v4 )
{
case 'c':
default_client_type = atoi(optarg);
if ( default_client_type > 1u )
{
fwrite("Values supported for default_client_type: {0,1}\n", 1uLL, 0x30uLL, stderr);
exit(1);
}
return result;
case 'h':
func0(*argv);
exit(0);
case 'm':
nr_msgs = atoi(optarg);
if ( nr_msgs <= 0 )
{
fwrite("nr_msgs be greater than zero\n", 1uLL, 0x1DuLL, stderr);
exit(1);
}
return result;
case 'n':
v3 = atoi(optarg);
if ( !v3 )
{
fwrite("Mailbox size must be greater than zero\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
return result;
case 'o':
v5 = fopen(optarg, "w");
if ( !v5 )
{
fwrite("Can't open logfile\n", 1uLL, 0x13uLL, stderr);
exit(1);
}
logfile = v5;
break;
case 's':
nr_secs = atoi(optarg);
if ( nr_secs <= 0 )
{
fwrite("nr_secs size must be greater than zero\n", 1uLL, 0x27uLL, stderr);
exit(1);
}
return result;
default:
continue;
}
}
sigemptyset(&v10);
sigaddset(&v10, 1);
sigaddset(&v10, 2);
sigaddset(&v10, 10);
sigaddset(&v10, 12);
sigaddset(&v10, 14);
pthread_sigmask(0, &v10, 0LL);
v6 = mbox_new(v3);
v7 = v6;
if ( v6 )
{
if ( (unsigned int)create_signal_handler(v6) )
{
fwrite("Error when creating signal handler\n", 1uLL, 0x23uLL, stderr);
v8 = -1;
}
else
{
v8 = create_server(v7);
if ( v8 )
{
fwrite("Error when creating server. \n", 1uLL, 0x1DuLL, stderr);
v8 = -1;
}
else
{
func1(v7);
puts("MAIN: Shutting down...");
puts("Wait for clients to properly finish....");
func2();
puts("ALL clients gone");
puts("Wait for server to finish...");
shutdown_server();
func3();
puts("Server down");
mbox_free(v7);
if ( logfile != stdout )
fclose(logfile);
puts("Good bye!!");
}
}
}
else
{
puts("Error when creating mbox.");
v8 = -1;
}
return v8;
}

original_code:
int main(void) {
  pthread_t th1, th2;
  int num1[2]={ 1, 4999};
  int num2[2]={5000, 10000};
  pthread_create(&th1, ((void *)0), suma_parcial, (void*)num1);
  pthread_create(&th2, ((void *)0), suma_parcial, (void*)num2);
  printf("El thread principal continua ejecutando\n");
  pthread_join(th1, ((void *)0));
  pthread_join(th2, ((void *)0));
  printf("La suma total es: %d y debería ser (50005000)\n", suma_total);
  return 0;
}

canonical_original_code:
int main() {
  unsigned long th1; unsigned long th2;
  int num1[2] = { 1, 4999};
  int num2[2] = {5000, 10000};
  pthread_create(&th1, ((void *)0), suma_parcial, (void *)num1);
  pthread_create(&th2, ((void *)0), suma_parcial, (void *)num2);
  printf("El thread principal continua ejecutando\n");
  pthread_join(th1, ((void *)0));
  pthread_join(th2, ((void *)0));
  printf("La suma total es: %d y debería ser (50005000)\n", suma_total);
  return 0;
}


decompiled_code:
void __fastcall free_message(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
if ( *((_QWORD *)ptr + 2) )
counting_sem_free();
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
if ( *((_QWORD *)ptr + 2) )
counting_sem_free();
free(ptr);
}
}

original_code:
void free_message(message_t* m) {
 if (m!= ((void *)0)) {
  if (m->content != ((void *)0)) free(m->content);
  if (m->op_completed) counting_sem_free(m->op_completed);
  free(m);
 }
 m= ((void *)0);
}

canonical_original_code:
void free_message(struct _message_ *m) {
 if (m!= ((void *)0)) {
  if (m->content != ((void *)0)) free(m->content);
  if (m->op_completed) counting_sem_free(m->op_completed);
  free(m);
 }
 m= ((void *)0);
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4[2]; // [rsp+0h] [rbp-28h] BYREF
int arg[2]; // [rsp+8h] [rbp-20h] BYREF
pthread_t th; // [rsp+10h] [rbp-18h] BYREF
pthread_t newthread[2]; // [rsp+18h] [rbp-10h] BYREF

arg[0] = 1;
arg[1] = 4999;
v4[0] = 5000;
v4[1] = 10000;
pthread_create(newthread, 0LL, (void *(*)(void *))suma_parcial, arg);
pthread_create(&th, 0LL, (void *(*)(void *))suma_parcial, v4);
puts("El thread principal continua ejecutando");
pthread_join(newthread[0], 0LL);
pthread_join(th, 0LL);
printf(format, (unsigned int)suma_total);
return 0;
}


repo: Peaker/bindings-sophia

decompiled_code:
__int64 __fastcall sp_listappend(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
__int64 result; // rax

*a2 = a1;
v2 = *(_QWORD **)(a1 + 8);
a2[1] = v2;
*v2 = a2;
result = *a2;
*(_QWORD *)(*a2 + 8LL) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _QWORD *a2)
{
_QWORD *v2; // rax
__int64 result; // rax

*a2 = a1;
v2 = *(_QWORD **)(a1 + 8);
a2[1] = v2;
*v2 = a2;
result = *a2;
*(_QWORD *)(*a2 + 8LL) = a2;
return result;
}

original_code:
static inline void
sp_listappend(splist *h, splist *n) {
 n->next = h;
 n->prev = h->prev;
 n->prev->next = n;
 n->next->prev = n;
}

canonical_original_code:
static inline void sp_listappend(struct splist *h, struct splist *n) {
 n->next = h;
 n->prev = h->prev;
 n->prev->next = n;
 n->next->prev = n;
}

variable_types: struct splist { struct splist *next; } *

variable_types:
n
struct splist *


original_code:
static inline spv*
sp_vnewof(sp *s, void *k, uint16_t size, int reserve) {
 spv *v = sp_malloc(&s->a, sizeof(spv) + size + reserve);
 if (__builtin_expect(!! (v == ((void *)0)), 0))
  return ((void *)0);
 v->epoch = 0;
 v->size = size;
 v->flags = 0;
 memcpy(v->key, k, size);
 return v;
}

canonical_original_code:
static inline struct spv *sp_vnewof(struct sp *s, void *k, unsigned short size, int reserve) {
 struct spv *v = sp_malloc(&s->a, sizeof(spv) + size + reserve);
 if (__builtin_expect(!! (v == ((void *)0)), 0))
  return ((void *)0);
 v->epoch = 0;
 v->size = size;
 v->flags = 0;
 memcpy(v->key, k, size);
 return v;
}

variable_types: struct sp { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spenv { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spe { unsigned char lock; int type; int errno_; char e[256]; } e; int inuse; void *(*alloc)(void *ptr, unsigned long size, void *arg); void *allocarg; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; unsigned int flags; char *dir; int merge; unsigned int mergewm; unsigned int page; unsigned int dbnewsize; float dbgrow; int gc; float gcfactor; } *env; struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } a; struct sprep { struct spa *a; unsigned int epoch; struct splist { struct splist *next; } l; int n; int ndb; int nxfer; } rep; enum sptxn { SPTSS=0, SPTMS=1 } txn; struct spi { struct spa *a; int pagesize; struct spipage { unsigned short count; struct spv *i[]; } **i; unsigned int itop; unsigned int icount; unsigned int count; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *i; struct spi itxn; int iskip; unsigned long psn; struct spcat { struct spa *a; struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv *min; struct spv *max; struct splist link; } **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } s; struct spbatch { struct iovec { void *iov_base; unsigned long iov_len; } iov[1024]; int iovc; } lb; int stop; struct sptask { int run; void *arg; unsigned long id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } l; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } c; } merger; struct sprefset { struct spref { unsigned char type; union { struct spvh { unsigned int crc; unsigned int size; unsigned int voffset; unsigned int vsize; unsigned char flags; char key[]; } *vh; struct spv *v; } v; } *r; int used; int max; } refs; struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; } *

variable_types:
k
void *

variable_types:
size
unsigned short

variable_types: reserve int

variable_types: struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *

user_defined_types: struct sp { enum spmagic m; struct spenv *env; struct spa a; struct sprep rep; enum sptxn txn; struct spi *i; struct spi itxn; int iskip; unsigned long psn; struct spcat s; struct spbatch lb; int stop; struct sptask merger; struct sprefset refs; struct spfile lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; }

user_defined_types: struct sprep { struct spa *a; unsigned int epoch; struct splist l; int n; int ndb; int nxfer; }

user_defined_types: struct spcat { struct spa *a; struct sppage **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; }

user_defined_types: struct spbatch { struct iovec iov[1024]; int iovc; }

user_defined_types: struct sptask { int run; void *arg; unsigned long id; union pthread_mutex_t l; union pthread_cond_t c; }

user_defined_types: struct sprefset { struct spref *r; int used; int max; }

user_defined_types: struct spenv { enum spmagic m; struct spe e; int inuse; void *(*alloc)(void *ptr, unsigned long size, void *arg); void *allocarg; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; unsigned int flags; char *dir; int merge; unsigned int mergewm; unsigned int page; unsigned int dbnewsize; float dbgrow; int gc; float gcfactor; }

user_defined_types: struct spi { struct spa *a; int pagesize; struct spipage **i; unsigned int itop; unsigned int icount; unsigned int count; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; }

user_defined_types: struct spref { unsigned char type; union { struct spvh *vh; struct spv *v; } v; }


decompiled_code:
void *__fastcall sp_memdup(__int64 a1, const void *a2, size_t a3)
{
void *v4; // rax
void *v5; // rbx

v4 = (void *)sp_malloc(a1 + 16, a3);
v5 = v4;
if ( v4 )
memcpy(v4, a2, a3);
return v5;
}

canonical_decompiled_code:
void *__fastcall func6(__int64 a1, const void *a2, size_t a3)
{
void *v4; // rax
void *v5; // rbx

v4 = (void *)func3(a1 + 16, a3);
v5 = v4;
if ( v4 )
memcpy(v4, a2, a3);
return v5;
}

original_code:
char *sp_memdup(sp *s, void *src, size_t size)
{
 char *v = sp_malloc(&s->a, size);
 if (__builtin_expect(!! (v == ((void *)0)), 0))
  return ((void *)0);
 memcpy(v, src, size);
 return v;
}

canonical_original_code:
char *sp_memdup(struct sp *s, void *src, unsigned long size)
{
 char *v = sp_malloc(&s->a, size);
 if (__builtin_expect(!! (v == ((void *)0)), 0))
  return ((void *)0);
 memcpy(v, src, size);
 return v;
}

variable_types: struct sp { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spenv { enum spmagic { SPMCUR=357046582, SPMENV=102058036, SPMDB=16695550, SPMNONE=0 } m; struct spe { unsigned char lock; int type; int errno_; char e[256]; } e; int inuse; void *(*alloc)(void *ptr, unsigned long size, void *arg); void *allocarg; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; unsigned int flags; char *dir; int merge; unsigned int mergewm; unsigned int page; unsigned int dbnewsize; float dbgrow; int gc; float gcfactor; } *env; struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; } a; struct sprep { struct spa *a; unsigned int epoch; struct splist { struct splist *next; } l; int n; int ndb; int nxfer; } rep; enum sptxn { SPTSS=0, SPTMS=1 } txn; struct spi { struct spa *a; int pagesize; struct spipage { unsigned short count; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *i[]; } **i; unsigned int itop; unsigned int icount; unsigned int count; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } *i; struct spi itxn; int iskip; unsigned long psn; struct spcat { struct spa *a; struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv *min; struct spv *max; struct splist link; } **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; } s; struct spbatch { struct iovec { void *iov_base; unsigned long iov_len; } iov[1024]; int iovc; } lb; int stop; struct sptask { int run; void *arg; unsigned long id; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } l; union pthread_cond_t { struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; } __data; char __size[48]; long long __align; } c; } merger; struct sprefset { struct spref { unsigned char type; union { struct spvh { unsigned int crc; unsigned int size; unsigned int voffset; unsigned int vsize; unsigned char flags; char key[]; } *vh; struct spv *v; } v; } *r; int used; int max; } refs; struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; } lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; } *

variable_types:
src
void *

variable_types:
size
unsigned long

variable_types:
v
char *

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: union pthread_cond_t { struct __pthread_cond_s __data; char __size[48]; long long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }

user_defined_types: struct spipage { unsigned short count; struct spv *i[]; }


decompiled_code:
__int64 __fastcall sp_pageattach(__int64 a1)
{
return sp_listappend(*(_QWORD *)(a1 + 16) + 160LL, (_QWORD *)(a1 + 44));
}

original_code:
void sp_pageattach(sppage *p) {
 ((void) (0));
 sp_listappend(&((spepoch*)p->epoch)->pages, &p->link);
}

canonical_original_code:
void sp_pageattach(struct sppage *p) {
 ((void) (0));
 sp_listappend(&((struct spepoch *)p->epoch)->pages, &p->link);
}

variable_types: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; } *min; struct spv *max; struct splist { struct splist *next; } link; } *

user_defined_types: struct sppage { unsigned long id; unsigned long offset; void *epoch; unsigned int size; struct spv *min; struct spv *max; struct splist link; }

user_defined_types: struct spepoch { unsigned int epoch; unsigned int n; unsigned int ngc; unsigned int nupdate; enum spepochtype type; unsigned int recover; struct spfile log; unsigned char lock; struct splist pages; struct splist link; }

user_defined_types: enum spepochtype { SPUNDEF=0, SPLIVE=1, SPXFER=2, SPDB=3 }

user_defined_types: struct spfile { struct spa *a; int creat; unsigned long used; unsigned long size; unsigned long svp; char *file; int fd; char *map; }

user_defined_types: struct spa { void *(*alloc)(void *ptr, unsigned long size, void *arg); void *arg; }


decompiled_code:
__int64 __fastcall sp_pagedetach(__int64 a1)
{
return sp_listunlink((__int64 *)(a1 + 44));
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return func2((__int64 *)(a1 + 44));
}

original_code:
void sp_pagedetach(sppage *p) {
 ((void) (0));
 sp_listunlink(&p->link);
}

canonical_original_code:
void sp_pagedetach(struct sppage *p) {
 ((void) (0));
 sp_listunlink(&p->link);
}

user_defined_types: struct spv { unsigned int epoch; unsigned int crc; unsigned short size; unsigned char flags; char key[]; }


original_code:
void sp_pagefree(sp *s, sppage *p) {
 sp_listunlink(&p->link);
 sp_free(&s->a, p->min);
 sp_free(&s->a, p->max);
 sp_free(&s->a, p);
}

canonical_original_code:
void sp_pagefree(struct sp *s, struct sppage *p) {
 sp_listunlink(&p->link);
 sp_free(&s->a, p->min);
 sp_free(&s->a, p->max);
 sp_free(&s->a, p);
}

variable_types:
p
struct sppage *

user_defined_types: struct sp { enum spmagic m; struct spenv *env; struct spa a; struct sprep rep; enum sptxn txn; struct spi *i; struct spi itxn; int iskip; unsigned long psn; struct spcat s; struct spbatch lb; int stop; struct sptask merger; struct sprefset refs; struct spfile lockdb; int lockc; unsigned char lockr; unsigned char locks; unsigned char locki; struct spe e; }

user_defined_types: struct sprep { struct spa *a; unsigned int epoch; struct splist l; int n; int ndb; int nxfer; }

user_defined_types: struct spcat { struct spa *a; struct sppage **i; unsigned int count; unsigned int top; int (*cmp)(char *a, unsigned long asz, char *b, unsigned long bsz, void *arg); void *cmparg; }

user_defined_types: struct spe { unsigned char lock; int type; int errno_; char e[256]; }

user_defined_types: struct iovec { void *iov_base; unsigned long iov_len; }

user_defined_types: struct __pthread_cond_s { union { unsigned long long __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; union { unsigned long long __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2]; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }

user_defined_types: struct spvh { unsigned int crc; unsigned int size; unsigned int voffset; unsigned int vsize; unsigned char flags; char key[]; }