threadRun

decompiled_code:
void __noreturn threadRun()
{
shopLocked = 0;
shopInvRestocking = 0;
while ( 1 )
{
if ( shopInvRestocking == 1 && (unsigned int)SDL_GetTicks() - lastChangedInv > 0x4E1F )
{
SDL_SemWait(shopLock);
setDefaultGenieStock();
shopInvRestocking = 0;
SDL_SemPost(shopLock);
}
SDL_Delay(2500LL);
if ( shopLocked == 1 && (unsigned int)SDL_GetTicks() - lastOpenShop > 0x270F )
{
SDL_SemWait(shopLock);
shopLocked = 0;
SDL_SemPost(shopLock);
}
}
}

canonical_decompiled_code:
void __noreturn func0()
{
shopLocked = 0;
shopInvRestocking = 0;
while ( 1 )
{
if ( shopInvRestocking == 1 && (unsigned int)SDL_GetTicks() - lastChangedInv > 0x4E1F )
{
SDL_SemWait(shopLock);
setDefaultGenieStock();
shopInvRestocking = 0;
SDL_SemPost(shopLock);
}
SDL_Delay(2500LL);
if ( shopLocked == 1 && (unsigned int)SDL_GetTicks() - lastOpenShop > 0x270F )
{
SDL_SemWait(shopLock);
shopLocked = 0;
SDL_SemPost(shopLock);
}
}
}

original_code:
int threadRun() {
 shopLocked = 0;
 shopInvRestocking = 0;
 while(1) {
  if(shopLocked == 1 && SDL_GetTicks() - lastOpenShop >= timeOpenShop) {
   SDL_SemWait(shopLock);
   shopLocked = 0;
   SDL_SemPost(shopLock);
  }
  if(shopInvRestocking == 1 && SDL_GetTicks() - lastChangedInv >= timeRestockInv) {
   SDL_SemWait(shopLock);
   setDefaultGenieStock();
   shopInvRestocking = 0;
   SDL_SemPost(shopLock);
  }
  SDL_Delay(2500);
 }
 return 0;
}


threadInit

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

if ( threadingAlready == 1 )
{
puts("threadInit: SEVERE ERROR, thread init called twice");
result = 1LL;
}
else
{
threadingAlready = 1;
thread = SDL_CreateThread(threadRun, 0LL);
shopLock = SDL_CreateSemaphore(1LL);
result = 0LL;
}
return result;
}

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

if ( threadingAlready == 1 )
{
puts("threadInit: SEVERE ERROR, thread init called twice");
result = 1LL;
}
else
{
threadingAlready = 1;
thread = SDL_CreateThread(threadRun, 0LL);
shopLock = SDL_CreateSemaphore(1LL);
result = 0LL;
}
return result;
}

original_code:
int threadInit() {
 if(threadingAlready == 1) {
  printf("threadInit: SEVERE ERROR, thread init called twice\n");
  return 1;
 }
 threadingAlready = 1;
 thread = SDL_CreateThread( threadRun, ((void *)0) );
 shopLock = SDL_CreateSemaphore( 1 );
 return 0;
}

return_type: int


threadCleanup

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

if ( thread )
{
result = SDL_KillThread();
thread = 0LL;
}
threadingAlready = 0;
if ( shopLock )
{
result = SDL_DestroySemaphore();
shopLock = 0LL;
}
return result;
}

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

if ( thread )
{
result = SDL_KillThread();
thread = 0LL;
}
threadingAlready = 0;
if ( shopLock )
{
result = SDL_DestroySemaphore();
shopLock = 0LL;
}
return result;
}

original_code:
void threadCleanup() {
 if(thread != ((void *)0)) {
  SDL_KillThread(thread);
  thread = ((void *)0);
 }
 threadingAlready = 0;
 if(shopLock != ((void *)0)) {
  SDL_DestroySemaphore( shopLock);
  shopLock = ((void *)0);
 }
}

return_type: void


checkForTreasureChest

decompiled_code:
__int64 __fastcall checkForTreasureChest(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = checkTreasureChestData(a2, a1);
if ( (_DWORD)result == 1 )
{
result = (int)a2 + 40LL * (int)a1 + 4;
if ( *((_DWORD *)&samplemap + result) == 520 )
{
addTreasureChestData(a2, a1);
result = openATreasureChest();
}
}
return result;
}

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

result = checkTreasureChestData(a2, a1);
if ( (_DWORD)result == 1 )
{
result = (int)a2 + 40LL * (int)a1 + 4;
if ( *((_DWORD *)&samplemap + result) == 520 )
{
addTreasureChestData(a2, a1);
result = openATreasureChest();
}
}
return result;
}

original_code:
void checkForTreasureChest(int y, int x){
 if((checkTreasureChestData(x ,y) == 1) && (samplemap.tile[y][x] == 520)) {
  addTreasureChestData(x , y);
  openATreasureChest();
 }
}

variable_types: y int

variable_types: x int


drawMap

decompiled_code:
__int64 drawMap()
{
int v0; // eax
int v1; // er15
int v2; // edx
int v3; // ebx
int v4; // eax
unsigned int v5; // er12
int v6; // edx
unsigned int v7; // er14
unsigned int v8; // ebp
_DWORD *v9; // r13
__int64 result; // rax
unsigned int v11; // [rsp+Ch] [rbp-4Ch]
__int64 v12; // [rsp+10h] [rbp-48h]
int v13; // [rsp+18h] [rbp-40h]
int v14; // [rsp+1Ch] [rbp-3Ch]

v0 = samplemap[0] % 40;
v13 = 40 * (samplemap[0] / 40) - samplemap[0];
if ( samplemap[0] % 40 )
v0 = 40;
v1 = v0 + 800 - samplemap[0] % 40;
v2 = samplemap[1];
v3 = v2 / 40;
v11 = v2 / 40;
v4 = v2 % 40;
v5 = 40 * (v2 / 40) - v2;
v6 = 600 - v2 % 40;
if ( v4 )
v4 = 40;
v14 = v6 + v4;
drawImage(backgroundImage, 0LL, 0LL);
v12 = 40LL * v3;
do
{
v7 = samplemap[0] / 40;
result = v12 + samplemap[0] / 40 + 4;
v9 = &samplemap[result];
v8 = v13;
do
{
if ( !*v9 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 510 )
result = drawImage(WAT_TILE, v8, v5);
if ( *v9 == 1 )
result = drawImage(GRA_TILE, v8, v5);
if ( *v9 == 2 )
result = drawImage(SNO_TILE, v8, v5);
if ( *v9 == 3 )
result = drawImage(RED_TILE, v8, v5);
if ( *v9 == 11 )
result = drawImage(DUN_WAT_R_TILE, v8, v5);
if ( *v9 == 12 )
result = drawImage(DUN_WAT_L_TILE, v8, v5);
if ( *v9 == 13 )
result = drawImage(DUN_WAT_T_TILE, v8, v5);
if ( *v9 == 14 )
result = drawImage(DUN_WAT_B_TILE, v8, v5);
if ( *v9 == 15 )
result = drawImage(DUN_WAT_TR_TILE, v8, v5);
if ( *v9 == 16 )
result = drawImage(DUN_WAT_TL_TILE, v8, v5);
if ( *v9 == 17 )
result = drawImage(DUN_WAT_BR_TILE, v8, v5);
if ( *v9 == 18 )
result = drawImage(DUN_WAT_BL_TILE, v8, v5);
if ( *v9 == 501 )
result = drawImage(DUN_EMP_R_TILE, v8, v5);
if ( *v9 == 502 )
result = drawImage(DUN_EMP_L_TILE, v8, v5);
if ( *v9 == 503 )
result = drawImage(DUN_EMP_T_TILE, v8, v5);
if ( *v9 == 505 )
result = drawImage(DUN_EMP_TR_TILE, v8, v5);
if ( *v9 == 506 )
result = drawImage(DUN_EMP_TL_TILE, v8, v5);
if ( *v9 == 101 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 102 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 103 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 520 )
{
if ( (unsigned int)checkTreasureChestData(v7, v11) == 1 )
result = drawImage(TRE_CLD_TILE, v8, v5);
else
result = drawImage(TRE_OPN_TILE, v8, v5);
}
++v7;
v8 += 40;
++v9;
}
while ( v1 > (int)v8 );
++v11;
v5 += 40;
v12 += 40LL;
}
while ( v14 > (int)v5 );
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
int v1; // er15
int v2; // edx
int v3; // ebx
int v4; // eax
unsigned int v5; // er12
int v6; // edx
unsigned int v7; // er14
unsigned int v8; // ebp
_DWORD *v9; // r13
__int64 result; // rax
unsigned int v11; // [rsp+Ch] [rbp-4Ch]
__int64 v12; // [rsp+10h] [rbp-48h]
int v13; // [rsp+18h] [rbp-40h]
int v14; // [rsp+1Ch] [rbp-3Ch]

v0 = samplemap[0] % 40;
v13 = 40 * (samplemap[0] / 40) - samplemap[0];
if ( samplemap[0] % 40 )
v0 = 40;
v1 = v0 + 800 - samplemap[0] % 40;
v2 = samplemap[1];
v3 = v2 / 40;
v11 = v2 / 40;
v4 = v2 % 40;
v5 = 40 * (v2 / 40) - v2;
v6 = 600 - v2 % 40;
if ( v4 )
v4 = 40;
v14 = v6 + v4;
drawImage(backgroundImage, 0LL, 0LL);
v12 = 40LL * v3;
do
{
v7 = samplemap[0] / 40;
result = v12 + samplemap[0] / 40 + 4;
v9 = &samplemap[result];
v8 = v13;
do
{
if ( !*v9 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 510 )
result = drawImage(WAT_TILE, v8, v5);
if ( *v9 == 1 )
result = drawImage(GRA_TILE, v8, v5);
if ( *v9 == 2 )
result = drawImage(SNO_TILE, v8, v5);
if ( *v9 == 3 )
result = drawImage(RED_TILE, v8, v5);
if ( *v9 == 11 )
result = drawImage(DUN_WAT_R_TILE, v8, v5);
if ( *v9 == 12 )
result = drawImage(DUN_WAT_L_TILE, v8, v5);
if ( *v9 == 13 )
result = drawImage(DUN_WAT_T_TILE, v8, v5);
if ( *v9 == 14 )
result = drawImage(DUN_WAT_B_TILE, v8, v5);
if ( *v9 == 15 )
result = drawImage(DUN_WAT_TR_TILE, v8, v5);
if ( *v9 == 16 )
result = drawImage(DUN_WAT_TL_TILE, v8, v5);
if ( *v9 == 17 )
result = drawImage(DUN_WAT_BR_TILE, v8, v5);
if ( *v9 == 18 )
result = drawImage(DUN_WAT_BL_TILE, v8, v5);
if ( *v9 == 501 )
result = drawImage(DUN_EMP_R_TILE, v8, v5);
if ( *v9 == 502 )
result = drawImage(DUN_EMP_L_TILE, v8, v5);
if ( *v9 == 503 )
result = drawImage(DUN_EMP_T_TILE, v8, v5);
if ( *v9 == 505 )
result = drawImage(DUN_EMP_TR_TILE, v8, v5);
if ( *v9 == 506 )
result = drawImage(DUN_EMP_TL_TILE, v8, v5);
if ( *v9 == 101 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 102 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 103 )
result = drawImage(DUN_TILE, v8, v5);
if ( *v9 == 520 )
{
if ( (unsigned int)checkTreasureChestData(v7, v11) == 1 )
result = drawImage(TRE_CLD_TILE, v8, v5);
else
result = drawImage(TRE_OPN_TILE, v8, v5);
}
++v7;
v8 += 40;
++v9;
}
while ( v1 > (int)v8 );
++v11;
v5 += 40;
v12 += 40LL;
}
while ( v14 > (int)v5 );
return result;
}

original_code:
void drawMap()
{
    int x, y, mapX, x1, x2, mapY, y1, y2;
    mapX = samplemap.startX / 40;
    x1 = (samplemap.startX % 40) * -1;
    x2 = x1 + 800 + (x1 == 0 ? 0 : 40);
    mapY = samplemap.startY / 40;
    y1 = (samplemap.startY % 40) * -1;
    y2 = y1 + 600 + (y1 == 0 ? 0 : 40);
    drawImage(backgroundImage, 0, 0);
    for (y=y1;y<y2;y+=40)
    {
        mapX = samplemap.startX / 40;
        for (x=x1;x<x2;x+=40)
        {
         if (samplemap.tile[mapY][mapX] == 0) {
                 drawImage(DUN_TILE, x, y);
             }
  if(samplemap.tile[mapY][mapX] == 510) {
   drawImage(WAT_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 1) {
   drawImage(GRA_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 2) {
   drawImage(SNO_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 3) {
  drawImage(RED_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 11) {
   drawImage(DUN_WAT_R_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 12) {
   drawImage(DUN_WAT_L_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 13) {
   drawImage(DUN_WAT_T_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 14) {
   drawImage(DUN_WAT_B_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 15) {
   drawImage(DUN_WAT_TR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 16) {
   drawImage(DUN_WAT_TL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 17) {
   drawImage(DUN_WAT_BR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 18) {
   drawImage(DUN_WAT_BL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 501) {
   drawImage(DUN_EMP_R_TILE, x, y);
    }
  if(samplemap.tile[mapY][mapX] == 502) {
   drawImage(DUN_EMP_L_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 503) {
   drawImage(DUN_EMP_T_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 505) {
   drawImage(DUN_EMP_TR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 506) {
   drawImage(DUN_EMP_TL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 101) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 102) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 103) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 520) {
   if(checkTreasureChestData(mapX, mapY) == 1){
    drawImage(TRE_CLD_TILE, x, y);
   }else{
    drawImage(TRE_OPN_TILE, x, y);
   }
      }
            mapX++;
        }
        mapY++;
    }
}

canonical_original_code:
void drawMap()
{
    int x; int y; int mapX; int x1; int x2; int mapY; int y1; int y2;
    mapX = samplemap.startX / 40;
    x1 = (samplemap.startX % 40) * -1;
    x2 = x1 + 800 + (x1 == 0 ? 0 : 40);
    mapY = samplemap.startY / 40;
    y1 = (samplemap.startY % 40) * -1;
    y2 = y1 + 600 + (y1 == 0 ? 0 : 40);
    drawImage(backgroundImage, 0, 0);
    for (y=y1;y<y2;y+=40)
    {
        mapX = samplemap.startX / 40;
        for (x=x1;x<x2;x+=40)
        {
         if (samplemap.tile[mapY][mapX] == 0) {
                 drawImage(DUN_TILE, x, y);
             }
  if(samplemap.tile[mapY][mapX] == 510) {
   drawImage(WAT_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 1) {
   drawImage(GRA_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 2) {
   drawImage(SNO_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 3) {
  drawImage(RED_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 11) {
   drawImage(DUN_WAT_R_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 12) {
   drawImage(DUN_WAT_L_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 13) {
   drawImage(DUN_WAT_T_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 14) {
   drawImage(DUN_WAT_B_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 15) {
   drawImage(DUN_WAT_TR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 16) {
   drawImage(DUN_WAT_TL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 17) {
   drawImage(DUN_WAT_BR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 18) {
   drawImage(DUN_WAT_BL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 501) {
   drawImage(DUN_EMP_R_TILE, x, y);
    }
  if(samplemap.tile[mapY][mapX] == 502) {
   drawImage(DUN_EMP_L_TILE, x, y);
     }
  if(samplemap.tile[mapY][mapX] == 503) {
   drawImage(DUN_EMP_T_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 505) {
   drawImage(DUN_EMP_TR_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 506) {
   drawImage(DUN_EMP_TL_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 101) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 102) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 103) {
   drawImage(DUN_TILE, x, y);
      }
  if(samplemap.tile[mapY][mapX] == 520) {
   if(checkTreasureChestData(mapX, mapY) == 1){
    drawImage(TRE_CLD_TILE, x, y);
   }else{
    drawImage(TRE_OPN_TILE, x, y);
   }
      }
            mapX++;
        }
        mapY++;
    }
}

variable_types: mapX int

variable_types: mapY int


addTreasureChestData

decompiled_code:
__int64 __fastcall addTreasureChestData(int a1, int a2)
{
int v2; // eax
unsigned int v3; // edx
__int64 v5; // rax

v2 = checkTreasureChestData();
v3 = 1;
if ( v2 == 1 )
{
v3 = 1;
v5 = 0LL;
while ( *((_DWORD *)&treasureChestData + 2 * v5) != -1 || *((_DWORD *)&treasureChestData + 2 * v5 + 1) != -1 )
{
if ( ++v5 == 8 )
return v3;
}
*((_DWORD *)&treasureChestData + 2 * (int)v5) = a1;
*((_DWORD *)&treasureChestData + 2 * (int)v5 + 1) = a2;
v3 = 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, int a2)
{
int v2; // eax
unsigned int v3; // edx
__int64 v5; // rax

v2 = checkTreasureChestData();
v3 = 1;
if ( v2 == 1 )
{
v3 = 1;
v5 = 0LL;
while ( *((_DWORD *)&treasureChestData + 2 * v5) != -1 || *((_DWORD *)&treasureChestData + 2 * v5 + 1) != -1 )
{
if ( ++v5 == 8 )
return v3;
}
*((_DWORD *)&treasureChestData + 2 * (int)v5) = a1;
*((_DWORD *)&treasureChestData + 2 * (int)v5 + 1) = a2;
v3 = 0;
}
return v3;
}

original_code:
int addTreasureChestData(int x , int y) {
 int i;
 if(checkTreasureChestData(x , y) == 1){
  for (i = 0; i < 8; i++){
   if(treasureChestData[i][0] == -1 && treasureChestData[i][1] == -1){
    treasureChestData[i][0] = x;
    treasureChestData[i][1] = y;
    return 0;
   }
  }
 }
 return 1;
}

canonical_original_code:
int addTreasureChestData(int x, int y) {
 int i;
 if(checkTreasureChestData(x , y) == 1){
  for (i = 0; i < 8; i++){
   if(treasureChestData[i][0] == -1 && treasureChestData[i][1] == -1){
    treasureChestData[i][0] = x;
    treasureChestData[i][1] = y;
    return 0;
   }
  }
 }
 return 1;
}

variable_types: i int


victory

decompiled_code:
void victory()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
int victory() {
}

canonical_original_code:
int victory() {
}


errorMem

decompiled_code:
__int64 __fastcall errorMem(unsigned int a1)
{
printf("\nError en memoria.\nLinea: %d\n", a1);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
printf("\nError en memoria.\nLinea: %d\n", a1);
return 0xFFFFFFFFLL;
}

original_code:
int errorMem(int line) {
    printf("\nError en memoria.\nLinea: %d\n", line);
    return -1;
}

variable_types: line int


errorHilo

decompiled_code:
__int64 __fastcall errorHilo(unsigned int a1)
{
printf("\nError en hilo.\nLinea: %d\n", a1);
return 4294967294LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
printf("\nError en hilo.\nLinea: %d\n", a1);
return 4294967294LL;
}

original_code:
int errorHilo(int line) {
    printf("\nError en hilo.\nLinea: %d\n", line);
    return -2;
}


errorSocket

decompiled_code:
__int64 __fastcall errorSocket(unsigned int a1)
{
printf("\nError en socket.\nLinea: %d\n", a1);
return 4294967292LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
printf("\nError en socket.\nLinea: %d\n", a1);
return 4294967292LL;
}

original_code:
int errorSocket(int line) {
    printf("\nError en socket.\nLinea: %d\n", line);
    return -4;
}


errorFile

decompiled_code:
__int64 __fastcall errorFile(unsigned int a1)
{
printf("\nError en escritura/lectura de archivos.\nLinea: %d\n", a1);
return 4294967291LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
printf("\nError en escritura/lectura de archivos.\nLinea: %d\n", a1);
return 4294967291LL;
}

original_code:
int errorFile(int line) {
    printf("\nError en escritura/lectura de archivos.\nLinea: %d\n", line);
    return -5;
}


decompiled_code:
_DWORD *create_queue()
{
_DWORD *v0; // rax
_DWORD *v1; // rbx

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*(_QWORD *)v0 = 0LL;
v0[4] = 0;
}
else
{
errorMem(25LL);
}
return v1;
}

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

v0 = malloc(0x18uLL);
v1 = v0;
if ( v0 )
{
*(_QWORD *)v0 = 0LL;
v0[4] = 0;
}
else
{
errorMem(25LL);
}
return v1;
}

original_code:
queue create_queue() {
    queue q;
    if ((q = (queue) malloc(sizeof(struct queue))) == ((void *)0)) {
        errorMem(25);
        return ((void *)0);
    }
    q->first = ((void *)0);
    q->size = 0;
    return q;
}

canonical_original_code:
struct queue *create_queue() {
    struct queue *q;
    if ((q = (struct queue *) malloc(sizeof(struct queue))) == ((void *)0)) {
        errorMem(25);
        return ((void *)0);
    }
    q->first = ((void *)0);
    q->size = 0;
    return q;
}

variable_types: struct queue { struct box { struct distr { char *nombre; char *DNS; int puerto; int pr; } *elem; struct box *next; } *first; int size; } *

user_defined_types: struct queue { struct box *first; int size; }

user_defined_types: struct box { struct distr *elem; struct box *next; }


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

if ( a1 )
result = *(_DWORD *)(a1 + 16) == 0;
else
result = 1LL;
return result;
}

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

if ( a1 )
result = *(_DWORD *)(a1 + 16) == 0;
else
result = 1LL;
return result;
}

original_code:
int is_empty(queue q) {
    if (q == ((void *)0)) {
        return 1;
    }
    return !q->size;
}

canonical_original_code:
int is_empty(struct queue *q) {
    if (q == ((void *)0)) {
        return 1;
    }
    return !q->size;
}

user_defined_types: struct distr { char *nombre; char *DNS; int puerto; int pr; }


get

original_code:
distr get(queue q) {
    box *aux;
    distr e;
    if (is_empty(q)) {
        return ((void *)0);
    }
    aux = q->first;
    q->first = q->first->next;
    if (q->size > 1) {
        q->first->prev = ((void *)0);
    }
    e = aux->elem;
    free(aux);
    --(q->size);
    return e;
}

canonical_original_code:
struct distr *get(struct queue *q) {
    struct box *aux;
    struct distr *e;
    if (is_empty(q)) {
        return ((void *)0);
    }
    aux = q->first;
    q->first = q->first->next;
    if (q->size > 1) {
        q->first->prev = ((void *)0);
    }
    e = aux->elem;
    free(aux);
    --(q->size);
    return e;
}

variable_types: struct queue { struct box { struct distr *elem; struct box *next; } *first; int size; } *

variable_types: struct box { struct distr { char *nombre; char *DNS; int puerto; int pr; } *elem; struct box *next; } *


decompiled_code:
void __fastcall clear_queue(__int64 *a1)
{
void *v1; // rax
int *v2; // rbx

if ( a1 && *a1 )
{
while ( 1 )
{
v2 = (int *)*a1;
if ( is_empty(*a1) )
break;
v1 = (void *)get(v2);
free(v1);
}
free(v2);
*a1 = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 *a1)
{
void *v1; // rax
int *v2; // rbx

if ( a1 && *a1 )
{
while ( 1 )
{
v2 = (int *)*a1;
if ( func1(*a1) )
break;
v1 = (void *)func3(v2);
free(v1);
}
free(v2);
*a1 = 0LL;
}
}

original_code:
void clear_queue(queue *q) {
    void *e;
    if (q == ((void *)0)) {
        return;
    }
    if (*q == ((void *)0)) {
        return;
    }
    while (!is_empty(*q)) {
        e = get(*q);
        free (e);
    }
    free(*q);
    *q = ((void *)0);
}

canonical_original_code:
void clear_queue(struct queue **q) {
    void *e;
    if (q == ((void *)0)) {
        return;
    }
    if (*q == ((void *)0)) {
        return;
    }
    while (!is_empty(*q)) {
        e = get(*q);
        free (e);
    }
    free(*q);
    *q = ((void *)0);
}

variable_types: struct queue { struct box { struct distr { char *nombre; char *DNS; int puerto; int pr; } *elem; struct box *next; } *first; int size; } **

variable_types:
e
void *


original_code:
distr next_it(iterator it) {
    distr e;
    if ((it == ((void *)0)) || (*it == ((void *)0))) {
        return ((void *)0);
    }
    e = (*it)->elem;
    *it = (*it)->next;
    return e;
}

canonical_original_code:
struct distr *next_it(struct box **it) {
    struct distr *e;
    if ((it == ((void *)0)) || (*it == ((void *)0))) {
        return ((void *)0);
    }
    e = (*it)->elem;
    *it = (*it)->next;
    return e;
}

variable_types: struct box { struct distr *elem; struct box *next; } **

variable_types: struct distr { char *nombre; char *DNS; int puerto; int pr; } *


decompiled_code:
__int64 __fastcall prev_it(__int64 *a1)
{
__int64 result; // rax
__int64 v2; // rax

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
v2 = *(_QWORD *)(result + 16);
*a1 = v2;
result = **(_QWORD **)(v2 + 16);
}
return result;
}

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

if ( !a1 )
return 0LL;
result = *a1;
if ( *a1 )
{
v2 = *(_QWORD *)(result + 16);
*a1 = v2;
result = **(_QWORD **)(v2 + 16);
}
return result;
}

original_code:
distr prev_it(iterator it) {
    if ((it == ((void *)0)) || (*it == ((void *)0))) {
        return ((void *)0);
    }
    *it = (*it)->prev;
    return (*it)->prev->elem;
}

canonical_original_code:
struct distr *prev_it(struct box **it) {
    if ((it == ((void *)0)) || (*it == ((void *)0))) {
        return ((void *)0);
    }
    *it = (*it)->prev;
    return (*it)->prev->elem;
}

return_type: struct distr { char *nombre; char *DNS; int puerto; int pr; } *


imprimirHB

decompiled_code:
int imprimirHB()
{
printf("\x1B[1mNOMBRE\n\x1B[0m");
puts(" \x1B[1mbomba\x1B[0m - simula una bomba (cliente) a conectarse con un centro (servidor).\n");
printf("\x1B[1mSINTAXIS\n\x1B[0m");
printf("\x1B[1mbomba [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
printf(" –fc FicheroCentros \x1B[1m]\n\n\x1B[0m");
printf("\x1B[1mFLAGS\n\x1B[0m");
puts(" -h: Ayuda, explica el uso del comando.\n");
puts(" -n: Indica el nombre de la bomba ");
puts(" Este flag viene acompanado obligatoriamente por una cadena de caracteres.");
puts(" -cp: Indica la capacidad maxima de almacenamiento de la bomba");
puts(aEsteFlagDebeEs);
puts(" -i: Indica el inventario inicial de la bomba.");
puts(aEsteFlagDebeEs_0);
puts(" -c: Indica el consumo de gasolina en litros por minuto de la bomba.");
puts(aEsteFlagDebeEs_1);
puts(
" -fc: Nombre del fichero que contiene en cada linea el nombre de un centro de distribucion asi como las \n"
" direcciones (DNS) de la maquina donde corre su servicio y el numero de puerto en el que corre el \n"
" servicio en esa maquina, separados entre si por un \"&\"");
puts(aEsteFlagDebeEs_2);
printf("\x1B[1mAUTOR\n\x1B[0m");
return puts(" Escrito por Juan Arocha y Matteo Ferrando.");
}

canonical_decompiled_code:
int func1()
{
printf("\x1B[1mNOMBRE\n\x1B[0m");
puts(" \x1B[1mbomba\x1B[0m - simula una bomba (cliente) a conectarse con un centro (servidor).\n");
printf("\x1B[1mSINTAXIS\n\x1B[0m");
printf("\x1B[1mbomba [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
printf(" –fc FicheroCentros \x1B[1m]\n\n\x1B[0m");
printf("\x1B[1mFLAGS\n\x1B[0m");
puts(" -h: Ayuda, explica el uso del comando.\n");
puts(" -n: Indica el nombre de la bomba ");
puts(" Este flag viene acompanado obligatoriamente por una cadena de caracteres.");
puts(" -cp: Indica la capacidad maxima de almacenamiento de la bomba");
puts(aEsteFlagDebeEs);
puts(" -i: Indica el inventario inicial de la bomba.");
puts(aEsteFlagDebeEs_0);
puts(" -c: Indica el consumo de gasolina en litros por minuto de la bomba.");
puts(aEsteFlagDebeEs_1);
puts(
" -fc: Nombre del fichero que contiene en cada linea el nombre de un centro de distribucion asi como las \n"
" direcciones (DNS) de la maquina donde corre su servicio y el numero de puerto en el que corre el \n"
" servicio en esa maquina, separados entre si por un \"&\"");
puts(aEsteFlagDebeEs_2);
printf("\x1B[1mAUTOR\n\x1B[0m");
return puts(" Escrito por Juan Arocha y Matteo Ferrando.");
}

original_code:
void imprimirHB() {
    printf("\033[1m""NOMBRE\n""\033[0m");
    printf("     ""\033[1m""bomba""\033[0m"" - simula una bomba (cliente) a "
           "conectarse con un centro (servidor).\n\n");
    printf("\033[1m""SINTAXIS\n""\033[0m");
    printf("\033[1m""bomba [""\033[0m"" -h ""\033[1m""|""\033[0m");
    printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
    printf(" –fc FicheroCentros ""\033[1m""]\n\n""\033[0m");
    printf("\033[1m""FLAGS\n""\033[0m");
    printf("     -h: Ayuda, explica el uso del comando.\n\n");
    printf("     -n: Indica el nombre de la bomba \n");
    printf("              Este flag viene acompanado obligatoriamente por "
           "una cadena de caracteres.\n");
    printf("     -cp: Indica la capacidad maxima de almacenamiento de la "
           "bomba\n");
    printf("              Este flag debe estar acompañado por un entero entre "
           "38.000 y 380.000\n\n");
    printf("     -i: Indica el inventario inicial de la bomba.\n");
    printf("               Este flag debe estar acompañado por un entero entre"
               "0 y capacidad maxima.\n\n");
    printf("     -c: Indica el consumo de gasolina en litros por minuto de "
           "la bomba.\n");
    printf("               Este flag debe estar acompañado por un entero entre"
               "0 y 1000.\n\n");
    printf("     -fc: Nombre del fichero que contiene en cada linea el nombre"
           " de un centro de distribucion asi como las \n          direcciones"
           " (DNS) de la maquina donde corre su servicio y el numero de puerto "
           "en el que corre el \n          servicio en esa maquina, separados "
           "entre si por un \"&\"\n");
    printf("               Este flag debe estar acompañado por una cadena de caracteres"
                   "indicando path absoluto o relativo del archivo.\n\n");
    printf("\033[1m""AUTOR\n""\033[0m");
    printf("     Escrito por Juan Arocha y Matteo Ferrando.\n");
}


imprimirEB

decompiled_code:
int imprimirEB()
{
printf("uso: \x1B[1mbomba [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
return printf(" –fc FicheroCentros \x1B[1m]\n\x1B[0m");
}

canonical_decompiled_code:
int func2()
{
printf("uso: \x1B[1mbomba [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
return printf(" –fc FicheroCentros \x1B[1m]\n\x1B[0m");
}

original_code:
void imprimirEB() {
    printf("uso: ""\033[1m""bomba [""\033[0m"" -h ""\033[1m""|""\033[0m");
    printf(" –n nombreBomba –cp capacidadMaxima –i inventario –c consumo");
    printf(" –fc FicheroCentros ""\033[1m""]\n""\033[0m");
}


imprimirHC

decompiled_code:
int imprimirHC()
{
printf("\x1B[1mNOMBRE\n\x1B[0m");
puts(" \x1B[1mcentro\x1B[0m - simula un centro de distribucion (servidor) a conectarse con una bomba (cliente).\n");
printf("\x1B[1mSINTAXIS\n\x1B[0m");
printf("\x1B[1mcentro [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
printf(" –s suministro -p puerto \x1B[1m]\n\x1B[0m");
printf("\x1B[1mFLAGS\n\x1B[0m");
puts(" -h: Ayuda, explica el uso del comando.\n");
puts(" -n: Indica el nombre del centro ");
puts(" Este flag viene acompanado obligatoriamente por una cadena de caracteres.");
puts(" -cp: Indica la capacidad maxima de almacenamiento del centro");
puts(aEsteFlagDebeEs_3);
puts(" -i: Indica el inventario inicial del centro.");
puts(aEsteFlagDebeEs_0);
puts(" -t: Tiempo de respuesta del centro en minutos.");
puts(aEsteFlagDebeEs_4);
puts(" -s: Indica el suminstro de gasolina en litros por minuto del centro.");
puts(aEsteFlagDebeEs_5);
puts(" -p: Puerto por el cual se escuchan peticiones.");
puts(aEsteFlagDebeEs_6);
printf("\x1B[1mAUTOR\n\x1B[0m");
return puts(" Escrito por Juan Arocha y Matteo Ferrando.");
}

canonical_decompiled_code:
int func3()
{
printf("\x1B[1mNOMBRE\n\x1B[0m");
puts(" \x1B[1mcentro\x1B[0m - simula un centro de distribucion (servidor) a conectarse con una bomba (cliente).\n");
printf("\x1B[1mSINTAXIS\n\x1B[0m");
printf("\x1B[1mcentro [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
printf(" –s suministro -p puerto \x1B[1m]\n\x1B[0m");
printf("\x1B[1mFLAGS\n\x1B[0m");
puts(" -h: Ayuda, explica el uso del comando.\n");
puts(" -n: Indica el nombre del centro ");
puts(" Este flag viene acompanado obligatoriamente por una cadena de caracteres.");
puts(" -cp: Indica la capacidad maxima de almacenamiento del centro");
puts(aEsteFlagDebeEs_3);
puts(" -i: Indica el inventario inicial del centro.");
puts(aEsteFlagDebeEs_0);
puts(" -t: Tiempo de respuesta del centro en minutos.");
puts(aEsteFlagDebeEs_4);
puts(" -s: Indica el suminstro de gasolina en litros por minuto del centro.");
puts(aEsteFlagDebeEs_5);
puts(" -p: Puerto por el cual se escuchan peticiones.");
puts(aEsteFlagDebeEs_6);
printf("\x1B[1mAUTOR\n\x1B[0m");
return puts(" Escrito por Juan Arocha y Matteo Ferrando.");
}

original_code:
void imprimirHC() {
    printf("\033[1m""NOMBRE\n""\033[0m");
    printf("     ""\033[1m""centro""\033[0m"" - simula un centro de "
           "distribucion (servidor) a conectarse con una bomba (cliente).\n\n");
    printf("\033[1m""SINTAXIS\n""\033[0m");
    printf("\033[1m""centro [""\033[0m"" -h ""\033[1m""|""\033[0m");
    printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
    printf(" –s suministro -p puerto ""\033[1m""]\n""\033[0m");
    printf("\033[1m""FLAGS\n""\033[0m");
    printf("     -h: Ayuda, explica el uso del comando.\n\n");
    printf("     -n: Indica el nombre del centro \n");
    printf("              Este flag viene acompanado obligatoriamente por "
           "una cadena de caracteres.\n");
    printf("     -cp: Indica la capacidad maxima de almacenamiento del "
           "centro\n");
    printf("               Este flag debe estar acompañado por un entero entre "
           "38.000 y 3.800.000\n\n");
    printf("     -i: Indica el inventario inicial del centro.\n");
    printf("               Este flag debe estar acompañado por un entero entre"
               "0 y capacidad maxima.\n\n");
    printf("     -t: Tiempo de respuesta del centro en minutos.\n");
    printf("               Este flag debe estar acompañado por un entero entre"
               "0 y 180.\n\n");
    printf("     -s: Indica el suminstro de gasolina en litros por minuto del "
           "centro.\n");
    printf("               Este flag debe estar acompañado por un entero entre"
               "0 y 10000.\n\n");
    printf("     -p: Puerto por el cual se escuchan peticiones.\n");
    printf("               Este flag debe estar acompañado por un entero"
                   " para un puerto valido.\n\n");
    printf("\033[1m""AUTOR\n""\033[0m");
    printf("     Escrito por Juan Arocha y Matteo Ferrando.\n");
}


imprimirEC

decompiled_code:
int imprimirEC()
{
printf("uso: \x1B[1mcentro [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
return printf(" –s suministro -p puerto \x1B[1m]\n\x1B[0m");
}

canonical_decompiled_code:
int func4()
{
printf("uso: \x1B[1mcentro [\x1B[0m -h \x1B[1m|\x1B[0m");
printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
return printf(" –s suministro -p puerto \x1B[1m]\n\x1B[0m");
}

original_code:
void imprimirEC() {
    printf("uso: ""\033[1m""centro [""\033[0m"" -h ""\033[1m""|""\033[0m");
    printf(" –n nombreCentro –cp capacidadMaxima –i inventario –t tiempo");
    printf(" –s suministro -p puerto ""\033[1m""]\n""\033[0m");
}


llamadaB

original_code:
int llamadaB (int argc, char **argv, char **nombre, char **fich, int *max, int *inv, int *con) {
    int i, flags;
    switch (argc) {
        case 1:
            imprimirEB();
            return -1;
        case 2:
            if (strcmp(argv[1], "-h") == 0) {
                imprimirHB();
            } else {
                imprimirEB();
            }
            return -1;
        default:
            if (argc != 11) {
                imprimirEB();
                return -1;
            }
            for (i = 1; i < argc; ++i) {
                if (argv[i] == ((void *)0)) {
                    continue;
                }
                if (strcmp(argv[i], "-n") == 0) {
                    if ((*nombre = (char *) malloc((strlen(argv[i+1]) + 1) * sizeof(char))) == ((void *)0)) {
                        return errorMem();
                    }
                    strcpy(*nombre,argv[i+1]);
                } else if (strcmp(argv[i], "-cp") == 0) {
                    *max = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-i") == 0) {
                    *inv = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-c") == 0) {
                    *con = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-fc") == 0) {
                    if ((*fich = (char *) malloc((strlen(argv[i+1]) + 1) * sizeof(char))) == ((void *)0)) {
                        return errorMem();
                    }
                    strcpy(*fich,argv[i+1]);
                } else {
                    imprimirEB();
                    return -1;
                }
                argv[i] = argv[i+1] = ((void *)0);
            }
    }
    return 0;
}

canonical_original_code:
int llamadaB(int argc, char **argv, char **nombre, char **fich, int *max, int *inv, int *con) {
    int i; int flags;
    switch (argc) {
        case 1:
            imprimirEB();
            return -1;
        case 2:
            if (strcmp(argv[1], "-h") == 0) {
                imprimirHB();
            } else {
                imprimirEB();
            }
            return -1;
        default:
            if (argc != 11) {
                imprimirEB();
                return -1;
            }
            for (i = 1; i < argc; ++i) {
                if (argv[i] == ((void *)0)) {
                    continue;
                }
                if (strcmp(argv[i], "-n") == 0) {
                    if ((*nombre = (char *) malloc((strlen(argv[i+1]) + 1) * sizeof(char))) == ((void *)0)) {
                        return errorMem();
                    }
                    strcpy(*nombre,argv[i+1]);
                } else if (strcmp(argv[i], "-cp") == 0) {
                    *max = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-i") == 0) {
                    *inv = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-c") == 0) {
                    *con = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-fc") == 0) {
                    if ((*fich = (char *) malloc((strlen(argv[i+1]) + 1) * sizeof(char))) == ((void *)0)) {
                        return errorMem();
                    }
                    strcpy(*fich,argv[i+1]);
                } else {
                    imprimirEB();
                    return -1;
                }
                argv[i] = argv[i+1] = ((void *)0);
            }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
nombre
char **

variable_types:
fich
char **

variable_types:
max
int *

variable_types:
inv
int *

variable_types:
con
int *

variable_types: flags int


llamadaC

decompiled_code:
__int64 __fastcall llamadaC(int a1, const char **a2, const char **a3, int *a4, int *a5, int *a6, int *a7, int *a8)
{
const char **v11; // rbx

if ( a1 == 1 )
goto LABEL_26;
if ( a1 == 2 )
{
if ( !strcmp(a2[1], "-h") )
imprimirHC();
else
imprimirEC();
return 0xFFFFFFFFLL;
}
if ( a1 != 13 )
{
LABEL_26:
imprimirEC();
return 0xFFFFFFFFLL;
}
v11 = a2 + 2;
do
{
if ( *(v11 - 1) )
{
if ( !strcmp(*(v11 - 1), "-n") )
{
*a3 = *v11;
}
else if ( !strcmp(*(v11 - 1), "-cp") )
{
*a4 = atoi(*v11);
}
else if ( !strcmp(*(v11 - 1), "-i") )
{
*a5 = atoi(*v11);
}
else if ( !strcmp(*(v11 - 1), "-t") )
{
*a6 = atoi(*v11);
}
else if ( !strcmp(*(v11 - 1), "-s") )
{
*a7 = atoi(*v11);
}
else
{
if ( strcmp(*(v11 - 1), "-p") )
goto LABEL_26;
*a8 = atoi(*v11);
}
*v11 = 0LL;
*(v11 - 1) = 0LL;
}
++v11;
}
while ( v11 != a2 + 14 );
return 0LL;
}

original_code:
int llamadaC (int argc, char **argv, char **nombre, int *max, int *inv, int *tiempo, int *sum, int *puerto ) {
    int i, flags;
    switch (argc) {
        case 1:
            imprimirEC();
            return -1;
        case 2:
            if (strcmp(argv[1], "-h") == 0) {
                imprimirHC();
            } else {
                imprimirEC();
            }
            return -1;
        default:
            if (argc != 13) {
                imprimirEC();
                return -1;
            }
            for (i = 1; i < argc; ++i) {
                if (argv[i] == ((void *)0)) {
                    continue;
                }
                if (strcmp(argv[i], "-n") == 0) {
                    *nombre = argv[i+1];
                } else if (strcmp(argv[i], "-cp") == 0) {
                    *max = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-i") == 0) {
                    *inv = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-t") == 0) {
                    *tiempo = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-s") == 0) {
                    *sum = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-p") == 0) {
                    *puerto = atoi(argv[i+1]);
                } else {
                    imprimirEC();
                    return -1;
                }
                argv[i] = argv[i+1] = ((void *)0);
            }
    }
    return 0;
}

canonical_original_code:
int llamadaC(int argc, char **argv, char **nombre, int *max, int *inv, int *tiempo, int *sum, int *puerto) {
    int i; int flags;
    switch (argc) {
        case 1:
            imprimirEC();
            return -1;
        case 2:
            if (strcmp(argv[1], "-h") == 0) {
                imprimirHC();
            } else {
                imprimirEC();
            }
            return -1;
        default:
            if (argc != 13) {
                imprimirEC();
                return -1;
            }
            for (i = 1; i < argc; ++i) {
                if (argv[i] == ((void *)0)) {
                    continue;
                }
                if (strcmp(argv[i], "-n") == 0) {
                    *nombre = argv[i+1];
                } else if (strcmp(argv[i], "-cp") == 0) {
                    *max = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-i") == 0) {
                    *inv = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-t") == 0) {
                    *tiempo = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-s") == 0) {
                    *sum = atoi(argv[i+1]);
                } else if (strcmp(argv[i], "-p") == 0) {
                    *puerto = atoi(argv[i+1]);
                } else {
                    imprimirEC();
                    return -1;
                }
                argv[i] = argv[i+1] = ((void *)0);
            }
    }
    return 0;
}

variable_types:
tiempo
int *

variable_types:
sum
int *

variable_types:
puerto
int *

variable_types: i int


controlGas

decompiled_code:
void __fastcall __noreturn controlGas(void *a1)
{
int i; // eax

for ( i = tiempo; tiempo <= 479; i = tiempo )
{
tiempo = i + 1;
usleep(0x186A0u);
sem_wait(&sem);
if ( entrada + gas >= max )
{
if ( gas < max )
{
gas = max;
sem_wait(&semf);
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
}
else
{
gas += entrada;
}
sem_post(&sem);
}
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(void *a1)
{
int i; // eax

for ( i = tiempo; tiempo <= 479; i = tiempo )
{
tiempo = i + 1;
usleep(0x186A0u);
sem_wait(&sem);
if ( entrada + gas >= max )
{
if ( gas < max )
{
gas = max;
sem_wait(&semf);
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
}
else
{
gas += entrada;
}
sem_post(&sem);
}
exit(0);
}

original_code:
void *controlGas(){
    while (tiempo < 480){
        ++tiempo;
        usleep(100000);
        sem_wait(&sem);
        if (entrada + gas < max){
            gas += entrada;
        } else if (gas < max) {
            gas = max;
            sem_wait(&semf);
            fprintf(out, "Tanque full: %d\n", tiempo);
            sem_post(&semf);
        }
        sem_post(&sem);
    }
    exit(0);
}

return_type: void *


decompiled_code:
void __fastcall __noreturn manejo_peticion(void *a1)
{
int v1; // ebx
char *v2; // r12
char *v3; // rbp
char s[2]; // [rsp+Ch] [rbp-11Ch] BYREF
char buf[280]; // [rsp+10h] [rbp-118h] BYREF

v1 = *(_DWORD *)a1;
free(a1);
if ( (int)read(v1, buf, 0x100uLL) <= 3 )
{
close(v1);
errorFile(78LL);
pthread_exit(0LL);
}
v2 = strtok(buf, "&");
v3 = strtok(0LL, "&");
if ( !strcmp(v3, "t") || !strcmp(v3, "T") )
{
sprintf(s, "%d", (unsigned int)resp);
if ( (int)write(v1, s, 4uLL) > 0 )
pthread_exit(0LL);
close(v1);
errorFile(97LL);
pthread_exit(0LL);
}
if ( !strcmp(v3, "g") || !strcmp(v3, "G") )
{
sem_wait(&sem);
if ( gas <= 37999 )
{
strcpy(s, "0");
if ( (int)write(v1, s, 2uLL) <= 0 )
{
close(v1);
errorFile(147LL);
pthread_exit(0LL);
}
sem_wait(&semf);
fprintf(out, "Suministro: %d, %s, Negativa, %d\n", (unsigned int)tiempo, v2, (unsigned int)gas);
sem_post(&semf);
}
else
{
strcpy(s, "1");
if ( (int)write(v1, s, 2uLL) <= 0 )
{
close(v1);
errorFile(119LL);
pthread_exit(0LL);
}
gas -= 38000;
sem_wait(&semf);
fprintf(out, "Suministro: %d, %s, Positiva, %d\n", (unsigned int)tiempo, v2, (unsigned int)gas);
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
sem_post(&sem);
}
close(v1);
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
int v1; // ebx
char *v2; // r12
char *v3; // rbp
char s[2]; // [rsp+Ch] [rbp-11Ch] BYREF
char buf[280]; // [rsp+10h] [rbp-118h] BYREF

v1 = *(_DWORD *)a1;
free(a1);
if ( (int)read(v1, buf, 0x100uLL) <= 3 )
{
close(v1);
errorFile(78LL);
pthread_exit(0LL);
}
v2 = strtok(buf, "&");
v3 = strtok(0LL, "&");
if ( !strcmp(v3, "t") || !strcmp(v3, "T") )
{
sprintf(s, "%d", (unsigned int)resp);
if ( (int)write(v1, s, 4uLL) > 0 )
pthread_exit(0LL);
close(v1);
errorFile(97LL);
pthread_exit(0LL);
}
if ( !strcmp(v3, "g") || !strcmp(v3, "G") )
{
sem_wait(&sem);
if ( gas <= 37999 )
{
strcpy(s, "0");
if ( (int)write(v1, s, 2uLL) <= 0 )
{
close(v1);
errorFile(147LL);
pthread_exit(0LL);
}
sem_wait(&semf);
fprintf(out, "Suministro: %d, %s, Negativa, %d\n", (unsigned int)tiempo, v2, (unsigned int)gas);
sem_post(&semf);
}
else
{
strcpy(s, "1");
if ( (int)write(v1, s, 2uLL) <= 0 )
{
close(v1);
errorFile(119LL);
pthread_exit(0LL);
}
gas -= 38000;
sem_wait(&semf);
fprintf(out, "Suministro: %d, %s, Positiva, %d\n", (unsigned int)tiempo, v2, (unsigned int)gas);
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
sem_post(&sem);
}
close(v1);
pthread_exit(0LL);
}

original_code:
void *manejo_peticion(void *args){
    int newfd = *((int *) args);
    char conex[256];
    char *nomB;
    char *pet;
    char res[4];
    free(args);
    if (read(newfd, conex, 256) < 4) {
        close(newfd);
        errorFile(78);
        pthread_exit(((void *)0));
    }
    nomB = strtok(conex, "&");
    pet = strtok(((void *)0), "&");
    if ((strcmp(pet, "t") == 0) || (strcmp(pet, "T") == 0)) {
        sprintf(res, "%d", resp);
        if (write(newfd, res, 4) < 1) {
            close(newfd);
            errorFile(97);
            pthread_exit(((void *)0));
        }
        pthread_exit(((void *)0));
    }
    if ((strcmp(pet, "g") == 0) || (strcmp(pet, "G") == 0)) {
        sem_wait(&sem);
        if (gas >= 38000){
            sprintf(res, "1");
            if (write(newfd, res, 2) < 1) {
                close(newfd);
                errorFile(119);
                pthread_exit(((void *)0));
            }
            gas -= 38000;
            sem_wait(&semf);
            fprintf(out, "Suministro: %d, %s, Positiva, %d\n", tiempo, nomB, gas);
            if (gas == 0) {
                fprintf(out, "Tanque vacio: %d\n", tiempo);
            }
            sem_post(&semf);
        } else {
            sprintf(res, "0");
            if (write(newfd, res, 2) < 1) {
                close(newfd);
                errorFile(147);
                pthread_exit(((void *)0));
            }
            sem_wait(&semf);
            fprintf(out, "Suministro: %d, %s, Negativa, %d\n", tiempo, nomB, gas);
            sem_post(&semf);
        }
        sem_post(&sem);
    }
    close(newfd);
    pthread_exit(((void *)0));
}

variable_types:
args
void *

variable_types: newfd int

variable_types:
conex
char [256]

variable_types:
nomB
char *

variable_types:
pet
char *

variable_types:
res
char [4]


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rdi
int v4; // ebp
int v5; // ebx
_DWORD *v6; // rax
__int64 v8[6]; // [rsp+0h] [rbp-98h] BYREF
__int16 v9; // [rsp+30h] [rbp-68h]
socklen_t addr_len; // [rsp+3Ch] [rbp-5Ch] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-58h] BYREF
struct sockaddr v12; // [rsp+50h] [rbp-48h] BYREF
__int16 v13; // [rsp+6Ch] [rbp-2Ch] BYREF
pthread_t th; // [rsp+70h] [rbp-28h] BYREF
pthread_t newthread[4]; // [rsp+78h] [rbp-20h] BYREF

v8[0] = 1600614252LL;
v8[1] = 0LL;
v8[2] = 0LL;
v8[3] = 0LL;
v8[4] = 0LL;
v8[5] = 0LL;
v9 = 0;
sem_init(&sem, 0, 1u);
sem_init(&semf, 0, 1u);
if ( (int)llamadaC((unsigned int)argc, argv, &nombre, &max, &gas, &resp, &entrada, &v13) < 0 )
return -1;
strcat((char *)v8, nombre);
strcat((char *)v8, ".txt");
v3 = fopen((const char *)v8, "w");
out = v3;
if ( !v3 )
return errorFile(191LL);
fprintf(v3, "Estado inicial: %d\n", (unsigned int)gas);
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
if ( gas == max )
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
if ( pthread_create(newthread, 0LL, (void *(*)(void *))controlGas, 0LL) )
return errorHilo(211LL);
v4 = socket(2, 1, 0);
if ( v4 < 0 )
return errorSocket(218LL);
*(_QWORD *)&v12.sa_family = 0LL;
*(_QWORD *)&v12.sa_data[6] = 0LL;
addr.sa_family = 2;
*(_DWORD *)&addr.sa_data[2] = _bswap_32(0);
*(_WORD *)addr.sa_data = _bswap_16(v13);
if ( bind(v4, &addr, 0x10u) )
return errorSocket(230LL);
if ( listen(v4, 5) < 0 )
return errorSocket(236LL);
while ( 1 )
{
if ( tiempo > 479 )
{
fclose(out);
exit(0);
}
addr_len = 16;
v5 = accept(v4, &v12, &addr_len);
if ( v5 < 0 )
return errorSocket(246LL);
v6 = malloc(4uLL);
if ( !v6 )
return errorMem(252LL);
*v6 = v5;
if ( pthread_create(&th, 0LL, (void *(*)(void *))manejo_peticion, v6) )
break;
if ( pthread_detach(th) )
return errorHilo(266LL);
}
return errorHilo(260LL);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rdi
int v4; // ebp
int v5; // ebx
_DWORD *v6; // rax
__int64 v8[6]; // [rsp+0h] [rbp-98h] BYREF
__int16 v9; // [rsp+30h] [rbp-68h]
socklen_t addr_len; // [rsp+3Ch] [rbp-5Ch] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-58h] BYREF
struct sockaddr v12; // [rsp+50h] [rbp-48h] BYREF
__int16 v13; // [rsp+6Ch] [rbp-2Ch] BYREF
pthread_t th; // [rsp+70h] [rbp-28h] BYREF
pthread_t newthread[4]; // [rsp+78h] [rbp-20h] BYREF

v8[0] = 1600614252LL;
v8[1] = 0LL;
v8[2] = 0LL;
v8[3] = 0LL;
v8[4] = 0LL;
v8[5] = 0LL;
v9 = 0;
sem_init(&sem, 0, 1u);
sem_init(&semf, 0, 1u);
if ( (int)llamadaC((unsigned int)argc, argv, &nombre, &max, &gas, &resp, &entrada, &v13) < 0 )
return -1;
strcat((char *)v8, nombre);
strcat((char *)v8, ".txt");
v3 = fopen((const char *)v8, "w");
out = v3;
if ( !v3 )
return errorFile(191LL);
fprintf(v3, "Estado inicial: %d\n", (unsigned int)gas);
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
if ( gas == max )
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
if ( pthread_create(newthread, 0LL, (void *(*)(void *))controlGas, 0LL) )
return errorHilo(211LL);
v4 = socket(2, 1, 0);
if ( v4 < 0 )
return errorSocket(218LL);
*(_QWORD *)&v12.sa_family = 0LL;
*(_QWORD *)&v12.sa_data[6] = 0LL;
addr.sa_family = 2;
*(_DWORD *)&addr.sa_data[2] = func2(0);
*(_WORD *)addr.sa_data = func3(v13);
if ( bind(v4, &addr, 0x10u) )
return errorSocket(230LL);
if ( listen(v4, 5) < 0 )
return errorSocket(236LL);
while ( 1 )
{
if ( tiempo > 479 )
{
fclose(out);
exit(0);
}
addr_len = 16;
v5 = accept(v4, &v12, &addr_len);
if ( v5 < 0 )
return errorSocket(246LL);
v6 = malloc(4uLL);
if ( !v6 )
return errorMem(252LL);
*v6 = v5;
if ( pthread_create(&th, 0LL, (void *(*)(void *))manejo_peticion, v6) )
break;
if ( pthread_detach(th) )
return errorHilo(266LL);
}
return errorHilo(260LL);
}

original_code:
int main(int argc, char **argv) {
    pthread_t controlador;
    pthread_t mensajero;
    int puerto;
    int fd, newfd;
    struct sockaddr_in Bdir, Cdir;
    socklen_t Btam;
    int *thrArg;
    char flog[50] = "log_";
    sem_init(&sem,0,1);
    sem_init(&semf,0,1);
    if (llamadaC(argc, argv, &nombre, &max, &gas, &resp, &entrada, &puerto) < 0) {
        return -1;
    }
    strcat(flog, nombre);
    strcat(flog, ".txt");
    if ((out = fopen(flog, "w")) == ((void *)0)) {
        return errorFile(191);
    }
    fprintf(out, "Estado inicial: %d\n", gas);
    if (gas == 0) {
        fprintf(out, "Tanque vacio: %d\n", tiempo);
    }
    if (gas == max) {
        fprintf(out, "Tanque full: %d\n", tiempo);
    }
    if (pthread_create(&controlador, ((void *)0), controlGas, ((void *)0)) != 0){
        return errorHilo(211);
    }
    if ((fd = socket(2, SOCK_STREAM, 0)) < 0){
        return errorSocket(218);
    }
    bzero(&Bdir, sizeof(Bdir));
    Cdir.sin_family = 2;
    Cdir.sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    Cdir.sin_port = htons(puerto);
    if (bind(fd, (struct sockaddr *) &Cdir, sizeof(Cdir)) != 0){
        return errorSocket(230);
    }
    if (listen(fd, 5) < 0){
        return errorSocket(236);
    }
    while (tiempo < 480){
        Btam = sizeof(Bdir);
        if ((newfd = accept(fd, (struct sockaddr *) &Bdir, &Btam)) < 0){
            return errorSocket(246);
        }
        if ((thrArg = (int *) malloc(sizeof(int))) == ((void *)0)) {
            return errorMem(252);
        }
        *thrArg = newfd;
        if (pthread_create(&mensajero, ((void *)0), manejo_peticion, (void *) thrArg) != 0){
            return errorHilo(260);
        }
        if (pthread_detach(mensajero) != 0){
            return errorHilo(266);
        }
    }
    fclose(out);
    exit(0);
}

canonical_original_code:
int main(int argc, char **argv) {
    unsigned long controlador;
    unsigned long mensajero;
    int puerto;
    int fd; int newfd;
    struct sockaddr_in Bdir; struct sockaddr_in Cdir;
    unsigned int Btam;
    int *thrArg;
    char flog[50] = "log_";
    sem_init(&sem,0,1);
    sem_init(&semf,0,1);
    if (llamadaC(argc, argv, &nombre, &max, &gas, &resp, &entrada, &puerto) < 0) {
        return -1;
    }
    strcat(flog, nombre);
    strcat(flog, ".txt");
    if ((out = fopen(flog, "w")) == ((void *)0)) {
        return errorFile(191);
    }
    fprintf(out, "Estado inicial: %d\n", gas);
    if (gas == 0) {
        fprintf(out, "Tanque vacio: %d\n", tiempo);
    }
    if (gas == max) {
        fprintf(out, "Tanque full: %d\n", tiempo);
    }
    if (pthread_create(&controlador, ((void *)0), controlGas, ((void *)0)) != 0){
        return errorHilo(211);
    }
    if ((fd = socket(2, SOCK_STREAM, 0)) < 0){
        return errorSocket(218);
    }
    bzero(&Bdir, sizeof(Bdir));
    Cdir.sin_family = 2;
    Cdir.sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    Cdir.sin_port = htons(puerto);
    if (bind(fd, (struct sockaddr *) &Cdir, sizeof(Cdir)) != 0){
        return errorSocket(230);
    }
    if (listen(fd, 5) < 0){
        return errorSocket(236);
    }
    while (tiempo < 480){
        Btam = sizeof(Bdir);
        if ((newfd = accept(fd, (struct sockaddr *) &Bdir, &Btam)) < 0){
            return errorSocket(246);
        }
        if ((thrArg = (int *) malloc(sizeof(int))) == ((void *)0)) {
            return errorMem(252);
        }
        *thrArg = newfd;
        if (pthread_create(&mensajero, ((void *)0), manejo_peticion, (void *) thrArg) != 0){
            return errorHilo(260);
        }
        if (pthread_detach(mensajero) != 0){
            return errorHilo(266);
        }
    }
    fclose(out);
    exit(0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
controlador
unsigned long

variable_types:
mensajero
unsigned long

variable_types: puerto int

variable_types: fd int

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

variable_types:
Btam
unsigned int

variable_types:
thrArg
int *

variable_types:
flog
char [50]

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

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


decompiled_code:
int __fastcall conectar_centro(char a1, __int16 a2, const char *a3)
{
int v4; // ebx
int result; // eax
struct sockaddr v6; // [rsp+0h] [rbp-138h] BYREF
char s[268]; // [rsp+10h] [rbp-128h] BYREF
char buf[28]; // [rsp+11Ch] [rbp-1Ch] BYREF

if ( (a1 & 0xDF) != 71 && (a1 & 0xDF) != 84 )
return -1;
sprintf(s, "%s&%c", nombre, (unsigned int)a1);
v4 = socket(2, 1, 0);
if ( v4 < 0 )
{
errorSocket(48LL);
result = -1;
}
else
{
*(_QWORD *)&v6.sa_family = 2LL;
*(_QWORD *)&v6.sa_data[6] = 0LL;
*(_QWORD *)&v6.sa_data[2] = **(unsigned int **)gethostbyname(a3)->h_addr_list;
*(_WORD *)v6.sa_data = _bswap_16(a2);
if ( connect(v4, &v6, 0x10u) < 0 )
{
close(v4);
errorSocket(62LL);
result = -1;
}
else if ( (int)write(v4, s, 0x100uLL) <= 0 )
{
close(v4);
errorFile(70LL);
result = -1;
}
else if ( (int)read(v4, buf, 4uLL) <= 0 )
{
close(v4);
errorFile(78LL);
result = -1;
}
else
{
close(v4);
result = atoi(buf);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(char a1, __int16 a2, const char *a3)
{
int v4; // ebx
int result; // eax
struct sockaddr v6; // [rsp+0h] [rbp-138h] BYREF
char s[268]; // [rsp+10h] [rbp-128h] BYREF
char buf[28]; // [rsp+11Ch] [rbp-1Ch] BYREF

if ( (a1 & 0xDF) != 71 && (a1 & 0xDF) != 84 )
return -1;
sprintf(s, "%s&%c", nombre, (unsigned int)a1);
v4 = socket(2, 1, 0);
if ( v4 < 0 )
{
errorSocket(48LL);
result = -1;
}
else
{
*(_QWORD *)&v6.sa_family = 2LL;
*(_QWORD *)&v6.sa_data[6] = 0LL;
*(_QWORD *)&v6.sa_data[2] = **(unsigned int **)gethostbyname(a3)->h_addr_list;
*(_WORD *)v6.sa_data = func0(a2);
if ( connect(v4, &v6, 0x10u) < 0 )
{
close(v4);
errorSocket(62LL);
result = -1;
}
else if ( (int)write(v4, s, 0x100uLL) <= 0 )
{
close(v4);
errorFile(70LL);
result = -1;
}
else if ( (int)read(v4, buf, 4uLL) <= 0 )
{
close(v4);
errorFile(78LL);
result = -1;
}
else
{
close(v4);
result = atoi(buf);
}
}
return result;
}

original_code:
int conectar_centro(char tipo, int puerto, char *DNS) {
char respuesta[4];
char peticion[256];
int fd;
struct sockaddr_in Cdir;
    if ((tipo != 'G') && (tipo != 'g') && (tipo != 'T') && (tipo != 't')) {
        return -1;
    }
    sprintf(peticion, "%s&%c", nombre, tipo);
    if ((fd = socket(2, SOCK_STREAM, 0)) < 0) {
        errorSocket(48);
        return -1;
    }
    bzero(&Cdir, sizeof(Cdir));
    Cdir.sin_family = 2;
    Cdir.sin_addr = *((struct in_addr *) gethostbyname(DNS)->h_addr_list[0]);
    Cdir.sin_port = htons(puerto);
    if (connect(fd,(struct sockaddr *) &Cdir, sizeof(Cdir)) < 0) {
        close(fd);
        errorSocket(62);
        return -1;
    }
    if (write(fd, peticion, 256) < 1) {
        close(fd);
        errorFile(70);
        return -1;
    }
    if (read(fd, respuesta, 4) < 1) {
        close(fd);
        errorFile(78);
        return -1;
    }
    close(fd);
    return atoi(respuesta);
}

variable_types: tipo char

variable_types:
DNS
char *

variable_types:
respuesta
char [4]

variable_types:
peticion
char [256]


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rdi
int v4; // ebp
int v5; // eax
int v7; // ebx
__int64 v8[6]; // [rsp+0h] [rbp-68h] BYREF
__int16 v9; // [rsp+30h] [rbp-38h]
pthread_t newthread; // [rsp+38h] [rbp-30h] BYREF
int v11; // [rsp+44h] [rbp-24h] BYREF
const char *v12; // [rsp+48h] [rbp-20h] BYREF

v11 = 0;
v8[0] = 1600614252LL;
v8[1] = 0LL;
v8[2] = 0LL;
v8[3] = 0LL;
v8[4] = 0LL;
v8[5] = 0LL;
v9 = 0;
sem_init(&sem, 0, 1u);
sem_init(&semf, 0, 1u);
if ( (int)llamadaB((unsigned int)argc, argv, &nombre, &v12, &max, &gas, &v11) < 0 )
return -1;
strcat((char *)v8, nombre);
strcat((char *)v8, ".txt");
v3 = fopen((const char *)v8, "w");
out = v3;
if ( !v3 )
return errorFile(250LL);
fprintf(v3, "Estado inicial: %d\n", (unsigned int)gas);
v4 = analizar_fichero(v12);
if ( v4 < 0 )
return -3;
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
if ( gas == max )
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
v5 = tiempo;
if ( tiempo > 479 )
return 0;
do
{
tiempo = v5 + 1;
usleep(0x186A0u);
sem_wait(&sem);
if ( gas - v11 <= 0 )
{
if ( gas > 0 )
{
gas = 0;
sem_wait(&semf);
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
}
else
{
gas -= v11;
}
v7 = gas - v11 * v4;
if ( v7 < 0 )
v7 = 0;
while ( max - v7 >= 38000 * pet )
{
++pet;
if ( pthread_create(&newthread, 0LL, (void *(*)(void *))pedir_gas, 0LL) )
errorHilo(312LL);
}
sem_post(&sem);
v5 = tiempo;
}
while ( tiempo <= 479 );
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
FILE *v3; // rdi
int v4; // ebp
int v5; // eax
int v7; // ebx
__int64 v8[6]; // [rsp+0h] [rbp-68h] BYREF
__int16 v9; // [rsp+30h] [rbp-38h]
pthread_t newthread; // [rsp+38h] [rbp-30h] BYREF
int v11; // [rsp+44h] [rbp-24h] BYREF
const char *v12; // [rsp+48h] [rbp-20h] BYREF

v11 = 0;
v8[0] = 1600614252LL;
v8[1] = 0LL;
v8[2] = 0LL;
v8[3] = 0LL;
v8[4] = 0LL;
v8[5] = 0LL;
v9 = 0;
sem_init(&sem, 0, 1u);
sem_init(&semf, 0, 1u);
if ( (int)llamadaB((unsigned int)argc, argv, &nombre, &v12, &max, &gas, &v11) < 0 )
return -1;
strcat((char *)v8, nombre);
strcat((char *)v8, ".txt");
v3 = fopen((const char *)v8, "w");
out = v3;
if ( !v3 )
return errorFile(250LL);
fprintf(v3, "Estado inicial: %d\n", (unsigned int)gas);
v4 = func3(v12);
if ( v4 < 0 )
return -3;
if ( !gas )
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
if ( gas == max )
fprintf(out, "Tanque full: %d\n", (unsigned int)tiempo);
v5 = tiempo;
if ( tiempo > 479 )
return 0;
do
{
tiempo = v5 + 1;
usleep(0x186A0u);
sem_wait(&sem);
if ( gas - v11 <= 0 )
{
if ( gas > 0 )
{
gas = 0;
sem_wait(&semf);
fprintf(out, "Tanque vacio: %d\n", (unsigned int)tiempo);
sem_post(&semf);
}
}
else
{
gas -= v11;
}
v7 = gas - v11 * v4;
if ( v7 < 0 )
v7 = 0;
while ( max - v7 >= 38000 * pet )
{
++pet;
if ( pthread_create(&newthread, 0LL, (void *(*)(void *))pedir_gas, 0LL) )
errorHilo(312LL);
}
sem_post(&sem);
v5 = tiempo;
}
while ( tiempo <= 479 );
return 0;
}

original_code:
int main(int argc, char **argv) {
char *fich;
int salida = 0;
int espera = 2147483647;
int tanque;
pthread_t mensajero;
char flog[50] = "log_";
    sem_init(&sem, 0, 1);
    sem_init(&semf, 0, 1);
    if (llamadaB(argc, argv, &nombre, &fich, &max, &gas, &salida) < 0) {
        return -1;
    }
    strcat(flog, nombre);
    strcat(flog, ".txt");
    if ((out = fopen(flog, "w")) == ((void *)0)) {
        return errorFile(250);
    }
    fprintf(out, "Estado inicial: %d\n", gas);
    if ((espera = analizar_fichero(fich)) < 0) {
        return -3;
    }
    if (gas == 0) {
        fprintf(out, "Tanque vacio: %d\n", tiempo);
    }
    if (gas == max) {
        fprintf(out, "Tanque full: %d\n", tiempo);
    }
    while (tiempo < 480) {
        ++tiempo;
        usleep(100000);
        sem_wait(&sem);
        if (gas - salida > 0) {
            gas -= salida;
        } else if (gas > 0) {
            gas = 0;
            sem_wait(&semf);
            fprintf(out, "Tanque vacio: %d\n", tiempo);
            sem_post(&semf);
        }
        tanque = (gas - espera * salida);
        if (tanque < 0) {
            tanque = 0;
        }
        while (max - tanque >= 38000 * pet) {
            ++pet;
            if (pthread_create(&mensajero, ((void *)0), pedir_gas, ((void *)0)) != 0) {
                errorHilo(312);
            }
        }
        sem_post(&sem);
    }
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
char *fich;
int salida = 0;
int espera = 2147483647;
int tanque;
unsigned long mensajero;
char flog[50] = "log_";
    sem_init(&sem, 0, 1);
    sem_init(&semf, 0, 1);
    if (llamadaB(argc, argv, &nombre, &fich, &max, &gas, &salida) < 0) {
        return -1;
    }
    strcat(flog, nombre);
    strcat(flog, ".txt");
    if ((out = fopen(flog, "w")) == ((void *)0)) {
        return errorFile(250);
    }
    fprintf(out, "Estado inicial: %d\n", gas);
    if ((espera = analizar_fichero(fich)) < 0) {
        return -3;
    }
    if (gas == 0) {
        fprintf(out, "Tanque vacio: %d\n", tiempo);
    }
    if (gas == max) {
        fprintf(out, "Tanque full: %d\n", tiempo);
    }
    while (tiempo < 480) {
        ++tiempo;
        usleep(100000);
        sem_wait(&sem);
        if (gas - salida > 0) {
            gas -= salida;
        } else if (gas > 0) {
            gas = 0;
            sem_wait(&semf);
            fprintf(out, "Tanque vacio: %d\n", tiempo);
            sem_post(&semf);
        }
        tanque = (gas - espera * salida);
        if (tanque < 0) {
            tanque = 0;
        }
        while (max - tanque >= 38000 * pet) {
            ++pet;
            if (pthread_create(&mensajero, ((void *)0), pedir_gas, ((void *)0)) != 0) {
                errorHilo(312);
            }
        }
        sem_post(&sem);
    }
    return 0;
}

variable_types:
fich
char *

variable_types: salida int

variable_types: espera int

variable_types: tanque int


repo: jcarrano/rtfi

decompiled_code:
float __fastcall rgb_hue(int a1)
{
float v1; // xmm0_4
float v2; // xmm1_4

v1 = (double)(unsigned __int8)a1 + (double)(unsigned __int8)a1 - (double)BYTE1(a1) - (double)BYTE2(a1);
v2 = (double)(BYTE1(a1) - BYTE2(a1)) * 1.732050807568877;
return atan2f(v1, v2);
}

canonical_decompiled_code:
float __fastcall func3(int a1)
{
float v1; // xmm0_4
float v2; // xmm1_4

v1 = (double)(unsigned __int8)a1 + (double)(unsigned __int8)a1 - (double)BYTE1(a1) - (double)BYTE2(a1);
v2 = (double)(BYTE1(a1) - BYTE2(a1)) * 1.732050807568877;
return atan2f(v1, v2);
}

variable_types:
col
struct RGB { unsigned char r; }

return_type: float


decompiled_code:
float __fastcall rgb_val(int a1)
{
return (double)(BYTE2(a1) + BYTE1(a1) + (unsigned __int8)a1) / 3.0;
}

canonical_decompiled_code:
float __fastcall func5(int a1)
{
return (double)(BYTE2(a1) + BYTE1(a1) + (unsigned __int8)a1) / 3.0;
}

original_code:
float rgb_val(struct RGB col)
{
 return (col.r + col.g + col.b) / 3.0;
}


decompiled_code:
float __fastcall rgb_crom(int a1)
{
float v1; // xmm0_4

v1 = rgb_val((unsigned __int8)a1 | a1 & 0xFF00 | (BYTE2(a1) << 16));
return d_3((float)(unsigned __int8)a1 - v1, (float)BYTE1(a1) - v1, (float)BYTE2(a1) - v1);
}

canonical_decompiled_code:
float __fastcall func6(int a1)
{
float v1; // xmm0_4

v1 = func5((unsigned __int8)a1 | a1 & 0xFF00 | (BYTE2(a1) << 16));
return func0((float)(unsigned __int8)a1 - v1, (float)BYTE1(a1) - v1, (float)BYTE2(a1) - v1);
}

original_code:
float rgb_crom(struct RGB col)
{
 float val = rgb_val(col);
 return _d_3(col.r - val, col.g - val, col.b - val);
}

variable_types: val float


original_code:
struct RGB rgb_compo(float hue, float crom, float value)
{
 unsigned char c[4];
 struct RGB ret;
 int k;
 const float l1 = (2*3.14159265358979323846)/3.0;
 float top = 255*crom;
 float tmp, crom1 = (1-crom)*255;
 hue = hue + 3.14159265358979323846;
 for(k=0; k<4; k++){
  tmp = (top*2)*fun_lambda((hue-l1*k)/l1);
  c[k] = (unsigned char)((tmp < top)? tmp: top);
 }
 c[0] += c[3];
 ret.r = (c[0] + crom1)*value;
 ret.g = (c[1] + crom1)*value;
 ret.b = (c[2] + crom1)*value;
 return ret;
}

canonical_original_code:
struct RGB rgb_compo(float hue, float crom, float value)
{
 unsigned char c[4];
 struct RGB ret;
 int k;
 float l1 = (2*3.14159265358979323846)/3.0;
 float top = 255*crom;
 float tmp; float crom1 = (1-crom)*255;
 hue = hue + 3.14159265358979323846;
 for(k=0; k<4; k++){
  tmp = (top*2)*fun_lambda((hue-l1*k)/l1);
  c[k] = (unsigned char)((tmp < top)? tmp: top);
 }
 c[0] += c[3];
 ret.r = (c[0] + crom1)*value;
 ret.g = (c[1] + crom1)*value;
 ret.b = (c[2] + crom1)*value;
 return ret;
}

variable_types: hue float

variable_types: crom float

variable_types: value float

variable_types:
c
unsigned char [4]

variable_types:
ret
struct RGB { unsigned char r; }

variable_types: k int

variable_types: top float

variable_types: tmp float

return_type: struct RGB { unsigned char r; }


decompiled_code:
unsigned __int64 __fastcall hcv2rgb(double a1, float a2)
{
unsigned __int64 v2; // rax

v2 = rgb_compo(*(float *)&a1, *((float *)&a1 + 1), a2);
return (unsigned __int16)v2 | v2 & 0xFF0000;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(double a1, float a2)
{
unsigned __int64 v2; // rax

v2 = func7(*(float *)&a1, *((float *)&a1 + 1), a2);
return (unsigned __int16)v2 | v2 & 0xFF0000;
}

original_code:
struct RGB hcv2rgb(struct HCV col)
{
 struct RGB ret = rgb_compo(col.h, col.c, col.v);
 return ret;
}

variable_types:
col
struct HCV { float h; }

user_defined_types:
struct HCV { float h; }
struct RGB { unsigned char r; }


decompiled_code:
__m128i __fastcall rgb2hcv(int a1, __m128i a2)
{
int v2; // ebp
int v3; // ebx
__m128i v5[2]; // [rsp+34h] [rbp-24h] BYREF

*(float *)a2.m128i_i32 = rgb_hue(a1 & 0xFF00 | (unsigned __int8)a1 | (BYTE2(a1) << 16));
v2 = _mm_cvtsi128_si32(a2);
v3 = (unsigned __int16)a1 | (BYTE2(a1) << 16);
rgb_val(v3);
v5[0].m128i_i64[0] = __PAIR64__(COERCE_UNSIGNED_INT(rgb_crom(v3)), v2);
return _mm_loadl_epi64(v5);
}

original_code:
struct HCV rgb2hcv(struct RGB col)
{
 struct HCV ret;
 ret.h = rgb_hue(col);
 ret.v = rgb_val(col);
 ret.c = rgb_crom(col);
 return ret;
}

variable_types:
ret
struct HCV { float h; }

return_type: struct HCV { float h; }

user_defined_types:
struct RGB { unsigned char r; }
struct HCV { float h; }


rgb

decompiled_code:
unsigned __int64 __fastcall rgb(char a1, char a2, unsigned __int8 a3)
{
unsigned __int16 v4; // [rsp+1h] [rbp-3h]

LOBYTE(v4) = a1;
HIBYTE(v4) = a2;
return ((unsigned __int64)a3 << 16) | v4;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(char a1, char a2, unsigned __int8 a3)
{
unsigned __int16 v4; // [rsp+1h] [rbp-3h]

LOBYTE(v4) = a1;
HIBYTE(v4) = a2;
return ((unsigned __int64)a3 << 16) | v4;
}

original_code:
extern inline struct RGB rgb(unsigned char r, unsigned char g, unsigned char b)
{
 struct RGB ret;
 ret.r = r;
 ret.g = g;
 ret.b = b;
 return ret;
}

variable_types:
r
unsigned char

variable_types:
g
unsigned char

variable_types:
b
unsigned char


hcv

decompiled_code:
__m128i __fastcall hcv(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

canonical_decompiled_code:
__m128i __fastcall func2(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

original_code:
extern inline struct HCV hcv(float h, float c, float v)
{
 struct HCV ret;
 ret.h = h;
 ret.c = c;
 ret.v = v;
 return ret;
}

variable_types: h float

variable_types: c float

variable_types: v float


decompiled_code:
double __fastcall fun_r(double result)
{
if ( *(float *)&result <= 0.0 )
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func0(double result)
{
if ( *(float *)&result <= 0.0 )
result = 0.0;
return result;
}

original_code:
inline float fun_r(float t)
{
 return (t > 0)? t : 0;
}

variable_types: t float


decompiled_code:
double __fastcall fun_lambda(float a1)
{
float v1; // xmm1_4
double v2; // xmm0_8

LODWORD(v1) = LODWORD(a1) & LC1;
*(_QWORD *)&v2 = (unsigned int)LC2;
*(float *)&v2 = 1.0 - v1;
return fun_r(v2);
}

canonical_decompiled_code:
double __fastcall func1(float a1)
{
float v1; // xmm1_4
double v2; // xmm0_8

LODWORD(v1) = LODWORD(a1) & LC1;
*(_QWORD *)&v2 = (unsigned int)LC2;
*(float *)&v2 = 1.0 - v1;
return func0(v2);
}

original_code:
inline float fun_lambda(float t)
{
 return fun_r(1 - fabsf(t));
}


decompiled_code:
double __fastcall fun_u(float a1)
{
double result; // xmm0_8

if ( a1 <= 0.0 )
return 0.0;
*(_QWORD *)&result = (unsigned int)LC2;
return result;
}

canonical_decompiled_code:
double __fastcall func2(float a1)
{
double result; // xmm0_8

if ( a1 <= 0.0 )
return 0.0;
*(_QWORD *)&result = (unsigned int)LC2;
return result;
}

original_code:
inline float fun_u(float t)
{
 return (t > 0);
}


decompiled_code:
double fun_pi()
{
return 0.0;
}

canonical_decompiled_code:
double func3()
{
return 0.0;
}

original_code:
inline float fun_pi(float t)
{
 return (fabsf(t) < 1/2);
}


min

decompiled_code:
__int64 __fastcall min(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = a1;
if ( (int)a2 <= (int)a1 )
result = a2;
return result;
}

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

result = a1;
if ( (int)a2 <= (int)a1 )
result = a2;
return result;
}

original_code:
static inline int min(int a, int b)
{
 return (a < b)? a : b;
}

variable_types: a int

variable_types: b int


decompiled_code:
float __fastcall cbuf_address(__int64 a1, char a2, char a3)
{
return *(float *)(a1 + 4LL * ((a2 - a3) & 0x1F));
}

canonical_decompiled_code:
float __fastcall func1(__int64 a1, char a2, char a3)
{
return *(float *)(a1 + 4LL * ((a2 - a3) & 0x1F));
}

original_code:
static inline sample_t cbuf_address(sample_t *cb, int cb_state, int delay)
{
 return cb[(cb_state - delay) & (32 - 1)];
}

canonical_original_code:
static inline float cbuf_address(float *cb, int cb_state, int delay)
{
 return cb[(cb_state - delay) & (32 - 1)];
}

variable_types:
cb
float *

variable_types: delay int


decompiled_code:
float __fastcall choose_src(__int64 a1, char a2, __int64 a3, int a4)
{
float result; // xmm0_4

if ( a4 < 0 )
result = cbuf_address(a1, a2, -(char)a4);
else
result = *(float *)(a3 + 4LL * a4);
return result;
}

canonical_decompiled_code:
float __fastcall func2(__int64 a1, char a2, __int64 a3, int a4)
{
float result; // xmm0_4

if ( a4 < 0 )
result = func1(a1, a2, -(char)a4);
else
result = *(float *)(a3 + 4LL * a4);
return result;
}

original_code:
static inline sample_t choose_src(sample_t *cb, int cb_state, sample_t *src, int i)
{
 return (i < 0)? cbuf_address(cb, cb_state, -i) : src[i];
}

canonical_original_code:
static inline float choose_src(float *cb, int cb_state, float *src, int i)
{
 return (i < 0)? cbuf_address(cb, cb_state, -i) : src[i];
}

variable_types:
src
float *

variable_types: i int


decompiled_code:
__int64 __fastcall KTH_BUFSIZE(int a1, char a2)
{
__int64 result; // rax

result = (unsigned int)(a1 >> (a2 + 1));
if ( !(_DWORD)result )
result = 1LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, char a2)
{
__int64 result; // rax

result = (unsigned int)(a1 >> (a2 + 1));
if ( !(_DWORD)result )
result = 1LL;
return result;
}

original_code:
static inline int KTH_BUFSIZE(int bs, int k)
{
 int kbs = bs >> (k+1);
 return kbs? kbs : 1;
}

variable_types: bs int

variable_types: k int

variable_types: kbs int


decompiled_code:
__int64 __fastcall decbuf_index(int a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx

if ( a2 <= 0 )
return 0;
v2 = 0;
for ( i = 0; i != a2; ++i )
v2 += KTH_BUFSIZE(a1, i);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx

if ( a2 <= 0 )
return 0;
v2 = 0;
for ( i = 0; i != a2; ++i )
v2 += func3(a1, i);
return v2;
}

original_code:
static inline int decbuf_index(int jack_bufsize, int k)
{
 int i, acc = 0;
 for (i = 0; i < k; i++) {
  acc += KTH_BUFSIZE(jack_bufsize, i);
 }
 return acc;
}

canonical_original_code:
static inline int decbuf_index(int jack_bufsize, int k)
{
 int i; int acc = 0;
 for (i = 0; i < k; i++) {
  acc += KTH_BUFSIZE(jack_bufsize, i);
 }
 return acc;
}

variable_types: acc int


decompiled_code:
__int64 __fastcall decbuf_minsize(int a1)
{
return decbuf_index(a1, 8);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
return func4(a1, 8);
}

original_code:
static inline int decbuf_minsize(int jack_bufsize) {
 return decbuf_index(jack_bufsize, 8);
}


decompiled_code:
__int64 __fastcall cbuf_copy(__int64 a1, int a2, const void *a3, int a4)
{
memcpy((void *)(a1 + 4LL * (a2 % 32)), a3, 4LL * a4);
return (unsigned int)((a2 + a4) % 32);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2, const void *a3, int a4)
{
memcpy((void *)(a1 + 4LL * (a2 % 32)), a3, 4LL * a4);
return (unsigned int)((a2 + a4) % 32);
}

original_code:
static inline int cbuf_copy(sample_t *cb, int cb_state, sample_t *src, int n_samples)
{
  memcpy(cb + cb_state % 32, src, n_samples*sizeof(*cb));
  return (cb_state + n_samples) % 32;
}

canonical_original_code:
static inline int cbuf_copy(float *cb, int cb_state, float *src, int n_samples)
{
  memcpy(cb + cb_state % 32, src, n_samples*sizeof(*cb));
  return (cb_state + n_samples) % 32;
}


decimate

original_code:
static inline int decimate(const float *h, sample_t *cb, int cb_state, sample_t *src,
      int n_samples, sample_t *dst)
{
 const int first_stage_l = min(32 - 1, n_samples);
 const int to_copy = min(32, n_samples);
 int n;
 for (n = 0; n < n_samples; n += 2) {
  int i;
  sample_t acc = 0;
  for (i = 0; i < (32 / 2); i++) {
   acc += h[i] * (choose_src(cb, cb_state, src, n-i)
      + choose_src(cb, cb_state, src, (n+i) - (32 - 1)));
  }
  dst[n/2] = acc;
 }
 return cbuf_copy(cb, cb_state, src + n_samples - to_copy, to_copy);
}

canonical_original_code:
static inline int decimate(float *h, float *cb, int cb_state, float *src, int n_samples, float *dst)
{
 int first_stage_l = min(32 - 1, n_samples);
 int to_copy = min(32, n_samples);
 int n;
 for (n = 0; n < n_samples; n += 2) {
  int i;
  float acc = 0;
  for (i = 0; i < (32 / 2); i++) {
   acc += h[i] * (choose_src(cb, cb_state, src, n-i)
      + choose_src(cb, cb_state, src, (n+i) - (32 - 1)));
  }
  dst[n/2] = acc;
 }
 return cbuf_copy(cb, cb_state, src + n_samples - to_copy, to_copy);
}

variable_types:
h
float *

variable_types:
dst
float *

variable_types: n int

variable_types: acc float


decompiled_code:
_BOOL8 __fastcall STEP_RUNNABLE(unsigned int a1, int a2, int a3)
{
int v3; // esi
char v4; // cl

_BitScanReverse(&a1, a1);
v3 = a2 - (a1 ^ 0x1F);
v4 = v3 + 1;
if ( v3 + 1 < 0 )
v4 = 0;
return a3 % (1 << v4) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(unsigned int a1, int a2, int a3)
{
int v3; // esi
char v4; // cl

_BitScanReverse(&a1, a1);
v3 = a2 - (a1 ^ 0x1F);
v4 = v3 + 1;
if ( v3 + 1 < 0 )
v4 = 0;
return a3 % (1 << v4) == 0;
}

original_code:
static inline int STEP_RUNNABLE(int bs, int step, int frame_count)
{
 int skip_n = (step - __builtin_clz(bs) + 1);
 return !(frame_count % (1 << ((skip_n <= 0) ? 0 : skip_n)));
}

variable_types: step int


decompiled_code:
void rtfi_unload()
{
jack_client_close();
free(decbuf);
decbuf = 0LL;
}

canonical_decompiled_code:
void func11()
{
jack_client_close();
free(decbuf);
decbuf = 0LL;
}

original_code:
void rtfi_unload(void *client)
{
 jack_client_close(client);
 free(decbuf);
 decbuf = ((void *)0);
}

variable_types:
client
void *


decompiled_code:
__int64 rtfi_launch()
{
return jack_activate();
}

canonical_decompiled_code:
__int64 func13()
{
return jack_activate();
}

original_code:
int rtfi_launch(void *client)
{
 return jack_activate(client);
}


original_code:
int generic_parser(int argc, char *argv[], struct opt_conf config)
{
 int error=0, i, j, no_more_options = 0;
 char *key, *value, *tmp_key, *pending_opt = ((void *)0);
 struct opt_rule curr_rule;
 if (config.ignore_argv0)
  i = 1;
 else
  i = 0;
 while( error >= PARSE_OK && i<argc ){
  if ( !no_more_options
      && ( (pending_opt != ((void *)0))
         || ( ((key=isopt(argv[i])) != ((void *)0) ) && key[0]!='\0' ))){
   if( pending_opt == ((void *)0) && (tmp_key=isopt(key))!=((void *)0)){
    key=tmp_key;
    if( tmp_key[0] == '\0' )
     no_more_options = 1;
   } else if( pending_opt != ((void *)0)){
    tmp_key = ((void *)0);
    key = pending_opt;
    pending_opt = ((void *)0);
   }
   if(!no_more_options) {
    for(j=0; j<config.n_reglas; j++){
     if( (tmp_key==((void *)0)
      && config.reglas[j].short_id == key[0])
       ||( (tmp_key != ((void *)0)) && (config.reglas[j].long_id !=((void *)0) )
         && strcmp(key, config.reglas[j].long_id)==0)){
          curr_rule = config.reglas[j];
          break;
     }
    }
    if (j < config.n_reglas){
     if (curr_rule.accion == DO_HELP){
      do_help(config);
      error = -PARSE_REQHELP;
     }else if ((int_in_arr((curr_rule).accion, need_value, (sizeof(need_value)/sizeof(int)))) ){
      if( tmp_key == ((void *)0) && key[1]!='\0'){
       value = &key[1];
      } else if( ( (tmp_key == ((void *)0)
        && key[1]=='\0')
             || tmp_key != ((void *)0)
          ) && i< (argc-1) ) {
       value = argv[++i];
      } else {
       if(tmp_key == ((void *)0) )
        fprintf(stderr, "Falta valor para la opcion: %c\n", key[0]);
       else
        fprintf(stderr, "Falta valor para la opcion: %s\n", key);
       error = -PARSE_BADSYNTAX;
      }
     } else {
      value = ((void *)0);
      if ( tmp_key == ((void *)0) && key[1]!='\0'){
       pending_opt = &key[1];
      }
     }
     if( error >= PARSE_OK )
      error =do_action(curr_rule, key,
         value);
    } else {
     fprintf(stderr, "Opcion desconocida: %s\n", key);
     error = -PARSE_BADSYNTAX;
    }
   }
  } else if(config.arg_parser != ((void *)0)){
   error = config.arg_parser(i, argv[i],
       config.arg_parser_data);
  } else {
   fprintf(stderr, "Argumento: %s no tiene clave\n", argv[i]);
   error = -PARSE_BADSYNTAX;
  }
  if ( pending_opt == ((void *)0) )
   i++;
 }
 return error;
}

canonical_original_code:
int generic_parser(int argc, char *argv[], struct opt_conf config)
{
 int error = 0; int i; int j; int no_more_options = 0;
 char *key; char *value; char *tmp_key; char *pending_opt = ((void *)0);
 struct opt_rule curr_rule;
 if (config.ignore_argv0)
  i = 1;
 else
  i = 0;
 while( error >= PARSE_OK && i<argc ){
  if ( !no_more_options
      && ( (pending_opt != ((void *)0))
         || ( ((key=isopt(argv[i])) != ((void *)0) ) && key[0]!='\0' ))){
   if( pending_opt == ((void *)0) && (tmp_key=isopt(key))!=((void *)0)){
    key=tmp_key;
    if( tmp_key[0] == '\0' )
     no_more_options = 1;
   } else if( pending_opt != ((void *)0)){
    tmp_key = ((void *)0);
    key = pending_opt;
    pending_opt = ((void *)0);
   }
   if(!no_more_options) {
    for(j=0; j<config.n_reglas; j++){
     if( (tmp_key==((void *)0)
      && config.reglas[j].short_id == key[0])
       ||( (tmp_key != ((void *)0)) && (config.reglas[j].long_id !=((void *)0) )
         && strcmp(key, config.reglas[j].long_id)==0)){
          curr_rule = config.reglas[j];
          break;
     }
    }
    if (j < config.n_reglas){
     if (curr_rule.accion == DO_HELP){
      do_help(config);
      error = -PARSE_REQHELP;
     }else if ((int_in_arr((curr_rule).accion, need_value, (sizeof(need_value)/sizeof(int)))) ){
      if( tmp_key == ((void *)0) && key[1]!='\0'){
       value = &key[1];
      } else if( ( (tmp_key == ((void *)0)
        && key[1]=='\0')
             || tmp_key != ((void *)0)
          ) && i< (argc-1) ) {
       value = argv[++i];
      } else {
       if(tmp_key == ((void *)0) )
        fprintf(stderr, "Falta valor para la opcion: %c\n", key[0]);
       else
        fprintf(stderr, "Falta valor para la opcion: %s\n", key);
       error = -PARSE_BADSYNTAX;
      }
     } else {
      value = ((void *)0);
      if ( tmp_key == ((void *)0) && key[1]!='\0'){
       pending_opt = &key[1];
      }
     }
     if( error >= PARSE_OK )
      error =do_action(curr_rule, key,
         value);
    } else {
     fprintf(stderr, "Opcion desconocida: %s\n", key);
     error = -PARSE_BADSYNTAX;
    }
   }
  } else if(config.arg_parser != ((void *)0)){
   error = config.arg_parser(i, argv[i],
       config.arg_parser_data);
  } else {
   fprintf(stderr, "Argumento: %s no tiene clave\n", argv[i]);
   error = -PARSE_BADSYNTAX;
  }
  if ( pending_opt == ((void *)0) )
   i++;
 }
 return error;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct opt_conf { char *helpstr; struct opt_rule { char short_id; char *long_id; char *desc; int accion; union { int *d_int; int *d_bool; double *d_double; float *d_float; char **d_str; struct { void *data; int (*callback)(char *, char *, void *, char **); } d_custom; } data; } *reglas; int n_reglas; int ignore_argv0; int (*arg_parser)(int, char *, void *); void *arg_parser_data; }

variable_types: error int

variable_types: j int

variable_types:
key
char *

variable_types:
value
char *

user_defined_types: struct opt_conf { char *helpstr; struct opt_rule *reglas; int n_reglas; int ignore_argv0; int (*arg_parser)(int, char *, void *); void *arg_parser_data; }


original_code:
void set_parse_meta(struct opt_rule *regla, char short_id, const char *long_id,
       const char *desc)
{
 regla->short_id = short_id;
 regla->long_id = long_id;
 regla->desc = desc;
}

canonical_original_code:
void set_parse_meta(struct opt_rule *regla, char short_id, char *long_id, char *desc)
{
 regla->short_id = short_id;
 regla->long_id = long_id;
 regla->desc = desc;
}

variable_types: struct opt_rule { char short_id; char *long_id; char *desc; int accion; union { int *d_int; int *d_bool; double *d_double; float *d_float; char **d_str; struct { void *data; int (*callback)(char *, char *, void *, char **); } d_custom; } data; } *

variable_types:
desc
char *


decompiled_code:
void __fastcall set_parse_ignore(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 0;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 0;
}

original_code:
void set_parse_ignore(struct opt_rule *regla)
{
 (regla)->accion = (PARSE_IGNORE);
}

user_defined_types: struct opt_rule { char short_id; char *long_id; char *desc; int accion; union { int *d_int; int *d_bool; double *d_double; float *d_float; char **d_str; struct { void *data; int (*callback)(char *, char *, void *, char **); } d_custom; } data; }


decompiled_code:
void __fastcall set_parse_ignore_sw(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 1;
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 1;
}

original_code:
void set_parse_ignore_sw(struct opt_rule *regla)
{
 (regla)->accion = (PARSE_IGNORE_SWITCH);
}


decompiled_code:
void __fastcall set_parse_help(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 10;
}

original_code:
void set_parse_help(struct opt_rule *regla)
{
 (regla)->accion = (DO_HELP);
}


original_code:
void set_parse_custom(struct opt_rule *regla,
  int (*callback)(char *, char*, void*, const char**), void* data)
{
 (regla)->accion = (CUSTOM_ACTION);
 regla->data.d_custom.callback = callback;
 regla->data.d_custom.data = data;
}

canonical_original_code:
void set_parse_custom(struct opt_rule *regla, int (*callback)(char *, char *, void *, char **), void *data)
{
 (regla)->accion = (CUSTOM_ACTION);
 regla->data.d_custom.callback = callback;
 regla->data.d_custom.data = data;
}

variable_types: int (*)(char *, char *, void *, char **)

variable_types:
data
void *


original_code: void set_parse_int(struct opt_rule *regla, int *data) { (regla)->accion = (PARSE_INT); regla->data.d_int = data ; }

variable_types:
data
int *


decompiled_code:
void __fastcall set_parse_double(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 24) = 6;
*(_QWORD *)(a1 + 32) = a2;
}

original_code: void set_parse_double(struct opt_rule *regla, double *data) { (regla)->accion = (PARSE_DOUBLE); regla->data.d_double = data ; }

variable_types:
data
double *


original_code: void set_parse_float(struct opt_rule *regla, float *data) { (regla)->accion = (PARSE_FLOAT); regla->data.d_float = data ; }

variable_types:
data
float *


original_code: void set_parse_bool(struct opt_rule *regla, int *data) { (regla)->accion = (SET_BOOL); regla->data.d_bool = data ; }


decompiled_code:
void __fastcall set_parse_bool_unset(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 24) = 5;
*(_QWORD *)(a1 + 32) = a2;
}

original_code: void set_parse_bool_unset(struct opt_rule *regla, int *data) { (regla)->accion = (UNSET_BOOL); regla->data.d_bool = data ; }


original_code: void set_parse_str(struct opt_rule *regla, char* *data) { (regla)->accion = (PARSE_STR); regla->data.d_str = data ; }

canonical_original_code: void set_parse_str(struct opt_rule *regla, char **data) { (regla)->accion = (PARSE_STR); regla->data.d_str = data ; }

variable_types:
data
char **


decompiled_code:
void __fastcall set_parse_str_nocopy(__int64 a1, __int64 a2)
{
*(_DWORD *)(a1 + 24) = 9;
*(_QWORD *)(a1 + 32) = a2;
}

original_code: void set_parse_str_nocopy(struct opt_rule *regla, char* *data) { (regla)->accion = (PARSE_STR_NOCOPY); regla->data.d_str = data ; }

canonical_original_code: void set_parse_str_nocopy(struct opt_rule *regla, char **data) { (regla)->accion = (PARSE_STR_NOCOPY); regla->data.d_str = data ; }


original_code:
static int vect_continue(struct vector_data *data, char *value, char **endptr)
{
 int ret = -PARSE_OK, i;
 if(*value != '\0')
 {
  for (i = 0; value[i] == data->sep[i] && value[i] != '\0'; i++);
  if (data->sep[i] != '\0')
   ret = -PARSE_BADSYNTAX;
  if (endptr != ((void *)0))
   *endptr = &value[i];
 } else {
  ret = 1;
 }
 return ret;
}

canonical_original_code:
static int vect_continue(struct vector_data *data, char *value, char **endptr)
{
 int ret = -PARSE_OK; int i;
 if(*value != '\0')
 {
  for (i = 0; value[i] == data->sep[i] && value[i] != '\0'; i++);
  if (data->sep[i] != '\0')
   ret = -PARSE_BADSYNTAX;
  if (endptr != ((void *)0))
   *endptr = &value[i];
 } else {
  ret = 1;
 }
 return ret;
}

variable_types: struct vector_data { unsigned long n_elem; char *sep; int type; int ignore_overfl; int ignore_underfl; char *msg; union { double *double_arr; float *float_arr; int *int_arr; char *char_arr; } arr; int *read; } *

variable_types:
endptr
char **

variable_types: ret int

variable_types: i int


decompiled_code:
__int64 __fastcall filler_strtot(__int64 a1, int a2, char *a3, char **a4)
{
int v6; // eax
__int64 result; // rax
int v8; // eax
char v9; // al
char *endptr[6]; // [rsp+8h] [rbp-30h] BYREF

endptr[0] = a3;
if ( (unsigned __int64)a2 < *(_QWORD *)a1 )
{
v8 = *(_DWORD *)(a1 + 16);
if ( v8 == 1 )
{
*(double *)(*(_QWORD *)(a1 + 40) + 8LL * a2) = strtod(a3, endptr);
}
else if ( v8 == 3 )
{
v9 = *a3;
if ( *a3 )
endptr[0] = a3 + 1;
*(_BYTE *)(*(_QWORD *)(a1 + 40) + a2) = v9;
}
else if ( v8 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 40) + 4LL * a2) = (int)(double)(int)strtol(a3, endptr, 0);
}
else
{
*(float *)(*(_QWORD *)(a1 + 40) + 4LL * a2) = strtof(a3, endptr);
}
LABEL_14:
result = 1LL;
if ( !*a3 )
goto LABEL_16;
goto LABEL_15;
}
if ( !*(_DWORD *)(a1 + 20) )
return 4294967294LL;
v6 = *(_DWORD *)(a1 + 16);
if ( v6 == 1 )
{
strtod(a3, endptr);
goto LABEL_14;
}
if ( v6 != 3 )
{
if ( v6 )
strtol(a3, endptr, 0);
else
strtof(a3, endptr);
goto LABEL_14;
}
result = 1LL;
if ( *a3 )
{
endptr[0] = a3 + 1;
LABEL_15:
result = 2 * (unsigned int)(endptr[0] != a3) - 2;
}
LABEL_16:
if ( a4 )
*a4 = endptr[0];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, char *a3, char **a4)
{
int v6; // eax
__int64 result; // rax
int v8; // eax
char v9; // al
char *endptr[6]; // [rsp+8h] [rbp-30h] BYREF

endptr[0] = a3;
if ( (unsigned __int64)a2 < *(_QWORD *)a1 )
{
v8 = *(_DWORD *)(a1 + 16);
if ( v8 == 1 )
{
*(double *)(*(_QWORD *)(a1 + 40) + 8LL * a2) = strtod(a3, endptr);
}
else if ( v8 == 3 )
{
v9 = *a3;
if ( *a3 )
endptr[0] = a3 + 1;
*(_BYTE *)(*(_QWORD *)(a1 + 40) + a2) = v9;
}
else if ( v8 )
{
*(_DWORD *)(*(_QWORD *)(a1 + 40) + 4LL * a2) = (int)(double)(int)strtol(a3, endptr, 0);
}
else
{
*(float *)(*(_QWORD *)(a1 + 40) + 4LL * a2) = strtof(a3, endptr);
}
LABEL_14:
result = 1LL;
if ( !*a3 )
goto LABEL_16;
goto LABEL_15;
}
if ( !*(_DWORD *)(a1 + 20) )
return 4294967294LL;
v6 = *(_DWORD *)(a1 + 16);
if ( v6 == 1 )
{
strtod(a3, endptr);
goto LABEL_14;
}
if ( v6 != 3 )
{
if ( v6 )
strtol(a3, endptr, 0);
else
strtof(a3, endptr);
goto LABEL_14;
}
result = 1LL;
if ( *a3 )
{
endptr[0] = a3 + 1;
LABEL_15:
result = 2 * (unsigned int)(endptr[0] != a3) - 2;
}
LABEL_16:
if ( a4 )
*a4 = endptr[0];
return result;
}

original_code:
static int filler_strtot(struct vector_data *data, int i, char *str,
        char **endptr)
{
 char c, *_endptr = str;
 union {
  float fl;
  double dbl;
  int n;
 } d;
 int ins, ret;
 if (i >= data->n_elem) {
  ins = 0;
  if (!data->ignore_overfl) {
   ret = -PARSE_BADSYNTAX;
   goto filler_strtot_end;
  }
 } else {
  ins = 1;
 }
 switch (data->type) {
 case VPARSER_FLOAT:
  d.fl = strtof(str, &_endptr);
  if (ins)
   data->arr.float_arr[i] = d.fl;
  break;
 case VPARSER_DOUBLE:
  d.dbl = strtod(str, &_endptr);
  if (ins)
   data->arr.double_arr[i] = d.dbl;
  break;
 default:
 case VPARSER_INT:
  d.dbl = strtol(str, &_endptr, 0);
  if (ins)
   data->arr.int_arr[i] = d.dbl;
  break;
 case VPARSER_CHAR:
  if((c = str[0]) != '\0')
   _endptr = str + 1;
  if (ins)
   data->arr.char_arr[i] = c;
  break;
 }
 if (*str == '\0') {
  ret = 1;
 } else if (str == _endptr) {
  ret = -PARSE_BADSYNTAX;
 } else {
  ret = -PARSE_OK;
 }
 if (endptr != ((void *)0))
  *endptr = _endptr;
filler_strtot_end:
 return ret;
}

canonical_original_code:
static int filler_strtot(struct vector_data *data, int i, char *str, char **endptr)
{
 char c; char *_endptr = str;
 union { float fl; double dbl; int n; } d;
 int ins; int ret;
 if (i >= data->n_elem) {
  ins = 0;
  if (!data->ignore_overfl) {
   ret = -PARSE_BADSYNTAX;
   goto filler_strtot_end;
  }
 } else {
  ins = 1;
 }
 switch (data->type) {
 case VPARSER_FLOAT:
  d.fl = strtof(str, &_endptr);
  if (ins)
   data->arr.float_arr[i] = d.fl;
  break;
 case VPARSER_DOUBLE:
  d.dbl = strtod(str, &_endptr);
  if (ins)
   data->arr.double_arr[i] = d.dbl;
  break;
 default:
 case VPARSER_INT:
  d.dbl = strtol(str, &_endptr, 0);
  if (ins)
   data->arr.int_arr[i] = d.dbl;
  break;
 case VPARSER_CHAR:
  if((c = str[0]) != '\0')
   _endptr = str + 1;
  if (ins)
   data->arr.char_arr[i] = c;
  break;
 }
 if (*str == '\0') {
  ret = 1;
 } else if (str == _endptr) {
  ret = -PARSE_BADSYNTAX;
 } else {
  ret = -PARSE_OK;
 }
 if (endptr != ((void *)0))
  *endptr = _endptr;
filler_strtot_end:
 return ret;
}

variable_types:
str
char *

variable_types: c char

variable_types:
d
union { float fl; double dbl; int n; }

variable_types: ins int

user_defined_types: struct vector_data { unsigned long n_elem; char *sep; int type; int ignore_overfl; int ignore_underfl; char *msg; union { double *double_arr; float *float_arr; int *int_arr; char *char_arr; } arr; int *read; }


decompiled_code:
__int64 __fastcall vector_parser(__int64 a1, char *a2, __int64 a3, _QWORD *a4)
{
char *v5; // rbx
int i; // ebp
__int64 v8; // r13
__int64 result; // rax
int v10; // ebx
__int64 v11; // rcx
_DWORD *v12; // rdx
char *v13[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !a2 || (v5 = a2, !a3) )
{
v11 = 0LL;
result = 4294967293LL;
goto LABEL_19;
}
if ( !valid_vtype(*(_DWORD *)(a3 + 16)) )
{
v11 = 0LL;
result = 4294967293LL;
goto LABEL_19;
}
for ( i = 0; ; ++i )
{
LODWORD(v8) = i + 1;
result = filler_strtot(a3, i, v5, v13);
v10 = result;
if ( (_DWORD)result )
break;
result = vect_continue(a3, v13[0], v13);
if ( (_DWORD)result )
break;
v5 = v13[0];
}
if ( (int)result <= 0 )
{
LABEL_12:
v11 = *(_QWORD *)(a3 + 32);
goto LABEL_13;
}
if ( (unsigned __int64)(int)v8 < *(_QWORD *)a3 )
{
if ( *(_DWORD *)(a3 + 24) )
{
v11 = 0LL;
result = 0LL;
goto LABEL_13;
}
result = 4294967294LL;
goto LABEL_12;
}
v11 = 0LL;
result = 0LL;
LABEL_13:
v12 = *(_DWORD **)(a3 + 48);
if ( v12 )
{
if ( v10 < 0 )
LODWORD(v8) = i;
if ( *(_QWORD *)a3 <= (unsigned __int64)(int)v8 )
v8 = *(_QWORD *)a3;
*v12 = v8;
}
LABEL_19:
if ( a4 )
*a4 = v11;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, char *a2, __int64 a3, _QWORD *a4)
{
char *v5; // rbx
int i; // ebp
__int64 v8; // r13
__int64 result; // rax
int v10; // ebx
__int64 v11; // rcx
_DWORD *v12; // rdx
char *v13[6]; // [rsp+8h] [rbp-30h] BYREF

if ( !a2 || (v5 = a2, !a3) )
{
v11 = 0LL;
result = 4294967293LL;
goto LABEL_19;
}
if ( !func0(*(_DWORD *)(a3 + 16)) )
{
v11 = 0LL;
result = 4294967293LL;
goto LABEL_19;
}
for ( i = 0; ; ++i )
{
LODWORD(v8) = i + 1;
result = func2(a3, i, v5, v13);
v10 = result;
if ( (_DWORD)result )
break;
result = func1(a3, v13[0], v13);
if ( (_DWORD)result )
break;
v5 = v13[0];
}
if ( (int)result <= 0 )
{
LABEL_12:
v11 = *(_QWORD *)(a3 + 32);
goto LABEL_13;
}
if ( (unsigned __int64)(int)v8 < *(_QWORD *)a3 )
{
if ( *(_DWORD *)(a3 + 24) )
{
v11 = 0LL;
result = 0LL;
goto LABEL_13;
}
result = 4294967294LL;
goto LABEL_12;
}
v11 = 0LL;
result = 0LL;
LABEL_13:
v12 = *(_DWORD **)(a3 + 48);
if ( v12 )
{
if ( v10 < 0 )
LODWORD(v8) = i;
if ( *(_QWORD *)a3 <= (unsigned __int64)(int)v8 )
v8 = *(_QWORD *)a3;
*v12 = v8;
}
LABEL_19:
if ( a4 )
*a4 = v11;
return result;
}

original_code:
int vector_parser(char *key, char *value, void *_data, const char **_msg)
{
 struct vector_data *data = (struct vector_data*)_data;
 int ret = -PARSE_OK, i = 0, vc = -PARSE_OK, fc = -PARSE_OK;
 char *end, *msg = ((void *)0);
 if (value != ((void *)0) && data!=((void *)0) && valid_vtype(data->type)) {
  do {
   vc = filler_strtot(data, i++, value, &end);
   fc = vc;
   if (vc)
    break;
   value = end;
   vc = vect_continue(data, value, &end);
   if (vc)
    break;
   value = end;
  } while (1);
  if (vc > 0 && i < data->n_elem && !data->ignore_underfl)
   vc = -PARSE_BADSYNTAX;
  if (vc < 0) {
   msg = data->msg;
   ret = vc;
  }
  if (data->read != ((void *)0)) {
   if (fc < 0)
    i--;
   *data->read = i > data->n_elem ? data->n_elem : i;
  }
 } else {
  ret = -PARSE_BADCONFIG;
 }
 if(_msg != ((void *)0) )
  *_msg = msg;
 return ret;
}

canonical_original_code:
int vector_parser(char *key, char *value, void *_data, char **_msg)
{
 struct vector_data *data = (struct vector_data*)_data;
 int ret = -PARSE_OK; int i = 0; int vc = -PARSE_OK; int fc = -PARSE_OK;
 char *end; char *msg = ((void *)0);
 if (value != ((void *)0) && data!=((void *)0) && valid_vtype(data->type)) {
  do {
   vc = filler_strtot(data, i++, value, &end);
   fc = vc;
   if (vc)
    break;
   value = end;
   vc = vect_continue(data, value, &end);
   if (vc)
    break;
   value = end;
  } while (1);
  if (vc > 0 && i < data->n_elem && !data->ignore_underfl)
   vc = -PARSE_BADSYNTAX;
  if (vc < 0) {
   msg = data->msg;
   ret = vc;
  }
  if (data->read != ((void *)0)) {
   if (fc < 0)
    i--;
   *data->read = i > data->n_elem ? data->n_elem : i;
  }
 } else {
  ret = -PARSE_BADCONFIG;
 }
 if(_msg != ((void *)0) )
  *_msg = msg;
 return ret;
}

variable_types:
key
char *

variable_types:
value
char *

variable_types: vc int

variable_types: fc int

variable_types:
end
char *

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall set_vector_parser(__int64 a1, __int64 a2)
{
return set_parse_custom(a1, vector_parser, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
return set_parse_custom(a1, vector_parser, a2);
}

original_code:
extern void set_vector_parser(struct opt_rule *regla, struct vector_data *cfg)
{
 set_parse_custom(regla, vector_parser, cfg);
}

variable_types: struct opt_rule { char short_id; char *long_id; char *desc; int accion; union { int *d_int; int *d_bool; double *d_double; float *d_float; char **d_str; struct { void *data; int (*callback)(char *, char *, void *, char **); } d_custom; } data; } *


decompiled_code:
__int64 __fastcall str_collector(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // rax
__int64 result; // rax

v3 = *(int *)(a3 + 12);
if ( v3 >= *(_QWORD *)a3 )
{
result = *(unsigned int *)(a3 + 8);
if ( (_DWORD)result )
result = 2LL;
}
else
{
*(_QWORD *)(*(_QWORD *)(a3 + 16) + 8 * v3) = a2;
++*(_DWORD *)(a3 + 12);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3)
{
unsigned __int64 v3; // rax
__int64 result; // rax

v3 = *(int *)(a3 + 12);
if ( v3 >= *(_QWORD *)a3 )
{
result = *(unsigned int *)(a3 + 8);
if ( (_DWORD)result )
result = 2LL;
}
else
{
*(_QWORD *)(*(_QWORD *)(a3 + 16) + 8 * v3) = a2;
++*(_DWORD *)(a3 + 12);
result = 0LL;
}
return result;
}

original_code:
int str_collector(int dummy, char *str, void *_cfg)
{
 struct str_coll_data *cfg = (struct str_coll_data*)_cfg;
 int ret = PARSE_OK;
 if (cfg->n < cfg->n_elem) {
  cfg->store[cfg->n] = str;
  cfg->n++;
 } else if (cfg->strict) {
  ret = PARSE_BADSYNTAX;
 }
 return ret;
}

variable_types: dummy int

variable_types: struct str_coll_data { unsigned long n_elem; int strict; int n; char **store; } *


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

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

original_code:
int str_coll_n_read(struct str_coll_data *cd)
{
 return cd->n;
}

user_defined_types: struct str_coll_data { unsigned long n_elem; int strict; int n; char **store; }


decompiled_code:
_BOOL8 __fastcall can_fullscreen(unsigned int a1)
{
return SDL_ListModes(0LL, a1) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(unsigned int a1)
{
return SDL_ListModes(0LL, a1) != 0;
}

original_code:
static int can_fullscreen(int flags)
{
 return SDL_ListModes(((void *)0), flags) != ((SDL_Rect**)(0));
}

canonical_original_code:
static int can_fullscreen(int flags)
{
 return SDL_ListModes(((void *)0), flags) != ((struct SDL_Rect **)(0));
}

variable_types: flags int

user_defined_types: struct SDL_Rect { short x; unsigned short w; }