decompiled_code:
__int64 __fastcall fit_space_with_color(char *a1, const char *a2, int a3)
{
const char *v4; // rax
int v5; // eax

snprintf(a1, 0x800uLL, "%s", a2);
v4 = (const char *)smash_color(a1);
v5 = strlen(v4);
return add_spaces(a1, (unsigned int)(a3 - v5));
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, const char *a2, int a3)
{
const char *v4; // rax
int v5; // eax

snprintf(a1, 0x800uLL, "%s", a2);
v4 = (const char *)smash_color(a1);
v5 = strlen(v4);
return add_spaces(a1, (unsigned int)(a3 - v5));
}

original_code:
void fit_space_with_color( char *dest, const char *orig, int space )
{
   snprintf( dest, 2048, "%s", orig );
   add_spaces( dest, ( space - strlen( smash_color( dest ) ) ) );
}

canonical_original_code:
void fit_space_with_color(char *dest, char *orig, int space)
{
   snprintf( dest, 2048, "%s", orig );
   add_spaces( dest, ( space - strlen( smash_color( dest ) ) ) );
}

variable_types:
dest
char *

variable_types:
orig
char *

variable_types: space int


AllocStack

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

result = malloc(0x10uLL);
*(_QWORD *)result = 0LL;
result[2] = 0;
return result;
}

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

result = malloc(0x10uLL);
*(_QWORD *)result = 0LL;
result[2] = 0;
return result;
}

original_code:
STACK *AllocStack()
{
  STACK *pStack;
  pStack = malloc(sizeof(*pStack));
  pStack->_pCells = ((void *)0);
  pStack->_iSize = 0;
  return pStack;
}

canonical_original_code:
struct BBGStack *AllocStack()
{
  struct BBGStack *pStack;
  pStack = malloc(sizeof(*pStack));
  pStack->_pCells = ((void *)0);
  pStack->_iSize = 0;
  return pStack;
}

variable_types: struct BBGStack { struct BBGStackCell { struct BBGStackCell *_pNext; void *_pContent; } *_pCells; int _iSize; } *

user_defined_types: struct BBGStack { struct BBGStackCell *_pCells; int _iSize; }


FreeStack

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

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = *v2;
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

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

v2 = *(_QWORD **)ptr;
if ( v2 )
{
do
{
*(_QWORD *)ptr = *v2;
free(v2);
v2 = *(_QWORD **)ptr;
}
while ( *(_QWORD *)ptr );
}
free(ptr);
}

original_code:
void FreeStack(STACK *pStack)
{
  SCELL *pCell;
  while ((pCell = pStack->_pCells) != ((void *)0))
  {
    pStack->_pCells = pCell->_pNext;
    free(pCell);
  }
  free(pStack);
}

canonical_original_code:
void FreeStack(struct BBGStack *pStack)
{
  struct BBGStackCell *pCell;
  while ((pCell = pStack->_pCells) != ((void *)0))
  {
    pStack->_pCells = pCell->_pNext;
    free(pCell);
  }
  free(pStack);
}

variable_types: struct BBGStackCell { struct BBGStackCell *_pNext; void *_pContent; } *

return_type: void


StackSize

decompiled_code:
__int64 __fastcall StackSize(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int StackSize(STACK *pStack)
{
  return pStack->_iSize;
}

canonical_original_code:
int StackSize(struct BBGStack *pStack)
{
  return pStack->_iSize;
}

return_type: int

user_defined_types: struct BBGStackCell { struct BBGStackCell *_pNext; void *_pContent; }


decompiled_code:
__int64 __fastcall get_coord_hash(int a1)
{
return (unsigned int)((int)abs32(a1) % 100);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return (unsigned int)((int)abs32(a1) % 100);
}

original_code:
int get_coord_hash( int x )
{
   return abs(x) % 100;
}

canonical_original_code:
int get_coord_hash(int x)
{
   return abs(x) % 100;
}

variable_types: x int


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

switch ( a1 )
{
case 0:
case 1:
case 6:
case 7:
result = (unsigned int)(a1 + 2);
break;
case 2:
case 3:
case 8:
case 9:
result = (unsigned int)(a1 - 2);
break;
case 4:
result = 5LL;
break;
case 5:
result = 4LL;
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
case 1:
case 6:
case 7:
result = (unsigned int)(a1 + 2);
break;
case 2:
case 3:
case 8:
case 9:
result = (unsigned int)(a1 - 2);
break;
case 4:
result = 5LL;
break;
case 5:
result = 4LL;
break;
default:
result = 0xFFFFFFFFLL;
break;
}
return result;
}

original_code:
int get_directional_opposite( int dir )
{
   switch( dir )
   {
      case DIR_NORTH:
      case DIR_EAST:
      case DIR_NORTH_EAST:
      case DIR_NORTH_WEST:
         return ( dir + 2 );
      case DIR_SOUTH:
      case DIR_WEST:
      case DIR_SOUTH_WEST:
      case DIR_SOUTH_EAST:
         return ( dir - 2 );
      case DIR_UP:
         return ( dir + 1 );
      case DIR_DOWN:
         return ( dir - 1 );
   }
   return -1;
}

canonical_original_code:
int get_directional_opposite(int dir)
{
   switch( dir )
   {
      case DIR_NORTH:
      case DIR_EAST:
      case DIR_NORTH_EAST:
      case DIR_NORTH_WEST:
         return ( dir + 2 );
      case DIR_SOUTH:
      case DIR_WEST:
      case DIR_SOUTH_WEST:
      case DIR_SOUTH_EAST:
         return ( dir - 2 );
      case DIR_UP:
         return ( dir + 1 );
      case DIR_DOWN:
         return ( dir - 1 );
   }
   return -1;
}

variable_types: dir int


decompiled_code:
void can_occupy()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
bool can_occupy( int x, int y, int z )
{
}

canonical_original_code:
unsigned char can_occupy(int x, int y, int z)
{
}

variable_types: y int

variable_types: z int

return_type: unsigned char


decompiled_code:
__int64 __fastcall check_name(const char *a1)
{
int v1; // ebx
__int64 result; // rax
const unsigned __int16 *v3; // rcx
__int64 v4; // rax

v1 = strlen(a1);
result = 0LL;
if ( (unsigned int)(v1 - 3) <= 9 )
{
v3 = *_ctype_b_loc();
v4 = 0LL;
while ( (v3[a1[v4]] & 0x400) != 0 )
{
if ( v1 <= (int)++v4 )
return 1LL;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
int v1; // ebx
__int64 result; // rax
const unsigned __int16 *v3; // rcx
__int64 v4; // rax

v1 = strlen(a1);
result = 0LL;
if ( (unsigned int)(v1 - 3) <= 9 )
{
v3 = *_ctype_b_loc();
v4 = 0LL;
while ( (v3[a1[v4]] & 0x400) != 0 )
{
if ( v1 <= (int)++v4 )
return 1LL;
}
result = 0LL;
}
return result;
}

original_code:
bool check_name(const char *name)
{
  int size, i;
  if ((size = strlen(name)) < 3 || size > 12)
    return 0;
  for (i = 0 ;i < size; i++)
    if (!((*__ctype_b_loc ())[(int) ((name[i]))] & (unsigned short int) _ISalpha)) return 0;
  return 1;
}

canonical_original_code:
unsigned char check_name(char *name)
{
  int size; int i;
  if ((size = strlen(name)) < 3 || size > 12)
    return 0;
  for (i = 0 ;i < size; i++)
    if (!((*__ctype_b_loc ())[(int) ((name[i]))] & (unsigned short) _ISalpha)) return 0;
  return 1;
}

variable_types:
name
char *

variable_types: size int

variable_types: i int


decompiled_code:
__int64 load_muddata()
{
return load_helps();
}

canonical_decompiled_code:
__int64 func2()
{
return load_helps();
}

original_code:
void load_muddata(bool fCopyOver)
{
  load_helps();
}

canonical_original_code:
void load_muddata(unsigned char fCopyOver)
{
  load_helps();
}

variable_types:
fCopyOver
unsigned char


decompiled_code:
char *get_time()
{
char *v0; // rcx
__int64 i; // rax

v0 = ctime(&current_time);
for ( i = 0LL; i != 15; ++i )
buf_1[i] = v0[i + 4];
byte_4FF = 0;
return buf_1;
}

canonical_decompiled_code:
char *func3()
{
char *v0; // rcx
__int64 i; // rax

v0 = ctime(&current_time);
for ( i = 0LL; i != 15; ++i )
buf_1[i] = v0[i + 4];
byte_4FF = 0;
return buf_1;
}

original_code:
char *get_time()
{
  static char buf[16];
  char *strtime;
  int i;
  strtime = ctime(&current_time);
  for (i = 0; i < 15; i++)
    buf[i] = strtime[i + 4];
  buf[15] = '\0';
  return buf;
}

variable_types:
buf
char [16]

variable_types:
strtime
char *

return_type: char *


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

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

original_code:
void free_command( COMMAND *command )
{
   command->cmd_name = ((void *)0);
   command->cmd_funct = ((void *)0);
   free(command);
}

canonical_original_code:
void free_command(struct typCmd *command)
{
   command->cmd_name = ((void *)0);
   command->cmd_funct = ((void *)0);
   free(command);
}

variable_types: struct typCmd { char *cmd_name; void (*cmd_funct)(void *passed, char *arg); short level; short state; } *


decompiled_code:
__int64 __fastcall count_color(const char *a1)
{
unsigned int v2; // edx
size_t v3; // rdi
const char *v4; // rax
const char *v5; // rdi

if ( !a1 )
return 0LL;
v2 = 0;
if ( *a1 )
{
v3 = strlen(a1);
v4 = a1;
v5 = &a1[v3];
v2 = 0;
while ( v4 != v5 )
v2 += *v4++ == 35;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
unsigned int v2; // edx
size_t v3; // rdi
const char *v4; // rax
const char *v5; // rdi

if ( !a1 )
return 0LL;
v2 = 0;
if ( *a1 )
{
v3 = strlen(a1);
v4 = a1;
v5 = &a1[v3];
v2 = 0;
while ( v4 != v5 )
v2 += *v4++ == 35;
}
return v2;
}

original_code:
int count_color( const char *str )
{
   int x;
   int count = 0;
   if( !str || str[0] == '\0' )
      return count;
   for( x = 0; x < strlen( str ); x++ )
      if( str[x] == '#' )
         count++;
   return count;
}

canonical_original_code:
int count_color(char *str)
{
   int x;
   int count = 0;
   if( !str || str[0] == '\0' )
      return count;
   for( x = 0; x < strlen( str ); x++ )
      if( str[x] == '#' )
         count++;
   return count;
}

variable_types:
str
char *

variable_types: count int


decompiled_code:
__int64 __fastcall is_number(_BYTE *a1)
{
char v1; // bl
__int64 result; // rax
_BYTE *v3; // rbp
char i; // al

v1 = *a1;
result = 0LL;
if ( *a1 )
{
v3 = a1;
for ( i = 1; v1 == 45 && i || ((*_ctype_b_loc())[v1] & 0x800) != 0; i = 0 )
{
v1 = *++v3;
if ( !*v3 )
return 1LL;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_BYTE *a1)
{
char v1; // bl
__int64 result; // rax
_BYTE *v3; // rbp
char i; // al

v1 = *a1;
result = 0LL;
if ( *a1 )
{
v3 = a1;
for ( i = 1; v1 == 45 && i || ((*_ctype_b_loc())[v1] & 0x800) != 0; i = 0 )
{
v1 = *++v3;
if ( !*v3 )
return 1LL;
}
result = 0LL;
}
return result;
}

original_code:
bool is_number( const char *arg )
{
   bool first = 1;
   if( *arg == '\0' )
      return 0;
   for( ; *arg != '\0'; arg++ )
   {
      if( first && *arg == '-' )
      {
         first = 0;
         continue;
      }
      if( !((*__ctype_b_loc ())[(int) ((*arg))] & (unsigned short int) _ISdigit) )
         return 0;
      first = 0;
   }
   return 1;
}

canonical_original_code:
unsigned char is_number(char *arg)
{
   unsigned char first = 1;
   if( *arg == '\0' )
      return 0;
   for( ; *arg != '\0'; arg++ )
   {
      if( first && *arg == '-' )
      {
         first = 0;
         continue;
      }
      if( !((*__ctype_b_loc ())[(int) ((*arg))] & (unsigned short) _ISdigit) )
         return 0;
      first = 0;
   }
   return 1;
}

variable_types:
arg
char *

variable_types:
first
unsigned char


decompiled_code:
const char *__fastcall unload_commands(__int64 a1, const char **a2, int a3, int a4)
{
const char **v4; // rbp
const char *result; // rax
const char **v8; // rax
__int16 *v9; // rbx
_BYTE v10[56]; // [rsp+0h] [rbp-38h] BYREF

v4 = a2;
for ( result = *a2; **v4; result = *v4 )
{
AttachIterator(v10, a1);
while ( 1 )
{
v8 = (const char **)NextInList(v10);
v9 = (__int16 *)v8;
if ( !v8 )
break;
if ( !strcmp(*v8, *v4) && v9[9] == a3 && v9[8] <= a4 )
{
DetachFromList(v9, a1);
free_command(v9);
}
}
DetachIterator(v10);
v4 += 3;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func10(__int64 a1, const char **a2, int a3, int a4)
{
const char **v4; // rbp
const char *result; // rax
const char **v8; // rax
__int16 *v9; // rbx
_BYTE v10[56]; // [rsp+0h] [rbp-38h] BYREF

v4 = a2;
for ( result = *a2; **v4; result = *v4 )
{
AttachIterator(v10, a1);
while ( 1 )
{
v8 = (const char **)NextInList(v10);
v9 = (__int16 *)v8;
if ( !v8 )
break;
if ( !strcmp(*v8, *v4) && v9[9] == a3 && v9[8] <= a4 )
{
DetachFromList(v9, a1);
func5(v9);
}
}
DetachIterator(v10);
v4 += 3;
}
return result;
}

original_code:
void unload_commands( LIST *commands, const struct typCmd to_unload[], int state, int level )
{
   COMMAND *com;
   ITERATOR Iter;
   int x;
   for( x = 0; to_unload[x].cmd_name[0] != '\0'; x++ )
   {
      AttachIterator( &Iter, commands );
      while( ( com = (COMMAND *)NextInList( &Iter ) ) != ((void *)0) )
         if( !strcmp( com->cmd_name, to_unload[x].cmd_name ) && com->state == state && com->level <= level )
         {
            DetachFromList( com, commands );
            free_command( com );
         }
      DetachIterator( &Iter );
   }
   return;
}

canonical_original_code:
void unload_commands(struct List *commands, struct typCmd to_unload[], int state, int level)
{
   struct typCmd *com;
   struct Iterator Iter;
   int x;
   for( x = 0; to_unload[x].cmd_name[0] != '\0'; x++ )
   {
      AttachIterator( &Iter, commands );
      while( ( com = (struct typCmd *)NextInList( &Iter ) ) != ((void *)0) )
         if( !strcmp( com->cmd_name, to_unload[x].cmd_name ) && com->state == state && com->level <= level )
         {
            DetachFromList( com, commands );
            free_command( com );
         }
      DetachIterator( &Iter );
   }
   return;
}

variable_types: struct typCmd { char *cmd_name; void (*cmd_funct)(void *passed, char *arg); short level; short state; } []

variable_types: state int

variable_types: level int

variable_types: struct Iterator { struct List { struct Cell { struct Cell *_pNextCell; struct Cell *_pPrevCell; void *_pContent; int _valid; } *_pFirstCell; struct Cell *_pLastCell; int _iterators; int _size; int _valid; } *_pList; struct Cell *_pCell; }

user_defined_types: struct Iterator { struct List *_pList; struct Cell *_pCell; }

user_defined_types: struct List { struct Cell *_pFirstCell; struct Cell *_pLastCell; int _iterators; int _size; int _valid; }


decompiled_code:
__int64 __fastcall clear_commands(__int64 a1)
{
__int64 v1; // rax
void *v2; // rbx
_BYTE v4[40]; // [rsp+0h] [rbp-28h] BYREF

AttachIterator(v4, a1);
while ( 1 )
{
v1 = NextInList(v4);
v2 = (void *)v1;
if ( !v1 )
break;
DetachFromList(v1, a1);
free_command(v2);
}
return DetachIterator(v4);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // rax
void *v2; // rbx
_BYTE v4[40]; // [rsp+0h] [rbp-28h] BYREF

AttachIterator(v4, a1);
while ( 1 )
{
v1 = NextInList(v4);
v2 = (void *)v1;
if ( !v1 )
break;
DetachFromList(v1, a1);
func5(v2);
}
return DetachIterator(v4);
}

original_code:
void clear_commands( LIST *commands )
{
   COMMAND *com;
   ITERATOR Iter;
   AttachIterator( &Iter, commands );
   while( ( com = (COMMAND *)NextInList( &Iter ) ) != ((void *)0) )
   {
      DetachFromList( com, commands );
      free_command( com );
   }
   DetachIterator( &Iter );
   return;
}

canonical_original_code:
void clear_commands(struct List *commands)
{
   struct typCmd *com;
   struct Iterator Iter;
   AttachIterator( &Iter, commands );
   while( ( com = (struct typCmd *)NextInList( &Iter ) ) != ((void *)0) )
   {
      DetachFromList( com, commands );
      free_command( com );
   }
   DetachIterator( &Iter );
   return;
}

variable_types: struct List { struct Cell { struct Cell *_pNextCell; struct Cell *_pPrevCell; void *_pContent; int _valid; } *_pFirstCell; struct Cell *_pLastCell; int _iterators; int _size; int _valid; } *

user_defined_types: struct typCmd { char *cmd_name; void (*cmd_funct)(void *passed, char *arg); short level; short state; }


decompiled_code:
__int64 __fastcall free_command_list(__int64 a1)
{
clear_commands(a1);
return FreeList(a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
func11(a1);
return FreeList(a1);
}

original_code:
void free_command_list( LIST *commands )
{
   clear_commands( commands );
   FreeList( commands );
}

canonical_original_code:
void free_command_list(struct List *commands)
{
   clear_commands( commands );
   FreeList( commands );
}

user_defined_types: struct Cell { struct Cell *_pNextCell; struct Cell *_pPrevCell; void *_pContent; int _valid; }


original_code:
void clear_shape( SHAPE *shape )
{
   shape->name = ((void *)0);
   shape->max_x = 0;
   shape->max_y = 0;
   shape->max_z = 0;
   return;
}

canonical_original_code:
void clear_shape(struct shape *shape)
{
   shape->name = ((void *)0);
   shape->max_x = 0;
   shape->max_y = 0;
   shape->max_z = 0;
   return;
}

variable_types: struct shape { char *name; int max_x; int max_y; int max_z; struct List { struct Cell { struct Cell *_pNextCell; struct Cell *_pPrevCell; void *_pContent; int _valid; } *_pFirstCell; struct Cell *_pLastCell; int _iterators; int _size; int _valid; } *offsets; } *

user_defined_types: struct shape { char *name; int max_x; int max_y; int max_z; struct List *offsets; }


decompiled_code:
_QWORD *init_shape()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = calloc(1uLL, 0x20uLL);
if ( !v0 )
{
perror("calloc failure");
fprintf(stderr, "Malloc failure @ %s:%d\n", "shape.c", 10LL);
abort();
}
v1 = v0;
clear_shape((__int64)v0);
v1[3] = AllocList();
return v1;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *v0; // rax
_QWORD *v1; // rbx

v0 = calloc(1uLL, 0x20uLL);
if ( !v0 )
{
perror("calloc failure");
fprintf(stderr, "Malloc failure @ %s:%d\n", "shape.c", 10LL);
abort();
}
v1 = v0;
func0((__int64)v0);
v1[3] = AllocList();
return v1;
}

original_code:
SHAPE *init_shape( void )
{
   SHAPE *shape;
   do { if (!((shape) = (SHAPE *) calloc ((1), sizeof(SHAPE)))) { perror("calloc failure"); fprintf(stderr, "Malloc failure @ %s:%d\n", "shape.c", 10 ); abort(); } } while(0);
   clear_shape( shape );
   shape->offsets = AllocList();
   return shape;
}

canonical_original_code:
struct shape *init_shape()
{
   struct shape *shape;
   do { if (!((shape) = (struct shape *) calloc ((1), sizeof(SHAPE)))) { perror("calloc failure"); fprintf(stderr, "Malloc failure @ %s:%d\n", "shape.c", 10 ); abort(); } } while(0);
   clear_shape( shape );
   shape->offsets = AllocList();
   return shape;
}

return_type: struct shape { char *name; int max_x; int max_y; int max_z; struct List { struct Cell { struct Cell *_pNextCell; struct Cell *_pPrevCell; void *_pContent; int _valid; } *_pFirstCell; struct Cell *_pLastCell; int _iterators; int _size; int _valid; } *offsets; } *


decompiled_code:
void __fastcall free_shape(void *ptr)
{
if ( *(_QWORD *)ptr )
free(ptr);
free_offset_list(*((_QWORD *)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( *(_QWORD *)ptr )
free(ptr);
free_offset_list(*((_QWORD *)ptr + 3));
free(ptr);
}

original_code:
void free_shape( SHAPE *shape )
{
   if( shape->name )
      free( shape );
   free_offset_list( shape->offsets );
   free( shape );
   return;
}

canonical_original_code:
void free_shape(struct shape *shape)
{
   if( shape->name )
      free( shape );
   free_offset_list( shape->offsets );
   free( shape );
   return;
}


decompiled_code:
__time_t __fastcall last_modified(const char *a1)
{
bool v1; // sf
__time_t result; // rax
struct stat v3; // [rsp+0h] [rbp-898h] BYREF
char s[2056]; // [rsp+90h] [rbp-808h] BYREF

snprintf(s, 0x800uLL, "../help/%s", a1);
v1 = stat(s, &v3) < 0;
result = 0LL;
if ( !v1 )
result = v3.st_mtim.tv_sec;
return result;
}

canonical_decompiled_code:
__time_t __fastcall func4(const char *a1)
{
bool v1; // sf
__time_t result; // rax
struct stat v3; // [rsp+0h] [rbp-898h] BYREF
char s[2056]; // [rsp+90h] [rbp-808h] BYREF

snprintf(s, 0x800uLL, "../help/%s", a1);
v1 = stat(s, &v3) < 0;
result = 0LL;
if ( !v1 )
result = v3.st_mtim.tv_sec;
return result;
}

original_code:
time_t last_modified(char *helpfile)
{
  char fHelp[2048];
  struct stat sBuf;
  time_t mTime = 0;
  snprintf(fHelp, 2048, "../help/%s", helpfile);
  if (stat(fHelp, &sBuf) >= 0)
    mTime = sBuf.st_mtim.tv_sec;
  return mTime;
}

canonical_original_code:
long last_modified(char *helpfile)
{
  char fHelp[2048];
  struct stat sBuf;
  long mTime = 0;
  snprintf(fHelp, 2048, "../help/%s", helpfile);
  if (stat(fHelp, &sBuf) >= 0)
    mTime = sBuf.st_mtim.tv_sec;
  return mTime;
}

variable_types:
helpfile
char *

variable_types:
fHelp
char [2048]

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: mTime long

return_type: long

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
_BOOL8 __fastcall verify_pcap(const char *a1)
{
char *v1; // rax
_BOOL4 v2; // edx

v1 = strrchr(a1, 46);
v2 = 0;
if ( v1 )
v2 = strcmp(v1 + 1, "pcap") == 0;
return v2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(const char *a1)
{
char *v1; // rax
_BOOL4 v2; // edx

v1 = strrchr(a1, 46);
v2 = 0;
if ( v1 )
v2 = strcmp(v1 + 1, "pcap") == 0;
return v2;
}

original_code:
int verify_pcap( const char *filename )
{
      char *p = strrchr(filename,'.');
      if ( p != ((void *)0))
     return ( strcmp(++p, "pcap") == 0 );
      return 0;
}

canonical_original_code:
int verify_pcap(char *filename)
{
      char *p = strrchr(filename,'.');
      if ( p != ((void *)0))
     return ( strcmp(++p, "pcap") == 0 );
      return 0;
}

variable_types:
filename
char *

variable_types:
p
char *


decompiled_code:
__int64 __fastcall ip_after_mac(__int64 a1)
{
__int16 v1; // bx
__int16 v2; // dx
__int64 result; // rax

v1 = *(_WORD *)(a1 + 12);
v2 = _bswap_16(2048);
result = 1LL;
if ( v1 != v2 )
result = 2 * (unsigned int)(v1 == _bswap_16(34525));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int16 v1; // bx
__int16 v2; // dx
__int64 result; // rax

v1 = *(_WORD *)(a1 + 12);
v2 = func0(2048);
result = 1LL;
if ( v1 != v2 )
result = 2 * (unsigned int)(v1 == func0(34525));
return result;
}

original_code:
int ip_after_mac( const u_char *packet )
{
      struct ether_header *header = (struct ether_header *)packet;
      if ( header->ether_type == ntohs(0x0800) )
     return 1;
      if ( header->ether_type == ntohs(0x86dd) )
     return 2;
      return 0;
}

canonical_original_code:
int ip_after_mac(unsigned char *packet)
{
      struct ether_header *header = (struct ether_header *)packet;
      if ( header->ether_type == ntohs(0x0800) )
     return 1;
      if ( header->ether_type == ntohs(0x86dd) )
     return 2;
      return 0;
}

variable_types:
packet
unsigned char *

variable_types: struct ether_header { unsigned char ether_dhost[6]; unsigned char ether_shost[6]; unsigned short ether_type; } *


decompiled_code:
__int64 __fastcall get_ipdaddr(__int64 a1)
{
return *(unsigned int *)(a1 + 30);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 + 30);
}

original_code:
u_int32_t get_ipdaddr( const u_char *packet )
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return header->daddr;
}

canonical_original_code:
unsigned int get_ipdaddr(unsigned char *packet)
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return header->daddr;
}

variable_types: struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; } *

return_type: unsigned int


decompiled_code:
__int64 __fastcall get_ip6daddr(__int64 a1)
{
return a1 + 38;
}

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

original_code:
uint8_t *get_ip6daddr( const u_char *packet )
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return header->ip6_dst.__in6_u.__u6_addr8;
}

canonical_original_code:
unsigned char *get_ip6daddr(unsigned char *packet)
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return header->ip6_dst.__in6_u.__u6_addr8;
}

variable_types: struct ip6_hdr { union { struct ip6_hdrctl { unsigned int ip6_un1_flow; unsigned short ip6_un1_plen; unsigned char ip6_un1_nxt; unsigned char ip6_un1_hlim; } ip6_un1; unsigned char ip6_un2_vfc; } ip6_ctlun; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } ip6_src; struct in6_addr ip6_dst; } *

return_type: unsigned char *

user_defined_types: struct ip6_hdr { union { struct ip6_hdrctl ip6_un1; unsigned char ip6_un2_vfc; } ip6_ctlun; struct in6_addr ip6_src; struct in6_addr ip6_dst; }


decompiled_code:
_BOOL8 __fastcall verify_daddr(__int64 a1, _DWORD *a2)
{
int v2; // eax
_BOOL8 result; // rax

v2 = ip_after_mac(a1);
if ( v2 == 1 )
{
result = 0LL;
if ( !*a2 )
result = a2[2] == (unsigned int)get_ipdaddr(a1);
}
else if ( v2 == 2 )
{
result = 0LL;
if ( *a2 == 1 )
result = *((_QWORD *)a2 + 1) == get_ip6daddr(a1);
}
else
{
result = 0LL;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(__int64 a1, _DWORD *a2)
{
int v2; // eax
_BOOL8 result; // rax

v2 = func3(a1);
if ( v2 == 1 )
{
result = 0LL;
if ( !*a2 )
result = a2[2] == (unsigned int)func4(a1);
}
else if ( v2 == 2 )
{
result = 0LL;
if ( *a2 == 1 )
result = *((_QWORD *)a2 + 1) == func5(a1);
}
else
{
result = 0LL;
}
return result;
}

original_code:
int verify_daddr( const u_char *packet, const wanted_ip *ipdaddr )
{
      switch (ip_after_mac(packet))
      {
      case 1:
     if (ipdaddr->t_ip != IPV4) break;
     return ( get_ipdaddr(packet) == ipdaddr->w_ip.ipv4 );
      case 2:
     if (ipdaddr->t_ip != IPV6) break;
     return ( get_ip6daddr(packet) == ipdaddr->w_ip.ipv6 );
      default:
     return 0;
      }
      return 0;
}

canonical_original_code:
int verify_daddr(unsigned char *packet, struct wanted_ip *ipdaddr)
{
      switch (ip_after_mac(packet))
      {
      case 1:
     if (ipdaddr->t_ip != IPV4) break;
     return ( get_ipdaddr(packet) == ipdaddr->w_ip.ipv4 );
      case 2:
     if (ipdaddr->t_ip != IPV6) break;
     return ( get_ip6daddr(packet) == ipdaddr->w_ip.ipv6 );
      default:
     return 0;
      }
      return 0;
}

variable_types: struct wanted_ip { enum type_ip { IPV4=0, IPV6=1 } t_ip; union { unsigned char *ipv6; unsigned int ipv4; } w_ip; } *

user_defined_types: struct wanted_ip { enum type_ip t_ip; union { unsigned char *ipv6; unsigned int ipv4; } w_ip; }


decompiled_code:
_BOOL8 __fastcall tcp_after_ip(__int64 a1)
{
return *(_BYTE *)(a1 + 23) == 6;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(__int64 a1)
{
return *(_BYTE *)(a1 + 23) == 6;
}

original_code:
int tcp_after_ip( const u_char *packet )
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return ( header->protocol == 0x06 );
}

canonical_original_code:
int tcp_after_ip(unsigned char *packet)
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return ( header->protocol == 0x06 );
}

user_defined_types: struct iphdr { unsigned int ihl; unsigned int version; unsigned char tos; unsigned short tot_len; unsigned short id; unsigned short frag_off; unsigned char ttl; unsigned char protocol; unsigned short check; unsigned int saddr; unsigned int daddr; }


decompiled_code:
_BOOL8 __fastcall tcp_after_ipv6(__int64 a1)
{
return *(_BYTE *)(a1 + 20) == 6;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int64 a1)
{
return *(_BYTE *)(a1 + 20) == 6;
}

original_code:
int tcp_after_ipv6( const u_char *packet )
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return ( header->ip6_ctlun.ip6_un1.ip6_un1_nxt == 0x06 );
}

canonical_original_code:
int tcp_after_ipv6(unsigned char *packet)
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return ( header->ip6_ctlun.ip6_un1.ip6_un1_nxt == 0x06 );
}

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }

user_defined_types: struct ip6_hdrctl { unsigned int ip6_un1_flow; unsigned short ip6_un1_plen; unsigned char ip6_un1_nxt; unsigned char ip6_un1_hlim; }


decompiled_code:
__int64 __fastcall get_ip6_plen(__int64 a1)
{
return *(unsigned __int16 *)(a1 + 18);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned __int16 *)(a1 + 18);
}

original_code:
uint16_t get_ip6_plen( const u_char *packet )
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return header->ip6_ctlun.ip6_un1.ip6_un1_plen;
}

canonical_original_code:
unsigned short get_ip6_plen(unsigned char *packet)
{
      struct ip6_hdr *header = (struct ip6_hdr *)(packet + 14);
      return header->ip6_ctlun.ip6_un1.ip6_un1_plen;
}

return_type: unsigned short


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

LOWORD(v1) = _bswap_16(*(_WORD *)(a1 + 16));
return v1 - 4 * (*(_BYTE *)(a1 + 14) & 0xFu);
}

original_code:
uint16_t get_ip_plen( const u_char *packet )
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return (ntohs(header->tot_len) - 4*(header->ihl));
}

canonical_original_code:
unsigned short get_ip_plen(unsigned char *packet)
{
      struct iphdr *header = (struct iphdr *)(packet + 14);
      return (ntohs(header->tot_len) - 4*(header->ihl));
}


decompiled_code:
__int64 __fastcall valid_packet(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // ebx

v1 = ip_after_mac(a1);
v2 = v1;
if ( v1 == 1 )
{
if ( tcp_after_ip(a1) )
return v2;
}
else if ( v1 != 2 )
{
return 0;
}
v2 = tcp_after_ipv6(a1);
if ( v2 )
v2 = 2;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // ebx

v1 = func3(a1);
v2 = v1;
if ( v1 == 1 )
{
if ( func7(a1) )
return v2;
}
else if ( v1 != 2 )
{
return 0;
}
v2 = func8(a1);
if ( v2 )
v2 = 2;
return v2;
}

original_code:
int valid_packet( const u_char *packet )
{
      switch (ip_after_mac(packet))
      {
      case 1:
     if (tcp_after_ip(packet)) return 1;
      case 2:
     if (tcp_after_ipv6(packet)) return 2;
      default:
     return 0;
      }
}

canonical_original_code:
int valid_packet(unsigned char *packet)
{
      switch (ip_after_mac(packet))
      {
      case 1:
     if (tcp_after_ip(packet)) return 1;
      case 2:
     if (tcp_after_ipv6(packet)) return 2;
      default:
     return 0;
      }
}


decompiled_code:
__int64 __fastcall get_tcphdr(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx

v1 = valid_packet(a1);
if ( !v1 )
return 0LL;
v2 = 20LL;
if ( v1 != 1 )
{
v2 = 0LL;
if ( v1 == 2 )
v2 = 40LL;
}
return a1 + v2 + 14;
}

original_code:
struct tcphdr *get_tcphdr( const u_char *packet )
{
      size_t ip_hdr = 0;
      int valid = valid_packet(packet);
      if (!valid)
     return ((void *)0);
      if (valid == 1)
     ip_hdr = 0x14;
      if (valid == 2)
     ip_hdr = 0x28;
      return (struct tcphdr *)(packet + (14 + ip_hdr));
}

canonical_original_code:
struct tcphdr *get_tcphdr(unsigned char *packet)
{
      unsigned long ip_hdr = 0;
      int valid = valid_packet(packet);
      if (!valid)
     return ((void *)0);
      if (valid == 1)
     ip_hdr = 0x14;
      if (valid == 2)
     ip_hdr = 0x28;
      return (struct tcphdr *)(packet + (14 + ip_hdr));
}

variable_types: valid int

return_type: struct tcphdr { union { struct { unsigned short th_sport; unsigned short th_dport; unsigned int th_seq; unsigned int th_ack; unsigned char th_x2; unsigned char th_off; unsigned char th_flags; unsigned short th_win; unsigned short th_sum; unsigned short th_urp; }; struct { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short doff; unsigned short fin; unsigned short syn; unsigned short rst; unsigned short psh; unsigned short ack; unsigned short urg; unsigned short res2; unsigned short window; unsigned short check; unsigned short urg_ptr; }; }; } *


decompiled_code:
__int64 __fastcall fix_ipdaddr(__int64 a1, _DWORD *a2)
{
unsigned int v2; // ebp
unsigned int v4; // eax

v2 = 0;
if ( (*(_BYTE *)(get_tcphdr(a1) + 13) & 0x12) == 18 )
{
v4 = ip_after_mac(a1);
v2 = v4;
if ( v4 == 1 )
{
*a2 = 0;
a2[2] = get_ipdaddr(a1);
}
else if ( v4 == 2 )
{
*a2 = 1;
*((_QWORD *)a2 + 1) = get_ip6daddr(a1);
v2 = 1;
}
else
{
v2 = 0;
}
}
return v2;
}

original_code:
int fix_ipdaddr( const u_char *packet, wanted_ip *ipdaddr )
{
      struct tcphdr *tcphdr = get_tcphdr(packet);
      if ( (tcphdr->th_flags & (0x02 | 0x10)) == (0x02 | 0x10) )
      {
     switch(ip_after_mac(packet))
     {
     case 1:
    ipdaddr->t_ip = IPV4;
    ipdaddr->w_ip.ipv4 = get_ipdaddr(packet);
    return 1;
     case 2:
    ipdaddr->t_ip = IPV6;
    ipdaddr->w_ip.ipv6 = get_ip6daddr(packet);
    return 1;
     default:
    return 0;
     }
      }
      return 0;
}

canonical_original_code:
int fix_ipdaddr(unsigned char *packet, struct wanted_ip *ipdaddr)
{
      struct tcphdr *tcphdr = get_tcphdr(packet);
      if ( (tcphdr->th_flags & (0x02 | 0x10)) == (0x02 | 0x10) )
      {
     switch(ip_after_mac(packet))
     {
     case 1:
    ipdaddr->t_ip = IPV4;
    ipdaddr->w_ip.ipv4 = get_ipdaddr(packet);
    return 1;
     case 2:
    ipdaddr->t_ip = IPV6;
    ipdaddr->w_ip.ipv6 = get_ip6daddr(packet);
    return 1;
     default:
    return 0;
     }
      }
      return 0;
}

variable_types: struct tcphdr { union { struct { unsigned short th_sport; unsigned short th_dport; unsigned int th_seq; unsigned int th_ack; unsigned char th_x2; unsigned char th_off; unsigned char th_flags; unsigned short th_win; unsigned short th_sum; unsigned short th_urp; }; struct { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short doff; unsigned short fin; unsigned short syn; unsigned short rst; unsigned short psh; unsigned short ack; unsigned short urg; unsigned short res2; unsigned short window; unsigned short check; unsigned short urg_ptr; }; }; } *


decompiled_code:
__int64 __fastcall get_sequence_number(__int64 a1)
{
return (unsigned int)_bswap_32(*(_DWORD *)(a1 + 4));
}

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

original_code:
long get_sequence_number( const struct tcphdr *header )
{
      return htonl(header->th_seq);
}

canonical_original_code:
long get_sequence_number(struct tcphdr *header)
{
      return htonl(header->th_seq);
}

user_defined_types: struct tcphdr { union { struct { unsigned short th_sport; unsigned short th_dport; unsigned int th_seq; unsigned int th_ack; unsigned char th_x2; unsigned char th_off; unsigned char th_flags; unsigned short th_win; unsigned short th_sum; unsigned short th_urp; }; struct { unsigned short source; unsigned short dest; unsigned int seq; unsigned int ack_seq; unsigned short res1; unsigned short doff; unsigned short fin; unsigned short syn; unsigned short rst; unsigned short psh; unsigned short ack; unsigned short urg; unsigned short res2; unsigned short window; unsigned short check; unsigned short urg_ptr; }; }; }


decompiled_code:
__int64 __fastcall get_payload_lgt(__int64 a1, __int64 a2)
{
char v2; // bl
int v3; // eax
unsigned __int16 v5; // ax
__int16 v6; // ax

v2 = *(_BYTE *)(a2 + 12) >> 4;
v3 = ip_after_mac(a1);
if ( v3 == 1 )
{
v5 = get_ip_plen(a1);
}
else
{
if ( v3 != 2 )
return 0xFFFFFFFFLL;
v6 = get_ip6_plen(a1);
v5 = _bswap_16(v6);
}
return v5 - (unsigned int)(unsigned __int8)(4 * v2);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
char v2; // bl
int v3; // eax
unsigned __int16 v5; // ax
__int16 v6; // ax

v2 = *(_BYTE *)(a2 + 12) >> 4;
v3 = func3(a1);
if ( v3 == 1 )
{
v5 = func10(a1);
}
else
{
if ( v3 != 2 )
return 0xFFFFFFFFLL;
v6 = func9(a1);
v5 = func0(v6);
}
return v5 - (unsigned int)(unsigned __int8)(4 * v2);
}

original_code:
int get_payload_lgt( const u_char *packet , const struct tcphdr *tcph )
{
      u_int8_t offset = tcph->th_off * 4;
      u_int16_t plen;
      switch (ip_after_mac(packet))
      {
      case 1:
     plen = get_ip_plen(packet);
     break;
      case 2:
     plen = htons(get_ip6_plen(packet));
     break;
      default:
     return -1;
      }
      return (plen - offset);
}

canonical_original_code:
int get_payload_lgt(unsigned char *packet, struct tcphdr *tcph)
{
      unsigned int offset = tcph->th_off * 4;
      unsigned int plen;
      switch (ip_after_mac(packet))
      {
      case 1:
     plen = get_ip_plen(packet);
     break;
      case 2:
     plen = htons(get_ip6_plen(packet));
     break;
      default:
     return -1;
      }
      return (plen - offset);
}

variable_types:
offset
unsigned int

variable_types:
plen
unsigned int


decompiled_code:
__int64 __fastcall get_next_sequence_number(__int64 a1, __int64 a2)
{
__int64 v2; // rbp

v2 = get_sequence_number(a2);
return v2 + (int)get_payload_lgt(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2)
{
__int64 v2; // rbp

v2 = func14(a2);
return v2 + (int)func15(a1, a2);
}

original_code:
long get_next_sequence_number( const u_char *packet , const struct tcphdr *tcph )
{
      return get_sequence_number(tcph)+ get_payload_lgt( packet, tcph);
}

canonical_original_code:
long get_next_sequence_number(unsigned char *packet, struct tcphdr *tcph)
{
      return get_sequence_number(tcph)+ get_payload_lgt( packet, tcph);
}


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

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

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

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

original_code:
packet_late *init_late()
{
      packet_late *begin = malloc(sizeof(packet_late));
      begin->p_sequence = 0;
      begin->expected = 0;
      begin->next = ((void *)0);
      return begin;
}

canonical_original_code:
struct packet_late *init_late()
{
      struct packet_late *begin = malloc(sizeof(packet_late));
      begin->p_sequence = 0;
      begin->expected = 0;
      begin->next = ((void *)0);
      return begin;
}

variable_types: struct packet_late { long p_sequence; long expected; struct packet_late *next; } *


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

while ( 1 )
{
v2 = a1;
a1 = (_QWORD *)a1[2];
if ( !a1 )
break;
if ( *a1 == a2 )
{
v2[2] = a1[2];
free(a1);
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

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

while ( 1 )
{
v2 = a1;
a1 = (_QWORD *)a1[2];
if ( !a1 )
break;
if ( *a1 == a2 )
{
v2[2] = a1[2];
free(a1);
return 0LL;
}
}
return 0xFFFFFFFFLL;
}

original_code:
int free_first( packet_late *begin, long seq )
{
      packet_late *tmp;
      for( ;
    begin->next != ((void *)0) && begin->next->p_sequence != seq;
    begin = begin->next);
      if (begin->next == ((void *)0))
     return -1;
      tmp = begin->next;
      begin->next = begin->next->next;
      free(tmp);
      return 0;
}

canonical_original_code:
int free_first(struct packet_late *begin, long seq)
{
      struct packet_late *tmp;
      for( ;
    begin->next != ((void *)0) && begin->next->p_sequence != seq;
    begin = begin->next);
      if (begin->next == ((void *)0))
     return -1;
      tmp = begin->next;
      begin->next = begin->next->next;
      free(tmp);
      return 0;
}

variable_types: seq long

user_defined_types: struct packet_late { long p_sequence; long expected; struct packet_late *next; }


decompiled_code:
__int64 __fastcall free_all_packet_late(void *ptr)
{
_QWORD *v1; // rbx

if ( !ptr )
return 1LL;
v1 = (_QWORD *)*((_QWORD *)ptr + 2);
if ( v1 )
{
while ( 1 )
{
free(ptr);
ptr = v1;
if ( !v1[2] )
break;
v1 = (_QWORD *)v1[2];
}
}
else
{
v1 = ptr;
}
free(v1);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func20(void *ptr)
{
_QWORD *v1; // rbx

if ( !ptr )
return 1LL;
v1 = (_QWORD *)*((_QWORD *)ptr + 2);
if ( v1 )
{
while ( 1 )
{
free(ptr);
ptr = v1;
if ( !v1[2] )
break;
v1 = (_QWORD *)v1[2];
}
}
else
{
v1 = ptr;
}
free(v1);
return 0xFFFFFFFFLL;
}

original_code:
int free_all_packet_late( packet_late *begin )
{
      packet_late *tmp;
      if (begin == ((void *)0))
     return 1;
      while ( begin->next != ((void *)0) )
      {
     tmp = begin;
     begin = begin->next;
     free(tmp);
      }
      free(begin);
      if ( begin != ((void *)0) ){
     return -1;
      }
      return 1;
}

canonical_original_code:
int free_all_packet_late(struct packet_late *begin)
{
      struct packet_late *tmp;
      if (begin == ((void *)0))
     return 1;
      while ( begin->next != ((void *)0) )
      {
     tmp = begin;
     begin = begin->next;
     free(tmp);
      }
      free(begin);
      if ( begin != ((void *)0) ){
     return -1;
      }
      return 1;
}


repo: mabalew/Budget

decompiled_code:
__int64 __fastcall is_add_string(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "a") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = (const char *)&unk_26F;
v3 = 4LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "a") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = (const char *)&unk_26F;
v3 = 4LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

original_code:
_Bool is_add_string(char *s) {
 if (strcmp(s, "a") == 0 || strcmp(s, "add") == 0) {
  return 1;
 }
 return 0;
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall is_update_string(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "u") )
{
v3 = strcmp(a1, "upd") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "update";
v2 = 7LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "u") )
{
v3 = strcmp(a1, "upd") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "update";
v2 = 7LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

original_code:
_Bool is_update_string(char *s) {
 if (strcmp(s, "u") == 0 || strcmp(s, "upd") == 0 || strcmp(s, "update") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall is_delete_string(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "d") )
{
v3 = strcmp(a1, "del") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "delete";
v2 = 7LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "d") )
{
v3 = strcmp(a1, "del") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "delete";
v2 = 7LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

original_code:
_Bool is_delete_string(char *s) {
 if (strcmp(s, "d") == 0 || strcmp(s, "del") == 0 || strcmp(s, "delete") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall is_login_string(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "lo") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "login";
v3 = 6LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "lo") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "login";
v3 = 6LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

original_code:
_Bool is_login_string(char *s) {
 if (strcmp(s, "lo") == 0 || strcmp(s, "login") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall is_list_string(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "l") )
{
v3 = strcmp(a1, "ls") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "list";
v2 = 5LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
__int64 v2; // rcx
bool v3; // dl
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

LODWORD(v2) = 1;
if ( strcmp(a1, "l") )
{
v3 = strcmp(a1, "ls") != 0;
LODWORD(v2) = 1;
v4 = 0;
v5 = !v3;
if ( v3 )
{
v6 = "list";
v2 = 5LL;
v7 = a1;
do
{
if ( !v2 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v2;
}
while ( v5 );
LOBYTE(v2) = (!v4 && !v5) == v4;
}
}
return (unsigned int)v2;
}

original_code:
_Bool is_list_string(char *s) {
 if (strcmp(s, "l") == 0 || strcmp(s, "ls") == 0 || strcmp(s, "list") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
bool __fastcall is_list_products_in_category_string(const char *a1)
{
return strcmp(a1, "lc") == 0;
}

canonical_decompiled_code:
bool __fastcall func5(const char *a1)
{
return strcmp(a1, "lc") == 0;
}

original_code:
_Bool is_list_products_in_category_string(char *s) {
 if (strcmp(s, "lc") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall is_get_by_id_string(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "gid") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "getbyid";
v3 = 8LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "gid") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "getbyid";
v3 = 8LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

original_code:
_Bool is_get_by_id_string(char *s) {
 if (strcmp(s, "gid") == 0 || strcmp(s, "getbyid") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
__int64 __fastcall is_get_by_login_string(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "gl") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "getbylogin";
v3 = 11LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
bool v2; // dl
__int64 v3; // rcx
bool v4; // cf
bool v5; // zf
const char *v6; // rdi
const char *v7; // rsi

v2 = strcmp(a1, "gl") != 0;
LODWORD(v3) = 1;
v4 = 0;
v5 = !v2;
if ( v2 )
{
v6 = "getbylogin";
v3 = 11LL;
v7 = a1;
do
{
if ( !v3 )
break;
v4 = *v7 < (unsigned int)*v6;
v5 = *v7++ == *v6++;
--v3;
}
while ( v5 );
LOBYTE(v3) = (!v4 && !v5) == v4;
}
return (unsigned int)v3;
}

original_code:
_Bool is_get_by_login_string(char *s) {
 if (strcmp(s, "gl") == 0 || strcmp(s, "getbylogin") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
bool __fastcall is_add_to_category_string(const char *a1)
{
return strcmp(a1, "atc") == 0;
}

canonical_decompiled_code:
bool __fastcall func8(const char *a1)
{
return strcmp(a1, "atc") == 0;
}

original_code:
_Bool is_add_to_category_string(char *s) {
 if (strcmp(s, "atc") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
bool __fastcall is_help_string(const char *a1)
{
return strcmp(a1, "help") == 0;
}

canonical_decompiled_code:
bool __fastcall func9(const char *a1)
{
return strcmp(a1, "help") == 0;
}

original_code:
_Bool is_help_string(char *s) {
 if (strcmp(s, "help") == 0) {
  return 1;
 }
 return 0;
}


decompiled_code:
// attributes: thunk
bool __fastcall is_help_for_expense_module(const char *a1)
{
return is_help_string(a1);
}

canonical_decompiled_code:
bool __fastcall func10(const char *a1)
{
return func9(a1);
}

original_code:
_Bool is_help_for_expense_module(char *s) {
 return is_help_string(s);
}


decompiled_code:
// attributes: thunk
bool __fastcall is_help_for_user_module(const char *a1)
{
return is_help_string(a1);
}

canonical_decompiled_code:
bool __fastcall func11(const char *a1)
{
return func9(a1);
}

original_code:
_Bool is_help_for_user_module(char *s) {
 return is_help_string(s);
}


decompiled_code:
// attributes: thunk
bool __fastcall is_help_for_category_module(const char *a1)
{
return is_help_string(a1);
}

canonical_decompiled_code:
bool __fastcall func12(const char *a1)
{
return func9(a1);
}

original_code:
_Bool is_help_for_category_module(char *s) {
 return is_help_string(s);
}


decompiled_code:
// attributes: thunk
bool __fastcall is_help_for_shop_module(const char *a1)
{
return is_help_string(a1);
}

canonical_decompiled_code:
bool __fastcall func13(const char *a1)
{
return func9(a1);
}

original_code:
_Bool is_help_for_shop_module(char *s) {
 return is_help_string(s);
}


decompiled_code:
__int64 __fastcall _add_category(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(8uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = add_category(v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(8uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = func2(v2);
free(v2);
return v3;
}

original_code:
int _add_category(char *name) {
 char *args[4] = {"","","",name};
 return __add_category(4, args);
}

variable_types:
name
char *

variable_types:
args
char *[4]


decompiled_code:
__int64 __fastcall _del_category(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(8uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = del_category(v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(8uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = func4(v2);
free(v2);
return v3;
}

original_code:
int _del_category(char *name) {
 char *args[4] = {"","","",name};
 return __del_category(4, args);
}


decompiled_code:
void __fastcall free_category_list(void **a1, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(*((void **)*v2 + 1));
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func5(void **a1, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(*((void **)*v2 + 1));
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void free_category_list(Category *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

canonical_original_code:
void free_category_list(struct category *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

variable_types: struct category { int id; char *name; } *[]

variable_types: size int

variable_types: counter int


decompiled_code:
__int64 __fastcall manage_category(unsigned int a1, __int64 a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return _update_category(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return _add_category(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return _del_category(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return _list_categories();
if ( (unsigned __int8)is_help_for_category_module(*(_QWORD *)(a2 + 16)) )
_show_help_for_category_module();
else
_show_common_help();
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, __int64 a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return _update_category(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return func1(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return func3(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return func6();
if ( (unsigned __int8)is_help_for_category_module(*(_QWORD *)(a2 + 16)) )
_show_help_for_category_module();
else
_show_common_help();
return 0xFFFFFFFFLL;
}

original_code:
int manage_category(int argc, char *argv[]) {
 if (argc == 2) {
  __show_common_help();
 }
 if (is_update_string(argv[2])) {
  return __update_category(argc, argv);
 } else if (is_add_string(argv[2])) {
  return __add_category(argc, argv);
 } else if (is_delete_string(argv[2])) {
  return __del_category(argc, argv);
 } else if (is_list_string(argv[2])) {
  return __list_categories();
 } else if (is_help_for_category_module(argv[2])) {
  __show_help_for_category_module();
 } else {
  __show_common_help();
 }
 return -1;
}

variable_types: argc int

variable_types:
argv
char *[]


original_code:
void free_expense_list(Expense *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->exp_date);
  free(list[counter]->product);
  free(list[counter]->category);
  free(list[counter]->shop);
  free(list[counter]);
 }
}

canonical_original_code:
void free_expense_list(struct expense *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->exp_date);
  free(list[counter]->product);
  free(list[counter]->category);
  free(list[counter]->shop);
  free(list[counter]);
 }
}

variable_types: struct expense { int id; char *exp_date; int category_id; char *category; int product_id; char *product; int shop_id; char *shop; float unit_price; int count; float amount; float price; } *[]


decompiled_code:
int __fastcall print_expense(const char **a1)
{
printf("\tdata: %s sklep: %s\n", a1[1], a1[7]);
printf(aZakupNr6dNaKwo, *(unsigned int *)a1, *((float *)a1 + 19), *((float *)a1 + 18), *((float *)a1 + 16));
printf("\tprodukt: %s z kategorii '%s' [%d]\n", a1[5], a1[3], *((unsigned int *)a1 + 4));
return puts("----------------------------------");
}

canonical_decompiled_code:
int __fastcall func4(const char **a1)
{
printf("\tdata: %s sklep: %s\n", a1[1], a1[7]);
printf(aZakupNr6dNaKwo, *(unsigned int *)a1, *((float *)a1 + 19), *((float *)a1 + 18), *((float *)a1 + 16));
printf("\tprodukt: %s z kategorii '%s' [%d]\n", a1[5], a1[3], *((unsigned int *)a1 + 4));
return puts("----------------------------------");
}

original_code:
void print_expense(Expense *e) {
 printf("\tdata: %s sklep: %s\n", e->exp_date, e->shop);
 printf("\tzakup nr. %.6d na kwotę %.2f / ilość  %.2f / cena jedn. %.2f\n", e->id, e->price, e->amount, e->unit_price);
 printf("\tprodukt: %s z kategorii '%s' [%d]\n", e->product, e->category, e->category_id);
 puts("----------------------------------");
}

canonical_original_code:
void print_expense(struct expense *e) {
 printf("\tdata: %s sklep: %s\n", e->exp_date, e->shop);
 printf("\tzakup nr. %.6d na kwotę %.2f / ilość  %.2f / cena jedn. %.2f\n", e->id, e->price, e->amount, e->unit_price);
 printf("\tprodukt: %s z kategorii '%s' [%d]\n", e->product, e->category, e->category_id);
 puts("----------------------------------");
}

variable_types: struct expense { int id; char *exp_date; int category_id; char *category; int product_id; char *product; int shop_id; char *shop; float unit_price; int count; float amount; float price; } *


decompiled_code:
__int64 __fastcall manage_expense(unsigned int a1, _QWORD *a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(a2[2]) )
return _update_expense(a1, (__int64)a2);
if ( (unsigned __int8)is_add_string(a2[2]) )
return _add_expense(a1, (__int64)a2);
if ( (unsigned __int8)is_delete_string(a2[2]) )
return _del_expense(a1, (__int64)a2);
if ( (unsigned __int8)is_list_string(a2[2]) )
return _list_expenses(a2[3], a2[4]);
if ( (unsigned __int8)is_help_for_expense_module(a2[2]) )
_show_help_for_expense_module();
else
_show_common_help();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, _QWORD *a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(a2[2]) )
return func0(a1, (__int64)a2);
if ( (unsigned __int8)is_add_string(a2[2]) )
return func1(a1, (__int64)a2);
if ( (unsigned __int8)is_delete_string(a2[2]) )
return func2(a1, (__int64)a2);
if ( (unsigned __int8)is_list_string(a2[2]) )
return func5(a2[3], a2[4]);
if ( (unsigned __int8)is_help_for_expense_module(a2[2]) )
_show_help_for_expense_module();
else
_show_common_help();
return 0LL;
}

original_code:
int manage_expense(int argc, char *argv[]) {
 if (argc == 2) {
  __show_common_help();
 }
 if (is_update_string(argv[2])) {
  return __update_expense(argc, argv);
 } else if (is_add_string(argv[2])) {
  return __add_expense(argc, argv);
 } else if (is_delete_string(argv[2])) {
  return __del_expense(argc, argv);
 } else if (is_list_string(argv[2])) {
  return __list_expenses(argv[3], argv[4]);
 } else if (is_help_for_expense_module(argv[2])) {
  __show_help_for_expense_module();
 } else {
  __show_common_help();
 }
 return 0;
}


decompiled_code:
__int64 __fastcall _update_shop(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
unsigned int v4; // er12

verify_number_of_parameters(a1, 5LL);
v2 = malloc(0x10uLL);
v3 = malloc(0x10uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3[1] = *(_QWORD *)(a2 + 32);
v4 = update_shop(v2, v3);
free(v2);
free(v3);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
unsigned int v4; // er12

verify_number_of_parameters(a1, 5LL);
v2 = malloc(0x10uLL);
v3 = malloc(0x10uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3[1] = *(_QWORD *)(a2 + 32);
v4 = func2(v2, v3);
free(v2);
free(v3);
return v4;
}

original_code:
int _update_shop(char *old_name, char *new_name) {
 char *args[5] = {"","","",old_name,new_name};
 return __update_shop(5, args);
}

variable_types:
args
char *[5]


decompiled_code:
__int64 __fastcall _add_shop(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(8uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = add_shop(v2);
free(v2);
return v3;
}

original_code:
int _add_shop(char *name) {
 char *args[4] = {"","","",name};
 return __add_shop(4, args);
}


decompiled_code:
__int64 __fastcall _del_shop(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(0x10uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = del_shop(v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(0x10uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = func6(v2);
free(v2);
return v3;
}

original_code:
int _del_shop(char *name) {
 char *args[4] = {"","","",name};
 return __del_shop(4, args);
}


decompiled_code:
void __fastcall free_shop_list(void **a1, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(*((void **)*v2 + 1));
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func7(void **a1, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(*((void **)*v2 + 1));
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void free_shop_list(Shop *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

canonical_original_code:
void free_shop_list(struct shop *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

variable_types:
list
struct shop { int id; char *name; } *[]


decompiled_code:
__int64 __fastcall manage_shop(unsigned int a1, __int64 a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return _update_shop(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return _add_shop(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return _del_shop(a1, a2);
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return _update_shop(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return _list_shops();
if ( (unsigned __int8)is_help_for_shop_module(*(_QWORD *)(a2 + 16)) )
_show_help_for_shop_module();
else
_show_common_help();
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, __int64 a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return func1(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return func3(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return func5(a1, a2);
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return func1(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return func8();
if ( (unsigned __int8)is_help_for_shop_module(*(_QWORD *)(a2 + 16)) )
func0();
else
_show_common_help();
return 0LL;
}

original_code:
int manage_shop(int argc, char *argv[]) {
 if (argc == 2) {
  __show_common_help();
 }
 if (is_update_string(argv[2])) {
  return __update_shop(argc, argv);
 } else if (is_add_string(argv[2])) {
  return __add_shop(argc, argv);
 } else if (is_delete_string(argv[2])) {
  return __del_shop(argc, argv);
 } else if (is_update_string(argv[2])) {
  return __update_shop(argc, argv);
 } else if (is_list_string(argv[2])) {
  return __list_shops();
 } else if (is_help_for_shop_module(argv[2])) {
  __show_help_for_shop_module();
 } else {
  __show_common_help();
 }
 return 0;
}


decompiled_code:
void __fastcall free_rows_list(void ***a1, int a2)
{
void ***v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(**v2);
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func0(void ***a1, int a2)
{
void ***v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(**v2);
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void free_rows_list(Row **rows, int count) {
 int i = 0;
 for (i = 0; i < count; i++) {
  free(rows[i]->category);
  free(rows[i]);
 }
}

canonical_original_code:
void free_rows_list(struct report_row **rows, int count) {
 int i = 0;
 for (i = 0; i < count; i++) {
  free(rows[i]->category);
  free(rows[i]);
 }
}

variable_types: struct report_row { char *category; double value; } **

variable_types: count int

variable_types: i int


original_code:
void free_expense_list2(Expense **e, int count) {
 int i = 0;
 for (i = 0; i < count; i++) {
  free(e[i]->exp_date);
  free(e[i]->category);
  free(e[i]->product);
  free(e[i]->shop);
  free(e[i]);
 }
}

canonical_original_code:
void free_expense_list2(struct expense **e, int count) {
 int i = 0;
 for (i = 0; i < count; i++) {
  free(e[i]->exp_date);
  free(e[i]->category);
  free(e[i]->product);
  free(e[i]->shop);
  free(e[i]);
 }
}

variable_types: struct expense { int id; char *exp_date; int category_id; char *category; int product_id; char *product; int shop_id; char *shop; float unit_price; int count; float amount; float price; } **


variable_types: total double

user_defined_types: struct report_row { char *category; double value; }


decompiled_code:
_BOOL8 __fastcall is_two_digit_number(int a1)
{
bool v1; // al

v1 = 1;
if ( (unsigned int)(a1 - 10) > 0x59 )
v1 = (unsigned int)(a1 + 99) <= 0x59;
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(int a1)
{
bool v1; // al

v1 = 1;
if ( (unsigned int)(a1 - 10) > 0x59 )
v1 = (unsigned int)(a1 + 99) <= 0x59;
return v1;
}

original_code:
_Bool is_two_digit_number(int number) {
 return ((number >= 10 && number < 100) || (number <= -10 && number > -100));
}

variable_types: number int


decompiled_code:
__int64 __fastcall fetch_monthly_report(const char *a1, const char *a2, char ***a3)
{
if ( (unsigned int)(atoi(a2) - 1) > 0xB )
{
printf(aErrorNiepopraw);
exit(0);
}
return get_monthly_expenses(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func6(const char *a1, const char *a2, char ***a3)
{
if ( (unsigned int)(atoi(a2) - 1) > 0xB )
{
printf(aErrorNiepopraw);
exit(0);
}
return func5(a1, a2, a3);
}

original_code:
void fetch_monthly_report(char *year, char *month, Row **rows) {
 if (atoi(month) < 1 || atoi(month) > 12) {
  printf("ERROR: niepoprawny miesiąc. Miesiąc musi zawierać się w przedziale od 1 do 12.");
  exit(0);
 }
 get_monthly_expenses(year, month, rows);
}

canonical_original_code:
void fetch_monthly_report(char *year, char *month, struct report_row **rows) {
 if (atoi(month) < 1 || atoi(month) > 12) {
  printf("ERROR: niepoprawny miesiąc. Miesiąc musi zawierać się w przedziale od 1 do 12.");
  exit(0);
 }
 get_monthly_expenses(year, month, rows);
}

variable_types:
year
char *

variable_types:
month
char *


decompiled_code:
void __fastcall get_exp_from(const char **a1, __int64 a2)
{
const char *v2; // r12
size_t v3; // r15
const char *v4; // rbp
size_t v5; // r14
const char *v6; // rbx
size_t v7; // rax
char *v8; // r14
int v9; // eax
char *v10; // r15
int v11; // eax
char *v12; // r15

v2 = *a1;
v3 = strlen(*a1);
v4 = a1[1];
v5 = strlen(v4);
v6 = a1[2];
v7 = strlen(v6);
v8 = (char *)malloc(v7 + v3 + v5 + 3);
if ( strlen(v4) == 1 )
{
v9 = atoi(v4);
if ( !is_two_digit_number(v9) )
{
v10 = (char *)malloc(1uLL);
sprintf(v10, "%s%s", "0", v4);
free(v10);
v4 = v10;
}
}
if ( strlen(v6) == 1 )
{
v11 = atoi(v6);
if ( !is_two_digit_number(v11) )
{
v12 = (char *)malloc(1uLL);
sprintf(v12, "%s%s", "0", v6);
free(v12);
v6 = v12;
}
}
sprintf(v8, "%s-%s-%s", v2, v4, v6);
get_expenses(v2, v4, a2);
free(v8);
}

canonical_decompiled_code:
void __fastcall func11(const char **a1, __int64 a2)
{
const char *v2; // r12
size_t v3; // r15
const char *v4; // rbp
size_t v5; // r14
const char *v6; // rbx
size_t v7; // rax
char *v8; // r14
int v9; // eax
char *v10; // r15
int v11; // eax
char *v12; // r15

v2 = *a1;
v3 = strlen(*a1);
v4 = a1[1];
v5 = strlen(v4);
v6 = a1[2];
v7 = strlen(v6);
v8 = (char *)malloc(v7 + v3 + v5 + 3);
if ( strlen(v4) == 1 )
{
v9 = atoi(v4);
if ( !func3(v9) )
{
v10 = (char *)malloc(1uLL);
sprintf(v10, "%s%s", "0", v4);
free(v10);
v4 = v10;
}
}
if ( strlen(v6) == 1 )
{
v11 = atoi(v6);
if ( !func3(v11) )
{
v12 = (char *)malloc(1uLL);
sprintf(v12, "%s%s", "0", v6);
free(v12);
v6 = v12;
}
}
sprintf(v8, "%s-%s-%s", v2, v4, v6);
get_expenses(v2, v4, a2);
free(v8);
}

original_code:
void get_exp_from(char *argv[], Expense **list) {
 char *date = malloc(sizeof(char) * (strlen(argv[0]) + strlen(argv[1]) + strlen(argv[2])) + 3);
 char *year = argv[0];
 char *month= argv[1];
 char *day = argv[2];
 if (strlen(month) == 1 && !is_two_digit_number(atoi(month))) {
  char *tmp = malloc(sizeof(char));
  sprintf(tmp, "%s%s", "0", month);
  month = tmp;
  free(tmp);
 }
 if (strlen(day) == 1 && !is_two_digit_number(atoi(day))) {
  char *tmp = malloc(sizeof(char));
  sprintf(tmp, "%s%s", "0", day);
  day = tmp;
  free(tmp);
 }
 sprintf(date, "%s-%s-%s", year, month, day);
 Expense *e = malloc(sizeof(Expense));
 e->exp_date = date;
 get_expenses(year, month, list);
 free(date);
 free(e);
}

canonical_original_code:
void get_exp_from(char *argv[], struct expense **list) {
 char *date = malloc(sizeof(char) * (strlen(argv[0]) + strlen(argv[1]) + strlen(argv[2])) + 3);
 char *year = argv[0];
 char *month = argv[1];
 char *day = argv[2];
 if (strlen(month) == 1 && !is_two_digit_number(atoi(month))) {
  char *tmp = malloc(sizeof(char));
  sprintf(tmp, "%s%s", "0", month);
  month = tmp;
  free(tmp);
 }
 if (strlen(day) == 1 && !is_two_digit_number(atoi(day))) {
  char *tmp = malloc(sizeof(char));
  sprintf(tmp, "%s%s", "0", day);
  day = tmp;
  free(tmp);
 }
 sprintf(date, "%s-%s-%s", year, month, day);
 struct expense *e = malloc(sizeof(Expense));
 e->exp_date = date;
 get_expenses(year, month, list);
 free(date);
 free(e);
}

variable_types:
date
char *

variable_types:
day
char *

variable_types:
tmp
char *

user_defined_types: struct expense { int id; char *exp_date; int category_id; char *category; int product_id; char *product; int shop_id; char *shop; float unit_price; int count; float amount; float price; }


decompiled_code:
__int64 __fastcall _update_product(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
const char *v4; // r13
unsigned int v5; // er12

verify_number_of_parameters(a1, 6LL);
v2 = malloc(0x18uLL);
v3 = malloc(0x18uLL);
v4 = *(const char **)(a2 + 24);
v2[1] = v4;
v3[1] = *(_QWORD *)(a2 + 32);
*((_DWORD *)v3 + 4) = atoi(*(const char **)(a2 + 40));
printf("po->name: %s\n", v4);
printf("pn->name: %s\n", (const char *)v3[1]);
printf("pn->category_id: %d\n", *((unsigned int *)v3 + 4));
v5 = update_product(v2, v3);
free(v2);
free(v3);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbp
_QWORD *v3; // rbx
const char *v4; // r13
unsigned int v5; // er12

verify_number_of_parameters(a1, 6LL);
v2 = malloc(0x18uLL);
v3 = malloc(0x18uLL);
v4 = *(const char **)(a2 + 24);
v2[1] = v4;
v3[1] = *(_QWORD *)(a2 + 32);
*((_DWORD *)v3 + 4) = atoi(*(const char **)(a2 + 40));
printf("po->name: %s\n", v4);
printf("pn->name: %s\n", (const char *)v3[1]);
printf("pn->category_id: %d\n", *((unsigned int *)v3 + 4));
v5 = func1(v2, v3);
free(v2);
free(v3);
return v5;
}

original_code:
int _update_product(char *old_name, char *new_name, int category_id) {
 char *cat_id = malloc(20);
 sprintf(cat_id, "%d", category_id);
 char *args[6] = {"","","",old_name, new_name, cat_id};
 int ret = __update_product(6, args);
 free(cat_id);
 return ret;
}

variable_types:
args
char *[6]

variable_types: ret int


decompiled_code:
__int64 __fastcall _add_product(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 5LL);
v2 = malloc(0x18uLL);
v2[1] = *(_QWORD *)(a2 + 24);
*((_DWORD *)v2 + 4) = atoi(*(const char **)(a2 + 32));
v3 = add_product(v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 5LL);
v2 = malloc(0x18uLL);
v2[1] = *(_QWORD *)(a2 + 24);
*((_DWORD *)v2 + 4) = atoi(*(const char **)(a2 + 32));
v3 = func3(v2);
free(v2);
return v3;
}

original_code:
int _add_product(char *name, int category_id) {
 char *cat_id = malloc(20);
 sprintf(cat_id, "%d", category_id);
 char *args[5] = {"","","",name,cat_id};
 return __add_product(5, args);
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall _del_product(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(0x18uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = del_product(v2);
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
_QWORD *v2; // rbx
unsigned int v3; // ebp

verify_number_of_parameters(a1, 4LL);
v2 = malloc(0x18uLL);
v2[1] = *(_QWORD *)(a2 + 24);
v3 = func5(v2);
free(v2);
return v3;
}

original_code:
int _del_product(char *name) {
 char *args[4] = {"","","",name};
 return __del_product(4, args);
}

variable_types:
args
char *[4]


decompiled_code:
void __fastcall free_product_list(void **a1, int a2)
{
void **v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
{
free(*((void **)*v2 + 1));
free(*v2++);
}
while ( v2 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void free_product_list(Product *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

canonical_original_code:
void free_product_list(struct product *list[], int size) {
 int counter = 0;
 for (counter = 0; counter < size; counter++) {
  free(list[counter]->name);
  free(list[counter]);
 }
}

variable_types: struct product { int id; char *name; int category_id; } *[]

variable_types: size int

variable_types: counter int


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

if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return _update_product(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return _add_product(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return _del_product(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return _list_products();
if ( (unsigned __int8)is_help_string(*(_QWORD *)(a2 + 16)) )
{
_show_help_for_product_module();
result = 0LL;
}
else if ( (unsigned __int8)is_add_to_category_string(*(_QWORD *)(a2 + 16)) )
{
result = _add_to_category(a1, a2);
}
else if ( (unsigned __int8)is_list_products_in_category_string(*(_QWORD *)(a2 + 16)) )
{
result = _list_products_in_category(a1, a2);
}
else
{
_show_common_help();
result = 0LL;
}
return result;
}

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

if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(*(_QWORD *)(a2 + 16)) )
return func0(a1, a2);
if ( (unsigned __int8)is_add_string(*(_QWORD *)(a2 + 16)) )
return func2(a1, a2);
if ( (unsigned __int8)is_delete_string(*(_QWORD *)(a2 + 16)) )
return func4(a1, a2);
if ( (unsigned __int8)is_list_string(*(_QWORD *)(a2 + 16)) )
return func8();
if ( (unsigned __int8)is_help_string(*(_QWORD *)(a2 + 16)) )
{
_show_help_for_product_module();
result = 0LL;
}
else if ( (unsigned __int8)is_add_to_category_string(*(_QWORD *)(a2 + 16)) )
{
result = func6(a1, a2);
}
else if ( (unsigned __int8)is_list_products_in_category_string(*(_QWORD *)(a2 + 16)) )
{
result = func9(a1, a2);
}
else
{
_show_common_help();
result = 0LL;
}
return result;
}

original_code:
int manage_product(int argc, char *argv[]) {
 if (argc == 2) {
  __show_common_help();
 }
 if (is_update_string(argv[2])) {
  return __update_product(argc, argv);
 } else if (is_add_string(argv[2])) {
  return __add_product(argc, argv);
 } else if (is_delete_string(argv[2])) {
  return __del_product(argc, argv);
 } else if (is_list_string(argv[2])) {
  return __list_products();
 } else if (is_help_string(argv[2])) {
  __show_help_for_product_module();
 } else if (is_add_to_category_string(argv[2])) {
  return __add_to_category(argc, argv);
 } else if (is_list_products_in_category_string(argv[2])) {
  return __list_products_in_category(argc, argv);
 } else {
  __show_common_help();
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
void __fastcall check_db_open(int a1)
{
if ( a1 )
{
puts("Can't open database");
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func0(int a1)
{
if ( a1 )
{
puts("Can't open database");
exit(0);
}
}

original_code:
void check_db_open(int error) {
 if (error) {
  puts("Can't open database");
  exit(0);
 }
}

variable_types: error int


login

decompiled_code:
bool __fastcall login(__int64 a1)
{
void *v1; // rbx

v1 = malloc(8uLL);
*((_QWORD *)v1 + 1) = *(_QWORD *)(a1 + 8);
get_user_by_login((__int64)v1);
return strcmp(*(const char **)(a1 + 16), *((const char **)v1 + 2)) == 0;
}

canonical_decompiled_code:
bool __fastcall func7(__int64 a1)
{
void *v1; // rbx

v1 = malloc(8uLL);
*((_QWORD *)v1 + 1) = *(_QWORD *)(a1 + 8);
func6((__int64)v1);
return strcmp(*(const char **)(a1 + 16), *((const char **)v1 + 2)) == 0;
}

original_code:
_Bool login(User *p) {
 User *user = (User *)malloc(sizeof user);
 user->nick = p->nick;
 get_user_by_login(user);
 if (strcmp(p->password, user->password) == 0) {
  return 1;
 } else {
  return 0;
 }
}

canonical_original_code:
_Bool login(struct user *p) {
 struct user *user = (User *)malloc(sizeof user);
 user->nick = p->nick;
 get_user_by_login(user);
 if (strcmp(p->password, user->password) == 0) {
  return 1;
 } else {
  return 0;
 }
}

variable_types: struct user { int id; char *nick; char *password; } *


decompiled_code:
void __fastcall verify_number_of_parameters(int a1, int a2)
{
if ( a1 < a2 )
{
puts("Niepoprawna liczba parametrow");
exit(0);
}
}

canonical_decompiled_code:
void __fastcall func0(int a1, int a2)
{
if ( a1 < a2 )
{
puts("Niepoprawna liczba parametrow");
exit(0);
}
}

original_code:
void verify_number_of_parameters(int argc, int should_be) {
 if (argc < should_be) {
  printf("Niepoprawna liczba parametrow\n");
  exit(0);
 }
}


decompiled_code:
char *__fastcall replace_str(char *src, char *s, const char *a3)
{
char *v4; // rbx
char *result; // rax
size_t v6; // rax

v4 = strstr(src, s);
result = src;
if ( v4 )
{
strncpy(buffer_0, src, v4 - src);
buffer_0[v4 - src] = 0;
v6 = strlen(s);
sprintf(&buffer_0[v4 - src], "%s%s", a3, &v4[v6]);
result = buffer_0;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func1(char *src, char *s, const char *a3)
{
char *v4; // rbx
char *result; // rax
size_t v6; // rax

v4 = strstr(src, s);
result = src;
if ( v4 )
{
strncpy(buffer_0, src, v4 - src);
buffer_0[v4 - src] = 0;
v6 = strlen(s);
sprintf(&buffer_0[v4 - src], "%s%s", a3, &v4[v6]);
result = buffer_0;
}
return result;
}

original_code:
char *replace_str(char *str, char *orig, char *rep) {
 static char buffer[4096];
 char *p;
 if(!(p = strstr(str, orig)))
  return str;
 strncpy(buffer, str, p-str);
 buffer[p-str] = '\0';
 sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));
 return buffer;
}

variable_types:
str
char *

variable_types:
orig
char *

variable_types:
rep
char *

variable_types:
buffer
char [4096]

variable_types:
p
char *


decompiled_code:
void __fastcall manage_user(int a1, _QWORD *a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(a2[2]) )
{
_update_user(a2);
}
else if ( (unsigned __int8)is_add_string(a2[2]) )
{
_add_user((__int64)a2);
}
else if ( (unsigned __int8)is_delete_string(a2[2]) )
{
_del_user((__int64)a2);
}
else if ( (unsigned __int8)is_login_string(a2[2]) )
{
_login(a2);
}
else if ( (unsigned __int8)is_list_string(a2[2]) )
{
_list_users();
}
else if ( (unsigned __int8)is_get_by_id_string(a2[2]) )
{
_get_user_by_id((__int64)a2);
}
else if ( (unsigned __int8)is_get_by_login_string(a2[2]) )
{
_get_user_by_login((__int64)a2);
}
else if ( (unsigned __int8)is_help_for_user_module(a2[2]) )
{
_show_help_for_user_module();
}
else
{
_show_common_help();
}
}

canonical_decompiled_code:
void __fastcall func7(int a1, _QWORD *a2)
{
if ( a1 == 2 )
_show_common_help();
if ( (unsigned __int8)is_update_string(a2[2]) )
{
func1(a2);
}
else if ( (unsigned __int8)is_add_string(a2[2]) )
{
func0((__int64)a2);
}
else if ( (unsigned __int8)is_delete_string(a2[2]) )
{
func2((__int64)a2);
}
else if ( (unsigned __int8)is_login_string(a2[2]) )
{
func3(a2);
}
else if ( (unsigned __int8)is_list_string(a2[2]) )
{
func4();
}
else if ( (unsigned __int8)is_get_by_id_string(a2[2]) )
{
func5((__int64)a2);
}
else if ( (unsigned __int8)is_get_by_login_string(a2[2]) )
{
func6((__int64)a2);
}
else if ( (unsigned __int8)is_help_for_user_module(a2[2]) )
{
_show_help_for_user_module();
}
else
{
_show_common_help();
}
}

original_code:
void manage_user(int argc, char *argv[]) {
 if (argc == 2) {
  __show_common_help();
 }
 if (is_update_string(argv[2])) {
  __update_user(argv);
 } else if (is_add_string(argv[2])) {
  __add_user(argv);
 } else if (is_delete_string(argv[2])) {
  __del_user(argv);
 } else if (is_login_string(argv[2])) {
  __login(argv);
 } else if (is_list_string(argv[2])) {
  __list_users();
 } else if (is_get_by_id_string(argv[2])) {
  __get_user_by_id(argv);
 } else if (is_get_by_login_string(argv[2])) {
  __get_user_by_login(argv);
 } else if (is_help_for_user_module(argv[2])) {
  __show_help_for_user_module();
 } else {
  __show_common_help();
 }
}


help

decompiled_code:
char __fastcall help(const char *a1)
{
bool v1; // cf
bool v2; // zf
const char *v4; // rdi
__int64 v5; // rcx
char result; // al

v4 = "main";
v5 = 5LL;
do
{
if ( !v5 )
break;
v1 = *a1 < (unsigned int)*v4;
v2 = *a1++ == *v4++;
--v5;
}
while ( v2 );
result = (!v1 && !v2) - v1;
if ( !result )
_show_common_help(v4, a1);
return result;
}

canonical_decompiled_code:
char __fastcall func5(const char *a1)
{
bool v1; // cf
bool v2; // zf
const char *v4; // rdi
__int64 v5; // rcx
char result; // al

v4 = "main";
v5 = 5LL;
do
{
if ( !v5 )
break;
v1 = *a1 < (unsigned int)*v4;
v2 = *a1++ == *v4++;
--v5;
}
while ( v2 );
result = (!v1 && !v2) - v1;
if ( !result )
func0(v4, a1);
return result;
}

original_code:
void help(char *h) {
 if (strcmp(h, "main") == 0) {
  __show_common_help();
 }
}

variable_types:
h
char *


repo: macdonad/MultiThreadedServer

decompiled_code:
void __fastcall __noreturn worker_function(void *a1)
{
double v1; // rbp

v1 = 1.0;
if ( rand() % 10 <= 1 )
v1 = (double)(rand() % 4 + 7);
sleep((int)v1);
*((double *)a1 + 1) = v1;
*((_BYTE *)a1 + 24) = 0;
printf("Thread: [%u] retrieved: %s\n", *(_QWORD *)a1, *((const char **)a1 + 2));
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(void *a1)
{
double v1; // rbp

v1 = 1.0;
if ( rand() % 10 <= 1 )
v1 = (double)(rand() % 4 + 7);
sleep((int)v1);
*((double *)a1 + 1) = v1;
*((_BYTE *)a1 + 24) = 0;
printf("Thread: [%u] retrieved: %s\n", *(_QWORD *)a1, *((const char **)a1 + 2));
pthread_exit(0LL);
}

original_code:
void*
worker_function(void* arg)
{
  file_worker_t* this = (file_worker_t*) arg;
  double sleep_time = ((rand() % 10) >= 2) ? 1 : 7 + (rand() % 4);
  sleep(sleep_time);
  this->time_taken = sleep_time;
  this->active = 0;
  printf("Thread: [%u] retrieved: %s\n", ((unsigned int)(this->id)), this->filename);
  pthread_exit(((void *)0));
}

canonical_original_code:
void *worker_function(void *arg)
{
  struct _file_worker_t *this = (file_worker_t*) arg;
  double sleep_time = ((rand() % 10) >= 2) ? 1 : 7 + (rand() % 4);
  sleep(sleep_time);
  this->time_taken = sleep_time;
  this->active = 0;
  printf("Thread: [%u] retrieved: %s\n", ((unsigned int)(this->id)), this->filename);
  pthread_exit(((void *)0));
}

variable_types:
arg
void *

variable_types: struct _file_worker_t { unsigned long id; double time_taken; char *filename; _Bool active; struct _file_worker_t *peer; } *

return_type: void *


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

if ( ptr )
{
v2 = (_BYTE *)*((_QWORD *)ptr + 2);
if ( v2 )
{
if ( *v2 )
free(v2);
}
free(ptr);
}
}

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

if ( ptr )
{
v2 = (_BYTE *)*((_QWORD *)ptr + 2);
if ( v2 )
{
if ( *v2 )
free(v2);
}
free(ptr);
}
}

original_code:
void
file_worker_free(file_worker_t* this)
{
  if (this)
    {
      if (this->filename && *(this->filename)) free(this->filename);
      free(this);
    }
}

canonical_original_code:
void file_worker_free(struct _file_worker_t *this)
{
  if (this)
    {
      if (this->filename && *(this->filename)) free(this->filename);
      free(this);
    }
}

user_defined_types: struct _file_worker_t { unsigned long id; double time_taken; char *filename; _Bool active; struct _file_worker_t *peer; }


decompiled_code:
int __fastcall file_worker_start(void *arg)
{
return pthread_create((pthread_t *)arg, 0LL, (void *(*)(void *))worker_function, arg);
}

canonical_decompiled_code:
int __fastcall func9(void *arg)
{
return pthread_create((pthread_t *)arg, 0LL, (void *(*)(void *))worker_function, arg);
}

original_code:
int
file_worker_start(file_worker_t* this)
{
  return pthread_create(&(this->id), ((void *)0), worker_function, this);
}

canonical_original_code:
int file_worker_start(struct _file_worker_t *this)
{
  return pthread_create(&(this->id), ((void *)0), worker_function, this);
}


decompiled_code:
int __fastcall file_worker_join(pthread_t *a1)
{
pthread_t v1; // rdi
int result; // eax

if ( !a1 )
return -1;
v1 = *a1;
if ( v1 )
result = pthread_join(v1, 0LL);
else
result = -1;
return result;
}

canonical_decompiled_code:
int __fastcall func10(pthread_t *a1)
{
pthread_t v1; // rdi
int result; // eax

if ( !a1 )
return -1;
v1 = *a1;
if ( v1 )
result = pthread_join(v1, 0LL);
else
result = -1;
return result;
}

original_code:
int
file_worker_join(file_worker_t* this)
{
  if (this && this->id) return pthread_join(this->id, (void*)((void *)0));
  else return -1;
}

canonical_original_code:
int file_worker_join(struct _file_worker_t *this)
{
  if (this && this->id) return pthread_join(this->id, (void *)((void *)0));
  else return -1;
}


decompiled_code:
char *read_filename()
{
char *result; // rax

fgets(input_buffer, 1024, stdin);
result = strchr(input_buffer, 10);
if ( result )
*result = 0;
return result;
}

canonical_decompiled_code:
char *func11()
{
char *result; // rax

fgets(input_buffer, 1024, stdin);
result = strchr(input_buffer, 10);
if ( result )
*result = 0;
return result;
}

original_code:
void
read_filename(void)
{
  fgets(input_buffer, 1024, stdin);
  char* newline_pos = strchr(input_buffer, '\n');
  if (newline_pos != ((void *)0)) *newline_pos = '\0';
}

canonical_original_code:
void read_filename()
{
  fgets(input_buffer, 1024, stdin);
  char *newline_pos = strchr(input_buffer, '\n');
  if (newline_pos != ((void *)0)) *newline_pos = '\0';
}


decompiled_code:
__int64 __fastcall str_is_whitespace(char *a1)
{
char v2; // al

if ( !a1 )
return 1LL;
while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
if ( (unsigned __int8)(v2 - 9) > 1u && v2 != 32 )
return 0LL;
++a1;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(char *a1)
{
char v2; // al

if ( !a1 )
return 1LL;
while ( 1 )
{
v2 = *a1;
if ( !*a1 )
break;
if ( (unsigned __int8)(v2 - 9) > 1u && v2 != 32 )
return 0LL;
++a1;
}
return 1LL;
}

original_code:
_Bool
str_is_whitespace(char* str)
{
  char* c;
  for (c = str; c && *c; c++) {
    if (!(*c == ' ' || *c == '\t' || *c == '\n')) {
      return 0;
    }
  }
  return 1;
}

canonical_original_code:
_Bool str_is_whitespace(char *str)
{
  char *c;
  for (c = str; c && *c; c++) {
    if (!(*c == ' ' || *c == '\t' || *c == '\n')) {
      return 0;
    }
  }
  return 1;
}

variable_types:
c
char *


main

canonical_name: main

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

signal(2, handle_sigint);
input_buffer = (char *)calloc(0x400uLL, 8uLL);
while ( 1 )
{
while ( 1 )
{
read_filename();
v4 = input_buffer;
if ( !(unsigned __int8)str_is_whitespace(input_buffer) )
break;
puts("No file given...");
}
v5 = file_worker_new(v4, (__int64)last_worker);
if ( file_worker_start(v5) )
{
v3 = "unknown";
if ( v5 )
{
v3 = (const char *)v5[2];
if ( !v3 )
v3 = "unknown";
}
printf("Error starting worker for \"%s\"\n", v3);
file_worker_free(v5);
}
else
{
last_worker = v5;
}
}
}

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

signal(2, handle_sigint);
input_buffer = (char *)calloc(0x400uLL, 8uLL);
while ( 1 )
{
while ( 1 )
{
func11();
v4 = input_buffer;
if ( !(unsigned __int8)func12(input_buffer) )
break;
puts("No file given...");
}
v5 = file_worker_new(v4, (__int64)last_worker);
if ( func9(v5) )
{
v3 = "unknown";
if ( v5 )
{
v3 = (const char *)v5[2];
if ( !v3 )
v3 = "unknown";
}
printf("Error starting worker for \"%s\"\n", v3);
func8(v5);
}
else
{
last_worker = v5;
}
}
}

original_code:
int
main(void)
{
  signal(2, handle_sigint);
  input_buffer = calloc(1024, sizeof(char*));
  while(1)
    {
      read_filename();
      if (!str_is_whitespace(input_buffer))
 {
   file_worker_t* worker = file_worker_new(input_buffer, last_worker);
   if(file_worker_start(worker) != 0)
     {
       printf("Error starting worker for \"%s\"\n",
       (worker && worker->filename) ? worker->filename : "unknown");
       file_worker_free(worker);
     }
   else
     {
       last_worker = worker;
     }
 }
      else
 {
   printf("No file given...\n");
 }
    }
  pthread_exit(((void *)0));
}

canonical_original_code:
int main()
{
  signal(2, handle_sigint);
  input_buffer = calloc(1024, sizeof(char *));
  while(1)
    {
      read_filename();
      if (!str_is_whitespace(input_buffer))
 {
   struct _file_worker_t *worker = file_worker_new(input_buffer, last_worker);
   if(file_worker_start(worker) != 0)
     {
       printf("Error starting worker for \"%s\"\n",
       (worker && worker->filename) ? worker->filename : "unknown");
       file_worker_free(worker);
     }
   else
     {
       last_worker = worker;
     }
 }
      else
 {
   printf("No file given...\n");
 }
    }
  pthread_exit(((void *)0));
}


decompiled_code:
int __fastcall print_server_stats(int a1, double a2)
{
printf("total_time_taken: %f\n", a2);
return printf("Retrieved %d files, Average time: %f seconds\n", (unsigned int)a1, a2 / (double)a1);
}

canonical_decompiled_code:
int __fastcall func13(int a1, double a2)
{
printf("total_time_taken: %f\n", a2);
return printf("Retrieved %d files, Average time: %f seconds\n", (unsigned int)a1, a2 / (double)a1);
}

original_code:
void
print_server_stats(int worker_count, double total_time_taken)
{
  printf("total_time_taken: %f\n", total_time_taken);
  printf("Retrieved %d files, Average time: %f seconds\n",
  worker_count,
  (total_time_taken / (double)worker_count));
}


decompiled_code:
void __noreturn handle_sigint()
{
int v0; // er12
void *v1; // rbx
double v2; // r13
void *v3; // rbp
const char *v4; // rsi

signal(2, handle_sigint);
v0 = sigint_count_0;
if ( !sigint_count_0 )
{
sigint_count_0 = 1;
puts("\nBeginning shutdown... Press C-c again to force quit");
v1 = last_worker;
if ( last_worker )
{
v2 = 0.0;
while ( 1 )
{
if ( file_worker_join((pthread_t *)v1) )
{
v4 = (const char *)*((_QWORD *)v1 + 2);
if ( !v4 )
v4 = "unknown";
printf("Error joining worker for \"%s\"\n", v4);
}
else
{
++v0;
v2 = v2 + *((double *)v1 + 1);
}
v3 = (void *)*((_QWORD *)v1 + 4);
file_worker_free(v1);
if ( !v3 )
break;
v1 = v3;
}
}
else
{
v2 = 0.0;
}
print_server_stats(v0, v2);
free(input_buffer);
exit(0);
}
puts("\n");
free(input_buffer);
exit(0);
}

canonical_decompiled_code:
void __noreturn func14()
{
int v0; // er12
void *v1; // rbx
double v2; // r13
void *v3; // rbp
const char *v4; // rsi

signal(2, handle_sigint);
v0 = sigint_count_0;
if ( !sigint_count_0 )
{
sigint_count_0 = 1;
puts("\nBeginning shutdown... Press C-c again to force quit");
v1 = last_worker;
if ( last_worker )
{
v2 = 0.0;
while ( 1 )
{
if ( func10((pthread_t *)v1) )
{
v4 = (const char *)*((_QWORD *)v1 + 2);
if ( !v4 )
v4 = "unknown";
printf("Error joining worker for \"%s\"\n", v4);
}
else
{
++v0;
v2 = v2 + *((double *)v1 + 1);
}
v3 = (void *)*((_QWORD *)v1 + 4);
func8(v1);
if ( !v3 )
break;
v1 = v3;
}
}
else
{
v2 = 0.0;
}
func13(v0, v2);
free(input_buffer);
exit(0);
}
puts("\n");
free(input_buffer);
exit(0);
}

original_code:
void
handle_sigint(int sig)
{
  signal(2, handle_sigint);
  static int sigint_count = 0;
  switch(sigint_count)
    {
    case 0: {
      sigint_count++;
      printf("\nBeginning shutdown... Press C-c again to force quit\n");
      file_worker_t* worker = last_worker;
      int worker_count = 0;
      double total_time_taken = 0;
      while (worker)
 {
   if(file_worker_join(worker) != 0)
     {
       printf("Error joining worker for \"%s\"\n",
       (worker && worker->filename) ? worker->filename : "unknown");
     }
   else
     {
       worker_count++;
       total_time_taken += worker->time_taken;
     }
   file_worker_t* current = worker;
   worker = worker->peer;
   file_worker_free(current);
 }
      print_server_stats(worker_count, total_time_taken);
      free(input_buffer);
      exit(0);
    }
    default:
      {
 puts("\n");
 free(input_buffer);
 exit(0);
      }
    }
}

canonical_original_code:
void handle_sigint(int sig)
{
  signal(2, handle_sigint);
  static int sigint_count = 0;
  switch(sigint_count)
    {
    case 0: {
      sigint_count++;
      printf("\nBeginning shutdown... Press C-c again to force quit\n");
      struct _file_worker_t *worker = last_worker;
      int worker_count = 0;
      double total_time_taken = 0;
      while (worker)
 {
   if(file_worker_join(worker) != 0)
     {
       printf("Error joining worker for \"%s\"\n",
       (worker && worker->filename) ? worker->filename : "unknown");
     }
   else
     {
       worker_count++;
       total_time_taken += worker->time_taken;
     }
   struct _file_worker_t *current = worker;
   worker = worker->peer;
   file_worker_free(current);
 }
      print_server_stats(worker_count, total_time_taken);
      free(input_buffer);
      exit(0);
    }
    default:
      {
 puts("\n");
 free(input_buffer);
 exit(0);
      }
    }
}

variable_types: sig int


WriteToLog

repo: maciejpatucha/GoRaspberry

decompiled_code:
void __fastcall WriteToLog(int a1, const char *a2)
{
openlog("GoHipsterd", 1, 8);
if ( a1 )
{
if ( a1 == 1 )
syslog(3, "%s", a2);
}
else
{
syslog(6, "%s", a2);
}
closelog();
}

canonical_decompiled_code:
void __fastcall func0(int a1, const char *a2)
{
openlog("GoHipsterd", 1, 8);
if ( a1 )
{
if ( a1 == 1 )
syslog(3, "%s", a2);
}
else
{
syslog(6, "%s", a2);
}
closelog();
}

original_code:
void WriteToLog(int level, char *message)
{
 openlog("GoHipsterd", 0x01, (1<<3));
 switch (level)
 {
  case 0:
   syslog(6, "%s", message);
   break;
  case 1:
   syslog(3, "%s", message);
   break;
 };
 closelog();
}

variable_types: level int

variable_types:
message
char *


main

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

original_code:
int main(int argc, char *argv[])
{
 daemonise();
 return 0;
}


GetFreeSpace

decompiled_code:
signed __int64 GetFreeSpace()
{
struct statvfs v1; // [rsp+0h] [rbp-78h] BYREF

if ( statvfs("/", &v1) != -1 )
return (signed __int64)(v1.f_bavail * v1.f_bsize) / 1047552;
WriteToLog(1LL, "Cannot get information about file system");
return 0LL;
}

canonical_decompiled_code:
signed __int64 func0()
{
struct statvfs v1; // [rsp+0h] [rbp-78h] BYREF

if ( statvfs("/", &v1) != -1 )
return (signed __int64)(v1.f_bavail * v1.f_bsize) / 1047552;
WriteToLog(1LL, "Cannot get information about file system");
return 0LL;
}

original_code:
static unsigned long GetFreeSpace(void)
{
 struct statvfs vfsbuffer;
 if (statvfs("/", &vfsbuffer) == -1)
 {
  WriteToLog(1, "Cannot get information about file system");
  return 0;
 }
 long long total_free_space = (long long)vfsbuffer.f_bsize * (long long)vfsbuffer.f_bavail;
 long long total_free_MB = total_free_space/(long long)(1023*1024);
 return (unsigned long)total_free_MB;
}

canonical_original_code:
static unsigned long GetFreeSpace()
{
 struct statvfs vfsbuffer;
 if (statvfs("/", &vfsbuffer) == -1)
 {
  WriteToLog(1, "Cannot get information about file system");
  return 0;
 }
 long long total_free_space = (long long)vfsbuffer.f_bsize * (long long)vfsbuffer.f_bavail;
 long long total_free_MB = total_free_space/(long long)(1023*1024);
 return (unsigned long)total_free_MB;
}

variable_types: struct statvfs { unsigned long f_bsize; unsigned long f_frsize; unsigned long f_blocks; unsigned long f_bfree; unsigned long f_bavail; unsigned long f_files; unsigned long f_ffree; unsigned long f_favail; unsigned long f_fsid; unsigned long f_flag; unsigned long f_namemax; int __f_spare[6]; }

return_type: unsigned long


IsRawVideoFile

decompiled_code:
bool __fastcall IsRawVideoFile(const char *a1)
{
return strstr(a1, "h264") != 0LL;
}

canonical_decompiled_code:
bool __fastcall func3(const char *a1)
{
return strstr(a1, "h264") != 0LL;
}

original_code:
static _Bool IsRawVideoFile(char *file)
{
 if (strstr(file, "h264") == ((void *)0))
 {
  return 0;
 }
 return 1;
}

variable_types:
file
char *