decompiled_code:
void *__fastcall vpack_cpfloat(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 4LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

canonical_decompiled_code:
void *__fastcall func12(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 4LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

original_code: static void vpack_cpfloat(void **dst, void **src, int n, int icrwho) { float *pd = (float*)(*dst); float *ps = (float*)(*src); memcpy(*dst, *src, sizeof(float)*n); if (icrwho) *src = (void*)(ps + n); else *dst = (void*)(pd + n); }

canonical_original_code: static void vpack_cpfloat(void **dst, void **src, int n, int icrwho) { float *pd = (float*)(*dst); float *ps = (float*)(*src); memcpy(*dst, *src, sizeof(float)*n); if (icrwho) *src = (void *)(ps + n); else *dst = (void *)(pd + n); }

variable_types:
pd
float *

variable_types:
ps
float *


repo: blackball/vpack

decompiled_code:
void *__fastcall vpack_cplong(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 8LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

canonical_decompiled_code:
void *__fastcall func13(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 8LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

original_code: static void vpack_cplong(void **dst, void **src, int n, int icrwho) { long *pd = (long*)(*dst); long *ps = (long*)(*src); memcpy(*dst, *src, sizeof(long)*n); if (icrwho) *src = (void*)(ps + n); else *dst = (void*)(pd + n); }

canonical_original_code: static void vpack_cplong(void **dst, void **src, int n, int icrwho) { long *pd = (long*)(*dst); long *ps = (long*)(*src); memcpy(*dst, *src, sizeof(long)*n); if (icrwho) *src = (void *)(ps + n); else *dst = (void *)(pd + n); }

variable_types:
dst
void **

variable_types:
src
void **

variable_types: n int

variable_types: icrwho int

variable_types:
pd
long *

variable_types:
ps
long *

return_type: void


decompiled_code:
void *__fastcall vpack_cpint(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 4LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

canonical_decompiled_code:
void *__fastcall func14(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 4LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

original_code: static void vpack_cpint(void **dst, void **src, int n, int icrwho) { int *pd = (int*)(*dst); int *ps = (int*)(*src); memcpy(*dst, *src, sizeof(int)*n); if (icrwho) *src = (void*)(ps + n); else *dst = (void*)(pd + n); }

canonical_original_code: static void vpack_cpint(void **dst, void **src, int n, int icrwho) { int *pd = (int*)(*dst); int *ps = (int*)(*src); memcpy(*dst, *src, sizeof(int)*n); if (icrwho) *src = (void *)(ps + n); else *dst = (void *)(pd + n); }

variable_types:
pd
int *

variable_types:
ps
int *


decompiled_code:
void *__fastcall vpack_cpshort(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 2LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

canonical_decompiled_code:
void *__fastcall func15(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
size_t v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = 2LL * a3;
result = memcpy(*a1, *a2, v7);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

original_code: static void vpack_cpshort(void **dst, void **src, int n, int icrwho) { short *pd = (short*)(*dst); short *ps = (short*)(*src); memcpy(*dst, *src, sizeof(short)*n); if (icrwho) *src = (void*)(ps + n); else *dst = (void*)(pd + n); }

canonical_original_code: static void vpack_cpshort(void **dst, void **src, int n, int icrwho) { short *pd = (short*)(*dst); short *ps = (short*)(*src); memcpy(*dst, *src, sizeof(short)*n); if (icrwho) *src = (void *)(ps + n); else *dst = (void *)(pd + n); }

variable_types:
pd
short *

variable_types:
ps
short *


decompiled_code:
void *__fastcall vpack_cpchar(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
__int64 v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = a3;
result = memcpy(*a1, *a2, a3);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

canonical_decompiled_code:
void *__fastcall func16(void **a1, const void **a2, int a3, int a4)
{
char *v5; // r14
char *v6; // r15
__int64 v7; // rbx
void *result; // rax

v5 = (char *)*a1;
v6 = (char *)*a2;
v7 = a3;
result = memcpy(*a1, *a2, a3);
if ( a4 )
*a2 = &v6[v7];
else
*a1 = &v5[v7];
return result;
}

original_code: static void vpack_cpchar(void **dst, void **src, int n, int icrwho) { char *pd = (char*)(*dst); char *ps = (char*)(*src); memcpy(*dst, *src, sizeof(char)*n); if (icrwho) *src = (void*)(ps + n); else *dst = (void*)(pd + n); }

canonical_original_code: static void vpack_cpchar(void **dst, void **src, int n, int icrwho) { char *pd = (char*)(*dst); char *ps = (char*)(*src); memcpy(*dst, *src, sizeof(char)*n); if (icrwho) *src = (void *)(ps + n); else *dst = (void *)(pd + n); }

variable_types:
pd
char *

variable_types:
ps
char *


original_code:
int world_border_detection(SDL_Rect *offset) {
 int detected = 0;
 if((offset->x + 640) > world->landscape->w) {
  offset->x = (world->landscape->w / 2) - (get_screen()->w / 2);
  world->player->x -= 30;
  detected = 1;
 }
 if((offset->y + 480) > world->landscape->h) {
  offset->y = (world->landscape->h/ 2) - (get_screen()->h / 2);
  world->player->y -= 30;
  detected = 1;
 }
 if(offset->x < 0) {
  offset->x = 0;
  world->player->x += 30;
  detected = 1;
 }
 if(offset->y < 0) {
  offset->y = 0;
  world->player->y += 30;
  detected = 1;
 }
 return detected;
}

canonical_original_code:
int world_border_detection(struct SDL_Rect *offset) {
 int detected = 0;
 if((offset->x + 640) > world->landscape->w) {
  offset->x = (world->landscape->w / 2) - (get_screen()->w / 2);
  world->player->x -= 30;
  detected = 1;
 }
 if((offset->y + 480) > world->landscape->h) {
  offset->y = (world->landscape->h/ 2) - (get_screen()->h / 2);
  world->player->y -= 30;
  detected = 1;
 }
 if(offset->x < 0) {
  offset->x = 0;
  world->player->x += 30;
  detected = 1;
 }
 if(offset->y < 0) {
  offset->y = 0;
  world->player->y += 30;
  detected = 1;
 }
 return detected;
}

variable_types: struct SDL_Rect { short x; unsigned short w; } *

variable_types: detected int

return_type: int


original_code:
void paint_world() {
 SDL_FillRect(get_screen(), &get_screen()->clip_rect, SDL_MapRGB( get_screen()->format, 0xFF, 0xFF, 0xFF ) );
 SDL_Rect offset;
 offset.x = (world->landscape->w / 2) - (get_screen()->w / 2) + world->player->x;
 offset.y = (world->landscape->h / 2) - (get_screen()->h / 2) + world->player->y;
 int border_detected = world_border_detection(&offset);
 offset.w = 640;
 offset.h = 480;
 apply_surface(&offset, ((void *)0), world->landscape, get_screen());
 if(border_detected) {
  offset.x = (get_screen()->w / 2) - (world->player->surface->w / 2);
  offset.y = (get_screen()->h / 2) - (world->player->surface->h / 2);
 } else {
  offset.x = (get_screen()->w / 2) - (world->player->surface->w / 2);
  offset.y = (get_screen()->h / 2) - (world->player->surface->h / 2);
 }
 apply_surface(((void *)0), &offset, world->player->surface, get_screen());
 SDL_Flip(get_screen());
}

canonical_original_code:
void paint_world() {
 SDL_FillRect(get_screen(), &get_screen()->clip_rect, SDL_MapRGB( get_screen()->format, 0xFF, 0xFF, 0xFF ) );
 struct SDL_Rect offset;
 offset.x = (world->landscape->w / 2) - (get_screen()->w / 2) + world->player->x;
 offset.y = (world->landscape->h / 2) - (get_screen()->h / 2) + world->player->y;
 int border_detected = world_border_detection(&offset);
 offset.w = 640;
 offset.h = 480;
 apply_surface(&offset, ((void *)0), world->landscape, get_screen());
 if(border_detected) {
  offset.x = (get_screen()->w / 2) - (world->player->surface->w / 2);
  offset.y = (get_screen()->h / 2) - (world->player->surface->h / 2);
 } else {
  offset.x = (get_screen()->w / 2) - (world->player->surface->w / 2);
  offset.y = (get_screen()->h / 2) - (world->player->surface->h / 2);
 }
 apply_surface(((void *)0), &offset, world->player->surface, get_screen());
 SDL_Flip(get_screen());
}

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


decompiled_code:
__int64 init_world()
{
_QWORD *v0; // rax
__int64 result; // rax

v0 = malloc(0x18uLL);
world = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
world = (void *)load_world("../world/world_description.wd");
result = 0LL;
}
else
{
fwrite("THE UNIVERSE HAS COLLAPSED :O", 1uLL, 0x1DuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
_QWORD *v0; // rax
__int64 result; // rax

v0 = malloc(0x18uLL);
world = v0;
if ( v0 )
{
*v0 = 0LL;
v0[1] = 0LL;
world = (void *)load_world("../world/world_description.wd");
result = 0LL;
}
else
{
fwrite("THE UNIVERSE HAS COLLAPSED :O", 1uLL, 0x1DuLL, stderr);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int init_world() {
 world = malloc(sizeof(*world));
 if(world == ((void *)0)) {
  fprintf(stderr, "THE UNIVERSE HAS COLLAPSED :O");
  return -1;
 }
 world->landscape = ((void *)0);
 world->player = ((void *)0);
 world = load_world("../world" "/world_description.wd");
 return 0;
}


decompiled_code:
void destroy_world()
{
SDL_FreeSurface(*(_QWORD *)world);
SDL_FreeSurface(**((_QWORD **)world + 1));
free(world);
}

canonical_decompiled_code:
void func3()
{
SDL_FreeSurface(*(_QWORD *)world);
SDL_FreeSurface(**((_QWORD **)world + 1));
free(world);
}

original_code:
void destroy_world() {
 SDL_FreeSurface(world->landscape);
 SDL_FreeSurface(world->player->surface);
 free(world);
}


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

v2 = world;
*(_DWORD *)(*((_QWORD *)world + 1) + 8LL) += a1;
result = v2[1];
*(_DWORD *)(result + 12) += a2;
return result;
}

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

v2 = world;
*(_DWORD *)(*((_QWORD *)world + 1) + 8LL) += a1;
result = v2[1];
*(_DWORD *)(result + 12) += a2;
return result;
}

original_code:
void move_player(int x, int y) {
 world->player->x += x;
 world->player->y += y;
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 init_opengl()
{
int v0; // edi
__int64 result; // rax
const char *v2; // rax

glMatrixMode(5889LL);
glLoadIdentity();
glOrtho(0.0, 640.0, 480.0, 0.0, 1.0, -1.0);
glMatrixMode(5888LL);
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0, 1.0);
v0 = glGetError();
result = 1LL;
if ( v0 )
{
v2 = (const char *)gluErrorString();
printf("Error initializing OpenGL! %s\n", v2);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // edi
__int64 result; // rax
const char *v2; // rax

glMatrixMode(5889LL);
glLoadIdentity();
glOrtho(0.0, 640.0, 480.0, 0.0, 1.0, -1.0);
glMatrixMode(5888LL);
glLoadIdentity();
glClearColor(0.0, 0.0, 0.0, 1.0);
v0 = glGetError();
result = 1LL;
if ( v0 )
{
v2 = (const char *)gluErrorString();
printf("Error initializing OpenGL! %s\n", v2);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int init_opengl() {
 glMatrixMode(0x1701);
 glLoadIdentity();
 glOrtho(0.0, 640, 480, 0.0, 1.0, -1.0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 glClearColor(0.f, 0.f, 0.f, 1.f);
 GLenum error = glGetError();
 if(error != 0) {
  printf( "Error initializing OpenGL! %s\n", gluErrorString(error));
  return -1;
 }
 return 1;
}

canonical_original_code:
int init_opengl() {
 glMatrixMode(0x1701);
 glLoadIdentity();
 glOrtho(0.0, 640, 480, 0.0, 1.0, -1.0);
 glMatrixMode(0x1700);
 glLoadIdentity();
 glClearColor(0.f, 0.f, 0.f, 1.f);
 unsigned int error = glGetError();
 if(error != 0) {
  printf( "Error initializing OpenGL! %s\n", gluErrorString(error));
  return -1;
 }
 return 1;
}

variable_types:
error
unsigned int


decompiled_code:
__int64 init_screen()
{
unsigned int v0; // ebx
const char *v2; // rax
const char *v3; // rax

if ( (unsigned int)SDL_Init(0xFFFFLL) == -1 )
{
v0 = -1;
v2 = (const char *)SDL_GetError();
fprintf(stderr, "SDL failed to initialize: %s\n", v2);
}
else
{
screen = SDL_SetVideoMode(640LL, 480LL, 32LL, 1LL);
if ( screen )
{
SDL_WM_SetCaption("Hello world!", 0LL);
SDL_EnableKeyRepeat(200LL, 30LL);
v0 = 0;
}
else
{
v3 = (const char *)SDL_GetError();
fprintf(stderr, "failed to initialize the screen: %s\n", v3);
v0 = -1;
}
}
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ebx
const char *v2; // rax
const char *v3; // rax

if ( (unsigned int)SDL_Init(0xFFFFLL) == -1 )
{
v0 = -1;
v2 = (const char *)SDL_GetError();
fprintf(stderr, "SDL failed to initialize: %s\n", v2);
}
else
{
screen = SDL_SetVideoMode(640LL, 480LL, 32LL, 1LL);
if ( screen )
{
SDL_WM_SetCaption("Hello world!", 0LL);
SDL_EnableKeyRepeat(200LL, 30LL);
v0 = 0;
}
else
{
v3 = (const char *)SDL_GetError();
fprintf(stderr, "failed to initialize the screen: %s\n", v3);
v0 = -1;
}
}
return v0;
}

original_code:
int init_screen() {
 if(SDL_Init(0x0000FFFF) == -1) {
  fprintf(stderr, "SDL failed to initialize: %s\n", SDL_GetError());
  return -1;
 }
 screen = SDL_SetVideoMode(640, 480, 32, 0x00000001);
 if(screen == ((void *)0)) {
  fprintf(stderr, "failed to initialize the screen: %s\n", SDL_GetError());
  return -1;
 }
 SDL_WM_SetCaption("Hello world!", ((void *)0));
 SDL_EnableKeyRepeat(500 - 300, 30);
 return 0;
}


update

decompiled_code:
void update()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void update() {
}

canonical_original_code:
void update() {
}


render

decompiled_code:
__int64 render()
{
glClear(0x4000LL);
glMatrixMode(5888LL);
glLoadIdentity();
glTranslatef(320.0, 240.0, 0.0);
glBegin(7LL);
glColor3f(1.0, 0.0);
glVertex2f(-50.0);
glColor3f(1.0, COERCE_DOUBLE((unsigned __int64)LC5));
glVertex2f(50.0);
glColor3f(0.0, COERCE_DOUBLE((unsigned __int64)LC5));
glVertex2f(50.0);
glColor3f(0.0, 0.0);
glVertex2f(-50.0);
glEnd(-50.0, 50.0, 1.0);
return SDL_GL_SwapBuffers();
}

canonical_decompiled_code:
__int64 func6()
{
glClear(0x4000LL);
glMatrixMode(5888LL);
glLoadIdentity();
glTranslatef(320.0, 240.0, 0.0);
glBegin(7LL);
glColor3f(1.0, 0.0);
glVertex2f(-50.0);
glColor3f(1.0, COERCE_DOUBLE((unsigned __int64)LC5));
glVertex2f(50.0);
glColor3f(0.0, COERCE_DOUBLE((unsigned __int64)LC5));
glVertex2f(50.0);
glColor3f(0.0, 0.0);
glVertex2f(-50.0);
glEnd(-50.0, 50.0, 1.0);
return SDL_GL_SwapBuffers();
}

original_code:
void render() {
 glClear(0x00004000);
 glMatrixMode(0x1700);
 glLoadIdentity();
 glTranslatef(640 / 2.f, 480 / 2.f, 0.f);
 glBegin( 0x0007 );
 glColor3f(1.f, 0.f, 0.f); glVertex2f(-50.f, -50.f);
 glColor3f(1.f, 1.f, 0.f); glVertex2f(50.f, -50.f);
 glColor3f(0.f, 1.f, 0.f); glVertex2f(50.f, 50.f);
 glColor3f(0.f, 0.f, 1.f); glVertex2f(-50.f, 50.f);
 glEnd();
 SDL_GL_SwapBuffers();
}


decompiled_code:
char *__fastcall get_character_path(__int64 a1, const char *a2)
{
__int64 v2; // rax
char *v3; // r12
const char *v4; // rbx
size_t v5; // r12
size_t v6; // rax

v2 = a1;
while ( 1 )
{
v3 = *(char **)(v2 + 8);
if ( !v3 )
break;
v4 = *(const char **)v2;
if ( !**(_BYTE **)v2 )
return 0LL;
if ( !strcmp(*(const char **)v2, "characters") )
{
strcat(*(char **)v2, "/player0.png");
v5 = strlen(a2);
v6 = strlen(v4);
v3 = (char *)malloc(v5 + v6);
strcpy(v3, a2);
strcat(v3, v4);
return v3;
}
v2 += 4104LL;
if ( v2 == a1 + 0x202008000LL )
return 0LL;
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func2(__int64 a1, const char *a2)
{
__int64 v2; // rax
char *v3; // r12
const char *v4; // rbx
size_t v5; // r12
size_t v6; // rax

v2 = a1;
while ( 1 )
{
v3 = *(char **)(v2 + 8);
if ( !v3 )
break;
v4 = *(const char **)v2;
if ( !**(_BYTE **)v2 )
return 0LL;
if ( !strcmp(*(const char **)v2, "characters") )
{
strcat(*(char **)v2, "/player0.png");
v5 = strlen(a2);
v6 = strlen(v4);
v3 = (char *)malloc(v5 + v6);
strcpy(v3, a2);
strcat(v3, v4);
return v3;
}
v2 += 4104LL;
if ( v2 == a1 + 0x202008000LL )
return 0LL;
}
return v3;
}

original_code:
char *get_character_path(struct parser_data *data, char *path) {
 int i;
 int size = sizeof(data->nodes);
   for(i = 0; i < size; i++) {
  if((data->nodes[i].data[0] == ((void *)0)) || (strcmp(data->nodes[i].name, "") == 0)) {
   break;
  }
  if((data->nodes[i].data[0] != ((void *)0))) {
   if(strcmp(data->nodes[i].name, "characters") == 0) {
    char *name = data->nodes[i].name;
    strcat(name, "/player0.png");
    char *pathdup = malloc(strlen(path) + strlen(name));
    strcpy(pathdup, path);
    strcat(pathdup, name);
    return pathdup;
   }
  }
 }
 return ((void *)0);
}

variable_types: struct parser_data { struct node { char *name; char *data[512]; } nodes[512]; } *

variable_types:
path
char *

variable_types: i int

variable_types: size int

variable_types:
name
char *

variable_types:
pathdup
char *

return_type: char *

user_defined_types: struct parser_data { struct node nodes[512]; }


BufCRC

repo: blakemcbride/Dynace

decompiled_code:
__int64 __fastcall BufCRC(__int64 a1, _BYTE *a2, int a3)
{
__int64 result; // rax
_BYTE *v5; // rdx
__int64 v6; // rsi

result = a1;
if ( a3 > 0 )
{
v5 = a2;
v6 = (__int64)&a2[a3 - 1 + 1];
do
result = crctab[(unsigned __int8)(*v5++ ^ result)] ^ ((unsigned int)result >> 8);
while ( v5 != (_BYTE *)v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _BYTE *a2, int a3)
{
__int64 result; // rax
_BYTE *v5; // rdx
__int64 v6; // rsi

result = a1;
if ( a3 > 0 )
{
v5 = a2;
v6 = (__int64)&a2[a3 - 1 + 1];
do
result = crctab[(unsigned __int8)(*v5++ ^ result)] ^ ((unsigned int)result >> 8);
while ( v5 != (_BYTE *)v6 );
}
return result;
}

original_code:
tcrc BufCRC(tcrc crccode, char *buf, int size)
{
 int i;
 for (i = 0 ; i < size ; i ++)
  crccode = crctab[(int) (crccode ^ buf[i]) & 0xff] ^ ((crccode >> 8) & 0x00FFFFFFL);
 return crccode;
}

canonical_original_code:
unsigned long BufCRC(unsigned long crccode, char *buf, int size)
{
 int i;
 for (i = 0 ; i < size ; i ++)
  crccode = crctab[(int) (crccode ^ buf[i]) & 0xff] ^ ((crccode >> 8) & 0x00FFFFFFL);
 return crccode;
}

variable_types:
crccode
unsigned long

variable_types:
buf
char *

return_type: unsigned long


InitCRC

decompiled_code:
__int64 InitCRC()
{
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func1()
{
return 0xFFFFFFFFLL;
}

original_code:
tcrc InitCRC()
{
 return 0xFFFFFFFFL;
}

canonical_original_code:
unsigned long InitCRC()
{
 return 0xFFFFFFFFL;
}


findbucket

decompiled_code:
__int64 __fastcall findbucket(_QWORD *a1, int a2)
{
__int64 i; // rcx
unsigned int v3; // er8
_QWORD *v4; // rax
int v5; // edx

for ( i = 0LL; i != 30; ++i )
{
v3 = i;
v4 = (_QWORD *)nextf[i];
if ( v4 && a2 )
{
if ( v4 == a1 )
return v3;
v5 = 0;
while ( 1 )
{
++v5;
v4 = (_QWORD *)*v4;
if ( !v4 || a2 == v5 )
break;
if ( a1 == v4 )
return v3;
}
}
}
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2)
{
__int64 i; // rcx
unsigned int v3; // er8
_QWORD *v4; // rax
int v5; // edx

for ( i = 0LL; i != 30; ++i )
{
v3 = i;
v4 = (_QWORD *)nextf[i];
if ( v4 && a2 )
{
if ( v4 == a1 )
return v3;
v5 = 0;
while ( 1 )
{
++v5;
v4 = (_QWORD *)*v4;
if ( !v4 || a2 == v5 )
break;
if ( a1 == v4 )
return v3;
}
}
}
return (unsigned int)-1;
}

original_code:
static int findbucket( union overhead *freep, int srchlen )
{
 union overhead *p;
 int i, j;
 for (i = 0; i < 30; i++) {
  j = 0;
  for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
   if (p == freep)
    return (i);
   j++;
  }
 }
 return (-1);
}

canonical_original_code:
static int findbucket(union overhead *freep, int srchlen)
{
 union overhead *p;
 int i; int j;
 for (i = 0; i < 30; i++) {
  j = 0;
  for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
   if (p == freep)
    return (i);
   j++;
  }
 }
 return (-1);
}

variable_types: union overhead { union overhead *ov_next; struct { unsigned char ovu_magic; unsigned char ovu_index; } ovu; } *

variable_types: srchlen int

variable_types: j int


getBlock

decompiled_code:
__int64 __fastcall getBlock(__int64 a1)
{
_QWORD *v1; // rbx
__int64 v2; // r12
_QWORD *v3; // rax
__int64 result; // rax

v1 = (_QWORD *)availList;
v2 = s_pagesz_0;
if ( !s_pagesz_0 )
{
v2 = Dynace_GetInitialPageSize();
s_pagesz_0 = Dynace_GetPageSize();
}
if ( v1 )
{
while ( v1[1] < a1 )
{
v1 = (_QWORD *)*v1;
if ( !v1 )
goto LABEL_6;
}
goto LABEL_10;
}
LABEL_6:
if ( a1 + 16 >= v2 )
v2 = a1 + 16;
v3 = (_QWORD *)Dynace_getpage(v2);
v1 = v3;
if ( v3 )
{
v3[2] = v3 + 3;
v3[1] = v2 - 24;
*v3 = availList;
availList = (__int64)v3;
LABEL_10:
result = v1[2];
v1[2] = result + a1;
v1[1] -= a1;
return result;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
_QWORD *v1; // rbx
__int64 v2; // r12
_QWORD *v3; // rax
__int64 result; // rax

v1 = (_QWORD *)availList;
v2 = s_pagesz_0;
if ( !s_pagesz_0 )
{
v2 = Dynace_GetInitialPageSize();
s_pagesz_0 = Dynace_GetPageSize();
}
if ( v1 )
{
while ( v1[1] < a1 )
{
v1 = (_QWORD *)*v1;
if ( !v1 )
goto LABEL_6;
}
goto LABEL_10;
}
LABEL_6:
if ( a1 + 16 >= v2 )
v2 = a1 + 16;
v3 = (_QWORD *)Dynace_getpage(v2);
v1 = v3;
if ( v3 )
{
v3[2] = v3 + 3;
v3[1] = v2 - 24;
*v3 = availList;
availList = (__int64)v3;
LABEL_10:
result = v1[2];
v1[2] = result + a1;
v1[1] -= a1;
return result;
}
return 0LL;
}

original_code:
static void *getBlock( long blockSize )
{
 char *returnBlock;
 al *tempList = availList;
 static long s_pagesz = 0;
 long curr_pagesz = s_pagesz;
 if ( !s_pagesz ) {
  curr_pagesz = Dynace_GetInitialPageSize();
  s_pagesz = Dynace_GetPageSize();
 }
 while( tempList )
 {
  if ( tempList->availAmt >= blockSize )
   break;
  tempList = tempList->next;
 }
 if ( !tempList )
 {
  returnBlock = _Dynace_getpage( ((curr_pagesz)>(blockSize + 16)?(curr_pagesz):(blockSize + 16)) );
  if ( !returnBlock )
   return( ((void *)0) );
  tempList = ( al * )returnBlock;
  returnBlock += sizeof( al );
  tempList->memBlock = returnBlock;
  tempList->availAmt = ((curr_pagesz)>(blockSize + 16)?(curr_pagesz):(blockSize + 16)) - sizeof( al );
  tempList->next = availList;
  availList = tempList;
 }
 returnBlock = tempList->memBlock;
 tempList->memBlock += blockSize;
 tempList->availAmt -= blockSize;
 return( returnBlock );
}

canonical_original_code:
static void *getBlock(long blockSize)
{
 char *returnBlock;
 struct _availList *tempList = availList;
 static long s_pagesz = 0;
 long curr_pagesz = s_pagesz;
 if ( !s_pagesz ) {
  curr_pagesz = Dynace_GetInitialPageSize();
  s_pagesz = Dynace_GetPageSize();
 }
 while( tempList )
 {
  if ( tempList->availAmt >= blockSize )
   break;
  tempList = tempList->next;
 }
 if ( !tempList )
 {
  returnBlock = _Dynace_getpage( ((curr_pagesz)>(blockSize + 16)?(curr_pagesz):(blockSize + 16)) );
  if ( !returnBlock )
   return( ((void *)0) );
  tempList = ( struct _availList * )returnBlock;
  returnBlock += sizeof( al );
  tempList->memBlock = returnBlock;
  tempList->availAmt = ((curr_pagesz)>(blockSize + 16)?(curr_pagesz):(blockSize + 16)) - sizeof( al );
  tempList->next = availList;
  availList = tempList;
 }
 returnBlock = tempList->memBlock;
 tempList->memBlock += blockSize;
 tempList->availAmt -= blockSize;
 return( returnBlock );
}

variable_types: blockSize long

variable_types:
returnBlock
char *

variable_types: struct _availList { struct _availList *next; long availAmt; char *memBlock; } *

return_type: void *


decompiled_code:
__int64 __fastcall Object_cm_gSetErrorFunction(__int64 a1, __int64 a2)
{
__int64 result; // rax

result = cErrorFunction;
cErrorFunction = a2;
return result;
}

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

result = cErrorFunction;
cErrorFunction = a2;
return result;
}

original_code:
static ifun Object_cm_gSetErrorFunction(object self, ifun fun)
{
 ifun ret = cErrorFunction;
 cErrorFunction = fun;
 return ret;
}

canonical_original_code:
static int (*Object_cm_gSetErrorFunction(struct _Object_iv_t *self, int (*fun)()))()
{
 int (*ret)() = cErrorFunction;
 cErrorFunction = fun;
 return ret;
}

variable_types: struct _Object_iv_t { struct _Object_iv_t *cls; unsigned short tag; unsigned short siz; unsigned long sn; } *

variable_types:
fun
int (*)()

variable_types:
ret
int (*)()


decompiled_code:
__int64 __fastcall Object_im_gInit(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return a1;
}

original_code:
static objrtn Object_im_gInit(object self)
{
 return self;
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gInit(struct _Object_iv_t *self)
{
 return self;
}

variable_types:
self
struct _Object_iv_t *

return_type: struct _Object_iv_t { struct _Object_iv_t *cls; unsigned short tag; unsigned short siz; unsigned long sn; } *


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

if ( CheckObjects_ && !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
v2 = gStringRepValue(a1);
gPuts(a2, v2);
gDispose(v2);
return a1;
}

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

if ( CheckObjects_ && !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
v2 = gStringRepValue(a1);
gPuts(a2, v2);
gDispose(v2);
return a1;
}

original_code:
static objrtn Object_im_gPrintValue(object self, object stream)
{
 object t;
 if (_CheckObjects_ && !IsObj(stream)) gInvalidObject(_LastGeneric_, 2, self);
 t = gStringRepValue(self);
 gPuts(stream, (char *) t);
 gDispose(t);
 return self;
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gPrintValue(struct _Object_iv_t *self, struct _Object_iv_t *stream)
{
 struct _Object_iv_t *t;
 if (_CheckObjects_ && !IsObj(stream)) gInvalidObject(_LastGeneric_, 2, self);
 t = gStringRepValue(self);
 gPuts(stream, (char *) t);
 gDispose(t);
 return self;
}

variable_types:
stream
struct _Object_iv_t *

user_defined_types: struct _Object_iv_t { struct _Object_iv_t *cls; unsigned short tag; unsigned short siz; unsigned long sn; }


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

if ( CheckObjects_ && !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
v2 = gStringRep(a1);
gPuts(a2, v2);
gDispose(v2);
return a1;
}

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

if ( CheckObjects_ && !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
v2 = gStringRep(a1);
gPuts(a2, v2);
gDispose(v2);
return a1;
}

original_code:
static objrtn Object_im_gPrint(object self, object stream)
{
 object t;
 if (_CheckObjects_ && !IsObj(stream)) gInvalidObject(_LastGeneric_, 2, self);
 t = gStringRep(self);
 gPuts(stream, (char *) t);
 gDispose(t);
 return self;
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gPrint(struct _Object_iv_t *self, struct _Object_iv_t *stream)
{
 struct _Object_iv_t *t;
 if (_CheckObjects_ && !IsObj(stream)) gInvalidObject(_LastGeneric_, 2, self);
 t = gStringRep(self);
 gPuts(stream, (char *) t);
 gDispose(t);
 return self;
}


decompiled_code:
__int64 __fastcall Object_im_gCompare(unsigned __int64 a1, unsigned __int64 a2)
{
if ( a1 == a2 )
return 0LL;
if ( CheckObjects_ )
{
if ( !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
}
return a1 < a2 ? -1 : 1;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 a1, unsigned __int64 a2)
{
if ( a1 == a2 )
return 0LL;
if ( CheckObjects_ )
{
if ( !(unsigned int)IsObj(a2) )
gInvalidObject(LastGeneric_, 2LL, a1);
}
return a1 < a2 ? -1 : 1;
}

original_code:
static int Object_im_gCompare(object self, object obj2)
{
 if (((self) == (obj2)))
  return 0;
 if (_CheckObjects_ && !IsObj(obj2)) gInvalidObject(_LastGeneric_, 2, self);
 if ((INT_PTR) self < (INT_PTR) obj2)
  return -1;
 else
  return 1;
}

canonical_original_code:
static int Object_im_gCompare(struct _Object_iv_t *self, struct _Object_iv_t *obj2)
{
 if (((self) == (obj2)))
  return 0;
 if (_CheckObjects_ && !IsObj(obj2)) gInvalidObject(_LastGeneric_, 2, self);
 if ((unsigned long) self < (unsigned long) obj2)
  return -1;
 else
  return 1;
}


decompiled_code:
__int64 __fastcall Object_im_gStringRepValue(_QWORD *a1)
{
__int64 (*v2)(__int64, const char *, ...); // r12
const char *v3; // rbp
__int64 v4; // rdi

v2 = vSprintf;
v3 = (const char *)gName(*a1);
v4 = String_c;
if ( !String_c )
v4 = String_initialize();
return v2(v4, "%s:<%8.8lx>", v3, a1);
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1)
{
__int64 (*v2)(__int64, const char *, ...); // r12
const char *v3; // rbp
__int64 v4; // rdi

v2 = vSprintf;
v3 = (const char *)gName(*a1);
v4 = String_c;
if ( !String_c )
v4 = String_initialize();
return v2(v4, "%s:<%8.8lx>", v3, a1);
}

original_code:
static objrtn Object_im_gStringRepValue(object self)
{
 return vSprintf((String_c ? String_c : String_initialize()), "%s:<%8.8lx>", gName((object) *((object *) (self))), self);
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gStringRepValue(struct _Object_iv_t *self)
{
 return vSprintf((String_c ? String_c : String_initialize()), "%s:<%8.8lx>", gName((object) *((struct _Object_iv_t **) (self))), self);
}


decompiled_code:
__int64 __fastcall Object_im_gStringRep(_QWORD *a1)
{
__int64 (*v2)(__int64, const char *, ...); // r12
const char *v3; // rbp
__int64 v4; // rdi
__int64 v5; // rbp
__int64 v6; // rbx

v2 = vSprintf;
v3 = (const char *)gName(*a1);
v4 = String_c;
if ( !String_c )
v4 = String_initialize();
v5 = v2(v4, "%s:<%8.8lx> [ ", v3, a1);
v6 = gStringRepValue(a1);
vBuild(v5, 0LL, v6, " ]\n", 0LL);
gDispose(v6);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1)
{
__int64 (*v2)(__int64, const char *, ...); // r12
const char *v3; // rbp
__int64 v4; // rdi
__int64 v5; // rbp
__int64 v6; // rbx

v2 = vSprintf;
v3 = (const char *)gName(*a1);
v4 = String_c;
if ( !String_c )
v4 = String_initialize();
v5 = v2(v4, "%s:<%8.8lx> [ ", v3, a1);
v6 = gStringRepValue(a1);
vBuild(v5, 0LL, v6, " ]\n", 0LL);
gDispose(v6);
return v5;
}

original_code:
static objrtn Object_im_gStringRep(object self)
{
 object s, t;
 s = vSprintf((String_c ? String_c : String_initialize()), "%s:<%8.8lx> [ ", gName((object) *((object *) (self))), self);
 t = gStringRepValue(self);
 vBuild(s, ((void *)0), t, " ]\n", ((void *)0));
 gDispose(t);
 return s;
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gStringRep(struct _Object_iv_t *self)
{
 struct _Object_iv_t *s; struct _Object_iv_t *t;
 s = vSprintf((String_c ? String_c : String_initialize()), "%s:<%8.8lx> [ ", gName((object) *((struct _Object_iv_t **) (self))), self);
 t = gStringRepValue(self);
 vBuild(s, ((void *)0), t, " ]\n", ((void *)0));
 gDispose(t);
 return s;
}


decompiled_code:
__int64 __fastcall Object_im_gObjectSerialNumber(__int64 a1)
{
return *(_QWORD *)(GetIVptr(a1, Object_c) + 16);
}

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

original_code:
static unsigned long Object_im_gObjectSerialNumber(object self)
{ Object_iv_t *iv = ((Object_iv_t *) GetIVptr((self), Object_c));
 return iv->sn;
}

canonical_original_code:
static unsigned long Object_im_gObjectSerialNumber(struct _Object_iv_t *self)
{ struct _Object_iv_t *iv = ((Object_iv_t *) GetIVptr((self), Object_c));
 return iv->sn;
}


decompiled_code:
__int64 __fastcall Object_im_gIsKindOf(_QWORD *a1, __int64 a2)
{
__int64 (__fastcall *v4)(__int64, __int64, __int64); // r12
__int64 v5; // r13
__int64 v6; // rdi

if ( class_IsKindOf_0 )
return class_IsKindOf_0(*a1, a2);
v4 = gFindMethod;
v5 = gIsKindOf_g;
v6 = Behavior_c;
if ( !Behavior_c )
v6 = Behavior_initialize();
class_IsKindOf_0 = (__int64 (__fastcall *)(_QWORD, _QWORD))v4(v6, v5, 1LL);
return class_IsKindOf_0(*a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, __int64 a2)
{
__int64 (__fastcall *v4)(__int64, __int64, __int64); // r12
__int64 v5; // r13
__int64 v6; // rdi

if ( class_IsKindOf_0 )
return class_IsKindOf_0(*a1, a2);
v4 = gFindMethod;
v5 = gIsKindOf_g;
v6 = Behavior_c;
if ( !Behavior_c )
v6 = Behavior_initialize();
class_IsKindOf_0 = (__int64 (__fastcall *)(_QWORD, _QWORD))v4(v6, v5, 1LL);
return class_IsKindOf_0(*a1, a2);
}

original_code:
static int Object_im_gIsKindOf(object self, object aCls)
{
 static gIsKindOf_t class_IsKindOf = ((void *)0);
 if (!class_IsKindOf)
  class_IsKindOf = (gIsKindOf_t) gFindMethod((Behavior_c ? Behavior_c : Behavior_initialize()), gIsKindOf_g, 1);
 return class_IsKindOf((object) *((object *) (self)), aCls);
}

canonical_original_code:
static int Object_im_gIsKindOf(struct _Object_iv_t *self, struct _Object_iv_t *aCls)
{
 static int (*class_IsKindOf)(struct _Object_iv_t *self, struct _Object_iv_t *aCls) = ((void *)0);
 if (!class_IsKindOf)
  class_IsKindOf = (int (*)(struct _Object_iv_t *self, struct _Object_iv_t *aCls)) gFindMethod((Behavior_c ? Behavior_c : Behavior_initialize()), gIsKindOf_g, 1);
 return class_IsKindOf((object) *((struct _Object_iv_t **) (self)), aCls);
}

variable_types:
aCls
struct _Object_iv_t *

variable_types: int (*)(struct _Object_iv_t { struct _Object_iv_t *cls; unsigned short tag; unsigned short siz; unsigned long sn; } *self, struct _Object_iv_t *aCls)


decompiled_code:
__int64 __fastcall Object_im_gShouldNotImplement(_QWORD **a1, const char *a2)
{
_QWORD *v3; // rdi
const char *v4; // rax
const char *v5; // rax
char v7[136]; // [rsp+0h] [rbp-88h] BYREF

v3 = *a1;
if ( *v3 == MetaClass_c || v3 == (_QWORD *)MetaClass_c )
{
v5 = (const char *)gName(a1);
sprintf(v7, "Method %s is not appropriate for the %s class\n", a2, v5);
}
else
{
v4 = (const char *)gName(v3);
sprintf(v7, "Method %s is not appropriate for instances of %s\n", a2, v4);
}
return gError(a1, v7);
}

canonical_decompiled_code:
__int64 __fastcall func9(_QWORD **a1, const char *a2)
{
_QWORD *v3; // rdi
const char *v4; // rax
const char *v5; // rax
char v7[136]; // [rsp+0h] [rbp-88h] BYREF

v3 = *a1;
if ( *v3 == MetaClass_c || v3 == (_QWORD *)MetaClass_c )
{
v5 = (const char *)gName(a1);
sprintf(v7, "Method %s is not appropriate for the %s class\n", a2, v5);
}
else
{
v4 = (const char *)gName(v3);
sprintf(v7, "Method %s is not appropriate for instances of %s\n", a2, v4);
}
return gError(a1, v7);
}

original_code:
static objrtn Object_im_gShouldNotImplement(object self, char *meth)
{
 char buf[100];
 if ((((object) *((object *) ((object) *((object *) (self)))) == MetaClass_c) || ((object) *((object *) (self)) == MetaClass_c)))
  sprintf(buf, "Method %s is not appropriate for the %s class\n",
  meth, gName(self));
 else
  sprintf(buf, "Method %s is not appropriate for instances of %s\n",
  meth, gName((object) *((object *) (self))));
 return gError(self, buf);
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gShouldNotImplement(struct _Object_iv_t *self, char *meth)
{
 char buf[100];
 if ((((object) *((struct _Object_iv_t **) ((object) *((struct _Object_iv_t **) (self)))) == MetaClass_c) || ((object) *((struct _Object_iv_t **) (self)) == MetaClass_c)))
  sprintf(buf, "Method %s is not appropriate for the %s class\n",
  meth, gName(self));
 else
  sprintf(buf, "Method %s is not appropriate for instances of %s\n",
  meth, gName((object) *((struct _Object_iv_t **) (self))));
 return gError(self, buf);
}

variable_types:
meth
char *

variable_types:
buf
char [100]


decompiled_code:
__int64 __fastcall Object_im_gSubclassResponsibility(_QWORD **a1, const char *a2)
{
_QWORD *v3; // rdi
const char *v4; // rax
char v6[136]; // [rsp+0h] [rbp-88h] BYREF

v3 = *a1;
if ( *v3 == MetaClass_c || v3 == (_QWORD *)MetaClass_c )
v3 = a1;
v4 = (const char *)gName(v3);
sprintf(v6, "Method %s should be implemented by a subclass of %s\n", a2, v4);
return gError(a1, v6);
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD **a1, const char *a2)
{
_QWORD *v3; // rdi
const char *v4; // rax
char v6[136]; // [rsp+0h] [rbp-88h] BYREF

v3 = *a1;
if ( *v3 == MetaClass_c || v3 == (_QWORD *)MetaClass_c )
v3 = a1;
v4 = (const char *)gName(v3);
sprintf(v6, "Method %s should be implemented by a subclass of %s\n", a2, v4);
return gError(a1, v6);
}

original_code:
static objrtn Object_im_gSubclassResponsibility(object self, char *meth)
{
 char buf[100];
 object aCls;
 aCls = (((object) *((object *) ((object) *((object *) (self)))) == MetaClass_c) || ((object) *((object *) (self)) == MetaClass_c)) ? self : (object) *((object *) (self));
 sprintf(buf, "Method %s should be implemented by a subclass of %s\n",
  meth, gName(aCls));
 return gError(self, buf);
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gSubclassResponsibility(struct _Object_iv_t *self, char *meth)
{
 char buf[100];
 struct _Object_iv_t *aCls;
 aCls = (((object) *((struct _Object_iv_t **) ((object) *((struct _Object_iv_t **) (self)))) == MetaClass_c) || ((object) *((struct _Object_iv_t **) (self)) == MetaClass_c)) ? self : (object) *((struct _Object_iv_t **) (self));
 sprintf(buf, "Method %s should be implemented by a subclass of %s\n",
  meth, gName(aCls));
 return gError(self, buf);
}


decompiled_code:
__int64 Object_ifm_vError(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return Object_ivm_vError(a1, (int *)va);
}

canonical_decompiled_code:
__int64 func12(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
return func11(a1, (int *)va);
}

original_code:
static objrtn Object_ifm_vError(object self, ...)
{
 va_list _rest_;
 __builtin_va_start(_rest_,self);
 return Object_ivm_vError(self, _rest_);
}

canonical_original_code:
static struct _Object_iv_t *Object_ifm_vError(struct _Object_iv_t *self, ...)
{
 __builtin_va_list _rest_;
 __builtin_va_start(_rest_,self);
 return Object_ivm_vError(self, _rest_);
}


decompiled_code:
void __fastcall __noreturn Object_im_gError(__int64 a1, const char *a2)
{
const char *v2; // rbx
void (__fastcall *v3)(__int64, const char *); // rbp
__int64 v4; // rdi

v2 = a2;
if ( cErrorFunction )
cErrorFunction(a2);
if ( File_c )
{
v3 = (void (__fastcall *)(__int64, const char *))gPuts;
v4 = stderrStream_o;
if ( !stderrStream_o )
{
File_initialize();
v4 = stderrStream_o;
}
v3(v4, a2);
}
else
{
if ( (unsigned int)IsObj(a2) )
v2 = (const char *)gStringValue(a2);
fputs(v2, stderr);
}
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func13(__int64 a1, const char *a2)
{
const char *v2; // rbx
void (__fastcall *v3)(__int64, const char *); // rbp
__int64 v4; // rdi

v2 = a2;
if ( cErrorFunction )
cErrorFunction(a2);
if ( File_c )
{
v3 = (void (__fastcall *)(__int64, const char *))gPuts;
v4 = stderrStream_o;
if ( !stderrStream_o )
{
File_initialize();
v4 = stderrStream_o;
}
v3(v4, a2);
}
else
{
if ( (unsigned int)IsObj(a2) )
v2 = (const char *)gStringValue(a2);
fputs(v2, stderr);
}
exit(1);
}

original_code:
static objrtn Object_im_gError(object self, char *msg)
{
 if (cErrorFunction)
  cErrorFunction(msg);
  if (File_c)
  gPuts((stderrStream_o ? stderrStream_o : (File_initialize(), stderrStream_o)), msg);
 else {
  if (IsObj((object) msg))
   msg = gStringValue((object) msg);
  fprintf(stderr, "%s", msg);
 }
  exit(1);
 return self;
}

canonical_original_code:
static struct _Object_iv_t *Object_im_gError(struct _Object_iv_t *self, char *msg)
{
 if (cErrorFunction)
  cErrorFunction(msg);
  if (File_c)
  gPuts((stderrStream_o ? stderrStream_o : (File_initialize(), stderrStream_o)), msg);
 else {
  if (IsObj((struct _Object_iv_t *) msg))
   msg = gStringValue((struct _Object_iv_t *) msg);
  fprintf(stderr, "%s", msg);
 }
  exit(1);
 return self;
}

variable_types:
msg
char *


original_code:
static int Object_im_gHash(object self)
{
 double t;
 t = .6125423371 * (double)(INT_PTR) self;
 t = t < 0.0 ? -t : t;
 return (int) ((sizeof(int) > 2 ? 320000001.0 : 32001.0) * (t - floor(t)));
}

canonical_original_code:
static int Object_im_gHash(struct _Object_iv_t *self)
{
 double t;
 t = .6125423371 * (double)(unsigned long) self;
 t = t < 0.0 ? -t : t;
 return (int) ((sizeof(int) > 2 ? 320000001.0 : 32001.0) * (t - floor(t)));
}

variable_types: t double


decompiled_code:
__int64 Object_initialize()
{
if ( !done_1 )
{
done_1 = 1;
gNewMethod(
Method_c,
"Object_cm_gSetErrorFunction",
*(_QWORD *)Object_c,
gSetErrorFunction_g,
Object_cm_gSetErrorFunction);
gNewMethod(Method_c, "Object_im_gError", Object_c, gError_g, Object_im_gError);
gNewMethod(Method_c, "Object_ivm_vError", Object_c, vError_g, Object_ivm_vError);
gNewMethod(
Method_c,
"Object_im_gSubclassResponsibility",
Object_c,
gSubclassResponsibility_g,
Object_im_gSubclassResponsibility);
gNewMethod(
Method_c,
"Object_im_gShouldNotImplement",
Object_c,
gShouldNotImplement_g,
Object_im_gShouldNotImplement);
gNewMethod(Method_c, "Object_im_gHash", Object_c, gHash_g, Object_im_gHash);
gNewMethod(Method_c, "Object_im_gCompare", Object_c, gCompare_g, Object_im_gCompare);
gNewMethod(Method_c, "Object_im_gIsKindOf", Object_c, gIsKindOf_g, Object_im_gIsKindOf);
gNewMethod(Method_c, "Object_im_gInit", Object_c, gInit_g, Object_im_gInit);
gNewMethod(
Method_c,
"Object_im_gObjectSerialNumber",
Object_c,
gObjectSerialNumber_g,
Object_im_gObjectSerialNumber);
gNewMethod(Method_c, "Object_im_gStringRep", Object_c, gStringRep_g, Object_im_gStringRep);
gNewMethod(Method_c, "Object_im_gStringRepValue", Object_c, gStringRepValue_g, Object_im_gStringRepValue);
gNewMethod(Method_c, "Object_im_gPrint", Object_c, gPrint_g, Object_im_gPrint);
gNewMethod(Method_c, "Object_im_gPrintValue", Object_c, gPrintValue_g, Object_im_gPrintValue);
}
return Object_c;
}

canonical_decompiled_code:
__int64 func15()
{
if ( !done_1 )
{
done_1 = 1;
gNewMethod(
Method_c,
"Object_cm_gSetErrorFunction",
*(_QWORD *)Object_c,
gSetErrorFunction_g,
Object_cm_gSetErrorFunction);
gNewMethod(Method_c, "Object_im_gError", Object_c, gError_g, Object_im_gError);
gNewMethod(Method_c, "Object_ivm_vError", Object_c, vError_g, Object_ivm_vError);
gNewMethod(
Method_c,
"Object_im_gSubclassResponsibility",
Object_c,
gSubclassResponsibility_g,
Object_im_gSubclassResponsibility);
gNewMethod(
Method_c,
"Object_im_gShouldNotImplement",
Object_c,
gShouldNotImplement_g,
Object_im_gShouldNotImplement);
gNewMethod(Method_c, "Object_im_gHash", Object_c, gHash_g, Object_im_gHash);
gNewMethod(Method_c, "Object_im_gCompare", Object_c, gCompare_g, Object_im_gCompare);
gNewMethod(Method_c, "Object_im_gIsKindOf", Object_c, gIsKindOf_g, Object_im_gIsKindOf);
gNewMethod(Method_c, "Object_im_gInit", Object_c, gInit_g, Object_im_gInit);
gNewMethod(
Method_c,
"Object_im_gObjectSerialNumber",
Object_c,
gObjectSerialNumber_g,
Object_im_gObjectSerialNumber);
gNewMethod(Method_c, "Object_im_gStringRep", Object_c, gStringRep_g, Object_im_gStringRep);
gNewMethod(Method_c, "Object_im_gStringRepValue", Object_c, gStringRepValue_g, Object_im_gStringRepValue);
gNewMethod(Method_c, "Object_im_gPrint", Object_c, gPrint_g, Object_im_gPrint);
gNewMethod(Method_c, "Object_im_gPrintValue", Object_c, gPrintValue_g, Object_im_gPrintValue);
}
return Object_c;
}

original_code:
objrtn Object_initialize(void)
{
 static int done = 0;
 if (done)
  return Object_c;
 done = 1;
 gNewMethod(Method_c, "Object_cm_gSetErrorFunction", (object) *((object *) (Object_c)), gSetErrorFunction_g, (ofun) Object_cm_gSetErrorFunction, (ofun) Object_cm_gSetErrorFunction);
 gNewMethod(Method_c, "Object_im_gError", Object_c, gError_g, (ofun) Object_im_gError, (ofun) Object_im_gError);
 gNewMethod(Method_c, "Object_ivm_vError", Object_c, vError_g, (ofun) Object_ivm_vError, (ofun) Object_ifm_vError);
 gNewMethod(Method_c, "Object_im_gSubclassResponsibility", Object_c, gSubclassResponsibility_g, (ofun) Object_im_gSubclassResponsibility, (ofun) Object_im_gSubclassResponsibility);
 gNewMethod(Method_c, "Object_im_gShouldNotImplement", Object_c, gShouldNotImplement_g, (ofun) Object_im_gShouldNotImplement, (ofun) Object_im_gShouldNotImplement);
 gNewMethod(Method_c, "Object_im_gHash", Object_c, gHash_g, (ofun) Object_im_gHash, (ofun) Object_im_gHash);
 gNewMethod(Method_c, "Object_im_gCompare", Object_c, gCompare_g, (ofun) Object_im_gCompare, (ofun) Object_im_gCompare);
 gNewMethod(Method_c, "Object_im_gIsKindOf", Object_c, gIsKindOf_g, (ofun) Object_im_gIsKindOf, (ofun) Object_im_gIsKindOf);
 gNewMethod(Method_c, "Object_im_gInit", Object_c, gInit_g, (ofun) Object_im_gInit, (ofun) Object_im_gInit);
 gNewMethod(Method_c, "Object_im_gObjectSerialNumber", Object_c, gObjectSerialNumber_g, (ofun) Object_im_gObjectSerialNumber, (ofun) Object_im_gObjectSerialNumber);
 gNewMethod(Method_c, "Object_im_gStringRep", Object_c, gStringRep_g, (ofun) Object_im_gStringRep, (ofun) Object_im_gStringRep);
 gNewMethod(Method_c, "Object_im_gStringRepValue", Object_c, gStringRepValue_g, (ofun) Object_im_gStringRepValue, (ofun) Object_im_gStringRepValue);
 gNewMethod(Method_c, "Object_im_gPrint", Object_c, gPrint_g, (ofun) Object_im_gPrint, (ofun) Object_im_gPrint);
 gNewMethod(Method_c, "Object_im_gPrintValue", Object_c, gPrintValue_g, (ofun) Object_im_gPrintValue, (ofun) Object_im_gPrintValue);
 return Object_c;
}

canonical_original_code:
struct _Object_iv_t *Object_initialize()
{
 static int done = 0;
 if (done)
  return Object_c;
 done = 1;
 gNewMethod(Method_c, "Object_cm_gSetErrorFunction", (object) *((struct _Object_iv_t **) (Object_c)), gSetErrorFunction_g, (struct _Object_iv_t *(*)()) Object_cm_gSetErrorFunction, (struct _Object_iv_t *(*)()) Object_cm_gSetErrorFunction);
 gNewMethod(Method_c, "Object_im_gError", Object_c, gError_g, (struct _Object_iv_t *(*)()) Object_im_gError, (struct _Object_iv_t *(*)()) Object_im_gError);
 gNewMethod(Method_c, "Object_ivm_vError", Object_c, vError_g, (struct _Object_iv_t *(*)()) Object_ivm_vError, (struct _Object_iv_t *(*)()) Object_ifm_vError);
 gNewMethod(Method_c, "Object_im_gSubclassResponsibility", Object_c, gSubclassResponsibility_g, (struct _Object_iv_t *(*)()) Object_im_gSubclassResponsibility, (struct _Object_iv_t *(*)()) Object_im_gSubclassResponsibility);
 gNewMethod(Method_c, "Object_im_gShouldNotImplement", Object_c, gShouldNotImplement_g, (struct _Object_iv_t *(*)()) Object_im_gShouldNotImplement, (struct _Object_iv_t *(*)()) Object_im_gShouldNotImplement);
 gNewMethod(Method_c, "Object_im_gHash", Object_c, gHash_g, (struct _Object_iv_t *(*)()) Object_im_gHash, (struct _Object_iv_t *(*)()) Object_im_gHash);
 gNewMethod(Method_c, "Object_im_gCompare", Object_c, gCompare_g, (struct _Object_iv_t *(*)()) Object_im_gCompare, (struct _Object_iv_t *(*)()) Object_im_gCompare);
 gNewMethod(Method_c, "Object_im_gIsKindOf", Object_c, gIsKindOf_g, (struct _Object_iv_t *(*)()) Object_im_gIsKindOf, (struct _Object_iv_t *(*)()) Object_im_gIsKindOf);
 gNewMethod(Method_c, "Object_im_gInit", Object_c, gInit_g, (struct _Object_iv_t *(*)()) Object_im_gInit, (struct _Object_iv_t *(*)()) Object_im_gInit);
 gNewMethod(Method_c, "Object_im_gObjectSerialNumber", Object_c, gObjectSerialNumber_g, (struct _Object_iv_t *(*)()) Object_im_gObjectSerialNumber, (struct _Object_iv_t *(*)()) Object_im_gObjectSerialNumber);
 gNewMethod(Method_c, "Object_im_gStringRep", Object_c, gStringRep_g, (struct _Object_iv_t *(*)()) Object_im_gStringRep, (struct _Object_iv_t *(*)()) Object_im_gStringRep);
 gNewMethod(Method_c, "Object_im_gStringRepValue", Object_c, gStringRepValue_g, (struct _Object_iv_t *(*)()) Object_im_gStringRepValue, (struct _Object_iv_t *(*)()) Object_im_gStringRepValue);
 gNewMethod(Method_c, "Object_im_gPrint", Object_c, gPrint_g, (struct _Object_iv_t *(*)()) Object_im_gPrint, (struct _Object_iv_t *(*)()) Object_im_gPrint);
 gNewMethod(Method_c, "Object_im_gPrintValue", Object_c, gPrintValue_g, (struct _Object_iv_t *(*)()) Object_im_gPrintValue, (struct _Object_iv_t *(*)()) Object_im_gPrintValue);
 return Object_c;
}

variable_types: done int


original_code:
void MA_free(void *arg)
{
 int i;
 Header *h = (Header *) arg;
 (void) CS;
 if (!h || (--h)->status != 'U') {
  (void) CS;
  return;
 }
 for (i=1 ; Map[i].userBytes && Map[i].userBytes <= h->size ; ++i);
 i--;
 h->status = 'F';
 if (h->next)
  *((char **) h->next) = ((void *)0);
 h->next = Map[i].h;
 Map[i].h = h;
 (void) CS;
}

canonical_original_code:
void MA_free(void *arg)
{
 int i;
 struct _header *h = (Header *) arg;
 (void) CS;
 if (!h || (--h)->status != 'U') {
  (void) CS;
  return;
 }
 for (i=1 ; Map[i].userBytes && Map[i].userBytes <= h->size ; ++i);
 i--;
 h->status = 'F';
 if (h->next)
  *((char **) h->next) = ((void *)0);
 h->next = Map[i].h;
 Map[i].h = h;
 (void) CS;
}

variable_types:
arg
void *

variable_types: i int

variable_types: struct _header { char status; struct _header *next; unsigned int rsize; unsigned int size; } *


original_code:
static void more_core(unsigned n)
{
 unsigned sz;
 unsigned as;
 MemBlk *mb;
 Header *h;
 sz = n > DBS ? n : DBS;
 sz = (((sz-1) / sizeof(Header)) + 1) * sizeof(Header);;
 as = sizeof(MemBlk) + sizeof(Header) + sz;
 mb = (MemBlk *) malloc(as);
 if (!mb) {
  fprintf(stderr, "\nOut of memory.\n");
  exit(1);
 }
 mb->next = MMBP;
 MMBP = mb;
 mb->size = sz + sizeof(Header);
 h = (Header *) (mb+1);
 h->status = 'U';
 h->next = ((void *)0);
 h->size = sz;
 MA_free(h+1);
}

canonical_original_code:
static void more_core(unsigned int n)
{
 unsigned int sz;
 unsigned int as;
 struct _memBlk *mb;
 struct _header *h;
 sz = n > DBS ? n : DBS;
 sz = (((sz-1) / sizeof(Header)) + 1) * sizeof(Header);;
 as = sizeof(MemBlk) + sizeof(Header) + sz;
 mb = (struct _memBlk *) malloc(as);
 if (!mb) {
  fprintf(stderr, "\nOut of memory.\n");
  exit(1);
 }
 mb->next = MMBP;
 MMBP = mb;
 mb->size = sz + sizeof(Header);
 h = (struct _header *) (mb+1);
 h->status = 'U';
 h->next = ((void *)0);
 h->size = sz;
 MA_free(h+1);
}

variable_types:
n
unsigned int

variable_types:
sz
unsigned int

variable_types:
as
unsigned int

variable_types: struct _memBlk { struct _memBlk *next; unsigned int size; } *

user_defined_types: struct _header { char status; struct _header *next; unsigned int rsize; unsigned int size; }


original_code:
void *MA_malloc(unsigned n, void *p)
{
 unsigned sz;
 int i;
 Header *h;
 Header *ph;
 Header *bh;
 Header *pbh;
 unsigned tnb;
 unsigned nbn;
 unsigned nbl;
 if (!CS_init) {
  (void) CS;
  CS_init = 1;
 }
 (void) CS;
 if (!n)
  ++n;
 sz = (((n-1) / sizeof(Header)) + 1) * sizeof(Header);;
 for (i=1 ; Map[i].userBytes && Map[i].userBytes <= sz ; ++i);
 i--;
 for (bh=pbh=ph=((void *)0), h=Map[i].h ; h ; ph=h, h=h->next)
  if (h->size == sz) {
  if (ph)
   ph->next = h->next;
  else
   Map[i].h = h->next;
  h->status = 'U';
  h->next = (Header *) p;
  h->rsize = n;
  (void) CS;
  return h+1;
 } else if (h->size > sz && (!bh || bh->size > h->size)) {
  pbh = ph;
  bh = h;
 }
 if (bh) {
  if (pbh)
   pbh->next = bh->next;
  else
   Map[i].h = bh->next;
  bh->status = 'U';
  bh->next = (Header *) p;
  bh->rsize = n;
  (void) CS;
  return bh+1;
 }
 for (i++ ; Map[i].userBytes && !Map[i].h ; ++i);
 if (!Map[i].userBytes) {
  more_core(n);
  (void) CS;
  return MA_malloc(n, p);
 }
 h = Map[i].h;
 Map[i].h = h->next;
 tnb = h->size / sizeof(Header);
 nbn = sz / sizeof(Header);
 nbl = tnb - nbn;
 if (nbl > 5) {
  bh = h + (nbn + 1);
  bh->status = 'U';
  bh->next = ((void *)0);
  bh->rsize = bh->size = (nbl - 1) * sizeof(Header);
  h->size -= nbl * sizeof(Header);
  MA_free(bh+1);
 }
 h->status = 'U';
 h->next = (Header *) p;
 h->rsize = n;
 (void) CS;
 return h+1;
}

canonical_original_code:
void *MA_malloc(unsigned int n, void *p)
{
 unsigned int sz;
 int i;
 struct _header *h;
 struct _header *ph;
 struct _header *bh;
 struct _header *pbh;
 unsigned int tnb;
 unsigned int nbn;
 unsigned int nbl;
 if (!CS_init) {
  (void) CS;
  CS_init = 1;
 }
 (void) CS;
 if (!n)
  ++n;
 sz = (((n-1) / sizeof(Header)) + 1) * sizeof(Header);;
 for (i=1 ; Map[i].userBytes && Map[i].userBytes <= sz ; ++i);
 i--;
 for (bh=pbh=ph=((void *)0), h=Map[i].h ; h ; ph=h, h=h->next)
  if (h->size == sz) {
  if (ph)
   ph->next = h->next;
  else
   Map[i].h = h->next;
  h->status = 'U';
  h->next = (struct _header *) p;
  h->rsize = n;
  (void) CS;
  return h+1;
 } else if (h->size > sz && (!bh || bh->size > h->size)) {
  pbh = ph;
  bh = h;
 }
 if (bh) {
  if (pbh)
   pbh->next = bh->next;
  else
   Map[i].h = bh->next;
  bh->status = 'U';
  bh->next = (struct _header *) p;
  bh->rsize = n;
  (void) CS;
  return bh+1;
 }
 for (i++ ; Map[i].userBytes && !Map[i].h ; ++i);
 if (!Map[i].userBytes) {
  more_core(n);
  (void) CS;
  return MA_malloc(n, p);
 }
 h = Map[i].h;
 Map[i].h = h->next;
 tnb = h->size / sizeof(Header);
 nbn = sz / sizeof(Header);
 nbl = tnb - nbn;
 if (nbl > 5) {
  bh = h + (nbn + 1);
  bh->status = 'U';
  bh->next = ((void *)0);
  bh->rsize = bh->size = (nbl - 1) * sizeof(Header);
  h->size -= nbl * sizeof(Header);
  MA_free(bh+1);
 }
 h->status = 'U';
 h->next = (struct _header *) p;
 h->rsize = n;
 (void) CS;
 return h+1;
}

variable_types:
p
void *

variable_types:
tnb
unsigned int

variable_types:
nbn
unsigned int

variable_types:
nbl
unsigned int


decompiled_code:
void *__fastcall MA_calloc(size_t n, __int64 a2)
{
void *v2; // rax

v2 = (void *)MA_malloc(n, a2);
return memset(v2, 0, (unsigned int)n);
}

canonical_decompiled_code:
void *__fastcall func3(size_t n, __int64 a2)
{
void *v2; // rax

v2 = (void *)func2(n, a2);
return memset(v2, 0, (unsigned int)n);
}

original_code:
void *MA_calloc(unsigned n, void *p)
{
 p = MA_malloc(n, p);
 memset(p, 0, n);
 return p;
}

canonical_original_code:
void *MA_calloc(unsigned int n, void *p)
{
 p = MA_malloc(n, p);
 memset(p, 0, n);
 return p;
}


decompiled_code:
void *__fastcall MA_realloc(void *src, unsigned int a2)
{
void *v2; // rbp

if ( !src )
return 0LL;
v2 = 0LL;
if ( *((char *)src - 24) == 85 )
{
if ( *((_DWORD *)src - 1) < a2 )
{
v2 = (void *)MA_malloc(a2, *((_QWORD *)src - 2));
memcpy(v2, src, *((unsigned int *)src - 2));
*((_QWORD *)src - 2) = 0LL;
MA_free((__int64)src);
}
else
{
*((_DWORD *)src - 2) = a2;
v2 = src;
}
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func4(void *src, unsigned int a2)
{
void *v2; // rbp

if ( !src )
return 0LL;
v2 = 0LL;
if ( *((char *)src - 24) == 85 )
{
if ( *((_DWORD *)src - 1) < a2 )
{
v2 = (void *)func2(a2, *((_QWORD *)src - 2));
memcpy(v2, src, *((unsigned int *)src - 2));
*((_QWORD *)src - 2) = 0LL;
func0((__int64)src);
}
else
{
*((_DWORD *)src - 2) = a2;
v2 = src;
}
}
return v2;
}

original_code:
void *MA_realloc(void *arg, unsigned n)
{
 char *m;
 Header *h = (Header *) arg;
 (void) CS;
 if (!h || (--h)->status != 'U') {
  (void) CS;
  return ((void *)0);
 }
 if (h->size >= n) {
  h->rsize = n;
  (void) CS;
  return h+1;
 }
 m = (char *) MA_malloc(n, h->next);
 memcpy(m, h+1, h->rsize);
 h->next = ((void *)0);
 MA_free(h+1);
 (void) CS;
 return m;
}

canonical_original_code:
void *MA_realloc(void *arg, unsigned int n)
{
 char *m;
 struct _header *h = (Header *) arg;
 (void) CS;
 if (!h || (--h)->status != 'U') {
  (void) CS;
  return ((void *)0);
 }
 if (h->size >= n) {
  h->rsize = n;
  (void) CS;
  return h+1;
 }
 m = (char *) MA_malloc(n, h->next);
 memcpy(m, h+1, h->rsize);
 h->next = ((void *)0);
 MA_free(h+1);
 (void) CS;
 return m;
}

variable_types:
m
char *


original_code:
void MA_compact(void)
{
 MemBlk *mb;
 Header *fh, *mfh = ((void *)0);
 int i;
 (void) CS;
 for (mb=MMBP ; mb ; mb = mb->next) {
  fh = compact(mb);
  if (fh) {
   fh->next = mfh;
   mfh = fh;
  }
 }
 for (i=0 ; Map[i].userBytes ; ++i)
  Map[i].h = ((void *)0);
 while (fh = mfh) {
  mfh = fh->next;
  fh->status = 'U';
  fh->next = ((void *)0);
  MA_free(fh+1);
 }
 (void) CS;
}

canonical_original_code:
void MA_compact()
{
 struct _memBlk *mb;
 struct _header *fh; struct _header *mfh = ((void *)0);
 int i;
 (void) CS;
 for (mb=MMBP ; mb ; mb = mb->next) {
  fh = compact(mb);
  if (fh) {
   fh->next = mfh;
   mfh = fh;
  }
 }
 for (i=0 ; Map[i].userBytes ; ++i)
  Map[i].h = ((void *)0);
 while (fh = mfh) {
  mfh = fh->next;
  fh->status = 'U';
  fh->next = ((void *)0);
  MA_free(fh+1);
 }
 (void) CS;
}

user_defined_types: struct _memBlk { struct _memBlk *next; unsigned int size; }


decompiled_code:
__int64 Dynace_GetInitialPageSize()
{
return Dynace_GetPageSize();
}

canonical_decompiled_code:
__int64 func0()
{
return Dynace_GetPageSize();
}

original_code:
long Dynace_GetInitialPageSize()
{
 return Dynace_GetPageSize();
}

return_type: long


decompiled_code:
void catch_timer()
{
if ( tick_count )
--tick_count;
signal(27, catch_timer);
}

canonical_decompiled_code:
void func0()
{
if ( tick_count )
--tick_count;
signal(27, catch_timer);
}

original_code:
static void catch_timer(int sig)
{
 (void) sig;
 if (_tick_count)
  _tick_count--;
 signal(27, catch_timer);
}

variable_types: sig int


repo: blanciq/bq-killer

decompiled_code:
__m128i *new_todelete()
{
__m128i *result; // rax

result = (__m128i *)todelete_free;
if ( todelete_free )
{
todelete_free = *(_QWORD *)todelete_free;
}
else
{
result = (__m128i *)calloc(1uLL, 0x20uLL);
if ( !result )
{
bugf("Malloc failure @ %s:%d\n", "todelete.c", 27LL);
abort();
}
}
*result = _mm_load_si128((const __m128i *)&todelete_zero_0);
result[1] = _mm_load_si128((const __m128i *)&xmmword_DD0);
result[1].m128i_i8[8] = 1;
result->m128i_i64[1] = (__int64)&str_empty;
return result;
}

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

result = (__m128i *)todelete_free;
if ( todelete_free )
{
todelete_free = *(_QWORD *)todelete_free;
}
else
{
result = (__m128i *)calloc(1uLL, 0x20uLL);
if ( !result )
{
bugf("Malloc failure @ %s:%d\n", "todelete.c", 27LL);
abort();
}
}
*result = _mm_load_si128((const __m128i *)&todelete_zero_0);
result[1] = _mm_load_si128((const __m128i *)&xmmword_DD0);
result[1].m128i_i8[8] = 1;
result->m128i_i64[1] = (__int64)&str_empty;
return result;
}

original_code:
TODELETE_DATA *new_todelete( void )
{
    static TODELETE_DATA todelete_zero;
    TODELETE_DATA *todelete;
    if ( todelete_free == ((void *)0) )
    {
        do { if (!((todelete) = (TODELETE_DATA *) calloc ((1), sizeof(TODELETE_DATA)))) { bugf( "Malloc failure @ %s:%d\n", "todelete.c", 27 ); abort(); } } while(0);
    }
    else
    {
 todelete = todelete_free;
 todelete_free = todelete_free->next;
    }
    *todelete = todelete_zero;
    ((todelete)->valid = 1);
    todelete->name = &str_empty[ 0 ];
    todelete->timestamp = 0;
    todelete->next = ((void *)0);
    return todelete;
}

canonical_original_code:
struct todelete_data *new_todelete()
{
    static struct todelete_data todelete_zero;
    struct todelete_data *todelete;
    if ( todelete_free == ((void *)0) )
    {
        do { if (!((todelete) = (struct todelete_data *) calloc ((1), sizeof(TODELETE_DATA)))) { bugf( "Malloc failure @ %s:%d\n", "todelete.c", 27 ); abort(); } } while(0);
    }
    else
    {
 todelete = todelete_free;
 todelete_free = todelete_free->next;
    }
    *todelete = todelete_zero;
    ((todelete)->valid = 1);
    todelete->name = &str_empty[ 0 ];
    todelete->timestamp = 0;
    todelete->next = ((void *)0);
    return todelete;
}

variable_types: struct todelete_data { struct todelete_data *next; char *name; long timestamp; unsigned char valid; } *


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

if ( a1 && *(_BYTE *)(a1 + 24) )
{
v2 = *(void **)(a1 + 8);
if ( v2 )
{
if ( v2 != &str_empty )
{
free(v2);
*(_QWORD *)(a1 + 8) = 0LL;
}
}
*(_BYTE *)(a1 + 24) = 0;
result = todelete_free;
*(_QWORD *)a1 = todelete_free;
todelete_free = a1;
}
return result;
}

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

if ( a1 && *(_BYTE *)(a1 + 24) )
{
v2 = *(void **)(a1 + 8);
if ( v2 )
{
if ( v2 != &str_empty )
{
free(v2);
*(_QWORD *)(a1 + 8) = 0LL;
}
}
*(_BYTE *)(a1 + 24) = 0;
result = todelete_free;
*(_QWORD *)a1 = todelete_free;
todelete_free = a1;
}
return result;
}

original_code:
void free_todelete( TODELETE_DATA *todelete )
{
    if ( !(((todelete) != ((void *)0)) && ((todelete)->valid)) )
    {
 return;
    }
    if ( (todelete->name) != &str_empty[0] ) do { if((todelete->name)) { free((todelete->name)); (todelete->name) = ((void *)0); } } while(0);
    ((todelete)->valid = 0);
    todelete->next = todelete_free;
    todelete_free = todelete;
    return;
}

canonical_original_code:
void free_todelete(struct todelete_data *todelete)
{
    if ( !(((todelete) != ((void *)0)) && ((todelete)->valid)) )
    {
 return;
    }
    if ( (todelete->name) != &str_empty[0] ) do { if((todelete->name)) { free((todelete->name)); (todelete->name) = ((void *)0); } } while(0);
    ((todelete)->valid = 0);
    todelete->next = todelete_free;
    todelete_free = todelete;
    return;
}

user_defined_types: struct todelete_data { struct todelete_data *next; char *name; long timestamp; unsigned char valid; }


decompiled_code:
__int64 __fastcall find_todelete(char *s1)
{
__int64 i; // rbx

for ( i = todelete_list; i; i = *(_QWORD *)i )
{
if ( !strcmp(s1, *(const char **)(i + 8)) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1)
{
__int64 i; // rbx

for ( i = todelete_list; i; i = *(_QWORD *)i )
{
if ( !strcmp(s1, *(const char **)(i + 8)) )
break;
}
return i;
}

original_code:
TODELETE_DATA *find_todelete( char *name )
{
    TODELETE_DATA *todelete = ((void *)0);
    for ( todelete = todelete_list; todelete; todelete = todelete->next )
    {
 if ( !strcmp( name, todelete->name ) )
 {
     break;
 }
    }
    return todelete;
}

canonical_original_code:
struct todelete_data *find_todelete(char *name)
{
    struct todelete_data *todelete = ((void *)0);
    for ( todelete = todelete_list; todelete; todelete = todelete->next )
    {
 if ( !strcmp( name, todelete->name ) )
 {
     break;
 }
    }
    return todelete;
}

variable_types:
name
char *

return_type: struct todelete_data { struct todelete_data *next; char *name; long timestamp; unsigned char valid; } *


decompiled_code:
void __fastcall remove_todelete(char *s1)
{
__int64 v1; // rbx
_QWORD *v2; // r13

v1 = todelete_list;
if ( todelete_list )
{
v2 = 0LL;
while ( strcmp(s1, *(const char **)(v1 + 8)) )
{
v2 = (_QWORD *)v1;
if ( !*(_QWORD *)v1 )
return;
v1 = *(_QWORD *)v1;
}
if ( v2 )
*v2 = *(_QWORD *)v1;
else
todelete_list = *(_QWORD *)v1;
free_todelete(v1);
}
}

canonical_decompiled_code:
void __fastcall func5(char *s1)
{
__int64 v1; // rbx
_QWORD *v2; // r13

v1 = todelete_list;
if ( todelete_list )
{
v2 = 0LL;
while ( strcmp(s1, *(const char **)(v1 + 8)) )
{
v2 = (_QWORD *)v1;
if ( !*(_QWORD *)v1 )
return;
v1 = *(_QWORD *)v1;
}
if ( v2 )
*v2 = *(_QWORD *)v1;
else
todelete_list = *(_QWORD *)v1;
func1(v1);
}
}

original_code:
void remove_todelete( char *name )
{
    TODELETE_DATA *todelete = ((void *)0);
    TODELETE_DATA *prev_todelete = ((void *)0);
    for ( todelete = todelete_list; todelete; todelete = todelete->next )
    {
 if ( !strcmp( name, todelete->name ) )
 {
     if ( prev_todelete )
     {
  prev_todelete->next = todelete->next;
     }
     else
     {
  todelete_list = todelete->next;
     }
     free_todelete( todelete );
     break;
 }
 prev_todelete = todelete;
    }
    return;
}

canonical_original_code:
void remove_todelete(char *name)
{
    struct todelete_data *todelete = ((void *)0);
    struct todelete_data *prev_todelete = ((void *)0);
    for ( todelete = todelete_list; todelete; todelete = todelete->next )
    {
 if ( !strcmp( name, todelete->name ) )
 {
     if ( prev_todelete )
     {
  prev_todelete->next = todelete->next;
     }
     else
     {
  todelete_list = todelete->next;
     }
     free_todelete( todelete );
     break;
 }
 prev_todelete = todelete;
    }
    return;
}


decompiled_code:
__int64 __fastcall time_diff(time_t a1, time_t a2, char a3)
{
__int64 v4; // r8
__int64 v5; // rdi
__int64 result; // rax

v4 = (unsigned int)(int)difftime(a1, a2);
v5 = (__int64)((unsigned __int128)(0x48D159E26AF37C05LL * (__int128)(v4 % 86400)) >> 64) >> 10;
result = (unsigned int)((v4 % 86400 - 3600 * (int)v5) / 60);
if ( a3 == 104 )
return (unsigned int)v5;
if ( a3 <= 104 )
{
result = (unsigned int)v4;
if ( a3 != 32 )
{
result = 0xFFFFFFFFLL;
if ( a3 == 100 )
result = (unsigned int)(v4 / 86400);
}
}
else if ( a3 != 109 )
{
if ( a3 == 115 )
result = (unsigned int)((v4 % 86400 - 3600 * (int)v5) % 60);
else
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(time_t a1, time_t a2, char a3)
{
__int64 v4; // r8
__int64 v5; // rdi
__int64 result; // rax

v4 = (unsigned int)(int)difftime(a1, a2);
v5 = (__int64)((unsigned __int128)(0x48D159E26AF37C05LL * (__int128)(v4 % 86400)) >> 64) >> 10;
result = (unsigned int)((v4 % 86400 - 3600 * (int)v5) / 60);
if ( a3 == 104 )
return (unsigned int)v5;
if ( a3 <= 104 )
{
result = (unsigned int)v4;
if ( a3 != 32 )
{
result = 0xFFFFFFFFLL;
if ( a3 == 100 )
result = (unsigned int)(v4 / 86400);
}
}
else if ( a3 != 109 )
{
if ( a3 == 115 )
result = (unsigned int)((v4 % 86400 - 3600 * (int)v5) % 60);
else
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int time_diff( time_t time1, time_t time2, char format )
{
    long diff = difftime( time1, time2 );
    long days = diff / 86400;
    int hours = ( diff - ( days * 86400 ) ) / 3600;
    int minutes = ( diff - ( days * 86400 ) - ( hours * 3600 ) ) / 60;
    int seconds = ( diff - ( days * 86400 ) - ( hours * 3600 ) - ( minutes * 60 ) );
    switch ( format )
    {
 case 's': return seconds; break;
 case 'm': return minutes; break;
 case 'h': return hours; break;
 case 'd': return days; break;
 case ' ': return diff; break;
 default: return -1; break;
    }
    return -1;
}

canonical_original_code:
int time_diff(long time1, long time2, char format)
{
    long diff = difftime( time1, time2 );
    long days = diff / 86400;
    int hours = ( diff - ( days * 86400 ) ) / 3600;
    int minutes = ( diff - ( days * 86400 ) - ( hours * 3600 ) ) / 60;
    int seconds = ( diff - ( days * 86400 ) - ( hours * 3600 ) - ( minutes * 60 ) );
    switch ( format )
    {
 case 's': return seconds; break;
 case 'm': return minutes; break;
 case 'h': return hours; break;
 case 'd': return days; break;
 case ' ': return diff; break;
 default: return -1; break;
    }
    return -1;
}

variable_types: format char

variable_types: diff long

variable_types: days long

variable_types: hours int

variable_types: minutes int

variable_types: seconds int


decompiled_code:
__int64 __fastcall todelete_time(char *a1, char a2)
{
__int64 v2; // rax
time_t v3; // r13
time_t v4; // r12
__int64 v5; // r14
unsigned int v6; // er15
unsigned int v7; // eax
unsigned int v9; // [rsp+Ch] [rbp-2034h]
char s[8240]; // [rsp+10h] [rbp-2030h] BYREF

v2 = find_todelete(a1);
v3 = current_time;
v4 = *(_QWORD *)(v2 + 16);
v5 = (int)time_diff(v4, current_time, 100);
v6 = time_diff(v4, v3, 104);
v9 = time_diff(v4, v3, 109);
switch ( a2 )
{
case 'h':
sprintf(s, "%ldd %dh", v5, v6);
break;
case 'm':
sprintf(s, "%ldd %dh %dm", v5, v6, v9);
break;
case 'd':
sprintf(s, "%ldd", v5);
break;
default:
v7 = time_diff(v4, v3, 115);
sprintf(s, "%ldd %dh %dm %ds", v5, v6, v9, v7);
break;
}
return str_dup(s);
}

canonical_decompiled_code:
__int64 __fastcall func8(char *a1, char a2)
{
__int64 v2; // rax
time_t v3; // r13
time_t v4; // r12
__int64 v5; // r14
unsigned int v6; // er15
unsigned int v7; // eax
unsigned int v9; // [rsp+Ch] [rbp-2034h]
char s[8240]; // [rsp+10h] [rbp-2030h] BYREF

v2 = func2(a1);
v3 = current_time;
v4 = *(_QWORD *)(v2 + 16);
v5 = (int)func7(v4, current_time, 100);
v6 = func7(v4, v3, 104);
v9 = func7(v4, v3, 109);
switch ( a2 )
{
case 'h':
sprintf(s, "%ldd %dh", v5, v6);
break;
case 'm':
sprintf(s, "%ldd %dh %dm", v5, v6, v9);
break;
case 'd':
sprintf(s, "%ldd", v5);
break;
default:
v7 = func7(v4, v3, 115);
sprintf(s, "%ldd %dh %dm %ds", v5, v6, v9, v7);
break;
}
return str_dup(s);
}

original_code:
char *todelete_time( char *name, char format )
{
    TODELETE_DATA *todelete = find_todelete( name );
    long days = time_diff( todelete->timestamp, current_time, 'd' );
    int hours = time_diff( todelete->timestamp, current_time, 'h' );
    int minutes = time_diff( todelete->timestamp, current_time, 'm' );
    int seconds = time_diff( todelete->timestamp, current_time, 's' );
    char buf[8192];
    switch ( format )
    {
 default:
 case 's': sprintf( buf, "%ldd %dh %dm %ds", days, hours, minutes, seconds ); break;
 case 'm': sprintf( buf, "%ldd %dh %dm", days, hours, minutes ); break;
 case 'h': sprintf( buf, "%ldd %dh", days, hours ); break;
 case 'd': sprintf( buf, "%ldd", days ); break;
    }
    return str_dup( buf );
}

canonical_original_code:
char *todelete_time(char *name, char format)
{
    struct todelete_data *todelete = find_todelete( name );
    long days = time_diff( todelete->timestamp, current_time, 'd' );
    int hours = time_diff( todelete->timestamp, current_time, 'h' );
    int minutes = time_diff( todelete->timestamp, current_time, 'm' );
    int seconds = time_diff( todelete->timestamp, current_time, 's' );
    char buf[8192];
    switch ( format )
    {
 default:
 case 's': sprintf( buf, "%ldd %dh %dm %ds", days, hours, minutes, seconds ); break;
 case 'm': sprintf( buf, "%ldd %dh %dm", days, hours, minutes ); break;
 case 'h': sprintf( buf, "%ldd %dh", days, hours ); break;
 case 'd': sprintf( buf, "%ldd", days ); break;
    }
    return str_dup( buf );
}

variable_types:
buf
char [8192]


decompiled_code:
__int64 __fastcall trap_limit(unsigned __int8 a1, __int16 a2, int a3)
{
return a1 + (unsigned __int16)(a2 << 8) + ((a3 << 16) & 0xFF0000u);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 a1, __int16 a2, int a3)
{
return a1 + (unsigned __int16)(a2 << 8) + ((a3 << 16) & 0xFF0000u);
}

original_code:
int trap_limit( int level, int dex, int skill )
{
 int ret_val = 0;
 ret_val = ( level & 0xff ) + ( ( dex & 0xff ) << 8 ) + ( ( skill & 0xff ) << 16 );
 return ret_val;
}

canonical_original_code:
int trap_limit(int level, int dex, int skill)
{
 int ret_val = 0;
 ret_val = ( level & 0xff ) + ( ( dex & 0xff ) << 8 ) + ( ( skill & 0xff ) << 16 );
 return ret_val;
}

variable_types: level int

variable_types: dex int

variable_types: skill int


decompiled_code:
void __fastcall set_trap_limit(_BYTE *a1, int a2, int a3)
{
switch ( a2 )
{
case 1:
a1[48] = URANGE(1LL, a3, 29LL);
break;
case 2:
a1[50] = URANGE(1LL, a3, 99LL);
break;
case 0:
a1[49] = URANGE(3LL, a3, 27LL);
break;
}
}

canonical_decompiled_code:
void __fastcall func1(_BYTE *a1, int a2, int a3)
{
switch ( a2 )
{
case 1:
a1[48] = URANGE(1LL, a3, 29LL);
break;
case 2:
a1[50] = URANGE(1LL, a3, 99LL);
break;
case 0:
a1[49] = URANGE(3LL, a3, 27LL);
break;
}
}

original_code:
void set_trap_limit( TRAP_DATA *trap, int limit, int value )
{
 char * ptr;
 switch ( limit )
 {
  case 0:
   ptr = ( char * ) & trap->limit;
   ptr++;
   *ptr = URANGE( 3, value, 27 ) & 0xff;
   break;
  case 2:
   ptr = ( char * ) & trap->limit;
   ptr += 2;
   *ptr = URANGE( 1, value, 99 ) & 0xff;
   break;
  case 1:
   ptr = ( char * ) & trap->limit;
   *ptr = URANGE( 1, value, 29 ) & 0xff;
   break;
  default: return ;
 }
 return ;
}

canonical_original_code:
void set_trap_limit(struct trap_data *trap, int limit, int value)
{
 char *ptr;
 switch ( limit )
 {
  case 0:
   ptr = ( char * ) & trap->limit;
   ptr++;
   *ptr = URANGE( 3, value, 27 ) & 0xff;
   break;
  case 2:
   ptr = ( char * ) & trap->limit;
   ptr += 2;
   *ptr = URANGE( 1, value, 99 ) & 0xff;
   break;
  case 1:
   ptr = ( char * ) & trap->limit;
   *ptr = URANGE( 1, value, 29 ) & 0xff;
   break;
  default: return ;
 }
 return ;
}

variable_types: struct trap_data { struct trap_data *next; unsigned short vnum; unsigned char active; int level; int type; char *triggered; char *disarmed; char *failed_disarm; int limit; } *

variable_types: limit int

variable_types: value int

variable_types:
ptr
char *


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

if ( !a1 )
return 0LL;
result = *(unsigned int *)(a1 + 48);
if ( (_DWORD)result )
{
if ( a2 == 1 )
{
result = (unsigned __int8)result;
}
else if ( a2 == 2 )
{
result = BYTE2(result);
}
else
{
result = BYTE1(result);
if ( a2 )
result = 0LL;
}
}
return result;
}

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

if ( !a1 )
return 0LL;
result = *(unsigned int *)(a1 + 48);
if ( (_DWORD)result )
{
if ( a2 == 1 )
{
result = (unsigned __int8)result;
}
else if ( a2 == 2 )
{
result = BYTE2(result);
}
else
{
result = BYTE1(result);
if ( a2 )
result = 0LL;
}
}
return result;
}

original_code:
int get_limit( TRAP_DATA * trap , int limit )
{
 if ( !trap || trap->limit == 0 )
  return 0;
 switch ( limit )
 {
  case 0: return ( ( trap->limit >> 8 ) & 0xff );
  case 2: return ( ( trap->limit >> 16 ) & 0xff );
  case 1: return ( trap->limit & 0xff );
  default: return 0;
 }
 return ( trap->limit & 0xff );
}

canonical_original_code:
int get_limit(struct trap_data *trap, int limit)
{
 if ( !trap || trap->limit == 0 )
  return 0;
 switch ( limit )
 {
  case 0: return ( ( trap->limit >> 8 ) & 0xff );
  case 2: return ( ( trap->limit >> 16 ) & 0xff );
  case 1: return ( trap->limit & 0xff );
  default: return 0;
 }
 return ( trap->limit & 0xff );
}

user_defined_types: struct trap_data { struct trap_data *next; unsigned short vnum; unsigned char active; int level; int type; char *triggered; char *disarmed; char *failed_disarm; int limit; }


decompiled_code:
__int64 __fastcall flag_lookup(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 4294967197LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)v2 + 2);
v2 += 2;
v3 = *v2;
}
while ( *v2 );
return 4294967197LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 4294967197LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)v2 + 2);
v2 += 2;
v3 = *v2;
}
while ( *v2 );
return 4294967197LL;
}

original_code:
int flag_lookup ( const char *name, const struct flag_type *flag_table )
{
 int flag;
 for ( flag = 0; flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, flag_table[ flag ].name ) )
   return flag_table[ flag ].bit;
 }
 return -99;
}

canonical_original_code:
int flag_lookup(char *name, struct flag_type *flag_table)
{
 int flag;
 for ( flag = 0; flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, flag_table[ flag ].name ) )
   return flag_table[ flag ].bit;
 }
 return -99;
}

variable_types: struct flag_type { char *name; int bit; unsigned char settable; } *

variable_types: flag int


decompiled_code:
unsigned __int8 *__fastcall ext_flag_lookup(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return (unsigned __int8 *)&EXT_NONE;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return v2[1];
v2 += 3;
v3 = *v2;
}
while ( *v2 );
return (unsigned __int8 *)&EXT_NONE;
}

canonical_decompiled_code:
unsigned __int8 *__fastcall func1(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return (unsigned __int8 *)&EXT_NONE;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return v2[1];
v2 += 3;
v3 = *v2;
}
while ( *v2 );
return (unsigned __int8 *)&EXT_NONE;
}

original_code:
BITVECT_DATA * ext_flag_lookup ( const char *name, const struct ext_flag_type * ext_flag_table )
{
 int flag;
 for ( flag = 0; ext_flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(ext_flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, ext_flag_table[ flag ].name ) )
   return ext_flag_table[ flag ].bitvect;
 }
 return &EXT_NONE;
}

canonical_original_code:
struct bitvect_data *ext_flag_lookup(char *name, struct ext_flag_type *ext_flag_table)
{
 int flag;
 for ( flag = 0; ext_flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(ext_flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, ext_flag_table[ flag ].name ) )
   return ext_flag_table[ flag ].bitvect;
 }
 return &EXT_NONE;
}

variable_types:
name
char *

variable_types: struct ext_flag_type { char *name; struct bitvect_data *bitvect; unsigned char settable; } *

return_type: struct bitvect_data { int bank; int vector; } *


decompiled_code:
__int64 __fastcall is_settable(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned __int8 *)v2 + 12);
v2 += 2;
v3 = *v2;
}
while ( *v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned __int8 *)v2 + 12);
v2 += 2;
v3 = *v2;
}
while ( *v2 );
return 0LL;
}

original_code:
bool is_settable ( const char *name, const struct flag_type *flag_table )
{
 int flag;
 for ( flag = 0; flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, flag_table[ flag ].name ) )
   return flag_table[ flag ].settable;
 }
 return 0;
}

canonical_original_code:
unsigned char is_settable(char *name, struct flag_type *flag_table)
{
 int flag;
 for ( flag = 0; flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, flag_table[ flag ].name ) )
   return flag_table[ flag ].settable;
 }
 return 0;
}

return_type: unsigned char

user_defined_types: struct flag_type { char *name; int bit; unsigned char settable; }


decompiled_code:
__int64 __fastcall ext_is_settable(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned __int8 *)v2 + 16);
v2 += 3;
v3 = *v2;
}
while ( *v2 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 *a1, unsigned __int8 **a2)
{
unsigned __int8 **v2; // rbx
unsigned __int8 *v3; // rsi

v2 = a2;
v3 = *a2;
if ( !v3 )
return 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v3) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned __int8 *)v2 + 16);
v2 += 3;
v3 = *v2;
}
while ( *v2 );
return 0LL;
}

original_code:
bool ext_is_settable ( const char *name, const struct ext_flag_type * ext_flag_table )
{
 int flag;
 for ( flag = 0; ext_flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(ext_flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, ext_flag_table[ flag ].name ) )
   return ext_flag_table[ flag ].settable;
 }
 return 0;
}

canonical_original_code:
unsigned char ext_is_settable(char *name, struct ext_flag_type *ext_flag_table)
{
 int flag;
 for ( flag = 0; ext_flag_table[ flag ].name != ((void *)0); flag++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(ext_flag_table[ flag ].name[ 0 ])])
       && !str_prefix( name, ext_flag_table[ flag ].name ) )
   return ext_flag_table[ flag ].settable;
 }
 return 0;
}

variable_types: struct ext_flag_type { char *name; struct bitvect_data { int bank; int vector; } *bitvect; unsigned char settable; } *

user_defined_types: struct ext_flag_type { char *name; struct bitvect_data *bitvect; unsigned char settable; }


decompiled_code:
__int64 __fastcall position_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)position_table[0];
if ( !position_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)position_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)position_table[0];
if ( !position_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)position_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int position_lookup ( const char *name )
{
 int pos;
 for ( pos = 0; position_table[ pos ].name != ((void *)0); pos++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(position_table[ pos ].name[ 0 ])])
       && !str_prefix( name, position_table[ pos ].name ) )
   return pos;
 }
 return -1;
}

canonical_original_code:
int position_lookup(char *name)
{
 int pos;
 for ( pos = 0; position_table[ pos ].name != ((void *)0); pos++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(position_table[ pos ].name[ 0 ])])
       && !str_prefix( name, position_table[ pos ].name ) )
   return pos;
 }
 return -1;
}

variable_types: pos int


decompiled_code:
__int64 __fastcall sex_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)sex_table;
if ( !sex_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&sex_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)sex_table;
if ( !sex_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&sex_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int sex_lookup ( const char *name )
{
 int sex;
 for ( sex = 0; sex_table[ sex ].name != ((void *)0); sex++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(sex_table[ sex ].name[ 0 ])])
       && !str_prefix( name, sex_table[ sex ].name ) )
   return sex;
 }
 return -1;
}

canonical_original_code:
int sex_lookup(char *name)
{
 int sex;
 for ( sex = 0; sex_table[ sex ].name != ((void *)0); sex++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(sex_table[ sex ].name[ 0 ])])
       && !str_prefix( name, sex_table[ sex ].name ) )
   return sex;
 }
 return -1;
}

variable_types: sex int


decompiled_code:
__int64 __fastcall gender_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)gender_table;
if ( !gender_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&gender_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)gender_table;
if ( !gender_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&gender_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int gender_lookup ( const char *name )
{
 int gender;
 for ( gender = 0; gender_table[ gender ].name != ((void *)0); gender++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(gender_table[ gender ].name[ 0 ])])
       && !str_prefix( name, gender_table[ gender ].name ) )
   return gender;
 }
 return -1;
}

canonical_original_code:
int gender_lookup(char *name)
{
 int gender;
 for ( gender = 0; gender_table[ gender ].name != ((void *)0); gender++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(gender_table[ gender ].name[ 0 ])])
       && !str_prefix( name, gender_table[ gender ].name ) )
   return gender;
 }
 return -1;
}

variable_types: gender int


decompiled_code:
__int64 __fastcall size_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)size_table;
if ( !size_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&size_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)size_table;
if ( !size_table )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&size_table + v2);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int size_lookup ( const char *name )
{
 int size;
 for ( size = 0; size_table[ size ].name != ((void *)0); size++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(size_table[ size ].name[ 0 ])])
       && !str_prefix( name, size_table[ size ].name ) )
   return size;
 }
 return -1;
}

canonical_original_code:
int size_lookup(char *name)
{
 int size;
 for ( size = 0; size_table[ size ].name != ((void *)0); size++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(size_table[ size ].name[ 0 ])])
       && !str_prefix( name, size_table[ size ].name ) )
   return size;
 }
 return -1;
}

variable_types: size int


decompiled_code:
__int64 __fastcall race_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12

v1 = (unsigned __int8 *)race_table;
if ( !race_table )
return 0;
v2 = (unsigned int)((_DWORD)&race_table + 216);
v3 = 0;
while ( *((_BYTE *)&upper_nopol + *a1) != *((_BYTE *)&upper_nopol + *v1) || (unsigned __int8)str_prefix(a1) )
{
++v3;
v2 += 216LL;
v1 = *(unsigned __int8 **)(v2 - 216);
if ( !v1 )
return 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12

v1 = (unsigned __int8 *)race_table;
if ( !race_table )
return 0;
v2 = (unsigned int)((_DWORD)&race_table + 216);
v3 = 0;
while ( *((_BYTE *)&upper_nopol + *a1) != *((_BYTE *)&upper_nopol + *v1) || (unsigned __int8)str_prefix(a1) )
{
++v3;
v2 += 216LL;
v1 = *(unsigned __int8 **)(v2 - 216);
if ( !v1 )
return 0;
}
return v3;
}

original_code:
int race_lookup ( const char *name )
{
 int race;
 for ( race = 0; race_table[ race ].name != ((void *)0); race++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(race_table[ race ].name[ 0 ])])
       && !str_prefix( name, race_table[ race ].name ) )
   return race;
 }
 return 0;
}

canonical_original_code:
int race_lookup(char *name)
{
 int race;
 for ( race = 0; race_table[ race ].name != ((void *)0); race++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(race_table[ race ].name[ 0 ])])
       && !str_prefix( name, race_table[ race ].name ) )
   return race;
 }
 return 0;
}

variable_types: race int


decompiled_code:
__int64 __fastcall item_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx

v1 = (unsigned __int8 *)*((_QWORD *)&item_table + 1);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)&item_table + 4 * (int)v2);
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&item_table + 2 * v2 + 1);
}
while ( v1 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx

v1 = (unsigned __int8 *)*((_QWORD *)&item_table + 1);
if ( !v1 )
return 0xFFFFFFFFLL;
v2 = 0LL;
do
{
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
return *((unsigned int *)&item_table + 4 * (int)v2);
++v2;
v1 = (unsigned __int8 *)*((_QWORD *)&item_table + 2 * v2 + 1);
}
while ( v1 );
return 0xFFFFFFFFLL;
}

original_code:
int item_lookup( const char *name )
{
 int type;
 for ( type = 0; item_table[ type ].name != ((void *)0); type++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(item_table[ type ].name[ 0 ])])
       && !str_prefix( name, item_table[ type ].name ) )
   return item_table[ type ].type;
 }
 return -1;
}

canonical_original_code:
int item_lookup(char *name)
{
 int type;
 for ( type = 0; item_table[ type ].name != ((void *)0); type++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(item_table[ type ].name[ 0 ])])
       && !str_prefix( name, item_table[ type ].name ) )
   return item_table[ type ].type;
 }
 return -1;
}

variable_types: type int


decompiled_code:
__int64 __fastcall liq_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12

v1 = (unsigned __int8 *)liq_table;
if ( !liq_table )
return (unsigned int)-1;
v2 = (unsigned int)((_DWORD)&liq_table + 72);
v3 = 0;
while ( *((_BYTE *)&upper_nopol + *a1) != *((_BYTE *)&upper_nopol + *v1) || (unsigned __int8)str_prefix(a1) )
{
++v3;
v2 += 72LL;
v1 = *(unsigned __int8 **)(v2 - 72);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er12

v1 = (unsigned __int8 *)liq_table;
if ( !liq_table )
return (unsigned int)-1;
v2 = (unsigned int)((_DWORD)&liq_table + 72);
v3 = 0;
while ( *((_BYTE *)&upper_nopol + *a1) != *((_BYTE *)&upper_nopol + *v1) || (unsigned __int8)str_prefix(a1) )
{
++v3;
v2 += 72LL;
v1 = *(unsigned __int8 **)(v2 - 72);
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int liq_lookup ( const char *name )
{
 int liq;
 for ( liq = 0; liq_table[ liq ].liq_name != ((void *)0); liq++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(liq_table[ liq ].liq_name[ 0 ])])
       && !str_prefix( name, liq_table[ liq ].liq_name ) )
   return liq;
 }
 return -1;
}

canonical_original_code:
int liq_lookup(char *name)
{
 int liq;
 for ( liq = 0; liq_table[ liq ].liq_name != ((void *)0); liq++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(liq_table[ liq ].liq_name[ 0 ])])
       && !str_prefix( name, liq_table[ liq ].liq_name ) )
   return liq;
 }
 return -1;
}

variable_types: liq int


decompiled_code:
__int64 __fastcall tool_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)tool_table[0];
if ( !tool_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)tool_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)tool_table[0];
if ( !tool_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
++v2;
v1 = (unsigned __int8 *)tool_table[2 * v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int tool_lookup ( const char *name)
{
 int tool;
 for ( tool = 0; tool_table[ tool ].name != ((void *)0); tool++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[0])]) == ( upper_nopol[(unsigned char)(tool_table[tool].name[0])])
    && !str_prefix( name, tool_table[tool].name ) )
  {
   return tool;
  }
 }
 return -1;
}

canonical_original_code:
int tool_lookup(char *name)
{
 int tool;
 for ( tool = 0; tool_table[ tool ].name != ((void *)0); tool++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[0])]) == ( upper_nopol[(unsigned char)(tool_table[tool].name[0])])
    && !str_prefix( name, tool_table[tool].name ) )
  {
   return tool;
  }
 }
 return -1;
}

variable_types: tool int


decompiled_code:
__int64 __fastcall rawmaterial_lookup(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // er12

if ( !rawmaterial_table )
return (unsigned int)-1;
v1 = (unsigned int)((_DWORD)&rawmaterial_table + 24);
v2 = 0;
while ( (unsigned __int8)str_prefix(a1) )
{
++v2;
v1 += 24LL;
if ( !*(_QWORD *)(v1 - 24) )
return (unsigned int)-1;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 v1; // rbx
unsigned int v2; // er12

if ( !rawmaterial_table )
return (unsigned int)-1;
v1 = (unsigned int)((_DWORD)&rawmaterial_table + 24);
v2 = 0;
while ( (unsigned __int8)str_prefix(a1) )
{
++v2;
v1 += 24LL;
if ( !*(_QWORD *)(v1 - 24) )
return (unsigned int)-1;
}
return v2;
}

original_code:
int rawmaterial_lookup( const char *name )
{
 int mat;
 for ( mat = 0; rawmaterial_table[ mat ].name; ++mat )
 {
  if ( !str_prefix( name, rawmaterial_table[ mat ].name ) )
  {
   return mat;
  }
 }
 return -1;
}

canonical_original_code:
int rawmaterial_lookup(char *name)
{
 int mat;
 for ( mat = 0; rawmaterial_table[ mat ].name; ++mat )
 {
  if ( !str_prefix( name, rawmaterial_table[ mat ].name ) )
  {
   return mat;
  }
 }
 return -1;
}

variable_types: mat int


decompiled_code:
__int64 __fastcall weed_lookup(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)weed_table[0];
if ( !weed_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
v1 = (unsigned __int8 *)weed_table[8 * ++v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rsi
__int64 v2; // rbx
unsigned int v3; // er13

v1 = (unsigned __int8 *)weed_table[0];
if ( !weed_table[0] )
return (unsigned int)-1;
v2 = 0LL;
while ( 1 )
{
v3 = v2;
if ( *((_BYTE *)&upper_nopol + *a1) == *((_BYTE *)&upper_nopol + *v1) && !(unsigned __int8)str_prefix(a1) )
break;
v1 = (unsigned __int8 *)weed_table[8 * ++v2];
if ( !v1 )
return (unsigned int)-1;
}
return v3;
}

original_code:
int weed_lookup ( const char *name )
{
 int weed;
 for ( weed = 0; weed_table[ weed ].weed_name != ((void *)0); weed++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(weed_table[ weed ].weed_name[ 0 ])])
       && !str_prefix( name, weed_table[ weed ].weed_name ) )
   return weed;
 }
 return -1;
}

canonical_original_code:
int weed_lookup(char *name)
{
 int weed;
 for ( weed = 0; weed_table[ weed ].weed_name != ((void *)0); weed++ )
 {
  if ( ( upper_nopol[(unsigned char)(name[ 0 ])]) == ( upper_nopol[(unsigned char)(weed_table[ weed ].weed_name[ 0 ])])
       && !str_prefix( name, weed_table[ weed ].weed_name ) )
   return weed;
 }
 return -1;
}

variable_types: weed int


decompiled_code:
__int64 __fastcall language_lookup(__int64 a1)
{
__int64 i; // rbx
unsigned int v2; // er14
__int64 v3; // r12

if ( !lang_table[2] )
return (unsigned int)-1;
for ( i = 0LL; ; ++i )
{
v2 = i;
v3 = 4 * i;
if ( !(unsigned __int8)str_prefix(a1) )
break;
if ( !lang_table[v3 + 6] )
return (unsigned int)-1;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
__int64 i; // rbx
unsigned int v2; // er14
__int64 v3; // r12

if ( !lang_table[2] )
return (unsigned int)-1;
for ( i = 0LL; ; ++i )
{
v2 = i;
v3 = 4 * i;
if ( !(unsigned __int8)str_prefix(a1) )
break;
if ( !lang_table[v3 + 6] )
return (unsigned int)-1;
}
return v2;
}

original_code:
int language_lookup( char *arg )
{
 int langs;
 for ( langs = 0; lang_table[ langs ].bit != 0; langs++ )
 {
  if ( !str_prefix( arg, lang_table[ langs ].name ) )
  {
   return langs;
  }
 }
 return -1;
}

canonical_original_code:
int language_lookup(char *arg)
{
 int langs;
 for ( langs = 0; lang_table[ langs ].bit != 0; langs++ )
 {
  if ( !str_prefix( arg, lang_table[ langs ].name ) )
  {
   return langs;
  }
 }
 return -1;
}

variable_types:
arg
char *

variable_types: langs int