original_code:
int make_shortcut_filesection(char *buffer, int bufsize, struct shortcut *scut)
{
 int sectionlen;
 char moremagic[] = {
  0x32, 0x00, 0x03, 0xD0, 0x42, 0x00, 0xAD, 0x2C,
  0xE6, 0x8D, 0x80, 0x00 };
 sectionlen = strlen(scut->filedata[0]) + strlen(scut->filedata[1]) + 16;
 if ( sectionlen > bufsize ) return 0;
 *(short int *)buffer = sectionlen;
 buffer += 2;
 memcpy(buffer, moremagic, 12);
 buffer += 12;
 memcpy(buffer, scut->filedata[0], strlen(scut->filedata[0])+1);
 buffer += strlen(scut->filedata[0]) + 1;
 memcpy(buffer, scut->filedata[1], strlen(scut->filedata[1])+1);
 buffer += strlen(scut->filedata[1]) + 1;
 *(short int *)buffer = 0x00;
 return sectionlen;
}

canonical_original_code:
int make_shortcut_filesection(char *buffer, int bufsize, struct shortcut *scut)
{
 int sectionlen;
 char moremagic[] = {
  0x32, 0x00, 0x03, 0xD0, 0x42, 0x00, 0xAD, 0x2C,
  0xE6, 0x8D, 0x80, 0x00 };
 sectionlen = strlen(scut->filedata[0]) + strlen(scut->filedata[1]) + 16;
 if ( sectionlen > bufsize ) return 0;
 *(short *)buffer = sectionlen;
 buffer += 2;
 memcpy(buffer, moremagic, 12);
 buffer += 12;
 memcpy(buffer, scut->filedata[0], strlen(scut->filedata[0])+1);
 buffer += strlen(scut->filedata[0]) + 1;
 memcpy(buffer, scut->filedata[1], strlen(scut->filedata[1])+1);
 buffer += strlen(scut->filedata[1]) + 1;
 *(short *)buffer = 0x00;
 return sectionlen;
}

variable_types:
moremagic
char []


repo: ZeWaren/DatabaseFS

original_code:
int make_shortcut_pathsection(char *buffer, int bufsize, struct shortcut *scut)
{
 int sectionlen;
 char magic[] = {
  0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
  0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x02, 0x00, };
 sectionlen = strlen(scut->pathdata[0]) + strlen(scut->pathdata[1]) + 50;
 if ( sectionlen > bufsize ) return 0;
 buffer += 2;
 *(short int *)buffer = sectionlen;
 buffer += 1;
 memcpy(buffer, magic, sizeof(magic));
 buffer += sizeof(magic);
 memcpy(buffer, scut->pathdata[0], strlen(scut->pathdata[0])+1);
 buffer += strlen(scut->pathdata[0])+1;
 memcpy(buffer, scut->pathdata[1], strlen(scut->pathdata[1])+1);
 buffer += strlen(scut->pathdata[1])+1;
 return sectionlen;
}

canonical_original_code:
int make_shortcut_pathsection(char *buffer, int bufsize, struct shortcut *scut)
{
 int sectionlen;
 char magic[] = {
  0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
  0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x02, 0x00, };
 sectionlen = strlen(scut->pathdata[0]) + strlen(scut->pathdata[1]) + 50;
 if ( sectionlen > bufsize ) return 0;
 buffer += 2;
 *(short *)buffer = sectionlen;
 buffer += 1;
 memcpy(buffer, magic, sizeof(magic));
 buffer += sizeof(magic);
 memcpy(buffer, scut->pathdata[0], strlen(scut->pathdata[0])+1);
 buffer += strlen(scut->pathdata[0])+1;
 memcpy(buffer, scut->pathdata[1], strlen(scut->pathdata[1])+1);
 buffer += strlen(scut->pathdata[1])+1;
 return sectionlen;
}

variable_types:
buffer
char *

variable_types: bufsize int

variable_types: struct shortcut { char garbage[200]; char *hostdata[2]; char *sharedata[3]; char *filedata[2]; char *pathdata[2]; char *unicodedata; int unicodelen; } *

variable_types: sectionlen int

variable_types:
magic
char []

return_type: int


original_code:
int easy_shortcut(const char *host, const char *share, const char *path, struct shortcut *template, char *buffer, int bufsize)
{
 int i, size;
 char *myhost = (char *)MALLOC(strlen(host) + 3);
 char *sharedata = (char *)MALLOC(strlen(host) + strlen(share) + 4);
 sprintf(myhost, "\\\\%s", host);
 sprintf(sharedata, "\\\\%s\\%s", host, share);
 template->hostdata[0] = myhost;
 template->hostdata[1] = share;
 template->sharedata[0] = sharedata;
 template->sharedata[1] = "Microsoft Network";
 template->sharedata[2] = "some bogus share";
 template->filedata[0] = path;
 template->filedata[1] = "ABCDEF~1.MP3";
 template->pathdata[0] = "";
 template->pathdata[1] = path;
 template->unicodelen = strlen(sharedata);
 template->unicodedata = (char *)MALLOC(template->unicodelen * 2 + 16);
 memset(template->unicodedata, 0x00, template->unicodelen * 2);
 for (i = 0; i < strlen(sharedata) + 1; i++)
  template->unicodedata[i * 2] = sharedata[i];
 size = make_shortcut(buffer, bufsize, template);
 FREE(template->unicodedata);
 FREE(myhost);
 FREE(sharedata);
 return size;
}

canonical_original_code:
int easy_shortcut(char *host, char *share, char *path, struct shortcut *template, char *buffer, int bufsize)
{
 int i; int size;
 char *myhost = (char *)MALLOC(strlen(host) + 3);
 char *sharedata = (char *)MALLOC(strlen(host) + strlen(share) + 4);
 sprintf(myhost, "\\\\%s", host);
 sprintf(sharedata, "\\\\%s\\%s", host, share);
 template->hostdata[0] = myhost;
 template->hostdata[1] = share;
 template->sharedata[0] = sharedata;
 template->sharedata[1] = "Microsoft Network";
 template->sharedata[2] = "some bogus share";
 template->filedata[0] = path;
 template->filedata[1] = "ABCDEF~1.MP3";
 template->pathdata[0] = "";
 template->pathdata[1] = path;
 template->unicodelen = strlen(sharedata);
 template->unicodedata = (char *)MALLOC(template->unicodelen * 2 + 16);
 memset(template->unicodedata, 0x00, template->unicodelen * 2);
 for (i = 0; i < strlen(sharedata) + 1; i++)
  template->unicodedata[i * 2] = sharedata[i];
 size = make_shortcut(buffer, bufsize, template);
 FREE(template->unicodedata);
 FREE(myhost);
 FREE(sharedata);
 return size;
}

variable_types:
host
char *

variable_types:
share
char *

variable_types:
path
char *

variable_types: i int

variable_types: size int

variable_types:
myhost
char *

variable_types:
sharedata
char *

user_defined_types: struct shortcut { char garbage[200]; char *hostdata[2]; char *sharedata[3]; char *filedata[2]; char *pathdata[2]; char *unicodedata; int unicodelen; }


decompiled_code:
const char *__fastcall get_string_option(char *s2)
{
const char *v2; // rdi
__int64 v3; // rbx

v2 = parse_table;
if ( parse_table )
{
v3 = 0LL;
while ( strcmp(v2, s2) )
{
++v3;
v2 = (&parse_table)[4 * v3];
if ( !v2 )
return v2;
}
v2 = (const char *)qword_258[4 * (int)v3];
if ( !v2 )
v2 = (&off_250)[4 * (int)v3];
}
return v2;
}

canonical_decompiled_code:
const char *__fastcall func1(char *s2)
{
const char *v2; // rdi
__int64 v3; // rbx

v2 = parse_table;
if ( parse_table )
{
v3 = 0LL;
while ( strcmp(v2, s2) )
{
++v3;
v2 = (&parse_table)[4 * v3];
if ( !v2 )
return v2;
}
v2 = (const char *)qword_258[4 * (int)v3];
if ( !v2 )
v2 = (&off_250)[4 * (int)v3];
}
return v2;
}

original_code:
char *get_string_option(const char *option)
{
 int i;
 for (i=0; parse_table[i].option; i++) {
  if ( strcmp(parse_table[i].option, option) == 0 )
   return ( parse_table[i].value == ((void *)0) )
    ? parse_table[i].defaultval
    : parse_table[i].value;
 }
 return ((void *)0);
}

canonical_original_code:
char *get_string_option(char *option)
{
 int i;
 for (i=0; parse_table[i].option; i++) {
  if ( strcmp(parse_table[i].option, option) == 0 )
   return ( parse_table[i].value == ((void *)0) )
    ? parse_table[i].defaultval
    : parse_table[i].value;
 }
 return ((void *)0);
}

variable_types:
option
char *

return_type: char *


decompiled_code:
__int64 cleanup_config()
{
__int64 *v0; // rbx
__int64 result; // rax

if ( parse_table )
{
v0 = qword_258;
do
{
if ( *(_BYTE *)*v0 )
result = FREE();
v0 += 4;
}
while ( *(v0 - 3) );
}
return result;
}

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

if ( parse_table )
{
v0 = qword_258;
do
{
if ( *(_BYTE *)*v0 )
result = FREE();
v0 += 4;
}
while ( *(v0 - 3) );
}
return result;
}

original_code:
void cleanup_config()
{
 int i;
 for (i = 0; parse_table[i].option; i++)
  if ( *(char *)parse_table[i].value != ((void *)0) )
   FREE(parse_table[i].value);
}

return_type: void


skipleadingpath

repo: Zeno-/bach

decompiled_code:
char *__fastcall skipleadingpath(char *s)
{
char *v2; // rbx
char v3; // al
const unsigned __int16 *v4; // rcx

while ( 1 )
{
v2 = strpbrk(s, "\\/");
if ( !v2 )
break;
v4 = *_ctype_b_loc();
while ( 1 )
{
v3 = v2[1];
if ( (v4[v3] & 0x2000) == 0 )
break;
++v2;
}
if ( !v3 )
break;
s = v2 + 1;
}
return s;
}

canonical_decompiled_code:
char *__fastcall func1(char *s)
{
char *v2; // rbx
char v3; // al
const unsigned __int16 *v4; // rcx

while ( 1 )
{
v2 = strpbrk(s, "\\/");
if ( !v2 )
break;
v4 = *_ctype_b_loc();
while ( 1 )
{
v3 = v2[1];
if ( (v4[v3] & 0x2000) == 0 )
break;
++v2;
}
if ( !v3 )
break;
s = v2 + 1;
}
return s;
}

original_code:
static const char *
skipleadingpath(const char *s)
{
    const char *p;
    while ((p = strpbrk(s, "\\/"))) {
        while (((*__ctype_b_loc ())[(int) ((*(p + 1)))] & (unsigned short int) _ISspace))
            p++;
        if (*(p + 1) == '\0')
            break;
        s = p + 1;
    }
    return s;
}

canonical_original_code:
static char *skipleadingpath(char *s)
{
    char *p;
    while ((p = strpbrk(s, "\\/"))) {
        while (((*__ctype_b_loc ())[(int) ((*(p + 1)))] & (unsigned short) _ISspace))
            p++;
        if (*(p + 1) == '\0')
            break;
        s = p + 1;
    }
    return s;
}

variable_types:
s
char *

variable_types:
p
char *


progname

decompiled_code:
char *__fastcall progname(int a1, char **a2)
{
char *result; // rax

result = "bach";
if ( a1 && **a2 )
{
result = skipleadingpath(*a2);
if ( !*result )
result = "bach";
}
return result;
}

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

result = "bach";
if ( a1 && **a2 )
{
result = func1(*a2);
if ( !*result )
result = "bach";
}
return result;
}

original_code:
static const char *
progname(int argc, char **argv)
{
    const char *s;
    if (argc == 0 || *argv[0] == '\0')
        return "bach";
    s = skipleadingpath(argv[0]);
    return *s == '\0' ? "bach" : s;
}

canonical_original_code:
static char *progname(int argc, char **argv)
{
    char *s;
    if (argc == 0 || *argv[0] == '\0')
        return "bach";
    s = skipleadingpath(argv[0]);
    return *s == '\0' ? "bach" : s;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall run_lua(__int64 a1)
{
*(_QWORD *)(a1 + 8) = "/home/crobbins/code/bach/lua/examples/test.lua";
return zvm_lua_runscript("/home/crobbins/code/bach/lua/examples/test.lua");
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
*(_QWORD *)(a1 + 8) = "/home/crobbins/code/bach/lua/examples/test.lua";
return zvm_lua_runscript("/home/crobbins/code/bach/lua/examples/test.lua");
}

original_code:
static int
run_lua(struct setup *setup)
{
    setup->luafilename = "/home/crobbins/code/bach/lua/examples/test.lua";
    return zvm_lua_runscript(setup->luafilename);
}

variable_types: struct setup { int runmode; char *luafilename; } *


decompiled_code:
__int64 run_tests()
{
return vputest_genterrain();
}

canonical_decompiled_code:
__int64 func5()
{
return vputest_genterrain();
}

original_code:
static void
run_tests(void)
{
        vputest_genterrain();
}

canonical_original_code:
static void run_tests()
{
        vputest_genterrain();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // edx
char *v5; // rax
_DWORD v7[10]; // [rsp+0h] [rbp-28h] BYREF

testcpuinstructions();
v3 = parseargs(argc, (__int64)argv, v7);
if ( v3 == 2 )
return run_lua((__int64)v7);
if ( v3 > 2 )
{
v4 = 1;
if ( v3 == 3 )
v4 = run_normal(v7, argv, 1LL);
}
else
{
v4 = 1;
if ( (unsigned int)v3 <= 1 )
{
v5 = progname(argc, (char **)argv);
printusage(v5, stderr);
v4 = 1;
}
}
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // edx
char *v5; // rax
_DWORD v7[10]; // [rsp+0h] [rbp-28h] BYREF

func7();
v3 = func0(argc, (__int64)argv, v7);
if ( v3 == 2 )
return func4((__int64)v7);
if ( v3 > 2 )
{
v4 = 1;
if ( v3 == 3 )
v4 = func6(v7, argv, 1LL);
}
else
{
v4 = 1;
if ( (unsigned int)v3 <= 1 )
{
v5 = func2(argc, (char **)argv);
func3(v5, stderr);
v4 = 1;
}
}
return v4;
}

original_code:
int main(int argc, char **argv)
{
    int r = 1;
    struct setup setup;
    testcpuinstructions();
    switch (parseargs(argc, argv, &setup)) {
    case RUNMODE_SHOWUSAGE:
    case RUNMODE_ERR_PARSEARGS:
        printusage(progname(argc, argv), stderr);
        break;
    case RUNMODE_LUA:
        r = run_lua(&setup);
        break;
    case RUNMODE_NORMAL:
        r = run_normal(&setup);
        break;
    }
    return r;
}

variable_types: r int

variable_types: struct setup { int runmode; char *luafilename; }


initqueue

original_code:
static enum eventsyserr
initqueue(EventSys *esys, eventflags eventflags)
{
    if ((esys->events = malloc(1024 * sizeof *esys->events)) == ((void *)0))
        return ESYSERR_MALLOC;
    esys->equeue.eventflags = eventflags;
    esys->equeue.maxsz = 1024;
    esys->equeue.back = 0;
    esys->equeue.front = 0;
    esys->equeue.fullbehaviour = EVENTQUEUE_WHENFULL_RMOLD;
    return ESYSERR_NONE;
}

canonical_original_code:
static enum eventsyserr initqueue(struct eventsys *esys, unsigned short eventflags)
{
    if ((esys->events = malloc(1024 * sizeof *esys->events)) == ((void *)0))
        return ESYSERR_MALLOC;
    esys->equeue.eventflags = eventflags;
    esys->equeue.maxsz = 1024;
    esys->equeue.back = 0;
    esys->equeue.front = 0;
    esys->equeue.fullbehaviour = EVENTQUEUE_WHENFULL_RMOLD;
    return ESYSERR_NONE;
}

variable_types: struct eventsys { struct eventqueue { unsigned short eventflags; int fullbehaviour; int maxsz; int front; } equeue; struct event { unsigned short type; union { struct kybdevent { int scancode; int ascii; unsigned char modkeys; } kybd; struct mouseevent { int x; unsigned char buttonstate; } mouse; unsigned char quit; } data; } *events; } *

variable_types:
eventflags
unsigned short

return_type: enum eventsyserr { ESYSERR_NONE=0, ESYSERR_MALLOC=1 }

user_defined_types: struct eventsys { struct eventqueue equeue; struct event *events; }

user_defined_types: struct event { unsigned short type; union { struct kybdevent kybd; struct mouseevent mouse; unsigned char quit; } data; }


cleanup

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

v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
free(v2);
free(ptr);
}

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

v2 = (void *)*((_QWORD *)ptr + 3);
if ( v2 )
free(v2);
free(ptr);
}

original_code:
inline static void
cleanup(EventSys *esys)
{
    if (esys->events) {
        free(esys->events);
    }
    free(esys);
}

canonical_original_code:
inline static void cleanup(struct eventsys *esys)
{
    if (esys->events) {
        free(esys->events);
    }
    free(esys);
}

user_defined_types: struct eventqueue { unsigned short eventflags; int fullbehaviour; int maxsz; int front; }

user_defined_types: struct kybdevent { int scancode; int ascii; unsigned char modkeys; }

user_defined_types: struct mouseevent { int x; unsigned char buttonstate; }


decompiled_code:
int __fastcall eq_rem(__int64 a1)
{
int result; // eax

if ( eq_isempty(a1) )
return fprintf(
stderr,
"Warning: %s:%d: %s\n",
"hal/sdl/hal_events.c",
181LL,
"Attempt to remove from empty event queue.");
result = (*(_DWORD *)(a1 + 16) + 1) / *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = (*(_DWORD *)(a1 + 16) + 1) % *(_DWORD *)(a1 + 8);
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
int result; // eax

if ( func1(a1) )
return fprintf(
stderr,
"Warning: %s:%d: %s\n",
"hal/sdl/hal_events.c",
181LL,
"Attempt to remove from empty event queue.");
result = (*(_DWORD *)(a1 + 16) + 1) / *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 16) = (*(_DWORD *)(a1 + 16) + 1) % *(_DWORD *)(a1 + 8);
return result;
}

original_code:
inline static void
eq_rem(EventSys *esys)
{
    if (eq_isempty(esys)) {
        fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 181, ("Attempt to remove from empty event queue."));
        return;
    }
    esys->equeue.back = (esys->equeue.back + 1) % esys->equeue.maxsz;
}

canonical_original_code:
inline static void eq_rem(struct eventsys *esys)
{
    if (eq_isempty(esys)) {
        fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 181, ("Attempt to remove from empty event queue."));
        return;
    }
    esys->equeue.back = (esys->equeue.back + 1) % esys->equeue.maxsz;
}


original_code:
inline static void
eq_add(EventSys *esys, const struct event *e)
{
    if (eq_isfull(esys)) {
        if (esys->equeue.fullbehaviour == EVENTQUEUE_WHENFULL_RMOLD)
            eq_rem(esys);
        else
            return;
    }
    memcpy(&esys->events[esys->equeue.front], e, sizeof *e);
    esys->equeue.front = (esys->equeue.front + 1) % esys->equeue.maxsz;
}

canonical_original_code:
inline static void eq_add(struct eventsys *esys, struct event *e)
{
    if (eq_isfull(esys)) {
        if (esys->equeue.fullbehaviour == EVENTQUEUE_WHENFULL_RMOLD)
            eq_rem(esys);
        else
            return;
    }
    memcpy(&esys->events[esys->equeue.front], e, sizeof *e);
    esys->equeue.front = (esys->equeue.front + 1) % esys->equeue.maxsz;
}

variable_types:
e
struct event *


decompiled_code:
__int64 __fastcall eq_peek(__int64 a1, __m128i *a2)
{
int v2; // edx
int v3; // eax
__int64 result; // rax

if ( eq_isempty(a1) )
{
fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 147LL, "Attempt to get/peek empty event queue.");
result = 0LL;
}
else
{
v2 = *(_DWORD *)(a1 + 12);
v3 = v2 - 1;
if ( !v2 )
v3 = *(_DWORD *)(a1 + 8) - 1;
*a2 = _mm_loadu_si128((const __m128i *)(*(_QWORD *)(a1 + 24) + 16LL * v3));
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __m128i *a2)
{
int v2; // edx
int v3; // eax
__int64 result; // rax

if ( func1(a1) )
{
fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 147LL, "Attempt to get/peek empty event queue.");
result = 0LL;
}
else
{
v2 = *(_DWORD *)(a1 + 12);
v3 = v2 - 1;
if ( !v2 )
v3 = *(_DWORD *)(a1 + 8) - 1;
*a2 = _mm_loadu_si128((const __m128i *)(*(_QWORD *)(a1 + 24) + 16LL * v3));
result = 1LL;
}
return result;
}

original_code:
inline static int
eq_peek(EventSys *esys, struct event *e)
{
    int headpos;
    if (eq_isempty(esys)) {
        fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 147, ("Attempt to get/peek empty event queue."));
        return 0;
    }
    if (esys->equeue.front == 0)
        headpos = esys->equeue.maxsz - 1;
    else
        headpos = esys->equeue.front - 1;
    memcpy(e, &esys->events[headpos], sizeof *e);
    return 1;
}

canonical_original_code:
inline static int eq_peek(struct eventsys *esys, struct event *e)
{
    int headpos;
    if (eq_isempty(esys)) {
        fprintf(stderr, "Warning: %s:%d: %s\n", "hal/sdl/hal_events.c", 147, ("Attempt to get/peek empty event queue."));
        return 0;
    }
    if (esys->equeue.front == 0)
        headpos = esys->equeue.maxsz - 1;
    else
        headpos = esys->equeue.front - 1;
    memcpy(e, &esys->events[headpos], sizeof *e);
    return 1;
}

variable_types: headpos int


decompiled_code:
void __fastcall evsys_stopeventsys(void *a1)
{
if ( a1 )
cleanup(a1);
}

canonical_decompiled_code:
void __fastcall func8(void *a1)
{
if ( a1 )
func3(a1);
}

original_code:
void evsys_stopeventsys(EventSys *esys)
{
    if (esys)
        cleanup(esys);
}

canonical_original_code:
void evsys_stopeventsys(struct eventsys *esys)
{
    if (esys)
        cleanup(esys);
}


decompiled_code:
__int64 evsys_wait()
{
return SDL_WaitEvent(0LL);
}

canonical_decompiled_code:
__int64 func9()
{
return SDL_WaitEvent(0LL);
}

original_code:
void evsys_wait(EventSys *esys)
{
    (void)esys;
    SDL_WaitEvent(((void *)0));
}

canonical_original_code:
void evsys_wait(struct eventsys *esys)
{
    (void)esys;
    SDL_WaitEvent(((void *)0));
}


decompiled_code:
_BOOL8 __fastcall evsys_hasevents(__int64 a1)
{
return !eq_isempty(a1);
}

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

original_code:
int evsys_hasevents(EventSys *esys)
{
    return !eq_isempty(esys);
}

canonical_original_code:
int evsys_hasevents(struct eventsys *esys)
{
    return !eq_isempty(esys);
}


decompiled_code:
__int64 __fastcall evsys_getevent(__int64 a1, __m128i *a2)
{
unsigned int v2; // ebx

v2 = eq_peek(a1, a2);
if ( v2 )
eq_rem(a1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __m128i *a2)
{
unsigned int v2; // ebx

v2 = func7(a1, a2);
if ( v2 )
func4(a1);
return v2;
}

original_code:
int evsys_getevent(EventSys *esys, struct event *e)
{
    int r;
    if ((r = eq_peek(esys, e)))
        eq_rem(esys);
    return r;
}

canonical_original_code:
int evsys_getevent(struct eventsys *esys, struct event *e)
{
    int r;
    if ((r = eq_peek(esys, e)))
        eq_rem(esys);
    return r;
}


decompiled_code:
__int64 __fastcall evsys_poll(_WORD *a1, __m128i *a2, int a3)
{
__int64 result; // rax

if ( evsys_hasevents((__int64)a1) )
return evsys_getevent((__int64)a1, a2);
if ( a3 != 1 )
{
if ( !a3 )
evsys_wait(a1);
LABEL_5:
result = eq_processbackend(a1);
if ( !(_DWORD)result )
return result;
return evsys_getevent((__int64)a1, a2);
}
result = SDL_PollEvent(0LL);
if ( (_DWORD)result )
goto LABEL_5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_WORD *a1, __m128i *a2, int a3)
{
__int64 result; // rax

if ( func10((__int64)a1) )
return func11((__int64)a1, a2);
if ( a3 != 1 )
{
if ( !a3 )
func9(a1);
LABEL_5:
result = func6(a1);
if ( !(_DWORD)result )
return result;
return func11((__int64)a1, a2);
}
result = SDL_PollEvent(0LL);
if ( (_DWORD)result )
goto LABEL_5;
return result;
}

original_code:
int evsys_poll(EventSys *esys, struct event *e,
               enum eventpollbehaviour pollbehaviour)
{
    if (evsys_hasevents(esys))
        return evsys_getevent(esys, e);
    if (pollbehaviour == EQ_POLL_NONBLOCKING && !SDL_PollEvent(((void *)0)))
        return 0;
    else if (pollbehaviour == EQ_POLL_BLOCKING)
        evsys_wait(esys);
    if (eq_processbackend(esys))
        return evsys_getevent(esys, e);
    return 0;
}

canonical_original_code:
int evsys_poll(struct eventsys *esys, struct event *e, enum eventpollbehaviour pollbehaviour)
{
    if (evsys_hasevents(esys))
        return evsys_getevent(esys, e);
    if (pollbehaviour == EQ_POLL_NONBLOCKING && !SDL_PollEvent(((void *)0)))
        return 0;
    else if (pollbehaviour == EQ_POLL_BLOCKING)
        evsys_wait(esys);
    if (eq_processbackend(esys))
        return evsys_getevent(esys, e);
    return 0;
}

variable_types: enum eventpollbehaviour { EQ_POLL_BLOCKING=0, EQ_POLL_NONBLOCKING=1 }


decompiled_code:
__int64 __fastcall evsys_waitforquit(_WORD *a1)
{
__m128i v2; // [rsp+0h] [rbp-18h] BYREF

do
{
while ( !(unsigned int)evsys_poll(a1, &v2, 0) )
;
}
while ( (v2.m128i_i8[0] & 1) == 0 );
return eq_add((__int64)a1, &v2);
}

original_code:
void evsys_waitforquit(EventSys *esys)
{
    struct event e;
    while (1) {
        if (evsys_poll(esys, &e, EQ_POLL_BLOCKING))
            if (e.type & EVENT_QUIT)
                break;
    }
    eq_add(esys, &e);
}

canonical_original_code:
void evsys_waitforquit(struct eventsys *esys)
{
    struct event e;
    while (1) {
        if (evsys_poll(esys, &e, EQ_POLL_BLOCKING))
            if (e.type & EVENT_QUIT)
                break;
    }
    eq_add(esys, &e);
}

variable_types: struct event { unsigned short type; union { struct kybdevent { int scancode; int ascii; unsigned char modkeys; } kybd; struct mouseevent { int x; unsigned char buttonstate; } mouse; unsigned char quit; } data; }


decompiled_code:
__int64 __fastcall evsys_peekevent(__int64 a1, __m128i *a2)
{
return eq_peek(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __m128i *a2)
{
return func7(a1, a2);
}

original_code:
int evsys_peekevent(EventSys *esys, struct event *e)
{
    return eq_peek(esys, e);
}

canonical_original_code:
int evsys_peekevent(struct eventsys *esys, struct event *e)
{
    return eq_peek(esys, e);
}


interpolate

decompiled_code:
double __fastcall interpolate(double a1, double a2, double a3)
{
return (1.0 - a3) * a1 + a3 * a2;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3)
{
return (1.0 - a3) * a1 + a3 * a2;
}

original_code:
inline static double
interpolate(double x0, double x1, double alpha)
{
    return x0 * (1.0 - alpha) + alpha * x1;
}

variable_types: alpha double

return_type: double


genrandarr

decompiled_code:
double *__fastcall genrandarr(int a1, int a2)
{
int v2; // ebp
double *v3; // rax
double *v4; // r12
double *v5; // rbx
double *v6; // rbp

v2 = a2 * a1;
v3 = (double *)malloc(8LL * a2 * a1);
if ( !v3 )
{
perror("genrandr()");
exit(1);
}
v4 = v3;
if ( v2 > 0 )
{
v5 = v3;
v6 = &v3[v2];
do
*v5++ = (double)rand() / 2147483647.0;
while ( v5 != v6 );
}
return v4;
}

canonical_decompiled_code:
double *__fastcall func2(int a1, int a2)
{
int v2; // ebp
double *v3; // rax
double *v4; // r12
double *v5; // rbx
double *v6; // rbp

v2 = a2 * a1;
v3 = (double *)malloc(8LL * a2 * a1);
if ( !v3 )
{
perror("genrandr()");
exit(1);
}
v4 = v3;
if ( v2 > 0 )
{
v5 = v3;
v6 = &v3[v2];
do
*v5++ = (double)rand() / 2147483647.0;
while ( v5 != v6 );
}
return v4;
}

original_code:
static double *
genrandarr(int w, int h)
{
    double *ra;
    int i, n;
    n = w * h;
    if ( (ra = malloc(n * sizeof *ra)) == ((void *)0)) {
        perror("genrandr()");
        exit(1);
    }
    for (i = 0; i < n; i++)
        ra[i] = (double)rand() / 2147483647;
    return ra;
}

canonical_original_code:
static double *genrandarr(int w, int h)
{
    double *ra;
    int i; int n;
    n = w * h;
    if ( (ra = malloc(n * sizeof *ra)) == ((void *)0)) {
        perror("genrandr()");
        exit(1);
    }
    for (i = 0; i < n; i++)
        ra[i] = (double)rand() / 2147483647;
    return ra;
}

variable_types: w int

variable_types: h int

variable_types:
ra
double *

variable_types: i int

variable_types: n int

return_type: double *


decompiled_code:
__int64 hal_init()
{
__int64 result; // rax
int v1; // edx

result = 0LL;
if ( !isinitialised )
{
v1 = SDL_Init(32LL);
result = 1LL;
if ( !v1 )
{
isinitialised = 1;
SDL_WM_SetCaption("BACH - BAsic ArCHitecture Emulator", 0LL);
atexit((void (*)(void))&SDL_Quit);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // edx

result = 0LL;
if ( !isinitialised )
{
v1 = SDL_Init(32LL);
result = 1LL;
if ( !v1 )
{
isinitialised = 1;
SDL_WM_SetCaption("BACH - BAsic ArCHitecture Emulator", 0LL);
atexit((void (*)(void))&SDL_Quit);
result = 0LL;
}
}
return result;
}

original_code:
enum hal_error
hal_init(void)
{
    if (isinitialised)
        return HAL_NOERROR;
    if (SDL_Init(0x00000020) != 0)
        return HAL_INIT_FAIL;
    isinitialised = 1;
    SDL_WM_SetCaption("BACH - BAsic ArCHitecture Emulator", ((void *)0));
    atexit(SDL_Quit);
    return HAL_NOERROR;
}

canonical_original_code:
enum hal_error hal_init()
{
    if (isinitialised)
        return HAL_NOERROR;
    if (SDL_Init(0x00000020) != 0)
        return HAL_INIT_FAIL;
    isinitialised = 1;
    SDL_WM_SetCaption("BACH - BAsic ArCHitecture Emulator", ((void *)0));
    atexit(SDL_Quit);
    return HAL_NOERROR;
}

return_type: enum hal_error { HAL_NOERROR=0, HAL_INIT_FAIL=1, HAL_INIT_VIDEO_FAIL=2, HAL_INIT_KYBDMOUSE_FAIL=3 }


decompiled_code:
__int64 hal_isinitalised()
{
return (unsigned int)isinitialised;
}

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

original_code:
int hal_isinitalised(void)
{
    return isinitialised;
}

canonical_original_code:
int hal_isinitalised()
{
    return isinitialised;
}


decompiled_code:
void *__fastcall vidfont_getnamedfont(const char *a1)
{
void *v1; // rcx

v1 = &vidfont8x8;
if ( strcmp("8x8", a1) )
{
v1 = &vidfont8x14;
if ( strcmp("8x14", a1) )
{
v1 = &vidfont8x16;
if ( strcmp("8x16", a1) )
v1 = 0LL;
}
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(const char *a1)
{
void *v1; // rcx

v1 = &vidfont8x8;
if ( strcmp("8x8", a1) )
{
v1 = &vidfont8x14;
if ( strcmp("8x14", a1) )
{
v1 = &vidfont8x16;
if ( strcmp("8x16", a1) )
v1 = 0LL;
}
}
return v1;
}

original_code:
const struct vidfont8 *vidfont_getnamedfont(const char *name)
{
    if (strcmp("8x8", name) == 0)
        return &vidfont8x8;
    else if (strcmp("8x14", name) == 0)
        return &vidfont8x14;
    else if (strcmp("8x16", name) == 0)
        return &vidfont8x16;
    return ((void *)0);
}

canonical_original_code:
struct vidfont8 *vidfont_getnamedfont(char *name)
{
    if (strcmp("8x8", name) == 0)
        return &vidfont8x8;
    else if (strcmp("8x14", name) == 0)
        return &vidfont8x14;
    else if (strcmp("8x16", name) == 0)
        return &vidfont8x16;
    return ((void *)0);
}

variable_types:
name
char *

return_type: struct vidfont8 { unsigned int height; unsigned char *pixeldata; } *


decompiled_code:
__int64 __fastcall vidfont_getglyph(__int64 a1, int a2)
{
return *(_QWORD *)(a1 + 8) + (unsigned int)(*(_DWORD *)a1 * a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
return *(_QWORD *)(a1 + 8) + (unsigned int)(*(_DWORD *)a1 * a2);
}

original_code:
const unsigned char *vidfont_getglyph(const struct vidfont8 *font, int ch)
{
    return font->pixeldata + ch * font->height;
}

canonical_original_code:
unsigned char *vidfont_getglyph(struct vidfont8 *font, int ch)
{
    return font->pixeldata + ch * font->height;
}

variable_types: struct vidfont8 { unsigned int height; unsigned char *pixeldata; } *

variable_types: ch int

return_type: unsigned char *


destroyNFA

repo: ZeyuMi/MiLex

decompiled_code:
__int64 destroyNFA()
{
stateNum = 0;
return destroyGraph();
}

canonical_decompiled_code:
__int64 func0()
{
stateNum = 0;
return destroyGraph();
}

original_code:
void destroyNFA(){
 stateNum = 0;
 destroyGraph();
}


pop

decompiled_code:
__int64 pop()
{
int v0; // eax

v0 = topp;
if ( !topp )
return -1LL;
--topp;
return *((_QWORD *)stack + v0 - 1);
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax

v0 = topp;
if ( !topp )
return -1LL;
--topp;
return *((_QWORD *)stack + v0 - 1);
}

original_code:
struct NFASection pop(){
 if(topp == 0){
  struct NFASection t = {-1,-1};
  return t;
 }
 else
  return stack[--topp];
}

variable_types: struct NFASection { int start; int end; }


constructFromRE

decompiled_code:
__int64 __fastcall constructFromRE(char *a1, __int64 a2, const char *a3)
{
char v3; // bp
int v4; // ebx
int v5; // eax
__int64 v6; // r15
__int64 v7; // r14
unsigned int v8; // er12
__int64 v9; // rbp
__int64 v10; // rbp
__int64 v11; // rbp
__int64 v12; // r14
unsigned int v13; // er12
__int64 v14; // rbp
unsigned __int64 v15; // r12
__int64 v16; // rbp
unsigned int v17; // er14
__int64 v18; // r12
__int64 v19; // rbx
__int64 v21; // [rsp+8h] [rbp-40h]

v21 = a2;
v3 = *a1;
if ( *a1 )
{
v4 = 0;
v5 = -1;
do
{
if ( v3 == 124 )
{
v6 = pop();
v7 = pop();
v8 = stateNum + 1;
stateNum += 2;
v9 = (unsigned int)stateNum;
addVertex(v8, 0LL);
addVertex((unsigned int)v9, 0LL);
addEdge(v8, (unsigned int)v6, 0xFFFFFFFFLL);
addEdge(v8, (unsigned int)v7, 0xFFFFFFFFLL);
addEdge(v6 >> 32, (unsigned int)v9, 0xFFFFFFFFLL);
LODWORD(a2) = v9;
addEdge(v7 >> 32, (unsigned int)v9, 0xFFFFFFFFLL);
push((v9 << 32) | v8);
v5 = v4;
}
else if ( v3 == 63 )
{
v10 = pop();
a2 = v10 >> 32;
addEdge((unsigned int)v10, v10 >> 32, 0xFFFFFFFFLL);
push(v10);
v5 = v4;
}
else if ( v3 == 43 )
{
v11 = pop();
LODWORD(a2) = v11;
addEdge(v11 >> 32, (unsigned int)v11, 0xFFFFFFFFLL);
push(v11);
v5 = v4;
}
else if ( v3 == 42 )
{
v12 = pop();
addEdge(HIDWORD(v12), (unsigned int)v12, 0xFFFFFFFFLL);
v13 = stateNum + 1;
stateNum += 2;
v14 = (unsigned int)stateNum;
addVertex(v13, 0LL);
addVertex((unsigned int)v14, 0LL);
addEdge(v13, (unsigned int)v12, 0xFFFFFFFFLL);
addEdge(HIDWORD(v12), (unsigned int)v14, 0xFFFFFFFFLL);
LODWORD(a2) = v14;
addEdge(v13, (unsigned int)v14, 0xFFFFFFFFLL);
push((v14 << 32) | v13);
v5 = v4;
}
else if ( v3 == -2 )
{
v15 = pop();
v16 = pop();
LODWORD(a2) = v15;
addEdge(v16 >> 32, (unsigned int)v15, 0xFFFFFFFFLL);
push((HIDWORD(v15) << 32) | (unsigned int)v16);
v5 = v4;
}
else
{
if ( v3 == 92 )
{
v4 = v5 + 2;
v3 = a1[v5 + 2];
}
if ( !v3 )
error((int)"invalid Regular expression.", a2, a3);
v17 = stateNum + 1;
stateNum += 2;
v18 = (unsigned int)stateNum;
addVertex(v17, 0LL);
addVertex((unsigned int)v18, 0LL);
LODWORD(a2) = v18;
addEdge(v17, (unsigned int)v18, (unsigned int)v3);
push((v18 << 32) | v17);
v5 = v4;
}
v4 = v5 + 1;
a3 = (const char *)(v5 + 1);
v3 = a3[(_QWORD)a1];
}
while ( v3 );
}
v19 = pop();
addActionToVertex(v19 >> 32, v21);
return (unsigned int)v19;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, __int64 a2, const char *a3)
{
char v3; // bp
int v4; // ebx
int v5; // eax
__int64 v6; // r15
__int64 v7; // r14
unsigned int v8; // er12
__int64 v9; // rbp
__int64 v10; // rbp
__int64 v11; // rbp
__int64 v12; // r14
unsigned int v13; // er12
__int64 v14; // rbp
unsigned __int64 v15; // r12
__int64 v16; // rbp
unsigned int v17; // er14
__int64 v18; // r12
__int64 v19; // rbx
__int64 v21; // [rsp+8h] [rbp-40h]

v21 = a2;
v3 = *a1;
if ( *a1 )
{
v4 = 0;
v5 = -1;
do
{
if ( v3 == 124 )
{
v6 = func2();
v7 = func2();
v8 = stateNum + 1;
stateNum += 2;
v9 = (unsigned int)stateNum;
addVertex(v8, 0LL);
addVertex((unsigned int)v9, 0LL);
addEdge(v8, (unsigned int)v6, 0xFFFFFFFFLL);
addEdge(v8, (unsigned int)v7, 0xFFFFFFFFLL);
addEdge(v6 >> 32, (unsigned int)v9, 0xFFFFFFFFLL);
LODWORD(a2) = v9;
addEdge(v7 >> 32, (unsigned int)v9, 0xFFFFFFFFLL);
func1((v9 << 32) | v8);
v5 = v4;
}
else if ( v3 == 63 )
{
v10 = func2();
a2 = v10 >> 32;
addEdge((unsigned int)v10, v10 >> 32, 0xFFFFFFFFLL);
func1(v10);
v5 = v4;
}
else if ( v3 == 43 )
{
v11 = func2();
LODWORD(a2) = v11;
addEdge(v11 >> 32, (unsigned int)v11, 0xFFFFFFFFLL);
func1(v11);
v5 = v4;
}
else if ( v3 == 42 )
{
v12 = func2();
addEdge(HIDWORD(v12), (unsigned int)v12, 0xFFFFFFFFLL);
v13 = stateNum + 1;
stateNum += 2;
v14 = (unsigned int)stateNum;
addVertex(v13, 0LL);
addVertex((unsigned int)v14, 0LL);
addEdge(v13, (unsigned int)v12, 0xFFFFFFFFLL);
addEdge(HIDWORD(v12), (unsigned int)v14, 0xFFFFFFFFLL);
LODWORD(a2) = v14;
addEdge(v13, (unsigned int)v14, 0xFFFFFFFFLL);
func1((v14 << 32) | v13);
v5 = v4;
}
else if ( v3 == -2 )
{
v15 = func2();
v16 = func2();
LODWORD(a2) = v15;
addEdge(v16 >> 32, (unsigned int)v15, 0xFFFFFFFFLL);
func1((HIDWORD(v15) << 32) | (unsigned int)v16);
v5 = v4;
}
else
{
if ( v3 == 92 )
{
v4 = v5 + 2;
v3 = a1[v5 + 2];
}
if ( !v3 )
error((int)"invalid Regular expression.", a2, a3);
v17 = stateNum + 1;
stateNum += 2;
v18 = (unsigned int)stateNum;
addVertex(v17, 0LL);
addVertex((unsigned int)v18, 0LL);
LODWORD(a2) = v18;
addEdge(v17, (unsigned int)v18, (unsigned int)v3);
func1((v18 << 32) | v17);
v5 = v4;
}
v4 = v5 + 1;
a3 = (const char *)(v5 + 1);
v3 = a3[(_QWORD)a1];
}
while ( v3 );
}
v19 = func2();
addActionToVertex(v19 >> 32, v21);
return (unsigned int)v19;
}

original_code:
int constructFromRE(char *postRE, char *action){
 int pos = -1;
 char c;
 int start , end;
 start = end = -1;
 while(1){
  pos++;
  c = *(postRE+pos);
  if('\0' == c){
   struct NFASection temp = pop();
   addActionToVertex(temp.end, action);
   return temp.start;
  }else if('|' == c){
   struct NFASection temp1 = pop();
   struct NFASection temp2 = pop();
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, temp1.start, -1);
   addEdge(start, temp2.start, -1);
   addEdge(temp1.end, end, -1);
   addEdge(temp2.end, end, -1);
   struct NFASection temp = {start, end};
   push(temp);
  }else if('?' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.start, temp1.end, -1);
   push(temp1);
  }else if('+' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp1.start, -1);
   push(temp1);
  }else if('*' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp1.start, -1);
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, temp1.start, -1);
   addEdge(temp1.end, end, -1);
   addEdge(start, end, -1);
   struct NFASection temp = {start, end};
   push(temp);
  }else if(-2 == c){
   struct NFASection temp2 = pop();
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp2.start, -1);
   struct NFASection temp = {temp1.start, temp2.end};
   push(temp);
  }else{
   if('\\' == c){
    pos++;
    c = *(postRE+pos);
   }
   if('\0' == c)
    error("invalid Regular expression.");
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, end, c);
   struct NFASection temp = {start, end};
   push(temp);
  }
 }
}

canonical_original_code:
int constructFromRE(char *postRE, char *action){
 int pos = -1;
 char c;
 int start; int end;
 start = end = -1;
 while(1){
  pos++;
  c = *(postRE+pos);
  if('\0' == c){
   struct NFASection temp = pop();
   addActionToVertex(temp.end, action);
   return temp.start;
  }else if('|' == c){
   struct NFASection temp1 = pop();
   struct NFASection temp2 = pop();
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, temp1.start, -1);
   addEdge(start, temp2.start, -1);
   addEdge(temp1.end, end, -1);
   addEdge(temp2.end, end, -1);
   struct NFASection temp = {start, end};
   push(temp);
  }else if('?' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.start, temp1.end, -1);
   push(temp1);
  }else if('+' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp1.start, -1);
   push(temp1);
  }else if('*' == c){
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp1.start, -1);
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, temp1.start, -1);
   addEdge(temp1.end, end, -1);
   addEdge(start, end, -1);
   struct NFASection temp = {start, end};
   push(temp);
  }else if(-2 == c){
   struct NFASection temp2 = pop();
   struct NFASection temp1 = pop();
   addEdge(temp1.end, temp2.start, -1);
   struct NFASection temp = {temp1.start, temp2.end};
   push(temp);
  }else{
   if('\\' == c){
    pos++;
    c = *(postRE+pos);
   }
   if('\0' == c)
    error("invalid Regular expression.");
   start = ++stateNum;
   end = ++stateNum;
   addVertex(start, ((void *)0));
   addVertex(end, ((void *)0));
   addEdge(start, end, c);
   struct NFASection temp = {start, end};
   push(temp);
  }
 }
}

variable_types:
postRE
char *

variable_types:
action
char *

variable_types: pos int

variable_types: c char

variable_types: start int

variable_types: end int

user_defined_types: struct NFASection { int start; int end; }


constructNFA

decompiled_code:
void constructNFA()
{
_QWORD *v0; // rbx
unsigned int v1; // er12
char *v2; // rbp
const char *v3; // rdx
__int64 v4; // rsi

v0 = (_QWORD *)regexps;
v1 = stateNum + 1;
stateNum = v1;
addVertex(v1, 0LL);
for ( ; v0; v0 = (_QWORD *)v0[2] )
{
v2 = (char *)infixToPostfix(*v0);
v4 = (unsigned int)constructFromRE(v2, v0[1], v3);
addEdge(v1, v4, 0xFFFFFFFFLL);
free(v2);
}
}

canonical_decompiled_code:
void func4()
{
_QWORD *v0; // rbx
unsigned int v1; // er12
char *v2; // rbp
const char *v3; // rdx
__int64 v4; // rsi

v0 = (_QWORD *)regexps;
v1 = stateNum + 1;
stateNum = v1;
addVertex(v1, 0LL);
for ( ; v0; v0 = (_QWORD *)v0[2] )
{
v2 = (char *)infixToPostfix(*v0);
v4 = (unsigned int)func3(v2, v0[1], v3);
addEdge(v1, v4, 0xFFFFFFFFLL);
free(v2);
}
}

original_code:
void constructNFA(){
 struct REentry *retemp = regexps;
 int startPoint = ++stateNum;
 addVertex(startPoint, ((void *)0));
 while(((void *)0) != retemp){
  char *postfix = infixToPostfix(retemp->regexp);
  int childgraph = constructFromRE(postfix, retemp->action);
  addEdge(startPoint, childgraph, -1);
  free(postfix);
  retemp = retemp->next;
 }
}

variable_types: struct REentry { char *regexp; char *action; struct REentry *next; } *

variable_types: startPoint int

variable_types:
postfix
char *

variable_types: childgraph int


addDFANewState

decompiled_code:
const char *__fastcall addDFANewState(int a1, __int64 a2)
{
const char *result; // rax
void *v3; // r12
_QWORD *v4; // rax
_QWORD *v5; // rbp
_QWORD *v6; // rbx

result = (const char *)getEntry(a1);
if ( !result )
{
v3 = table;
if ( table )
{
v4 = table;
do
{
v5 = v4;
v4 = (_QWORD *)v4[3];
}
while ( v4 );
}
else
{
v5 = table;
}
v6 = malloc(0x20uLL);
*(_DWORD *)v6 = a1;
v6[1] = malloc(0x200uLL);
v6[2] = a2;
result = 0LL;
do
{
*(_DWORD *)&result[v6[1]] = 0;
result += 4;
}
while ( result != "ate%d by %d," );
v6[3] = 0LL;
if ( v3 )
v5[3] = v6;
else
table = v6;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1, __int64 a2)
{
const char *result; // rax
void *v3; // r12
_QWORD *v4; // rax
_QWORD *v5; // rbp
_QWORD *v6; // rbx

result = (const char *)getEntry(a1);
if ( !result )
{
v3 = table;
if ( table )
{
v4 = table;
do
{
v5 = v4;
v4 = (_QWORD *)v4[3];
}
while ( v4 );
}
else
{
v5 = table;
}
v6 = malloc(0x20uLL);
*(_DWORD *)v6 = a1;
v6[1] = malloc(0x200uLL);
v6[2] = a2;
result = 0LL;
do
{
*(_DWORD *)&result[v6[1]] = 0;
result += 4;
}
while ( result != "ate%d by %d," );
v6[3] = 0LL;
if ( v3 )
v5[3] = v6;
else
table = v6;
}
return result;
}

original_code:
void addDFANewState(int state, char *action){
 struct dfaTTEntry *temp = getEntry(state);
 if(((void *)0) != temp)
  return;
 temp = table;
 struct dfaTTEntry *pre = ((void *)0);
 while(((void *)0) != temp){
  pre = temp;
  temp = temp->next;
 }
 temp = malloc(sizeof(struct dfaTTEntry));
 temp->state = state;
 temp->trans = malloc(sizeof(int) * 128);
 temp->action = action;
 int i = 0;
 while(i < 128){
  (temp->trans)[i] = 0;
  i++;
 }
 temp->next = ((void *)0);
 if(((void *)0) == table)
  table = temp;
 else
  pre->next = temp;
}

variable_types: state int

variable_types: struct dfaTTEntry { int state; int *trans; char *action; struct dfaTTEntry *next; } *


printDFATransTable

decompiled_code:
int printDFATransTable()
{
unsigned int *v0; // rbp
__int64 i; // rbx
__int64 v3; // rsi
const char *v4; // rsi

v0 = (unsigned int *)table;
if ( table )
{
do
{
printf("state%d: ", *v0);
for ( i = 0LL; i != 128; ++i )
{
v3 = *(unsigned int *)(*((_QWORD *)v0 + 1) + 4 * i);
if ( (_DWORD)v3 )
printf("connects to state%d by %d,", v3, (unsigned int)i);
}
v4 = (const char *)*((_QWORD *)v0 + 2);
if ( v4 )
printf("action is %s", v4);
putchar(10);
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
}
while ( v0 );
}
return putchar(10);
}

canonical_decompiled_code:
int func1()
{
unsigned int *v0; // rbp
__int64 i; // rbx
__int64 v3; // rsi
const char *v4; // rsi

v0 = (unsigned int *)table;
if ( table )
{
do
{
printf("state%d: ", *v0);
for ( i = 0LL; i != 128; ++i )
{
v3 = *(unsigned int *)(*((_QWORD *)v0 + 1) + 4 * i);
if ( (_DWORD)v3 )
printf("connects to state%d by %d,", v3, (unsigned int)i);
}
v4 = (const char *)*((_QWORD *)v0 + 2);
if ( v4 )
printf("action is %s", v4);
putchar(10);
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
}
while ( v0 );
}
return putchar(10);
}

original_code:
void printDFATransTable(){
 struct dfaTTEntry *temp = table;
 while(((void *)0) != temp){
  printf("state%d: ", temp->state);
  int i = 0;
  while(i < 128){
   if(0 != (temp->trans)[i])
    printf("connects to state%d by %d,", (temp->trans)[i], i);
   i++;
  }
  if(((void *)0) != temp->action)
   printf("action is %s", temp->action);
  printf("\n");
  temp = temp->next;
 }
 printf("\n");
}

variable_types: i int

user_defined_types: struct dfaTTEntry { int state; int *trans; char *action; struct dfaTTEntry *next; }


destroyDFATransTable

decompiled_code:
void destroyDFATransTable()
{
void **v0; // rbx
void **v1; // rbp

v0 = (void **)table;
if ( table )
{
do
{
v1 = v0;
v0 = (void **)v0[3];
free(v1[1]);
free(v1);
}
while ( v0 );
}
table = 0LL;
}

canonical_decompiled_code:
void func2()
{
void **v0; // rbx
void **v1; // rbp

v0 = (void **)table;
if ( table )
{
do
{
v1 = v0;
v0 = (void **)v0[3];
free(v1[1]);
free(v1);
}
while ( v0 );
}
table = 0LL;
}

original_code:
void destroyDFATransTable(){
 struct dfaTTEntry *temp = table;
 struct dfaTTEntry *next = ((void *)0);
 while(((void *)0) != temp){
  next = temp->next;
  temp->state = 0;
  free(temp->trans);
  temp->trans = ((void *)0);
  temp->next = ((void *)0);
  free(temp);
  temp = next;
 }
 table = ((void *)0);
}


getTable

decompiled_code:
void *getTable()
{
return table;
}

canonical_decompiled_code:
void *func3()
{
return table;
}

original_code:
struct dfaTTEntry *getTable(){
 return table;
}

return_type: struct dfaTTEntry { int state; int *trans; char *action; struct dfaTTEntry *next; } *


getTableEntryNum

decompiled_code:
__int64 getTableEntryNum()
{
_QWORD *v0; // rax
unsigned int v1; // edx

v0 = table;
if ( !table )
return 0;
v1 = 0;
do
{
++v1;
v0 = (_QWORD *)v0[3];
}
while ( v0 );
return v1;
}

canonical_decompiled_code:
__int64 func4()
{
_QWORD *v0; // rax
unsigned int v1; // edx

v0 = table;
if ( !table )
return 0;
v1 = 0;
do
{
++v1;
v0 = (_QWORD *)v0[3];
}
while ( v0 );
return v1;
}

original_code:
int getTableEntryNum(){
 struct dfaTTEntry *temp = table;
 int num = 0;
 while(((void *)0) != temp){
  num++;
  temp = temp->next;
 }
 return num;
}

variable_types: num int


printGraph

decompiled_code:
int printGraph()
{
unsigned int *v0; // rbp
unsigned int **i; // rbx
const char *v3; // rsi

v0 = (unsigned int *)graph;
if ( graph )
{
do
{
printf("vertex%d connects to ", *v0);
for ( i = (unsigned int **)*((_QWORD *)v0 + 2); i; i = (unsigned int **)i[2] )
printf("vertex%d labeled %c, ", **i, (unsigned int)*((char *)i + 8));
v3 = (const char *)*((_QWORD *)v0 + 1);
if ( v3 )
printf("action is %s.", v3);
putchar(10);
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
}
while ( v0 );
}
return putchar(10);
}

canonical_decompiled_code:
int func0()
{
unsigned int *v0; // rbp
unsigned int **i; // rbx
const char *v3; // rsi

v0 = (unsigned int *)graph;
if ( graph )
{
do
{
printf("vertex%d connects to ", *v0);
for ( i = (unsigned int **)*((_QWORD *)v0 + 2); i; i = (unsigned int **)i[2] )
printf("vertex%d labeled %c, ", **i, (unsigned int)*((char *)i + 8));
v3 = (const char *)*((_QWORD *)v0 + 1);
if ( v3 )
printf("action is %s.", v3);
putchar(10);
v0 = (unsigned int *)*((_QWORD *)v0 + 3);
}
while ( v0 );
}
return putchar(10);
}

original_code:
void printGraph(){
 struct vertex *vertexTemp = graph;
 while(((void *)0) != vertexTemp){
  printf("vertex%d connects to ", vertexTemp->state);
  struct edge *edgeTemp = vertexTemp->edges;
  while(((void *)0) != edgeTemp){
   printf("vertex%d labeled %c, ", edgeTemp->connectsTo->state, edgeTemp->symbol);
   edgeTemp = edgeTemp->next;
  }
  if(((void *)0) != vertexTemp->action)
   printf("action is %s.", vertexTemp->action);
  printf("\n");
  vertexTemp = vertexTemp->next;
 }
 printf("\n");
}

variable_types: struct vertex { int state; char *action; struct edge { struct vertex *connectsTo; char symbol; struct edge *next; } *edges; struct vertex *next; } *

variable_types: struct edge { struct vertex { int state; char *action; struct edge *edges; struct vertex *next; } *connectsTo; char symbol; struct edge *next; } *


destroyEdge

decompiled_code:
void __fastcall destroyEdge(_QWORD *a1)
{
if ( a1 )
{
if ( a1[2] )
destroyEdge();
free(a1);
}
}

canonical_decompiled_code:
void __fastcall func1(_QWORD *a1)
{
if ( a1 )
{
if ( a1[2] )
func1();
free(a1);
}
}

original_code:
void destroyEdge(struct edge *e){
 if(((void *)0) == e)
  return;
 if(((void *)0) != e->next){
  destroyEdge(e->next);
 }
 e->connectsTo = ((void *)0);
 e->next = ((void *)0);
 free(e);
}

user_defined_types: struct edge { struct vertex *connectsTo; char symbol; struct edge *next; }

user_defined_types: struct vertex { int state; char *action; struct edge *edges; struct vertex *next; }


destroyVertex

decompiled_code:
void __fastcall destroyVertex(__int64 a1)
{
if ( *(_QWORD *)(a1 + 24) )
destroyVertex();
destroyEdge(*(_QWORD **)(a1 + 16));
free((void *)a1);
}

original_code:
void destroyVertex(struct vertex *v){
 if(((void *)0) != v->next){
  destroyVertex(v->next);
 }
 destroyEdge(v->edges);
 v->next = ((void *)0);
 v->edges = ((void *)0);
 v->action = ((void *)0);
 free(v);
}


destroyGraph

decompiled_code:
void destroyGraph()
{
if ( graph )
{
destroyVertex(graph);
graph = 0LL;
}
}

canonical_decompiled_code:
void func3()
{
if ( graph )
{
func2(graph);
graph = 0LL;
}
}

original_code:
void destroyGraph(){
 if(((void *)0) != graph){
  destroyVertex(graph);
  graph = ((void *)0);
 }
}


isVertexExist

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

result = graph;
if ( !graph )
return 0LL;
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 24);
if ( !result )
return result;
}
return 1LL;
}

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

result = graph;
if ( !graph )
return 0LL;
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 24);
if ( !result )
return result;
}
return 1LL;
}

original_code:
int isVertexExist(int state){
 struct vertex *temp = graph;
 while(((void *)0) != temp){
  if(temp->state == state)
   return 1;
  temp = temp->next;
 }
 return 0;
}


addVertex

decompiled_code:
__int64 __fastcall addVertex(int a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
_QWORD *v4; // rdx
__int64 v5; // rax
__int64 v6; // rcx

v2 = isVertexExist(a1);
result = 0LL;
if ( !v2 )
{
v4 = malloc(0x20uLL);
*(_DWORD *)v4 = a1;
v4[2] = 0LL;
v4[1] = a2;
v4[3] = 0LL;
v5 = graph;
if ( graph )
{
do
{
v6 = v5;
v5 = *(_QWORD *)(v5 + 24);
}
while ( v5 );
*(_QWORD *)(v6 + 24) = v4;
result = 1LL;
}
else
{
graph = (__int64)v4;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, __int64 a2)
{
int v2; // edx
__int64 result; // rax
_QWORD *v4; // rdx
__int64 v5; // rax
__int64 v6; // rcx

v2 = func4(a1);
result = 0LL;
if ( !v2 )
{
v4 = malloc(0x20uLL);
*(_DWORD *)v4 = a1;
v4[2] = 0LL;
v4[1] = a2;
v4[3] = 0LL;
v5 = graph;
if ( graph )
{
do
{
v6 = v5;
v5 = *(_QWORD *)(v5 + 24);
}
while ( v5 );
*(_QWORD *)(v6 + 24) = v4;
result = 1LL;
}
else
{
graph = (__int64)v4;
result = 1LL;
}
}
return result;
}

original_code:
int addVertex(int state, char *action){
 if(isVertexExist(state))
   return 0;
 struct vertex *v = malloc(sizeof(struct vertex));
 v->state = state;
 v->edges = ((void *)0);
 v->action = action;
 v->next = ((void *)0);
 if(((void *)0) == graph){
  graph = v;
 }else{
  struct vertex *temp = graph;
  while(((void *)0) != temp->next){
   temp = temp->next;
  }
  temp->next = v;
 }
 return 1;
}


getVertex

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

for ( result = graph; result; result = *(_QWORD *)(result + 24) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

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

for ( result = graph; result; result = *(_QWORD *)(result + 24) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

original_code:
struct vertex *getVertex(int state){
 struct vertex *temp = graph;
 while(((void *)0) != temp){
  if(temp->state == state)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

return_type: struct vertex { int state; char *action; struct edge { struct vertex *connectsTo; char symbol; struct edge *next; } *edges; struct vertex *next; } *


reachByEdgeSymbol

decompiled_code:
void *__fastcall reachByEdgeSymbol(int a1, char a2)
{
void *v2; // rbx
unsigned int v3; // er12
unsigned int *i; // rbx
int v5; // eax

v2 = 0LL;
if ( (unsigned int)isVertexExist(a1) )
{
v3 = initializeIntBuffer();
for ( i = *(unsigned int **)(getVertex(a1) + 16); i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
if ( *((_BYTE *)i + 8) == a2 )
addIntElement(v3, **(unsigned int **)i);
}
addIntElement(v3, 0xFFFFFFFFLL);
v5 = intSize(v3);
v2 = malloc(4LL * v5);
fillIntArrayWithBuffer(v3, v2);
destroyIntBuffer(v3);
}
return v2;
}

canonical_decompiled_code:
void *__fastcall func7(int a1, char a2)
{
void *v2; // rbx
unsigned int v3; // er12
unsigned int *i; // rbx
int v5; // eax

v2 = 0LL;
if ( (unsigned int)func4(a1) )
{
v3 = initializeIntBuffer();
for ( i = *(unsigned int **)(func6(a1) + 16); i; i = (unsigned int *)*((_QWORD *)i + 2) )
{
if ( *((_BYTE *)i + 8) == a2 )
addIntElement(v3, **(unsigned int **)i);
}
addIntElement(v3, 0xFFFFFFFFLL);
v5 = intSize(v3);
v2 = malloc(4LL * v5);
fillIntArrayWithBuffer(v3, v2);
destroyIntBuffer(v3);
}
return v2;
}

original_code:
int *reachByEdgeSymbol(int state, char symbol){
 if(!isVertexExist(state))
  return ((void *)0);
 int bufferid = initializeIntBuffer();
 struct vertex *vertexTemp = getVertex(state);
 struct edge *edgeTemp = vertexTemp->edges;
 while(((void *)0) != edgeTemp){
  if(symbol == edgeTemp->symbol)
   addIntElement(bufferid, edgeTemp->connectsTo->state);
  edgeTemp = edgeTemp->next;
 }
 addIntElement(bufferid, -1);
 int *result = malloc(intSize(bufferid) * sizeof(int));
 fillIntArrayWithBuffer(bufferid, result);
 destroyIntBuffer(bufferid);
 return result;
}

variable_types: symbol char

variable_types: bufferid int

variable_types:
result
int *

return_type: int *


addActionToVertex

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

result = isVertexExist(a1);
if ( (_DWORD)result )
{
*(_QWORD *)(getVertex(a1) + 8) = a2;
result = 1LL;
}
return result;
}

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

result = func4(a1);
if ( (_DWORD)result )
{
*(_QWORD *)(func6(a1) + 8) = a2;
result = 1LL;
}
return result;
}

original_code:
int addActionToVertex(int state, char *action){
 if(!isVertexExist(state))
  return 0;
 struct vertex *temp = getVertex(state);
 temp->action = action;
 return 1;
}

variable_types:
action
char *


getAction

decompiled_code:
__int64 __fastcall getAction(int *a1)
{
int *v1; // rbx
int v2; // edi
__int64 result; // rax
__int64 v4; // rax

v1 = a1;
v2 = *a1;
if ( v2 == -1 )
return 0LL;
while ( 1 )
{
v4 = getVertex(v2);
if ( v4 )
{
result = *(_QWORD *)(v4 + 8);
if ( result )
break;
}
v2 = *++v1;
if ( *v1 == -1 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(int *a1)
{
int *v1; // rbx
int v2; // edi
__int64 result; // rax
__int64 v4; // rax

v1 = a1;
v2 = *a1;
if ( v2 == -1 )
return 0LL;
while ( 1 )
{
v4 = func6(v2);
if ( v4 )
{
result = *(_QWORD *)(v4 + 8);
if ( result )
break;
}
v2 = *++v1;
if ( *v1 == -1 )
return 0LL;
}
return result;
}

original_code:
char *getAction(int *states){
 int temp = 0;
 while(-1 != (temp = *states)){
  struct vertex *vertexTemp = getVertex(temp);
  if(((void *)0) != vertexTemp && ((void *)0) != vertexTemp->action)
   return vertexTemp->action;
  states++;
 }
 return ((void *)0);
}

variable_types:
states
int *

variable_types: temp int


isConnectTo

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

result = isVertexExist(a1);
if ( (_DWORD)result )
{
result = isVertexExist(a2);
if ( (_DWORD)result )
{
result = *(_QWORD *)(getVertex(a1) + 16);
if ( result )
{
while ( **(_DWORD **)result != a2 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
result = 1LL;
}
else
{
result = 0LL;
}
}
}
return result;
}

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

result = func4(a1);
if ( (_DWORD)result )
{
result = func4(a2);
if ( (_DWORD)result )
{
result = *(_QWORD *)(func6(a1) + 16);
if ( result )
{
while ( **(_DWORD **)result != a2 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
return result;
}
result = 1LL;
}
else
{
result = 0LL;
}
}
}
return result;
}

original_code:
int isConnectTo(int state1, int state2){
 if(!isVertexExist(state1) || !isVertexExist(state2))
  return 0;
 struct vertex *v1 = getVertex(state1);
 struct edge *edgetemp = v1->edges;
 while(((void *)0) != edgetemp){
  if(edgetemp->connectsTo->state == state2)
   return 1;
  edgetemp = edgetemp->next;
 }
 return 0;
}


addEdge

decompiled_code:
__int64 __fastcall addEdge(int a1, int a2, char a3)
{
__int64 result; // rax
int v5; // edx
__int64 v6; // rbx
__int64 v7; // rbp
_BYTE *v8; // rcx
__int64 v9; // rax
__int64 v10; // rdx

result = isVertexExist(a1);
if ( (_DWORD)result )
{
result = isVertexExist(a2);
if ( (_DWORD)result )
{
v5 = isConnectTo(a1, a2);
result = 0LL;
if ( !v5 )
{
v6 = getVertex(a1);
v7 = getVertex(a2);
v8 = malloc(0x18uLL);
*(_QWORD *)v8 = v7;
v8[8] = a3;
*((_QWORD *)v8 + 2) = 0LL;
v9 = *(_QWORD *)(v6 + 16);
if ( v9 )
{
do
{
v10 = v9;
v9 = *(_QWORD *)(v9 + 16);
}
while ( v9 );
*(_QWORD *)(v10 + 16) = v8;
result = 1LL;
}
else
{
*(_QWORD *)(v6 + 16) = v8;
result = 1LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2, char a3)
{
__int64 result; // rax
int v5; // edx
__int64 v6; // rbx
__int64 v7; // rbp
_BYTE *v8; // rcx
__int64 v9; // rax
__int64 v10; // rdx

result = func4(a1);
if ( (_DWORD)result )
{
result = func4(a2);
if ( (_DWORD)result )
{
v5 = func10(a1, a2);
result = 0LL;
if ( !v5 )
{
v6 = func6(a1);
v7 = func6(a2);
v8 = malloc(0x18uLL);
*(_QWORD *)v8 = v7;
v8[8] = a3;
*((_QWORD *)v8 + 2) = 0LL;
v9 = *(_QWORD *)(v6 + 16);
if ( v9 )
{
do
{
v10 = v9;
v9 = *(_QWORD *)(v9 + 16);
}
while ( v9 );
*(_QWORD *)(v10 + 16) = v8;
result = 1LL;
}
else
{
*(_QWORD *)(v6 + 16) = v8;
result = 1LL;
}
}
}
}
return result;
}

original_code:
int addEdge(int state1, int state2, char symbol){
 if(!isVertexExist(state1) || !isVertexExist(state2))
  return 0;
 if(isConnectTo(state1,state2))
  return 0;
 struct vertex *v1 = getVertex(state1);
 struct vertex *v2 = getVertex(state2);
 struct edge *newEdge = malloc(sizeof(struct edge));
 newEdge->connectsTo = v2;
 newEdge->symbol = symbol;
 newEdge->next = ((void *)0);
 struct edge *edgetemp = v1->edges;
 if(((void *)0) == edgetemp){
  v1->edges = newEdge;
 }else{
  while(((void *)0) != edgetemp->next){
   edgetemp = edgetemp->next;
  }
  edgetemp->next = newEdge;
 }
 return 1;
}


getGraph

decompiled_code:
__int64 getGraph()
{
return graph;
}

canonical_decompiled_code:
__int64 func12()
{
return graph;
}

original_code:
struct vertex *getGraph(){
 return graph;
}


getCharBuffer

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

result = charBufferList;
if ( charBufferList )
{
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 32);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 8);
}
return result;
}

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

result = charBufferList;
if ( charBufferList )
{
while ( *(_DWORD *)result != a1 )
{
result = *(_QWORD *)(result + 32);
if ( !result )
return result;
}
result = *(_QWORD *)(result + 8);
}
return result;
}

original_code:
char *getCharBuffer(int id){
 charEntry *temp = charBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp->buffer;
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
char *getCharBuffer(int id){
 struct charBufferEntry *temp = charBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp->buffer;
  temp = temp->next;
 }
 return ((void *)0);
}

variable_types: id int

variable_types: struct charBufferEntry { int id; char *buffer; char *bufp; int buffersize; struct charBufferEntry *next; } *


findCharEntry

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

for ( result = charBufferList; result; result = *(_QWORD *)(result + 32) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

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

for ( result = charBufferList; result; result = *(_QWORD *)(result + 32) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

original_code:
charEntry *findCharEntry(int id){
 charEntry *temp = charBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct charBufferEntry *findCharEntry(int id){
 struct charBufferEntry *temp = charBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

return_type: struct charBufferEntry { int id; char *buffer; char *bufp; int buffersize; struct charBufferEntry *next; } *


findPreCharEntry

decompiled_code:
__int64 __fastcall findPreCharEntry(int a1)
{
__int64 i; // rdx
_DWORD *v2; // rax

for ( i = charBufferList; i; i = *(_QWORD *)(i + 32) )
{
v2 = *(_DWORD **)(i + 32);
if ( !v2 )
return 0LL;
if ( *v2 == a1 )
return i;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 i; // rdx
_DWORD *v2; // rax

for ( i = charBufferList; i; i = *(_QWORD *)(i + 32) )
{
v2 = *(_DWORD **)(i + 32);
if ( !v2 )
return 0LL;
if ( *v2 == a1 )
return i;
}
return i;
}

original_code:
charEntry *findPreCharEntry(int id){
 charEntry *temp = charBufferList;
 while(((void *)0) != temp && ((void *)0) != temp->next){
  if(temp->next->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct charBufferEntry *findPreCharEntry(int id){
 struct charBufferEntry *temp = charBufferList;
 while(((void *)0) != temp && ((void *)0) != temp->next){
  if(temp->next->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

user_defined_types: struct charBufferEntry { int id; char *buffer; char *bufp; int buffersize; struct charBufferEntry *next; }


findIntEntry

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

for ( result = intBufferList; result; result = *(_QWORD *)(result + 32) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

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

for ( result = intBufferList; result; result = *(_QWORD *)(result + 32) )
{
if ( *(_DWORD *)result == a1 )
break;
}
return result;
}

original_code:
intEntry *findIntEntry(int id){
 intEntry *temp = intBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct intBufferEntry *findIntEntry(int id){
 struct intBufferEntry *temp = intBufferList;
 while(((void *)0) != temp){
  if(temp->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

variable_types: struct intBufferEntry { int id; int *buffer; int *bufp; int buffersize; struct intBufferEntry *next; } *


findPreIntEntry

decompiled_code:
__int64 __fastcall findPreIntEntry(int a1)
{
__int64 i; // rdx
_DWORD *v2; // rax

for ( i = intBufferList; i; i = *(_QWORD *)(i + 32) )
{
v2 = *(_DWORD **)(i + 32);
if ( !v2 )
return 0LL;
if ( *v2 == a1 )
return i;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
__int64 i; // rdx
_DWORD *v2; // rax

for ( i = intBufferList; i; i = *(_QWORD *)(i + 32) )
{
v2 = *(_DWORD **)(i + 32);
if ( !v2 )
return 0LL;
if ( *v2 == a1 )
return i;
}
return i;
}

original_code:
intEntry *findPreIntEntry(int id){
 intEntry *temp = intBufferList;
 while(((void *)0) != temp && ((void *)0) != temp->next){
  if(temp->next->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct intBufferEntry *findPreIntEntry(int id){
 struct intBufferEntry *temp = intBufferList;
 while(((void *)0) != temp && ((void *)0) != temp->next){
  if(temp->next->id == id)
   return temp;
  temp = temp->next;
 }
 return ((void *)0);
}

return_type: struct intBufferEntry { int id; int *buffer; int *bufp; int buffersize; struct intBufferEntry *next; } *


removeCharLast

decompiled_code:
__int64 __fastcall removeCharLast(int a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = findCharEntry(a1);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
if ( v2 != *(_QWORD *)(result + 8) )
*(_QWORD *)(result + 16) = v2 - 1;
}
return result;
}

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

result = func1(a1);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
if ( v2 != *(_QWORD *)(result + 8) )
*(_QWORD *)(result + 16) = v2 - 1;
}
return result;
}

original_code:
void removeCharLast(int id){
 charEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp == temp->buffer)
  return;
 else
  (temp->bufp)--;
}

canonical_original_code:
void removeCharLast(int id){
 struct charBufferEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp == temp->buffer)
  return;
 else
  (temp->bufp)--;
}


removeIntLast

decompiled_code:
__int64 __fastcall removeIntLast(int a1)
{
__int64 result; // rax
__int64 v2; // rdx

result = findIntEntry(a1);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
if ( v2 != *(_QWORD *)(result + 8) )
*(_QWORD *)(result + 16) = v2 - 4;
}
return result;
}

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

result = func3(a1);
if ( result )
{
v2 = *(_QWORD *)(result + 16);
if ( v2 != *(_QWORD *)(result + 8) )
*(_QWORD *)(result + 16) = v2 - 4;
}
return result;
}

original_code:
void removeIntLast(int id){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp == temp->buffer)
  return;
 else
  (temp->bufp)--;
}

canonical_original_code:
void removeIntLast(int id){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp == temp->buffer)
  return;
 else
  (temp->bufp)--;
}

user_defined_types: struct intBufferEntry { int id; int *buffer; int *bufp; int buffersize; struct intBufferEntry *next; }


destroyCharBuffer

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

v1 = charBufferList;
if ( *(_DWORD *)charBufferList == a1 )
{
charBufferList = *(_QWORD *)(charBufferList + 32);
LABEL_3:
*(_DWORD *)v1 = 0;
*(_DWORD *)(v1 + 24) = 0;
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)(v1 + 32) = 0LL;
return;
}
v2 = findPreCharEntry(a1);
if ( v2 )
{
v1 = *(_QWORD *)(v2 + 32);
*(_QWORD *)(v2 + 32) = *(_QWORD *)(v1 + 32);
goto LABEL_3;
}
}

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

v1 = charBufferList;
if ( *(_DWORD *)charBufferList == a1 )
{
charBufferList = *(_QWORD *)(charBufferList + 32);
LABEL_3:
*(_DWORD *)v1 = 0;
*(_DWORD *)(v1 + 24) = 0;
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)(v1 + 32) = 0LL;
return;
}
v2 = func2(a1);
if ( v2 )
{
v1 = *(_QWORD *)(v2 + 32);
*(_QWORD *)(v2 + 32) = *(_QWORD *)(v1 + 32);
goto LABEL_3;
}
}

original_code:
void destroyCharBuffer(int id){
 charEntry *temp = ((void *)0);
 if(charBufferList->id == id){
  temp = charBufferList;
  charBufferList = charBufferList->next;
 }else{
  charEntry *pre = findPreCharEntry(id);
  if(((void *)0) == pre)
   return;
  temp = pre->next;
  pre->next = pre->next->next;
 }
 temp->id = 0;
 temp->buffersize = 0;
 free(temp->buffer);
 temp->bufp = temp->buffer = 0;
 temp->next = ((void *)0);
}

canonical_original_code:
void destroyCharBuffer(int id){
 struct charBufferEntry *temp = ((void *)0);
 if(charBufferList->id == id){
  temp = charBufferList;
  charBufferList = charBufferList->next;
 }else{
  struct charBufferEntry *pre = findPreCharEntry(id);
  if(((void *)0) == pre)
   return;
  temp = pre->next;
  pre->next = pre->next->next;
 }
 temp->id = 0;
 temp->buffersize = 0;
 free(temp->buffer);
 temp->bufp = temp->buffer = 0;
 temp->next = ((void *)0);
}


destroyIntBuffer

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

v1 = intBufferList;
if ( *(_DWORD *)intBufferList == a1 )
{
intBufferList = *(_QWORD *)(intBufferList + 32);
LABEL_3:
*(_DWORD *)v1 = 0;
*(_DWORD *)(v1 + 24) = 0;
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)(v1 + 32) = 0LL;
return;
}
v2 = findPreIntEntry(a1);
if ( v2 )
{
v1 = *(_QWORD *)(v2 + 32);
*(_QWORD *)(v2 + 32) = *(_QWORD *)(v1 + 32);
goto LABEL_3;
}
}

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

v1 = intBufferList;
if ( *(_DWORD *)intBufferList == a1 )
{
intBufferList = *(_QWORD *)(intBufferList + 32);
LABEL_3:
*(_DWORD *)v1 = 0;
*(_DWORD *)(v1 + 24) = 0;
free(*(void **)(v1 + 8));
*(_QWORD *)(v1 + 8) = 0LL;
*(_QWORD *)(v1 + 16) = 0LL;
*(_QWORD *)(v1 + 32) = 0LL;
return;
}
v2 = func4(a1);
if ( v2 )
{
v1 = *(_QWORD *)(v2 + 32);
*(_QWORD *)(v2 + 32) = *(_QWORD *)(v1 + 32);
goto LABEL_3;
}
}

original_code:
void destroyIntBuffer(int id){
 intEntry *temp = ((void *)0);
 if(intBufferList->id == id){
  temp = intBufferList;
  intBufferList = intBufferList->next;
 }else{
  intEntry *pre = findPreIntEntry(id);
  if(((void *)0) == pre)
   return;
  temp = pre->next;
  pre->next = pre->next->next;
 }
 temp->id = 0;
 temp->buffersize = 0;
 free(temp->buffer);
 temp->bufp = temp->buffer = 0;
 temp->next = ((void *)0);
}

canonical_original_code:
void destroyIntBuffer(int id){
 struct intBufferEntry *temp = ((void *)0);
 if(intBufferList->id == id){
  temp = intBufferList;
  intBufferList = intBufferList->next;
 }else{
  struct intBufferEntry *pre = findPreIntEntry(id);
  if(((void *)0) == pre)
   return;
  temp = pre->next;
  pre->next = pre->next->next;
 }
 temp->id = 0;
 temp->buffersize = 0;
 free(temp->buffer);
 temp->bufp = temp->buffer = 0;
 temp->next = ((void *)0);
}


rewindCharPointer

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

result = findCharEntry(a1);
if ( result )
*(_QWORD *)(result + 16) = *(_QWORD *)(result + 8);
return result;
}

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

result = func1(a1);
if ( result )
*(_QWORD *)(result + 16) = *(_QWORD *)(result + 8);
return result;
}

original_code:
void rewindCharPointer(int id){
 charEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 temp->bufp = temp->buffer;
}

canonical_original_code:
void rewindCharPointer(int id){
 struct charBufferEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 temp->bufp = temp->buffer;
}


rewindIntPointer

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

result = findIntEntry(a1);
if ( result )
*(_QWORD *)(result + 16) = *(_QWORD *)(result + 8);
return result;
}

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

result = func3(a1);
if ( result )
*(_QWORD *)(result + 16) = *(_QWORD *)(result + 8);
return result;
}

original_code:
void rewindIntPointer(int id){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 temp->bufp = temp->buffer;
}

canonical_original_code:
void rewindIntPointer(int id){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 temp->bufp = temp->buffer;
}


charSize

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

v1 = findCharEntry(a1);
if ( v1 )
result = (unsigned int)*(_QWORD *)(v1 + 16) - *(_DWORD *)(v1 + 8);
else
result = 0LL;
return result;
}

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

v1 = func1(a1);
if ( v1 )
result = (unsigned int)*(_QWORD *)(v1 + 16) - *(_DWORD *)(v1 + 8);
else
result = 0LL;
return result;
}

original_code:
int charSize(int id){
 charEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return 0;
 return temp->bufp - temp->buffer;
}

canonical_original_code:
int charSize(int id){
 struct charBufferEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return 0;
 return temp->bufp - temp->buffer;
}


intSize

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

v1 = findIntEntry(a1);
if ( v1 )
result = (__int64)(*(_QWORD *)(v1 + 16) - *(_QWORD *)(v1 + 8)) >> 2;
else
result = 0LL;
return result;
}

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

v1 = func3(a1);
if ( v1 )
result = (__int64)(*(_QWORD *)(v1 + 16) - *(_QWORD *)(v1 + 8)) >> 2;
else
result = 0LL;
return result;
}

original_code:
int intSize(int id){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return 0;
 return temp->bufp - temp->buffer;
}

canonical_original_code:
int intSize(int id){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return 0;
 return temp->bufp - temp->buffer;
}


fillIntArrayWithBuffer

decompiled_code:
__int64 __fastcall fillIntArrayWithBuffer(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rcx

result = findIntEntry(a1);
if ( result )
{
v3 = result;
result = intSize(a1);
if ( (int)result > 0 )
{
v4 = 4LL * (unsigned int)result;
result = 0LL;
do
{
*(_DWORD *)(a2 + result) = *(_DWORD *)(*(_QWORD *)(v3 + 8) + result);
result += 4LL;
}
while ( result != v4 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbx
__int64 v4; // rcx

result = func3(a1);
if ( result )
{
v3 = result;
result = func12(a1);
if ( (int)result > 0 )
{
v4 = 4LL * (unsigned int)result;
result = 0LL;
do
{
*(_DWORD *)(a2 + result) = *(_DWORD *)(*(_QWORD *)(v3 + 8) + result);
result += 4LL;
}
while ( result != v4 );
}
}
return result;
}

original_code:
void fillIntArrayWithBuffer(int id, int *array){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 int size = intSize(id);
 int i = 0;
 while(i < size){
  *(array+i) = *((temp->buffer)+i);
  i++;
 }
}

canonical_original_code:
void fillIntArrayWithBuffer(int id, int *array){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 int size = intSize(id);
 int i = 0;
 while(i < size){
  *(array+i) = *((temp->buffer)+i);
  i++;
 }
}

variable_types:
array
int *

variable_types: size int


isInIntBuffer

decompiled_code:
__int64 __fastcall isInIntBuffer(int a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rdx
_DWORD *v4; // rax
_DWORD *v5; // rdx

v2 = findIntEntry(a1);
if ( !v2 )
return 0LL;
v3 = v2;
v4 = *(_DWORD **)(v2 + 8);
v5 = *(_DWORD **)(v3 + 16);
if ( v4 == v5 )
return 0LL;
while ( *v4 != a2 )
{
if ( ++v4 == v5 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rdx
_DWORD *v4; // rax
_DWORD *v5; // rdx

v2 = func3(a1);
if ( !v2 )
return 0LL;
v3 = v2;
v4 = *(_DWORD **)(v2 + 8);
v5 = *(_DWORD **)(v3 + 16);
if ( v4 == v5 )
return 0LL;
while ( *v4 != a2 )
{
if ( ++v4 == v5 )
return 0LL;
}
return 1LL;
}

original_code:
int isInIntBuffer(int id, int i){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return 0;
 int *tempBufp = temp->buffer;
 while(tempBufp != temp->bufp){
  if(*tempBufp == i)
   return 1;
  tempBufp++;
 }
 return 0;
}

canonical_original_code:
int isInIntBuffer(int id, int i){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return 0;
 int *tempBufp = temp->buffer;
 while(tempBufp != temp->bufp){
  if(*tempBufp == i)
   return 1;
  tempBufp++;
 }
 return 0;
}

variable_types:
tempBufp
int *


memError

decompiled_code:
size_t memError()
{
return fwrite("memory error!\n", 1uLL, 0xEuLL, stderr);
}

canonical_decompiled_code:
size_t func15()
{
return fwrite("memory error!\n", 1uLL, 0xEuLL, stderr);
}

original_code:
void memError(){
 fprintf(stderr, "memory error!\n");
}


initializeCharBuffer

decompiled_code:
__int64 initializeCharBuffer()
{
__int64 v0; // rax
__int64 v1; // rbp
_DWORD *v2; // rbx
void *v3; // rax

v0 = charBufferList;
if ( charBufferList )
{
do
{
v1 = v0;
v0 = *(_QWORD *)(v0 + 32);
}
while ( v0 );
}
else
{
v1 = charBufferList;
}
v2 = malloc(0x28uLL);
if ( !v2 )
memError();
*v2 = ++charNum;
v2[6] = 100;
v3 = malloc(0x64uLL);
*((_QWORD *)v2 + 1) = v3;
*((_QWORD *)v2 + 2) = v3;
if ( !v3 )
memError();
*((_QWORD *)v2 + 4) = 0LL;
if ( charBufferList )
*(_QWORD *)(v1 + 32) = v2;
else
charBufferList = (__int64)v2;
return (unsigned int)charNum;
}

canonical_decompiled_code:
__int64 func16()
{
__int64 v0; // rax
__int64 v1; // rbp
_DWORD *v2; // rbx
void *v3; // rax

v0 = charBufferList;
if ( charBufferList )
{
do
{
v1 = v0;
v0 = *(_QWORD *)(v0 + 32);
}
while ( v0 );
}
else
{
v1 = charBufferList;
}
v2 = malloc(0x28uLL);
if ( !v2 )
func15();
*v2 = ++charNum;
v2[6] = 100;
v3 = malloc(0x64uLL);
*((_QWORD *)v2 + 1) = v3;
*((_QWORD *)v2 + 2) = v3;
if ( !v3 )
func15();
*((_QWORD *)v2 + 4) = 0LL;
if ( charBufferList )
*(_QWORD *)(v1 + 32) = v2;
else
charBufferList = (__int64)v2;
return (unsigned int)charNum;
}

original_code:
int initializeCharBuffer(){
 charEntry *temp = charBufferList;
 charEntry *pre = ((void *)0);
 while(((void *)0) != temp){
  pre = temp;
  temp = temp->next;
 }
 temp = malloc(sizeof(charEntry));
 if(((void *)0) == temp)
  memError();
 temp->id = ++charNum;
 temp->buffersize = 100;
 temp->bufp = temp->buffer = malloc(100);
 if(((void *)0) == temp->bufp)
  memError();
 temp->next = ((void *)0);
 if(((void *)0) == charBufferList)
  charBufferList = temp;
 else
  pre->next = temp;
 return charNum;
}

canonical_original_code:
int initializeCharBuffer(){
 struct charBufferEntry *temp = charBufferList;
 struct charBufferEntry *pre = ((void *)0);
 while(((void *)0) != temp){
  pre = temp;
  temp = temp->next;
 }
 temp = malloc(sizeof(charEntry));
 if(((void *)0) == temp)
  memError();
 temp->id = ++charNum;
 temp->buffersize = 100;
 temp->bufp = temp->buffer = malloc(100);
 if(((void *)0) == temp->bufp)
  memError();
 temp->next = ((void *)0);
 if(((void *)0) == charBufferList)
  charBufferList = temp;
 else
  pre->next = temp;
 return charNum;
}


initializeIntBuffer

decompiled_code:
__int64 initializeIntBuffer()
{
__int64 v0; // rax
__int64 v1; // rbp
_DWORD *v2; // rbx
void *v3; // rax

v0 = intBufferList;
if ( intBufferList )
{
do
{
v1 = v0;
v0 = *(_QWORD *)(v0 + 32);
}
while ( v0 );
}
else
{
v1 = intBufferList;
}
v2 = malloc(0x28uLL);
if ( !v2 )
memError();
*v2 = ++intNum;
v2[6] = 100;
v3 = malloc(0x190uLL);
*((_QWORD *)v2 + 1) = v3;
*((_QWORD *)v2 + 2) = v3;
if ( !v3 )
memError();
*((_QWORD *)v2 + 4) = 0LL;
if ( intBufferList )
*(_QWORD *)(v1 + 32) = v2;
else
intBufferList = (__int64)v2;
return (unsigned int)intNum;
}

canonical_decompiled_code:
__int64 func17()
{
__int64 v0; // rax
__int64 v1; // rbp
_DWORD *v2; // rbx
void *v3; // rax

v0 = intBufferList;
if ( intBufferList )
{
do
{
v1 = v0;
v0 = *(_QWORD *)(v0 + 32);
}
while ( v0 );
}
else
{
v1 = intBufferList;
}
v2 = malloc(0x28uLL);
if ( !v2 )
func15();
*v2 = ++intNum;
v2[6] = 100;
v3 = malloc(0x190uLL);
*((_QWORD *)v2 + 1) = v3;
*((_QWORD *)v2 + 2) = v3;
if ( !v3 )
func15();
*((_QWORD *)v2 + 4) = 0LL;
if ( intBufferList )
*(_QWORD *)(v1 + 32) = v2;
else
intBufferList = (__int64)v2;
return (unsigned int)intNum;
}

original_code:
int initializeIntBuffer(){
 intEntry *temp = intBufferList;
 intEntry *pre = ((void *)0);
 while(((void *)0) != temp){
  pre = temp;
  temp = temp->next;
 }
 temp = malloc(sizeof(intEntry));
 if(((void *)0) == temp)
  memError();
 temp->id = ++intNum;
 temp->buffersize = 100;
 temp->bufp = temp->buffer = malloc(sizeof(int) * 100);
 if(((void *)0) == temp->bufp)
  memError();
 temp->next = ((void *)0);
 if(((void *)0) == intBufferList)
  intBufferList = temp;
 else
  pre->next = temp;
 return intNum;
}

canonical_original_code:
int initializeIntBuffer(){
 struct intBufferEntry *temp = intBufferList;
 struct intBufferEntry *pre = ((void *)0);
 while(((void *)0) != temp){
  pre = temp;
  temp = temp->next;
 }
 temp = malloc(sizeof(intEntry));
 if(((void *)0) == temp)
  memError();
 temp->id = ++intNum;
 temp->buffersize = 100;
 temp->bufp = temp->buffer = malloc(sizeof(int) * 100);
 if(((void *)0) == temp->bufp)
  memError();
 temp->next = ((void *)0);
 if(((void *)0) == intBufferList)
  intBufferList = temp;
 else
  pre->next = temp;
 return intNum;
}


addCharElement

decompiled_code:
__int64 __fastcall addCharElement(int a1, char a2)
{
__int64 result; // rax
__int64 v3; // rbx
void *v4; // r12
int v5; // edi
int v6; // edi
void *v7; // rax

result = findCharEntry(a1);
if ( result )
{
v3 = result;
v4 = *(void **)(result + 8);
v5 = *(_DWORD *)(result + 24);
if ( *(_QWORD *)(result + 16) - (_QWORD)v4 >= v5 )
{
v6 = 2 * v5;
*(_DWORD *)(result + 24) = v6;
v7 = malloc(v6);
*(_QWORD *)(v3 + 8) = v7;
if ( !v7 )
memError();
memcpy(*(void **)(v3 + 8), v4, *(_DWORD *)(v3 + 24) / 2);
free(v4);
*(_QWORD *)(v3 + 16) = *(_QWORD *)(v3 + 8) + *(_DWORD *)(v3 + 24) / 2;
}
result = *(_QWORD *)(v3 + 16);
*(_QWORD *)(v3 + 16) = result + 1;
*(_BYTE *)result = a2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(int a1, char a2)
{
__int64 result; // rax
__int64 v3; // rbx
void *v4; // r12
int v5; // edi
int v6; // edi
void *v7; // rax

result = func1(a1);
if ( result )
{
v3 = result;
v4 = *(void **)(result + 8);
v5 = *(_DWORD *)(result + 24);
if ( *(_QWORD *)(result + 16) - (_QWORD)v4 >= v5 )
{
v6 = 2 * v5;
*(_DWORD *)(result + 24) = v6;
v7 = malloc(v6);
*(_QWORD *)(v3 + 8) = v7;
if ( !v7 )
func15();
memcpy(*(void **)(v3 + 8), v4, *(_DWORD *)(v3 + 24) / 2);
free(v4);
*(_QWORD *)(v3 + 16) = *(_QWORD *)(v3 + 8) + *(_DWORD *)(v3 + 24) / 2;
}
result = *(_QWORD *)(v3 + 16);
*(_QWORD *)(v3 + 16) = result + 1;
*(_BYTE *)result = a2;
}
return result;
}

original_code:
void addCharElement(int id, char c){
 charEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp - temp->buffer >= temp->buffersize){
  temp->buffersize *= 2;
  char *old = temp->buffer;
  temp->buffer = malloc(temp->buffersize);
  if(temp->buffer == ((void *)0))
   memError();
  memcpy((void *)temp->buffer, (void *)old, (temp->buffersize)/2);
  free(old);
  temp->bufp = temp->buffer + ((temp->buffersize)/2);
 }
 *((temp->bufp)++) = c;
}

canonical_original_code:
void addCharElement(int id, char c){
 struct charBufferEntry *temp = findCharEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp - temp->buffer >= temp->buffersize){
  temp->buffersize *= 2;
  char *old = temp->buffer;
  temp->buffer = malloc(temp->buffersize);
  if(temp->buffer == ((void *)0))
   memError();
  memcpy((void *)temp->buffer, (void *)old, (temp->buffersize)/2);
  free(old);
  temp->bufp = temp->buffer + ((temp->buffersize)/2);
 }
 *((temp->bufp)++) = c;
}

variable_types: c char

variable_types:
old
char *


addCharElements

decompiled_code:
__int64 __fastcall addCharElements(int a1, char *a2)
{
char *v2; // rbx
char v3; // si
__int64 result; // rax

v2 = a2;
v3 = *a2;
if ( v3 )
{
do
{
result = addCharElement(a1, v3);
v3 = *++v2;
}
while ( *v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(int a1, char *a2)
{
char *v2; // rbx
char v3; // si
__int64 result; // rax

v2 = a2;
v3 = *a2;
if ( v3 )
{
do
{
result = func18(a1, v3);
v3 = *++v2;
}
while ( *v2 );
}
return result;
}

original_code:
void addCharElements(int id, char *s){
 while('\0' != *s){
  addCharElement(id, *s);
  s++;
 }
}

variable_types:
s
char *


addIntElement

decompiled_code:
__int64 __fastcall addIntElement(int a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbx
void *v4; // r12
int v5; // edi
int v6; // edi
void *v7; // rax

result = findIntEntry(a1);
if ( result )
{
v3 = result;
v4 = *(void **)(result + 8);
v5 = *(_DWORD *)(result + 24);
if ( (__int64)(*(_QWORD *)(result + 16) - (_QWORD)v4) >> 2 >= v5 )
{
v6 = 2 * v5;
*(_DWORD *)(result + 24) = v6;
v7 = malloc(4LL * v6);
*(_QWORD *)(v3 + 8) = v7;
if ( !v7 )
memError();
memcpy(*(void **)(v3 + 8), v4, (unsigned __int64)(4LL * *(int *)(v3 + 24)) >> 1);
free(v4);
*(_QWORD *)(v3 + 16) = *(_QWORD *)(v3 + 8) + 4LL * (*(_DWORD *)(v3 + 24) / 2);
}
result = *(_QWORD *)(v3 + 16);
*(_QWORD *)(v3 + 16) = result + 4;
*(_DWORD *)result = a2;
}
return result;
}

original_code:
void addIntElement(int id, int i){
 intEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp - temp->buffer >= temp->buffersize){
  temp->buffersize *= 2;
  int *old = temp->buffer;
  temp->buffer = malloc(sizeof(int) * temp->buffersize);
  if(temp->buffer == ((void *)0))
   memError();
  memcpy((void *)temp->buffer, (void *)old, sizeof(int) * (temp->buffersize)/2);
  free(old);
  temp->bufp = temp->buffer + ((temp->buffersize)/2);
 }
 *((temp->bufp)++) = i;
}

canonical_original_code:
void addIntElement(int id, int i){
 struct intBufferEntry *temp = findIntEntry(id);
 if(((void *)0) == temp)
  return;
 if(temp->bufp - temp->buffer >= temp->buffersize){
  temp->buffersize *= 2;
  int *old = temp->buffer;
  temp->buffer = malloc(sizeof(int) * temp->buffersize);
  if(temp->buffer == ((void *)0))
   memError();
  memcpy((void *)temp->buffer, (void *)old, sizeof(int) * (temp->buffersize)/2);
  free(old);
  temp->bufp = temp->buffer + ((temp->buffersize)/2);
 }
 *((temp->bufp)++) = i;
}

variable_types: i int

variable_types:
old
int *


isOperator

decompiled_code:
__int64 __fastcall isOperator(char a1)
{
return ((unsigned __int8)(a1 - 40) <= 3u) | (unsigned __int8)(a1 == 63 || a1 == 124 || a1 == -2);
}

original_code:
int isOperator(char c){
 if('*' == c)
  return 1;
 else if(-2 == c)
  return 1;
 else if('|' == c)
  return 1;
 else if('?' == c)
  return 1;
 else if('+' == c)
  return 1;
 else if('(' == c)
  return 1;
 else if(')' == c)
  return 1;
 else
  return 0;
}


getPrecedence

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

if ( (unsigned __int8)(a1 - 42) <= 1u || a1 == 63 )
return 10LL;
if ( a1 == -2 )
return 5LL;
result = 1LL;
if ( a1 != 124 )
{
if ( a1 == 40 )
result = a2 == 0 ? 0xB : 0;
else
result = 0xFFFFFFFFLL;
}
return result;
}

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

if ( (unsigned __int8)(a1 - 42) <= 1u || a1 == 63 )
return 10LL;
if ( a1 == -2 )
return 5LL;
result = 1LL;
if ( a1 != 124 )
{
if ( a1 == 40 )
result = a2 == 0 ? 0xB : 0;
else
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int getPrecedence(char c, int instack){
 if('?' == c || '+' == c || '*' == c)
  return 10;
 else if(-2 == c)
  return 5;
 else if('|' == c)
  return 1;
 else if('(' == c){
  if(instack)
   return 0;
  else
   return 11;
 }else
  return -1;
}

variable_types: instack int


infixToPostfix

decompiled_code:
char *__fastcall infixToPostfix(char *a1)
{
unsigned int v1; // ebp
char v2; // bl
int v3; // er13
char v4; // al
char v5; // al
char v6; // al
int v7; // ebx
unsigned int v8; // er12
char v9; // al
const char *v10; // r12
size_t v11; // rax
char *v12; // rbx

v1 = initializeCharBuffer();
v2 = *a1;
if ( *a1 )
{
v3 = 0;
do
{
v8 = v2;
if ( (unsigned int)isOperator(v2) )
{
if ( (unsigned int)topStack() != -1 )
{
if ( v2 == 41 )
{
while ( (unsigned int)topStack() != 40 )
{
v4 = popStack();
addCharElement(v1, (unsigned int)v4);
}
popStack();
goto LABEL_14;
}
while ( (unsigned int)topStack() != -1 )
{
v6 = topStack();
v7 = getPrecedence(v6, 1);
if ( v7 < (int)getPrecedence(v8, 0) )
break;
v5 = popStack();
addCharElement(v1, (unsigned int)v5);
}
}
pushStack(v8);
}
else if ( v2 == 92 )
{
addCharElement(v1, 92LL);
addCharElement(v1, (unsigned int)a1[++v3]);
}
else
{
addCharElement(v1, (unsigned int)v2);
}
LABEL_14:
v2 = a1[++v3];
}
while ( v2 );
}
while ( (unsigned int)topStack() != -1 )
{
v9 = popStack();
addCharElement(v1, (unsigned int)v9);
}
addCharElement(v1, 0LL);
v10 = (const char *)getCharBuffer(v1);
v11 = strlen(v10);
v12 = (char *)malloc(v11 + 1);
strcpy(v12, v10);
destroyCharBuffer(v1);
return v12;
}

canonical_decompiled_code:
char *__fastcall func2(char *a1)
{
unsigned int v1; // ebp
char v2; // bl
int v3; // er13
char v4; // al
char v5; // al
char v6; // al
int v7; // ebx
unsigned int v8; // er12
char v9; // al
const char *v10; // r12
size_t v11; // rax
char *v12; // rbx

v1 = initializeCharBuffer();
v2 = *a1;
if ( *a1 )
{
v3 = 0;
do
{
v8 = v2;
if ( (unsigned int)func0(v2) )
{
if ( (unsigned int)topStack() != -1 )
{
if ( v2 == 41 )
{
while ( (unsigned int)topStack() != 40 )
{
v4 = popStack();
addCharElement(v1, (unsigned int)v4);
}
popStack();
goto LABEL_14;
}
while ( (unsigned int)topStack() != -1 )
{
v6 = topStack();
v7 = func1(v6, 1);
if ( v7 < (int)func1(v8, 0) )
break;
v5 = popStack();
addCharElement(v1, (unsigned int)v5);
}
}
pushStack(v8);
}
else if ( v2 == 92 )
{
addCharElement(v1, 92LL);
addCharElement(v1, (unsigned int)a1[++v3]);
}
else
{
addCharElement(v1, (unsigned int)v2);
}
LABEL_14:
v2 = a1[++v3];
}
while ( v2 );
}
while ( (unsigned int)topStack() != -1 )
{
v9 = popStack();
addCharElement(v1, (unsigned int)v9);
}
addCharElement(v1, 0LL);
v10 = (const char *)getCharBuffer(v1);
v11 = strlen(v10);
v12 = (char *)malloc(v11 + 1);
strcpy(v12, v10);
destroyCharBuffer(v1);
return v12;
}

original_code:
char *infixToPostfix(char *origin){
 int bufferid = initializeCharBuffer();
 int pos = 0;
 char c;
 int doubleCharFlag = 0;
 while('\0' != (c = *(origin+pos))){
  if(isOperator(c)){
   if(-1 == topStack()){
    pushStack(c);
   }else{
    if(')' == c){
     while('(' != topStack()){
      addCharElement(bufferid, popStack());
     }
     popStack();
    }else{
     while(-1 != topStack() && getPrecedence(topStack(), 1) >= getPrecedence(c, 0)){
      addCharElement(bufferid, popStack());
     }
     pushStack(c);
    }
   }
  }else{
   if('\\' == c){
    addCharElement(bufferid, c);
    pos++;
    c = *(origin+pos);
    addCharElement(bufferid, c);
   }else{
    addCharElement(bufferid, c);
   }
  }
  pos++;
 }
 while(-1 != topStack()){
  addCharElement(bufferid, popStack());
 }
 addCharElement(bufferid, '\0');
 char *s = getCharBuffer(bufferid);
 char *result = malloc(strlen(s) + 1);
 strcpy(result, s);
 destroyCharBuffer(bufferid);
 return result;
}

variable_types:
origin
char *

variable_types: bufferid int

variable_types: pos int

variable_types: doubleCharFlag int

variable_types:
result
char *


destroyDFA

decompiled_code:
__int64 destroyDFA()
{
destroyDFATransTable();
return destroyDFATable();
}

canonical_decompiled_code:
__int64 func0()
{
destroyDFATransTable();
return destroyDFATable();
}

original_code:
void destroyDFA(){
 destroyDFATransTable();
 destroyDFATable();
}


epsilonClosure

decompiled_code:
void *__fastcall epsilonClosure(unsigned int *a1)
{
unsigned int v1; // er12
_DWORD *v2; // rbp
unsigned int i; // ebx
unsigned int v4; // eax
unsigned int *v5; // rax
_DWORD *v6; // rbp
unsigned int j; // ebx
int v8; // eax
void *v9; // rbx

clearStack();
v1 = initializeIntBuffer();
v2 = a1 + 1;
for ( i = *a1; i != -1; i = *(v2 - 1) )
{
addIntElement(v1, i);
pushStack(i);
++v2;
}
while ( 1 )
{
v4 = popStack();
if ( v4 == -1 )
break;
v5 = (unsigned int *)reachByEdgeSymbol(v4, 0xFFFFFFFFLL);
v6 = v5 + 1;
for ( j = *v5; j != -1; j = *(v6 - 1) )
{
if ( !(unsigned int)isInIntBuffer(v1, j) )
{
addIntElement(v1, j);
pushStack(j);
}
++v6;
}
}
addIntElement(v1, 0xFFFFFFFFLL);
v8 = intSize(v1);
v9 = malloc(4LL * v8);
fillIntArrayWithBuffer(v1, v9);
destroyIntBuffer(v1);
return v9;
}

canonical_decompiled_code:
void *__fastcall func1(unsigned int *a1)
{
unsigned int v1; // er12
_DWORD *v2; // rbp
unsigned int i; // ebx
unsigned int v4; // eax
unsigned int *v5; // rax
_DWORD *v6; // rbp
unsigned int j; // ebx
int v8; // eax
void *v9; // rbx

clearStack();
v1 = initializeIntBuffer();
v2 = a1 + 1;
for ( i = *a1; i != -1; i = *(v2 - 1) )
{
addIntElement(v1, i);
pushStack(i);
++v2;
}
while ( 1 )
{
v4 = popStack();
if ( v4 == -1 )
break;
v5 = (unsigned int *)reachByEdgeSymbol(v4, 0xFFFFFFFFLL);
v6 = v5 + 1;
for ( j = *v5; j != -1; j = *(v6 - 1) )
{
if ( !(unsigned int)isInIntBuffer(v1, j) )
{
addIntElement(v1, j);
pushStack(j);
}
++v6;
}
}
addIntElement(v1, 0xFFFFFFFFLL);
v8 = intSize(v1);
v9 = malloc(4LL * v8);
fillIntArrayWithBuffer(v1, v9);
destroyIntBuffer(v1);
return v9;
}

original_code:
int *epsilonClosure(int *stateSet){
 clearStack();
 int temp = -1;
 int bufferid = initializeIntBuffer();
 while(-1 != (temp = *(stateSet++))){
  addIntElement(bufferid, temp);
  pushStack(temp);
 }
 while(-1 != (temp = popStack())){
  int *reach = reachByEdgeSymbol(temp, -1);
  int tempState = -1;
  while(-1 != (tempState = *(reach++))){
   if(!isInIntBuffer(bufferid, tempState)){
    addIntElement(bufferid, tempState);
    pushStack(tempState);
   }
  }
 }
 addIntElement(bufferid, -1);
 int *result = malloc(intSize(bufferid) * sizeof(int));
 fillIntArrayWithBuffer(bufferid, result);
 destroyIntBuffer(bufferid);
 return result;
}

variable_types:
stateSet
int *

variable_types: temp int

variable_types:
reach
int *

variable_types: tempState int

variable_types:
result
int *


constructDFA

decompiled_code:
__int64 constructDFA()
{
void *v0; // rbx
unsigned int v1; // ebp
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // r14
unsigned int *v5; // r13
int v6; // er12
unsigned int *v7; // rdi
_DWORD *v8; // rbx
int v9; // eax
unsigned int v10; // er15
__int64 v11; // rax
unsigned int v12[16]; // [rsp+8h] [rbp-40h] BYREF

v12[0] = *(_DWORD *)getGraph();
v12[1] = -1;
v0 = epsilonClosure(v12);
v1 = installState(v0);
v2 = getAction(v0);
addDFANewState(v1, v2);
while ( 1 )
{
result = unmarkedStatesExist();
if ( !(_DWORD)result )
break;
v4 = (unsigned int)getUnmarkedState();
markState(v4);
v5 = (unsigned int *)getNFAStates((unsigned int)v4);
v6 = 1;
do
{
v7 = move(v5, (unsigned __int8)v6 - 1);
v8 = epsilonClosure(v7);
v9 = v6;
if ( *v8 != -1 )
{
v10 = installState(v8);
v11 = getAction(v8);
addDFANewState(v10, v11);
addDFATransTableEntry((unsigned int)v4, v10, (unsigned int)(char)(v6 - 1));
v9 = v6;
}
++v6;
}
while ( v9 <= 127 );
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
void *v0; // rbx
unsigned int v1; // ebp
__int64 v2; // rax
__int64 result; // rax
__int64 v4; // r14
unsigned int *v5; // r13
int v6; // er12
unsigned int *v7; // rdi
_DWORD *v8; // rbx
int v9; // eax
unsigned int v10; // er15
__int64 v11; // rax
unsigned int v12[16]; // [rsp+8h] [rbp-40h] BYREF

v12[0] = *(_DWORD *)getGraph();
v12[1] = -1;
v0 = func1(v12);
v1 = installState(v0);
v2 = getAction(v0);
addDFANewState(v1, v2);
while ( 1 )
{
result = unmarkedStatesExist();
if ( !(_DWORD)result )
break;
v4 = (unsigned int)getUnmarkedState();
markState(v4);
v5 = (unsigned int *)getNFAStates((unsigned int)v4);
v6 = 1;
do
{
v7 = move(v5, (unsigned __int8)v6 - 1);
v8 = func1(v7);
v9 = v6;
if ( *v8 != -1 )
{
v10 = installState(v8);
v11 = getAction(v8);
addDFANewState(v10, v11);
addDFATransTableEntry((unsigned int)v4, v10, (unsigned int)(char)(v6 - 1));
v9 = v6;
}
++v6;
}
while ( v9 <= 127 );
}
return result;
}

original_code:
void constructDFA(){
 struct vertex *graph = getGraph();
 int startPoint = graph->state;
 int firstNFAState[2] = {startPoint, -1};
 int *nfaClosure = epsilonClosure(firstNFAState);
 int dfaState = installState(nfaClosure);
 char *action = getAction(nfaClosure);
 addDFANewState(dfaState, action);
 while(unmarkedStatesExist()){
  int state = getUnmarkedState();
  markState(state);
  int *nfaStates = getNFAStates(state);
  int i = 0;
  while(i < 128){
   int *reach = move(nfaStates, i);
   int *closure = epsilonClosure(reach);
   if(-1 == closure[0]){
    i++;
    continue;
   }
   dfaState = installState(closure);
   char *action = getAction(closure);
   addDFANewState(dfaState, action);
   addDFATransTableEntry(state, dfaState, i);
   i++;
  }
 }
}

variable_types: struct vertex { int state; char *action; struct edge { struct vertex *connectsTo; char symbol; struct edge *next; } *edges; struct vertex *next; } *

variable_types: startPoint int

variable_types:
firstNFAState
int [2]

variable_types:
nfaClosure
int *

variable_types: dfaState int

variable_types:
action
char *

variable_types: state int

variable_types:
nfaStates
int *

variable_types:
closure
int *


insertDefEntry

decompiled_code:
char *__fastcall insertDefEntry(char *src)
{
char **v1; // rax
char **v2; // rbx
size_t v3; // rax
char *v4; // rax
char *result; // rax

v1 = (char **)malloc(0x18uLL);
v2 = v1;
if ( definitions )
{
*(_QWORD *)(defp + 16) = v1;
defp = (__int64)v1;
}
else
{
defp = (__int64)v1;
definitions = v1;
}
v3 = strlen(src);
v4 = (char *)malloc(v3 + 1);
*v2 = v4;
result = strcpy(v4, src);
v2[1] = 0LL;
v2[2] = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
char **v1; // rax
char **v2; // rbx
size_t v3; // rax
char *v4; // rax
char *result; // rax

v1 = (char **)malloc(0x18uLL);
v2 = v1;
if ( definitions )
{
*(_QWORD *)(defp + 16) = v1;
defp = (__int64)v1;
}
else
{
defp = (__int64)v1;
definitions = v1;
}
v3 = strlen(src);
v4 = (char *)malloc(v3 + 1);
*v2 = v4;
result = strcpy(v4, src);
v2[1] = 0LL;
v2[2] = 0LL;
return result;
}

original_code:
void insertDefEntry(char *name){
 struct Defentry *temp = malloc(sizeof(struct Defentry));
 if(((void *)0) == definitions){
  definitions = defp = temp;
 }else{
  defp->next = temp;
  defp = temp;
 }
 temp->name = malloc(strlen(name)+1);
 strcpy(temp->name, name);
 temp->definition = ((void *)0);
 temp->next = ((void *)0);
}

variable_types:
name
char *

variable_types: struct Defentry { char *name; char *definition; struct Defentry *next; } *


insertDefContent

decompiled_code:
char *__fastcall insertDefContent(char *src)
{
size_t v1; // rax
__int64 v2; // rbp
char *v3; // rax

v1 = strlen(src);
v2 = defp;
v3 = (char *)malloc(v1 + 1);
*(_QWORD *)(v2 + 8) = v3;
return strcpy(v3, src);
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
size_t v1; // rax
__int64 v2; // rbp
char *v3; // rax

v1 = strlen(src);
v2 = defp;
v3 = (char *)malloc(v1 + 1);
*(_QWORD *)(v2 + 8) = v3;
return strcpy(v3, src);
}

original_code:
void insertDefContent(char *def){
 defp->definition = malloc(strlen(def)+1);
 strcpy(defp->definition, def);
}

variable_types:
def
char *


insertREEntry

decompiled_code:
char *__fastcall insertREEntry(char *src)
{
char **v1; // rax
char **v2; // rbx
size_t v3; // rax
char *v4; // rax
char *result; // rax

v1 = (char **)malloc(0x18uLL);
v2 = v1;
if ( regexps )
{
*(_QWORD *)(rep + 16) = v1;
rep = (__int64)v1;
}
else
{
rep = (__int64)v1;
regexps = v1;
}
v3 = strlen(src);
v4 = (char *)malloc(v3 + 1);
*v2 = v4;
result = strcpy(v4, src);
v2[1] = 0LL;
v2[2] = 0LL;
return result;
}

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
char **v1; // rax
char **v2; // rbx
size_t v3; // rax
char *v4; // rax
char *result; // rax

v1 = (char **)malloc(0x18uLL);
v2 = v1;
if ( regexps )
{
*(_QWORD *)(rep + 16) = v1;
rep = (__int64)v1;
}
else
{
rep = (__int64)v1;
regexps = v1;
}
v3 = strlen(src);
v4 = (char *)malloc(v3 + 1);
*v2 = v4;
result = strcpy(v4, src);
v2[1] = 0LL;
v2[2] = 0LL;
return result;
}

original_code:
void insertREEntry(char *re){
 struct REentry *temp = malloc(sizeof(struct REentry));
 if(((void *)0) == regexps){
  regexps = rep = temp;
 }else{
  rep->next = temp;
  rep = temp;
 }
 temp->regexp = malloc(strlen(re)+1);
 strcpy(temp->regexp, re);
 temp->action = ((void *)0);
 temp->next = ((void *)0);
}

variable_types:
re
char *

variable_types: struct REentry { char *regexp; char *action; struct REentry *next; } *