main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
unsigned int v4; // er13
char v5; // al
__int64 v6; // rdx
char **v7; // r14
char *v8; // rax
unsigned int v9; // ebx
__int64 v10; // r15
char *v11; // r13
__int64 v12; // rax
bool v13; // al
const char *v14; // r10
unsigned int v15; // er13
__int64 v16; // rbx
unsigned int v17; // er9
void *v18; // rax
_OWORD *v19; // rax
__pid_t v20; // eax
__int64 v21; // rdx
__int64 v22; // rcx
__int64 v23; // r8
__pid_t v24; // edi
char *v25; // rax
unsigned int v26; // eax
char *v27; // r10
__int64 v28; // rdi
__int64 v29; // rax
void *v30; // rsp
char **v31; // rcx
char **v32; // rax
char *v33; // rbx
char *filename[2]; // [rsp+0h] [rbp-60h] BYREF
unsigned __int64 v36; // [rsp+10h] [rbp-50h]
size_t size; // [rsp+1Ch] [rbp-44h]
unsigned int v38; // [rsp+28h] [rbp-38h] BYREF
int stat_loc[13]; // [rsp+2Ch] [rbp-34h] BYREF

LODWORD(size) = 80;
v3 = malloc(0x50uLL);
while ( 1 )
{
v4 = 0;
printf("$ ");
do
{
if ( (_DWORD)size == v4 )
{
LODWORD(size) = size + 40;
v3 = realloc(v3, (unsigned int)size);
if ( !v3 )
{
perror("Error increasing size of input buffer.");
exit(-1);
}
}
v5 = getchar();
v6 = v4++;
*((_BYTE *)v3 + v6) = v5;
}
while ( v5 != 10 );
v7 = (char **)calloc(0xA0uLL, 1uLL);
v8 = strtok((char *)v3, " \n");
if ( v8 )
{
*v7 = v8;
v9 = 1;
LODWORD(v10) = 20;
v11 = strtok(0LL, " \n");
while ( v11 )
{
v12 = v9++;
v7[v12] = v11;
v11 = strtok(0LL, " \n");
if ( (_DWORD)v10 == v9 )
{
v10 = (unsigned int)(v10 + 10);
v7 = (char **)realloc(v7, 8 * v10);
if ( !v7 )
{
perror("Error increasing size of token buffer.");
exit(-1);
}
}
}
v13 = (_DWORD)v10 != 0;
}
else
{
v13 = 1;
LODWORD(v10) = 20;
}
v14 = *v7;
v38 = 0;
if ( !v14 || !v13 )
goto LABEL_24;
v15 = 0;
do
{
v17 = v15++;
v16 = v15;
}
while ( v7[v15] && v15 < (unsigned int)v10 );
v38 = v15;
if ( !v15 )
goto LABEL_24;
if ( !strcmp(v14, "exit") )
break;
filename[1] = (char *)v14;
LODWORD(v36) = v17;
v20 = fork();
v24 = v20;
if ( v20 < 0 )
{
perror("Fork was unsuccesful in creating a new process.");
exit(-1);
}
if ( v20 )
{
v25 = v7[(unsigned int)v36];
if ( *v25 != 38 || v25[1] )
waitpid(v24, stat_loc, 0);
}
else
{
v26 = find_redirect(v7, &v38, v21, v22, v23, (unsigned int)v36);
v28 = v26;
if ( v26 )
{
v29 = v26 + 1;
v16 = (unsigned int)v28;
if ( v15 <= (unsigned int)v29 )
{
filename[0] = (char *)"";
v15 = v28;
}
else
{
v15 = v28;
filename[0] = v7[v29];
}
}
v30 = alloca(16 * ((8 * (unsigned __int64)(v15 + 1) + 15) >> 4));
v31 = filename;
v36 = ((unsigned __int64)filename + 7) >> 3;
v32 = v7 + 1;
while ( *v27 != 38 || v27[1] )
{
*v31++ = v27;
if ( &v7[v16] == v32 )
{
filename[v16] = 0LL;
if ( !(_DWORD)v28 )
goto LABEL_41;
goto LABEL_44;
}
v27 = *v32++;
}
filename[v16] = 0LL;
if ( !(_DWORD)v28 )
{
fclose(stdout);
stdout = fopen("/dev/null", "w");
if ( !stdout )
{
perror("Couldn't open /dev/null for writing.");
exit(-1);
}
goto LABEL_41;
}
LABEL_44:
v33 = v7[v28];
if ( *v33 == 62 && !v33[1] )
{
fclose(stdout);
stdout = fopen(filename[0], "w");
if ( !stdout )
{
perror("Couldn't open output file for writing.");
exit(-1);
}
}
if ( *v33 == 62 && v33[1] == 62 && !v33[2] )
{
fclose(stdout);
stdout = fopen(filename[0], "a");
if ( !stdout )
{
perror("Couldn't open output file for appending.");
exit(-1);
}
}
if ( *v33 == 60 && !v33[1] )
{
fclose(stdin);
stdin = fopen(filename[0], "r");
if ( !stdin )
{
perror("Couldn't open input file for reading.");
exit(-1);
}
}
LABEL_41:
if ( execvp(*(const char **)(8 * v36), filename) == -1 )
{
printf("Could not exec: %s\n", filename[0]);
exit(-1);
}
}
LABEL_24:
free(v7);
v19 = realloc(v3, 0x50uLL);
v3 = v19;
if ( !v19 )
goto LABEL_22;
*v19 = 0LL;
v19[1] = 0LL;
v19[2] = 0LL;
v19[3] = 0LL;
v19[4] = 0LL;
}
free(v7);
v18 = realloc(v3, 0x50uLL);
if ( !v18 )
{
LABEL_22:
perror("Error decreasing size of input buffer.");
exit(-1);
}
free(v18);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // r12
unsigned int v4; // er13
char v5; // al
__int64 v6; // rdx
char **v7; // r14
char *v8; // rax
unsigned int v9; // ebx
__int64 v10; // r15
char *v11; // r13
__int64 v12; // rax
bool v13; // al
const char *v14; // r10
unsigned int v15; // er13
__int64 v16; // rbx
unsigned int v17; // er9
void *v18; // rax
_OWORD *v19; // rax
__pid_t v20; // eax
__int64 v21; // rdx
__int64 v22; // rcx
__int64 v23; // r8
__pid_t v24; // edi
char *v25; // rax
unsigned int v26; // eax
char *v27; // r10
__int64 v28; // rdi
__int64 v29; // rax
void *v30; // rsp
char **v31; // rcx
char **v32; // rax
char *v33; // rbx
char *filename[2]; // [rsp+0h] [rbp-60h] BYREF
unsigned __int64 v36; // [rsp+10h] [rbp-50h]
size_t size; // [rsp+1Ch] [rbp-44h]
unsigned int v38; // [rsp+28h] [rbp-38h] BYREF
int stat_loc[13]; // [rsp+2Ch] [rbp-34h] BYREF

LODWORD(size) = 80;
v3 = malloc(0x50uLL);
while ( 1 )
{
v4 = 0;
printf("$ ");
do
{
if ( (_DWORD)size == v4 )
{
LODWORD(size) = size + 40;
v3 = realloc(v3, (unsigned int)size);
if ( !v3 )
{
perror("Error increasing size of input buffer.");
exit(-1);
}
}
v5 = getchar();
v6 = v4++;
*((_BYTE *)v3 + v6) = v5;
}
while ( v5 != 10 );
v7 = (char **)calloc(0xA0uLL, 1uLL);
v8 = strtok((char *)v3, " \n");
if ( v8 )
{
*v7 = v8;
v9 = 1;
LODWORD(v10) = 20;
v11 = strtok(0LL, " \n");
while ( v11 )
{
v12 = v9++;
v7[v12] = v11;
v11 = strtok(0LL, " \n");
if ( (_DWORD)v10 == v9 )
{
v10 = (unsigned int)(v10 + 10);
v7 = (char **)realloc(v7, 8 * v10);
if ( !v7 )
{
perror("Error increasing size of token buffer.");
exit(-1);
}
}
}
v13 = (_DWORD)v10 != 0;
}
else
{
v13 = 1;
LODWORD(v10) = 20;
}
v14 = *v7;
v38 = 0;
if ( !v14 || !v13 )
goto LABEL_24;
v15 = 0;
do
{
v17 = v15++;
v16 = v15;
}
while ( v7[v15] && v15 < (unsigned int)v10 );
v38 = v15;
if ( !v15 )
goto LABEL_24;
if ( !strcmp(v14, "exit") )
break;
filename[1] = (char *)v14;
LODWORD(v36) = v17;
v20 = fork();
v24 = v20;
if ( v20 < 0 )
{
perror("Fork was unsuccesful in creating a new process.");
exit(-1);
}
if ( v20 )
{
v25 = v7[(unsigned int)v36];
if ( *v25 != 38 || v25[1] )
waitpid(v24, stat_loc, 0);
}
else
{
v26 = func7(v7, &v38, v21, v22, v23, (unsigned int)v36);
v28 = v26;
if ( v26 )
{
v29 = v26 + 1;
v16 = (unsigned int)v28;
if ( v15 <= (unsigned int)v29 )
{
filename[0] = (char *)"";
v15 = v28;
}
else
{
v15 = v28;
filename[0] = v7[v29];
}
}
v30 = alloca(16 * ((8 * (unsigned __int64)(v15 + 1) + 15) >> 4));
v31 = filename;
v36 = ((unsigned __int64)filename + 7) >> 3;
v32 = v7 + 1;
while ( *v27 != 38 || v27[1] )
{
*v31++ = v27;
if ( &v7[v16] == v32 )
{
filename[v16] = 0LL;
if ( !(_DWORD)v28 )
goto LABEL_41;
goto LABEL_44;
}
v27 = *v32++;
}
filename[v16] = 0LL;
if ( !(_DWORD)v28 )
{
fclose(stdout);
stdout = fopen("/dev/null", "w");
if ( !stdout )
{
perror("Couldn't open /dev/null for writing.");
exit(-1);
}
goto LABEL_41;
}
LABEL_44:
v33 = v7[v28];
if ( *v33 == 62 && !v33[1] )
{
fclose(stdout);
stdout = fopen(filename[0], "w");
if ( !stdout )
{
perror("Couldn't open output file for writing.");
exit(-1);
}
}
if ( *v33 == 62 && v33[1] == 62 && !v33[2] )
{
fclose(stdout);
stdout = fopen(filename[0], "a");
if ( !stdout )
{
perror("Couldn't open output file for appending.");
exit(-1);
}
}
if ( *v33 == 60 && !v33[1] )
{
fclose(stdin);
stdin = fopen(filename[0], "r");
if ( !stdin )
{
perror("Couldn't open input file for reading.");
exit(-1);
}
}
LABEL_41:
if ( execvp(*(const char **)(8 * v36), filename) == -1 )
{
printf("Could not exec: %s\n", filename[0]);
exit(-1);
}
}
LABEL_24:
free(v7);
v19 = realloc(v3, 0x50uLL);
v3 = v19;
if ( !v19 )
goto LABEL_22;
*v19 = 0LL;
v19[1] = 0LL;
v19[2] = 0LL;
v19[3] = 0LL;
v19[4] = 0LL;
}
free(v7);
v18 = realloc(v3, 0x50uLL);
if ( !v18 )
{
LABEL_22:
perror("Error decreasing size of input buffer.");
exit(-1);
}
free(v18);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
  unsigned int buf_base_size = 80;
  unsigned int buf_size = buf_base_size;
  char *input_buf = malloc(buf_size*sizeof(char));
  _Bool exit_status = 0;
  while(exit_status == 0)
    {
      printf("$ ");
      char in_char = '\0';
      unsigned int buf_pos = 0;
      while( in_char != '\n' )
 {
   if( buf_pos == buf_size )
     {
       buf_size += buf_base_size/2;
       input_buf = realloc(input_buf, buf_size*sizeof(char));
       if(input_buf == ((void *)0))
  {
    perror("Error increasing size of input buffer.");
    exit(-1);
  }
     }
   in_char = getchar();
   input_buf[buf_pos] = in_char;
   buf_pos++;
 }
      unsigned int token_buf_base_size = 20;
      unsigned int token_buf_size = token_buf_base_size;
      char** token_buf = malloc(token_buf_base_size*sizeof(char*));
      unsigned int token_pos;
      for(token_pos = 0; token_pos < token_buf_size; token_pos++)
 {
   token_buf[token_pos] = ((void *)0);
 }
      char *token = strtok(input_buf, " \n");
      token_pos = 0;
      while(token != ((void *)0))
 {
   token_buf[token_pos] = token;
   token = strtok(((void *)0), " \n");
   token_pos++;
   if(token_pos == token_buf_size)
     {
       token_buf_size += token_buf_base_size/2;
       token_buf = realloc(token_buf, token_buf_size*sizeof(char*));
       if(token_buf == ((void *)0))
  {
    perror("Error increasing size of token buffer.");
    exit(-1);
  }
     }
 }
      unsigned int token_buf_len = 0;
      while((token_buf[token_buf_len] != ((void *)0)) && (token_buf_len < token_buf_size)) token_buf_len++;
      if( token_buf_len > 0 )
 {
   if( strcmp(token_buf[0], "exit") == 0) exit_status = 1;
   else
     {
       pid_t child_pid = fork();
       if(child_pid >= 0)
  {
    if(child_pid == 0)
      {
        unsigned int redirect_token_pos = find_redirect(token_buf, &token_buf_len);
        char* redirect_file_name;
        if( redirect_token_pos > 0 )
   {
     if( redirect_token_pos + 1 < token_buf_len ) redirect_file_name = token_buf[redirect_token_pos + 1];
     else redirect_file_name = "";
   }
        unsigned int param_buf_size;
        if( redirect_token_pos > 0 ) param_buf_size = redirect_token_pos;
        else param_buf_size = token_buf_len;
        char *param_buf[param_buf_size + 1];
        _Bool is_background = 0;
        unsigned int i;
        for( i = 0; i < param_buf_size; i++)
   {
     if( strcmp(token_buf[i], "&") == 0 )
       {
         is_background = 1;
         break;
       }
     param_buf[i] = token_buf[i];
   }
        param_buf[param_buf_size] = ((void *)0);
        if( ( redirect_token_pos == 0) && ( is_background == 1 ) )
   {
     fclose(stdout);
     stdout = fopen("/dev/null", "w");
     if( stdout == ((void *)0) )
       {
         perror("Couldn't open /dev/null for writing.");
         exit(-1);
       }
   }
        if( redirect_token_pos > 0 )
   {
     if( strcmp(token_buf[redirect_token_pos], ">") == 0 )
       {
         fclose(stdout);
         stdout = fopen(redirect_file_name, "w");
         if( stdout == ((void *)0) )
    {
      perror("Couldn't open output file for writing.");
      exit(-1);
    }
       }
     if( strcmp(token_buf[redirect_token_pos], ">>") == 0 )
       {
         fclose(stdout);
         stdout = fopen(redirect_file_name, "a");
         if( stdout == ((void *)0) )
    {
      perror("Couldn't open output file for appending.");
      exit(-1);
    }
       }
     if( strcmp(token_buf[redirect_token_pos], "<") == 0 )
       {
         fclose(stdin);
         stdin = fopen(redirect_file_name, "r");
         if( stdin == ((void *)0) )
    {
      perror("Couldn't open input file for reading.");
      exit(-1);
    }
       }
   }
        int retval = execvp(param_buf[0], param_buf);
        if( retval == -1 )
   {
     printf("Could not exec: %s\n", param_buf[0]);
     exit(-1);
   }
      }
    else
      {
        if( strcmp(token_buf[token_buf_len - 1], "&") != 0 )
   {
     int status;
     waitpid(child_pid, &status, 0);
   }
      }
  }
       else
  {
    perror("Fork was unsuccesful in creating a new process.");
    exit(-1);
  }
     }
 }
      free(token_buf);
      input_buf = realloc(input_buf, buf_base_size*sizeof(char));
      if(input_buf == ((void *)0))
 {
   perror("Error decreasing size of input buffer.");
   exit(-1);
 }
      memset(input_buf,'\0',buf_base_size*sizeof(char));
    }
  free(input_buf);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  unsigned int buf_base_size = 80;
  unsigned int buf_size = buf_base_size;
  char *input_buf = malloc(buf_size*sizeof(char));
  _Bool exit_status = 0;
  while(exit_status == 0)
    {
      printf("$ ");
      char in_char = '\0';
      unsigned int buf_pos = 0;
      while( in_char != '\n' )
 {
   if( buf_pos == buf_size )
     {
       buf_size += buf_base_size/2;
       input_buf = realloc(input_buf, buf_size*sizeof(char));
       if(input_buf == ((void *)0))
  {
    perror("Error increasing size of input buffer.");
    exit(-1);
  }
     }
   in_char = getchar();
   input_buf[buf_pos] = in_char;
   buf_pos++;
 }
      unsigned int token_buf_base_size = 20;
      unsigned int token_buf_size = token_buf_base_size;
      char **token_buf = malloc(token_buf_base_size*sizeof(char*));
      unsigned int token_pos;
      for(token_pos = 0; token_pos < token_buf_size; token_pos++)
 {
   token_buf[token_pos] = ((void *)0);
 }
      char *token = strtok(input_buf, " \n");
      token_pos = 0;
      while(token != ((void *)0))
 {
   token_buf[token_pos] = token;
   token = strtok(((void *)0), " \n");
   token_pos++;
   if(token_pos == token_buf_size)
     {
       token_buf_size += token_buf_base_size/2;
       token_buf = realloc(token_buf, token_buf_size*sizeof(char *));
       if(token_buf == ((void *)0))
  {
    perror("Error increasing size of token buffer.");
    exit(-1);
  }
     }
 }
      unsigned int token_buf_len = 0;
      while((token_buf[token_buf_len] != ((void *)0)) && (token_buf_len < token_buf_size)) token_buf_len++;
      if( token_buf_len > 0 )
 {
   if( strcmp(token_buf[0], "exit") == 0) exit_status = 1;
   else
     {
       int child_pid = fork();
       if(child_pid >= 0)
  {
    if(child_pid == 0)
      {
        unsigned int redirect_token_pos = find_redirect(token_buf, &token_buf_len);
        char *redirect_file_name;
        if( redirect_token_pos > 0 )
   {
     if( redirect_token_pos + 1 < token_buf_len ) redirect_file_name = token_buf[redirect_token_pos + 1];
     else redirect_file_name = "";
   }
        unsigned int param_buf_size;
        if( redirect_token_pos > 0 ) param_buf_size = redirect_token_pos;
        else param_buf_size = token_buf_len;
        char *param_buf[-1];
        _Bool is_background = 0;
        unsigned int i;
        for( i = 0; i < param_buf_size; i++)
   {
     if( strcmp(token_buf[i], "&") == 0 )
       {
         is_background = 1;
         break;
       }
     param_buf[i] = token_buf[i];
   }
        param_buf[param_buf_size] = ((void *)0);
        if( ( redirect_token_pos == 0) && ( is_background == 1 ) )
   {
     fclose(stdout);
     stdout = fopen("/dev/null", "w");
     if( stdout == ((void *)0) )
       {
         perror("Couldn't open /dev/null for writing.");
         exit(-1);
       }
   }
        if( redirect_token_pos > 0 )
   {
     if( strcmp(token_buf[redirect_token_pos], ">") == 0 )
       {
         fclose(stdout);
         stdout = fopen(redirect_file_name, "w");
         if( stdout == ((void *)0) )
    {
      perror("Couldn't open output file for writing.");
      exit(-1);
    }
       }
     if( strcmp(token_buf[redirect_token_pos], ">>") == 0 )
       {
         fclose(stdout);
         stdout = fopen(redirect_file_name, "a");
         if( stdout == ((void *)0) )
    {
      perror("Couldn't open output file for appending.");
      exit(-1);
    }
       }
     if( strcmp(token_buf[redirect_token_pos], "<") == 0 )
       {
         fclose(stdin);
         stdin = fopen(redirect_file_name, "r");
         if( stdin == ((void *)0) )
    {
      perror("Couldn't open input file for reading.");
      exit(-1);
    }
       }
   }
        int retval = execvp(param_buf[0], param_buf);
        if( retval == -1 )
   {
     printf("Could not exec: %s\n", param_buf[0]);
     exit(-1);
   }
      }
    else
      {
        if( strcmp(token_buf[token_buf_len - 1], "&") != 0 )
   {
     int status;
     waitpid(child_pid, &status, 0);
   }
      }
  }
       else
  {
    perror("Fork was unsuccesful in creating a new process.");
    exit(-1);
  }
     }
 }
      free(token_buf);
      input_buf = realloc(input_buf, buf_base_size*sizeof(char));
      if(input_buf == ((void *)0))
 {
   perror("Error decreasing size of input buffer.");
   exit(-1);
 }
      memset(input_buf,'\0',buf_base_size*sizeof(char));
    }
  free(input_buf);
  return 0;
}

variable_types: argc int

variable_types:
token
char *

variable_types: retval int

variable_types: status int


programOptionsCreate

repo: afumoleau/Parangon

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

result = malloc(0x28uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
return result;
}

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

result = malloc(0x28uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
return result;
}

original_code:
programOptions programOptionsCreate()
{
 programOptions instance = (programOptions) malloc(sizeof(struct programOptions));
 instance->mode = 0;
 instance->verbose = 0;
 instance->archiveFilename = ((void *)0);
 instance->filesNames = ((void *)0);
 instance->filesCount = 0;
 instance->gzip = 0;
 instance->sparse = 0;
 return instance;
}

canonical_original_code:
struct programOptions *programOptionsCreate()
{
 struct programOptions *instance = (programOptions) malloc(sizeof(struct programOptions));
 instance->mode = 0;
 instance->verbose = 0;
 instance->archiveFilename = ((void *)0);
 instance->filesNames = ((void *)0);
 instance->filesCount = 0;
 instance->gzip = 0;
 instance->sparse = 0;
 return instance;
}

variable_types: struct programOptions { unsigned int mode; char *archiveFilename; char **filesNames; unsigned int filesCount; unsigned int verbose; unsigned int gzip; unsigned int sparse; } *


programOptionsDestroy

decompiled_code:
// attributes: thunk
void programOptionsDestroy(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void programOptionsDestroy(programOptions po)
{
 free(po);
}

canonical_original_code:
void programOptionsDestroy(struct programOptions *po)
{
 free(po);
}

return_type: void

user_defined_types: struct programOptions { unsigned int mode; char *archiveFilename; char **filesNames; unsigned int filesCount; unsigned int verbose; unsigned int gzip; unsigned int sparse; }


programOptionsGetMode

decompiled_code:
__int64 __fastcall programOptionsGetMode(unsigned int *a1)
{
return *a1;
}

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

original_code:
unsigned int programOptionsGetMode(programOptions po)
{
 return po->mode;
}

canonical_original_code:
unsigned int programOptionsGetMode(struct programOptions *po)
{
 return po->mode;
}

return_type: unsigned int


programOptionsAddFile

decompiled_code:
void *__fastcall programOptionsAddFile(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v4; // rdi
void *result; // rax
_QWORD *v6; // rcx
__int64 v7; // rdi

v2 = *(_DWORD *)(a1 + 24);
v4 = v2 + 1;
*(_DWORD *)(a1 + 24) = v4;
result = malloc(8 * v4);
v6 = result;
if ( v2 )
{
v7 = *(_QWORD *)(a1 + 16);
result = 0LL;
do
{
v6[(_QWORD)result] = *(_QWORD *)(v7 + 8LL * (_QWORD)result);
result = (char *)result + 1;
}
while ( (void *)v2 != result );
}
v6[v2] = a2;
*(_QWORD *)(a1 + 16) = v6;
return result;
}

canonical_decompiled_code:
void *__fastcall func4(__int64 a1, __int64 a2)
{
unsigned int v2; // er12
__int64 v4; // rdi
void *result; // rax
_QWORD *v6; // rcx
__int64 v7; // rdi

v2 = *(_DWORD *)(a1 + 24);
v4 = v2 + 1;
*(_DWORD *)(a1 + 24) = v4;
result = malloc(8 * v4);
v6 = result;
if ( v2 )
{
v7 = *(_QWORD *)(a1 + 16);
result = 0LL;
do
{
v6[(_QWORD)result] = *(_QWORD *)(v7 + 8LL * (_QWORD)result);
result = (char *)result + 1;
}
while ( (void *)v2 != result );
}
v6[v2] = a2;
*(_QWORD *)(a1 + 16) = v6;
return result;
}

original_code:
void programOptionsAddFile(programOptions po, char* filename)
{
 ++po->filesCount;
 char** tmp = (char**) malloc(sizeof(char*) * po->filesCount);
 for (int i = 0; i < po->filesCount - 1; ++i)
  tmp[i] = po->filesNames[i];
 tmp[po->filesCount - 1] = filename;
 po->filesNames = tmp;
}

canonical_original_code:
void programOptionsAddFile(struct programOptions *po, char *filename)
{
 ++po->filesCount;
 char **tmp = (char**) malloc(sizeof(char*) * po->filesCount);
 for (int i = 0; i < po->filesCount - 1; ++i)
  tmp[i] = po->filesNames[i];
 tmp[po->filesCount - 1] = filename;
 po->filesNames = tmp;
}

variable_types:
filename
char *

variable_types:
tmp
char **

variable_types: i int


programOptionsSetArchiveName

decompiled_code:
void __fastcall programOptionsSetArchiveName(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void programOptionsSetArchiveName(programOptions po, char* archiveName)
{
 po->archiveFilename = archiveName;
}

canonical_original_code:
void programOptionsSetArchiveName(struct programOptions *po, char *archiveName)
{
 po->archiveFilename = archiveName;
}

variable_types:
archiveName
char *


programOptionsGetArchiveName

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

result = *(_QWORD *)(a1 + 8);
if ( !result )
{
v2 = malloc(0x64uLL);
*(_QWORD *)(a1 + 8) = v2;
_isoc99_scanf(&unk_1AB, v2);
result = *(_QWORD *)(a1 + 8);
}
return result;
}

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

result = *(_QWORD *)(a1 + 8);
if ( !result )
{
v2 = malloc(0x64uLL);
*(_QWORD *)(a1 + 8) = v2;
_isoc99_scanf(&unk_1AB, v2);
result = *(_QWORD *)(a1 + 8);
}
return result;
}

original_code:
char* programOptionsGetArchiveName(programOptions po)
{
 if (po->archiveFilename == ((void *)0))
 {
  po->archiveFilename = (char*) malloc(100 * sizeof(char));
  scanf("%s", po->archiveFilename);
 }
 return po->archiveFilename;
}

canonical_original_code:
char *programOptionsGetArchiveName(struct programOptions *po)
{
 if (po->archiveFilename == ((void *)0))
 {
  po->archiveFilename = (char *) malloc(100 * sizeof(char));
  scanf("%s", po->archiveFilename);
 }
 return po->archiveFilename;
}

return_type: char *


programOptionsGetFilesName

decompiled_code:
__int64 __fastcall programOptionsGetFilesName(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
char** programOptionsGetFilesName(programOptions po)
{
 return po->filesNames;
}

canonical_original_code:
char **programOptionsGetFilesName(struct programOptions *po)
{
 return po->filesNames;
}

return_type: char **


programOptionsGetFilesCount

decompiled_code:
__int64 __fastcall programOptionsGetFilesCount(__int64 a1)
{
return *(unsigned int *)(a1 + 24);
}

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

original_code:
unsigned int programOptionsGetFilesCount(programOptions po)
{
 return po->filesCount;
}

canonical_original_code:
unsigned int programOptionsGetFilesCount(struct programOptions *po)
{
 return po->filesCount;
}


programOptionsGetVerbose

decompiled_code:
__int64 __fastcall programOptionsGetVerbose(__int64 a1)
{
return *(unsigned int *)(a1 + 28);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return *(unsigned int *)(a1 + 28);
}

original_code:
unsigned int programOptionsGetVerbose(programOptions po)
{
 return po->verbose;
}

canonical_original_code:
unsigned int programOptionsGetVerbose(struct programOptions *po)
{
 return po->verbose;
}


programOptionsSetVerbose

decompiled_code:
void __fastcall programOptionsSetVerbose(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 28) = a2;
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 28) = a2;
}

original_code:
void programOptionsSetVerbose(programOptions po, unsigned int verbose)
{
 po->verbose = verbose;
}

canonical_original_code:
void programOptionsSetVerbose(struct programOptions *po, unsigned int verbose)
{
 po->verbose = verbose;
}

variable_types:
verbose
unsigned int


programOptionsSetGZip

decompiled_code:
void __fastcall programOptionsSetGZip(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 32) = a2;
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 32) = a2;
}

original_code:
void programOptionsSetGZip(programOptions po, unsigned int gzip)
{
 po->gzip = gzip;
}

canonical_original_code:
void programOptionsSetGZip(struct programOptions *po, unsigned int gzip)
{
 po->gzip = gzip;
}

variable_types:
gzip
unsigned int


programOptionsGetGZip

decompiled_code:
__int64 __fastcall programOptionsGetGZip(__int64 a1)
{
return *(unsigned int *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
return *(unsigned int *)(a1 + 32);
}

original_code:
unsigned int programOptionsGetGZip(programOptions po)
{
 return po->gzip;
}

canonical_original_code:
unsigned int programOptionsGetGZip(struct programOptions *po)
{
 return po->gzip;
}


programOptionsSetSparse

decompiled_code:
void __fastcall programOptionsSetSparse(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 36) = a2;
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 36) = a2;
}

original_code:
void programOptionsSetSparse(programOptions po, unsigned int sparse)
{
 po->sparse = sparse;
}

canonical_original_code:
void programOptionsSetSparse(struct programOptions *po, unsigned int sparse)
{
 po->sparse = sparse;
}

variable_types:
sparse
unsigned int


multipleCommandError

decompiled_code:
void __noreturn multipleCommandError()
{
fwrite("Multiple commands found\n", 1uLL, 0x18uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func14()
{
fwrite("Multiple commands found\n", 1uLL, 0x18uLL, stderr);
exit(1);
}

original_code:
void multipleCommandError()
{
 fprintf(stderr, "Multiple commands found\n");
 exit(1);
}


usage

decompiled_code:
void __noreturn usage()
{
puts("Usage: par <operation> [options]");
puts("For more help, type : par -h ");
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
puts("Usage: par <operation> [options]");
puts("For more help, type : par -h ");
exit(1);
}

original_code:
void usage()
{
 printf("Usage: par <operation> [options]\n");
 printf("For more help, type : par -h \n");
 exit(1);
}


repo: agalakhov/lr-experiments

decompiled_code:
__int64 __fastcall strarr_destroy(__int64 a1)
{
unsigned __int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( *(_QWORD *)(a1 + 8) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2++ + 16);
result = rcunref(v3);
}
while ( *(_QWORD *)(a1 + 8) > v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
unsigned __int64 v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( *(_QWORD *)(a1 + 8) )
{
v2 = 0LL;
do
{
v3 = *(_QWORD *)(a1 + 8 * v2++ + 16);
result = rcunref(v3);
}
while ( *(_QWORD *)(a1 + 8) > v2 );
}
return result;
}

original_code:
static void
strarr_destroy(void *ptr)
{
    strarr_t arr = (strarr_t) ptr;
    size_t i;
    for (i = 0; i < arr->size; ++i)
        rcunref((void*)arr->data[i]);
}

canonical_original_code:
static void strarr_destroy(void *ptr)
{
    struct strarr *arr = (strarr_t) ptr;
    unsigned long i;
    for (i = 0; i < arr->size; ++i)
        rcunref((void *)arr->data[i]);
}

variable_types:
ptr
void *

variable_types: struct strarr { unsigned long space; unsigned long size; char *data[]; } *

variable_types:
i
unsigned long


decompiled_code:
__int64 __fastcall strarr_push(__int64 *a1, __int64 a2)
{
__int64 v2; // rbp
unsigned __int64 v3; // rdx
unsigned __int64 v4; // rax
__int64 v5; // rdx

v2 = (__int64)a1;
v3 = *a1;
v4 = a1[1] + 1;
a1[1] = v4;
if ( v4 > v3 )
{
v5 = 2 * v3;
*a1 = v5;
v2 = rcrealloc_free(a1, 8 * v5 + 16, strarr_destroy);
if ( !v2 )
return 0LL;
}
rcref(a2);
*(_QWORD *)(v2 + 8LL * *(_QWORD *)(v2 + 8) + 8) = a2;
return v2;
}

original_code:
strarr_t
strarr_push(strarr_t arr, const char *str)
{
    ++(arr->size);
    if (arr->size > arr->space) {
        arr->space *= 2;
        arr = (strarr_t)rcrealloc_free(arr, sizeof(struct strarr) + arr->space * (sizeof(const char*)), strarr_destroy);
        if (! arr)
            return ((void *)0);
    }
    rcref((void*)str);
    arr->data[arr->size - 1] = str;
    return arr;
}

canonical_original_code:
struct strarr *strarr_push(struct strarr *arr, char *str)
{
    ++(arr->size);
    if (arr->size > arr->space) {
        arr->space *= 2;
        arr = (struct strarr *)rcrealloc_free(arr, sizeof(struct strarr) + arr->space * (sizeof(char *)), strarr_destroy);
        if (! arr)
            return ((void *)0);
    }
    rcref((void *)str);
    arr->data[arr->size - 1] = str;
    return arr;
}

variable_types:
arr
struct strarr *

variable_types:
str
char *

return_type: struct strarr { unsigned long space; unsigned long size; char *data[]; } *


decompiled_code:
__int64 __fastcall strarr_data(__int64 a1)
{
return a1 + 16;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return a1 + 16;
}

original_code:
const char **
strarr_data(strarr_t arr)
{
    return arr->data;
}

canonical_original_code:
char **strarr_data(struct strarr *arr)
{
    return arr->data;
}

user_defined_types: struct strarr { unsigned long space; unsigned long size; char *data[]; }


decompiled_code:
__int64 __fastcall strarr_size(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
size_t
strarr_size(strarr_t arr)
{
    return arr->size;
}

canonical_original_code:
unsigned long strarr_size(struct strarr *arr)
{
    return arr->size;
}

return_type: unsigned long


decompiled_code:
// attributes: thunk
__int64 __fastcall strarr_ref(__int64 a1)
{
return rcref(a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return rcref(a1);
}

original_code:
void
strarr_ref(strarr_t arr)
{
    rcref(arr);
}

canonical_original_code:
void strarr_ref(struct strarr *arr)
{
    rcref(arr);
}


decompiled_code:
__int64 __fastcall strarr_unref(__int64 a1)
{
return rcunref_free(a1, strarr_destroy);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return rcunref_free(a1, strarr_destroy);
}

original_code:
void
strarr_unref(strarr_t arr)
{
    rcunref_free(arr, strarr_destroy);
}

canonical_original_code:
void strarr_unref(struct strarr *arr)
{
    rcunref_free(arr, strarr_destroy);
}


decompiled_code:
// attributes: thunk
int do_print(const char *format, __gnuc_va_list arg)
{
return vprintf(format, arg);
}

canonical_decompiled_code:
int func0(const char *format, __gnuc_va_list arg)
{
return vprintf(format, arg);
}

original_code:
static void
do_print(const char *fmt, va_list ap)
{
    vprintf(fmt, ap);
}

canonical_original_code:
static void do_print(char *fmt, __builtin_va_list ap)
{
    vprintf(fmt, ap);
}

variable_types:
fmt
char *


canonical_decompiled_code:
void func1(void)
{
set_free(options);
}

original_code:
static void
print_options_free(void)
{
    set_free(options);
}

canonical_original_code:
static void print_options_free()
{
    set_free(options);
}


decompiled_code:
__int64 __fastcall print_opt(unsigned int a1)
{
return set_has(options, a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return set_has(options, a1);
}

original_code:
_Bool
print_opt(enum print opt)
{
    return set_has(options, opt);
}

variable_types: enum print { P_GRAMMAR=0, P_SYMBOLS=1, P_NULLABLE=2, P_LR0_KERNELS=3, P_LR0_CLOSURES=4, P_LR0_GOTO=5, P_LR_REDUCE=6, P_MAX_=7 }


print

decompiled_code:
int print(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
return do_print(a1, arg);
}

canonical_decompiled_code:
int func3(const char *a1, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a1);
return func0(a1, arg);
}

original_code:
void
print(const char *fmt, ...)
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    do_print(fmt, ap);
    __builtin_va_end(ap);
}

canonical_original_code:
void print(char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    do_print(fmt, ap);
    __builtin_va_end(ap);
}


printo

decompiled_code:
int printo(unsigned int a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
result = print_opt(a1);
if ( (_BYTE)result )
result = do_print(a2, arg);
return result;
}

canonical_decompiled_code:
int func4(unsigned int a1, const char *a2, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
result = func2(a1);
if ( (_BYTE)result )
result = func0(a2, arg);
return result;
}

original_code:
void
printo(enum print opt, const char *fmt, ...)
{
    va_list ap;
    __builtin_va_start(ap,fmt);
    if (print_opt(opt))
        do_print(fmt, ap);
    __builtin_va_end(ap);
}

canonical_original_code:
void printo(enum print opt, char *fmt, ...)
{
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    if (print_opt(opt))
        do_print(fmt, ap);
    __builtin_va_end(ap);
}

user_defined_types: enum print { P_GRAMMAR=0, P_SYMBOLS=1, P_NULLABLE=2, P_LR0_KERNELS=3, P_LR0_CLOSURES=4, P_LR0_GOTO=5, P_LR_REDUCE=6, P_MAX_=7 }


decompiled_code:
__int64 __fastcall print_options(char *s)
{
char *v1; // rbp
__int64 v2; // r13
char *v3; // r12
unsigned __int64 v4; // rcx
unsigned int *v5; // r15
const char *j; // rdi
__int64 v7; // rsi
__int64 v8; // rsi
int k; // ebx
__int64 result; // rax
__int64 v11; // rsi
unsigned int i; // ebx
__int64 v13; // rsi

v1 = s;
if ( options )
set_free(options);
options = set_alloc(7LL);
v2 = options;
if ( !options )
print_options_cold();
atexit(print_options_free);
if ( *s )
{
while ( 1 )
{
v3 = strchr(v1, 44);
if ( !v3 )
v3 = &v1[strlen(v1)];
v4 = 4LL;
if ( (unsigned __int64)(v3 - v1) <= 4 )
v4 = v3 - v1;
if ( !memcmp("all", v1, v4) )
{
for ( i = 0; i != 7; ++i )
{
v13 = i;
set_add(v2, v13);
v2 = options;
}
break;
}
v5 = (unsigned int *)&unk_3E8;
for ( j = "grammar"; strncmp(j, v1, v3 - v1); j = (const char *)*((_QWORD *)v5 - 1) )
{
v5 += 4;
if ( v5 == (unsigned int *)&unk_458 )
goto LABEL_15;
LABEL_12:
;
}
v7 = *v5;
v5 += 4;
set_add(v2, v7);
v2 = options;
if ( v5 != (unsigned int *)&unk_458 )
goto LABEL_12;
LABEL_15:
if ( *v3 )
{
v1 = v3 + 1;
if ( v3[1] )
continue;
}
break;
}
}
v8 = 4LL;
for ( k = 0; ; v8 = (unsigned int)prdepends[k] )
{
result = set_has(v2, v8);
if ( (_BYTE)result )
break;
if ( (unsigned int)++k > 8 )
return result;
LABEL_18:
v2 = options;
}
while ( 1 )
{
result = (unsigned int)(k + 1);
v11 = (unsigned int)prdepends[result];
++k;
if ( (_DWORD)v11 == 7 )
break;
set_add(options, v11);
}
if ( (unsigned int)++k <= 8 )
goto LABEL_18;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s)
{
char *v1; // rbp
__int64 v2; // r13
char *v3; // r12
unsigned __int64 v4; // rcx
unsigned int *v5; // r15
const char *j; // rdi
__int64 v7; // rsi
__int64 v8; // rsi
int k; // ebx
__int64 result; // rax
__int64 v11; // rsi
unsigned int i; // ebx
__int64 v13; // rsi

v1 = s;
if ( options )
set_free(options);
options = set_alloc(7LL);
v2 = options;
if ( !options )
func6();
atexit(print_options_free);
if ( *s )
{
while ( 1 )
{
v3 = strchr(v1, 44);
if ( !v3 )
v3 = &v1[strlen(v1)];
v4 = 4LL;
if ( (unsigned __int64)(v3 - v1) <= 4 )
v4 = v3 - v1;
if ( !memcmp("all", v1, v4) )
{
for ( i = 0; i != 7; ++i )
{
v13 = i;
set_add(v2, v13);
v2 = options;
}
break;
}
v5 = (unsigned int *)&unk_3E8;
for ( j = "grammar"; strncmp(j, v1, v3 - v1); j = (const char *)*((_QWORD *)v5 - 1) )
{
v5 += 4;
if ( v5 == (unsigned int *)&unk_458 )
goto LABEL_15;
LABEL_12:
;
}
v7 = *v5;
v5 += 4;
set_add(v2, v7);
v2 = options;
if ( v5 != (unsigned int *)&unk_458 )
goto LABEL_12;
LABEL_15:
if ( *v3 )
{
v1 = v3 + 1;
if ( v3[1] )
continue;
}
break;
}
}
v8 = 4LL;
for ( k = 0; ; v8 = (unsigned int)prdepends[k] )
{
result = set_has(v2, v8);
if ( (_BYTE)result )
break;
if ( (unsigned int)++k > 8 )
return result;
LABEL_18:
v2 = options;
}
while ( 1 )
{
result = (unsigned int)(k + 1);
v11 = (unsigned int)prdepends[result];
++k;
if ( (_DWORD)v11 == 7 )
break;
set_add(options, v11);
}
if ( (unsigned int)++k <= 8 )
goto LABEL_18;
return result;
}

original_code:
void
print_options(const char *opts)
{
    if (options)
        set_free(options);
    options = set_alloc(P_MAX_);
    if (! options)
        abort();
    atexit(print_options_free);
    const char *end;
    while (*opts) {
        end = strchr(opts, ',');
        if (! end)
            end = opts + strlen(opts);
        if (! strncmp("all", opts, end - opts)) {
            for (unsigned i = 0; i < P_MAX_; ++i)
                set_add(options, i);
            break;
        }
        for (unsigned i = 0; i < (sizeof(propts)/sizeof(propts[0])); ++i) {
            if (! strncmp(propts[i].name, opts, end - opts))
                set_add(options, propts[i].flag);
        }
        opts = end;
        if (*opts)
            ++opts;
    }
    for (unsigned i = 0; i < (sizeof(prdepends)/sizeof(prdepends[0])); ++i) {
        if (set_has(options, prdepends[i])) {
            for (++i; prdepends[i] != P_MAX_; ++i)
                set_add(options, prdepends[i]);
        }
    }
}

canonical_original_code:
void print_options(char *opts)
{
    if (options)
        set_free(options);
    options = set_alloc(P_MAX_);
    if (! options)
        abort();
    atexit(print_options_free);
    char *end;
    while (*opts) {
        end = strchr(opts, ',');
        if (! end)
            end = opts + strlen(opts);
        if (! strncmp("all", opts, end - opts)) {
            for (unsigned int i = 0; i < P_MAX_; ++i)
                set_add(options, i);
            break;
        }
        for (unsigned int i = 0; i < (sizeof(propts)/sizeof(propts[0])); ++i) {
            if (! strncmp(propts[i].name, opts, end - opts))
                set_add(options, propts[i].flag);
        }
        opts = end;
        if (*opts)
            ++opts;
    }
    for (unsigned int i = 0; i < (sizeof(prdepends)/sizeof(prdepends[0])); ++i) {
        if (set_has(options, prdepends[i])) {
            for (++i; prdepends[i] != P_MAX_; ++i)
                set_add(options, prdepends[i]);
        }
    }
}

variable_types:
opts
char *

variable_types:
end
char *

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall sizeof_struct_bucket(__int64 a1)
{
return a1 + 17;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1 + 17;
}

original_code:
static inline size_t sizeof_struct_bucket(size_t len) {
    return sizeof(struct bucket) + len + 1;
}

canonical_original_code:
static inline unsigned long sizeof_struct_bucket(unsigned long len) {
    return sizeof(struct bucket) + len + 1;
}

variable_types:
len
unsigned long

user_defined_types: struct bucket { struct bucket *next; void *payload; char key[]; }


hashfunc

decompiled_code:
__int64 __fastcall hashfunc(_BYTE *a1)
{
int v1; // eax
int v2; // edx

v1 = (char)*a1;
if ( !*a1 )
return 197LL;
v2 = -2128831035;
do
{
++a1;
v2 = 16777619 * (v2 ^ v1);
v1 = (char)*a1;
}
while ( *a1 );
return (unsigned __int8)((unsigned __int16)(v2 ^ HIWORD(v2)) >> 8) ^ (unsigned int)(unsigned __int8)(v2 ^ BYTE2(v2));
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
int v1; // eax
int v2; // edx

v1 = (char)*a1;
if ( !*a1 )
return 197LL;
v2 = -2128831035;
do
{
++a1;
v2 = 16777619 * (v2 ^ v1);
v1 = (char)*a1;
}
while ( *a1 );
return (unsigned __int8)((unsigned __int16)(v2 ^ HIWORD(v2)) >> 8) ^ (unsigned int)(unsigned __int8)(v2 ^ BYTE2(v2));
}

original_code:
static unsigned
hashfunc(const char *str)
{
    uint32_t hsh = 2166136261;
    for (; *str; ++str) {
        hsh ^= *str;
        hsh *= 16777619;
    }
    hsh ^= (hsh >> 16);
    hsh &= 0xFFFF;
    hsh ^= (hsh >> 8);
    return hsh % 256;
}

canonical_original_code:
static unsigned int hashfunc(char *str)
{
    unsigned int hsh = 2166136261;
    for (; *str; ++str) {
        hsh ^= *str;
        hsh *= 16777619;
    }
    hsh ^= (hsh >> 16);
    hsh &= 0xFFFF;
    hsh ^= (hsh >> 8);
    return hsh % 256;
}

variable_types:
hsh
unsigned int


equals

decompiled_code:
bool __fastcall equals(const char *a1, const char *a2)
{
bool result; // al

if ( a1 == a2 )
result = 1;
else
result = strcmp(a1, a2) == 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func2(const char *a1, const char *a2)
{
bool result; // al

if ( a1 == a2 )
result = 1;
else
result = strcmp(a1, a2) == 0;
return result;
}

original_code:
static _Bool
equals(const char *s1, const char *s2)
{
    return (s1 == s2) || (strcmp(s1, s2) == 0);
}

canonical_original_code:
static _Bool equals(char *s1, char *s2)
{
    return (s1 == s2) || (strcmp(s1, s2) == 0);
}


decompiled_code:
void *strhash_alloc()
{
return calloc(1uLL, 0x800uLL);
}

canonical_decompiled_code:
void *func3()
{
return calloc(1uLL, 0x800uLL);
}

original_code:
strhash_t
strhash_alloc(void)
{
    return (strhash_t)calloc(1, sizeof(struct strhash));
}

canonical_original_code:
struct strhash *strhash_alloc()
{
    return (struct strhash *)calloc(1, sizeof(struct strhash));
}

return_type: struct strhash { struct bucket { struct bucket *next; void *payload; char key[]; } *buckets[256]; } *

user_defined_types: struct strhash { struct bucket *buckets[256]; }


decompiled_code:
void __fastcall strhash_free(void *ptr, void (__fastcall *a2)(_QWORD))
{
_QWORD *v2; // r13
_QWORD *v3; // rbx
_QWORD *v4; // rbp

v2 = ptr;
do
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
if ( a2 )
a2(v4[1]);
free(v4);
}
while ( v3 );
}
++v2;
}
while ( v2 != (_QWORD *)((char *)ptr + 2048) );
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr, void (__fastcall *a2)(_QWORD))
{
_QWORD *v2; // r13
_QWORD *v3; // rbx
_QWORD *v4; // rbp

v2 = ptr;
do
{
v3 = (_QWORD *)*v2;
if ( *v2 )
{
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
if ( a2 )
a2(v4[1]);
free(v4);
}
while ( v3 );
}
++v2;
}
while ( v2 != (_QWORD *)((char *)ptr + 2048) );
free(ptr);
}

original_code:
void
strhash_free(strhash_t hash, hash_free_func_t freefunc)
{
    for (unsigned i = 0; i < 256; ++i) {
        struct bucket *b = hash->buckets[i];
        while (b) {
            struct bucket *n = b->next;
            if (freefunc)
                freefunc(b->payload);
            free(b);
            b = n;
        }
    }
    free(hash);
}

canonical_original_code:
void strhash_free(struct strhash *hash, void (*freefunc)(void *))
{
    for (unsigned int i = 0; i < 256; ++i) {
        struct bucket *b = hash->buckets[i];
        while (b) {
            struct bucket *n = b->next;
            if (freefunc)
                freefunc(b->payload);
            free(b);
            b = n;
        }
    }
    free(hash);
}

variable_types: struct strhash { struct bucket { struct bucket *next; void *payload; char key[]; } *buckets[256]; } *

variable_types:
freefunc
void (*)(void *)


decompiled_code:
char *__fastcall strhash_find(__int64 a1, char *a2)
{
__int64 v2; // rbp
char *v3; // r13
char *v4; // r12
__int64 v6; // r15
__int64 v7; // rax
char *v8; // rax

v2 = (unsigned int)hashfunc(a2);
v3 = *(char **)(a1 + 8 * v2);
v4 = v3;
if ( v3 )
{
while ( !equals(a2, v4 + 16) )
{
v4 = *(char **)v4;
if ( !v4 )
goto LABEL_7;
}
}
else
{
LABEL_7:
v6 = strlen(a2);
v7 = sizeof_struct_bucket(v6);
v8 = (char *)calloc(1uLL, v7);
v4 = v8;
if ( !v8 )
return v4;
memcpy(v8 + 16, a2, v6 + 1);
*(_QWORD *)v4 = v3;
*(_QWORD *)(a1 + 8 * v2) = v4;
}
v4 += 8;
return v4;
}

original_code:
void **
strhash_find(strhash_t hash, const char *key)
{
    unsigned hsh = hashfunc(key);
    struct bucket * b = hash->buckets[hsh];
    for ( ; b && ! equals(key, b->key); b = b->next)
        ;
    if (! b) {
        b = calloc(1, sizeof_struct_bucket(strlen(key)));
        if (! b)
            return ((void *)0);
        strcpy(b->key, key);
        b->next = hash->buckets[hsh];
        hash->buckets[hsh] = b;
    }
    return &b->payload;
}

canonical_original_code:
void **strhash_find(struct strhash *hash, char *key)
{
    unsigned int hsh = hashfunc(key);
    struct bucket *b = hash->buckets[hsh];
    for ( ; b && ! equals(key, b->key); b = b->next)
        ;
    if (! b) {
        b = calloc(1, sizeof_struct_bucket(strlen(key)));
        if (! b)
            return ((void *)0);
        strcpy(b->key, key);
        b->next = hash->buckets[hsh];
        hash->buckets[hsh] = b;
    }
    return &b->payload;
}

variable_types:
key
char *

variable_types: struct bucket { struct bucket *next; void *payload; char key[]; } *

return_type: void **


decompiled_code:
__int64 __fastcall sizeof_struct_bitset(__int64 a1)
{
return 8 * a1 + 8;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return 8 * a1 + 8;
}

original_code:
static inline size_t sizeof_struct_bitset(size_t max) {
    return sizeof(struct bitset) + max * sizeof(unsigned long);
}

canonical_original_code:
static inline unsigned long sizeof_struct_bitset(unsigned long max) {
    return sizeof(struct bitset) + max * sizeof(unsigned long);
}

variable_types:
max
unsigned long

user_defined_types: struct bitset { unsigned long max; unsigned long data[]; }


decompiled_code:
// attributes: thunk
void set_free(void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void func1(void *ptr)
{
free(ptr);
}

original_code:
void
set_free(bitset_t set)
{
    free(set);
}

canonical_original_code:
void set_free(struct bitset *set)
{
    free(set);
}

variable_types: struct bitset { unsigned long max; unsigned long data[]; } *


decompiled_code:
__int64 __fastcall set_has(_QWORD *a1, unsigned int a2)
{
unsigned int v2; // er8

v2 = 0;
if ( (unsigned __int64)a2 < *a1 << 6 )
LOBYTE(v2) = (a1[(a2 >> 6) + 1] & (1 << a2)) != 0LL;
return v2;
}

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

v2 = 0;
if ( (unsigned __int64)a2 < *a1 << 6 )
LOBYTE(v2) = (a1[(a2 >> 6) + 1] & (1 << a2)) != 0LL;
return v2;
}

original_code:
_Bool
set_has(bitset_t set, unsigned x)
{
    if (x >= set->max * (8 * sizeof(unsigned long)))
        return 0;
    size_t idx = x / (8 * sizeof(unsigned long));
    size_t bit = x % (8 * sizeof(unsigned long));
    return !! (set->data[idx] & (1 << bit));
}

canonical_original_code:
_Bool set_has(struct bitset *set, unsigned int x)
{
    if (x >= set->max * (8 * sizeof(unsigned long)))
        return 0;
    unsigned long idx = x / (8 * sizeof(unsigned long));
    unsigned long bit = x % (8 * sizeof(unsigned long));
    return !! (set->data[idx] & (1 << bit));
}

variable_types:
x
unsigned int

variable_types:
idx
unsigned long

variable_types:
bit
unsigned long


decompiled_code:
__int64 __fastcall set_add(_QWORD *a1, unsigned int a2)
{
unsigned int v2; // er8
char v3; // cl
__int64 v4; // rdx
__int64 v5; // rsi
__int64 v6; // rax

v2 = 0;
v3 = a2;
if ( (unsigned __int64)a2 < *a1 << 6 )
{
v4 = a2 >> 6;
v5 = a1[v4 + 1];
v6 = v5 | (1 << v3);
a1[v4 + 1] = v6;
LOBYTE(v2) = v6 != v5;
}
return v2;
}

original_code:
_Bool
set_add(bitset_t set, unsigned x)
{
    if (x >= set->max * (8 * sizeof(unsigned long)))
        return 0;
    size_t idx = x / (8 * sizeof(unsigned long));
    size_t bit = x % (8 * sizeof(unsigned long));
    unsigned long old = set->data[idx];
    set->data[idx] |= (1 << bit);
    return (set->data[idx] != old);
}

canonical_original_code:
_Bool set_add(struct bitset *set, unsigned int x)
{
    if (x >= set->max * (8 * sizeof(unsigned long)))
        return 0;
    unsigned long idx = x / (8 * sizeof(unsigned long));
    unsigned long bit = x % (8 * sizeof(unsigned long));
    unsigned long old = set->data[idx];
    set->data[idx] |= (1 << bit);
    return (set->data[idx] != old);
}

variable_types:
old
unsigned long


original_code:
_Bool
set_union(bitset_t set, bitset_t xs)
{
    _Bool ret = 0;
    for (size_t i = 0; i < set->max && i < xs->max; ++i) {
        unsigned long old = set->data[i];
        set->data[i] |= xs->data[i];
        ret = ret || (set->data[i] != old);
    }
    return ret;
}

canonical_original_code:
_Bool set_union(struct bitset *set, struct bitset *xs)
{
    _Bool ret = 0;
    for (unsigned long i = 0; i < set->max && i < xs->max; ++i) {
        unsigned long old = set->data[i];
        set->data[i] |= xs->data[i];
        ret = ret || (set->data[i] != old);
    }
    return ret;
}

variable_types:
xs
struct bitset *

variable_types:
i
unsigned long


original_code:
size_t
set_size(bitset_t set)
{
    static const unsigned long mask[] = {
        (unsigned long) 0x5555555555555555,
        (unsigned long) 0x3333333333333333,
        (unsigned long) 0x0F0F0F0F0F0F0F0F,
        (unsigned long) 0x00FF00FF00FF00FF,
        (unsigned long) 0x0000FFFF0000FFFF,
        (unsigned long) 0x00000000FFFFFFFF,
    };
    size_t ret = 0;
    for (size_t i = 0; i < set->max; ++i) {
        unsigned long cnt = set->data[i];
        for (unsigned j = 0; (1u << j) < (8 * sizeof(unsigned long)); ++j)
            cnt = (cnt & mask[j]) + ((cnt >> (1u << j)) & mask[j]);
        ret += cnt;
    }
    return ret;
}

canonical_original_code:
unsigned long set_size(struct bitset *set)
{
    static unsigned long mask[] = {
        (unsigned long) 0x5555555555555555,
        (unsigned long) 0x3333333333333333,
        (unsigned long) 0x0F0F0F0F0F0F0F0F,
        (unsigned long) 0x00FF00FF00FF00FF,
        (unsigned long) 0x0000FFFF0000FFFF,
        (unsigned long) 0x00000000FFFFFFFF,
    };
    unsigned long ret = 0;
    for (unsigned long i = 0; i < set->max; ++i) {
        unsigned long cnt = set->data[i];
        for (unsigned int j = 0; (1u << j) < (8 * sizeof(unsigned long)); ++j)
            cnt = (cnt & mask[j]) + ((cnt >> (1u << j)) & mask[j]);
        ret += cnt;
    }
    return ret;
}

variable_types:
mask
unsigned long []

variable_types:
ret
unsigned long

variable_types:
cnt
unsigned long

variable_types:
j
unsigned int


decompiled_code:
__int64 __fastcall sizeof_struct_array(__int64 a1, __int64 a2)
{
return a2 * a1 + 32;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return a2 * a1 + 32;
}

original_code:
static inline size_t sizeof_struct_array(size_t size, size_t elem_size) {
    return sizeof(struct array) + size * elem_size;
}

canonical_original_code:
static inline unsigned long sizeof_struct_array(unsigned long size, unsigned long elem_size) {
    return sizeof(struct array) + size * elem_size;
}

variable_types:
size
unsigned long

user_defined_types: struct array { void (*freefunc)(void *); unsigned long elem_size; unsigned long space; unsigned long size; char data[]; }


original_code:
array_t
array_push(array_t array, void *elem)
{
    ++(array->size);
    if (array->size > array->space) {
        array->space *= 2;
        array = rcrealloc_free(array, sizeof_struct_array(array->space, array->elem_size), array_destroy);
        if (! array)
            return ((void *)0);
    }
    memcpy(array->data + ((array->size - 1) * array->elem_size), elem, array->elem_size);
    return array;
}

canonical_original_code:
struct array *array_push(struct array *array, void *elem)
{
    ++(array->size);
    if (array->size > array->space) {
        array->space *= 2;
        array = rcrealloc_free(array, sizeof_struct_array(array->space, array->elem_size), array_destroy);
        if (! array)
            return ((void *)0);
    }
    memcpy(array->data + ((array->size - 1) * array->elem_size), elem, array->elem_size);
    return array;
}

variable_types:
array
struct array *

variable_types:
elem
void *

return_type: struct array { void (*freefunc)(void *); unsigned long elem_size; unsigned long space; unsigned long size; char data[]; } *


decompiled_code:
__int64 __fastcall array_data(__int64 a1)
{
return a1 + 32;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return a1 + 32;
}

original_code:
void *
array_data(array_t array)
{
    return array->data;
}

canonical_original_code:
void *array_data(struct array *array)
{
    return array->data;
}

variable_types: struct array { void (*freefunc)(void *); unsigned long elem_size; unsigned long space; unsigned long size; char data[]; } *

return_type: void *


decompiled_code:
__int64 __fastcall array_size(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

original_code:
size_t
array_size(array_t array)
{
    return array->size;
}

canonical_original_code:
unsigned long array_size(struct array *array)
{
    return array->size;
}


decompiled_code:
// attributes: thunk
__int64 array_ref()
{
return rcref();
}

canonical_decompiled_code:
__int64 func4()
{
return rcref();
}

original_code:
void
array_ref(array_t array)
{
    rcref(array);
}

canonical_original_code:
void array_ref(struct array *array)
{
    rcref(array);
}


decompiled_code:
__int64 __fastcall array_unref(__int64 a1)
{
return rcunref_free(a1, array_destroy);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return rcunref_free(a1, array_destroy);
}

original_code:
void
array_unref(array_t array)
{
    rcunref_free(array, array_destroy);
}

canonical_original_code:
void array_unref(struct array *array)
{
    rcunref_free(array, array_destroy);
}


rcunref

decompiled_code:
void __fastcall rcunref(__int64 a1)
{
rcunref_free(a1, 0LL);
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
func1(a1, 0LL);
}

original_code:
void
rcunref(void *ptr)
{
    rcunref_free(ptr, ((void *)0));
}

variable_types:
ptr
void *


rcrealloc

decompiled_code:
char *__fastcall rcrealloc(__int64 a1, __int64 a2)
{
return rcrealloc_free(a1, a2, 0LL);
}

canonical_decompiled_code:
char *__fastcall func4(__int64 a1, __int64 a2)
{
return func3(a1, a2, 0LL);
}

original_code:
void *
rcrealloc(void *ptr, size_t size)
{
    return rcrealloc_free(ptr, size, ((void *)0));
}

canonical_original_code:
void *rcrealloc(void *ptr, unsigned long size)
{
    return rcrealloc_free(ptr, size, ((void *)0));
}


usage

decompiled_code:
__int64 __fastcall usage(const char *a1)
{
fprintf(
stderr,
"Usage: %s [OPTION]... FILE\n"
"Generate *.c and *.h constant array file from an arbitrary text file.\n"
"\n"
"Options:\n"
" -H FILE.h header file to generate\n"
" -o FILE.c source file to generate\n"
" -s SYMBOL C symbol name\n",
a1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
fprintf(
stderr,
"Usage: %s [OPTION]... FILE\n"
"Generate *.c and *.h constant array file from an arbitrary text file.\n"
"\n"
"Options:\n"
" -H FILE.h header file to generate\n"
" -o FILE.c source file to generate\n"
" -s SYMBOL C symbol name\n",
a1);
return 1LL;
}

original_code:
static int
usage(const char *name)
{
    fprintf(stderr, ""
"Usage: %s [OPTION]... FILE\n"
"Generate *.c and *.h constant array file from an arbitrary text file.\n"
"\n"
"Options:\n"
"  -H FILE.h  header file to generate\n"
"  -o FILE.c  source file to generate\n"
"  -s SYMBOL  C symbol name\n"
            "", name);
    return 1;
}

canonical_original_code:
static int usage(char *name)
{
    fprintf(stderr, ""
"Usage: %s [OPTION]... FILE\n"
"Generate *.c and *.h constant array file from an arbitrary text file.\n"
"\n"
"Options:\n"
"  -H FILE.h  header file to generate\n"
"  -o FILE.c  source file to generate\n"
"  -s SYMBOL  C symbol name\n"
            "", name);
    return 1;
}

variable_types:
name
char *

return_type: int


svgIsCommand

decompiled_code:
__int64 __fastcall svgIsCommand(char a1)
{
__int64 result; // rax
unsigned __int64 v2; // rdx

result = g_atPathCommandFormat;
if ( g_atPathCommandFormat )
{
v2 = (unsigned int)((_DWORD)&g_atPathCommandFormat + 8);
while ( a1 != (_BYTE)result )
{
result = *(unsigned __int8 *)v2;
v2 += 8LL;
if ( !(_BYTE)result )
return result;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
__int64 result; // rax
unsigned __int64 v2; // rdx

result = g_atPathCommandFormat;
if ( g_atPathCommandFormat )
{
v2 = (unsigned int)((_DWORD)&g_atPathCommandFormat + 8);
while ( a1 != (_BYTE)result )
{
result = *(unsigned __int8 *)v2;
v2 += 8LL;
if ( !(_BYTE)result )
return result;
}
result = 1LL;
}
return result;
}

original_code:
char svgIsCommand( char c )
{
 int i;
 for( i = 0; g_atPathCommandFormat[ i ].cCommand!='\0'; i ++ ) {
  if( g_atPathCommandFormat[ i].cCommand==c )
   return 1;
 }
 return 0;
}

canonical_original_code:
char svgIsCommand(char c)
{
 int i;
 for( i = 0; g_atPathCommandFormat[ i ].cCommand!='\0'; i ++ ) {
  if( g_atPathCommandFormat[ i].cCommand==c )
   return 1;
 }
 return 0;
}

variable_types: c char

variable_types: i int

return_type: char


svgGetNextPathField

decompiled_code:
const char *__fastcall svgGetNextPathField(char *a1, char *a2, int a3)
{
signed __int64 v3; // rbp
char *v4; // r14
char *v5; // rax
const char *v6; // r12
char v7; // cl
char v8; // cl
char *v9; // rax
char *v10; // r13
signed __int64 v11; // r13
const char *result; // rax
char *v13; // rax

v3 = a3;
v4 = &a1[a3 - 1];
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
*a2 = 0;
v5 = svgSkipWS(a1, &a1[a3 - 1]);
v6 = v5;
if ( v4 == v5 )
return 0LL;
v7 = *v5;
if ( !*v5 )
return 0LL;
if ( v7 == 44 )
{
v13 = svgSkipWS(v5 + 1, v4);
v6 = v13;
if ( v4 != v13 )
{
v8 = *v13;
if ( *v13 )
goto LABEL_7;
}
return 0LL;
}
if ( (unsigned __int8)svgIsCommand(v7) )
{
*a2 = v8;
result = v6;
a2[1] = 0;
return result;
}
LABEL_7:
v9 = svgSkipDigits((char *)&v6[((v8 - 43) & 0xFD) == 0], v4);
v10 = v9;
if ( v4 != v9 && *v9 == 46 )
v10 = svgSkipDigits(v9 + 1, v4);
v11 = v10 - v6;
if ( v11 >= v3 )
_assert_fail("szEnd - szStart < n", "svg_string.c", 0x32u, "svgGetNextPathField");
strncpy(a2, v6, v11);
a2[v11] = 0;
return v6;
}

canonical_decompiled_code:
const char *__fastcall func3(char *a1, char *a2, int a3)
{
signed __int64 v3; // rbp
char *v4; // r14
char *v5; // rax
const char *v6; // r12
char v7; // cl
char v8; // cl
char *v9; // rax
char *v10; // r13
signed __int64 v11; // r13
const char *result; // rax
char *v13; // rax

v3 = a3;
v4 = &a1[a3 - 1];
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
*a2 = 0;
v5 = func1(a1, &a1[a3 - 1]);
v6 = v5;
if ( v4 == v5 )
return 0LL;
v7 = *v5;
if ( !*v5 )
return 0LL;
if ( v7 == 44 )
{
v13 = func1(v5 + 1, v4);
v6 = v13;
if ( v4 != v13 )
{
v8 = *v13;
if ( *v13 )
goto LABEL_7;
}
return 0LL;
}
if ( (unsigned __int8)func0(v7) )
{
*a2 = v8;
result = v6;
a2[1] = 0;
return result;
}
LABEL_7:
v9 = func2((char *)&v6[((v8 - 43) & 0xFD) == 0], v4);
v10 = v9;
if ( v4 != v9 && *v9 == 46 )
v10 = func2(v9 + 1, v4);
v11 = v10 - v6;
if ( v11 >= v3 )
_assert_fail("szEnd - szStart < n", "svg_string.c", 0x32u, "svgGetNextPathField");
strncpy(a2, v6, v11);
a2[v11] = 0;
return v6;
}

original_code:
const char* svgGetNextPathField( const char *szData, char *szField, int n )
{
 const char *szStart = ((void *)0), *szEnd = ((void *)0), *szEOF = szData + n - 1;
 if( szData==((void *)0) || szField==((void *)0) )
  return ((void *)0);
 szField[ 0 ] = '\0';
 szStart = szData;
 szStart = svgSkipWS(szStart, szEOF);
 if( szStart==szEOF || *szStart=='\0' )
  return ((void *)0);
 if ( *szStart==',' ) {
  szStart ++;
  szStart = svgSkipWS(szStart, szEOF);
  if( szStart==szEOF || *szStart=='\0' )
   return ((void *)0);
 } else if ( svgIsCommand( *szStart ) ) {
  szField[ 0 ] = *szStart;
  szField[ 1 ] = 0;
  return szStart;
 }
 szEnd = szStart;
 if (szEnd != szEOF && ( *szEnd=='-' || *szEnd =='+' ) )
  szEnd ++;
 szEnd = svgSkipDigits( szEnd, szEOF );
 if (szEnd != szEOF && *szEnd == '.') {
  szEnd ++;
  szEnd = svgSkipDigits( szEnd, szEOF );
 }
 ((void) sizeof ((szEnd - szStart < n) ? 1 : 0), __extension__ ({ if (szEnd - szStart < n) ; else __assert_fail ("szEnd - szStart < n", "svg_string.c", 50, __extension__ __PRETTY_FUNCTION__); }));
 strncpy( szField, szStart, ( size_t )( szEnd - szStart ) );
 szField[ szEnd - szStart ] = 0;
 return szStart;
}

canonical_original_code:
char *svgGetNextPathField(char *szData, char *szField, int n)
{
 char *szStart = ((void *)0); char *szEnd = ((void *)0); char *szEOF = szData + n - 1;
 if( szData==((void *)0) || szField==((void *)0) )
  return ((void *)0);
 szField[ 0 ] = '\0';
 szStart = szData;
 szStart = svgSkipWS(szStart, szEOF);
 if( szStart==szEOF || *szStart=='\0' )
  return ((void *)0);
 if ( *szStart==',' ) {
  szStart ++;
  szStart = svgSkipWS(szStart, szEOF);
  if( szStart==szEOF || *szStart=='\0' )
   return ((void *)0);
 } else if ( svgIsCommand( *szStart ) ) {
  szField[ 0 ] = *szStart;
  szField[ 1 ] = 0;
  return szStart;
 }
 szEnd = szStart;
 if (szEnd != szEOF && ( *szEnd=='-' || *szEnd =='+' ) )
  szEnd ++;
 szEnd = svgSkipDigits( szEnd, szEOF );
 if (szEnd != szEOF && *szEnd == '.') {
  szEnd ++;
  szEnd = svgSkipDigits( szEnd, szEOF );
 }
 ((void) sizeof ((szEnd - szStart < n) ? 1 : 0), __extension__ ({ if (szEnd - szStart < n) ; else __assert_fail ("szEnd - szStart < n", "svg_string.c", 50, __extension__ __PRETTY_FUNCTION__); }));
 strncpy( szField, szStart, ( unsigned long )( szEnd - szStart ) );
 szField[ szEnd - szStart ] = 0;
 return szStart;
}

variable_types:
szData
char *

variable_types:
szField
char *

variable_types: n int

variable_types:
szStart
char *

variable_types:
szEnd
char *

variable_types:
szEOF
char *


svgGetNextPointField

decompiled_code:
char *__fastcall svgGetNextPointField(char *a1, char *a2, int a3)
{
signed __int64 v3; // r13
char *v4; // r14
char *v5; // rax
char *v6; // r12
char v7; // al
char *v8; // rax
char *v9; // rbp
signed __int64 v10; // rbp
char *v12; // rax

v3 = a3;
v4 = &a1[a3 - 1];
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
*a2 = 0;
v5 = svgSkipWS(a1, &a1[a3 - 1]);
v6 = v5;
if ( v4 == v5 )
return 0LL;
v7 = *v5;
if ( !v7 )
return 0LL;
if ( v7 == 44 )
{
v12 = svgSkipWS(v6 + 1, v4);
v6 = v12;
if ( v4 == v12 )
return 0LL;
v7 = *v12;
if ( !v7 )
return 0LL;
}
v8 = svgSkipDigits(&v6[((v7 - 43) & 0xFD) == 0], v4);
v9 = v8;
if ( v4 != v8 && *v8 == 46 )
v9 = svgSkipDigits(v8 + 1, v4);
v10 = v9 - v6;
if ( v10 >= v3 )
_assert_fail("szEnd - szStart < n", "svg_string.c", 0x5Au, "svgGetNextPointField");
strncpy(a2, v6, v10);
a2[v10] = 0;
return v6;
}

canonical_decompiled_code:
char *__fastcall func4(char *a1, char *a2, int a3)
{
signed __int64 v3; // r13
char *v4; // r14
char *v5; // rax
char *v6; // r12
char v7; // al
char *v8; // rax
char *v9; // rbp
signed __int64 v10; // rbp
char *v12; // rax

v3 = a3;
v4 = &a1[a3 - 1];
if ( !a1 )
return 0LL;
if ( !a2 )
return 0LL;
*a2 = 0;
v5 = func1(a1, &a1[a3 - 1]);
v6 = v5;
if ( v4 == v5 )
return 0LL;
v7 = *v5;
if ( !v7 )
return 0LL;
if ( v7 == 44 )
{
v12 = func1(v6 + 1, v4);
v6 = v12;
if ( v4 == v12 )
return 0LL;
v7 = *v12;
if ( !v7 )
return 0LL;
}
v8 = func2(&v6[((v7 - 43) & 0xFD) == 0], v4);
v9 = v8;
if ( v4 != v8 && *v8 == 46 )
v9 = func2(v8 + 1, v4);
v10 = v9 - v6;
if ( v10 >= v3 )
_assert_fail("szEnd - szStart < n", "svg_string.c", 0x5Au, "svgGetNextPointField");
strncpy(a2, v6, v10);
a2[v10] = 0;
return v6;
}

original_code:
const char* svgGetNextPointField( const char *szData, char *szField, int n )
{
 const char *szStart = ((void *)0), *szEnd = ((void *)0), *szEOF = szData + n - 1;
 if( szData==((void *)0) || szField==((void *)0) )
  return ((void *)0);
 szField[ 0 ] = '\0';
 szStart = szData;
 szStart = svgSkipWS(szStart, szEOF);
 if( szStart==szEOF || *szStart=='\0' )
  return ((void *)0);
 if ( *szStart==',' ) {
  szStart ++;
  szStart = svgSkipWS(szStart, szEOF);
  if( szStart==szEOF || *szStart=='\0' )
   return ((void *)0);
 }
 szEnd = szStart;
 if (szEnd != szEOF && ( *szEnd=='-' || *szEnd =='+' ) )
  szEnd ++;
 szEnd = svgSkipDigits( szEnd, szEOF );
 if (szEnd != szEOF && *szEnd == '.') {
  szEnd ++;
  szEnd = svgSkipDigits( szEnd, szEOF );
 }
 ((void) sizeof ((szEnd - szStart < n) ? 1 : 0), __extension__ ({ if (szEnd - szStart < n) ; else __assert_fail ("szEnd - szStart < n", "svg_string.c", 90, __extension__ __PRETTY_FUNCTION__); }));
 strncpy( szField, szStart, ( size_t )( szEnd - szStart ) );
 szField[ szEnd - szStart ] = 0;
 return szStart;
}

canonical_original_code:
char *svgGetNextPointField(char *szData, char *szField, int n)
{
 char *szStart = ((void *)0); char *szEnd = ((void *)0); char *szEOF = szData + n - 1;
 if( szData==((void *)0) || szField==((void *)0) )
  return ((void *)0);
 szField[ 0 ] = '\0';
 szStart = szData;
 szStart = svgSkipWS(szStart, szEOF);
 if( szStart==szEOF || *szStart=='\0' )
  return ((void *)0);
 if ( *szStart==',' ) {
  szStart ++;
  szStart = svgSkipWS(szStart, szEOF);
  if( szStart==szEOF || *szStart=='\0' )
   return ((void *)0);
 }
 szEnd = szStart;
 if (szEnd != szEOF && ( *szEnd=='-' || *szEnd =='+' ) )
  szEnd ++;
 szEnd = svgSkipDigits( szEnd, szEOF );
 if (szEnd != szEOF && *szEnd == '.') {
  szEnd ++;
  szEnd = svgSkipDigits( szEnd, szEOF );
 }
 ((void) sizeof ((szEnd - szStart < n) ? 1 : 0), __extension__ ({ if (szEnd - szStart < n) ; else __assert_fail ("szEnd - szStart < n", "svg_string.c", 90, __extension__ __PRETTY_FUNCTION__); }));
 strncpy( szField, szStart, ( unsigned long )( szEnd - szStart ) );
 szField[ szEnd - szStart ] = 0;
 return szStart;
}


svgIsRealNumber

decompiled_code:
bool __fastcall svgIsRealNumber(_BYTE *a1)
{
char *v1; // rax
char v2; // dl

if ( !a1 )
return 0;
v1 = svgSkipDigits(&a1[((*a1 - 43) & 0xFD) == 0], 0LL);
v2 = *v1;
if ( *v1 == 46 )
v2 = *svgSkipDigits(v1 + 1, 0LL);
return v2 == 0;
}

original_code:
char svgIsRealNumber( const char *szString )
{
 if( szString==((void *)0) )
  return 0;
 if ( *szString=='-' || *szString =='+' )
  szString ++;
 szString = svgSkipDigits( szString, ((void *)0) );
 if (*szString == '.') {
  szString ++;
  szString = svgSkipDigits( szString, ((void *)0) );
 }
 if( *szString=='\0' )
  return 1;
 return 0;
}

canonical_original_code:
char svgIsRealNumber(char *szString)
{
 if( szString==((void *)0) )
  return 0;
 if ( *szString=='-' || *szString =='+' )
  szString ++;
 szString = svgSkipDigits( szString, ((void *)0) );
 if (*szString == '.') {
  szString ++;
  szString = svgSkipDigits( szString, ((void *)0) );
 }
 if( *szString=='\0' )
  return 1;
 return 0;
}

variable_types:
szString
char *


svgSetLastError

decompiled_code:
__int64 svgSetLastError(unsigned int a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( a2 )
{
va_start(arg, a2);
vsprintf(g_szLastErrorDesc, a2, arg);
}
else
{
g_szLastErrorDesc[0] = 0;
}
g_tLastError = a1;
return a1;
}

canonical_decompiled_code:
__int64 func0(unsigned int a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

if ( a2 )
{
va_start(arg, a2);
vsprintf(g_szLastErrorDesc, a2, arg);
}
else
{
g_szLastErrorDesc[0] = 0;
}
g_tLastError = a1;
return a1;
}

original_code:
svgError svgSetLastError( svgError tError, const char *szDesc, ... )
{
 va_list tVaList;
 if( szDesc!=((void *)0) ) {
  __builtin_va_start(tVaList,szDesc);
  vsprintf( g_szLastErrorDesc, szDesc, tVaList );
  __builtin_va_end(tVaList);
 }
 else
  g_szLastErrorDesc[ 0 ] = '\0';
 g_tLastError = tError;
 return tError;
}

canonical_original_code:
enum _svgError svgSetLastError(enum _svgError tError, char *szDesc, ...)
{
 __builtin_va_list tVaList;
 if( szDesc!=((void *)0) ) {
  __builtin_va_start(tVaList,szDesc);
  vsprintf( g_szLastErrorDesc, szDesc, tVaList );
  __builtin_va_end(tVaList);
 }
 else
  g_szLastErrorDesc[ 0 ] = '\0';
 g_tLastError = tError;
 return tError;
}

variable_types: enum _svgError { SVG_ERR_SUCCESS=0, SVG_ERR_INVALID_PARAMETER=1, SVG_ERR_NO_SUCH_FILE=2, SVG_ERR_BAD_FILE_FORMAT=3, SVG_ERR_NOT_ENOUGH_RAM=4 }

variable_types:
szDesc
char *


svgGetLastError

decompiled_code:
__int64 svgGetLastError()
{
return (unsigned int)g_tLastError;
}

canonical_decompiled_code:
__int64 func1()
{
return (unsigned int)g_tLastError;
}

original_code:
svgError svgGetLastError( void )
{
 return g_tLastError;
}

canonical_original_code:
enum _svgError svgGetLastError()
{
 return g_tLastError;
}

return_type: enum _svgError { SVG_ERR_SUCCESS=0, SVG_ERR_INVALID_PARAMETER=1, SVG_ERR_NO_SUCH_FILE=2, SVG_ERR_BAD_FILE_FORMAT=3, SVG_ERR_NOT_ENOUGH_RAM=4 }


svgGetLastErrorDescription

decompiled_code:
char *svgGetLastErrorDescription()
{
return g_szLastErrorDesc;
}

canonical_decompiled_code:
char *func2()
{
return g_szLastErrorDesc;
}

original_code:
char* svgGetLastErrorDescription( void )
{
 return g_szLastErrorDesc;
}


svgFreeItem

decompiled_code:
void __fastcall svgFreeItem(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
_QWORD *v4; // rbx
void *v5; // rdi
_QWORD *v6; // rbx
void *v7; // rdi
_QWORD *v8; // rbx
void *v9; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
switch ( *(_DWORD *)ptr )
{
case 1:
v4 = (_QWORD *)*((_QWORD *)ptr + 7);
while ( v4 )
{
v5 = v4;
v4 = (_QWORD *)v4[8];
free(v5);
}
break;
case 6:
v6 = (_QWORD *)*((_QWORD *)ptr + 9);
while ( v6 )
{
v7 = v6;
v6 = (_QWORD *)v6[2];
free(v7);
}
break;
case 7:
v8 = (_QWORD *)*((_QWORD *)ptr + 9);
while ( v8 )
{
v9 = v8;
v8 = (_QWORD *)v8[2];
free(v9);
}
break;
case 8:
case 9:
v3 = (void *)*((_QWORD *)ptr + 7);
if ( v3 )
free(v3);
break;
default:
break;
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v2; // rdi
void *v3; // rdi
_QWORD *v4; // rbx
void *v5; // rdi
_QWORD *v6; // rbx
void *v7; // rdi
_QWORD *v8; // rbx
void *v9; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
switch ( *(_DWORD *)ptr )
{
case 1:
v4 = (_QWORD *)*((_QWORD *)ptr + 7);
while ( v4 )
{
v5 = v4;
v4 = (_QWORD *)v4[8];
free(v5);
}
break;
case 6:
v6 = (_QWORD *)*((_QWORD *)ptr + 9);
while ( v6 )
{
v7 = v6;
v6 = (_QWORD *)v6[2];
free(v7);
}
break;
case 7:
v8 = (_QWORD *)*((_QWORD *)ptr + 9);
while ( v8 )
{
v9 = v8;
v8 = (_QWORD *)v8[2];
free(v9);
}
break;
case 8:
case 9:
v3 = (void *)*((_QWORD *)ptr + 7);
if ( v3 )
free(v3);
break;
default:
break;
}
free(ptr);
}
}

original_code:
void svgFreeItem( svgItem *ptItem )
{
 svgPathCommand *ptPathCmd, *ptNextPathCmd;
 svgPoint *ptPoint, *ptNextPoint;
 if( ptItem==((void *)0) )
  return;
 if( ptItem->szId!=((void *)0) )
  free( ptItem->szId );
 switch( ptItem->tKind )
 {
  case SVG_ITEM_KIND_GROUP:
   break;
  case SVG_ITEM_KIND_PATH:
   ptPathCmd = ptItem->tParameters.tPath.ptFirstCommand;
   while( ptPathCmd!=((void *)0) ) {
    ptNextPathCmd = ptPathCmd->ptNextCommand;
    free( ptPathCmd );
    ptPathCmd = ptNextPathCmd;
   }
   break;
  case SVG_ITEM_KIND_RECT:
   break;
  case SVG_ITEM_KIND_CIRCLE:
   break;
  case SVG_ITEM_KIND_ELLIPSE:
   break;
  case SVG_ITEM_KIND_LINE:
   break;
  case SVG_ITEM_KIND_POLYLINE:
   ptPoint = ptItem->tParameters.tPolyline.tFirstPoint.ptNextPoint;
   while( ptPoint!=((void *)0) ) {
    ptNextPoint = ptPoint->ptNextPoint;
    free( ptPoint );
    ptPoint = ptNextPoint;
   }
   break;
  case SVG_ITEM_KIND_POLYGON:
   ptPoint = ptItem->tParameters.tPolygon.tFirstPoint.ptNextPoint;
   while( ptPoint!=((void *)0) ) {
    ptNextPoint = ptPoint->ptNextPoint;
    free( ptPoint );
    ptPoint = ptNextPoint;
   }
   break;
  case SVG_ITEM_KIND_TITLE:
   if( ptItem->tParameters.tTitle.szText!=((void *)0) )
    free( ptItem->tParameters.tTitle.szText );
   break;
  case SVG_ITEM_KIND_DESC:
   if( ptItem->tParameters.tTitle.szText!=((void *)0) )
    free( ptItem->tParameters.tDesc.szText );
   break;
 }
 free( ptItem );
}

canonical_original_code:
void svgFreeItem(struct _svgItem *ptItem)
{
 struct _svgPathCommand *ptPathCmd; struct _svgPathCommand *ptNextPathCmd;
 struct _svgPoint *ptPoint; struct _svgPoint *ptNextPoint;
 if( ptItem==((void *)0) )
  return;
 if( ptItem->szId!=((void *)0) )
  free( ptItem->szId );
 switch( ptItem->tKind )
 {
  case SVG_ITEM_KIND_GROUP:
   break;
  case SVG_ITEM_KIND_PATH:
   ptPathCmd = ptItem->tParameters.tPath.ptFirstCommand;
   while( ptPathCmd!=((void *)0) ) {
    ptNextPathCmd = ptPathCmd->ptNextCommand;
    free( ptPathCmd );
    ptPathCmd = ptNextPathCmd;
   }
   break;
  case SVG_ITEM_KIND_RECT:
   break;
  case SVG_ITEM_KIND_CIRCLE:
   break;
  case SVG_ITEM_KIND_ELLIPSE:
   break;
  case SVG_ITEM_KIND_LINE:
   break;
  case SVG_ITEM_KIND_POLYLINE:
   ptPoint = ptItem->tParameters.tPolyline.tFirstPoint.ptNextPoint;
   while( ptPoint!=((void *)0) ) {
    ptNextPoint = ptPoint->ptNextPoint;
    free( ptPoint );
    ptPoint = ptNextPoint;
   }
   break;
  case SVG_ITEM_KIND_POLYGON:
   ptPoint = ptItem->tParameters.tPolygon.tFirstPoint.ptNextPoint;
   while( ptPoint!=((void *)0) ) {
    ptNextPoint = ptPoint->ptNextPoint;
    free( ptPoint );
    ptPoint = ptNextPoint;
   }
   break;
  case SVG_ITEM_KIND_TITLE:
   if( ptItem->tParameters.tTitle.szText!=((void *)0) )
    free( ptItem->tParameters.tTitle.szText );
   break;
  case SVG_ITEM_KIND_DESC:
   if( ptItem->tParameters.tTitle.szText!=((void *)0) )
    free( ptItem->tParameters.tDesc.szText );
   break;
 }
 free( ptItem );
}

variable_types: struct _svgItem { enum _svgItemKind { SVG_ITEM_KIND_GROUP=0, SVG_ITEM_KIND_PATH=1, SVG_ITEM_KIND_RECT=2, SVG_ITEM_KIND_CIRCLE=3, SVG_ITEM_KIND_ELLIPSE=4, SVG_ITEM_KIND_LINE=5, SVG_ITEM_KIND_POLYLINE=6, SVG_ITEM_KIND_POLYGON=7, SVG_ITEM_KIND_TITLE=8, SVG_ITEM_KIND_DESC=9 } tKind; char *szId; struct _svgItem *ptParent; struct _svgItem *ptFirstChild; struct _svgItem *ptLastChild; struct _svgItem *ptNextItem; struct _svgItem *ptNextUnsortedItem; union { struct _svgTitle { char *szText; } tTitle; struct _svgDesc { char *szText; } tDesc; struct _svgLine { struct _svgLength { enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 } tUnit; float fValue; } tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; } tLine; struct _svgRect { struct _svgLength tX; struct _svgLength tY; struct _svgLength tWidth; struct _svgLength tHeight; struct _svgLength tRadiusX; struct _svgLength tRadiusY; } tRect; struct _svgCircle { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadius; } tCircle; struct _svgPath { struct _svgPathCommand { enum _svgPathCommandId { SVG_PATH_CMD_ID_MOVETO_ABS=0, SVG_PATH_CMD_ID_MOVETO_REL=1, SVG_PATH_CMD_ID_LINETO_ABS=2, SVG_PATH_CMD_ID_LINETO_REL=3, SVG_PATH_CMD_ID_VERTICAL_LINETO_ABS=4, SVG_PATH_CMD_ID_VERTICAL_LINETO_REL=5, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_ABS=6, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_REL=7, SVG_PATH_CMD_ID_CUBIC_CURVETO_ABS=8, SVG_PATH_CMD_ID_CUBIC_CURVETO_REL=9, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_ABS=10, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_REL=11, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_ABS=12, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_REL=13, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_ABS=14, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_REL=15, SVG_PATH_CMD_ID_ARCTO_ABS=16, SVG_PATH_CMD_ID_ARCTO_REL=17, SVG_PATH_CMD_ID_CLOSEPATH=18, SVG_PATH_CMD_ID_END_OF_ENUM=19 } tId; union { struct _svgPathCommand_MoveTo { struct _svgLength tX; struct _svgLength tY; } tMoveTo; struct _svgPathCommand_Lineto { struct _svgLength tX; struct _svgLength tY; } tLineTo; struct _svgPathCommand_CubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; } tCubicCurveTo; struct _svgPathCommand_SmoothCubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX2; struct _svgLength tY2; } tSmoothCubicCurveTo; struct _svgPathCommand_QuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; } tQuadraticCurveTo; struct _svgPathCommand_SmoothQuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; } tSmoothQuadraticCurveTo; struct _svgPathCommand_ArcTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; struct _svgLength tXAxisAngle; struct _svgLength tLargeArcFlag; struct _svgLength tSweepFlag; } tArcTo; } tParameters; struct _svgPathCommand *ptNextCommand; } *ptFirstCommand; } tPath; struct _svgEllipse { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; } tEllipse; struct _svgPolyline { struct _svgPoint { struct _svgLength tX; struct _svgLength tY; struct _svgPoint *ptNextPoint; } tFirstPoint; } tPolyline; struct _svgPolygon { struct _svgPoint tFirstPoint; } tPolygon; } tParameters; } *

variable_types: struct _svgPathCommand { enum _svgPathCommandId { SVG_PATH_CMD_ID_MOVETO_ABS=0, SVG_PATH_CMD_ID_MOVETO_REL=1, SVG_PATH_CMD_ID_LINETO_ABS=2, SVG_PATH_CMD_ID_LINETO_REL=3, SVG_PATH_CMD_ID_VERTICAL_LINETO_ABS=4, SVG_PATH_CMD_ID_VERTICAL_LINETO_REL=5, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_ABS=6, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_REL=7, SVG_PATH_CMD_ID_CUBIC_CURVETO_ABS=8, SVG_PATH_CMD_ID_CUBIC_CURVETO_REL=9, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_ABS=10, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_REL=11, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_ABS=12, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_REL=13, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_ABS=14, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_REL=15, SVG_PATH_CMD_ID_ARCTO_ABS=16, SVG_PATH_CMD_ID_ARCTO_REL=17, SVG_PATH_CMD_ID_CLOSEPATH=18, SVG_PATH_CMD_ID_END_OF_ENUM=19 } tId; union { struct _svgPathCommand_MoveTo { struct _svgLength { enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 } tUnit; float fValue; } tX; struct _svgLength tY; } tMoveTo; struct _svgPathCommand_Lineto { struct _svgLength tX; struct _svgLength tY; } tLineTo; struct _svgPathCommand_CubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; } tCubicCurveTo; struct _svgPathCommand_SmoothCubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX2; struct _svgLength tY2; } tSmoothCubicCurveTo; struct _svgPathCommand_QuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; } tQuadraticCurveTo; struct _svgPathCommand_SmoothQuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; } tSmoothQuadraticCurveTo; struct _svgPathCommand_ArcTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; struct _svgLength tXAxisAngle; struct _svgLength tLargeArcFlag; struct _svgLength tSweepFlag; } tArcTo; } tParameters; struct _svgPathCommand *ptNextCommand; } *

variable_types: struct _svgPoint { struct _svgLength { enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 } tUnit; float fValue; } tX; struct _svgLength tY; struct _svgPoint *ptNextPoint; } *

user_defined_types: struct _svgItem { enum _svgItemKind tKind; char *szId; struct _svgItem *ptParent; struct _svgItem *ptFirstChild; struct _svgItem *ptLastChild; struct _svgItem *ptNextItem; struct _svgItem *ptNextUnsortedItem; union { struct _svgTitle tTitle; struct _svgDesc tDesc; struct _svgLine tLine; struct _svgRect tRect; struct _svgCircle tCircle; struct _svgPath tPath; struct _svgEllipse tEllipse; struct _svgPolyline tPolyline; struct _svgPolygon tPolygon; } tParameters; }

user_defined_types: struct _svgPathCommand { enum _svgPathCommandId tId; union { struct _svgPathCommand_MoveTo tMoveTo; struct _svgPathCommand_Lineto tLineTo; struct _svgPathCommand_CubicCurveTo tCubicCurveTo; struct _svgPathCommand_SmoothCubicCurveTo tSmoothCubicCurveTo; struct _svgPathCommand_QuadraticCurveTo tQuadraticCurveTo; struct _svgPathCommand_SmoothQuadraticCurveTo tSmoothQuadraticCurveTo; struct _svgPathCommand_ArcTo tArcTo; } tParameters; struct _svgPathCommand *ptNextCommand; }

user_defined_types: struct _svgLength { enum _svgLengthUnit tUnit; float fValue; }

user_defined_types: struct _svgLine { struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; }

user_defined_types: struct _svgPath { struct _svgPathCommand *ptFirstCommand; }

user_defined_types: struct _svgPolyline { struct _svgPoint tFirstPoint; }


svgFreeDrawing

decompiled_code:
void __fastcall svgFreeDrawing(void *ptr)
{
void *v2; // rdi
_QWORD *v3; // rbx
void *v4; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
v3 = (_QWORD *)*((_QWORD *)ptr + 6);
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)v3[6];
svgFreeItem(v4);
}
free(ptr);
}
}

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

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 1);
if ( v2 )
free(v2);
if ( *(_QWORD *)ptr )
free(*(void **)ptr);
v3 = (_QWORD *)*((_QWORD *)ptr + 6);
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)v3[6];
func0(v4);
}
free(ptr);
}
}

original_code:
void svgFreeDrawing( svgDrawing *ptDrawing )
{
 svgItem *ptItem, *ptNextItem;
 if( ptDrawing==((void *)0) )
  return;
 if( ptDrawing->szId!=((void *)0) )
  free( ptDrawing->szId );
 if( ptDrawing->szVersion!=((void *)0) )
  free( ptDrawing->szVersion );
 ptItem = ptDrawing->tItemList.ptItem;
 while( ptItem!=((void *)0) ){
  ptNextItem = ptItem->ptNextUnsortedItem;
  svgFreeItem( ptItem );
  ptItem = ptNextItem;
 }
 free( ptDrawing );
}

canonical_original_code:
void svgFreeDrawing(struct _svgDrawing *ptDrawing)
{
 struct _svgItem *ptItem; struct _svgItem *ptNextItem;
 if( ptDrawing==((void *)0) )
  return;
 if( ptDrawing->szId!=((void *)0) )
  free( ptDrawing->szId );
 if( ptDrawing->szVersion!=((void *)0) )
  free( ptDrawing->szVersion );
 ptItem = ptDrawing->tItemList.ptItem;
 while( ptItem!=((void *)0) ){
  ptNextItem = ptItem->ptNextUnsortedItem;
  svgFreeItem( ptItem );
  ptItem = ptNextItem;
 }
 free( ptDrawing );
}

variable_types: struct _svgDrawing { char *szVersion; char *szId; struct _svgLength { enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 } tUnit; float fValue; } tX; struct _svgLength tY; struct _svgLength tWidth; struct _svgLength tHeight; struct _svgItemList { struct _svgItem { enum _svgItemKind { SVG_ITEM_KIND_GROUP=0, SVG_ITEM_KIND_PATH=1, SVG_ITEM_KIND_RECT=2, SVG_ITEM_KIND_CIRCLE=3, SVG_ITEM_KIND_ELLIPSE=4, SVG_ITEM_KIND_LINE=5, SVG_ITEM_KIND_POLYLINE=6, SVG_ITEM_KIND_POLYGON=7, SVG_ITEM_KIND_TITLE=8, SVG_ITEM_KIND_DESC=9 } tKind; char *szId; struct _svgItem *ptParent; struct _svgItem *ptFirstChild; struct _svgItem *ptLastChild; struct _svgItem *ptNextItem; struct _svgItem *ptNextUnsortedItem; union { struct _svgTitle { char *szText; } tTitle; struct _svgDesc { char *szText; } tDesc; struct _svgLine { struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; } tLine; struct _svgRect { struct _svgLength tX; struct _svgLength tY; struct _svgLength tWidth; struct _svgLength tHeight; struct _svgLength tRadiusX; struct _svgLength tRadiusY; } tRect; struct _svgCircle { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadius; } tCircle; struct _svgPath { struct _svgPathCommand { enum _svgPathCommandId { SVG_PATH_CMD_ID_MOVETO_ABS=0, SVG_PATH_CMD_ID_MOVETO_REL=1, SVG_PATH_CMD_ID_LINETO_ABS=2, SVG_PATH_CMD_ID_LINETO_REL=3, SVG_PATH_CMD_ID_VERTICAL_LINETO_ABS=4, SVG_PATH_CMD_ID_VERTICAL_LINETO_REL=5, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_ABS=6, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_REL=7, SVG_PATH_CMD_ID_CUBIC_CURVETO_ABS=8, SVG_PATH_CMD_ID_CUBIC_CURVETO_REL=9, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_ABS=10, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_REL=11, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_ABS=12, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_REL=13, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_ABS=14, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_REL=15, SVG_PATH_CMD_ID_ARCTO_ABS=16, SVG_PATH_CMD_ID_ARCTO_REL=17, SVG_PATH_CMD_ID_CLOSEPATH=18, SVG_PATH_CMD_ID_END_OF_ENUM=19 } tId; union { struct _svgPathCommand_MoveTo { struct _svgLength tX; struct _svgLength tY; } tMoveTo; struct _svgPathCommand_Lineto { struct _svgLength tX; struct _svgLength tY; } tLineTo; struct _svgPathCommand_CubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; } tCubicCurveTo; struct _svgPathCommand_SmoothCubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX2; struct _svgLength tY2; } tSmoothCubicCurveTo; struct _svgPathCommand_QuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; } tQuadraticCurveTo; struct _svgPathCommand_SmoothQuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; } tSmoothQuadraticCurveTo; struct _svgPathCommand_ArcTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; struct _svgLength tXAxisAngle; struct _svgLength tLargeArcFlag; struct _svgLength tSweepFlag; } tArcTo; } tParameters; struct _svgPathCommand *ptNextCommand; } *ptFirstCommand; } tPath; struct _svgEllipse { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; } tEllipse; struct _svgPolyline { struct _svgPoint { struct _svgLength tX; struct _svgLength tY; struct _svgPoint *ptNextPoint; } tFirstPoint; } tPolyline; struct _svgPolygon { struct _svgPoint tFirstPoint; } tPolygon; } tParameters; } *ptItem; unsigned int ui32Count; } tItemList; } *

user_defined_types: struct _svgDrawing { char *szVersion; char *szId; struct _svgLength tX; struct _svgLength tY; struct _svgLength tWidth; struct _svgLength tHeight; struct _svgItemList tItemList; }

user_defined_types: struct _svgItemList { struct _svgItem *ptItem; unsigned int ui32Count; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
__int64 v4; // r13
__int64 v5; // r12
int v6; // ebp
int v7; // ebx
__int64 v8; // rbx
__int64 v9; // rax
int result; // eax
const char *v11; // r12
unsigned int v12; // eax

if ( argc <= 1 )
return -1;
v3 = svgOpenFile(argv[1]);
v4 = v3;
if ( v3 )
{
printf("Nbr of items : %d\n", *(unsigned int *)(v3 + 56));
v5 = *(_QWORD *)(v4 + 48);
if ( v5 )
{
v6 = 0;
putchar(124);
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
printf("-%s\n", *(const char **)(v5 + 8));
if ( !*(_QWORD *)(v5 + 24) )
break;
++v6;
v5 = *(_QWORD *)(v5 + 24);
putchar(124);
LABEL_7:
v7 = 0;
do
{
++v7;
printf(" |");
}
while ( v6 != v7 );
}
v8 = *(_QWORD *)(v5 + 40);
if ( !v8 )
break;
LABEL_11:
v5 = v8;
putchar(124);
if ( v6 )
goto LABEL_7;
}
v9 = *(_QWORD *)(v5 + 16);
if ( !v9 )
break;
v8 = *(_QWORD *)(v9 + 40);
if ( v6 )
{
if ( !v8 )
break;
--v6;
goto LABEL_11;
}
if ( !v8 )
break;
v5 = *(_QWORD *)(v9 + 40);
putchar(124);
}
}
svgFreeDrawing(v4);
result = 0;
}
else
{
v11 = (const char *)svgGetLastErrorDescription();
v12 = svgGetLastError();
printf("ERROR(%d): %s.\n", v12, v11);
result = -1;
}
return result;
}

original_code:
int main( int iargc, char **argv )
{
 svgDrawing *ptSvg;
 svgItem *ptItem;
 int iLevel,j;
 if( iargc<2 )
  return -1;
 ptSvg = svgOpenFile( argv[ 1 ] );
 if( ptSvg==((void *)0) ) {
  printf( "ERROR(%d): %s.\n", svgGetLastError(), svgGetLastErrorDescription() );
  return -1;
 }
 printf( "Nbr of items : %d\n", ptSvg->tItemList.ui32Count );
 iLevel = 0;
 ptItem = ptSvg->tItemList.ptItem;
 while( ptItem!=((void *)0) )
 {
  printf( "|" );
  for( j=0; j<iLevel; j++ )
   printf( "  |" );
  printf( "-%s\n", ptItem->szId );
  if( ptItem->ptFirstChild!=((void *)0) ) {
   ptItem = ptItem->ptFirstChild;
   iLevel ++;
  }
  else {
   if( ptItem->ptNextItem!=((void *)0) )
    ptItem = ptItem->ptNextItem;
   else if( ptItem->ptParent!=((void *)0) ) {
    ptItem = ptItem->ptParent->ptNextItem;
    if( iLevel > 0 )
     iLevel --;
   }
   else
    ptItem = ((void *)0);
  }
 }
 svgFreeDrawing( ptSvg );
 return 0;
}

canonical_original_code:
int main(int iargc, char **argv)
{
 struct _svgDrawing *ptSvg;
 struct _svgItem *ptItem;
 int iLevel; int j;
 if( iargc<2 )
  return -1;
 ptSvg = svgOpenFile( argv[ 1 ] );
 if( ptSvg==((void *)0) ) {
  printf( "ERROR(%d): %s.\n", svgGetLastError(), svgGetLastErrorDescription() );
  return -1;
 }
 printf( "Nbr of items : %d\n", ptSvg->tItemList.ui32Count );
 iLevel = 0;
 ptItem = ptSvg->tItemList.ptItem;
 while( ptItem!=((void *)0) )
 {
  printf( "|" );
  for( j=0; j<iLevel; j++ )
   printf( "  |" );
  printf( "-%s\n", ptItem->szId );
  if( ptItem->ptFirstChild!=((void *)0) ) {
   ptItem = ptItem->ptFirstChild;
   iLevel ++;
  }
  else {
   if( ptItem->ptNextItem!=((void *)0) )
    ptItem = ptItem->ptNextItem;
   else if( ptItem->ptParent!=((void *)0) ) {
    ptItem = ptItem->ptParent->ptNextItem;
    if( iLevel > 0 )
     iLevel --;
   }
   else
    ptItem = ((void *)0);
  }
 }
 svgFreeDrawing( ptSvg );
 return 0;
}

variable_types: iargc int

variable_types:
argv
char **

variable_types: iLevel int

variable_types: j int

user_defined_types: enum _svgItemKind { SVG_ITEM_KIND_GROUP=0, SVG_ITEM_KIND_PATH=1, SVG_ITEM_KIND_RECT=2, SVG_ITEM_KIND_CIRCLE=3, SVG_ITEM_KIND_ELLIPSE=4, SVG_ITEM_KIND_LINE=5, SVG_ITEM_KIND_POLYLINE=6, SVG_ITEM_KIND_POLYGON=7, SVG_ITEM_KIND_TITLE=8, SVG_ITEM_KIND_DESC=9 }

user_defined_types: enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 }

user_defined_types: struct _svgRect { struct _svgLength tX; struct _svgLength tY; struct _svgLength tWidth; struct _svgLength tHeight; struct _svgLength tRadiusX; struct _svgLength tRadiusY; }

user_defined_types: struct _svgCircle { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadius; }

user_defined_types: struct _svgEllipse { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; }

user_defined_types: struct _svgPolygon { struct _svgPoint tFirstPoint; }

user_defined_types: struct _svgPoint { struct _svgLength tX; struct _svgLength tY; struct _svgPoint *ptNextPoint; }

user_defined_types: enum _svgPathCommandId { SVG_PATH_CMD_ID_MOVETO_ABS=0, SVG_PATH_CMD_ID_MOVETO_REL=1, SVG_PATH_CMD_ID_LINETO_ABS=2, SVG_PATH_CMD_ID_LINETO_REL=3, SVG_PATH_CMD_ID_VERTICAL_LINETO_ABS=4, SVG_PATH_CMD_ID_VERTICAL_LINETO_REL=5, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_ABS=6, SVG_PATH_CMD_ID_HORIZONTAL_LINETO_REL=7, SVG_PATH_CMD_ID_CUBIC_CURVETO_ABS=8, SVG_PATH_CMD_ID_CUBIC_CURVETO_REL=9, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_ABS=10, SVG_PATH_CMD_ID_SMOOTH_CUBIC_CURVETO_REL=11, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_ABS=12, SVG_PATH_CMD_ID_QUADRATIC_CURVETO_REL=13, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_ABS=14, SVG_PATH_CMD_ID_SMOOTH_QUADRATIC_CURVETO_REL=15, SVG_PATH_CMD_ID_ARCTO_ABS=16, SVG_PATH_CMD_ID_ARCTO_REL=17, SVG_PATH_CMD_ID_CLOSEPATH=18, SVG_PATH_CMD_ID_END_OF_ENUM=19 }

user_defined_types: struct _svgPathCommand_MoveTo { struct _svgLength tX; struct _svgLength tY; }

user_defined_types: struct _svgPathCommand_Lineto { struct _svgLength tX; struct _svgLength tY; }

user_defined_types: struct _svgPathCommand_CubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; struct _svgLength tX2; struct _svgLength tY2; }

user_defined_types: struct _svgPathCommand_SmoothCubicCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX2; struct _svgLength tY2; }

user_defined_types: struct _svgPathCommand_QuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tX1; struct _svgLength tY1; }

user_defined_types: struct _svgPathCommand_SmoothQuadraticCurveTo { struct _svgLength tX; struct _svgLength tY; }

user_defined_types: struct _svgPathCommand_ArcTo { struct _svgLength tX; struct _svgLength tY; struct _svgLength tRadiusX; struct _svgLength tRadiusY; struct _svgLength tXAxisAngle; struct _svgLength tLargeArcFlag; struct _svgLength tSweepFlag; }


svgStringToLength

original_code:
void svgStringToLength( const char *szValue, svgLength *ptLength )
{
 char szUnit[ 8 ] = "";
 if( szValue==((void *)0) || ptLength==((void *)0) )
  return;
 memset( ptLength, 0, sizeof( *ptLength ) );
 sscanf( szValue, "%f%s", &ptLength->fValue, szUnit );
 ptLength->tUnit = SVG_LENGTH_UNIT_NONE;
 if( szUnit[ 0 ]=='\0' )
  return;
 if( strcmp( szUnit, "em" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_EM;
 else if( strcmp( szUnit, "ex" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_EX;
 else if( strcmp( szUnit, "in" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_IN;
 else if( strcmp( szUnit, "cm" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_CM;
 else if( strcmp( szUnit, "mm" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_MM;
 else if( strcmp( szUnit, "pt" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PT;
 else if( strcmp( szUnit, "pc" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PC;
 else if( strcmp( szUnit, "%" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PERCENT;
 else if( strcmp( szUnit, "px" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PX;
}

canonical_original_code:
void svgStringToLength(char *szValue, struct _svgLength *ptLength)
{
 char szUnit[8] = "";
 if( szValue==((void *)0) || ptLength==((void *)0) )
  return;
 memset( ptLength, 0, sizeof( *ptLength ) );
 sscanf( szValue, "%f%s", &ptLength->fValue, szUnit );
 ptLength->tUnit = SVG_LENGTH_UNIT_NONE;
 if( szUnit[ 0 ]=='\0' )
  return;
 if( strcmp( szUnit, "em" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_EM;
 else if( strcmp( szUnit, "ex" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_EX;
 else if( strcmp( szUnit, "in" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_IN;
 else if( strcmp( szUnit, "cm" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_CM;
 else if( strcmp( szUnit, "mm" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_MM;
 else if( strcmp( szUnit, "pt" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PT;
 else if( strcmp( szUnit, "pc" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PC;
 else if( strcmp( szUnit, "%" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PERCENT;
 else if( strcmp( szUnit, "px" )==0 )
  ptLength->tUnit = SVG_LENGTH_UNIT_PX;
}

variable_types:
szValue
char *

variable_types: struct _svgLength { enum _svgLengthUnit { SVG_LENGTH_UNIT_NONE=0, SVG_LENGTH_UNIT_PX=1, SVG_LENGTH_UNIT_EM=2, SVG_LENGTH_UNIT_EX=3, SVG_LENGTH_UNIT_IN=4, SVG_LENGTH_UNIT_CM=5, SVG_LENGTH_UNIT_MM=6, SVG_LENGTH_UNIT_PT=7, SVG_LENGTH_UNIT_PC=8, SVG_LENGTH_UNIT_PERCENT=9 } tUnit; float fValue; } *

variable_types:
szUnit
char [8]

user_defined_types: struct _svgLength { enum _svgLengthUnit tUnit; float fValue; }


aggancia

repo: agentOfChaos/chaos-controller

decompiled_code:
__int64 __fastcall aggancia(unsigned int a1)
{
unsigned int v1; // ebx

v1 = ptrace(PTRACE_ATTACH, a1, 0LL, 0LL);
if ( v1 != -1 )
wait(0LL);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
unsigned int v1; // ebx

v1 = ptrace(PTRACE_ATTACH, a1, 0LL, 0LL);
if ( v1 != -1 )
wait(0LL);
return v1;
}

original_code:
int aggancia(pid_t pid)
{
    int ret;
    ret=ptrace(PTRACE_ATTACH,pid,((void *)0),((void *)0));
    if (ret!=-1)
        {
        wait(((void *)0));
        }
    return ret;
}

canonical_original_code:
int aggancia(int pid)
{
    int ret;
    ret=ptrace(PTRACE_ATTACH,pid,((void *)0),((void *)0));
    if (ret!=-1)
        {
        wait(((void *)0));
        }
    return ret;
}

variable_types: pid int

variable_types: ret int


decompiled_code:
void *self_discover()
{
return dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "rand");
}

canonical_decompiled_code:
void *func2()
{
return dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "rand");
}

original_code:
unsigned long long int self_discover()
{
    void *altro;
    altro=dlsym(((void *) -1l),"rand");
    return (unsigned long long int)altro;
}

canonical_original_code:
unsigned long long self_discover()
{
    void *altro;
    altro=dlsym(((void *) -1l),"rand");
    return (unsigned long long)altro;
}

variable_types:
altro
void *

return_type: unsigned long long