readBytes

decompiled_code:
__int64 __fastcall readBytes(int fd, __int64 a2, unsigned int a3)
{
unsigned int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // eax

v3 = a3;
if ( a3 )
{
v4 = 0;
while ( 1 )
{
v5 = recv(fd, (void *)(a2 + (int)v4), (int)(v3 - v4), 0);
a3 = v5;
if ( !v5 || v5 == -1 )
break;
v4 += v5;
if ( v3 == v5 )
return v4;
}
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func1(int fd, __int64 a2, unsigned int a3)
{
unsigned int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // eax

v3 = a3;
if ( a3 )
{
v4 = 0;
while ( 1 )
{
v5 = recv(fd, (void *)(a2 + (int)v4), (int)(v3 - v4), 0);
a3 = v5;
if ( !v5 || v5 == -1 )
break;
v4 += v5;
if ( v3 == v5 )
return v4;
}
}
return a3;
}

original_code:
int readBytes(SOCKET s, char *ptr, int bytes2read, int timeout)
{
 int len = 0;
 int res = 0;
 while (res != bytes2read) {
  res = recv(s, ptr + len, bytes2read - len, 0);
  if (res == 0) {
   return 0;
  } else if (res == -1) {
   return -1;
  }
  len += res;
 }
 return len;
}

canonical_original_code:
int readBytes(int s, char *ptr, int bytes2read, int timeout)
{
 int len = 0;
 int res = 0;
 while (res != bytes2read) {
  res = recv(s, ptr + len, bytes2read - len, 0);
  if (res == 0) {
   return 0;
  } else if (res == -1) {
   return -1;
  }
  len += res;
 }
 return len;
}

variable_types: s int

variable_types: timeout int

variable_types: len int

variable_types: res int


readWords

repo: sergforce/iscsi

original_code:
int readWords(SOCKET s, uint32_t *ptr, int bytes2read, int timeout)
{
 int len = 0;
 int res = readBytes(s, (char*)ptr, bytes2read, timeout);
 if (res != bytes2read) {
  return -1;
 }
 for (len = 0; len < bytes2read; len += sizeof(uint32_t), ptr++) {
  *ptr = ntohl(*ptr);
 }
 return len;
}

canonical_original_code:
int readWords(int s, unsigned int *ptr, int bytes2read, int timeout)
{
 int len = 0;
 int res = readBytes(s, (char*)ptr, bytes2read, timeout);
 if (res != bytes2read) {
  return -1;
 }
 for (len = 0; len < bytes2read; len += sizeof(unsigned int), ptr++) {
  *ptr = ntohl(*ptr);
 }
 return len;
}

variable_types:
ptr
unsigned int *

return_type: int


writeBytes

decompiled_code:
__int64 __fastcall writeBytes(int fd, __int64 a2, unsigned int a3)
{
unsigned int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // eax

v3 = a3;
if ( a3 )
{
v4 = 0;
while ( 1 )
{
v5 = send(fd, (const void *)(a2 + (int)v4), (int)(v3 - v4), 0);
a3 = v5;
if ( !v5 || v5 == -1 )
break;
v4 += v5;
if ( v3 == v5 )
return v4;
}
}
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func3(int fd, __int64 a2, unsigned int a3)
{
unsigned int v3; // ebp
unsigned int v4; // ebx
unsigned int v5; // eax

v3 = a3;
if ( a3 )
{
v4 = 0;
while ( 1 )
{
v5 = send(fd, (const void *)(a2 + (int)v4), (int)(v3 - v4), 0);
a3 = v5;
if ( !v5 || v5 == -1 )
break;
v4 += v5;
if ( v3 == v5 )
return v4;
}
}
return a3;
}

original_code:
int writeBytes(SOCKET s, char *ptr, int bytes2write, int timeout)
{
 int len = 0;
 int res = 0;
 while (res != bytes2write) {
  res = send(s, ptr + len, bytes2write - len, 0);
  if (res == 0) {
   return 0;
  } else if (res == -1) {
   return -1;
  }
  len += res;
 }
 return len;
}

canonical_original_code:
int writeBytes(int s, char *ptr, int bytes2write, int timeout)
{
 int len = 0;
 int res = 0;
 while (res != bytes2write) {
  res = send(s, ptr + len, bytes2write - len, 0);
  if (res == 0) {
   return 0;
  } else if (res == -1) {
   return -1;
  }
  len += res;
 }
 return len;
}

variable_types:
ptr
char *


writeWords

original_code:
int writeWords(SOCKET s, uint32_t *ptr, int bytes2write, int timeout)
{
 int len;
 int res;
 uint32_t *tmp = ptr;
 for (len = 0; len < bytes2write; len += sizeof(uint32_t), tmp++) {
  *tmp = htonl(*tmp);
 }
 res = writeBytes(s, (char*)ptr, bytes2write, timeout);
 return res;
}

canonical_original_code:
int writeWords(int s, unsigned int *ptr, int bytes2write, int timeout)
{
 int len;
 int res;
 unsigned int *tmp = ptr;
 for (len = 0; len < bytes2write; len += sizeof(unsigned int), tmp++) {
  *tmp = htonl(*tmp);
 }
 res = writeBytes(s, (char *)ptr, bytes2write, timeout);
 return res;
}

variable_types:
tmp
unsigned int *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax

while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "c:dD");
if ( v3 == -1 )
break;
if ( v3 == 99 )
{
strncpy(inifile, optarg, 0xFFuLL);
inifile[255] = 0;
}
else if ( (v3 & 0xFFFFFFDF) != 68 )
{
fprintf(stderr, "Usage: %s [-c configuration] [-d]\n", *argv);
exit(1);
}
}
targetTest();
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 int daemonize = 0;
 int debug = 0;
 int opt;
 while ((opt = getopt(argc, argv, "c:dD")) != -1) {
  switch (opt) {
  case 'D':
   debug = 1;
   break;
  case 'd':
   daemonize = 1;
   break;
  case 'c':
   strncpy(inifile, optarg, 255);
   inifile[255] = 0;
   break;
  default:
   fprintf(stderr, "Usage: %s [-c configuration] [-d]\n",
    argv[0]);
   exit(1);
  }
 }
 targetTest();
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int daemonize = 0;
 int debug = 0;
 int opt;
 while ((opt = getopt(argc, argv, "c:dD")) != -1) {
  switch (opt) {
  case 'D':
   debug = 1;
   break;
  case 'd':
   daemonize = 1;
   break;
  case 'c':
   strncpy(inifile, optarg, 255);
   inifile[255] = 0;
   break;
  default:
   fprintf(stderr, "Usage: %s [-c configuration] [-d]\n",
    argv[0]);
   exit(1);
  }
 }
 targetTest();
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: daemonize int

variable_types: debug int

variable_types: opt int


findElement

decompiled_code:
const char *__fastcall findElement(const char *a1, const char *a2)
{
const char *v2; // rbx

if ( !a1 )
return 0LL;
v2 = a1;
while ( strcmp(v2 + 40, a2) )
{
v2 = *(const char **)v2;
if ( a1 == v2 )
return 0LL;
}
return v2;
}

canonical_decompiled_code:
const char *__fastcall func1(const char *a1, const char *a2)
{
const char *v2; // rbx

if ( !a1 )
return 0LL;
v2 = a1;
while ( strcmp(v2 + 40, a2) )
{
v2 = *(const char **)v2;
if ( a1 == v2 )
return 0LL;
}
return v2;
}

original_code:
struct confElement *findElement(struct confElement *el, const char *name)
{
 int res;
 struct confElement *elFirst = el;
 if (el == ((void *)0)) {
  return ((void *)0);
 }
 do {
  res = strcmp(el->name, name);
  if (res == 0) {
   return el;
  }
  el = el->list.next;
 } while (el != elFirst);
 return ((void *)0);
}

canonical_original_code:
struct confElement *findElement(struct confElement *el, char *name)
{
 int res;
 struct confElement *elFirst = el;
 if (el == ((void *)0)) {
  return ((void *)0);
 }
 do {
  res = strcmp(el->name, name);
  if (res == 0) {
   return el;
  }
  el = el->list.next;
 } while (el != elFirst);
 return ((void *)0);
}

variable_types:
el
struct confElement *

variable_types:
name
char *

variable_types: struct confElement { struct confElemList { struct confElement *next; struct confElement *prev; } list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; } *

user_defined_types: struct confElement { struct confElemList list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; }


findMain

decompiled_code:
const char *__fastcall findMain(const char **a1, const char *a2)
{
return findElement(*a1, a2);
}

canonical_decompiled_code:
const char *__fastcall func2(const char **a1, const char *a2)
{
return func1(*a1, a2);
}

original_code:
struct confElement *findMain(struct configuration *cnf, const char *name)
{
 return findElement(cnf->head, name);
}

canonical_original_code:
struct confElement *findMain(struct configuration *cnf, char *name)
{
 return findElement(cnf->head, name);
}

variable_types: struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; } *

return_type: struct confElement { struct confElemList { struct confElement *next; struct confElement *prev; } list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; } *


getValue

decompiled_code:
const char *__fastcall getValue(const char *a1, const char *a2)
{
const char *result; // rax

result = findElement(a1, a2);
if ( result )
result += 150;
return result;
}

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

result = func1(a1, a2);
if ( result )
result += 150;
return result;
}

original_code:
const char *getValue(struct confElement *main, const char *name)
{
 struct confElement *el = findElement(main, name);
 return ((el != ((void *)0)) ? el->value : ((void *)0));
}

canonical_original_code:
char *getValue(struct confElement *main, char *name)
{
 struct confElement *el = findElement(main, name);
 return ((el != ((void *)0)) ? el->value : ((void *)0));
}

return_type: char *

user_defined_types: struct confElemList { struct confElement *next; struct confElement *prev; }


getValueDef

decompiled_code:
const char *__fastcall getValueDef(const char *a1, const char *a2, const char *a3)
{
const char *result; // rax

result = getValue(a1, a2);
if ( !result )
result = a3;
return result;
}

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

result = func3(a1, a2);
if ( !result )
result = a3;
return result;
}

original_code:
const char *getValueDef(struct confElement *main, const char *name, const char *def)
{
 const char *val = getValue(main, name);
 return ((val != ((void *)0)) ? val : def);
}

canonical_original_code:
char *getValueDef(struct confElement *main, char *name, char *def)
{
 char *val = getValue(main, name);
 return ((val != ((void *)0)) ? val : def);
}

variable_types:
def
char *

variable_types:
val
char *


allocElement

decompiled_code:
__int64 __fastcall allocElement(__int64 a1)
{
return allocNode(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return allocNode(a1 + 8);
}

original_code:
struct confElement *allocElement(struct configuration *cnf)
{
 return (struct confElement *)allocNode((struct DCirList **)&cnf->free);
}

user_defined_types: struct configuration { struct confElement *head; struct confElement *free; struct confElement pool[128]; }

user_defined_types: struct DCirList { struct DCirList *next; struct DCirList *prev; }


addElementFill

decompiled_code:
__int64 __fastcall addElementFill(__int64 *a1, __int64 a2, const char *a3, const char *a4)
{
__int64 v6; // rax
__int64 v7; // rbx
size_t v8; // rax
size_t v9; // rax

v6 = allocElement((__int64)a1);
v7 = v6;
if ( v6 )
{
*(_QWORD *)(v6 + 16) = a2;
*(_QWORD *)(v6 + 24) = 0LL;
v8 = strlen(a3);
if ( v8 > 0x6E )
LODWORD(v8) = 110;
*(_DWORD *)(v7 + 32) = v8;
v9 = strlen(a4);
if ( v9 > 0x78 )
LODWORD(v9) = 120;
*(_DWORD *)(v7 + 36) = v9;
strncpy((char *)(v7 + 40), a3, 0x6EuLL);
strncpy((char *)(v7 + 150), a4, 0x78uLL);
if ( a2 )
{
addNode(v7, a2 + 24);
}
else if ( *a1 )
{
addNode(v7, a1);
}
else
{
*a1 = v7;
}
}
return v7;
}

original_code:
struct confElement *addElementFill(struct configuration *cnf, struct confElement *el, const char *name, const char *value)
{
 struct confElement *elNew = allocElement(cnf);
 if (elNew == ((void *)0)) {
  return ((void *)0);
 }
 elNew->parent = el;
 elNew->childs = ((void *)0);
 elNew->cbName = (((strlen(name)) > (110)) ? (110) : (strlen(name)));
 elNew->cbValue = (((strlen(value)) > (120)) ? (120) : (strlen(value)));
 strncpy(elNew->name, name, 110);
 strncpy(elNew->value, value, 120);
 if (el) {
  addNode((struct DCirList *)elNew, (struct DCirList **)&el->childs);
 } else if (cnf->head) {
  addNode((struct DCirList *)elNew, (struct DCirList **)&cnf->head);
 } else {
  cnf->head = elNew;
 }
 return elNew;
}

canonical_original_code:
struct confElement *addElementFill(struct configuration *cnf, struct confElement *el, char *name, char *value)
{
 struct confElement *elNew = allocElement(cnf);
 if (elNew == ((void *)0)) {
  return ((void *)0);
 }
 elNew->parent = el;
 elNew->childs = ((void *)0);
 elNew->cbName = (((strlen(name)) > (110)) ? (110) : (strlen(name)));
 elNew->cbValue = (((strlen(value)) > (120)) ? (120) : (strlen(value)));
 strncpy(elNew->name, name, 110);
 strncpy(elNew->value, value, 120);
 if (el) {
  addNode((struct DCirList *)elNew, (struct DCirList **)&el->childs);
 } else if (cnf->head) {
  addNode((struct DCirList *)elNew, (struct DCirList **)&cnf->head);
 } else {
  cnf->head = elNew;
 }
 return elNew;
}

variable_types:
value
char *


addElement

decompiled_code:
__int64 __fastcall addElement(__int64 a1, __int64 a2)
{
return addNode(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return addNode(a1, a2);
}

original_code:
struct confElement *addElement(struct confElement *elNew, struct confElement **elAfter)
{
 return (struct confElement *)addNode((struct DCirList *)elNew, (struct DCirList **)elAfter);
}

variable_types:
elNew
struct confElement *

variable_types:
elAfter
struct confElement **


addMain

decompiled_code:
__int64 __fastcall addMain(__int64 *a1, const char *a2, const char *a3)
{
return addElementFill(a1, *a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1, const char *a2, const char *a3)
{
return func6(a1, *a1, a2, a3);
}

original_code:
struct confElement *addMain(struct configuration *cnf, const char *name, const char *value)
{
 return addElementFill(cnf, cnf->head, name, value);
}

canonical_original_code:
struct confElement *addMain(struct configuration *cnf, char *name, char *value)
{
 return addElementFill(cnf, cnf->head, name, value);
}


removeElement

decompiled_code:
__int64 __fastcall removeElement(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
__int64 result; // rax

while ( *(_QWORD *)(a2 + 24) )
{
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
removeElement(a1);
}
v3 = *(_QWORD *)(a2 + 16);
if ( v3 )
result = moveNode(a2, v3 + 24, a1 + 8);
else
result = moveNode(a2, a1, a1 + 8);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
__int64 v3; // rsi
__int64 result; // rax

while ( *(_QWORD *)(a2 + 24) )
{
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
if ( !*(_QWORD *)(a2 + 24) )
break;
func9(a1);
}
v3 = *(_QWORD *)(a2 + 16);
if ( v3 )
result = moveNode(a2, v3 + 24, a1 + 8);
else
result = moveNode(a2, a1, a1 + 8);
return result;
}

original_code:
void removeElement(struct configuration *cnf, struct confElement *el)
{
 while (el->childs != ((void *)0)) {
  removeElement(cnf, el->childs);
 }
 if (el->parent == ((void *)0)) {
  moveNode((struct DCirList *)el, (struct DCirList **)&cnf->head, (struct DCirList **)&cnf->free);
 } else {
  moveNode((struct DCirList *)el, (struct DCirList **)&el->parent->childs,
           (struct DCirList **)&cnf->free);
 }
}

variable_types: struct configuration { struct confElement { struct confElemList { struct confElement *next; struct confElement *prev; } list; struct confElement *parent; struct confElement *childs; int cbName; int cbValue; char name[110]; char value[120]; } *head; struct confElement *free; struct confElement pool[128]; } *

return_type: void


getElemInt

decompiled_code:
const char *__fastcall getElemInt(__int64 a1, const char *a2, __int64 a3)
{
const char *v4; // rax
const char *v5; // rbx

v4 = findElement(*(const char **)(a1 + 24), a2);
v5 = v4;
if ( v4 && (unsigned int)_isoc99_sscanf(v4 + 150, &unk_2BD, a3) != 1 )
v5 = 0LL;
return v5;
}

canonical_decompiled_code:
const char *__fastcall func10(__int64 a1, const char *a2, __int64 a3)
{
const char *v4; // rax
const char *v5; // rbx

v4 = func1(*(const char **)(a1 + 24), a2);
v5 = v4;
if ( v4 && (unsigned int)_isoc99_sscanf(v4 + 150, &unk_2BD, a3) != 1 )
v5 = 0LL;
return v5;
}

original_code:
struct confElement *getElemInt(struct confElement *head, const char *paramName, int *value)
{
 struct confElement *el = findElement(head->childs, paramName);
 if (el) {
  if (sscanf(el->value, "%d", value) == 1) {
   return el;
  }
 }
 return ((void *)0);
}

canonical_original_code:
struct confElement *getElemInt(struct confElement *head, char *paramName, int *value)
{
 struct confElement *el = findElement(head->childs, paramName);
 if (el) {
  if (sscanf(el->value, "%d", value) == 1) {
   return el;
  }
 }
 return ((void *)0);
}

variable_types:
head
struct confElement *

variable_types:
paramName
char *

variable_types:
value
int *


decompiled_code:
unsigned __int64 __fastcall crc32c(_BYTE *a1, int a2)
{
_BYTE *v2; // rdx
__int64 v3; // rcx
unsigned __int64 v4; // rax
int v5; // esi
unsigned __int64 v6; // rax
__int64 v7; // r9
__int64 v8; // r11
unsigned __int8 v9; // r10

if ( a2 )
{
v2 = a1;
v3 = (__int64)&a1[a2 - 1 + 1];
v4 = -1LL;
v5 = a2 & 7;
if ( !v5 )
goto LABEL_22;
if ( v5 != 1LL )
{
if ( v5 != 2LL )
{
if ( v5 != 3LL )
{
if ( v5 != 4LL )
{
if ( v5 != 5LL )
{
if ( v5 != 6LL )
{
v4 = crc_c[(unsigned __int8)~*a1] ^ 0xFFFFFFFFFFFFFFLL;
v2 = a1 + 1;
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
if ( v2 != (_BYTE *)v3 )
{
LABEL_22:
do
{
v6 = crc_c[(unsigned __int8)(v2[3] ^ LOBYTE(crc_c[(unsigned __int8)(v2[2] ^ LOBYTE(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ ((unsigned int)v4 >> 8)) >> 8))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((LODWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ (unsigned int)(v4 >> 8)) >> 8)) >> 8))] ^ ((crc_c[(unsigned __int8)(v2[2] ^ LOBYTE(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ ((unsigned int)v4 >> 8)) >> 8))] ^ ((crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))] ^ ((crc_c[(unsigned __int8)(*v2 ^ v4)] ^ (v4 >> 8)) >> 8)) >> 8)) >> 8);
v7 = (unsigned __int8)(v2[4] ^ v6);
v8 = (unsigned __int8)(v2[5] ^ LOBYTE(crc_c[v7]) ^ BYTE1(v6));
v9 = v2[6] ^ LOBYTE(crc_c[v8]) ^ ((unsigned __int16)(LOWORD(crc_c[v7]) ^ ((unsigned int)v6 >> 8)) >> 8);
v4 = crc_c[(unsigned __int8)(v2[7] ^ LOBYTE(crc_c[v9]) ^ ((unsigned __int16)(LOWORD(crc_c[v8]) ^ ((LODWORD(crc_c[v7]) ^ (unsigned int)(v6 >> 8)) >> 8)) >> 8))] ^ ((crc_c[v9] ^ ((crc_c[v8] ^ ((crc_c[v7] ^ (v6 >> 8)) >> 8)) >> 8)) >> 8);
v2 += 8;
}
while ( v2 != (_BYTE *)v3 );
}
}
else
{
v4 = -1LL;
}
return ~v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func0(_BYTE *a1, int a2)
{
_BYTE *v2; // rdx
__int64 v3; // rcx
unsigned __int64 v4; // rax
int v5; // esi
unsigned __int64 v6; // rax
__int64 v7; // r9
__int64 v8; // r11
unsigned __int8 v9; // r10

if ( a2 )
{
v2 = a1;
v3 = (__int64)&a1[a2 - 1 + 1];
v4 = -1LL;
v5 = a2 & 7;
if ( !v5 )
goto LABEL_22;
if ( v5 != 1LL )
{
if ( v5 != 2LL )
{
if ( v5 != 3LL )
{
if ( v5 != 4LL )
{
if ( v5 != 5LL )
{
if ( v5 != 6LL )
{
v4 = crc_c[(unsigned __int8)~*a1] ^ 0xFFFFFFFFFFFFFFLL;
v2 = a1 + 1;
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
}
v4 = crc_c[(unsigned __int8)(*v2++ ^ v4)] ^ (v4 >> 8);
if ( v2 != (_BYTE *)v3 )
{
LABEL_22:
do
{
v6 = crc_c[(unsigned __int8)(v2[3] ^ LOBYTE(crc_c[(unsigned __int8)(v2[2] ^ LOBYTE(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ ((unsigned int)v4 >> 8)) >> 8))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((LODWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ (unsigned int)(v4 >> 8)) >> 8)) >> 8))] ^ ((crc_c[(unsigned __int8)(v2[2] ^ LOBYTE(crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))]) ^ ((unsigned __int16)(LOWORD(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ ((unsigned int)v4 >> 8)) >> 8))] ^ ((crc_c[(unsigned __int8)(v2[1] ^ LOBYTE(crc_c[(unsigned __int8)(*v2 ^ v4)]) ^ BYTE1(v4))] ^ ((crc_c[(unsigned __int8)(*v2 ^ v4)] ^ (v4 >> 8)) >> 8)) >> 8)) >> 8);
v7 = (unsigned __int8)(v2[4] ^ v6);
v8 = (unsigned __int8)(v2[5] ^ LOBYTE(crc_c[v7]) ^ BYTE1(v6));
v9 = v2[6] ^ LOBYTE(crc_c[v8]) ^ ((unsigned __int16)(LOWORD(crc_c[v7]) ^ ((unsigned int)v6 >> 8)) >> 8);
v4 = crc_c[(unsigned __int8)(v2[7] ^ LOBYTE(crc_c[v9]) ^ ((unsigned __int16)(LOWORD(crc_c[v8]) ^ ((LODWORD(crc_c[v7]) ^ (unsigned int)(v6 >> 8)) >> 8)) >> 8))] ^ ((crc_c[v9] ^ ((crc_c[v8] ^ ((crc_c[v7] ^ (v6 >> 8)) >> 8)) >> 8)) >> 8);
v2 += 8;
}
while ( v2 != (_BYTE *)v3 );
}
}
else
{
v4 = -1LL;
}
return ~v4;
}

original_code:
unsigned long crc32c(const unsigned char *buffer, unsigned int length)
{
  unsigned int i;
  unsigned long crc32 = ~0L;
  unsigned long result;
  for (i = 0; i < length; i++){
      (crc32=(crc32>>8)^crc_c[(crc32^(buffer[i]))&0xFF]);
  }
  result = ~crc32;
  return ( result );
}

canonical_original_code:
unsigned long crc32c(unsigned char *buffer, unsigned int length)
{
  unsigned int i;
  unsigned long crc32 = ~0L;
  unsigned long result;
  for (i = 0; i < length; i++){
      (crc32=(crc32>>8)^crc_c[(crc32^(buffer[i]))&0xFF]);
  }
  result = ~crc32;
  return ( result );
}

variable_types:
buffer
unsigned char *

variable_types:
length
unsigned int

variable_types:
i
unsigned int

variable_types:
result
unsigned long

return_type: unsigned long


addNode

decompiled_code:
__int64 __fastcall addNode(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rsi

result = *a2;
if ( *a2 )
{
**(_QWORD **)(result + 8) = a1;
**(_QWORD **)(a1 + 8) = result;
v3 = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = *(_QWORD *)(result + 8);
*(_QWORD *)(result + 8) = v3;
}
else
{
*a2 = a1;
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rsi

result = *a2;
if ( *a2 )
{
**(_QWORD **)(result + 8) = a1;
**(_QWORD **)(a1 + 8) = result;
v3 = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 8) = *(_QWORD *)(result + 8);
*(_QWORD *)(result + 8) = v3;
}
else
{
*a2 = a1;
result = a1;
}
return result;
}

original_code:
struct DCirList *addNode(struct DCirList *node, struct DCirList **listTo)
{
 struct DCirList *to = *listTo;
 struct DCirList *tmp;
 if (to == ((void *)0)) {
  to = *listTo = node;
 } else {
  to->prev->next = node;
  node->prev->next = to;
  tmp = node->prev;
  node->prev = to->prev;
  to->prev = tmp;
 }
 return to;
}

variable_types:
node
struct DCirList *

variable_types:
listTo
struct DCirList **

variable_types: struct DCirList { struct DCirList *next; struct DCirList *prev; } *


moveNode

decompiled_code:
__int64 __fastcall moveNode(__int64 *a1, __int64 **a2, __int64 *a3)
{
__int64 *v4; // rdx
__int64 result; // rax

v4 = removeNode(a1, a2);
result = 0LL;
if ( a1 == v4 )
result = addNode((__int64)a1, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 *a1, __int64 **a2, __int64 *a3)
{
__int64 *v4; // rdx
__int64 result; // rax

v4 = removeNode(a1, a2);
result = 0LL;
if ( a1 == v4 )
result = func2((__int64)a1, a3);
return result;
}

original_code:
struct DCirList *moveNode(struct DCirList *node, struct DCirList **listFrom, struct DCirList **listTo)
{
 if (removeNode(node, listFrom) == node) {
  return addNode(node, listTo);
 }
 return ((void *)0);
}

variable_types:
listFrom
struct DCirList **

return_type: struct DCirList { struct DCirList *next; struct DCirList *prev; } *


init

repo: sergioalberto/MyPthreadOS

decompiled_code:
int *init()
{
int *result; // rax

sem_init(&mutex, 0, 1u);
pthread_attr_init(&attr);
sem_init(&cFull, 0, 0);
sem_init(&cEmpty, 0, 0x13u);
cg = 0;
thread = 1;
students = 0;
teacher = 0;
result = &buffer;
do
*result++ = 33;
while ( result != (int *)&unk_4041AC );
return result;
}

canonical_decompiled_code:
int *func7()
{
int *result; // rax

sem_init(&mutex, 0, 1u);
pthread_attr_init(&attr);
sem_init(&cFull, 0, 0);
sem_init(&cEmpty, 0, 0x13u);
cg = 0;
thread = 1;
students = 0;
teacher = 0;
result = &buffer;
do
*result++ = 33;
while ( result != (int *)&unk_4041AC );
return result;
}

original_code:
void init() {
 int c2;
 sem_init(&mutex, 0, 1);
 pthread_attr_init(&attr);
 sem_init(&cFull, 0, 0);
 sem_init(&cEmpty, 0, 19);
 cg = 0;
 thread = 1;
 students = 0;
 teacher = 0;
 for(c2=0; c2<19; c2++){
  buffer[c2] = 33;
 }
}


randInt

decompiled_code:
__int64 randInt()
{
return (unsigned int)(rand() % 100);
}

canonical_decompiled_code:
__int64 func8()
{
return (unsigned int)(rand() % 100);
}

original_code:
int randInt() {
    return rand() % 100;
}

canonical_original_code:
int randInt() {
    return rand() % 100;
}


generarSolicitudImpresion

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

v1 = cg;
if ( cg > 18 )
return 0xFFFFFFFFLL;
if ( a1 )
++teacher;
else
++students;
buffer[cg] = a1;
cg = v1 + 1;
return 0LL;
}

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

v1 = cg;
if ( cg > 18 )
return 0xFFFFFFFFLL;
if ( a1 )
++teacher;
else
++students;
buffer[cg] = a1;
cg = v1 + 1;
return 0LL;
}

original_code:
int generarSolicitudImpresion(buffer_item item){
 if(cg < 19)
 {
  if (item == 0){
   students ++;
  }else{
   teacher ++;
  }
  buffer[cg] = item;
  cg ++;
  return 0;
 }else
 {
  return -1;
 }
}

canonical_original_code:
int generarSolicitudImpresion(int item){
 if(cg < 19)
 {
  if (item == 0){
   students ++;
  }else{
   teacher ++;
  }
  buffer[cg] = item;
  cg ++;
  return 0;
 }else
 {
  return -1;
 }
}

variable_types: item int


producer

decompiled_code:
int __fastcall producer(void *a1)
{
unsigned int v1; // ebx

sleep(1u);
v1 = *((_DWORD *)a1 + 1);
sem_wait(&cEmpty);
sem_wait(&mutex);
if ( (unsigned int)generarSolicitudImpresion(v1) )
fwrite("Producer error", 1uLL, 0xEuLL, _bss_start);
else
printf("Ingreso un: %d\n", v1);
sem_post(&mutex);
return sem_post(&cFull);
}

canonical_decompiled_code:
int __fastcall func10(void *a1)
{
unsigned int v1; // ebx

sleep(1u);
v1 = *((_DWORD *)a1 + 1);
sem_wait(&cEmpty);
sem_wait(&mutex);
if ( (unsigned int)func9(v1) )
fwrite("Producer error", 1uLL, 0xEuLL, _bss_start);
else
printf("Ingreso un: %d\n", v1);
sem_post(&mutex);
return sem_post(&cFull);
}

original_code:
void *producer(void *param){
 buffer_item item;
 datasClient *message;
 message = (datasClient*)param;
 sleep(1);
 item = message->IdClient;
 sem_wait(&cEmpty);
 sem_wait(&mutex);
 if(generarSolicitudImpresion(item)){
  fprintf(stderr, "Producer error");
 }
 else{
  printf("Ingreso un: %d\n", item);
 }
 sem_post(&mutex);
 sem_post(&cFull);
}

canonical_original_code:
void *producer(void *param){
 int item;
 struct datasClient *message;
 message = (struct datasClient *)param;
 sleep(1);
 item = message->IdClient;
 sem_wait(&cEmpty);
 sem_wait(&mutex);
 if(generarSolicitudImpresion(item)){
  fprintf(stderr, "Producer error");
 }
 else{
  printf("Ingreso un: %d\n", item);
 }
 sem_post(&mutex);
 sem_post(&cFull);
}

variable_types:
param
void *

variable_types: struct datasClient { int Idthread; int IdClient; } *

return_type: void *


search

decompiled_code:
__int64 __fastcall search(int a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = 0LL;
while ( 1 )
{
v2 = buffer[v1];
if ( v2 == 1 )
break;
if ( ++v1 == 19 )
return (unsigned int)buffer[a1];
}
buffer[(int)v1] = buffer[a1];
buffer[a1] = 1;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
__int64 v1; // rax
unsigned int v2; // edx

v1 = 0LL;
while ( 1 )
{
v2 = buffer[v1];
if ( v2 == 1 )
break;
if ( ++v1 == 19 )
return (unsigned int)buffer[a1];
}
buffer[(int)v1] = buffer[a1];
buffer[a1] = 1;
return v2;
}

original_code:
int search(int position){
 int result = 50;
 int i = 0;
 int pos = 0;
 int flag = 0;
 for(i=0; i < 19; i++){
  if(buffer[i] == 1){
   pos = i;
   flag = 1;
   break;
  }
 }
 if(flag == 1){
  result = buffer[pos];
  buffer[pos] = buffer[position];
  buffer[position] = result;
 }else{
  result = buffer[position];
 }
 return result;
}

variable_types: position int

variable_types: result int

variable_types: i int

variable_types: pos int

variable_types: flag int


sheduler

decompiled_code:
__int64 __fastcall sheduler(_DWORD *a1)
{
if ( cg > 0 )
{
if ( teacher )
{
if ( teacher > 1 )
{
if ( (int)randInt() <= 50 )
{
*a1 = search(cg - 1);
--teacher;
}
else
{
*a1 = buffer[cg - 1];
--students;
}
goto LABEL_10;
}
}
else if ( students )
{
*a1 = buffer[cg - 1];
--students;
LABEL_10:
--cg;
return 0LL;
}
*a1 = buffer[cg - 1];
--teacher;
goto LABEL_10;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func12(_DWORD *a1)
{
if ( cg > 0 )
{
if ( teacher )
{
if ( teacher > 1 )
{
if ( (int)func8() <= 50 )
{
*a1 = func11(cg - 1);
--teacher;
}
else
{
*a1 = buffer[cg - 1];
--students;
}
goto LABEL_10;
}
}
else if ( students )
{
*a1 = buffer[cg - 1];
--students;
LABEL_10:
--cg;
return 0LL;
}
*a1 = buffer[cg - 1];
--teacher;
goto LABEL_10;
}
return 0xFFFFFFFFLL;
}

original_code:
int sheduler(buffer_item *item)
{
 if(cg > 0)
 {
  if ( (teacher == 0) && (students != 0) ){
   *item = buffer[(cg-1)];
   students --;
  }else{
   if(teacher >= 2){
    int data = randInt();
    if(data > 50){
     *item = buffer[(cg-1)];
     students --;
    }
    else{
     *item = search((cg-1));
     teacher --;
    }
   }else{
    *item = buffer[(cg-1)];
    teacher --;
   }
  }
  cg--;
  return 0;
 }
 else{
  return -1;
 }
}

canonical_original_code:
int sheduler(int *item)
{
 if(cg > 0)
 {
  if ( (teacher == 0) && (students != 0) ){
   *item = buffer[(cg-1)];
   students --;
  }else{
   if(teacher >= 2){
    int data = randInt();
    if(data > 50){
     *item = buffer[(cg-1)];
     students --;
    }
    else{
     *item = search((cg-1));
     teacher --;
    }
   }else{
    *item = buffer[(cg-1)];
    teacher --;
   }
  }
  cg--;
  return 0;
 }
 else{
  return -1;
 }
}

variable_types:
item
int *

variable_types: data int


consumer

decompiled_code:
void __fastcall __noreturn consumer(void *a1)
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
sleep(1u);
sem_wait(&cFull);
sem_wait(&mutex);
if ( (unsigned int)sheduler(v1) )
fwrite("print error ", 1uLL, 0xCuLL, _bss_start);
else
printf("Imprimiendo a: %d\n", v1[0]);
sem_post(&mutex);
sem_post(&cEmpty);
}
}

canonical_decompiled_code:
void __fastcall __noreturn func13(void *a1)
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
sleep(1u);
sem_wait(&cFull);
sem_wait(&mutex);
if ( (unsigned int)func12(v1) )
fwrite("print error ", 1uLL, 0xCuLL, _bss_start);
else
printf("Imprimiendo a: %d\n", v1[0]);
sem_post(&mutex);
sem_post(&cEmpty);
}
}

original_code:
void *consumer(void *param){
 buffer_item item;
 while(1) {
  sleep(1);
  sem_wait(&cFull);
  sem_wait(&mutex);
  if(sheduler(&item)){
   fprintf(stderr, "print error ");
  }
  else{
   printf("Imprimiendo a: %d\n", item);
  }
  sem_post(&mutex);
  sem_post(&cEmpty);
 }
}

canonical_original_code:
void *consumer(void *param){
 int item;
 while(1) {
  sleep(1);
  sem_wait(&cFull);
  sem_wait(&mutex);
  if(sheduler(&item)){
   fprintf(stderr, "print error ");
  }
  else{
   printf("Imprimiendo a: %d\n", item);
  }
  sem_post(&mutex);
  sem_post(&cEmpty);
 }
}


repo: sergot/asteroids

decompiled_code:
float *__fastcall p_times(float *a1, float a2)
{
float *result; // rax

result = (float *)calloc(1uLL, 8uLL);
*result = a2 * *a1;
result[1] = a2 * a1[1];
return result;
}

canonical_decompiled_code:
float *__fastcall func0(float *a1, float a2)
{
float *result; // rax

result = (float *)calloc(1uLL, 8uLL);
*result = a2 * *a1;
result[1] = a2 * a1[1];
return result;
}

original_code:
point *p_times(point *v, float multipier) {
    point *new = calloc(1, sizeof(point));
    new->x = v->x * multipier;
    new->y = v->y * multipier;
    return new;
}

canonical_original_code:
struct point *p_times(struct point *v, float multipier) {
    struct point *new = calloc(1, sizeof(point));
    new->x = v->x * multipier;
    new->y = v->y * multipier;
    return new;
}

variable_types:
v
struct point *

variable_types: multipier float

variable_types:
new
struct point { float x; } *

return_type: struct point { float x; } *


decompiled_code:
void *new_point()
{
return calloc(1uLL, 8uLL);
}

canonical_decompiled_code:
void *func1()
{
return calloc(1uLL, 8uLL);
}

original_code:
point *new_point() {
    point *new = calloc(1, sizeof(point));
    new->x = 0;
    new->y = 0;
    return new;
}

canonical_original_code:
struct point *new_point() {
    struct point *new = calloc(1, sizeof(point));
    new->x = 0;
    new->y = 0;
    return new;
}


dist

decompiled_code:
float __fastcall dist(float *a1, float *a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
float result; // xmm0_4

v2 = (float)(a2[1] - a1[1]);
v3 = v2 * v2 + (float)(*a2 - *a1) * (float)(*a2 - *a1);
if ( v3 < 0.0 )
result = sqrt(v3);
else
result = sqrt(v3);
return result;
}

canonical_decompiled_code:
float __fastcall func2(float *a1, float *a2)
{
double v2; // xmm0_8
double v3; // xmm0_8
float result; // xmm0_4

v2 = (float)(a2[1] - a1[1]);
v3 = v2 * v2 + (float)(*a2 - *a1) * (float)(*a2 - *a1);
if ( v3 < 0.0 )
result = sqrt(v3);
else
result = sqrt(v3);
return result;
}

original_code:
float dist(point *p1, point *p2) {
    return sqrt(pow(p2->x - p1->x, 2) + pow(p2->y - p1->y, 2));
}

canonical_original_code:
float dist(struct point *p1, struct point *p2) {
    return sqrt(pow(p2->x - p1->x, 2) + pow(p2->y - p1->y, 2));
}

return_type: float


decompiled_code:
void __fastcall turn_left(__int64 a1)
{
float v1; // xmm0_4

v1 = *(float *)(a1 + 8) - 0.1;
*(float *)(a1 + 8) = v1;
}

original_code:
void turn_left(ship *s) {
    s->angle -= 0.1;
}

canonical_original_code:
void turn_left(struct ship *s) {
    s->angle -= 0.1;
}

variable_types: struct ship { struct point { float x; } *position; float angle; int life; } *

user_defined_types: struct ship { struct point *position; float angle; int life; }


decompiled_code:
void __fastcall turn_right(__int64 a1)
{
float v1; // xmm0_4

v1 = *(float *)(a1 + 8) + 0.1;
*(float *)(a1 + 8) = v1;
}

original_code:
void turn_right(ship *s) {
    s->angle += 0.1;
}

canonical_original_code:
void turn_right(struct ship *s) {
    s->angle += 0.1;
}


qlnew

repo: serprex/qtree

decompiled_code:
void *qlnew()
{
return calloc(1uLL, 8uLL);
}

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

canonical_original_code: struct qlist *qlnew(){return calloc(1,sizeof(qlist));}

return_type: struct qlist { unsigned int n; unsigned int p; void *q[]; } *


qldel

decompiled_code:
void __fastcall qldel(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(void *a1)
{
free(a1);
}

original_code: void qldel(qlist*n){free(n);}

canonical_original_code: void qldel(struct qlist *n){free(n);}

variable_types: struct qlist { unsigned int n; unsigned int p; void *q[]; } *


qlin

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

if ( !*a1 )
return 0LL;
v2 = a1 + 2;
while ( *v2 != a2 )
{
if ( ++v2 == (_QWORD *)&a1[2 * (*a1 - 1) + 4] )
return 0LL;
}
return 1LL;
}

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

if ( !*a1 )
return 0LL;
v2 = a1 + 2;
while ( *v2 != a2 )
{
if ( ++v2 == (_QWORD *)&a1[2 * (*a1 - 1) + 4] )
return 0LL;
}
return 1LL;
}

original_code:
int qlin(qlist*n,void*q){
 for(uint32_t i=0;i<n->n;i++)
  if(n->q[i]==q)return 1;
 return 0;
}

canonical_original_code:
int qlin(struct qlist *n, void *q){
 for(unsigned int i = 0;i<n->n;i++)
  if(n->q[i]==q)return 1;
 return 0;
}

variable_types:
q
void *

variable_types:
i
unsigned int

user_defined_types: struct qlist { unsigned int n; unsigned int p; void *q[]; }


qlset

decompiled_code:
void __fastcall qlset(unsigned int *a1, unsigned int a2)
{
if ( *a1 > a2 )
a1[1] = a2;
}

canonical_decompiled_code:
void __fastcall func3(unsigned int *a1, unsigned int a2)
{
if ( *a1 > a2 )
a1[1] = a2;
}

canonical_original_code: void qlset(struct qlist *n, unsigned int i){if(i<n->n)n->p=i;}


qlnxt

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

v1 = a1[1];
v2 = 0LL;
if ( v1 < *a1 )
{
a1[1] = v1 + 1;
v2 = *(_QWORD *)&a1[2 * v1 + 2];
}
return v2;
}

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

v1 = a1[1];
v2 = 0LL;
if ( v1 < *a1 )
{
a1[1] = v1 + 1;
v2 = *(_QWORD *)&a1[2 * v1 + 2];
}
return v2;
}

canonical_original_code: void *qlnxt(struct qlist *n){return n->p<n->n?n->q[n->p++]:0;}


rqtnew

decompiled_code:
void *rqtnew()
{
return calloc(0x30uLL, 1uLL);
}

canonical_decompiled_code:
void *func1()
{
return calloc(0x30uLL, 1uLL);
}

canonical_original_code: struct rqtree *rqtnew(){return calloc(sizeof(rqtree),1);}

return_type: struct rqtree { struct rqtree *n[4]; unsigned short x; unsigned short *r; } *


rqtsubp

decompiled_code:
void rqtsubp()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void rqtsubp(rqtree*q,uint16_t x,uint16_t y){
}

canonical_original_code:
void rqtsubp(struct rqtree *q, unsigned short x, unsigned short y){
}

variable_types: struct rqtree { struct rqtree *n[4]; unsigned short x; unsigned short *r; } *

variable_types:
x
unsigned short

variable_types:
y
unsigned short


rqtsubr

decompiled_code:
void rqtsubr()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void rqtsubr(rqtree*q,uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2){
}

canonical_original_code:
void rqtsubr(struct rqtree *q, unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2){
}

user_defined_types: struct rqtree { struct rqtree *n[4]; unsigned short x; unsigned short *r; }


rqtgetp

decompiled_code:
__int64 rqtgetp()
{
return qlnew();
}

canonical_decompiled_code:
__int64 func7()
{
return qlnew();
}

original_code:
qlist*rqtgetp(rqtree*q,uint16_t x,uint16_t y){
 qlist*r=qlnew();
 return r;
}

canonical_original_code:
struct qlist *rqtgetp(struct rqtree *q, unsigned short x, unsigned short y){
 struct qlist *r = qlnew();
 return r;
}


repo: sessionc/libsesstype

decompiled_code:
int __fastcall st_node_print(unsigned int *a1, unsigned int a2)
{
return st_node_fprint(stdout, a1, a2);
}

canonical_decompiled_code:
int __fastcall func15(unsigned int *a1, unsigned int a2)
{
return func14(stdout, a1, a2);
}

original_code:
inline void st_node_print(const st_node *node, int indent)
{
  st_node_fprint(stdout, node, indent);
}

canonical_original_code:
inline void st_node_print(struct __st_node *node, int indent)
{
  st_node_fprint(stdout, node, indent);
}

variable_types: struct __st_node { int type; union { struct st_node_interaction_t { struct st_node_msgsig_t { char *op; char *payload; } msgsig; int nto; struct st_role { char *name; unsigned int dimen; struct __st_expr_t { int type; union { struct __st_bin_expr_t { struct __st_expr_t *left; struct __st_expr_t *right; } *bin; struct __st_seq_expr_t { unsigned int count; int *values; } *seq; struct __st_rng_expr_t { char *bindvar; struct __st_expr_t *from; struct __st_expr_t *to; } *rng; char *var; int num; }; } **param; } **to; struct st_role *from; struct st_role *msg_cond; } *interaction; struct st_node_choice_t { struct st_role *at; } *choice; struct st_node_recur_t { char *label; } *recur; struct st_node_continue_t { char *label; } *cont; struct st_node_for_t { struct __st_rng_expr_t *range; char *except; } *forloop; struct st_node_allreduce_t { struct st_node_msgsig_t msgsig; } *allreduce; struct st_node_ifblk_t { struct st_role *cond; } *ifblk; struct st_node_oneof_t { char *role; struct __st_rng_expr_t *range; unsigned int unordered; } *oneof; }; int nchild; struct __st_node **children; int marked; } *

variable_types: indent int

user_defined_types: struct __st_node { int type; union { struct st_node_interaction_t *interaction; struct st_node_choice_t *choice; struct st_node_recur_t *recur; struct st_node_continue_t *cont; struct st_node_for_t *forloop; struct st_node_allreduce_t *allreduce; struct st_node_ifblk_t *ifblk; struct st_node_oneof_t *oneof; }; int nchild; struct __st_node **children; int marked; }

user_defined_types: struct st_node_interaction_t { struct st_node_msgsig_t msgsig; int nto; struct st_role **to; struct st_role *from; struct st_role *msg_cond; }

user_defined_types: struct st_role { char *name; unsigned int dimen; struct __st_expr_t **param; }

user_defined_types: struct __st_expr_t { int type; union { struct __st_bin_expr_t *bin; struct __st_seq_expr_t *seq; struct __st_rng_expr_t *rng; char *var; int num; }; }


decompiled_code:
int __fastcall st_tree_print(_QWORD *a1)
{
int v1; // eax
__int64 v2; // rbx
const char **v3; // rax
__int64 v4; // rax
__int64 v5; // rbx
_DWORD *v6; // rdx
int v7; // eax
__int64 v8; // rbx
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // r14
__int64 v12; // rbx
__int64 v13; // rdi
__int64 v15; // [rsp+8h] [rbp-40h]

if ( !a1 )
fprintf(stderr, "%s:%d %s tree is NULL\n", "st_node_print.c", 23LL, "st_tree_print");
puts("\n-------Summary------");
if ( *a1 )
{
printf("Protocol: %s#%s\n", *(const char **)(*a1 + 88LL), *(const char **)(*a1 + 40LL));
v1 = *(_DWORD *)(*a1 + 32LL);
if ( v1 == 128 )
{
puts("Local protocol");
}
else
{
if ( v1 != 256 )
_assert_fail("0", "st_node_print.c", 0x22u, "st_tree_print");
puts("Global protocol");
}
if ( *(_DWORD *)(*a1 + 32LL) != 256 )
{
if ( *(_QWORD *)(*a1 + 48LL) )
{
printf("Endpoint role: ");
st_role_fprint(stdout, *(_QWORD *)(*a1 + 48LL));
}
else
{
printf("Endpoint role: NOT SET");
}
}
putchar(10);
printf("Imports: [");
if ( *(int *)*a1 > 0 )
{
v2 = 0LL;
do
{
if ( !(_DWORD)v2 )
putchar(10);
v3 = *(const char ***)(*(_QWORD *)(*a1 + 8LL) + 8 * v2);
printf(" { name: %s, as: %s, from: %s }\n", *v3, v3[1], v3[2]);
++v2;
}
while ( *(_DWORD *)*a1 > (int)v2 );
}
puts("]");
printf("Constants: [");
v4 = *a1;
if ( *(int *)(*a1 + 16LL) > 0 )
{
v5 = 0LL;
do
{
printf("\n%s ", **(const char ***)(*(_QWORD *)(v4 + 24) + 8 * v5));
v6 = *(_DWORD **)(*(_QWORD *)(*a1 + 24LL) + 8 * v5);
v7 = v6[2];
switch ( v7 )
{
case 2:
printf("is between %u and %u", (unsigned int)v6[3], (unsigned int)v6[4]);
break;
case 3:
printf("is unbounded from %u to +Inf", (unsigned int)v6[3]);
break;
case 1:
printf("= %u", (unsigned int)v6[3]);
break;
}
v4 = *a1;
++v5;
}
while ( *(_DWORD *)(*a1 + 16LL) > (int)v5 );
}
puts("]");
printf("Roles: [");
v8 = 0LL;
if ( *(int *)(*a1 + 56LL) > 0 )
{
while ( 1 )
{
st_role_fprint(stdout, *(_QWORD *)(*(_QWORD *)(*a1 + 64LL) + 8 * v8));
if ( *(_DWORD *)(*a1 + 56LL) <= (int)v8 + 1 )
break;
if ( (_DWORD)v8 != -1 )
printf(", ");
++v8;
}
}
puts("]");
printf("Groups: [");
v9 = *a1;
if ( *(int *)(*a1 + 72LL) > 0 )
{
v15 = 0LL;
do
{
printf(" %s={", **(const char ***)(*(_QWORD *)(v9 + 80) + 8 * v15));
v10 = *(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15);
if ( *(_DWORD *)(v10 + 8) )
{
v11 = 0LL;
do
{
printf(" %s", **(const char ***)(*(_QWORD *)(v10 + 16) + 8 * v11));
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15) + 16LL) + 8 * v11)
+ 8LL) )
{
v12 = 0LL;
do
{
putchar(91);
st_expr_print(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL)
+ 8 * v15)
+ 16LL)
+ 8 * v11)
+ 16LL)
+ 8 * v12));
putchar(93);
++v12;
}
while ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15) + 16LL)
+ 8 * v11)
+ 8LL) > (unsigned int)v12 );
}
v10 = *(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15);
++v11;
}
while ( *(_DWORD *)(v10 + 8) > (unsigned int)v11 );
}
putchar(125);
v9 = *a1;
++v15;
}
while ( *(_DWORD *)(*a1 + 72LL) > (int)v15 );
}
puts(" ]");
}
else
{
puts("Protocol info not found");
}
puts("--------------------");
v13 = a1[1];
if ( v13 )
st_node_print_r_localalias(v13, 0);
else
puts("Protocol tree is empty");
return puts("--------------------\n");
}

canonical_decompiled_code:
int __fastcall func18(_QWORD *a1)
{
int v1; // eax
__int64 v2; // rbx
const char **v3; // rax
__int64 v4; // rax
__int64 v5; // rbx
_DWORD *v6; // rdx
int v7; // eax
__int64 v8; // rbx
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // r14
__int64 v12; // rbx
__int64 v13; // rdi
__int64 v15; // [rsp+8h] [rbp-40h]

if ( !a1 )
fprintf(stderr, "%s:%d %s tree is NULL\n", "st_node_print.c", 23LL, "st_tree_print");
puts("\n-------Summary------");
if ( *a1 )
{
printf("Protocol: %s#%s\n", *(const char **)(*a1 + 88LL), *(const char **)(*a1 + 40LL));
v1 = *(_DWORD *)(*a1 + 32LL);
if ( v1 == 128 )
{
puts("Local protocol");
}
else
{
if ( v1 != 256 )
_assert_fail("0", "st_node_print.c", 0x22u, "st_tree_print");
puts("Global protocol");
}
if ( *(_DWORD *)(*a1 + 32LL) != 256 )
{
if ( *(_QWORD *)(*a1 + 48LL) )
{
printf("Endpoint role: ");
func0(stdout, *(_QWORD *)(*a1 + 48LL));
}
else
{
printf("Endpoint role: NOT SET");
}
}
putchar(10);
printf("Imports: [");
if ( *(int *)*a1 > 0 )
{
v2 = 0LL;
do
{
if ( !(_DWORD)v2 )
putchar(10);
v3 = *(const char ***)(*(_QWORD *)(*a1 + 8LL) + 8 * v2);
printf(" { name: %s, as: %s, from: %s }\n", *v3, v3[1], v3[2]);
++v2;
}
while ( *(_DWORD *)*a1 > (int)v2 );
}
puts("]");
printf("Constants: [");
v4 = *a1;
if ( *(int *)(*a1 + 16LL) > 0 )
{
v5 = 0LL;
do
{
printf("\n%s ", **(const char ***)(*(_QWORD *)(v4 + 24) + 8 * v5));
v6 = *(_DWORD **)(*(_QWORD *)(*a1 + 24LL) + 8 * v5);
v7 = v6[2];
switch ( v7 )
{
case 2:
printf("is between %u and %u", (unsigned int)v6[3], (unsigned int)v6[4]);
break;
case 3:
printf("is unbounded from %u to +Inf", (unsigned int)v6[3]);
break;
case 1:
printf("= %u", (unsigned int)v6[3]);
break;
}
v4 = *a1;
++v5;
}
while ( *(_DWORD *)(*a1 + 16LL) > (int)v5 );
}
puts("]");
printf("Roles: [");
v8 = 0LL;
if ( *(int *)(*a1 + 56LL) > 0 )
{
while ( 1 )
{
func0(stdout, *(_QWORD *)(*(_QWORD *)(*a1 + 64LL) + 8 * v8));
if ( *(_DWORD *)(*a1 + 56LL) <= (int)v8 + 1 )
break;
if ( (_DWORD)v8 != -1 )
printf(", ");
++v8;
}
}
puts("]");
printf("Groups: [");
v9 = *a1;
if ( *(int *)(*a1 + 72LL) > 0 )
{
v15 = 0LL;
do
{
printf(" %s={", **(const char ***)(*(_QWORD *)(v9 + 80) + 8 * v15));
v10 = *(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15);
if ( *(_DWORD *)(v10 + 8) )
{
v11 = 0LL;
do
{
printf(" %s", **(const char ***)(*(_QWORD *)(v10 + 16) + 8 * v11));
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15) + 16LL) + 8 * v11)
+ 8LL) )
{
v12 = 0LL;
do
{
putchar(91);
st_expr_print(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL)
+ 8 * v15)
+ 16LL)
+ 8 * v11)
+ 16LL)
+ 8 * v12));
putchar(93);
++v12;
}
while ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15) + 16LL)
+ 8 * v11)
+ 8LL) > (unsigned int)v12 );
}
v10 = *(_QWORD *)(*(_QWORD *)(*a1 + 80LL) + 8 * v15);
++v11;
}
while ( *(_DWORD *)(v10 + 8) > (unsigned int)v11 );
}
putchar(125);
v9 = *a1;
++v15;
}
while ( *(_DWORD *)(*a1 + 72LL) > (int)v15 );
}
puts(" ]");
}
else
{
puts("Protocol info not found");
}
puts("--------------------");
v13 = a1[1];
if ( v13 )
func17(v13, 0);
else
puts("Protocol tree is empty");
return puts("--------------------\n");
}

original_code:
void st_tree_print(const st_tree *tree)
{
  if (tree == ((void *)0)) {
    fprintf(stderr, "%s:%d %s tree is NULL\n", "st_node_print.c", 23, __FUNCTION__);
  }
  printf("\n-------Summary------\n");
  if (tree->info != ((void *)0)) {
    printf("Protocol: %s#%s\n", tree->info->module, tree->info->name);
    switch (tree->info->type) {
      case 0x100: printf("Global protocol\n"); break;
      case 0x80: printf("Local protocol\n"); break;
      default:
        ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "st_node_print.c", 34, __extension__ __PRETTY_FUNCTION__); }));
    }
    if (0x100 != tree->info->type) {
      if (tree->info->myrole != ((void *)0)) {
        printf("Endpoint role: ");
        st_role_fprint(stdout, tree->info->myrole);
      } else {
        printf("Endpoint role: NOT SET");
      }
    }
    printf("\n");
    printf("Imports: [");
    for (int i=0; i<tree->info->nimport; ++i) {
      if (i==0) printf("\n");
      printf("  { name: %s, as: %s, from: %s }\n",
          tree->info->imports[i]->name,
          tree->info->imports[i]->as,
          tree->info->imports[i]->from);
    }
    printf("]\n");
    printf("Constants: [");
    for (int c=0; c<tree->info->nconst; ++c) {
      printf("\n%s ", tree->info->consts[c]->name);
      switch (tree->info->consts[c]->type) {
        case 1:
          printf("= %u",
              tree->info->consts[c]->value);
          break;
        case 2:
          printf("is between %u and %u",
              tree->info->consts[c]->bounds.lbound,
              tree->info->consts[c]->bounds.ubound);
          break;
        case 3:
          printf("is unbounded from %u to +Inf",
              tree->info->consts[c]->inf.lbound);
          break;
      }
    }
    printf("]\n");
    printf("Roles: [");
    for (int r=0; r<tree->info->nrole; ++r) {
      if (r!=0) printf(", ");
      st_role_fprint(stdout, tree->info->roles[r]);
    }
    printf("]\n");
    printf("Groups: [");
    for (int g=0; g<tree->info->ngroup; ++g) {
      printf(" %s={", tree->info->groups[g]->name);
      for (int r=0; r<tree->info->groups[g]->nmemb; ++r) {
        printf(" %s", tree->info->groups[g]->membs[r]->name);
        for (int p=0; p<tree->info->groups[g]->membs[r]->dimen; ++p) {
          printf("[");
          st_expr_print(tree->info->groups[g]->membs[r]->param[p]);
          printf("]");
        }
      }
      printf("}");
    }
    printf(" ]\n");
  } else {
    printf("Protocol info not found\n");
  }
  printf("--------------------\n");
  if (tree->root != ((void *)0)) {
    st_node_print_r(tree->root, 0);
  } else {
    printf("Protocol tree is empty\n");
  }
  printf("--------------------\n\n");
}

canonical_original_code:
void st_tree_print(struct st_tree *tree)
{
  if (tree == ((void *)0)) {
    fprintf(stderr, "%s:%d %s tree is NULL\n", "st_node_print.c", 23, __FUNCTION__);
  }
  printf("\n-------Summary------\n");
  if (tree->info != ((void *)0)) {
    printf("Protocol: %s#%s\n", tree->info->module, tree->info->name);
    switch (tree->info->type) {
      case 0x100: printf("Global protocol\n"); break;
      case 0x80: printf("Local protocol\n"); break;
      default:
        ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "st_node_print.c", 34, __extension__ __PRETTY_FUNCTION__); }));
    }
    if (0x100 != tree->info->type) {
      if (tree->info->myrole != ((void *)0)) {
        printf("Endpoint role: ");
        st_role_fprint(stdout, tree->info->myrole);
      } else {
        printf("Endpoint role: NOT SET");
      }
    }
    printf("\n");
    printf("Imports: [");
    for (int i = 0; i<tree->info->nimport; ++i) {
      if (i==0) printf("\n");
      printf("  { name: %s, as: %s, from: %s }\n",
          tree->info->imports[i]->name,
          tree->info->imports[i]->as,
          tree->info->imports[i]->from);
    }
    printf("]\n");
    printf("Constants: [");
    for (int c = 0; c<tree->info->nconst; ++c) {
      printf("\n%s ", tree->info->consts[c]->name);
      switch (tree->info->consts[c]->type) {
        case 1:
          printf("= %u",
              tree->info->consts[c]->value);
          break;
        case 2:
          printf("is between %u and %u",
              tree->info->consts[c]->bounds.lbound,
              tree->info->consts[c]->bounds.ubound);
          break;
        case 3:
          printf("is unbounded from %u to +Inf",
              tree->info->consts[c]->inf.lbound);
          break;
      }
    }
    printf("]\n");
    printf("Roles: [");
    for (int r = 0; r<tree->info->nrole; ++r) {
      if (r!=0) printf(", ");
      st_role_fprint(stdout, tree->info->roles[r]);
    }
    printf("]\n");
    printf("Groups: [");
    for (int g = 0; g<tree->info->ngroup; ++g) {
      printf(" %s={", tree->info->groups[g]->name);
      for (int r = 0; r<tree->info->groups[g]->nmemb; ++r) {
        printf(" %s", tree->info->groups[g]->membs[r]->name);
        for (int p = 0; p<tree->info->groups[g]->membs[r]->dimen; ++p) {
          printf("[");
          st_expr_print(tree->info->groups[g]->membs[r]->param[p]);
          printf("]");
        }
      }
      printf("}");
    }
    printf(" ]\n");
  } else {
    printf("Protocol info not found\n");
  }
  printf("--------------------\n");
  if (tree->root != ((void *)0)) {
    st_node_print_r(tree->root, 0);
  } else {
    printf("Protocol tree is empty\n");
  }
  printf("--------------------\n\n");
}

variable_types: struct st_tree { struct st_info { int nimport; struct st_tree_import_t { char *name; char *as; char *from; } **imports; int nconst; struct st_const_t { char *name; int type; union { unsigned int value; struct { unsigned int lbound; unsigned int ubound; } bounds; struct { unsigned int lbound; } inf; }; } **consts; int type; char *name; struct st_role { char *name; unsigned int dimen; struct __st_expr_t { int type; union { struct __st_bin_expr_t { struct __st_expr_t *left; struct __st_expr_t *right; } *bin; struct __st_seq_expr_t { unsigned int count; int *values; } *seq; struct __st_rng_expr_t { char *bindvar; struct __st_expr_t *from; struct __st_expr_t *to; } *rng; char *var; int num; }; } **param; } *myrole; int nrole; struct st_role **roles; int ngroup; struct st_role_group { char *name; unsigned int nmemb; struct st_role **membs; } **groups; char *module; } *info; struct __st_node { int type; union { struct st_node_interaction_t { struct st_node_msgsig_t { char *op; char *payload; } msgsig; int nto; struct st_role **to; struct st_role *from; struct st_role *msg_cond; } *interaction; struct st_node_choice_t { struct st_role *at; } *choice; struct st_node_recur_t { char *label; } *recur; struct st_node_continue_t { char *label; } *cont; struct st_node_for_t { struct __st_rng_expr_t *range; char *except; } *forloop; struct st_node_allreduce_t { struct st_node_msgsig_t msgsig; } *allreduce; struct st_node_ifblk_t { struct st_role *cond; } *ifblk; struct st_node_oneof_t { char *role; struct __st_rng_expr_t *range; unsigned int unordered; } *oneof; }; int nchild; struct __st_node **children; int marked; } *root; } *

variable_types: i int

variable_types: c int

variable_types: r int

variable_types: g int

variable_types: p int

user_defined_types: struct st_tree { struct st_info *info; struct __st_node *root; }

user_defined_types: struct st_info { int nimport; struct st_tree_import_t **imports; int nconst; struct st_const_t **consts; int type; char *name; struct st_role *myrole; int nrole; struct st_role **roles; int ngroup; struct st_role_group **groups; char *module; }


main

repo: sevenonlinez/asnake

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
_QWORD *v4; // rbx
__int64 i; // rbp
void *v6; // rax
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

set_display_size(argc, argv, envp);
check_display_size();
set_geschwindigkeit(5LL);
v3 = check_args((unsigned int)argc, argv);
if ( v3 != -1 )
{
v4 = malloc(8LL * len_x);
if ( v4 )
{
for ( i = 0LL; len_x > (int)i; ++i )
{
v6 = malloc(len_y);
v4[i] = v6;
if ( !v6 )
printf("Kein Speicher mehr fuer Zeile %d\n", (unsigned int)i);
}
if ( (unsigned int)new_tty(0LL) == -1 )
{
puts("Fehler bei der Funktion new_tty()");
exit(1);
}
newthread[0] = 1LL;
v3 = pthread_create(newthread, 0LL, (void *(*)(void *))&read_stdin, 0LL);
if ( v3 )
{
puts("Konnte keinen Thread erzeugen");
exit(1);
}
snake_create_playground(v4);
create_snake(v4);
create_hindernis(v4);
snake_print_out(v4);
game[2] = 0;
do
{
while ( (eingabe & 0xDF) == 80 )
usleep(0x64u);
system("clear");
snake_print_out(v4);
usleep(game[1]);
move_snake(v4);
}
while ( eingabe != 113 );
game_over();
}
else
{
printf("Kein virtueller RAM mehr vorhanden...!!");
v3 = 1;
}
}
return v3;
}

original_code:
int main(int argc, char *argv[]) {
    set_display_size();
    check_display_size();
    set_geschwindigkeit(5);
    int args_check = check_args(argc, argv);
    if (args_check == -1) {
        return -1;
    }
    char **playfield;
    playfield=malloc(len_x * sizeof( char*));
    if(((void *)0)== playfield) {
        printf("Kein virtueller RAM mehr vorhanden...!!");
        return 1;
    }
    int i;
    for( i=0; i< len_x; i++) {
        playfield[i] = malloc(len_y * sizeof(char));
        if( ((void *)0) == playfield[i]) {
            printf("Kein Speicher mehr fuer Zeile %d\n", i);
        }
    }
    if (new_tty (0) == -1) {
        printf ("Fehler bei der Funktion new_tty()\n");
        exit (1);
    }
    pthread_t th1=1, th2=2, th3=3;
    if (pthread_create (&th1,((void *)0),&read_stdin,((void *)0)) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
    snake_create_playground(playfield);
    create_snake(playfield);
    create_hindernis(playfield);
    snake_print_out(playfield);
    game.score=0;
    do {
        if (eingabe == 'p' || eingabe == 'P') {
            do {
                usleep(100);
            } while (eingabe == 'p' || eingabe == 'P');
        }
        system("clear");
        snake_print_out(playfield);
        usleep(game.geschwindigkeit);
        move_snake(playfield);
    } while (eingabe != 'q');
    game_over();
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
    set_display_size();
    check_display_size();
    set_geschwindigkeit(5);
    int args_check = check_args(argc, argv);
    if (args_check == -1) {
        return -1;
    }
    char **playfield;
    playfield=malloc(len_x * sizeof( char *));
    if(((void *)0)== playfield) {
        printf("Kein virtueller RAM mehr vorhanden...!!");
        return 1;
    }
    int i;
    for( i=0; i< len_x; i++) {
        playfield[i] = malloc(len_y * sizeof(char));
        if( ((void *)0) == playfield[i]) {
            printf("Kein Speicher mehr fuer Zeile %d\n", i);
        }
    }
    if (new_tty (0) == -1) {
        printf ("Fehler bei der Funktion new_tty()\n");
        exit (1);
    }
    unsigned long th1 = 1; unsigned long th2 = 2; unsigned long th3 = 3;
    if (pthread_create (&th1,((void *)0),&read_stdin,((void *)0)) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
    snake_create_playground(playfield);
    create_snake(playfield);
    create_hindernis(playfield);
    snake_print_out(playfield);
    game.score=0;
    do {
        if (eingabe == 'p' || eingabe == 'P') {
            do {
                usleep(100);
            } while (eingabe == 'p' || eingabe == 'P');
        }
        system("clear");
        snake_print_out(playfield);
        usleep(game.geschwindigkeit);
        move_snake(playfield);
    } while (eingabe != 'q');
    game_over();
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
playfield
char **


decompiled_code:
__int64 get_cols()
{
int v0; // eax
unsigned int v1; // ebx

v0 = fileno(stdin);
if ( setupterm(0LL, v0, 0LL) )
{
perror("setupterm()");
exit(1);
}
v1 = tigetnum("cols");
if ( v1 == -1 )
puts(aGetColsWirdNic);
return v1;
}

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

v0 = fileno(stdin);
if ( setupterm(0LL, v0, 0LL) )
{
perror("setupterm()");
exit(1);
}
v1 = tigetnum("cols");
if ( v1 == -1 )
puts(aGetColsWirdNic);
return v1;
}

original_code:
int get_cols() {
    int ret;
    ret = setupterm (((void *)0), fileno (stdin), ((void *)0));
    if (ret != 0) {
        perror ("setupterm()");
        exit (1);
    }
    ret=tigetnum("cols");
    if (ret == -1) {
        printf ("get_cols: wird nicht unterstützt\n");
        return -1;
    }
    else
        return ret;
}

variable_types: ret int


decompiled_code:
__int64 get_lines()
{
int v0; // eax
unsigned int v1; // ebx

v0 = fileno(stdin);
if ( setupterm(0LL, v0, 0LL) )
{
perror("setupterm()");
exit(1);
}
v1 = tigetnum("lines");
if ( v1 == -1 )
puts(aGetLinesWirdNi);
return v1;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
unsigned int v1; // ebx

v0 = fileno(stdin);
if ( setupterm(0LL, v0, 0LL) )
{
perror("setupterm()");
exit(1);
}
v1 = tigetnum("lines");
if ( v1 == -1 )
puts(aGetLinesWirdNi);
return v1;
}

original_code:
int get_lines() {
    int ret;
    ret = setupterm (((void *)0), fileno (stdin), ((void *)0));
    if (ret != 0) {
        perror ("setupterm()");
        exit (1);
    }
    ret=tigetnum("lines");
    if (ret == -1) {
        printf ("get_lines: wird nicht unterstützt\n");
        return -1;
    }
    else
        return ret;
}


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

len_x = get_cols();
len_y = get_lines() - 1;
if ( (len_x & 1) != 0 )
result = (unsigned int)((len_x + 1) / 2 - 1);
else
result = (unsigned int)(len_x / 2);
len_x = result;
return result;
}

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

len_x = func0();
len_y = func1() - 1;
if ( (len_x & 1) != 0 )
result = (unsigned int)((len_x + 1) / 2 - 1);
else
result = (unsigned int)(len_x / 2);
len_x = result;
return result;
}

original_code:
void set_display_size() {
    len_x=get_cols();
    len_y=get_lines()-1;
    int xcor=len_x;
    if( xcor % 2 == 0) {
        xcor = len_x/2;
    }
    else {
        xcor = (len_x+1)/2;
        xcor--;
    }
    len_x = xcor;
}

canonical_original_code:
void set_display_size() {
    len_x=get_cols();
    len_y=get_lines()-1;
    int xcor = len_x;
    if( xcor % 2 == 0) {
        xcor = len_x/2;
    }
    else {
        xcor = (len_x+1)/2;
        xcor--;
    }
    len_x = xcor;
}

variable_types: xcor int


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

result = (unsigned int)len_x;
if ( len_x <= 4 || len_y <= 7 )
{
puts(aZuKleineTermin);
goto LABEL_7;
}
if ( len_y > 998 || len_x > 499 )
{
puts("To big terminal size!!");
LABEL_7:
result = 1LL;
}
return result;
}

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

result = (unsigned int)len_x;
if ( len_x <= 4 || len_y <= 7 )
{
puts(aZuKleineTermin);
goto LABEL_7;
}
if ( len_y > 998 || len_x > 499 )
{
puts("To big terminal size!!");
LABEL_7:
result = 1LL;
}
return result;
}

original_code:
int check_display_size() {
    if(len_x<5 || len_y < 8) {
        printf("Zu kleine Terminalgrösse!!\n");
        return 1;
    }
    if(len_x>499 || len_y>998) {
        printf("To big terminal size!!\n");
        return 1;
    }
}


decompiled_code:
int __fastcall new_tty(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = tcgetattr(fd, &BACKUP_TTY);
if ( result != -1 )
{
*(__m128i *)&v2.c_iflag = _mm_load_si128((const __m128i *)&BACKUP_TTY);
*(__m128i *)&v2.c_line = _mm_load_si128((const __m128i *)&BACKUP_TTY.c_line);
*(__m128i *)&v2.c_cc[15] = _mm_load_si128((const __m128i *)&BACKUP_TTY.c_cc[15]);
*(_QWORD *)&v2.c_cc[31] = *(_QWORD *)&BACKUP_TTY.c_cc[31];
v2.c_ospeed = BACKUP_TTY.c_ospeed;
v2.c_lflag &= 0xFFFFFFF4;
v2.c_cc[6] = 1;
result = -(tcsetattr(fd, 2, &v2) == -1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = tcgetattr(fd, &BACKUP_TTY);
if ( result != -1 )
{
*(__m128i *)&v2.c_iflag = _mm_load_si128((const __m128i *)&BACKUP_TTY);
*(__m128i *)&v2.c_line = _mm_load_si128((const __m128i *)&BACKUP_TTY.c_line);
*(__m128i *)&v2.c_cc[15] = _mm_load_si128((const __m128i *)&BACKUP_TTY.c_cc[15]);
*(_QWORD *)&v2.c_cc[31] = *(_QWORD *)&BACKUP_TTY.c_cc[31];
v2.c_ospeed = BACKUP_TTY.c_ospeed;
v2.c_lflag &= 0xFFFFFFF4;
v2.c_cc[6] = 1;
result = -(tcsetattr(fd, 2, &v2) == -1);
}
return result;
}

original_code:
int new_tty (int fd) {
    struct termios buffer;
    if ((tcgetattr (fd, &BACKUP_TTY)) == -1)
        return -1;
    buffer = BACKUP_TTY;
    buffer.c_lflag = buffer.c_lflag & ~(0000010 | 0000002 | 0000001);
    buffer.c_cc[6] = 1;
    if ((tcsetattr (fd, 2, &buffer)) == -1)
        return -1;
    return 0;
}

canonical_original_code:
int new_tty(int fd) {
    struct termios buffer;
    if ((tcgetattr (fd, &BACKUP_TTY)) == -1)
        return -1;
    buffer = BACKUP_TTY;
    buffer.c_lflag = buffer.c_lflag & ~(0000010 | 0000002 | 0000001);
    buffer.c_cc[6] = 1;
    if ((tcsetattr (fd, 2, &buffer)) == -1)
        return -1;
    return 0;
}

variable_types: fd int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
__int64 __fastcall restore_tty(int a1)
{
return (unsigned int)-(tcsetattr(a1, 2, &BACKUP_TTY) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return (unsigned int)-(tcsetattr(a1, 2, &BACKUP_TTY) == -1);
}

original_code:
int restore_tty (int fd) {
    if ((tcsetattr (fd, 2, &BACKUP_TTY)) == -1)
        return -1;
    return 0;
}

canonical_original_code:
int restore_tty(int fd) {
    if ((tcsetattr (fd, 2, &BACKUP_TTY)) == -1)
        return -1;
    return 0;
}


decompiled_code:
void __fastcall __noreturn special_point_blink(void *a1)
{
_BYTE *v1; // rax

while ( special_point_active == 1 )
{
if ( sync_del_special_point )
break;
v1 = (_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * specialpoint) + *(&specialpoint + 1));
if ( *v1 == 36 )
{
*v1 = 32;
}
else if ( *v1 )
{
*v1 = 36;
}
usleep(2 * *(&game + 1));
}
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(void *a1)
{
_BYTE *v1; // rax

while ( special_point_active == 1 )
{
if ( sync_del_special_point )
break;
v1 = (_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * specialpoint) + *(&specialpoint + 1));
if ( *v1 == 36 )
{
*v1 = 32;
}
else if ( *v1 )
{
*v1 = 36;
}
usleep(2 * *(&game + 1));
}
pthread_exit(0LL);
}

original_code:
void *special_point_blink(void *param) {
    struct parameter *f = (struct parameter *)param;
    while(special_point_active==1 && sync_del_special_point==0 ) {
        if(f->array[specialpoint.x][specialpoint.y]=='$') {
            f->array[specialpoint.x][specialpoint.y]=' ';
        }
        else if(f->array[specialpoint.x][specialpoint.y]) {
            f->array[specialpoint.x][specialpoint.y]='$';
        }
        usleep(2*game.geschwindigkeit);
    }
    pthread_exit(((void *)0));
}

variable_types:
param
void *

variable_types:
f
struct parameter { char **array; } *


decompiled_code:
void __fastcall __noreturn del_special_point(void *a1)
{
__int64 v2; // rax
_DWORD *v3; // rdx
int v4; // eax
int v5; // edi
int v6; // edx
int v7; // edi

sync_del_special_point = 0;
v2 = anfang;
do
{
v3 = (_DWORD *)v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
v4 = *v3 - specialpoint;
if ( *v3 <= specialpoint )
v4 = specialpoint - *v3;
v5 = v3[1];
v6 = *(&specialpoint + 1);
if ( v5 <= v6 )
v7 = v6 - v5 + v4;
else
v7 = v4 + v5 - v6;
usleep(*(&game + 1) * (v7 + 10));
if ( !sync_del_special_point )
{
*(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * specialpoint) + *(&specialpoint + 1)) = 32;
sync_del_special_point = 1;
}
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
__int64 v2; // rax
_DWORD *v3; // rdx
int v4; // eax
int v5; // edi
int v6; // edx
int v7; // edi

sync_del_special_point = 0;
v2 = anfang;
do
{
v3 = (_DWORD *)v2;
v2 = *(_QWORD *)(v2 + 8);
}
while ( v2 );
v4 = *v3 - specialpoint;
if ( *v3 <= specialpoint )
v4 = specialpoint - *v3;
v5 = v3[1];
v6 = *(&specialpoint + 1);
if ( v5 <= v6 )
v7 = v6 - v5 + v4;
else
v7 = v4 + v5 - v6;
usleep(*(&game + 1) * (v7 + 10));
if ( !sync_del_special_point )
{
*(_BYTE *)(*(_QWORD *)(*(_QWORD *)a1 + 8LL * specialpoint) + *(&specialpoint + 1)) = 32;
sync_del_special_point = 1;
}
pthread_exit(0LL);
}

original_code:
void *del_special_point(void *param) {
    struct parameter *f = (struct parameter *)param;
    sync_del_special_point=0;
    struct snake *zeiger;
    zeiger=anfang;
    while(zeiger->next != ((void *)0))
        zeiger=zeiger->next;
    int len=0;
    if(zeiger->xachse>specialpoint.x) {
        len+=(zeiger->xachse-specialpoint.x);
    }
    else if(zeiger->xachse<=specialpoint.x) {
        len+=(specialpoint.x-zeiger->xachse);
    }
    if(zeiger->yachse>specialpoint.y) {
        len+=(zeiger->yachse-specialpoint.y);
    }
    else if(zeiger->yachse<=specialpoint.y) {
        len+=(specialpoint.y-zeiger->yachse);
    }
    len+=10;
    len*=game.geschwindigkeit;
    usleep(len);
    if (sync_del_special_point==0) {
        f->array[specialpoint.x][specialpoint.y]=' ';
        sync_del_special_point=1;
    }
    pthread_exit(((void *)0));
}

canonical_original_code:
void *del_special_point(void *param) {
    struct parameter *f = (struct parameter *)param;
    sync_del_special_point=0;
    struct snake *zeiger;
    zeiger=anfang;
    while(zeiger->next != ((void *)0))
        zeiger=zeiger->next;
    int len = 0;
    if(zeiger->xachse>specialpoint.x) {
        len+=(zeiger->xachse-specialpoint.x);
    }
    else if(zeiger->xachse<=specialpoint.x) {
        len+=(specialpoint.x-zeiger->xachse);
    }
    if(zeiger->yachse>specialpoint.y) {
        len+=(zeiger->yachse-specialpoint.y);
    }
    else if(zeiger->yachse<=specialpoint.y) {
        len+=(specialpoint.y-zeiger->yachse);
    }
    len+=10;
    len*=game.geschwindigkeit;
    usleep(len);
    if (sync_del_special_point==0) {
        f->array[specialpoint.x][specialpoint.y]=' ';
        sync_del_special_point=1;
    }
    pthread_exit(((void *)0));
}

variable_types: struct snake { int xachse; int yachse; struct snake *next; struct snake *previous; } *

variable_types: len int


decompiled_code:
void __noreturn read_stdin()
{
while ( read(0, &eingabe, 1uLL) > 0 )
usleep(*(&game + 1));
puts("Fehler bei read");
restore_tty(0LL);
exit(1);
}

canonical_decompiled_code:
void __noreturn func2()
{
while ( read(0, &eingabe, 1uLL) > 0 )
usleep(*(&game + 1));
puts("Fehler bei read");
restore_tty(0LL);
exit(1);
}

original_code:
void *read_stdin () {
    while(0 == 0) {
        if (read (0, &eingabe, 1) < 1) {
            printf ("Fehler bei read\n");
            restore_tty (0);
            exit (1);
        }
        usleep(game.geschwindigkeit);
    }
}

canonical_original_code:
void *read_stdin() {
    while(0 == 0) {
        if (read (0, &eingabe, 1) < 1) {
            printf ("Fehler bei read\n");
            restore_tty (0);
            exit (1);
        }
        usleep(game.geschwindigkeit);
    }
}


original_code:
void snake_create_playground (char **playfield) {
    int counter;
    int n,m;
    for(n=0; n < len_x-1; n++) {
        for( m=0; m < len_y-1; m++) {
            playfield[n][m]=' ';
        }
    }
    for (counter=0;counter<len_x;counter++) {
        playfield[counter][0]='#';
        playfield[counter][len_y-1]='#';
    }
    for (counter=0;counter<len_y;counter++) {
        playfield[0][counter]='#';
        playfield[len_x-1][counter]='#';
    }
}

canonical_original_code:
void snake_create_playground(char **playfield) {
    int counter;
    int n; int m;
    for(n=0; n < len_x-1; n++) {
        for( m=0; m < len_y-1; m++) {
            playfield[n][m]=' ';
        }
    }
    for (counter=0;counter<len_x;counter++) {
        playfield[counter][0]='#';
        playfield[counter][len_y-1]='#';
    }
    for (counter=0;counter<len_y;counter++) {
        playfield[0][counter]='#';
        playfield[len_x-1][counter]='#';
    }
}

variable_types: counter int

variable_types: n int

variable_types: m int


decompiled_code:
int __fastcall snake_print_out(__int64 a1)
{
__int64 i; // rbp
__int64 j; // rbx
int result; // eax

for ( i = 0LL; len_y > (int)i; ++i )
{
for ( j = 0LL; len_x > (int)j; ++j )
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(a1 + 8 * j) + i));
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
__int64 i; // rbp
__int64 j; // rbx
int result; // eax

for ( i = 0LL; len_y > (int)i; ++i )
{
for ( j = 0LL; len_x > (int)j; ++j )
printf("%c ", (unsigned int)*(char *)(*(_QWORD *)(a1 + 8 * j) + i));
result = putchar(10);
}
return result;
}

original_code:
void snake_print_out (char **playfield) {
    int j,i;
    for (i=0;i<len_y;i++) {
        for( j=0;j<len_x;j++) {
            printf("%c ", playfield[j][i]);
        }
        printf("\n");
    }
}

canonical_original_code:
void snake_print_out(char **playfield) {
    int j; int i;
    for (i=0;i<len_y;i++) {
        for( j=0;j<len_x;j++) {
            printf("%c ", playfield[j][i]);
        }
        printf("\n");
    }
}

variable_types: j int

variable_types: i int


decompiled_code:
int *__fastcall create_snake(__int64 a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12
int *result; // rax

v1 = len_x / 2;
v2 = len_y / 2;
anhaengen((unsigned int)(len_x / 2 - 2), (unsigned int)(len_y / 2));
anhaengen(v1 - 1, v2);
anhaengen(v1, v2);
anhaengen(v1 + 1, v2);
result = (int *)anfang;
if ( anfang )
{
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 8LL * *result) + result[1]) = 64;
result = (int *)*((_QWORD *)result + 1);
}
while ( result );
}
return result;
}

canonical_decompiled_code:
int *__fastcall func5(__int64 a1)
{
unsigned int v1; // ebp
unsigned int v2; // er12
int *result; // rax

v1 = len_x / 2;
v2 = len_y / 2;
anhaengen((unsigned int)(len_x / 2 - 2), (unsigned int)(len_y / 2));
anhaengen(v1 - 1, v2);
anhaengen(v1, v2);
anhaengen(v1 + 1, v2);
result = (int *)anfang;
if ( anfang )
{
do
{
*(_BYTE *)(*(_QWORD *)(a1 + 8LL * *result) + result[1]) = 64;
result = (int *)*((_QWORD *)result + 1);
}
while ( result );
}
return result;
}

original_code:
void create_snake (char **playfield) {
    int mittex = len_x / 2;
    int mittey = len_y / 2;
    anhaengen(mittex-2,mittey);
    anhaengen(mittex-1,mittey);
    anhaengen(mittex,mittey);
    anhaengen(mittex+1,mittey);
    struct snake *zeiger;
    zeiger=anfang;
    while( zeiger != ((void *)0)) {
        int x=zeiger->xachse;
        int y=zeiger->yachse;
        playfield[x][y]='@';
        zeiger=zeiger->next;
    }
}

canonical_original_code:
void create_snake(char **playfield) {
    int mittex = len_x / 2;
    int mittey = len_y / 2;
    anhaengen(mittex-2,mittey);
    anhaengen(mittex-1,mittey);
    anhaengen(mittex,mittey);
    anhaengen(mittex+1,mittey);
    struct snake *zeiger;
    zeiger=anfang;
    while( zeiger != ((void *)0)) {
        int x = zeiger->xachse;
        int y = zeiger->yachse;
        playfield[x][y]='@';
        zeiger=zeiger->next;
    }
}

variable_types: mittex int

variable_types: mittey int

variable_types: x int

variable_types: y int

user_defined_types: struct snake { int xachse; int yachse; struct snake *next; struct snake *previous; }


zufallsauswahl

decompiled_code:
__int64 __fastcall zufallsauswahl(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1 + 1) + a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1 + 1) + a1);
}

original_code:
int zufallsauswahl (int minimum, int maximum) {
    int bereich = maximum - minimum + 1;
    int zahl = minimum + ( rand() % bereich );
    return zahl;
}

canonical_original_code:
int zufallsauswahl(int minimum, int maximum) {
    int bereich = maximum - minimum + 1;
    int zahl = minimum + ( rand() % bereich );
    return zahl;
}

variable_types: minimum int

variable_types: maximum int

variable_types: bereich int

variable_types: zahl int


decompiled_code:
int __fastcall special_point(__int64 a1)
{
_QWORD *v1; // r12
__int64 v2; // rbp
int v3; // eax
_BYTE *v4; // rax
int v5; // ecx
int result; // eax
pthread_t v7; // [rsp+0h] [rbp-28h] BYREF
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = malloc(8uLL);
if ( !v1 )
puts("Konnte keinen Speicher reservieren...!!!");
*v1 = a1;
v2 = 536871043LL;
do
{
specialpoint = zufallsauswahl(1, len_x);
v3 = zufallsauswahl(1, len_y);
*(&specialpoint + 1) = v3;
v4 = (_BYTE *)(*(_QWORD *)(a1 + 8LL * specialpoint) + v3);
v5 = (unsigned __int8)*v4;
}
while ( (unsigned __int8)(v5 - 35) <= 0x1Du && _bittest64(&v2, (unsigned int)(v5 - 35)) );
*v4 = 36;
special_point_active = 1;
sync_del_special_point = 0;
if ( pthread_create(&v7, 0LL, (void *(*)(void *))special_point_blink, v1) )
{
puts("Konnte keinen Thread erzeugen");
exit(1);
}
result = pthread_create(newthread, 0LL, (void *(*)(void *))del_special_point, v1);
if ( result )
{
puts("Konnte keinen Thread erzeugen");
exit(1);
}
return result;
}

canonical_decompiled_code:
int __fastcall func7(__int64 a1)
{
_QWORD *v1; // r12
__int64 v2; // rbp
int v3; // eax
_BYTE *v4; // rax
int v5; // ecx
int result; // eax
pthread_t v7; // [rsp+0h] [rbp-28h] BYREF
pthread_t newthread[4]; // [rsp+8h] [rbp-20h] BYREF

v1 = malloc(8uLL);
if ( !v1 )
puts("Konnte keinen Speicher reservieren...!!!");
*v1 = a1;
v2 = 536871043LL;
do
{
specialpoint = func6(1, len_x);
v3 = func6(1, len_y);
*(&specialpoint + 1) = v3;
v4 = (_BYTE *)(*(_QWORD *)(a1 + 8LL * specialpoint) + v3);
v5 = (unsigned __int8)*v4;
}
while ( (unsigned __int8)(v5 - 35) <= 0x1Du && _bittest64(&v2, (unsigned int)(v5 - 35)) );
*v4 = 36;
special_point_active = 1;
sync_del_special_point = 0;
if ( pthread_create(&v7, 0LL, (void *(*)(void *))special_point_blink, v1) )
{
puts("Konnte keinen Thread erzeugen");
exit(1);
}
result = pthread_create(newthread, 0LL, (void *(*)(void *))del_special_point, v1);
if ( result )
{
puts("Konnte keinen Thread erzeugen");
exit(1);
}
return result;
}

original_code:
void special_point ( char **playfield) {
    pthread_t th1,th2;
    struct parameter *f;
    f = (struct parameter *)malloc(sizeof(struct parameter));
    if( f==((void *)0)) {
        printf("Konnte keinen Speicher reservieren...!!!\n");
    }
    f->array=playfield;
    do {
        specialpoint.x= zufallsauswahl(1,len_x);
        specialpoint.y= zufallsauswahl(1,len_y);
    } while ( playfield[specialpoint.x][specialpoint.y]=='@' || playfield[specialpoint.x][specialpoint.y]== '*' || playfield[specialpoint.x][specialpoint.y]== '#' || playfield[specialpoint.x][specialpoint.y]== '$');
    playfield[specialpoint.x][specialpoint.y]='$';
    special_point_active=1;
    sync_del_special_point=0;
    if( pthread_create(&th2,((void *)0), &special_point_blink,f) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
    if (pthread_create (&th1,((void *)0),&del_special_point,f) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
}

canonical_original_code:
void special_point(char **playfield) {
    unsigned long th1; unsigned long th2;
    struct parameter *f;
    f = (struct parameter *)malloc(sizeof(struct parameter));
    if( f==((void *)0)) {
        printf("Konnte keinen Speicher reservieren...!!!\n");
    }
    f->array=playfield;
    do {
        specialpoint.x= zufallsauswahl(1,len_x);
        specialpoint.y= zufallsauswahl(1,len_y);
    } while ( playfield[specialpoint.x][specialpoint.y]=='@' || playfield[specialpoint.x][specialpoint.y]== '*' || playfield[specialpoint.x][specialpoint.y]== '#' || playfield[specialpoint.x][specialpoint.y]== '$');
    playfield[specialpoint.x][specialpoint.y]='$';
    special_point_active=1;
    sync_del_special_point=0;
    if( pthread_create(&th2,((void *)0), &special_point_blink,f) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
    if (pthread_create (&th1,((void *)0),&del_special_point,f) != 0) {
        printf ("Konnte keinen Thread erzeugen\n");
        exit (1);
    }
}

variable_types:
playfield
char **


anhaengen

decompiled_code:
__int64 __fastcall anhaengen(int a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
__int64 result; // rax

if ( !ende )
{
ende = (__int64)malloc(0x18uLL);
if ( !ende )
{
puts(s);
exit(0);
}
}
v2 = anfang;
if ( anfang )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[1];
}
while ( v2 );
result = (__int64)malloc(0x18uLL);
v3[1] = result;
if ( result )
{
*(_DWORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = 0LL;
ende = result;
*(_QWORD *)(result + 16) = v3;
v3[1] = result;
}
else
{
result = fwrite(&unk_1E8, 1uLL, 0x2BuLL, stderr);
}
}
else
{
result = (__int64)malloc(0x18uLL);
anfang = (void *)result;
if ( result )
{
*(_DWORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = 0LL;
ende = result;
*(_QWORD *)(result + 16) = 0LL;
}
else
{
result = fwrite(&unk_1B8, 1uLL, 0x29uLL, stderr);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbx
__int64 result; // rax

if ( !ende )
{
ende = (__int64)malloc(0x18uLL);
if ( !ende )
{
puts(s);
exit(0);
}
}
v2 = anfang;
if ( anfang )
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[1];
}
while ( v2 );
result = (__int64)malloc(0x18uLL);
v3[1] = result;
if ( result )
{
*(_DWORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = 0LL;
ende = result;
*(_QWORD *)(result + 16) = v3;
v3[1] = result;
}
else
{
result = fwrite(&unk_1E8, 1uLL, 0x2BuLL, stderr);
}
}
else
{
result = (__int64)malloc(0x18uLL);
anfang = (void *)result;
if ( result )
{
*(_DWORD *)result = a1;
*(_DWORD *)(result + 4) = a2;
*(_QWORD *)(result + 8) = 0LL;
ende = result;
*(_QWORD *)(result + 16) = 0LL;
}
else
{
result = fwrite(&unk_1B8, 1uLL, 0x29uLL, stderr);
}
}
return result;
}

original_code:
void anhaengen(int xachse, int yachse) {
    struct snake *zeiger, *zeiger1;
    if(ende == ((void *)0)) {
        if((ende = malloc(sizeof(struct snake))) == ((void *)0)) {
            printf("Konnte keinen Speicherplatz für ende reservieren\n");
            exit(0);
        }
    }
    if(anfang == ((void *)0)) {
        if((anfang = malloc(sizeof(struct snake))) == ((void *)0)) {
            fprintf(stderr, "Kein Speicherplatz vorhanden für anfang\n");
            return;
        }
        anfang->xachse=xachse;
        anfang->yachse=yachse;
        anfang->next=((void *)0);
        ende=anfang;
        ende->previous=((void *)0);
    }
    else {
        zeiger=anfang;
        while(zeiger->next != ((void *)0))
            zeiger=zeiger->next;
        if((zeiger->next =malloc(sizeof(struct snake))) == ((void *)0)) {
            fprintf(stderr,"Kein Speicherplatz für das "
                    "letzte Element\n");
            return;
        }
        zeiger1=zeiger;
        zeiger=zeiger->next;
        zeiger->xachse=xachse;
        zeiger->yachse=yachse;
        zeiger->next=((void *)0);
        ende=zeiger;
        zeiger->previous=zeiger1;
        zeiger1->next=zeiger;
    }
}

canonical_original_code:
void anhaengen(int xachse, int yachse) {
    struct snake *zeiger; struct snake *zeiger1;
    if(ende == ((void *)0)) {
        if((ende = malloc(sizeof(struct snake))) == ((void *)0)) {
            printf("Konnte keinen Speicherplatz für ende reservieren\n");
            exit(0);
        }
    }
    if(anfang == ((void *)0)) {
        if((anfang = malloc(sizeof(struct snake))) == ((void *)0)) {
            fprintf(stderr, "Kein Speicherplatz vorhanden für anfang\n");
            return;
        }
        anfang->xachse=xachse;
        anfang->yachse=yachse;
        anfang->next=((void *)0);
        ende=anfang;
        ende->previous=((void *)0);
    }
    else {
        zeiger=anfang;
        while(zeiger->next != ((void *)0))
            zeiger=zeiger->next;
        if((zeiger->next =malloc(sizeof(struct snake))) == ((void *)0)) {
            fprintf(stderr,"Kein Speicherplatz für das "
                    "letzte Element\n");
            return;
        }
        zeiger1=zeiger;
        zeiger=zeiger->next;
        zeiger->xachse=xachse;
        zeiger->yachse=yachse;
        zeiger->next=((void *)0);
        ende=zeiger;
        zeiger->previous=zeiger1;
        zeiger1->next=zeiger;
    }
}

variable_types: xachse int

variable_types: yachse int


decompiled_code:
void __fastcall del_first(__int64 a1)
{
_QWORD *v1; // rbx

v1 = (_QWORD *)*((_QWORD *)anfang + 1);
*(_BYTE *)(*(_QWORD *)(a1 + 8LL * *(int *)anfang) + *((int *)anfang + 1)) = 32;
if ( v1 )
{
v1[2] = 0LL;
free(anfang);
anfang = v1;
}
else
{
free(anfang);
anfang = 0LL;
ende = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
_QWORD *v1; // rbx

v1 = (_QWORD *)*((_QWORD *)anfang + 1);
*(_BYTE *)(*(_QWORD *)(a1 + 8LL * *(int *)anfang) + *((int *)anfang + 1)) = 32;
if ( v1 )
{
v1[2] = 0LL;
free(anfang);
anfang = v1;
}
else
{
free(anfang);
anfang = 0LL;
ende = 0LL;
}
}

original_code:
void del_first(char **playfield) {
    struct snake *zeiger;
    zeiger=anfang->next;
    playfield[anfang->xachse][anfang->yachse]=' ';
    if(zeiger == ((void *)0)) {
        free(anfang);
        anfang=((void *)0);
        ende=((void *)0);
        return;
    }
    zeiger->previous=((void *)0);
    free(anfang);
    anfang=zeiger;
}

variable_types: struct snake { int xachse; int yachse; struct snake *next; struct snake *previous; } *


original_code:
void move_snake(char **playfield) {
    if(eingabe==100) {
        struct snake *zeiger1, *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->xachse>=zeiger2->xachse) {
            x_move(1,playfield);
        }
        else if(zeiger1->xachse<zeiger2->xachse) {
            x_move(-1,playfield);
        }
    }
    else if(eingabe==97) {
        struct snake *zeiger1, *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->xachse<=zeiger2->xachse) {
            x_move(-1,playfield);
        }
        if(zeiger1->xachse>zeiger2->xachse) {
            x_move(1,playfield);
        }
    }
    else if(eingabe==119) {
        struct snake *zeiger1, *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse<=zeiger2->yachse) {
            y_move(-1,playfield);
        }
        if( zeiger1->yachse>zeiger2->yachse) {
            y_move(1,playfield);
        }
    }
    else if(eingabe==115) {
        struct snake *zeiger1, *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse>=zeiger2->yachse) {
            y_move(1,playfield);
        }
        if( zeiger1->yachse<zeiger2->yachse) {
            y_move(-1,playfield);
        }
    }
    else {
        struct snake *zeiger1, *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse>zeiger2->yachse) {
            y_move(1,playfield);
        }
        if( zeiger1->yachse<zeiger2->yachse) {
            y_move(-1, playfield);
        }
        if( zeiger1->xachse<zeiger2->xachse) {
            x_move(-1, playfield);
        }
        if(zeiger1->xachse>zeiger2->xachse) {
            x_move(1, playfield);
        }
    }
}

canonical_original_code:
void move_snake(char **playfield) {
    if(eingabe==100) {
        struct snake *zeiger1; struct snake *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->xachse>=zeiger2->xachse) {
            x_move(1,playfield);
        }
        else if(zeiger1->xachse<zeiger2->xachse) {
            x_move(-1,playfield);
        }
    }
    else if(eingabe==97) {
        struct snake *zeiger1; struct snake *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->xachse<=zeiger2->xachse) {
            x_move(-1,playfield);
        }
        if(zeiger1->xachse>zeiger2->xachse) {
            x_move(1,playfield);
        }
    }
    else if(eingabe==119) {
        struct snake *zeiger1; struct snake *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse<=zeiger2->yachse) {
            y_move(-1,playfield);
        }
        if( zeiger1->yachse>zeiger2->yachse) {
            y_move(1,playfield);
        }
    }
    else if(eingabe==115) {
        struct snake *zeiger1; struct snake *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse>=zeiger2->yachse) {
            y_move(1,playfield);
        }
        if( zeiger1->yachse<zeiger2->yachse) {
            y_move(-1,playfield);
        }
    }
    else {
        struct snake *zeiger1; struct snake *zeiger2;
        zeiger1=anfang;
        while(zeiger1->next != ((void *)0)) {
            zeiger1=zeiger1->next;
        }
        zeiger2=zeiger1->previous;
        if( zeiger1->yachse>zeiger2->yachse) {
            y_move(1,playfield);
        }
        if( zeiger1->yachse<zeiger2->yachse) {
            y_move(-1, playfield);
        }
        if( zeiger1->xachse<zeiger2->xachse) {
            x_move(-1, playfield);
        }
        if(zeiger1->xachse>zeiger2->xachse) {
            x_move(1, playfield);
        }
    }
}


decompiled_code:
void __fastcall set_geschwindigkeit(int a1)
{
switch ( a1 )
{
case 1:
game[1] = 300000;
game[0] = 1;
break;
case 2:
game[1] = 200000;
game[0] = 2;
break;
case 3:
game[1] = 100000;
game[0] = 3;
break;
case 4:
game[1] = 80000;
game[0] = 4;
break;
case 5:
game[1] = 70000;
game[0] = 5;
break;
case 6:
game[1] = 60000;
game[0] = 6;
break;
case 7:
game[1] = 50000;
game[0] = 7;
break;
case 8:
game[1] = 40000;
game[0] = 8;
break;
case 9:
game[1] = 30000;
game[0] = 9;
break;
default:
game[1] = 80000;
game[0] = 4;
break;
}
}

original_code:
void set_geschwindigkeit(int eingabe) {
    switch(eingabe) {
    case 1:
        game.geschwindigkeit=300000;
        game.level=1;
        break;
    case 2:
        game.geschwindigkeit=200000;
        game.level=2;
        break;
    case 3:
        game.geschwindigkeit=100000;
        game.level=3;
        break;
    case 4:
        game.geschwindigkeit=80000;
        game.level=4;
        break;
    case 5:
        game.geschwindigkeit=70000;
        game.level=5;
        break;
    case 6:
        game.geschwindigkeit=60000;
        game.level=6;
        break;
    case 7:
        game.geschwindigkeit=50000;
        game.level=7;
        break;
    case 8:
        game.geschwindigkeit=40000;
        game.level=8;
        break;
    case 9:
        game.geschwindigkeit=30000;
        game.level=9;
        break;
    default:
        game.geschwindigkeit=80000;
        game.level=4;
        break;
    }
}

variable_types: eingabe int


decompiled_code:
void __noreturn show_help_screen()
{
puts("asnake\nReleased under the GNU GPL.");
puts("-s =SPEED\t Set the speed of the snake, default is 5");
puts("-h\t\t Show this help screen");
exit(0);
}

canonical_decompiled_code:
void __noreturn func1()
{
puts("asnake\nReleased under the GNU GPL.");
puts("-s =SPEED\t Set the speed of the snake, default is 5");
puts("-h\t\t Show this help screen");
exit(0);
}

original_code:
void show_help_screen() {
    printf("asnake\nReleased under the GNU GPL.\n");
    printf("-s =SPEED\t Set the speed of the snake, default is 5\n");
    printf("-h\t\t Show this help screen\n");
    exit(0);
}


decompiled_code:
__int64 __fastcall check_args(int argc, char **argv)
{
int v2; // eax
int v3; // eax
unsigned int v4; // ebx
__int64 result; // rax

opterr = 0;
while ( 1 )
{
v2 = getopt(argc, argv, "dhs:");
if ( v2 == -1 )
break;
if ( v2 != 100 )
{
if ( v2 <= 100 )
{
if ( v2 != 63 )
LABEL_17:
abort();
v4 = optopt;
if ( optopt == 115 )
{
fprintf(stderr, "Option -%c requires an argument.\n", 115LL);
}
else if ( ((*_ctype_b_loc())[v4] & 0x4000) != 0 )
{
fprintf(stderr, "Unknown option '-%c'.\n", v4);
}
else
{
fprintf(stderr, "Unknown option character '\\x%x'.\n", v4);
}
goto LABEL_12;
}
if ( v2 == 104 )
show_help_screen();
if ( v2 != 115 )
goto LABEL_17;
v3 = atoi(optarg);
set_geschwindigkeit(v3);
}
}
result = (unsigned int)optind;
if ( argc > optind )
{
printf("Non-option argument %s\n", argv[optind]);
LABEL_12:
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int argc, char **argv)
{
int v2; // eax
int v3; // eax
unsigned int v4; // ebx
__int64 result; // rax

opterr = 0;
while ( 1 )
{
v2 = getopt(argc, argv, "dhs:");
if ( v2 == -1 )
break;
if ( v2 != 100 )
{
if ( v2 <= 100 )
{
if ( v2 != 63 )
LABEL_17:
abort();
v4 = optopt;
if ( optopt == 115 )
{
fprintf(stderr, "Option -%c requires an argument.\n", 115LL);
}
else if ( ((*_ctype_b_loc())[v4] & 0x4000) != 0 )
{
fprintf(stderr, "Unknown option '-%c'.\n", v4);
}
else
{
fprintf(stderr, "Unknown option character '\\x%x'.\n", v4);
}
goto LABEL_12;
}
if ( v2 == 104 )
func1();
if ( v2 != 115 )
goto LABEL_17;
v3 = atoi(optarg);
func0(v3);
}
}
result = (unsigned int)optind;
if ( argc > optind )
{
printf("Non-option argument %s\n", argv[optind]);
LABEL_12:
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int check_args(int argc, char *argv[]) {
    int dflag = 0;
    int hflag = 0;
    char *svalue = ((void *)0);
    int index;
    int c;
    opterr = 0;
    while ((c = getopt (argc, argv, "dhs:")) != -1)
        switch (c) {
        case 'd':
            dflag = 1;
            break;
        case 'h':
            hflag = 1;
            show_help_screen();
            break;
        case 's':
            svalue = optarg;
            set_geschwindigkeit(atoi(svalue));
            break;
        case '?':
            if (optopt == 's') {
                fprintf(stderr, "Option -%c requires an argument.\n", optopt);
            }
            else if (((*__ctype_b_loc ())[(int) ((optopt))] & (unsigned short int) _ISprint)) {
                fprintf(stderr, "Unknown option '-%c'.\n", optopt);
            }
            else
                fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
            return -1;
        default:
            abort ();
        }
    for (index = optind; index < argc; index++) {
        printf("Non-option argument %s\n", argv[index]);
        return -1;
    }
}

canonical_original_code:
int check_args(int argc, char *argv[]) {
    int dflag = 0;
    int hflag = 0;
    char *svalue = ((void *)0);
    int index;
    int c;
    opterr = 0;
    while ((c = getopt (argc, argv, "dhs:")) != -1)
        switch (c) {
        case 'd':
            dflag = 1;
            break;
        case 'h':
            hflag = 1;
            show_help_screen();
            break;
        case 's':
            svalue = optarg;
            set_geschwindigkeit(atoi(svalue));
            break;
        case '?':
            if (optopt == 's') {
                fprintf(stderr, "Option -%c requires an argument.\n", optopt);
            }
            else if (((*__ctype_b_loc ())[(int) ((optopt))] & (unsigned short) _ISprint)) {
                fprintf(stderr, "Unknown option '-%c'.\n", optopt);
            }
            else
                fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
            return -1;
        default:
            abort ();
        }
    for (index = optind; index < argc; index++) {
        printf("Non-option argument %s\n", argv[index]);
        return -1;
    }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: dflag int

variable_types: hflag int

variable_types:
svalue
char *

variable_types: index int

variable_types: c int


showHelp

decompiled_code:
void __fastcall __noreturn showHelp(const char *a1)
{
printf("%s [options]\n\n", a1);
printf(
"Varies the fan speed with PWM when temperature is between lower and upper bounds\n"
"\n"
"-f Force update PWM each time temperature is checked (default: false)\n"
"-d Daemon mode\n"
"-u n At or above this temperature (degrees C), fan at 100%% (default: 80)\n"
"-l n Below this temperature (degrees C), fan off (default: 45)\n"
"-m n Operating mode (default: 0)\n"
" 0 = auto-detect\n"
" 1 = force kernel 3.0 mode\n"
" 2 = force kernel 3.8+ mode\n"
" -i n Interval (seconds) between probes (default: 1)\n"
"\n");
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func9(const char *a1)
{
printf("%s [options]\n\n", a1);
printf(
"Varies the fan speed with PWM when temperature is between lower and upper bounds\n"
"\n"
"-f Force update PWM each time temperature is checked (default: false)\n"
"-d Daemon mode\n"
"-u n At or above this temperature (degrees C), fan at 100%% (default: 80)\n"
"-l n Below this temperature (degrees C), fan off (default: 45)\n"
"-m n Operating mode (default: 0)\n"
" 0 = auto-detect\n"
" 1 = force kernel 3.0 mode\n"
" 2 = force kernel 3.8+ mode\n"
" -i n Interval (seconds) between probes (default: 1)\n"
"\n");
exit(0);
}

original_code:
void showHelp ( const char * me )
{
    printf ( "%s [options]\n\n", me );
    printf ( "Varies the fan speed with PWM when temperature is between lower and upper bounds\n\n"
             "-f    Force update PWM each time temperature is checked (default: false)\n"
             "-d    Daemon mode\n"
             "-u n  At or above this temperature (degrees C), fan at 100%% (default: 80)\n"
             "-l n  Below this temperature (degrees C), fan off (default: 45)\n"
             "-m n  Operating mode (default: 0)\n"
             "      0 = auto-detect\n"
             "      1 = force kernel 3.0 mode\n"
             "      2 = force kernel 3.8+ mode\n"
             " -i n Interval (seconds) between probes (default: 1)\n"
             "\n" );
    exit ( 0 );
}

canonical_original_code:
void showHelp(char *me)
{
    printf ( "%s [options]\n\n", me );
    printf ( "Varies the fan speed with PWM when temperature is between lower and upper bounds\n\n"
             "-f    Force update PWM each time temperature is checked (default: false)\n"
             "-d    Daemon mode\n"
             "-u n  At or above this temperature (degrees C), fan at 100%% (default: 80)\n"
             "-l n  Below this temperature (degrees C), fan off (default: 45)\n"
             "-m n  Operating mode (default: 0)\n"
             "      0 = auto-detect\n"
             "      1 = force kernel 3.0 mode\n"
             "      2 = force kernel 3.8+ mode\n"
             " -i n Interval (seconds) between probes (default: 1)\n"
             "\n" );
    exit ( 0 );
}

variable_types:
me
char *