decompiled_code:
int __fastcall lock_pages(__int64 a1, __int64 a2)
{
return mlock((const void *)(a1 & 0xFFFFFFFFFFFFF000LL), (a2 + 4095) & 0xFFFFFFFFFFFFF000LL);
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, __int64 a2)
{
return mlock((const void *)(a1 & 0xFFFFFFFFFFFFF000LL), (a2 + 4095) & 0xFFFFFFFFFFFFF000LL);
}

original_code:
int
lock_pages(
    void *addr,
    size_t len)
{
    int e = 0;
    return e;
}

canonical_original_code:
int lock_pages(void *addr, unsigned long len)
{
    int e = 0;
    return e;
}

variable_types:
addr
void *

variable_types:
len
unsigned long

variable_types: e int


repo: xenserver/xha

decompiled_code:
int __fastcall unlock_pages(__int64 a1, __int64 a2)
{
return munlock((const void *)(a1 & 0xFFFFFFFFFFFFF000LL), (a2 + 4095) & 0xFFFFFFFFFFFFF000LL);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1, __int64 a2)
{
return munlock((const void *)(a1 & 0xFFFFFFFFFFFFF000LL), (a2 + 4095) & 0xFFFFFFFFFFFFF000LL);
}

original_code:
void
unlock_pages(
    void *addr,
    size_t len)
{
}

canonical_original_code:
void unlock_pages(void *addr, unsigned long len)
{
}

return_type: void


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

va_start(va, a2);
fprintf(stderr, a2, va);
return fflush(stderr);
}

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

va_start(va, a2);
fprintf(stderr, a2, va);
return fflush(stderr);
}

original_code:
void log_message(MTC_S32 priority, PMTC_S8 fmt, ...)
{
    time_t now;
    struct tm *ptm;
    va_list ap;
    if (!initialized)
    {
        return;
    }
    pthread_spin_lock(&lock);
    if (priority & (1<<17) && fpLogfile != ((void *)0) && privatelogflag)
    {
        MTC_S32 i = 0;
        while (prioritynames[i].c_val != -1 &&
               prioritynames[i].c_val != ((priority) & 0x07))
        {
            i++;
        }
        now = time(((void *)0));
        ptm = localtime(&now);
        fprintf(fpLogfile, "%s %02d %02d:%02d:%02d %s %04d [%s] ",
                monthnames[ptm->tm_mon], ptm->tm_mday,
                ptm->tm_hour, ptm->tm_min, ptm->tm_sec,
                ptm->tm_zone, 1900 + ptm->tm_year, prioritynames[i].c_name);
        __builtin_va_start(ap,fmt);
        vfprintf(fpLogfile, fmt, ap);
        __builtin_va_end(ap);
        fflush(fpLogfile);
    }
    if (priority & (1<<16))
    {
        __builtin_va_start(ap,fmt);
        vsyslog(((priority) & 0x07), fmt, ap);
        __builtin_va_end(ap);
    }
    pthread_spin_unlock(&lock);
}

canonical_original_code:
void log_message(int priority, char *fmt, ...)
{
    long now;
    struct tm *ptm;
    __builtin_va_list ap;
    if (!initialized)
    {
        return;
    }
    pthread_spin_lock(&lock);
    if (priority & (1<<17) && fpLogfile != ((void *)0) && privatelogflag)
    {
        int i = 0;
        while (prioritynames[i].c_val != -1 &&
               prioritynames[i].c_val != ((priority) & 0x07))
        {
            i++;
        }
        now = time(((void *)0));
        ptm = localtime(&now);
        fprintf(fpLogfile, "%s %02d %02d:%02d:%02d %s %04d [%s] ",
                monthnames[ptm->tm_mon], ptm->tm_mday,
                ptm->tm_hour, ptm->tm_min, ptm->tm_sec,
                ptm->tm_zone, 1900 + ptm->tm_year, prioritynames[i].c_name);
        __builtin_va_start(ap,fmt);
        vfprintf(fpLogfile, fmt, ap);
        __builtin_va_end(ap);
        fflush(fpLogfile);
    }
    if (priority & (1<<16))
    {
        __builtin_va_start(ap,fmt);
        vsyslog(((priority) & 0x07), fmt, ap);
        __builtin_va_end(ap);
    }
    pthread_spin_unlock(&lock);
}

variable_types: priority int

variable_types:
fmt
char *

variable_types: now long

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

variable_types: i int


chop

decompiled_code:
size_t __fastcall chop(const char *a1)
{
size_t result; // rax
const char *v2; // rbx

result = strlen(a1);
if ( (_DWORD)result )
{
v2 = &a1[(unsigned int)(result - 1)];
if ( *v2 == 10 )
*v2 = 0;
}
return result;
}

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

result = strlen(a1);
if ( (_DWORD)result )
{
v2 = &a1[(unsigned int)(result - 1)];
if ( *v2 == 10 )
*v2 = 0;
}
return result;
}

original_code:
void chop(MTC_S8 *line)
{
    MTC_U32 len = strlen(line);
    if (len > 0 && line[len - 1] == '\n')
    {
        line[len - 1] = '\0';
    }
}

canonical_original_code:
void chop(char *line)
{
    unsigned int len = strlen(line);
    if (len > 0 && line[len - 1] == '\n')
    {
        line[len - 1] = '\0';
    }
}

variable_types:
line
char *

variable_types:
len
unsigned int


repo: xerpi/Znake

original_code:
void znake_update(struct znake_t *znake)
{
    if(znake->direction != DIR_NONE) {
        if(znake->body_length == 0) {
            znake->tail.x = znake->head.x;
            znake->tail.y = znake->head.y;
        } else {
            znake->tail.x = znake->body[znake->body_length-1]->x;
            znake->tail.y = znake->body[znake->body_length-1]->y;
            int i;
            for(i = znake->body_length-1; i > 0; i--) {
                znake->body[i]->x = znake->body[i-1]->x;
                znake->body[i]->y = znake->body[i-1]->y;
            }
            znake->body[0]->x = znake->head.x;
            znake->body[0]->y = znake->head.y;
        }
    }
    switch(znake->direction)
    {
    case DIR_UP:
        znake->head.y--;
        break;
    case DIR_DOWN:
        znake->head.y++;
        break;
    case DIR_RIGHT:
        znake->head.x++;
        break;
    case DIR_LEFT:
        znake->head.x--;
        break;
    default:
        break;
    }
}

variable_types: struct znake_t { struct vector2d { int x; int y; } head; struct vector2d **body; struct vector2d tail; enum znake_dir_t { DIR_NONE=0, DIR_UP=1, DIR_DOWN=2, DIR_RIGHT=3, DIR_LEFT=4 } direction; int body_length; } *

user_defined_types: struct znake_t { struct vector2d head; struct vector2d **body; struct vector2d tail; enum znake_dir_t direction; int body_length; }


original_code:
void znake_add_body(struct znake_t *znake)
{
    if(znake->body_length < znake->max_size) {
        znake->body[znake->body_length] = malloc(sizeof(struct vector2d));
        znake->body[znake->body_length]->x = znake->tail.x;
        znake->body[znake->body_length]->y = znake->tail.y;
        znake->body_length++;
    }
}

user_defined_types: enum znake_dir_t { DIR_NONE=0, DIR_UP=1, DIR_DOWN=2, DIR_RIGHT=3, DIR_LEFT=4 }


decompiled_code:
__int64 __fastcall znake_self_collision(__int64 a1)
{
int v1; // er8
__int64 v2; // rax
__int64 v3; // rsi

v1 = *(_DWORD *)(a1 + 28);
if ( !v1 )
return (unsigned int)v1;
if ( *(_QWORD *)a1 == *(_QWORD *)(a1 + 16) )
return 1;
if ( v1 > 0 )
{
v2 = *(_QWORD *)(a1 + 8);
v3 = v2 + 8LL * (unsigned int)(v1 - 1) + 8;
while ( *(_DWORD *)a1 != **(_DWORD **)v2 || *(_DWORD *)(a1 + 4) != *(_DWORD *)(*(_QWORD *)v2 + 4LL) )
{
v2 += 8LL;
if ( v2 == v3 )
return 0LL;
}
return 1;
}
return 0LL;
}

original_code:
int znake_self_collision(struct znake_t *znake)
{
    if(znake->body_length == 0) {
        return 0;
    } else {
        if((znake->head.x == znake->tail.x) && (znake->head.y == znake->tail.y)) {
            return 1;
        }
        int i;
        for(i = 0; i < znake->body_length; i++) {
            if((znake->head.x == znake->body[i]->x) && (znake->head.y == znake->body[i]->y)) {
                return 1;
            }
        }
    }
    return 0;
}

return_type: int


decompiled_code:
_BOOL8 __fastcall znake_head_collision(_DWORD *a1, int a2, int a3)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == a2 )
result = a1[1] == a3;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(_DWORD *a1, int a2, int a3)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == a2 )
result = a1[1] == a3;
return result;
}

original_code:
int znake_head_collision(struct znake_t *znake, int x, int y)
{
    if((znake->head.x == x) && (znake->head.y == y)) {
        return 1;
    }
    return 0;
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 __fastcall znake_collisions_with(_DWORD *a1, int a2, int a3)
{
int v3; // ecx
__int64 result; // rax

if ( *a1 != a2 )
{
if ( a1[4] != a2 )
goto LABEL_3;
LABEL_13:
result = 1LL;
if ( a1[5] == a3 )
return result;
goto LABEL_3;
}
result = 1LL;
if ( a1[1] == a3 )
return result;
if ( a1[4] == a2 )
goto LABEL_13;
LABEL_3:
v3 = a1[7];
result = 0LL;
if ( v3 > 0 )
{
do
{
if ( *a1 == a2 && a1[1] == a3 )
return 1LL;
LODWORD(result) = result + 1;
}
while ( (_DWORD)result != v3 );
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_DWORD *a1, int a2, int a3)
{
int v3; // ecx
__int64 result; // rax

if ( *a1 != a2 )
{
if ( a1[4] != a2 )
goto LABEL_3;
LABEL_13:
result = 1LL;
if ( a1[5] == a3 )
return result;
goto LABEL_3;
}
result = 1LL;
if ( a1[1] == a3 )
return result;
if ( a1[4] == a2 )
goto LABEL_13;
LABEL_3:
v3 = a1[7];
result = 0LL;
if ( v3 > 0 )
{
do
{
if ( *a1 == a2 && a1[1] == a3 )
return 1LL;
LODWORD(result) = result + 1;
}
while ( (_DWORD)result != v3 );
result = 0LL;
}
return result;
}

original_code:
int znake_collisions_with(struct znake_t *znake, int x, int y)
{
    if((znake->head.x == x) && (znake->head.y == y)) {
        return 1;
    }
    if((znake->tail.x == x) && (znake->tail.y == y)) {
        return 1;
    }
    int i;
    for(i = 0; i < znake->body_length; i++) {
        if((znake->head.x == x) && (znake->head.y == y)) {
            return 1;
        }
    }
    return 0;
}


original_code:
void znake_clear(struct znake_t *znake)
{
    if(znake->body_length > 0) {
        int i;
        for(i = 0; i < znake->body_length; i++) {
            free(znake->body[i]);
        }
        znake->body_length = 0;
    }
}


decompiled_code:
void __fastcall znake_init(__int64 a1, int a2, int a3, int a4)
{
void *v6; // rax

v6 = malloc(8LL * a4);
*(_DWORD *)(a1 + 32) = a4;
*(_QWORD *)(a1 + 8) = v6;
*(_DWORD *)(a1 + 28) = 0;
znake_reset((_DWORD *)a1, a2, a3);
}

original_code:
void znake_init(struct znake_t *znake, int x, int y, int max_size)
{
    znake->body = malloc(sizeof(struct vector2d *) * max_size);
    znake->body_length = 0;
    znake->max_size = max_size;
    znake_reset(znake, x, y);
}


decompiled_code:
void __fastcall znake_kill(__int64 a1)
{
znake_clear(a1);
free(*(void **)(a1 + 8));
}

canonical_decompiled_code:
void __fastcall func13(__int64 a1)
{
func10(a1);
free(*(void **)(a1 + 8));
}

original_code:
void znake_kill(struct znake_t *znake)
{
    znake_clear(znake);
    free(znake->body);
}


repo: xerpi/pspload

decompiled_code:
ssize_t __fastcall pspload_send(int a1, const void *a2, unsigned int a3)
{
ssize_t result; // rax

result = send(a1, a2, a3, 0);
if ( result == -1 )
{
perror("Error sending data");
result = -1LL;
}
return result;
}

canonical_decompiled_code:
ssize_t __fastcall func8(int a1, const void *a2, unsigned int a3)
{
ssize_t result; // rax

result = send(a1, a2, a3, 0);
if ( result == -1 )
{
perror("Error sending data");
result = -1LL;
}
return result;
}

original_code:
ssize_t pspload_send(int sock, void *data, uint32_t size)
{
    ssize_t ret = send(sock, data, size, 0);
    if (ret == -1) {
        perror("Error sending data");
    }
    return ret;
}

canonical_original_code:
long pspload_send(int sock, void *data, unsigned int size)
{
    long ret = send(sock, data, size, 0);
    if (ret == -1) {
        perror("Error sending data");
    }
    return ret;
}

variable_types: sock int

variable_types:
data
void *

variable_types:
size
unsigned int

variable_types: ret long

return_type: long


decompiled_code:
int print_usage()
{
return puts("Usage: pspload file <args>\nwill send file to the PSP");
}

canonical_decompiled_code:
int func9()
{
return puts("Usage: pspload file <args>\nwill send file to the PSP");
}

original_code:
void print_usage()
{
    printf("Usage: pspload file <args>\nwill send file to the PSP\n");
}


redimloe

repo: xhub/vinci

decompiled_code:
__int64 __fastcall redimloe(__int64 a1)
{
int v1; // esi
__int64 result; // rax

v1 = *(_DWORD *)a1 + 6;
*(_DWORD *)a1 += 5;
result = my_realloc(*(_QWORD *)(a1 + 8), 8LL * v1, 40LL);
*(_QWORD *)(a1 + 8) = result;
return result;
}

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

v1 = *(_DWORD *)a1 + 6;
*(_DWORD *)a1 += 5;
result = my_realloc(*(_QWORD *)(a1 + 8), 8LL * v1, 40LL);
*(_QWORD *)(a1 + 8) = result;
return result;
}

original_code:
static void redimloe (T_VertexSet *s)
{
   s -> maxel += 5;
   s -> loe = (T_Vertex **)
              my_realloc (s -> loe, (s -> maxel + 1) * sizeof (T_Vertex *),
                          5 * sizeof (T_Vertex *));
}

canonical_original_code:
static void redimloe(struct T_VertexSet *s)
{
   s -> maxel += 5;
   s -> loe = (struct T_Vertex **)
              my_realloc (s -> loe, (s -> maxel + 1) * sizeof (struct T_Vertex *),
                          5 * sizeof (struct T_Vertex *));
}

variable_types: struct T_VertexSet { int maxel; int lastel; struct T_Vertex { double *coords; int no; } **loe; } *

user_defined_types: struct T_VertexSet { int maxel; int lastel; struct T_Vertex **loe; }


decompiled_code:
unsigned __int64 create_empty_set()
{
int v0; // ebx

v0 = G_d;
my_malloc(8LL * (G_d + 6));
return (unsigned int)(v0 + 5) | 0xFFFFFFFF00000000LL;
}

canonical_decompiled_code:
unsigned __int64 func2()
{
int v0; // ebx

v0 = G_d;
my_malloc(8LL * (G_d + 6));
return (unsigned int)(v0 + 5) | 0xFFFFFFFF00000000LL;
}

original_code:
T_VertexSet create_empty_set ()
{ T_VertexSet s;
   s.maxel = G_d + 5;
   s.loe = ((void *)0);
   s.lastel = -1;
   s.loe = (T_Vertex **) my_malloc ((s.maxel + 1) * sizeof (T_Vertex *));
   return s;
}

canonical_original_code:
struct T_VertexSet create_empty_set()
{ struct T_VertexSet s;
   s.maxel = G_d + 5;
   s.loe = ((void *)0);
   s.lastel = -1;
   s.loe = (struct T_Vertex **) my_malloc ((s.maxel + 1) * sizeof (struct T_Vertex *));
   return s;
}

variable_types: struct T_VertexSet { int maxel; int lastel; struct T_Vertex { double *coords; int no; } **loe; }


decompiled_code:
__int64 __fastcall free_set(int a1, __int64 a2)
{
return my_free(a2, 8LL * (a1 + 1));
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, __int64 a2)
{
return my_free(a2, 8LL * (a1 + 1));
}

original_code:
void free_set (T_VertexSet s)
{
   my_free (s.loe, (s.maxel + 1) * sizeof (T_Vertex *));
}

canonical_original_code:
void free_set(struct T_VertexSet s)
{
   my_free (s.loe, (s.maxel + 1) * sizeof (struct T_Vertex *));
}

user_defined_types: struct T_Vertex { double *coords; int no; }


decompiled_code:
__int64 __fastcall free_set_and_vertices(__int64 a1, __int64 a2)
{
int v2; // er13
int v3; // er12
__int64 i; // rbx
__int64 v5; // rdi

v2 = a1;
v3 = HIDWORD(a1);
for ( i = 0LL; v3 >= (int)i; ++i )
{
v5 = *(_QWORD *)(a2 + 8 * i);
free_vertex(v5);
}
return free_set(v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
int v2; // er13
int v3; // er12
__int64 i; // rbx
__int64 v5; // rdi

v2 = a1;
v3 = HIDWORD(a1);
for ( i = 0LL; v3 >= (int)i; ++i )
{
v5 = *(_QWORD *)(a2 + 8 * i);
free_vertex(v5);
}
return func3(v2, a2);
}

original_code:
void free_set_and_vertices (T_VertexSet s)
{ int i;
   for (i = 0; i <= s.lastel; i++) free_vertex (s.loe [i]);
   free_set (s);
}

canonical_original_code:
void free_set_and_vertices(struct T_VertexSet s)
{ int i;
   for (i = 0; i <= s.lastel; i++) free_vertex (s.loe [i]);
   free_set (s);
}


decompiled_code:
void __fastcall clear_set(__int64 a1)
{
*(_DWORD *)(a1 + 4) = -1;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
*(_DWORD *)(a1 + 4) = -1;
}

original_code:
void clear_set (T_VertexSet *s)
{ (*s).lastel = -1;
}

canonical_original_code:
void clear_set(struct T_VertexSet *s)
{ (*s).lastel = -1;
}


decompiled_code:
__int64 __fastcall duplicate_set(__int64 a1, const void *a2)
{
void *v2; // rax

v2 = (void *)my_malloc(8LL * (HIDWORD(a1) + 1));
memcpy(v2, a2, 8LL * (HIDWORD(a1) + 1));
return (a1 >> 32 << 32) | HIDWORD(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, const void *a2)
{
void *v2; // rax

v2 = (void *)my_malloc(8LL * (HIDWORD(a1) + 1));
memcpy(v2, a2, 8LL * (HIDWORD(a1) + 1));
return (a1 >> 32 << 32) | HIDWORD(a1);
}

original_code:
T_VertexSet duplicate_set (T_VertexSet s)
{ T_VertexSet newset;
   newset.maxel = s.lastel;
   newset.lastel = s.lastel;
   newset.loe = (T_Vertex **) my_malloc ((s.lastel + 1) * sizeof (T_Vertex *));
   memcpy (newset.loe, s.loe, (s.lastel + 1) * sizeof (T_Vertex *));
   return newset;
}

canonical_original_code:
struct T_VertexSet duplicate_set(struct T_VertexSet s)
{ struct T_VertexSet newset;
   newset.maxel = s.lastel;
   newset.lastel = s.lastel;
   newset.loe = (struct T_Vertex **) my_malloc ((s.lastel + 1) * sizeof (struct T_Vertex *));
   memcpy (newset.loe, s.loe, (s.lastel + 1) * sizeof (struct T_Vertex *));
   return newset;
}

variable_types:
s
struct T_VertexSet

return_type: struct T_VertexSet { int maxel; int lastel; struct T_Vertex { double *coords; int no; } **loe; }


original_code:
void renumber_vertices ()
{
   int i, j, k;
   T_Vertex *tmp_vertex;
   boolean *tmp_incidence;
   for (i = 0; i < G_n; i++)
      G_Vertices.loe [i] -> no = 0;
   for (i = 0; i < G_n; i++)
      for (j = 0; j < G_m; j++)
         if (G_Incidence [i][j])
            G_Vertices.loe [i] -> no --;
   for (i = 0; i < G_n - 1; i++)
   {
      j = i;
      for (k = i + 1; k < G_n; k++)
         if (G_Vertices.loe [k] -> no < G_Vertices.loe [j] -> no)
            j = k;
      if (i != j)
      {
         tmp_vertex = G_Vertices.loe [i];
         G_Vertices.loe [i] = G_Vertices.loe [j];
         G_Vertices.loe [j] = tmp_vertex;
         if (G_Incidence != ((void *)0))
         {
            tmp_incidence = G_Incidence [i];
            G_Incidence [i] = G_Incidence [j];
            G_Incidence [j] = tmp_incidence;
         }
      }
   }
   for (i = 0; i < G_n; i++)
      G_Vertices.loe [i] -> no = i;
   printf ("Vertices reordered.\n");
}

canonical_original_code:
void renumber_vertices()
{
   int i; int j; int k;
   struct T_Vertex *tmp_vertex;
   unsigned char *tmp_incidence;
   for (i = 0; i < G_n; i++)
      G_Vertices.loe [i] -> no = 0;
   for (i = 0; i < G_n; i++)
      for (j = 0; j < G_m; j++)
         if (G_Incidence [i][j])
            G_Vertices.loe [i] -> no --;
   for (i = 0; i < G_n - 1; i++)
   {
      j = i;
      for (k = i + 1; k < G_n; k++)
         if (G_Vertices.loe [k] -> no < G_Vertices.loe [j] -> no)
            j = k;
      if (i != j)
      {
         tmp_vertex = G_Vertices.loe [i];
         G_Vertices.loe [i] = G_Vertices.loe [j];
         G_Vertices.loe [j] = tmp_vertex;
         if (G_Incidence != ((void *)0))
         {
            tmp_incidence = G_Incidence [i];
            G_Incidence [i] = G_Incidence [j];
            G_Incidence [j] = tmp_incidence;
         }
      }
   }
   for (i = 0; i < G_n; i++)
      G_Vertices.loe [i] -> no = i;
   printf ("Vertices reordered.\n");
}

variable_types: j int

variable_types: k int

variable_types: struct T_Vertex { double *coords; int no; } *


original_code:
rational normalise_vertices ()
{
   rational *scaling = create_vector ();
   rational scaling_volume = 1;
   rational absolute;
   int i, j;
   for (j = 0; j < G_d; j ++)
      scaling [j] = -1;
   for (j = 0; j < G_d; j++)
      for (i = 0; i <= G_Vertices.lastel; i++)
      { absolute = fabs (G_Vertices.loe [i] -> coords [j]);
         if (absolute > scaling [j])
            scaling [j] = absolute;
      }
   for (j = 0; j < G_d; j++)
   { scaling_volume *= scaling [j];
      for (i = 0; i <= G_Vertices.lastel; i++)
         G_Vertices.loe [i] -> coords [j] /= scaling [j];
   }
   my_free(scaling, sizeof(rational));
   return scaling_volume;
}

canonical_original_code:
double normalise_vertices()
{
   double *scaling = create_vector ();
   double scaling_volume = 1;
   double absolute;
   int i; int j;
   for (j = 0; j < G_d; j ++)
      scaling [j] = -1;
   for (j = 0; j < G_d; j++)
      for (i = 0; i <= G_Vertices.lastel; i++)
      { absolute = fabs (G_Vertices.loe [i] -> coords [j]);
         if (absolute > scaling [j])
            scaling [j] = absolute;
      }
   for (j = 0; j < G_d; j++)
   { scaling_volume *= scaling [j];
      for (i = 0; i <= G_Vertices.lastel; i++)
         G_Vertices.loe [i] -> coords [j] /= scaling [j];
   }
   my_free(scaling, sizeof(rational));
   return scaling_volume;
}

variable_types:
scaling
double *

variable_types: absolute double

return_type: double


empty

decompiled_code:
bool __fastcall empty(__int64 a1)
{
return HIDWORD(a1) == -1;
}

canonical_decompiled_code:
bool __fastcall func9(__int64 a1)
{
return HIDWORD(a1) == -1;
}

original_code:
boolean empty (T_VertexSet s)
{
   return (s.lastel == -1);
}

canonical_original_code:
unsigned char empty(struct T_VertexSet s)
{
   return (s.lastel == -1);
}

return_type: unsigned char


decompiled_code:
__int64 __fastcall is_in_hyperplane(__int64 a1, int a2)
{
return *(unsigned __int8 *)(*(_QWORD *)(G_Incidence + 8LL * *(int *)(a1 + 8)) + a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2)
{
return *(unsigned __int8 *)(*(_QWORD *)(G_Incidence + 8LL * *(int *)(a1 + 8)) + a2);
}

original_code:
boolean is_in_hyperplane (T_Vertex *e, int j)
{
   return G_Incidence [e -> no][j];
}

canonical_original_code:
unsigned char is_in_hyperplane(struct T_Vertex *e, int j)
{
   return G_Incidence [e -> no][j];
}


decompiled_code:
bool __fastcall are_equal_sets(__int64 a1, __int64 a2, __int64 a3)
{
bool result; // al
int v4; // ecx
const void *v5; // r8
const void *v6; // r9
bool v7; // r10

result = 0;
if ( HIDWORD(a1) == HIDWORD(a3) )
{
v7 = empty(a1);
result = 1;
if ( !v7 )
result = memcmp(v5, v6, 8LL * (v4 + 1)) == 0;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func12(__int64 a1, __int64 a2, __int64 a3)
{
bool result; // al
int v4; // ecx
const void *v5; // r8
const void *v6; // r9
bool v7; // r10

result = 0;
if ( HIDWORD(a1) == HIDWORD(a3) )
{
v7 = func9(a1);
result = 1;
if ( !v7 )
result = memcmp(v5, v6, 8LL * (v4 + 1)) == 0;
}
return result;
}

original_code:
boolean are_equal_sets (T_VertexSet s1, T_VertexSet s2)
{
   if (s1.lastel != s2.lastel) return 0;
   else if (empty (s1)) return 1;
   else
      return (!(memcmp (s1.loe, s2.loe, (s1.lastel + 1) * sizeof (T_Vertex *))));
}

canonical_original_code:
unsigned char are_equal_sets(struct T_VertexSet s1, struct T_VertexSet s2)
{
   if (s1.lastel != s2.lastel) return 0;
   else if (empty (s1)) return 1;
   else
      return (!(memcmp (s1.loe, s2.loe, (s1.lastel + 1) * sizeof (struct T_Vertex *))));
}


original_code:
void copy_set (T_VertexSet s1, T_VertexSet *s2)
{ int i;
   clear_set (s2);
   for (i = 0; i <= s1.lastel; i++) add_element (s2, s1.loe [i]);
}

canonical_original_code:
void copy_set(struct T_VertexSet s1, struct T_VertexSet *s2)
{ int i;
   clear_set (s2);
   for (i = 0; i <= s1.lastel; i++) add_element (s2, s1.loe [i]);
}

variable_types: i int


decompiled_code:
__int64 __fastcall delete_element(__int64 a1, __int64 a2)
{
signed int v2; // ebp
signed int v3; // eax
__int64 v4; // r11
unsigned int v5; // er8
int v6; // ebp

v2 = *(_DWORD *)(a1 + 4);
v3 = position_of_element_isra_0(*(_DWORD *)(a2 + 8), v2, *(_QWORD *)(a1 + 8));
v5 = 0;
if ( v3 != -1 )
{
if ( v3 >= v2 )
{
v6 = v2 - 1;
}
else
{
v6 = v2 - 1;
memmove((void *)(v4 + 8LL * v3), (const void *)(v4 + 8LL * v3 + 8), 8LL * (unsigned int)(v6 - v3) + 8);
}
*(_DWORD *)(a1 + 4) = v6;
v5 = 1;
}
return v5;
}

original_code:
boolean delete_element (T_VertexSet *s, T_Vertex *e)
{ int j, position;
   position = position_of_element (e, *s);
   if (position == -1) return 0;
   else
   { for (j = position; j < s -> lastel; j++)
         s -> loe [j] = s -> loe [j+1];
      s -> lastel --;
      return 1;
   }
}

canonical_original_code:
unsigned char delete_element(struct T_VertexSet *s, struct T_Vertex *e)
{ int j; int position;
   position = position_of_element (e, *s);
   if (position == -1) return 0;
   else
   { for (j = position; j < s -> lastel; j++)
         s -> loe [j] = s -> loe [j+1];
      s -> lastel --;
      return 1;
   }
}

variable_types:
e
struct T_Vertex *

variable_types: position int


original_code:
void intersect_with_hyperplane (T_VertexSet s, int j, T_VertexSet *inter)
{
   int i;
   inter -> lastel = -1;
   if (!(empty (s)))
      for (i = 0; i <= s.lastel; i++)
         if (is_in_hyperplane (s.loe [i], j))
            {
               if (inter -> lastel == inter -> maxel) redimloe (inter);
               inter -> loe [++ inter -> lastel] = s.loe [i];
            }
}

canonical_original_code:
void intersect_with_hyperplane(struct T_VertexSet s, int j, struct T_VertexSet *inter)
{
   int i;
   inter -> lastel = -1;
   if (!(empty (s)))
      for (i = 0; i <= s.lastel; i++)
         if (is_in_hyperplane (s.loe [i], j))
            {
               if (inter -> lastel == inter -> maxel) redimloe (inter);
               inter -> loe [++ inter -> lastel] = s.loe [i];
            }
}

variable_types:
inter
struct T_VertexSet *


decompiled_code:
__int64 create_empty_superset()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func17()
{
return 0LL;
}

original_code:
T_VertexSuperset *create_empty_superset ()
{ return ((void *)0);
}

canonical_original_code:
struct T_VertexSuperset *create_empty_superset()
{ return ((void *)0);
}

return_type: struct T_VertexSuperset { struct T_VertexSuperset *next; struct T_VertexSet { int maxel; int lastel; struct T_Vertex { double *coords; int no; } **loe; } content; } *

user_defined_types: struct T_VertexSuperset { struct T_VertexSuperset *next; struct T_VertexSet content; }


decompiled_code:
bool __fastcall is_in_superset(__int64 a1, __int64 a2, _QWORD *a3)
{
_QWORD *v3; // rbx
bool result; // al

if ( !a3 )
return 0;
v3 = a3;
while ( 1 )
{
result = are_equal_sets(v3[1], v3[2], a1);
if ( result )
break;
v3 = (_QWORD *)*v3;
if ( !v3 )
return result;
}
return 1;
}

canonical_decompiled_code:
bool __fastcall func20(__int64 a1, __int64 a2, _QWORD *a3)
{
_QWORD *v3; // rbx
bool result; // al

if ( !a3 )
return 0;
v3 = a3;
while ( 1 )
{
result = func12(v3[1], v3[2], a1);
if ( result )
break;
v3 = (_QWORD *)*v3;
if ( !v3 )
return result;
}
return 1;
}

original_code:
boolean is_in_superset (T_VertexSet s, T_VertexSuperset *S)
{ while (S != ((void *)0) && !are_equal_sets (S -> content, s)) S = S -> next;
   if (S == ((void *)0)) return 0;
   else return 1;
}

canonical_original_code:
unsigned char is_in_superset(struct T_VertexSet s, struct T_VertexSuperset *S)
{ while (S != ((void *)0) && !are_equal_sets (S -> content, s)) S = S -> next;
   if (S == ((void *)0)) return 0;
   else return 1;
}

variable_types: struct T_VertexSuperset { struct T_VertexSuperset *next; struct T_VertexSet content; } *


decompiled_code:
__int64 __fastcall determine_data_type(const char *a1)
{
unsigned int v1; // er8

v1 = 1;
if ( !strcmp(a1, "integer") )
return v1;
v1 = 2;
if ( !strcmp(a1, "real") )
return v1;
v1 = 3;
if ( !strcmp(a1, "rational") )
return v1;
fprintf(stderr, "\n***** ERROR: '%s' is not a known data type; use integer, real or rational.", a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
unsigned int v1; // er8

v1 = 1;
if ( !strcmp(a1, "integer") )
return v1;
v1 = 2;
if ( !strcmp(a1, "real") )
return v1;
v1 = 3;
if ( !strcmp(a1, "rational") )
return v1;
fprintf(stderr, "\n***** ERROR: '%s' is not a known data type; use integer, real or rational.", a1);
return 0LL;
}

original_code:
int determine_data_type (char *data_type)
{
   if (!strcmp (data_type, "integer"))
      return 1;
   else if (!strcmp (data_type, "real"))
      return 2;
   else if (!strcmp (data_type, "rational"))
      return 3;
   else
   { fprintf (stderr, "\n***** ERROR: '%s' is not a known data type; use integer, real or rational.",
              data_type);
      return 0;
   }
}

canonical_original_code:
int determine_data_type(char *data_type)
{
   if (!strcmp (data_type, "integer"))
      return 1;
   else if (!strcmp (data_type, "real"))
      return 2;
   else if (!strcmp (data_type, "rational"))
      return 3;
   else
   { fprintf (stderr, "\n***** ERROR: '%s' is not a known data type; use integer, real or rational.",
              data_type);
      return 0;
   }
}


decompiled_code:
size_t __fastcall sread_rational_value(_BYTE *a1, double *a2)
{
const char *v2; // rbx
const char *v3; // rbp
char *v4; // rax
char *v5; // r14
size_t result; // rax
const char *v7; // r15
int v8; // er13
const char *v9; // rbx
char *v10; // r14
int v11; // ebp
double v12; // [rsp+8h] [rbp-50h]
double v13; // [rsp+10h] [rbp-48h]
int v14; // [rsp+1Ch] [rbp-3Ch]

if ( *a1 == 45 )
{
v14 = -1;
v2 = a1 + 1;
}
else
{
v14 = 1;
v2 = &a1[*a1 == 43];
}
v3 = 0LL;
v4 = strchr(v2, 47);
v5 = v4;
if ( v4 )
{
*v4 = 0;
v3 = v4 + 1;
}
result = strlen(v2);
v12 = 0.0;
v7 = &v2[result];
while ( v2 != v7 )
{
v8 = *v2;
result = (size_t)strchr("0123456789", v8);
if ( result )
v12 = 10.0 * v12 + (double)v8 - 48.0;
++v2;
}
v13 = *(double *)&LC9;
if ( v5 )
{
v9 = v3;
result = strlen(v3);
v13 = 0.0;
v10 = (char *)&v3[result];
while ( v9 != v10 )
{
v11 = *v9;
result = (size_t)strchr("0123456789", v11);
if ( result )
v13 = 10.0 * v13 + (double)v11 - 48.0;
++v9;
}
}
*a2 = (double)v14 * v12 / v13;
return result;
}

original_code:
void sread_rational_value (char *s, rational *value)
{
   char *numerator_s, *denominator_s = ((void *)0), *position, token;
   int sign = 1, i;
   rational numerator, denominator;
   numerator_s = s;
   if (s [0] == '-')
   { sign = -1;
      numerator_s++;
   }
   else if (s [0] == '+')
      numerator_s++;
   position = strchr (numerator_s, '/');
   if (position != ((void *)0))
   { *position = '\0';
      denominator_s = position + 1;
   };
   numerator = 0;
   for (i = 0; i < strlen (numerator_s); i++)
   { token = numerator_s [i];
      if (strchr ("0123456789", token))
         numerator = 10 * numerator + (int) token - 48;
   }
   if (position != ((void *)0))
   { denominator = 0;
      for (i = 0; i < strlen (denominator_s); i++)
      { token = denominator_s [i];
         if (strchr ("0123456789", token))
            denominator = 10 * denominator + (int) token - 48;
      }
   }
   else denominator = 1;
   *value = sign * numerator / denominator;
}

canonical_original_code:
void sread_rational_value(char *s, double *value)
{
   char *numerator_s; char *denominator_s = ((void *)0); char *position; char token;
   int sign = 1; int i;
   double numerator; double denominator;
   numerator_s = s;
   if (s [0] == '-')
   { sign = -1;
      numerator_s++;
   }
   else if (s [0] == '+')
      numerator_s++;
   position = strchr (numerator_s, '/');
   if (position != ((void *)0))
   { *position = '\0';
      denominator_s = position + 1;
   };
   numerator = 0;
   for (i = 0; i < strlen (numerator_s); i++)
   { token = numerator_s [i];
      if (strchr ("0123456789", token))
         numerator = 10 * numerator + (int) token - 48;
   }
   if (position != ((void *)0))
   { denominator = 0;
      for (i = 0; i < strlen (denominator_s); i++)
      { token = denominator_s [i];
         if (strchr ("0123456789", token))
            denominator = 10 * denominator + (int) token - 48;
      }
   }
   else denominator = 1;
   *value = sign * numerator / denominator;
}

variable_types:
s
char *

variable_types:
value
double *

variable_types:
position
char *

variable_types: token char

variable_types: sign int

variable_types: numerator double

variable_types: denominator double


decompiled_code:
__int64 compute_incidence()
{
__int64 result; // rax
__int64 i; // r9
__int64 j; // rdi
__int64 v3; // rdx
double v4; // xmm1_8
__int64 v5; // rax
double v6; // xmm0_8

result = create_incidence();
for ( i = 0LL; G_m > (int)i; ++i )
{
result = G_n;
for ( j = 0LL; G_n > (int)j; ++j )
{
v3 = *(_QWORD *)(G_Hyperplanes + 8 * i);
v4 = *(double *)(v3 + 8LL * G_d);
if ( G_d > 0 )
{
v5 = 0LL;
do
{
v6 = *(double *)(**(_QWORD **)(G_Vertices[1] + 8 * j) + 8 * v5) * *(double *)(v3 + 8 * v5);
++v5;
v4 = v4 - v6;
}
while ( G_d != v5 );
}
result = G_Incidence;
*(_BYTE *)(i + *(_QWORD *)(G_Incidence + 8 * j)) = COERCE_DOUBLE(*(_QWORD *)&v4 & LC24) < 0.000001;
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
__int64 i; // r9
__int64 j; // rdi
__int64 v3; // rdx
double v4; // xmm1_8
__int64 v5; // rax
double v6; // xmm0_8

result = create_incidence();
for ( i = 0LL; G_m > (int)i; ++i )
{
result = G_n;
for ( j = 0LL; G_n > (int)j; ++j )
{
v3 = *(_QWORD *)(G_Hyperplanes + 8 * i);
v4 = *(double *)(v3 + 8LL * G_d);
if ( G_d > 0 )
{
v5 = 0LL;
do
{
v6 = *(double *)(**(_QWORD **)(G_Vertices[1] + 8 * j) + 8 * v5) * *(double *)(v3 + 8 * v5);
++v5;
v4 = v4 - v6;
}
while ( G_d != v5 );
}
result = G_Incidence;
*(_BYTE *)(i + *(_QWORD *)(G_Incidence + 8 * j)) = COERCE_DOUBLE(*(_QWORD *)&v4 & LC24) < 0.000001;
}
}
return result;
}

original_code:
void compute_incidence ()
{ int i, j, k;
   real diff;
   create_incidence ();
   for (j = 0; j < G_m; j++)
      for (i = 0; i < G_n; i++)
      {
         diff = G_Hyperplanes [j][G_d];
         for (k = 0; k < G_d; k++)
            diff -= (G_Vertices.loe [i] -> coords [k]) * G_Hyperplanes [j][k];
         if (fabs (diff) < 1e-6)
            G_Incidence [i][j] = 1;
         else
            G_Incidence [i][j] = 0;
     }
}

canonical_original_code:
void compute_incidence()
{ int i; int j; int k;
   double diff;
   create_incidence ();
   for (j = 0; j < G_m; j++)
      for (i = 0; i < G_n; i++)
      {
         diff = G_Hyperplanes [j][G_d];
         for (k = 0; k < G_d; k++)
            diff -= (G_Vertices.loe [i] -> coords [k]) * G_Hyperplanes [j][k];
         if (fabs (diff) < 1e-6)
            G_Incidence [i][j] = 1;
         else
            G_Incidence [i][j] = 0;
     }
}

variable_types: j int

variable_types: diff double


main

canonical_name: main

repo: xianjimli/png-image

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
void *v4; // rbp

if ( argc == 3 )
{
v4 = (void *)png_image_load(argv[1]);
png_image_save(argv[2], v4);
png_image_destroy(v4);
result = 0;
}
else
{
printf("Usage: %s <file_in> <file_out>\n", *argv);
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
void *v4; // rbp

if ( argc == 3 )
{
v4 = (void *)png_image_load(argv[1]);
func7(argv[2], v4);
func8(v4);
result = 0;
}
else
{
printf("Usage: %s <file_in> <file_out>\n", *argv);
result = 1;
}
return result;
}

original_code:
int main(int argc, char **argv)
{
 if (argc != 3)
 {
  printf("Usage: %s <file_in> <file_out>\n", argv[0]);
  return 1;
 }
 ImageData* image = png_image_load(argv[1]);
 process_file(image);
 png_image_save(argv[2], image);
 png_image_destroy(image);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 if (argc != 3)
 {
  printf("Usage: %s <file_in> <file_out>\n", argv[0]);
  return 1;
 }
 struct _ImageData *image = png_image_load(argv[1]);
 process_file(image);
 png_image_save(argv[2], image);
 png_image_destroy(image);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct _ImageData { int bit_depth; int color_type; unsigned int width; unsigned int height; unsigned int rowbytes; unsigned char **rows; } *


decompiled_code:
void __fastcall png_image_destroy(void *ptr)
{
void *v2; // r13
int v3; // eax
void **v4; // rbx
__int64 v5; // r12
void *v6; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = *((_DWORD *)ptr + 3);
if ( v3 )
{
v4 = (void **)*((_QWORD *)ptr + 3);
v5 = (__int64)v2 + 8 * (unsigned int)(v3 - 1) + 8;
do
{
v6 = *v4++;
free(v6);
}
while ( v4 != (void **)v5 );
}
free(v2);
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr)
{
void *v2; // r13
int v3; // eax
void **v4; // rbx
__int64 v5; // r12
void *v6; // rdi

if ( ptr )
{
v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
{
v3 = *((_DWORD *)ptr + 3);
if ( v3 )
{
v4 = (void **)*((_QWORD *)ptr + 3);
v5 = (__int64)v2 + 8 * (unsigned int)(v3 - 1) + 8;
do
{
v6 = *v4++;
free(v6);
}
while ( v4 != (void **)v5 );
}
free(v2);
}
free(ptr);
}
}

original_code:
void png_image_destroy(ImageData* image)
{
 unsigned int y = 0;
 if(image) {
  unsigned int height = image->height;
  unsigned char** row_pointers = image->rows;
  if(row_pointers) {
   for (y=0; y<height; y++)
   {
    free(row_pointers[y]);
   }
   free(row_pointers);
  }
  image->rows = ((void *)0);
  free(image);
 }
 return;
}

canonical_original_code:
void png_image_destroy(struct _ImageData *image)
{
 unsigned int y = 0;
 if(image) {
  unsigned int height = image->height;
  unsigned char **row_pointers = image->rows;
  if(row_pointers) {
   for (y=0; y<height; y++)
   {
    free(row_pointers[y]);
   }
   free(row_pointers);
  }
  image->rows = ((void *)0);
  free(image);
 }
 return;
}

variable_types:
y
unsigned int

variable_types:
height
unsigned int

user_defined_types: struct _ImageData { int bit_depth; int color_type; unsigned int width; unsigned int height; unsigned int rowbytes; unsigned char **rows; }


decompiled_code:
void process_file()
{
;
}

canonical_decompiled_code:
void func9()
{
;
}

original_code:
void process_file(ImageData* image)
{
 int x, y;
 unsigned int height = image->height;
 unsigned int width = image->width;
 png_bytep* row_pointers = image->rows;
 for (y=0; y<height; y++) {
   png_byte* row = row_pointers[y];
   for (x=0; x<width; x++) {
   }
 }
}

canonical_original_code:
void process_file(struct _ImageData *image)
{
 int x; int y;
 unsigned int height = image->height;
 unsigned int width = image->width;
 unsigned char **row_pointers = image->rows;
 for (y=0; y<height; y++) {
   unsigned char *row = row_pointers[y];
   for (x=0; x<width; x++) {
   }
 }
}

variable_types: x int

variable_types: y int

variable_types:
width
unsigned int

variable_types:
row
unsigned char *


repo: xiaobai/fib

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

if ( argc != 2 )
usage(argc, argv, envp);
v3 = strtol(argv[1], &endptr, 10);
generate(v3);
putchar(10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

if ( argc != 2 )
func7(argc, argv, envp);
v3 = strtol(argv[1], &endptr, 10);
func8(v3);
putchar(10);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
 if (argc != 2) {
  usage();
 }
 char *end;
 int terms = strtol(argv[1], &end, 10);
 generate(terms);
 printf("\n");
 return 0;
}

variable_types:
argv
char *[]

variable_types:
end
char *

variable_types: terms int


usage

decompiled_code:
void __noreturn usage()
{
puts("Invalid paramters.");
puts("fib: usage: fib [terms]");
exit(0);
}

canonical_decompiled_code:
void __noreturn func7()
{
puts("Invalid paramters.");
puts("fib: usage: fib [terms]");
exit(0);
}

original_code:
void usage()
{
 printf("Invalid paramters.\n");
 printf("fib: usage: fib [terms]\n");
 exit(0);
}


generate

decompiled_code:
__int64 __fastcall generate(unsigned __int64 a1)
{
unsigned __int64 v1; // rbx

v1 = 0LL;
__gmpz_init();
do
{
++v1;
__gmpz_fib_ui();
__gmp_printf();
}
while ( a1 >= v1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int64 a1)
{
unsigned __int64 v1; // rbx

v1 = 0LL;
__gmpz_init();
do
{
++v1;
__gmpz_fib_ui();
__gmp_printf();
}
while ( a1 >= v1 );
return 0LL;
}

original_code:
int generate(unsigned long terms)
{
 unsigned long i;
 mpz_t F_i;
 __gmpz_init(F_i);
 for (i = 0; i <= terms; i++) {
  __gmpz_fib_ui(F_i, i);
  __gmp_printf("%Zd ", F_i);
 }
 return 0;
}

canonical_original_code:
int generate(unsigned long terms)
{
 unsigned long i;
 struct __mpz_struct F_i[1];
 __gmpz_init(F_i);
 for (i = 0; i <= terms; i++) {
  __gmpz_fib_ui(F_i, i);
  __gmp_printf("%Zd ", F_i);
 }
 return 0;
}

variable_types:
terms
unsigned long

variable_types:
i
unsigned long

variable_types: struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; } [1]


repo: xiaotmiaomiao/unixODBC-SPEC

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

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

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

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

original_code:
EnvironmentClass
*EN_Constructor(void)
{
EnvironmentClass *rv;
    rv = (EnvironmentClass *) malloc(sizeof(EnvironmentClass));
    if( rv) {
  rv->errormsg = 0;
  rv->errornumber = 0;
 }
    return rv;
}

canonical_original_code:
struct EnvironmentClass_ *EN_Constructor()
{
struct EnvironmentClass_ *rv;
    rv = (struct EnvironmentClass_ *) malloc(sizeof(EnvironmentClass));
    if( rv) {
  rv->errormsg = 0;
  rv->errornumber = 0;
 }
    return rv;
}

variable_types: struct EnvironmentClass_ { char *errormsg; int errornumber; } *


decompiled_code:
__int64 __fastcall EN_Destructor(void *ptr)
{
unsigned int v1; // er13
void ***v2; // rbx
void ***v3; // rbp

v1 = 1;
mylog("in EN_Destructor, self=%u\n", ptr);
v2 = (void ***)&conns;
v3 = (void ***)((char *)&conns + 1024);
do
{
while ( !*v2 || **v2 != ptr || !(_BYTE)v1 )
{
if ( v3 == ++v2 )
goto LABEL_7;
}
LOBYTE(v1) = (unsigned __int8)CC_Destructor() != 0;
++v2;
}
while ( v3 != v2 );
LABEL_7:
free(ptr);
mylog("exit EN_Destructor: rv = %d\n", (unsigned int)(char)v1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
unsigned int v1; // er13
void ***v2; // rbx
void ***v3; // rbp

v1 = 1;
mylog("in EN_Destructor, self=%u\n", ptr);
v2 = (void ***)&conns;
v3 = (void ***)((char *)&conns + 1024);
do
{
while ( !*v2 || **v2 != ptr || !(_BYTE)v1 )
{
if ( v3 == ++v2 )
goto LABEL_7;
}
LOBYTE(v1) = (unsigned __int8)CC_Destructor() != 0;
++v2;
}
while ( v3 != v2 );
LABEL_7:
free(ptr);
mylog("exit EN_Destructor: rv = %d\n", (unsigned int)(char)v1);
return v1;
}

original_code:
char
EN_Destructor(EnvironmentClass *self)
{
int lf;
char rv = 1;
 mylog("in EN_Destructor, self=%u\n", self);
 for (lf = 0; lf < 128; lf++) {
  if (conns[lf] && conns[lf]->henv == (HENV) self)
   rv = rv && CC_Destructor(conns[lf]);
 }
    free( self );
 mylog("exit EN_Destructor: rv = %d\n", rv);
 return rv;
}

canonical_original_code:
char EN_Destructor(struct EnvironmentClass_ *self)
{
int lf;
char rv = 1;
 mylog("in EN_Destructor, self=%u\n", self);
 for (lf = 0; lf < 128; lf++) {
  if (conns[lf] && conns[lf]->henv == (void *) self)
   rv = rv && CC_Destructor(conns[lf]);
 }
    free( self );
 mylog("exit EN_Destructor: rv = %d\n", rv);
 return rv;
}

variable_types: lf int

variable_types: rv char

return_type: char

user_defined_types: struct EnvironmentClass_ { char *errormsg; int errornumber; }


decompiled_code:
__int64 __fastcall EN_get_error(__int64 a1, _DWORD *a2, _QWORD *a3)
{
int v3; // er8
__int64 result; // rax

if ( !a1 || !*(_QWORD *)a1 )
return 0LL;
v3 = *(_DWORD *)(a1 + 8);
result = 0LL;
if ( v3 )
{
*a3 = *(_QWORD *)a1;
result = 1LL;
*a2 = v3;
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 8) = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, _DWORD *a2, _QWORD *a3)
{
int v3; // er8
__int64 result; // rax

if ( !a1 || !*(_QWORD *)a1 )
return 0LL;
v3 = *(_DWORD *)(a1 + 8);
result = 0LL;
if ( v3 )
{
*a3 = *(_QWORD *)a1;
result = 1LL;
*a2 = v3;
*(_QWORD *)a1 = 0LL;
*(_DWORD *)(a1 + 8) = 0;
}
return result;
}

original_code:
char
EN_get_error(EnvironmentClass *self, int *number, char **message)
{
 if(self && self->errormsg && self->errornumber) {
  *message = self->errormsg;
  *number = self->errornumber;
  self->errormsg = 0;
  self->errornumber = 0;
  return 1;
 } else {
  return 0;
 }
}

canonical_original_code:
char EN_get_error(struct EnvironmentClass_ *self, int *number, char **message)
{
 if(self && self->errormsg && self->errornumber) {
  *message = self->errormsg;
  *number = self->errornumber;
  self->errormsg = 0;
  self->errornumber = 0;
  return 1;
 } else {
  return 0;
 }
}

variable_types:
number
int *

variable_types:
message
char **


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

if ( a3 )
result = qlog(
"ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n",
a1,
a2,
*(unsigned int *)(a3 + 8),
*(const char **)a3);
else
result = qlog("INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", a1, a2);
return result;
}

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

if ( a3 )
result = qlog(
"ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n",
a1,
a2,
*(unsigned int *)(a3 + 8),
*(const char **)a3);
else
result = qlog("INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", a1, a2);
return result;
}

original_code:
void
EN_log_error(char *func, char *desc, EnvironmentClass *self)
{
 if (self) {
  qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
 }
 else
  qlog("INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
}

canonical_original_code:
void EN_log_error(char *func, char *desc, struct EnvironmentClass_ *self)
{
 if (self) {
  qlog("ENVIRON ERROR: func=%s, desc='%s', errnum=%d, errmsg='%s'\n", func, desc, self->errornumber, self->errormsg);
 }
 else
  qlog("INVALID ENVIRON HANDLE ERROR: func=%s, desc='%s'\n", func, desc);
}

variable_types:
func
char *

variable_types:
desc
char *


SQLAllocEnv

decompiled_code:
__int64 __fastcall SQLAllocEnv(_QWORD *a1)
{
_DWORD *v1; // rax
__int64 result; // rax

mylog("**** in SQLAllocEnv ** \n");
getGlobalDefaults("PostgreSQL", "ODBCINST.INI", 0LL);
v1 = EN_Constructor();
*a1 = v1;
if ( v1 )
{
mylog("** exit SQLAllocEnv: phenv = %u **\n", v1);
result = 0LL;
}
else
{
EN_log_error("SQLAllocEnv", "Error allocating environment", 0LL);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1)
{
_DWORD *v1; // rax
__int64 result; // rax

mylog("**** in SQLAllocEnv ** \n");
getGlobalDefaults("PostgreSQL", "ODBCINST.INI", 0LL);
v1 = func0();
*a1 = v1;
if ( v1 )
{
mylog("** exit SQLAllocEnv: phenv = %u **\n", v1);
result = 0LL;
}
else
{
func6("SQLAllocEnv", "Error allocating environment", 0LL);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
RETCODE SQLAllocEnv(HENV *phenv)
{
static char* const func = "SQLAllocEnv";
mylog("**** in SQLAllocEnv ** \n");
 getGlobalDefaults("PostgreSQL", "ODBCINST.INI", (int)0);
 *phenv = (HENV) EN_Constructor();
 if ( ! *phenv) {
  *phenv = 0;
  EN_log_error(func, "Error allocating environment", ((void *)0));
  return (-1);
 }
 mylog("** exit SQLAllocEnv: phenv = %u **\n", *phenv);
 return 0;
}

canonical_original_code:
short SQLAllocEnv(void **phenv)
{
static char *func = "SQLAllocEnv";
mylog("**** in SQLAllocEnv ** \n");
 getGlobalDefaults("PostgreSQL", "ODBCINST.INI", (int)0);
 *phenv = (void *) EN_Constructor();
 if ( ! *phenv) {
  *phenv = 0;
  EN_log_error(func, "Error allocating environment", ((void *)0));
  return (-1);
 }
 mylog("** exit SQLAllocEnv: phenv = %u **\n", *phenv);
 return 0;
}

variable_types:
phenv
void **

return_type: short


SQLFreeEnv

decompiled_code:
__int64 __fastcall SQLFreeEnv(void *ptr)
{
__int64 result; // rax

mylog("**** in SQLFreeEnv: env = %u ** \n", ptr);
if ( ptr && (unsigned __int8)EN_Destructor(ptr) )
{
mylog(" ok\n");
result = 0LL;
}
else
{
mylog(" error\n");
EN_log_error("SQLFreeEnv", "Error freeing environment", (__int64)ptr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(void *ptr)
{
__int64 result; // rax

mylog("**** in SQLFreeEnv: env = %u ** \n", ptr);
if ( ptr && (unsigned __int8)func1(ptr) )
{
mylog(" ok\n");
result = 0LL;
}
else
{
mylog(" error\n");
func6("SQLFreeEnv", "Error freeing environment", (__int64)ptr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
RETCODE SQLFreeEnv(HENV henv)
{
static char* const func = "SQLFreeEnv";
EnvironmentClass *env = (EnvironmentClass *) henv;
mylog("**** in SQLFreeEnv: env = %u ** \n", env);
 if (env && EN_Destructor(env)) {
  mylog("   ok\n");
  return 0;
 }
 mylog("    error\n");
 EN_log_error(func, "Error freeing environment", env);
 return (-1);
}

canonical_original_code:
short SQLFreeEnv(void *henv)
{
static char *func = "SQLFreeEnv";
struct EnvironmentClass_ *env = (EnvironmentClass *) henv;
mylog("**** in SQLFreeEnv: env = %u ** \n", env);
 if (env && EN_Destructor(env)) {
  mylog("   ok\n");
  return 0;
 }
 mylog("    error\n");
 EN_log_error(func, "Error freeing environment", env);
 return (-1);
}

variable_types:
henv
void *


SQLValidDSN

decompiled_code:
_BOOL8 __fastcall SQLValidDSN(char *s)
{
_BOOL4 v1; // er12

v1 = 0;
inst_logClear();
if ( s
&& *s
&& strlen(s) <= 0x20
&& !strchr(s, 91)
&& !strchr(s, 93)
&& !strchr(s, 123)
&& !strchr(s, 125)
&& !strchr(s, 40)
&& !strchr(s, 41)
&& !strchr(s, 44)
&& !strchr(s, 59)
&& !strchr(s, 63)
&& !strchr(s, 42)
&& !strchr(s, 61)
&& !strchr(s, 33)
&& !strchr(s, 64) )
{
v1 = strchr(s, 92) == 0LL;
}
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s)
{
_BOOL4 v1; // er12

v1 = 0;
inst_logClear();
if ( s
&& *s
&& strlen(s) <= 0x20
&& !strchr(s, 91)
&& !strchr(s, 93)
&& !strchr(s, 123)
&& !strchr(s, 125)
&& !strchr(s, 40)
&& !strchr(s, 41)
&& !strchr(s, 44)
&& !strchr(s, 59)
&& !strchr(s, 63)
&& !strchr(s, 42)
&& !strchr(s, 61)
&& !strchr(s, 33)
&& !strchr(s, 64) )
{
v1 = strchr(s, 92) == 0LL;
}
return v1;
}

original_code:
int SQLValidDSN( LPCSTR pszDSN )
{
    inst_logClear();
 if ( pszDSN == ((void *)0) )
  return 0;
 if ( strlen( pszDSN ) < 1 || strlen( pszDSN ) > 32 )
  return 0;
 if ( strstr( pszDSN, "[" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "]" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "{" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "}" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "(" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, ")" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "," ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, ";" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "?" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "*" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "=" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "!" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "@" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "\\" ) != ((void *)0) )
  return 0;
 return 1;
}

canonical_original_code:
int SQLValidDSN(char *pszDSN)
{
    inst_logClear();
 if ( pszDSN == ((void *)0) )
  return 0;
 if ( strlen( pszDSN ) < 1 || strlen( pszDSN ) > 32 )
  return 0;
 if ( strstr( pszDSN, "[" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "]" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "{" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "}" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "(" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, ")" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "," ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, ";" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "?" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "*" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "=" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "!" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "@" ) != ((void *)0) )
  return 0;
 if ( strstr( pszDSN, "\\" ) != ((void *)0) )
  return 0;
 return 1;
}

variable_types:
pszDSN
char *


SQLValidDSNW

decompiled_code:
_BOOL8 __fastcall SQLValidDSNW(__int64 a1)
{
char *v1; // rbp
_BOOL4 v2; // er12

inst_logClear();
v1 = (char *)single_string_alloc_and_copy(a1);
v2 = SQLValidDSN(v1);
free(v1);
return v2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
char *v1; // rbp
_BOOL4 v2; // er12

inst_logClear();
v1 = (char *)single_string_alloc_and_copy(a1);
v2 = func0(v1);
free(v1);
return v2;
}

original_code:
int SQLValidDSNW(LPCWSTR lpszDSN)
{
 char *dsn;
 int ret;
    inst_logClear();
 dsn = _single_string_alloc_and_copy( lpszDSN );
 ret = SQLValidDSN( dsn );
 free( dsn );
 return ret;
}

canonical_original_code:
int SQLValidDSNW(unsigned short *lpszDSN)
{
 char *dsn;
 int ret;
    inst_logClear();
 dsn = _single_string_alloc_and_copy( lpszDSN );
 ret = SQLValidDSN( dsn );
 free( dsn );
 return ret;
}

variable_types:
lpszDSN
unsigned short *

variable_types:
dsn
char *

variable_types: ret int


CreateDataSource

decompiled_code:
_BOOL8 __fastcall CreateDataSource(_BYTE *a1)
{
_BYTE *v1; // rsi
char v3[4096]; // [rsp+0h] [rbp-1018h] BYREF
__int64 v4; // [rsp+1000h] [rbp-18h]

v1 = a1;
strcpy(v3, "odbcinstQ4");
v4 = 0LL;
if ( a1 && !*a1 )
v1 = 0LL;
return (unsigned int)SQLCreateDataSource(v3, v1) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1)
{
_BYTE *v1; // rsi
char v3[4096]; // [rsp+0h] [rbp-1018h] BYREF
__int64 v4; // [rsp+1000h] [rbp-18h]

v1 = a1;
strcpy(v3, "odbcinstQ4");
v4 = 0LL;
if ( a1 && !*a1 )
v1 = 0LL;
return (unsigned int)SQLCreateDataSource(v3, v1) == 0;
}

original_code:
int CreateDataSource( char *pszDataSourceName )
{
    ODBCINSTWND odbcinstwnd;
    odbcinstwnd.hWnd = 0;
    strcpy( odbcinstwnd.szUI, "odbcinstQ4" );
    if ( SQLCreateDataSource( (HWND)&(odbcinstwnd), ( (pszDataSourceName && *pszDataSourceName) ? pszDataSourceName : 0 ) ) == 0 )
        return 1;
    return 0;
}

canonical_original_code:
int CreateDataSource(char *pszDataSourceName)
{
    struct tODBCINSTWND odbcinstwnd;
    odbcinstwnd.hWnd = 0;
    strcpy( odbcinstwnd.szUI, "odbcinstQ4" );
    if ( SQLCreateDataSource( (HWND)&(odbcinstwnd), ( (pszDataSourceName && *pszDataSourceName) ? pszDataSourceName : 0 ) ) == 0 )
        return 1;
    return 0;
}

variable_types:
pszDataSourceName
char *

variable_types: struct tODBCINSTWND { char szUI[4096]; void *hWnd; }


ManageDataSources

decompiled_code:
_BOOL8 ManageDataSources()
{
char v1[4096]; // [rsp+0h] [rbp-1018h] BYREF
__int64 v2; // [rsp+1000h] [rbp-18h]

strcpy(v1, "odbcinstQ4");
v2 = 0LL;
return (unsigned int)SQLManageDataSources(v1) == 0;
}

canonical_decompiled_code:
_BOOL8 func1()
{
char v1[4096]; // [rsp+0h] [rbp-1018h] BYREF
__int64 v2; // [rsp+1000h] [rbp-18h]

strcpy(v1, "odbcinstQ4");
v2 = 0LL;
return (unsigned int)SQLManageDataSources(v1) == 0;
}

original_code:
int ManageDataSources()
{
    ODBCINSTWND odbcinstwnd;
    odbcinstwnd.hWnd = 0;
    strcpy( odbcinstwnd.szUI, "odbcinstQ4" );
    if ( SQLManageDataSources( (HWND)&(odbcinstwnd) ) == 0 )
        return 1;
    return 0;
}

canonical_original_code:
int ManageDataSources()
{
    struct tODBCINSTWND odbcinstwnd;
    odbcinstwnd.hWnd = 0;
    strcpy( odbcinstwnd.szUI, "odbcinstQ4" );
    if ( SQLManageDataSources( (HWND)&(odbcinstwnd) ) == 0 )
        return 1;
    return 0;
}

user_defined_types: struct tODBCINSTWND { char szUI[4096]; void *hWnd; }


DriverUninstall

decompiled_code:
__int64 __fastcall DriverUninstall(const char *a1)
{
unsigned int v1; // er12
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

if ( !(unsigned int)SQLRemoveDriver(a1, 0LL, v3) )
{
v1 = 1;
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLRemoveDriver failed with %s.\n", szError);
return v1;
}
v1 = 0;
if ( v3[0] )
{
if ( cVerbose )
return v1;
printf("%s usage count has been reduced to %d\n", a1, v3[0]);
result = 0LL;
}
else
{
if ( cVerbose )
return v1;
printf("%s has been deleted (if it existed at all) because its usage count became zero\n", a1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
unsigned int v1; // er12
__int64 result; // rax
__int64 v3[4]; // [rsp+8h] [rbp-20h] BYREF

if ( !(unsigned int)SQLRemoveDriver(a1, 0LL, v3) )
{
v1 = 1;
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLRemoveDriver failed with %s.\n", szError);
return v1;
}
v1 = 0;
if ( v3[0] )
{
if ( cVerbose )
return v1;
printf("%s usage count has been reduced to %d\n", a1, v3[0]);
result = 0LL;
}
else
{
if ( cVerbose )
return v1;
printf("%s has been deleted (if it existed at all) because its usage count became zero\n", a1);
result = 0LL;
}
return result;
}

original_code:
int DriverUninstall( char *pszDriver )
{
    DWORD nUsageCount;
    if ( SQLRemoveDriver( pszDriver, 0, &nUsageCount ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLRemoveDriver failed with %s.\n", szError );
        return 1;
    }
    if ( nUsageCount == 0 )
    {
        if ( cVerbose == 0 ) printf( "%s has been deleted (if it existed at all) because its usage count became zero\n", pszDriver );
    }
    else
    {
        if ( cVerbose == 0 ) printf( "%s usage count has been reduced to %d\n", pszDriver, (int)nUsageCount );
    }
    return 0;
}

canonical_original_code:
int DriverUninstall(char *pszDriver)
{
    unsigned long nUsageCount;
    if ( SQLRemoveDriver( pszDriver, 0, &nUsageCount ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLRemoveDriver failed with %s.\n", szError );
        return 1;
    }
    if ( nUsageCount == 0 )
    {
        if ( cVerbose == 0 ) printf( "%s has been deleted (if it existed at all) because its usage count became zero\n", pszDriver );
    }
    else
    {
        if ( cVerbose == 0 ) printf( "%s usage count has been reduced to %d\n", pszDriver, (int)nUsageCount );
    }
    return 0;
}

variable_types:
pszDriver
char *

variable_types:
nUsageCount
unsigned long


DriverQuery

decompiled_code:
__int64 __fastcall DriverQuery(const char *a1)
{
char *j; // rbx
__int64 result; // rax
char *i; // rbx
char v4[512]; // [rsp+0h] [rbp-11E8h] BYREF
char s[4072]; // [rsp+200h] [rbp-FE8h] BYREF

if ( a1 && *a1 )
{
if ( (int)SQLGetPrivateProfileString(a1, 0LL, 0LL, s, 4047LL, "ODBCINST.INI") > 0 )
{
printf("[%s]\n", a1);
for ( i = s; *i; i += strlen(i) + 1 )
{
printf("%s=", i);
if ( (int)SQLGetPrivateProfileString(a1, i, &unk_1CE1, v4, 500LL, "ODBCINST.INI") > 0 )
printf("%s", v4);
putchar(10);
}
return 0LL;
}
}
else if ( (int)SQLGetPrivateProfileString(0LL, 0LL, 0LL, s, 4047LL, "ODBCINST.INI") > 0 )
{
for ( j = s; *j; j += strlen(j) + 1 )
printf("[%s]\n", j);
return 0LL;
}
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
result = 1LL;
if ( !cVerbose )
{
printf("odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1)
{
char *j; // rbx
__int64 result; // rax
char *i; // rbx
char v4[512]; // [rsp+0h] [rbp-11E8h] BYREF
char s[4072]; // [rsp+200h] [rbp-FE8h] BYREF

if ( a1 && *a1 )
{
if ( (int)SQLGetPrivateProfileString(a1, 0LL, 0LL, s, 4047LL, "ODBCINST.INI") > 0 )
{
printf("[%s]\n", a1);
for ( i = s; *i; i += strlen(i) + 1 )
{
printf("%s=", i);
if ( (int)SQLGetPrivateProfileString(a1, i, &unk_1CE1, v4, 500LL, "ODBCINST.INI") > 0 )
printf("%s", v4);
putchar(10);
}
return 0LL;
}
}
else if ( (int)SQLGetPrivateProfileString(0LL, 0LL, 0LL, s, 4047LL, "ODBCINST.INI") > 0 )
{
for ( j = s; *j; j += strlen(j) + 1 )
printf("[%s]\n", j);
return 0LL;
}
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
result = 1LL;
if ( !cVerbose )
{
printf("odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError);
result = 1LL;
}
return result;
}

original_code:
int DriverQuery( char *pszDriver )
{
    char szResults[4048];
    char szValue[501];
    char *ptr;
    if ( pszDriver && (*pszDriver) )
    {
        if ( SQLGetPrivateProfileString( pszDriver, ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBCINST.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            return 1;
        }
        printf( "[%s]\n", pszDriver );
        ptr = szResults;
        while ( *ptr )
        {
            printf( "%s=", ptr );
            if ( SQLGetPrivateProfileString( pszDriver, ptr, "", szValue, sizeof( szValue ) - 1, "ODBCINST.INI" ) > 0 )
            {
                printf( "%s", szValue );
            }
            printf( "\n" );
            ptr += strlen( ptr ) + 1;
        }
    }
    else
    {
        if ( SQLGetPrivateProfileString( ((void *)0), ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBCINST.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            return 1;
        }
        ptr = szResults;
        while ( *ptr )
        {
            printf( "[%s]\n", ptr );
            ptr += strlen( ptr ) + 1;
        }
    }
    return 0;
}

canonical_original_code:
int DriverQuery(char *pszDriver)
{
    char szResults[4048];
    char szValue[501];
    char *ptr;
    if ( pszDriver && (*pszDriver) )
    {
        if ( SQLGetPrivateProfileString( pszDriver, ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBCINST.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            return 1;
        }
        printf( "[%s]\n", pszDriver );
        ptr = szResults;
        while ( *ptr )
        {
            printf( "%s=", ptr );
            if ( SQLGetPrivateProfileString( pszDriver, ptr, "", szValue, sizeof( szValue ) - 1, "ODBCINST.INI" ) > 0 )
            {
                printf( "%s", szValue );
            }
            printf( "\n" );
            ptr += strlen( ptr ) + 1;
        }
    }
    else
    {
        if ( SQLGetPrivateProfileString( ((void *)0), ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBCINST.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            return 1;
        }
        ptr = szResults;
        while ( *ptr )
        {
            printf( "[%s]\n", ptr );
            ptr += strlen( ptr ) + 1;
        }
    }
    return 0;
}

variable_types:
szResults
char [4048]

variable_types:
szValue
char [501]

variable_types:
ptr
char *


DSNUninstall

decompiled_code:
__int64 __fastcall DSNUninstall(__int64 a1)
{
const char *v1; // rsi
unsigned int v2; // er12
__int16 v4[13]; // [rsp+Eh] [rbp-1Ah] BYREF

if ( system_dsn )
{
SQLSetConfigMode(2LL);
LABEL_3:
if ( (unsigned int)SQLGetConfigMode(v4) )
goto LABEL_4;
LABEL_11:
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLGetConfigMode failed with %s.\n", szError);
return 1LL;
}
if ( !user_dsn )
goto LABEL_3;
SQLSetConfigMode(1LL);
if ( !(unsigned int)SQLGetConfigMode(v4) )
goto LABEL_11;
LABEL_4:
if ( !(unsigned int)SQLRemoveDSNFromIni(a1) )
{
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
{
v2 = 1;
printf("odbcinst: SQLRemoveDSNFromIni failed with %s.\n", szError);
return v2;
}
return 1LL;
}
v1 = "Unknown mode";
if ( v4[0] <= 2u )
{
v2 = 0;
v1 = CSWTCH_75[(unsigned __int16)v4[0]];
if ( cVerbose )
return v2;
}
else
{
v2 = 0;
if ( cVerbose )
return v2;
}
printf("odbcinst: DSN removed (if it existed at all). %s was used as the search path.\n", v1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
const char *v1; // rsi
unsigned int v2; // er12
__int16 v4[13]; // [rsp+Eh] [rbp-1Ah] BYREF

if ( system_dsn )
{
SQLSetConfigMode(2LL);
LABEL_3:
if ( (unsigned int)SQLGetConfigMode(v4) )
goto LABEL_4;
LABEL_11:
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLGetConfigMode failed with %s.\n", szError);
return 1LL;
}
if ( !user_dsn )
goto LABEL_3;
SQLSetConfigMode(1LL);
if ( !(unsigned int)SQLGetConfigMode(v4) )
goto LABEL_11;
LABEL_4:
if ( !(unsigned int)SQLRemoveDSNFromIni(a1) )
{
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
{
v2 = 1;
printf("odbcinst: SQLRemoveDSNFromIni failed with %s.\n", szError);
return v2;
}
return 1LL;
}
v1 = "Unknown mode";
if ( v4[0] <= 2u )
{
v2 = 0;
v1 = CSWTCH_75[(unsigned __int16)v4[0]];
if ( cVerbose )
return v2;
}
else
{
v2 = 0;
if ( cVerbose )
return v2;
}
printf("odbcinst: DSN removed (if it existed at all). %s was used as the search path.\n", v1);
return 0LL;
}

original_code:
int DSNUninstall( char *pszDSN )
{
    UWORD nConfigMode;
    char *pMode;
    if ( system_dsn )
    {
        SQLSetConfigMode( 2 );
    }
    else if ( user_dsn )
    {
        SQLSetConfigMode( 1 );
    }
    if ( SQLGetConfigMode( &nConfigMode ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLGetConfigMode failed with %s.\n", szError );
        return 1;
    }
    if ( SQLRemoveDSNFromIni( pszDSN ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLRemoveDSNFromIni failed with %s.\n", szError );
        return 1;
    }
    switch ( nConfigMode )
    {
        case 2:
            pMode = "ODBC_SYSTEM_DSN";
            break;
        case 1:
            pMode = "ODBC_USER_DSN";
            break;
        case 0:
            pMode = "ODBC_BOTH_DSN";
            break;
        default:
            pMode = "Unknown mode";
    }
    if ( cVerbose == 0 ) printf( "odbcinst: DSN removed (if it existed at all). %s was used as the search path.\n", pMode );
    return 0;
}

canonical_original_code:
int DSNUninstall(char *pszDSN)
{
    unsigned short nConfigMode;
    char *pMode;
    if ( system_dsn )
    {
        SQLSetConfigMode( 2 );
    }
    else if ( user_dsn )
    {
        SQLSetConfigMode( 1 );
    }
    if ( SQLGetConfigMode( &nConfigMode ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLGetConfigMode failed with %s.\n", szError );
        return 1;
    }
    if ( SQLRemoveDSNFromIni( pszDSN ) == 0 )
    {
        SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
        if ( cVerbose == 0 ) printf( "odbcinst: SQLRemoveDSNFromIni failed with %s.\n", szError );
        return 1;
    }
    switch ( nConfigMode )
    {
        case 2:
            pMode = "ODBC_SYSTEM_DSN";
            break;
        case 1:
            pMode = "ODBC_USER_DSN";
            break;
        case 0:
            pMode = "ODBC_BOTH_DSN";
            break;
        default:
            pMode = "Unknown mode";
    }
    if ( cVerbose == 0 ) printf( "odbcinst: DSN removed (if it existed at all). %s was used as the search path.\n", pMode );
    return 0;
}

variable_types:
nConfigMode
unsigned short

variable_types:
pMode
char *


DSNQuery

decompiled_code:
__int64 __fastcall DSNQuery(const char *a1)
{
char *i; // rbx
char *v3; // rbx
char v4[512]; // [rsp+0h] [rbp-27A8h] BYREF
char s[9640]; // [rsp+200h] [rbp-25A8h] BYREF

s[0] = 0;
if ( system_dsn )
{
SQLSetConfigMode(2LL);
}
else if ( user_dsn )
{
SQLSetConfigMode(1LL);
}
if ( a1 && *a1 )
{
if ( (int)SQLGetPrivateProfileString(a1, 0LL, 0LL, s, 9600LL, "ODBC.INI") > 0 )
{
printf("[%s]\n", a1);
if ( s[0] )
{
v3 = s;
do
{
printf("%s=", v3);
if ( (int)SQLGetPrivateProfileString(a1, v3, &unk_1CE1, v4, 500LL, "ODBC.INI") > 0 )
printf("%s", v4);
putchar(10);
v3 += strlen(v3) + 1;
}
while ( *v3 );
}
goto LABEL_9;
}
}
else if ( (int)SQLGetPrivateProfileString(0LL, 0LL, 0LL, s, 9600LL, "ODBC.INI") > 0 )
{
for ( i = s; *i; i += strlen(i) + 1 )
printf("[%s]\n", i);
LABEL_9:
SQLSetConfigMode(0LL);
return 0LL;
}
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError);
SQLSetConfigMode(0LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
char *i; // rbx
char *v3; // rbx
char v4[512]; // [rsp+0h] [rbp-27A8h] BYREF
char s[9640]; // [rsp+200h] [rbp-25A8h] BYREF

s[0] = 0;
if ( system_dsn )
{
SQLSetConfigMode(2LL);
}
else if ( user_dsn )
{
SQLSetConfigMode(1LL);
}
if ( a1 && *a1 )
{
if ( (int)SQLGetPrivateProfileString(a1, 0LL, 0LL, s, 9600LL, "ODBC.INI") > 0 )
{
printf("[%s]\n", a1);
if ( s[0] )
{
v3 = s;
do
{
printf("%s=", v3);
if ( (int)SQLGetPrivateProfileString(a1, v3, &unk_1CE1, v4, 500LL, "ODBC.INI") > 0 )
printf("%s", v4);
putchar(10);
v3 += strlen(v3) + 1;
}
while ( *v3 );
}
goto LABEL_9;
}
}
else if ( (int)SQLGetPrivateProfileString(0LL, 0LL, 0LL, s, 9600LL, "ODBC.INI") > 0 )
{
for ( i = s; *i; i += strlen(i) + 1 )
printf("[%s]\n", i);
LABEL_9:
SQLSetConfigMode(0LL);
return 0LL;
}
SQLInstallerError(1LL, &nError, szError, 4096LL, 0LL);
if ( !cVerbose )
printf("odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError);
SQLSetConfigMode(0LL);
return 1LL;
}

original_code:
int DSNQuery( char *pszDSN )
{
    char szResults[9601];
    char szValue[501];
    char *ptr;
    szResults[0] = '\0';
    if ( system_dsn )
        SQLSetConfigMode( 2 );
    else if ( user_dsn )
        SQLSetConfigMode( 1 );
    if ( pszDSN && (*pszDSN) )
    {
        if ( SQLGetPrivateProfileString( pszDSN, ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBC.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            SQLSetConfigMode( 0 );
            return 1;
        }
        printf( "[%s]\n", pszDSN );
        ptr = szResults;
        while ( *ptr )
        {
            printf( "%s=", ptr );
            if ( SQLGetPrivateProfileString( pszDSN, ptr, "", szValue, sizeof( szValue ) - 1, "ODBC.INI" ) > 0 )
            {
                printf( "%s", szValue );
            }
            printf( "\n" );
            ptr += strlen( ptr ) + 1;
        }
    }
    else
    {
        if ( SQLGetPrivateProfileString( ((void *)0), ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBC.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            SQLSetConfigMode( 0 );
            return 1;
        }
        ptr = szResults;
        while ( *ptr )
        {
            printf( "[%s]\n", ptr );
            ptr += strlen( ptr ) + 1;
        }
    }
    SQLSetConfigMode( 0 );
    return 0;
}

canonical_original_code:
int DSNQuery(char *pszDSN)
{
    char szResults[9601];
    char szValue[501];
    char *ptr;
    szResults[0] = '\0';
    if ( system_dsn )
        SQLSetConfigMode( 2 );
    else if ( user_dsn )
        SQLSetConfigMode( 1 );
    if ( pszDSN && (*pszDSN) )
    {
        if ( SQLGetPrivateProfileString( pszDSN, ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBC.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            SQLSetConfigMode( 0 );
            return 1;
        }
        printf( "[%s]\n", pszDSN );
        ptr = szResults;
        while ( *ptr )
        {
            printf( "%s=", ptr );
            if ( SQLGetPrivateProfileString( pszDSN, ptr, "", szValue, sizeof( szValue ) - 1, "ODBC.INI" ) > 0 )
            {
                printf( "%s", szValue );
            }
            printf( "\n" );
            ptr += strlen( ptr ) + 1;
        }
    }
    else
    {
        if ( SQLGetPrivateProfileString( ((void *)0), ((void *)0), ((void *)0), szResults, sizeof( szResults ) - 1, "ODBC.INI" ) < 1 )
        {
            SQLInstallerError( 1, &nError, szError, 4096, ((void *)0) );
            if ( cVerbose == 0 ) printf( "odbcinst: SQLGetPrivateProfileString failed with %s.\n", szError );
            SQLSetConfigMode( 0 );
            return 1;
        }
        ptr = szResults;
        while ( *ptr )
        {
            printf( "[%s]\n", ptr );
            ptr += strlen( ptr ) + 1;
        }
    }
    SQLSetConfigMode( 0 );
    return 0;
}

variable_types:
szResults
char [9601]


Syntax

decompiled_code:
int Syntax()
{
int result; // eax

if ( !cVerbose )
result = puts(szSyntax);
return result;
}

canonical_decompiled_code:
int func8()
{
int result; // eax

if ( !cVerbose )
result = puts(szSyntax);
return result;
}

original_code:
void Syntax()
{
    if ( cVerbose != 0 )
        return;
    puts( szSyntax );
}


PrintConfigInfo

decompiled_code:
int PrintConfigInfo()
{
const char *v0; // r12
const char *v1; // rax
__int64 v3; // [rsp+0h] [rbp-1218h] BYREF
char v4[256]; // [rsp+100h] [rbp-1118h] BYREF
char s[4120]; // [rsp+200h] [rbp-1018h] BYREF

puts("unixODBC 2.3.0");
s[0] = 0;
v0 = (const char *)odbcinst_system_file_name(v4);
v1 = (const char *)odbcinst_system_file_path(&v3);
sprintf(s, "%s/%s", v1, v0);
printf("DRIVERS............: %s\n", s);
s[0] = 0;
odbcinst_SystemINI(s, 0LL);
printf("SYSTEM DATA SOURCES: %s\n", s);
s[0] = 0;
odbcinst_FileINI(s);
printf("FILE DATA SOURCES..: %s\n", s);
s[0] = 0;
odbcinst_UserINI(s, 0LL);
printf("USER DATA SOURCES..: %s\n", s);
printf("SQLULEN Size.......: %ld\n", 8LL);
printf("SQLLEN Size........: %ld\n", 8LL);
return printf("SQLSETPOSIROW Size.: %ld\n", 2LL);
}

canonical_decompiled_code:
int func9()
{
const char *v0; // r12
const char *v1; // rax
__int64 v3; // [rsp+0h] [rbp-1218h] BYREF
char v4[256]; // [rsp+100h] [rbp-1118h] BYREF
char s[4120]; // [rsp+200h] [rbp-1018h] BYREF

puts("unixODBC 2.3.0");
s[0] = 0;
v0 = (const char *)odbcinst_system_file_name(v4);
v1 = (const char *)odbcinst_system_file_path(&v3);
sprintf(s, "%s/%s", v1, v0);
printf("DRIVERS............: %s\n", s);
s[0] = 0;
odbcinst_SystemINI(s, 0LL);
printf("SYSTEM DATA SOURCES: %s\n", s);
s[0] = 0;
odbcinst_FileINI(s);
printf("FILE DATA SOURCES..: %s\n", s);
s[0] = 0;
odbcinst_UserINI(s, 0LL);
printf("USER DATA SOURCES..: %s\n", s);
printf("SQLULEN Size.......: %ld\n", 8LL);
printf("SQLLEN Size........: %ld\n", 8LL);
return printf("SQLSETPOSIROW Size.: %ld\n", 2LL);
}

original_code:
void PrintConfigInfo()
{
    char szFileName[4096 +1];
 char b1[ 256 ], b2[ 256 ];
    printf( "unixODBC " "2.3.0" "\n" );
    *szFileName = '\0';
    sprintf( szFileName, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b2 ));
    printf( "DRIVERS............: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_SystemINI( szFileName, 0 );
    printf( "SYSTEM DATA SOURCES: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_FileINI( szFileName );
    printf( "FILE DATA SOURCES..: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_UserINI( szFileName, 0 );
    printf( "USER DATA SOURCES..: %s\n", szFileName );
 printf( "SQLULEN Size.......: %ld\n", (long) sizeof( SQLUINTEGER ));
 printf( "SQLLEN Size........: %ld\n", (long) sizeof( SQLINTEGER ));
 printf( "SQLSETPOSIROW Size.: %ld\n", (long) sizeof( SQLUSMALLINT ));
}

canonical_original_code:
void PrintConfigInfo()
{
    char szFileName[-1];
 char b1[256]; char b2[256];
    printf( "unixODBC " "2.3.0" "\n" );
    *szFileName = '\0';
    sprintf( szFileName, "%s/%s", odbcinst_system_file_path( b1 ), odbcinst_system_file_name( b2 ));
    printf( "DRIVERS............: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_SystemINI( szFileName, 0 );
    printf( "SYSTEM DATA SOURCES: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_FileINI( szFileName );
    printf( "FILE DATA SOURCES..: %s\n", szFileName );
    *szFileName = '\0';
    _odbcinst_UserINI( szFileName, 0 );
    printf( "USER DATA SOURCES..: %s\n", szFileName );
 printf( "SQLULEN Size.......: %ld\n", (long) sizeof( SQLUINTEGER ));
 printf( "SQLLEN Size........: %ld\n", (long) sizeof( SQLINTEGER ));
 printf( "SQLSETPOSIROW Size.: %ld\n", (long) sizeof( SQLUSMALLINT ));
}

variable_types:
szFileName
char [-1]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
char v4; // r14
char v5; // r15
int v6; // er13
const char *v7; // rax
char v8; // dl
int v9; // edi
int result; // eax
char v11[1008]; // [rsp+0h] [rbp-1438h] BYREF
char dest[4168]; // [rsp+3F0h] [rbp-1048h] BYREF

cVerbose = 0;
if ( argc <= 1 )
goto LABEL_29;
v11[0] = 0;
v3 = 1LL;
dest[0] = 0;
v4 = 0;
v5 = 0;
v6 = argc - 1;
do
{
v7 = argv[v3];
if ( *v7 == 45 )
{
v8 = v7[1];
switch ( v8 )
{
case '-':
puts("unixODBC 2.3.0");
exit(0);
case 'c':
case 'd':
case 'm':
case 's':
v4 = v7[1];
break;
case 'f':
if ( v6 > (int)v3 )
strncpy(dest, argv[v3 + 1], 0x1000uLL);
break;
case 'h':
user_dsn = 1;
if ( system_dsn )
goto LABEL_10;
break;
case 'i':
case 'q':
case 'u':
v5 = v7[1];
break;
case 'j':
PrintConfigInfo();
exit(0);
case 'l':
system_dsn = 1;
if ( user_dsn )
{
LABEL_10:
if ( !cVerbose )
printf("odbcinst: cannot install both user and system dsn at the same time");
exit(-2);
}
return result;
case 'n':
if ( v6 > (int)v3 )
strncpy(v11, argv[v3 + 1], 0x3E8uLL);
break;
case 'r':
from_stdin = 1;
break;
case 'v':
cVerbose = 118;
break;
default:
if ( !cVerbose )
printf("odbcinst: Unknown option %c\n", (unsigned int)v8);
exit(-1);
}
}
++v3;
}
while ( v3 != argc );
if ( v4 == 100 )
{
switch ( v5 )
{
case 'i':
if ( dest[0] )
{
v9 = DriverInstall(dest);
goto LABEL_33;
}
if ( from_stdin )
{
v9 = DriverInstall((const char *)0xFFFFFFFFFFFFFFFFLL);
goto LABEL_33;
}
if ( !cVerbose )
puts(
"odbcinst: Please supply -f template.ini (The fileformat of template.ini is identical to odbcinst.ini and odb"
"c.ini, respectively)");
break;
case 'u':
if ( v11[0] )
{
v9 = DriverUninstall(v11);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -n FriendlyDriverName ");
break;
case 'q':
v9 = DriverQuery(v11);
goto LABEL_33;
default:
goto LABEL_37;
}
}
else
{
if ( v4 != 115 )
{
if ( v4 == 99 )
{
v9 = CreateDataSource(v11);
}
else
{
if ( v4 != 109 )
{
if ( !cVerbose )
puts("odbcinst: Invalid Object");
goto LABEL_29;
}
v9 = ManageDataSources();
}
LABEL_33:
exit(v9);
}
switch ( v5 )
{
case 'i':
if ( dest[0] )
{
v9 = DSNInstall(dest);
goto LABEL_33;
}
if ( from_stdin )
{
v9 = DSNInstall((const char *)0xFFFFFFFFFFFFFFFFLL);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -f template.ini ");
break;
case 'u':
if ( v11[0] )
{
v9 = DSNUninstall((__int64)v11);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -n DataSourceName ");
break;
case 'q':
v9 = DSNQuery(v11);
goto LABEL_33;
default:
LABEL_37:
if ( !cVerbose )
puts("odbcinst: Invalid Action for Object");
break;
}
}
LABEL_29:
Syntax();
exit(1);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
char v4; // r14
char v5; // r15
int v6; // er13
const char *v7; // rax
char v8; // dl
int v9; // edi
int result; // eax
char v11[1008]; // [rsp+0h] [rbp-1438h] BYREF
char dest[4168]; // [rsp+3F0h] [rbp-1048h] BYREF

cVerbose = 0;
if ( argc <= 1 )
goto LABEL_29;
v11[0] = 0;
v3 = 1LL;
dest[0] = 0;
v4 = 0;
v5 = 0;
v6 = argc - 1;
do
{
v7 = argv[v3];
if ( *v7 == 45 )
{
v8 = v7[1];
switch ( v8 )
{
case '-':
puts("unixODBC 2.3.0");
exit(0);
case 'c':
case 'd':
case 'm':
case 's':
v4 = v7[1];
break;
case 'f':
if ( v6 > (int)v3 )
strncpy(dest, argv[v3 + 1], 0x1000uLL);
break;
case 'h':
user_dsn = 1;
if ( system_dsn )
goto LABEL_10;
break;
case 'i':
case 'q':
case 'u':
v5 = v7[1];
break;
case 'j':
func9();
exit(0);
case 'l':
system_dsn = 1;
if ( user_dsn )
{
LABEL_10:
if ( !cVerbose )
printf("odbcinst: cannot install both user and system dsn at the same time");
exit(-2);
}
return result;
case 'n':
if ( v6 > (int)v3 )
strncpy(v11, argv[v3 + 1], 0x3E8uLL);
break;
case 'r':
from_stdin = 1;
break;
case 'v':
cVerbose = 118;
break;
default:
if ( !cVerbose )
printf("odbcinst: Unknown option %c\n", (unsigned int)v8);
exit(-1);
}
}
++v3;
}
while ( v3 != argc );
if ( v4 == 100 )
{
switch ( v5 )
{
case 'i':
if ( dest[0] )
{
v9 = func2(dest);
goto LABEL_33;
}
if ( from_stdin )
{
v9 = func2((const char *)0xFFFFFFFFFFFFFFFFLL);
goto LABEL_33;
}
if ( !cVerbose )
puts(
"odbcinst: Please supply -f template.ini (The fileformat of template.ini is identical to odbcinst.ini and odb"
"c.ini, respectively)");
break;
case 'u':
if ( v11[0] )
{
v9 = func3(v11);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -n FriendlyDriverName ");
break;
case 'q':
v9 = func4(v11);
goto LABEL_33;
default:
goto LABEL_37;
}
}
else
{
if ( v4 != 115 )
{
if ( v4 == 99 )
{
v9 = func0(v11);
}
else
{
if ( v4 != 109 )
{
if ( !cVerbose )
puts("odbcinst: Invalid Object");
goto LABEL_29;
}
v9 = func1();
}
LABEL_33:
exit(v9);
}
switch ( v5 )
{
case 'i':
if ( dest[0] )
{
v9 = func5(dest);
goto LABEL_33;
}
if ( from_stdin )
{
v9 = func5((const char *)0xFFFFFFFFFFFFFFFFLL);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -f template.ini ");
break;
case 'u':
if ( v11[0] )
{
v9 = func6((__int64)v11);
goto LABEL_33;
}
if ( !cVerbose )
puts("odbcinst: Please supply -n DataSourceName ");
break;
case 'q':
v9 = func7(v11);
goto LABEL_33;
default:
LABEL_37:
if ( !cVerbose )
puts("odbcinst: Invalid Action for Object");
break;
}
}
LABEL_29:
func8();
exit(1);
}

original_code:
int main( int argc, char *argv[] )
{
    int nArg;
    char cAction = 0;
    char cObject = 0;
    char szTemplateINI[4096 +1];
    char szObjectName[1000 +1];
    int nReturn = 0;
    cVerbose = 0;
    if ( argc < 2 )
    {
        Syntax();
        exit ( 1 );
    }
    szTemplateINI[0] = '\0';
    szObjectName[0] = '\0';
    for ( nArg = 1; nArg < argc; nArg++ )
    {
        if ( argv[nArg][0] == '-' )
        {
            switch ( argv[nArg][1] )
            {
                case 'i':
                case 'u':
                case 'q':
                    cAction = argv[nArg][1];
                    break;
                case 'j':
                    PrintConfigInfo();
                    exit(0);
                case '-':
                    printf( "unixODBC " "2.3.0" "\n" );
                    exit(0);
                case 'c':
                case 'd':
                case 's':
                case 'm':
                    cObject = argv[nArg][1];
                    break;
                case 'n':
                    if ( nArg < argc-1 )
                        strncpy( szObjectName, argv[nArg+1], 1000 );
                    break;
                case 'f':
                    if ( nArg < argc-1 )
                        strncpy( szTemplateINI, argv[nArg+1], 4096 );
                    break;
                case 'r':
                    from_stdin = 1;
                    break;
                case 'v':
                    cVerbose = argv[nArg][1];
                    break;
                case 'l':
                    system_dsn = 1;
                    if ( user_dsn )
                    {
                        if ( cVerbose == 0 ) printf( "odbcinst: cannot install both user and system dsn at the same time");
                        exit( -2 );
                    }
                    break;
                case 'h':
                    user_dsn = 1;
                    if ( system_dsn )
                    {
                        if ( cVerbose == 0 ) printf( "odbcinst: cannot install both user and system dsn at the same time");
                        exit( -2 );
                    }
                    break;
                default:
                    if ( cVerbose == 0 ) printf( "odbcinst: Unknown option %c\n", argv[nArg][1] );
                    exit( -1 );
            }
        }
    }
    if ( cObject == 'd' )
    {
        if ( cAction == 'i' )
        {
            if ( szTemplateINI[0] != '\0' )
                nReturn = DriverInstall( szTemplateINI );
            else if ( from_stdin )
                nReturn = DriverInstall( ((char*)-1) );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -f template.ini (The fileformat of template.ini is identical to odbcinst.ini and odbc.ini, respectively)\n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'u' )
        {
            if ( szObjectName[0] != '\0' )
                nReturn = DriverUninstall( szObjectName );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -n FriendlyDriverName \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'q' )
            nReturn = DriverQuery( szObjectName );
        else
        {
            if ( cVerbose == 0 ) printf( "odbcinst: Invalid Action for Object\n" );
            Syntax();
            exit( 1 );
        }
    }
    else if ( cObject == 's' )
    {
        if ( cAction == 'i' )
        {
            if ( szTemplateINI[0] != '\0' )
                nReturn = DSNInstall( szTemplateINI );
            else if ( from_stdin )
                nReturn = DSNInstall( ((char*)-1) );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -f template.ini \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'u' )
        {
            if ( szObjectName[0] != '\0' )
                nReturn = DSNUninstall( szObjectName );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -n DataSourceName \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'q' )
            nReturn = DSNQuery( szObjectName );
        else
        {
            if ( cVerbose == 0 ) printf( "odbcinst: Invalid Action for Object\n" );
            Syntax();
            exit( 1 );
        }
    }
    else if ( cObject == 'c' )
    {
        nReturn = CreateDataSource( szObjectName );
    }
    else if ( cObject == 'm' )
    {
        nReturn = ManageDataSources();
    }
    else
    {
        if ( cVerbose == 0 ) printf( "odbcinst: Invalid Object\n" );
        Syntax();
        exit( 1 );
    }
    exit( nReturn );
}

canonical_original_code:
int main(int argc, char *argv[])
{
    int nArg;
    char cAction = 0;
    char cObject = 0;
    char szTemplateINI[-1];
    char szObjectName[-1];
    int nReturn = 0;
    cVerbose = 0;
    if ( argc < 2 )
    {
        Syntax();
        exit ( 1 );
    }
    szTemplateINI[0] = '\0';
    szObjectName[0] = '\0';
    for ( nArg = 1; nArg < argc; nArg++ )
    {
        if ( argv[nArg][0] == '-' )
        {
            switch ( argv[nArg][1] )
            {
                case 'i':
                case 'u':
                case 'q':
                    cAction = argv[nArg][1];
                    break;
                case 'j':
                    PrintConfigInfo();
                    exit(0);
                case '-':
                    printf( "unixODBC " "2.3.0" "\n" );
                    exit(0);
                case 'c':
                case 'd':
                case 's':
                case 'm':
                    cObject = argv[nArg][1];
                    break;
                case 'n':
                    if ( nArg < argc-1 )
                        strncpy( szObjectName, argv[nArg+1], 1000 );
                    break;
                case 'f':
                    if ( nArg < argc-1 )
                        strncpy( szTemplateINI, argv[nArg+1], 4096 );
                    break;
                case 'r':
                    from_stdin = 1;
                    break;
                case 'v':
                    cVerbose = argv[nArg][1];
                    break;
                case 'l':
                    system_dsn = 1;
                    if ( user_dsn )
                    {
                        if ( cVerbose == 0 ) printf( "odbcinst: cannot install both user and system dsn at the same time");
                        exit( -2 );
                    }
                    break;
                case 'h':
                    user_dsn = 1;
                    if ( system_dsn )
                    {
                        if ( cVerbose == 0 ) printf( "odbcinst: cannot install both user and system dsn at the same time");
                        exit( -2 );
                    }
                    break;
                default:
                    if ( cVerbose == 0 ) printf( "odbcinst: Unknown option %c\n", argv[nArg][1] );
                    exit( -1 );
            }
        }
    }
    if ( cObject == 'd' )
    {
        if ( cAction == 'i' )
        {
            if ( szTemplateINI[0] != '\0' )
                nReturn = DriverInstall( szTemplateINI );
            else if ( from_stdin )
                nReturn = DriverInstall( ((char *)-1) );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -f template.ini (The fileformat of template.ini is identical to odbcinst.ini and odbc.ini, respectively)\n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'u' )
        {
            if ( szObjectName[0] != '\0' )
                nReturn = DriverUninstall( szObjectName );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -n FriendlyDriverName \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'q' )
            nReturn = DriverQuery( szObjectName );
        else
        {
            if ( cVerbose == 0 ) printf( "odbcinst: Invalid Action for Object\n" );
            Syntax();
            exit( 1 );
        }
    }
    else if ( cObject == 's' )
    {
        if ( cAction == 'i' )
        {
            if ( szTemplateINI[0] != '\0' )
                nReturn = DSNInstall( szTemplateINI );
            else if ( from_stdin )
                nReturn = DSNInstall( ((char *)-1) );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -f template.ini \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'u' )
        {
            if ( szObjectName[0] != '\0' )
                nReturn = DSNUninstall( szObjectName );
            else
            {
                if ( cVerbose == 0 ) printf( "odbcinst: Please supply -n DataSourceName \n" );
                Syntax();
                exit( 1 );
            }
        }
        else if ( cAction == 'q' )
            nReturn = DSNQuery( szObjectName );
        else
        {
            if ( cVerbose == 0 ) printf( "odbcinst: Invalid Action for Object\n" );
            Syntax();
            exit( 1 );
        }
    }
    else if ( cObject == 'c' )
    {
        nReturn = CreateDataSource( szObjectName );
    }
    else if ( cObject == 'm' )
    {
        nReturn = ManageDataSources();
    }
    else
    {
        if ( cVerbose == 0 ) printf( "odbcinst: Invalid Object\n" );
        Syntax();
        exit( 1 );
    }
    exit( nReturn );
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: nArg int

variable_types: cAction char

variable_types: cObject char

variable_types:
szTemplateINI
char [-1]

variable_types:
szObjectName
char [-1]

variable_types: nReturn int


decompiled_code:
__int64 __fastcall inst_logPushMsg(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int a5, __int64 a6)
{
unsigned int v9; // er15

mutex_entry_isra_0();
v9 = log_tried;
if ( !log_tried )
{
log_tried = 1;
if ( (unsigned int)logOpen(&hODBCINSTLog, "odbcinst", 0LL, 10LL) != 1 )
{
hODBCINSTLog = 0LL;
goto LABEL_4;
}
logOn(hODBCINSTLog, 1LL);
}
v9 = 0;
if ( hODBCINSTLog )
v9 = logPushMsg(hODBCINSTLog, a1, a2, a3, a4, a5, a6);
LABEL_4:
mutex_exit_isra_0();
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int a5, __int64 a6)
{
unsigned int v9; // er15

func1();
v9 = log_tried;
if ( !log_tried )
{
log_tried = 1;
if ( (unsigned int)logOpen(&hODBCINSTLog, "odbcinst", 0LL, 10LL) != 1 )
{
hODBCINSTLog = 0LL;
goto LABEL_4;
}
logOn(hODBCINSTLog, 1LL);
}
v9 = 0;
if ( hODBCINSTLog )
v9 = logPushMsg(hODBCINSTLog, a1, a2, a3, a4, a5, a6);
LABEL_4:
func0();
return v9;
}

original_code:
int inst_logPushMsg( char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, char *pszMessage )
{
    int ret = 0;
    mutex_entry();
    if ( !log_tried )
    {
        long nMaxMessages = 10;
        log_tried = 1;
        if ( logOpen( &hODBCINSTLog, "odbcinst", ((void *)0), nMaxMessages ) != 1 )
        {
            hODBCINSTLog = ((void *)0);
        }
        else
        {
            logOn( hODBCINSTLog, 1 );
        }
    }
    if ( hODBCINSTLog )
    {
        ret = logPushMsg( hODBCINSTLog,
                pszModule,
                pszFunctionName,
                nLine,
                nSeverity,
                nCode,
                pszMessage );
    }
    mutex_exit();
    return ret;
}

canonical_original_code:
int inst_logPushMsg(char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, char *pszMessage)
{
    int ret = 0;
    mutex_entry();
    if ( !log_tried )
    {
        long nMaxMessages = 10;
        log_tried = 1;
        if ( logOpen( &hODBCINSTLog, "odbcinst", ((void *)0), nMaxMessages ) != 1 )
        {
            hODBCINSTLog = ((void *)0);
        }
        else
        {
            logOn( hODBCINSTLog, 1 );
        }
    }
    if ( hODBCINSTLog )
    {
        ret = logPushMsg( hODBCINSTLog,
                pszModule,
                pszFunctionName,
                nLine,
                nSeverity,
                nCode,
                pszMessage );
    }
    mutex_exit();
    return ret;
}

variable_types:
pszModule
char *

variable_types:
pszFunctionName
char *

variable_types: nLine int

variable_types: nSeverity int

variable_types: nCode int

variable_types:
pszMessage
char *

variable_types: ret int

variable_types: nMaxMessages long


decompiled_code:
__int64 inst_logClear()
{
unsigned int v0; // er12

v0 = 0;
mutex_entry_isra_0();
if ( hODBCINSTLog )
v0 = logClear();
mutex_exit_isra_0();
return v0;
}

canonical_decompiled_code:
__int64 func4()
{
unsigned int v0; // er12

v0 = 0;
func1();
if ( hODBCINSTLog )
v0 = logClear();
func0();
return v0;
}

original_code:
int inst_logClear( void )
{
    int ret = 0;
    mutex_entry();
    if ( hODBCINSTLog )
        ret = logClear( hODBCINSTLog );
    mutex_exit();
    return ret;
}

canonical_original_code:
int inst_logClear()
{
    int ret = 0;
    mutex_entry();
    if ( hODBCINSTLog )
        ret = logClear( hODBCINSTLog );
    mutex_exit();
    return ret;
}


popc

original_code:
static char popc(yyenv_t* penv)
{
 char c;
 c = (penv->pstmt->sqlexpr)[(penv->scanpos)];
 (penv->errpos) = (penv->scanpos);
 (penv->scanpos) ++;
 return c;
}

canonical_original_code:
static char popc(struct yyenv_t *penv)
{
 char c;
 c = (penv->pstmt->sqlexpr)[(penv->scanpos)];
 (penv->errpos) = (penv->scanpos);
 (penv->scanpos) ++;
 return c;
}

variable_types: struct yyenv_t { int extlevel; int errpos; int scanpos; char *texts_bufptr; int dummy_npar; struct yystmt_t { void *hcndes; int type; int errcode; int errpos; struct yycol_t { int iattr; char *table; union { long num; char *qstr; struct date_t { int year; int month; int day; } date; } value; } *pcol; struct yyattr_t { int stat; int wstat; int article; union { char *location; long number; struct date_t date; } value; void *nntp_hand; } *pattr; struct yypar_t { int type; union { char *location; long number; struct date_t date; } value; } *ppar; char *table; int ncol; int npar; int count; char *sqlexpr; char *texts_buf; char msgbuf[64]; struct tnode { int type; union { int cmpop; int logop; int iattr; int ipar; char *qstr; long num; struct date_t date; char esc; } value; struct tnode *left; struct tnode *right; } *srchtree; struct tnode *node_buf; int srchtreesize; int srchtreenum; char **ins_heads; struct tnode *ins_values; long artnum_min; long artnum_max; } *pstmt; } *

variable_types: c char

user_defined_types: struct yyenv_t { int extlevel; int errpos; int scanpos; char *texts_bufptr; int dummy_npar; struct yystmt_t *pstmt; }

user_defined_types: struct yystmt_t { void *hcndes; int type; int errcode; int errpos; struct yycol_t *pcol; struct yyattr_t *pattr; struct yypar_t *ppar; char *table; int ncol; int npar; int count; char *sqlexpr; char *texts_buf; char msgbuf[64]; struct tnode *srchtree; struct tnode *node_buf; int srchtreesize; int srchtreenum; char **ins_heads; struct tnode *ins_values; long artnum_min; long artnum_max; }

user_defined_types: struct yycol_t { int iattr; char *table; union { long num; char *qstr; struct date_t date; } value; }


getxkeywdidxbyname

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

if ( (unsigned int)upper_strneq(a1, &LC0, 6LL) )
result = 296LL;
else
result = (unsigned int)upper_strneq(a1, &LC1, 6LL) == 0 ? 256 : 297;
return result;
}

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

if ( (unsigned int)upper_strneq(a1, &LC0, 6LL) )
result = 296LL;
else
result = (unsigned int)upper_strneq(a1, &LC1, 6LL) == 0 ? 256 : 297;
return result;
}

original_code:
static int getxkeywdidxbyname(char* name)
{
 int i, size;
 size = sizeof(xkeywd_tab)/sizeof(xkeywd_tab[0]);
 for(i=0; i<size; i++)
 {
  if(upper_strneq(name, xkeywd_tab[i].name, 6))
   return xkeywd_tab[i].idx;
 }
 return 256;
}

canonical_original_code:
static int getxkeywdidxbyname(char *name)
{
 int i; int size;
 size = sizeof(xkeywd_tab)/sizeof(xkeywd_tab[0]);
 for(i=0; i<size; i++)
 {
  if(upper_strneq(name, xkeywd_tab[i].name, 6))
   return xkeywd_tab[i].idx;
 }
 return 256;
}

variable_types:
name
char *

variable_types: i int

variable_types: size int


getkeywdidxbyname

decompiled_code:
__int64 __fastcall getkeywdidxbyname(__int64 a1)
{
const char *v1; // rsi
const char **v2; // rbp
int v3; // ebx

v1 = "select";
v2 = (const char **)&off_7F8;
v3 = 0;
while ( 1 )
{
if ( (unsigned int)upper_strneq(a1, v1, 12LL) )
return *((unsigned int *)&keywd_tab + 4 * v3);
if ( ++v3 == 41 )
break;
v1 = *v2;
v2 += 2;
}
return 256LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
const char *v1; // rsi
const char **v2; // rbp
int v3; // ebx

v1 = "select";
v2 = (const char **)&off_7F8;
v3 = 0;
while ( 1 )
{
if ( (unsigned int)upper_strneq(a1, v1, 12LL) )
return *((unsigned int *)&keywd_tab + 4 * v3);
if ( ++v3 == 41 )
break;
v1 = *v2;
v2 += 2;
}
return 256LL;
}

original_code:
static int getkeywdidxbyname(char* name)
{
 int i, size;
 size = sizeof(keywd_tab)/sizeof(keywd_tab[0]);
 for(i=0; i<size; i++)
 {
  if(upper_strneq(name, keywd_tab[i].name, 12))
   return keywd_tab[i].idx;
 }
 return 256;
}

canonical_original_code:
static int getkeywdidxbyname(char *name)
{
 int i; int size;
 size = sizeof(keywd_tab)/sizeof(keywd_tab[0]);
 for(i=0; i<size; i++)
 {
  if(upper_strneq(name, keywd_tab[i].name, 12))
   return keywd_tab[i].idx;
 }
 return 256;
}