printdebug

decompiled_code:
int printdebug()
{
int *v0; // rax
unsigned int v1; // ebx

fprintf(stderr, "%s: debug stack depth = %d\n", (const char *)programname, *((unsigned int *)debugmem + 3));
v0 = (int *)debugmem;
if ( *((int *)debugmem + 3) > 0 )
{
v1 = 0;
do
{
fprintf(
stderr,
"%s: stackframe %d = %s, line %d\n",
(const char *)programname,
v1,
*((const char **)&aDebugFilenameArray + v0[2 * v1 + 5]),
(unsigned int)v0[2 * v1 + 6]);
++v1;
v0 = (int *)debugmem;
}
while ( *((_DWORD *)debugmem + 3) > (signed int)v1 );
}
return fprintf(stderr, "\n%s: last db fetch was for #%d\n", (const char *)programname, (unsigned int)v0[2]);
}

canonical_decompiled_code:
int func0()
{
int *v0; // rax
unsigned int v1; // ebx

fprintf(stderr, "%s: debug stack depth = %d\n", (const char *)programname, *((unsigned int *)debugmem + 3));
v0 = (int *)debugmem;
if ( *((int *)debugmem + 3) > 0 )
{
v1 = 0;
do
{
fprintf(
stderr,
"%s: stackframe %d = %s, line %d\n",
(const char *)programname,
v1,
*((const char **)&aDebugFilenameArray + v0[2 * v1 + 5]),
(unsigned int)v0[2 * v1 + 6]);
++v1;
v0 = (int *)debugmem;
}
while ( *((_DWORD *)debugmem + 3) > (signed int)v1 );
}
return fprintf(stderr, "\n%s: last db fetch was for #%d\n", (const char *)programname, (unsigned int)v0[2]);
}

original_code:
void printdebug( void )
{
  int idx;
  fprintf(stderr, "%s: debug stack depth = %d\n", programname,
          debugmem->stacktop);
  for( idx = 0; idx < debugmem->stacktop; idx++) {
      fprintf(stderr, "%s: stackframe %d = %s, line %d\n", programname,
              idx, aDebugFilenameArray[debugmem->callstack[idx].filenum],
              debugmem->callstack[idx].linenum);
  }
  fprintf(stderr, "\n%s: last db fetch was for #%d\n", programname,
          debugmem->lastdbfetch);
}

canonical_original_code:
void printdebug()
{
  int idx;
  fprintf(stderr, "%s: debug stack depth = %d\n", programname,
          debugmem->stacktop);
  for( idx = 0; idx < debugmem->stacktop; idx++) {
      fprintf(stderr, "%s: stackframe %d = %s, line %d\n", programname,
              idx, aDebugFilenameArray[debugmem->callstack[idx].filenum],
              debugmem->callstack[idx].linenum);
  }
  fprintf(stderr, "\n%s: last db fetch was for #%d\n", programname,
          debugmem->lastdbfetch);
}

variable_types: idx int


repo: kenneaal/RhostMUSH

decompiled_code:
void handle_usr1()
{
fprintf(stderr, "\n%s: caught SIGUSR1\n", (const char *)programname);
printdebug();
signal(10, handle_usr1);
}

canonical_decompiled_code:
void func1()
{
fprintf(stderr, "\n%s: caught SIGUSR1\n", (const char *)programname);
func0();
signal(10, handle_usr1);
}

original_code:
void handle_usr1(int sig)
{
   fprintf(stderr, "\n%s: caught SIGUSR1\n", programname);
   printdebug();
   signal(10, handle_usr1);
}

variable_types: sig int

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rsi
_DWORD *v5; // rax
__pid_t v6; // eax
__pid_t v7; // ebx
int shmid; // [rsp+4h] [rbp-24h] BYREF
unsigned int v10; // [rsp+8h] [rbp-20h] BYREF
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = *argv;
programname = (__int64)v4;
if ( argc <= 2 )
{
printf("usage: %s <shared mem key> <prog name>\n", v4);
exit(1);
}
if ( (int)_isoc99_sscanf(argv[1], "%d", &v10) < 0 )
{
fprintf(stderr, "** debug_id must be an integer, not '%s' **\n", argv[1]);
exit(1);
}
debugmem = (void *)shmConnect(v10, 1LL, &shmid);
*((_DWORD *)debugmem + 1) = getpid();
*(_DWORD *)debugmem = -1;
fprintf(stderr, "Master IPC Debugging stack created w/ key = %d [shared memory id: %d]\n", v10, (unsigned int)shmid);
v5 = debugmem;
*((_DWORD *)debugmem + 2) = -1;
v5[3] = 0;
v5[4] = 0;
fprintf(stderr, "%s: initiating %s\n", (const char *)programname, argv[2]);
v6 = fork();
v7 = v6;
if ( v6 < 0 )
{
perror("fork");
exit(1);
}
if ( !v6 )
{
execv(argv[2], (char *const *)argv + 2);
perror("execv");
exit(1);
}
signal(10, (__sighandler_t)handle_usr1);
while ( wait((__WAIT_STATUS)&stat_loc) != v7 )
;
fprintf(stderr, "%s: %s exited with status %d\n", (const char *)programname, argv[2], LODWORD(stat_loc.__uptr));
printdebug();
shmdt(debugmem);
shmctl(shmid, 0, 0LL);
fprintf(stderr, "%s: exiting\n", (const char *)programname);
return (int)stat_loc.__uptr;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rsi
_DWORD *v5; // rax
__pid_t v6; // eax
__pid_t v7; // ebx
int shmid; // [rsp+4h] [rbp-24h] BYREF
unsigned int v10; // [rsp+8h] [rbp-20h] BYREF
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1Ch] BYREF

v4 = *argv;
programname = (__int64)v4;
if ( argc <= 2 )
{
printf("usage: %s <shared mem key> <prog name>\n", v4);
exit(1);
}
if ( (int)_isoc99_sscanf(argv[1], "%d", &v10) < 0 )
{
fprintf(stderr, "** debug_id must be an integer, not '%s' **\n", argv[1]);
exit(1);
}
debugmem = (void *)shmConnect(v10, 1LL, &shmid);
*((_DWORD *)debugmem + 1) = getpid();
*(_DWORD *)debugmem = -1;
fprintf(stderr, "Master IPC Debugging stack created w/ key = %d [shared memory id: %d]\n", v10, (unsigned int)shmid);
v5 = debugmem;
*((_DWORD *)debugmem + 2) = -1;
v5[3] = 0;
v5[4] = 0;
fprintf(stderr, "%s: initiating %s\n", (const char *)programname, argv[2]);
v6 = fork();
v7 = v6;
if ( v6 < 0 )
{
perror("fork");
exit(1);
}
if ( !v6 )
{
execv(argv[2], (char *const *)argv + 2);
perror("execv");
exit(1);
}
signal(10, (__sighandler_t)handle_usr1);
while ( wait((__WAIT_STATUS)&stat_loc) != v7 )
;
fprintf(stderr, "%s: %s exited with status %d\n", (const char *)programname, argv[2], LODWORD(stat_loc.__uptr));
func0();
shmdt(debugmem);
shmctl(shmid, 0, 0LL);
fprintf(stderr, "%s: exiting\n", (const char *)programname);
return (int)stat_loc.__uptr;
}

original_code:
int main( int argc, char *argv[] )
{
  int status;
  int pid;
  int debug_id;
  int shmid;
  int foo;
  programname = argv[0];
  if( argc < 3 ) {
    printf("usage: %s <shared mem key> <prog name>\n", programname);
    exit(1);
  }
  foo = sscanf(argv[1], "%d", &debug_id);
  if ( foo < 0) {
    fprintf(stderr, "** debug_id must be an integer, not '%s' **\n", argv[1]);
    exit(1);
  }
  debugmem = shmConnect(debug_id, 1, &shmid);
  debugmem->debugport = getpid();
  debugmem->mushport = -1;
  fprintf(stderr, "Master IPC Debugging stack created w/ key = %d [shared memory id: %d]\n",
          debug_id, shmid);
  { debugmem->lastdbfetch = -1; debugmem->stacktop = 0; debugmem->stackval = 0; };
  fprintf(stderr, "%s: initiating %s\n", programname, argv[2]);
  if( (pid = fork()) < 0 ) {
    perror("fork");
    exit(1);
  }
  if( pid == 0 ) {
    execv(argv[2], argv + 2);
    perror("execv");
    exit(1);
  }
  signal(10, handle_usr1);
  while( wait(&status) != pid ) {
  }
  fprintf(stderr, "%s: %s exited with status %d\n", programname,
                  argv[2], status);
  printdebug();
  shmdt((const void *)debugmem);
  shmctl(shmid, 0, ((void *)0));
  fprintf(stderr, "%s: exiting\n", programname);
  return status;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  int status;
  int pid;
  int debug_id;
  int shmid;
  int foo;
  programname = argv[0];
  if( argc < 3 ) {
    printf("usage: %s <shared mem key> <prog name>\n", programname);
    exit(1);
  }
  foo = sscanf(argv[1], "%d", &debug_id);
  if ( foo < 0) {
    fprintf(stderr, "** debug_id must be an integer, not '%s' **\n", argv[1]);
    exit(1);
  }
  debugmem = shmConnect(debug_id, 1, &shmid);
  debugmem->debugport = getpid();
  debugmem->mushport = -1;
  fprintf(stderr, "Master IPC Debugging stack created w/ key = %d [shared memory id: %d]\n",
          debug_id, shmid);
  { debugmem->lastdbfetch = -1; debugmem->stacktop = 0; debugmem->stackval = 0; };
  fprintf(stderr, "%s: initiating %s\n", programname, argv[2]);
  if( (pid = fork()) < 0 ) {
    perror("fork");
    exit(1);
  }
  if( pid == 0 ) {
    execv(argv[2], argv + 2);
    perror("execv");
    exit(1);
  }
  signal(10, handle_usr1);
  while( wait(&status) != pid ) {
  }
  fprintf(stderr, "%s: %s exited with status %d\n", programname,
                  argv[2], status);
  printdebug();
  shmdt((void *)debugmem);
  shmctl(shmid, 0, ((void *)0));
  fprintf(stderr, "%s: exiting\n", programname);
  return status;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: status int

variable_types: pid int

variable_types: shmid int

variable_types: foo int

return_type: int


decompiled_code:
char *real_tprintf(const char *a1, unsigned int a2, char *a3, __int64 *a4, const char *a5, ...)
{
char *v5; // r12
int v8; // ebx
int v9; // ebp
int v10; // eax
int v11; // er13
char *v12; // rbp
__int64 v13; // rsi
char *v14; // rax
bool v15; // cl
bool v16; // dl
gcc_va_list arg; // [rsp+10h] [rbp-108h] BYREF
char *v19; // [rsp+28h] [rbp-F0h] BYREF

va_start(arg, a5);
v5 = a3;
if ( !a3 )
{
v5 = (char *)getTrackedBuffer();
v19 = v5;
a4 = (__int64 *)&v19;
}
v8 = getBufferSize(v5);
v9 = v8 - 1;
if ( v8 <= 0 )
fprintf(stderr, "ERR: (%s:%d) Unknown pool passed to safe_tprintf.\n", a1, a2);
else
v8 = (_DWORD)v5 + v9 - *(_DWORD *)a4;
if ( v8 < 0 )
{
fprintf(stderr, "WRN: (%s:%d) Zero length buffer in safe_tprintf.\n", a1, a2);
v8 = 0;
}
v10 = vsnprintf(v5, v8, a5, arg);
v11 = v10;
v12 = &v5[v9];
*v12 = 0;
if ( v10 < 0 )
fprintf(stderr, "ERR: (%s:%d) vsnprintf returned error code (%d).\n", a1, a2, (unsigned int)v10);
if ( v8 < v11 )
{
v13 = *a4;
if ( v12 != (char *)*a4 && v13 )
{
v14 = (char *)(v13 + 1);
do
{
v13 = (__int64)v14;
v15 = v12 != v14;
v16 = v14++ != 0LL;
}
while ( v16 && v15 );
}
*a4 = v13;
}
else
{
*a4 += v11 + 1LL;
}
return v5;
}

canonical_decompiled_code:
char *func1(const char *a1, unsigned int a2, char *a3, __int64 *a4, const char *a5, ...)
{
char *v5; // r12
int v8; // ebx
int v9; // ebp
int v10; // eax
int v11; // er13
char *v12; // rbp
__int64 v13; // rsi
char *v14; // rax
bool v15; // cl
bool v16; // dl
gcc_va_list arg; // [rsp+10h] [rbp-108h] BYREF
char *v19; // [rsp+28h] [rbp-F0h] BYREF

va_start(arg, a5);
v5 = a3;
if ( !a3 )
{
v5 = (char *)func0();
v19 = v5;
a4 = (__int64 *)&v19;
}
v8 = getBufferSize(v5);
v9 = v8 - 1;
if ( v8 <= 0 )
fprintf(stderr, "ERR: (%s:%d) Unknown pool passed to safe_tprintf.\n", a1, a2);
else
v8 = (_DWORD)v5 + v9 - *(_DWORD *)a4;
if ( v8 < 0 )
{
fprintf(stderr, "WRN: (%s:%d) Zero length buffer in safe_tprintf.\n", a1, a2);
v8 = 0;
}
v10 = vsnprintf(v5, v8, a5, arg);
v11 = v10;
v12 = &v5[v9];
*v12 = 0;
if ( v10 < 0 )
fprintf(stderr, "ERR: (%s:%d) vsnprintf returned error code (%d).\n", a1, a2, (unsigned int)v10);
if ( v8 < v11 )
{
v13 = *a4;
if ( v12 != (char *)*a4 && v13 )
{
v14 = (char *)(v13 + 1);
do
{
v13 = (__int64)v14;
v15 = v12 != v14;
v16 = v14++ != 0LL;
}
while ( v16 && v15 );
}
*a4 = v13;
}
else
{
*a4 += v11 + 1LL;
}
return v5;
}

original_code:
char *real_tprintf(char *filename, int lineNo,
     char *buff, char **bp, char *format, ...)
{
  int length, end, ret;
  char *bp2;
  va_list ap;
  __builtin_va_start(ap,format);
  if (buff == ((void *)0)) {
    buff = getTrackedBuffer();
    bp2 = buff;
    bp = &bp2;
  }
  length = getBufferSize(buff);
  end = length - 1;
  if (length > 0) {
    length -= (*bp - buff) + 1;
  } else {
    fprintf(stderr,
     "ERR: (%s:%d) Unknown pool passed to safe_tprintf.\n",
     filename, lineNo);
  }
  if (length < 0) {
    length = 0;
    fprintf(stderr,
     "WRN: (%s:%d) Zero length buffer in safe_tprintf.\n",
     filename, lineNo);
  }
  ret = vsnprintf(buff, length, format, ap);
  __builtin_va_end(ap);
  buff[end] = '\0';
  if (ret < 0) {
     fprintf(stderr,
      "ERR: (%s:%d) vsnprintf returned error code (%d).\n",
      filename, lineNo, ret);
  }
  if (ret <= length) {
     *bp += ret + 1;
  } else {
     for (bp2 = *bp; bp2 != '\0' && bp2 != &buff[end]; bp2++);
     *bp = bp2;
  }
  return buff;
}

canonical_original_code:
char *real_tprintf(char *filename, int lineNo, char *buff, char **bp, char *format, ...)
{
  int length; int end; int ret;
  char *bp2;
  __builtin_va_list ap;
  __builtin_va_start(ap,format);
  if (buff == ((void *)0)) {
    buff = getTrackedBuffer();
    bp2 = buff;
    bp = &bp2;
  }
  length = getBufferSize(buff);
  end = length - 1;
  if (length > 0) {
    length -= (*bp - buff) + 1;
  } else {
    fprintf(stderr,
     "ERR: (%s:%d) Unknown pool passed to safe_tprintf.\n",
     filename, lineNo);
  }
  if (length < 0) {
    length = 0;
    fprintf(stderr,
     "WRN: (%s:%d) Zero length buffer in safe_tprintf.\n",
     filename, lineNo);
  }
  ret = vsnprintf(buff, length, format, ap);
  __builtin_va_end(ap);
  buff[end] = '\0';
  if (ret < 0) {
     fprintf(stderr,
      "ERR: (%s:%d) vsnprintf returned error code (%d).\n",
      filename, lineNo, ret);
  }
  if (ret <= length) {
     *bp += ret + 1;
  } else {
     for (bp2 = *bp; bp2 != '\0' && bp2 != &buff[end]; bp2++);
     *bp = bp2;
  }
  return buff;
}

variable_types:
filename
char *

variable_types: lineNo int

variable_types:
buff
char *

variable_types:
bp
char **

variable_types:
format
char *

variable_types: length int

variable_types: end int

variable_types: ret int

return_type: char *


freeTrackedBuffers

decompiled_code:
void freeTrackedBuffers()
{
int v0; // er13
void *v1; // r15
char *i; // r12
int v3; // eax
char *v4; // rbp
int v5; // ebx
int j; // er14
int v7; // eax

v0 = 0;
v1 = 0LL;
for ( i = (char *)&bufferList; ; v1 = i )
{
v3 = *((_DWORD *)i + 20);
v4 = i;
v5 = 0;
for ( j = v0 + 1; v3 > v5; v4 += 8 )
{
pool_free(2LL, v4, 205LL, "tprintf.c");
v0 = j + v5++;
v3 = *((_DWORD *)i + 20);
}
v7 = v3 - v5;
*((_DWORD *)i + 20) = v7;
if ( v7 )
{
if ( (mudconf[8104] & 8) != 0 && (unsigned int)start_log("ASSERT", "FAIL") )
{
log_text("Assertion failed, raise a bug report: '#x'");
end_log();
}
mudstate[13] = 1;
}
i = (char *)*((_QWORD *)i + 11);
if ( v1 )
free(v1);
else
qword_4B8 = 0LL;
if ( !i )
break;
}
if ( v0 > 0 )
{
qword_448 += v0;
++qword_450;
dword_444 -= v0;
if ( dword_444 )
_assert_fail("bufferStats.current == 0", "tprintf.c", 0xE9u, "freeTrackedBuffers");
}
}

canonical_decompiled_code:
void func2()
{
int v0; // er13
void *v1; // r15
char *i; // r12
int v3; // eax
char *v4; // rbp
int v5; // ebx
int j; // er14
int v7; // eax

v0 = 0;
v1 = 0LL;
for ( i = (char *)&bufferList; ; v1 = i )
{
v3 = *((_DWORD *)i + 20);
v4 = i;
v5 = 0;
for ( j = v0 + 1; v3 > v5; v4 += 8 )
{
pool_free(2LL, v4, 205LL, "tprintf.c");
v0 = j + v5++;
v3 = *((_DWORD *)i + 20);
}
v7 = v3 - v5;
*((_DWORD *)i + 20) = v7;
if ( v7 )
{
if ( (mudconf[8104] & 8) != 0 && (unsigned int)start_log("ASSERT", "FAIL") )
{
log_text("Assertion failed, raise a bug report: '#x'");
end_log();
}
mudstate[13] = 1;
}
i = (char *)*((_QWORD *)i + 11);
if ( v1 )
free(v1);
else
qword_4B8 = 0LL;
if ( !i )
break;
}
if ( v0 > 0 )
{
qword_448 += v0;
++qword_450;
dword_444 -= v0;
if ( dword_444 )
_assert_fail("bufferStats.current == 0", "tprintf.c", 0xE9u, "freeTrackedBuffers");
}
}

original_code:
void freeTrackedBuffers(void) {
  tprintf_list_t *pList = &bufferList;
  tprintf_list_t *pCurrentList = ((void *)0);
  int nFreed = 0;
  int i;
  while (pList != ((void *)0)) {
    for ( i = 0 ; i < pList->nInUse ; i++) {
      pool_free(2,((char **)&(pList->pBuff[i])),205,"tprintf.c");
      nFreed++;
    }
    pList->nInUse -= i;
    if (! (pList->nInUse == 0) ) { if ((((0x00000008) & mudconf.log_options) != 0) && start_log("ASSERT", "FAIL")) {; log_text("Assertion failed, raise a bug report: '#x'"); end_log(); }; mudstate.panicking = 1; };
    pList = pList->pNext;
    if (pCurrentList != ((void *)0)) {
      free(pCurrentList);
    } else {
      bufferList.pNext = ((void *)0);
    }
    pCurrentList = pList;
  };
  if ( nFreed > 0 ) {
    bufferStats.cummulativeLength += nFreed;
    bufferStats.numberOfCalls++;
    bufferStats.current -= nFreed;
    ((void) sizeof ((bufferStats.current == 0) ? 1 : 0), __extension__ ({ if (bufferStats.current == 0) ; else __assert_fail ("bufferStats.current == 0", "tprintf.c", 233, __extension__ __PRETTY_FUNCTION__); }));
  }
}

canonical_original_code:
void freeTrackedBuffers() {
  struct _tprintf_list *pList = &bufferList;
  struct _tprintf_list *pCurrentList = ((void *)0);
  int nFreed = 0;
  int i;
  while (pList != ((void *)0)) {
    for ( i = 0 ; i < pList->nInUse ; i++) {
      pool_free(2,((char **)&(pList->pBuff[i])),205,"tprintf.c");
      nFreed++;
    }
    pList->nInUse -= i;
    if (! (pList->nInUse == 0) ) { if ((((0x00000008) & mudconf.log_options) != 0) && start_log("ASSERT", "FAIL")) {; log_text("Assertion failed, raise a bug report: '#x'"); end_log(); }; mudstate.panicking = 1; };
    pList = pList->pNext;
    if (pCurrentList != ((void *)0)) {
      free(pCurrentList);
    } else {
      bufferList.pNext = ((void *)0);
    }
    pCurrentList = pList;
  };
  if ( nFreed > 0 ) {
    bufferStats.cummulativeLength += nFreed;
    bufferStats.numberOfCalls++;
    bufferStats.current -= nFreed;
    ((void) sizeof ((bufferStats.current == 0) ? 1 : 0), __extension__ ({ if (bufferStats.current == 0) ; else __assert_fail ("bufferStats.current == 0", "tprintf.c", 233, __extension__ __PRETTY_FUNCTION__); }));
  }
}

variable_types: struct _tprintf_list { char *pBuff[10]; int nInUse; struct _tprintf_list *pNext; } *

variable_types: nFreed int

variable_types: i int


showTrackedBufferStats

decompiled_code:
__int64 __fastcall showTrackedBufferStats(unsigned int a1)
{
__int64 v1; // rax
char *v2; // rax

v1 = (unsigned int)dword_444;
if ( qword_450 > 0 )
v1 = qword_448 / qword_450;
v2 = real_tprintf(
"tprintf.c",
0xFAu,
0LL,
0LL,
"\nTprintf Stats Current Maximum Average\n %-5d %-5d %-5d",
(unsigned int)dword_444,
(unsigned int)bufferStats,
v1);
return notify_check(a1, a1, v2, 0LL, 3085LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
__int64 v1; // rax
char *v2; // rax

v1 = (unsigned int)dword_444;
if ( qword_450 > 0 )
v1 = qword_448 / qword_450;
v2 = func1(
"tprintf.c",
0xFAu,
0LL,
0LL,
"\nTprintf Stats Current Maximum Average\n %-5d %-5d %-5d",
(unsigned int)dword_444,
(unsigned int)bufferStats,
v1);
return notify_check(a1, a1, v2, 0LL, 3085LL, 0LL);
}

original_code:
void showTrackedBufferStats(dbref player) {
  char *buff = ((void *)0);
  int avg = 0;
  if (bufferStats.numberOfCalls > 0) {
      avg = bufferStats.cummulativeLength / bufferStats.numberOfCalls;
  } else {
      avg = bufferStats.current;
  }
  buff = real_tprintf("tprintf.c", 250, ((void *)0), ((void *)0), "\nTprintf Stats   Current  Maximum   Average\n" "                %-5d    %-5d     %-5d", bufferStats.current, bufferStats.maxLength, avg);
  notify_check(player,player,buff,0, 1|(2048|8|1024)|(4), 0);
}

canonical_original_code:
void showTrackedBufferStats(int player) {
  char *buff = ((void *)0);
  int avg = 0;
  if (bufferStats.numberOfCalls > 0) {
      avg = bufferStats.cummulativeLength / bufferStats.numberOfCalls;
  } else {
      avg = bufferStats.current;
  }
  buff = real_tprintf("tprintf.c", 250, ((void *)0), ((void *)0), "\nTprintf Stats   Current  Maximum   Average\n" "                %-5d    %-5d     %-5d", bufferStats.current, bufferStats.maxLength, avg);
  notify_check(player,player,buff,0, 1|(2048|8|1024)|(4), 0);
}

variable_types: player int

variable_types: avg int


bittype

decompiled_code:
__int64 __fastcall bittype(unsigned int a1)
{
__int64 v1; // rax
int v2; // edx
__int64 v3; // rcx
int v4; // edx
__int64 v5; // rbp
__int64 result; // rax
int v7; // ecx
__int64 v8; // rbp
int v9; // edi
int v10; // edx
__int64 v11; // rsi
__int64 v12; // rcx
unsigned int v13; // eax
char v14; // dl
int v15; // esi
int v16; // ecx
int v17; // edx
int v18; // eax
int v19; // eax
int v20; // esi
int v21; // edx
int v22; // edx
__int64 v23; // rax
int v24; // edx
int v25; // eax
int v26; // eax
int v27; // ecx
int v28; // edx
int v29; // edx
__int64 v30; // rax
int v31; // edx
__int64 v32; // rax
int v33; // edx
int v34; // eax
int v35; // eax
int v36; // ecx
int v37; // edx
int v38; // edx
__int64 v39; // rax
int v40; // edx
__int64 v41; // rax
int v42; // edx
__int64 v43; // rax
int v44; // edx
int v45; // eax
int v46; // eax
int v47; // ecx
int v48; // edx
int v49; // edx
__int64 v50; // rax
int v51; // edx
int v52; // eax
int v53; // eax
int v54; // ecx
int v55; // edx
int v56; // edx
int v57; // eax
int v58; // eax
int v59; // ecx
int v60; // edx

v1 = debugmem;
if ( debugmem )
{
v2 = *(_DWORD *)(debugmem + 12LL);
if ( v2 > 999 )
{
printf("Debug Stack Overflow! (line %d of fp %d)\n", 26LL, 58LL);
exit(1);
}
v3 = v2 + 2LL;
*(_DWORD *)(debugmem + 8 * v3 + 4) = 58;
v4 = v2 + 1;
*(_DWORD *)(v1 + 12) = v4;
*(_DWORD *)(v1 + 8 * v3 + 8) = 26;
if ( *(_DWORD *)(v1 + 16) >= v4 )
v4 = *(_DWORD *)(v1 + 16);
*(_DWORD *)(v1 + 16) = v4;
}
if ( (a1 & 0x80000000) != 0 )
return 0LL;
if ( mudstate[1830] <= (signed int)a1 )
return 0LL;
v5 = 88LL * (int)a1;
if ( (*(_DWORD *)(db + v5 + 40) & 7u) > 4 )
return 0LL;
if ( (*(_QWORD *)(db + v5 + 40) & 0x40000000004000LL) != 0 )
return 0LL;
result = 7LL;
if ( a1 != 1 )
{
if ( (unsigned int)evlevchk(a1, 5LL) )
{
result = 6LL;
if ( mudstate[2077] )
goto LABEL_11;
}
else
{
v13 = *(_DWORD *)(db + v5 + 40);
v14 = 1;
if ( (v13 & 0x200000) == 0 )
{
v15 = *(_DWORD *)(db + v5 + 24);
v16 = *(_DWORD *)(db + 88LL * v15 + 40);
v14 = 0;
if ( (v16 & 0x200000) != 0 )
v14 = ((v15 == a1) | ((v16 | v13) >> 25)) & 1;
}
result = 6LL;
if ( (v14 & 1) != 0 )
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 4LL) )
{
result = 5LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_19;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
{
LABEL_39:
result = 5LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_39;
}
else
{
v19 = *(_DWORD *)(db + v5 + 40);
if ( (v19 & 0x200000) != 0 )
goto LABEL_39;
v20 = *(_DWORD *)(db + v5 + 24);
v21 = *(_DWORD *)(db + 88LL * v20 + 40);
if ( (v21 & 0x200000) != 0 && (((v21 | v19) & 0x2000000) != 0 || v20 == a1) )
goto LABEL_39;
}
v17 = *(_DWORD *)(db + v5 + 24);
v18 = *(_DWORD *)(db + 88LL * v17 + 40);
if ( (v18 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v18) & 0x2000000) != 0 || v17 == a1) )
{
result = 5LL;
goto LABEL_11;
}
LABEL_19:
if ( (unsigned int)evlevchk(a1, 3LL) )
{
result = 4LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_21;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) == 0 )
{
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_52;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_52;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_52;
}
else
{
v26 = *(_DWORD *)(db + v5 + 40);
if ( (v26 & 0x200000) != 0 )
goto LABEL_52;
v27 = *(_DWORD *)(db + v5 + 24);
v28 = *(_DWORD *)(db + 88LL * v27 + 40);
if ( (v28 & 0x200000) != 0 && (((v28 | v26) & 0x2000000) != 0 || v27 == a1) )
goto LABEL_52;
}
v24 = *(_DWORD *)(db + v5 + 24);
v25 = *(_DWORD *)(db + 88LL * v24 + 40);
if ( (v25 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v25) & 0x2000000) != 0 || v24 == a1) )
goto LABEL_52;
}
v22 = *(_DWORD *)(db + v5 + 24);
v23 = db + 88LL * v22;
if ( (*(_BYTE *)(v23 + 45) & 1) == 0 )
goto LABEL_21;
if ( (*(_BYTE *)(db + v5 + 43) & 2) == 0 )
{
if ( (*(_BYTE *)(v23 + 43) & 2) != 0 || v22 == a1 )
{
result = 4LL;
goto LABEL_11;
}
LABEL_21:
if ( (unsigned int)evlevchk(a1, 2LL) )
{
result = 3LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_23;
}
if ( (*(_BYTE *)(db + v5 + 47) & 0x20) != 0 )
{
LABEL_73:
result = 3LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
goto LABEL_76;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_73;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_73;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
}
else
{
v35 = *(_DWORD *)(db + v5 + 40);
if ( (v35 & 0x200000) != 0 )
goto LABEL_73;
v36 = *(_DWORD *)(db + v5 + 24);
v37 = *(_DWORD *)(db + 88LL * v36 + 40);
if ( (v37 & 0x200000) != 0 )
{
if ( ((v37 | v35) & 0x2000000) != 0 || v36 == a1 )
goto LABEL_73;
goto LABEL_82;
}
}
v33 = *(_DWORD *)(db + v5 + 24);
v34 = *(_DWORD *)(db + 88LL * v33 + 40);
if ( (v34 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v34) & 0x2000000) != 0 || v33 == a1) )
goto LABEL_73;
}
LABEL_82:
v31 = *(_DWORD *)(db + v5 + 24);
v32 = db + 88LL * v31;
if ( (*(_BYTE *)(v32 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v32 + 43) & 2) != 0 || v31 == a1 )
goto LABEL_73;
v29 = *(_DWORD *)(db + v5 + 24);
v30 = 88LL * v29 + db;
if ( (*(_BYTE *)(v30 + 47) & 0x20) == 0 )
goto LABEL_23;
goto LABEL_87;
}
LABEL_76:
v29 = *(_DWORD *)(db + v5 + 24);
v30 = db + 88LL * v29;
if ( (*(_BYTE *)(v30 + 47) & 0x20) == 0 )
goto LABEL_23;
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 )
goto LABEL_73;
LABEL_87:
if ( (*(_BYTE *)(v30 + 43) & 2) != 0 || a1 == v29 )
{
result = 3LL;
goto LABEL_11;
}
LABEL_23:
if ( (unsigned int)evlevchk(a1, 1LL) )
{
result = 2LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_25;
}
if ( (*(_BYTE *)(db + v5 + 45) & 4) != 0 )
{
LABEL_103:
result = 2LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 2LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
LABEL_106:
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
LABEL_108:
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_110;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v58 = *(_DWORD *)(db + v5 + 40);
if ( (v58 & 0x200000) != 0 )
goto LABEL_103;
v59 = *(_DWORD *)(db + v5 + 24);
v60 = *(_DWORD *)(db + 88LL * v59 + 40);
if ( (v60 & 0x200000) != 0 )
{
if ( ((v60 | v58) & 0x2000000) != 0 || v59 == a1 )
goto LABEL_103;
LABEL_110:
v38 = *(_DWORD *)(db + v5 + 24);
v39 = db + 88LL * v38;
if ( (*(_BYTE *)(v39 + 45) & 4) == 0 )
goto LABEL_25;
if ( (*(_BYTE *)(db + v5 + 43) & 2) == 0 )
{
if ( (*(_BYTE *)(v39 + 43) & 2) != 0 || v38 == a1 )
{
result = 2LL;
goto LABEL_11;
}
LABEL_25:
v8 = db + v5;
v9 = *(_DWORD *)(v8 + 44);
result = v9 & 0x1000000;
if ( (v9 & 0x1000000) != 0 )
{
result = 0LL;
goto LABEL_11;
}
v10 = *(_DWORD *)(v8 + 24);
if ( v10 < 0 )
{
result = (v9 & 0x200000) == 0;
goto LABEL_11;
}
if ( v10 >= mudstate[1830] )
{
if ( (v9 & 0x200000) != 0 )
goto LABEL_11;
result = 1LL;
if ( v10 >= mudstate[1830] )
goto LABEL_11;
}
else
{
v11 = db + 88LL * v10;
if ( (*(_DWORD *)(v11 + 40) & 7u) <= 4 && (*(_BYTE *)(v11 + 47) & 1) != 0 || (v9 & 0x200000) != 0 )
goto LABEL_11;
}
v12 = 88LL * v10 + db;
result = 1LL;
if ( (*(_DWORD *)(v12 + 40) & 7u) <= 4 )
result = (*(_BYTE *)(v12 + 46) & 0x20) == 0;
goto LABEL_11;
}
goto LABEL_103;
}
}
v56 = *(_DWORD *)(db + v5 + 24);
v57 = *(_DWORD *)(db + 88LL * v56 + 40);
if ( (v57 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v57) & 0x2000000) != 0 || v56 == a1) )
goto LABEL_103;
goto LABEL_110;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_147;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v53 = *(_DWORD *)(db + v5 + 40);
if ( (v53 & 0x200000) != 0 )
goto LABEL_103;
v54 = *(_DWORD *)(db + v5 + 24);
v55 = *(_DWORD *)(db + 88LL * v54 + 40);
if ( (v55 & 0x200000) != 0 )
{
if ( ((v55 | v53) & 0x2000000) != 0 || v54 == a1 )
goto LABEL_103;
goto LABEL_147;
}
}
v51 = *(_DWORD *)(db + v5 + 24);
v52 = *(_DWORD *)(db + 88LL * v51 + 40);
if ( (v52 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v52) & 0x2000000) != 0 || v51 == a1) )
goto LABEL_103;
LABEL_147:
v49 = *(_DWORD *)(db + v5 + 24);
v50 = db + 88LL * v49;
if ( (*(_BYTE *)(v50 + 45) & 1) != 0
&& ((*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v50 + 43) & 2) != 0 || v49 == a1) )
{
goto LABEL_103;
}
goto LABEL_108;
}
if ( (*(_BYTE *)(db + v5 + 47) & 0x20) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_118;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v46 = *(_DWORD *)(db + v5 + 40);
if ( (v46 & 0x200000) != 0 )
goto LABEL_103;
v47 = *(_DWORD *)(db + v5 + 24);
v48 = *(_DWORD *)(db + 88LL * v47 + 40);
if ( (v48 & 0x200000) != 0 )
{
if ( ((v48 | v46) & 0x2000000) != 0 || v47 == a1 )
goto LABEL_103;
goto LABEL_124;
}
}
v44 = *(_DWORD *)(db + v5 + 24);
v45 = *(_DWORD *)(db + 88LL * v44 + 40);
if ( (v45 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v45) & 0x2000000) != 0 || v44 == a1) )
goto LABEL_103;
}
LABEL_124:
v42 = *(_DWORD *)(db + v5 + 24);
v43 = db + 88LL * v42;
if ( (*(_BYTE *)(v43 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v43 + 43) & 2) != 0 || v42 == a1 )
goto LABEL_103;
v40 = *(_DWORD *)(db + v5 + 24);
v41 = 88LL * v40 + db;
if ( (*(_BYTE *)(v41 + 47) & 0x20) == 0 )
goto LABEL_106;
goto LABEL_129;
}
LABEL_118:
v40 = *(_DWORD *)(db + v5 + 24);
v41 = db + 88LL * v40;
if ( (*(_BYTE *)(v41 + 47) & 0x20) == 0 )
goto LABEL_106;
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 )
goto LABEL_103;
LABEL_129:
if ( (*(_BYTE *)(v41 + 43) & 2) != 0 || a1 == v40 )
goto LABEL_103;
goto LABEL_106;
}
}
LABEL_52:
result = 4LL;
}
LABEL_11:
if ( debugmem )
{
v7 = *(_DWORD *)(debugmem + 12LL);
if ( v7 <= 0 )
{
printf("Debug Stack Underflow! (line %d of fp %d)\n", 47LL, 58LL);
exit(1);
}
*(_DWORD *)(debugmem + 12LL) = v7 - 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 v1; // rax
int v2; // edx
__int64 v3; // rcx
int v4; // edx
__int64 v5; // rbp
__int64 result; // rax
int v7; // ecx
__int64 v8; // rbp
int v9; // edi
int v10; // edx
__int64 v11; // rsi
__int64 v12; // rcx
unsigned int v13; // eax
char v14; // dl
int v15; // esi
int v16; // ecx
int v17; // edx
int v18; // eax
int v19; // eax
int v20; // esi
int v21; // edx
int v22; // edx
__int64 v23; // rax
int v24; // edx
int v25; // eax
int v26; // eax
int v27; // ecx
int v28; // edx
int v29; // edx
__int64 v30; // rax
int v31; // edx
__int64 v32; // rax
int v33; // edx
int v34; // eax
int v35; // eax
int v36; // ecx
int v37; // edx
int v38; // edx
__int64 v39; // rax
int v40; // edx
__int64 v41; // rax
int v42; // edx
__int64 v43; // rax
int v44; // edx
int v45; // eax
int v46; // eax
int v47; // ecx
int v48; // edx
int v49; // edx
__int64 v50; // rax
int v51; // edx
int v52; // eax
int v53; // eax
int v54; // ecx
int v55; // edx
int v56; // edx
int v57; // eax
int v58; // eax
int v59; // ecx
int v60; // edx

v1 = debugmem;
if ( debugmem )
{
v2 = *(_DWORD *)(debugmem + 12LL);
if ( v2 > 999 )
{
printf("Debug Stack Overflow! (line %d of fp %d)\n", 26LL, 58LL);
exit(1);
}
v3 = v2 + 2LL;
*(_DWORD *)(debugmem + 8 * v3 + 4) = 58;
v4 = v2 + 1;
*(_DWORD *)(v1 + 12) = v4;
*(_DWORD *)(v1 + 8 * v3 + 8) = 26;
if ( *(_DWORD *)(v1 + 16) >= v4 )
v4 = *(_DWORD *)(v1 + 16);
*(_DWORD *)(v1 + 16) = v4;
}
if ( (a1 & 0x80000000) != 0 )
return 0LL;
if ( mudstate[1830] <= (signed int)a1 )
return 0LL;
v5 = 88LL * (int)a1;
if ( (*(_DWORD *)(db + v5 + 40) & 7u) > 4 )
return 0LL;
if ( (*(_QWORD *)(db + v5 + 40) & 0x40000000004000LL) != 0 )
return 0LL;
result = 7LL;
if ( a1 != 1 )
{
if ( (unsigned int)evlevchk(a1, 5LL) )
{
result = 6LL;
if ( mudstate[2077] )
goto LABEL_11;
}
else
{
v13 = *(_DWORD *)(db + v5 + 40);
v14 = 1;
if ( (v13 & 0x200000) == 0 )
{
v15 = *(_DWORD *)(db + v5 + 24);
v16 = *(_DWORD *)(db + 88LL * v15 + 40);
v14 = 0;
if ( (v16 & 0x200000) != 0 )
v14 = ((v15 == a1) | ((v16 | v13) >> 25)) & 1;
}
result = 6LL;
if ( (v14 & 1) != 0 )
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 4LL) )
{
result = 5LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_19;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
{
LABEL_39:
result = 5LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_39;
}
else
{
v19 = *(_DWORD *)(db + v5 + 40);
if ( (v19 & 0x200000) != 0 )
goto LABEL_39;
v20 = *(_DWORD *)(db + v5 + 24);
v21 = *(_DWORD *)(db + 88LL * v20 + 40);
if ( (v21 & 0x200000) != 0 && (((v21 | v19) & 0x2000000) != 0 || v20 == a1) )
goto LABEL_39;
}
v17 = *(_DWORD *)(db + v5 + 24);
v18 = *(_DWORD *)(db + 88LL * v17 + 40);
if ( (v18 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v18) & 0x2000000) != 0 || v17 == a1) )
{
result = 5LL;
goto LABEL_11;
}
LABEL_19:
if ( (unsigned int)evlevchk(a1, 3LL) )
{
result = 4LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_21;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) == 0 )
{
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_52;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_52;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_52;
}
else
{
v26 = *(_DWORD *)(db + v5 + 40);
if ( (v26 & 0x200000) != 0 )
goto LABEL_52;
v27 = *(_DWORD *)(db + v5 + 24);
v28 = *(_DWORD *)(db + 88LL * v27 + 40);
if ( (v28 & 0x200000) != 0 && (((v28 | v26) & 0x2000000) != 0 || v27 == a1) )
goto LABEL_52;
}
v24 = *(_DWORD *)(db + v5 + 24);
v25 = *(_DWORD *)(db + 88LL * v24 + 40);
if ( (v25 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v25) & 0x2000000) != 0 || v24 == a1) )
goto LABEL_52;
}
v22 = *(_DWORD *)(db + v5 + 24);
v23 = db + 88LL * v22;
if ( (*(_BYTE *)(v23 + 45) & 1) == 0 )
goto LABEL_21;
if ( (*(_BYTE *)(db + v5 + 43) & 2) == 0 )
{
if ( (*(_BYTE *)(v23 + 43) & 2) != 0 || v22 == a1 )
{
result = 4LL;
goto LABEL_11;
}
LABEL_21:
if ( (unsigned int)evlevchk(a1, 2LL) )
{
result = 3LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_23;
}
if ( (*(_BYTE *)(db + v5 + 47) & 0x20) != 0 )
{
LABEL_73:
result = 3LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
goto LABEL_76;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_73;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_73;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_73;
}
else
{
v35 = *(_DWORD *)(db + v5 + 40);
if ( (v35 & 0x200000) != 0 )
goto LABEL_73;
v36 = *(_DWORD *)(db + v5 + 24);
v37 = *(_DWORD *)(db + 88LL * v36 + 40);
if ( (v37 & 0x200000) != 0 )
{
if ( ((v37 | v35) & 0x2000000) != 0 || v36 == a1 )
goto LABEL_73;
goto LABEL_82;
}
}
v33 = *(_DWORD *)(db + v5 + 24);
v34 = *(_DWORD *)(db + 88LL * v33 + 40);
if ( (v34 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v34) & 0x2000000) != 0 || v33 == a1) )
goto LABEL_73;
}
LABEL_82:
v31 = *(_DWORD *)(db + v5 + 24);
v32 = db + 88LL * v31;
if ( (*(_BYTE *)(v32 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v32 + 43) & 2) != 0 || v31 == a1 )
goto LABEL_73;
v29 = *(_DWORD *)(db + v5 + 24);
v30 = 88LL * v29 + db;
if ( (*(_BYTE *)(v30 + 47) & 0x20) == 0 )
goto LABEL_23;
goto LABEL_87;
}
LABEL_76:
v29 = *(_DWORD *)(db + v5 + 24);
v30 = db + 88LL * v29;
if ( (*(_BYTE *)(v30 + 47) & 0x20) == 0 )
goto LABEL_23;
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 )
goto LABEL_73;
LABEL_87:
if ( (*(_BYTE *)(v30 + 43) & 2) != 0 || a1 == v29 )
{
result = 3LL;
goto LABEL_11;
}
LABEL_23:
if ( (unsigned int)evlevchk(a1, 1LL) )
{
result = 2LL;
if ( mudstate[2077] )
goto LABEL_11;
goto LABEL_25;
}
if ( (*(_BYTE *)(db + v5 + 45) & 4) != 0 )
{
LABEL_103:
result = 2LL;
goto LABEL_11;
}
if ( (unsigned int)evlevchk(a1, 2LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
LABEL_106:
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
LABEL_108:
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_110;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v58 = *(_DWORD *)(db + v5 + 40);
if ( (v58 & 0x200000) != 0 )
goto LABEL_103;
v59 = *(_DWORD *)(db + v5 + 24);
v60 = *(_DWORD *)(db + 88LL * v59 + 40);
if ( (v60 & 0x200000) != 0 )
{
if ( ((v60 | v58) & 0x2000000) != 0 || v59 == a1 )
goto LABEL_103;
LABEL_110:
v38 = *(_DWORD *)(db + v5 + 24);
v39 = db + 88LL * v38;
if ( (*(_BYTE *)(v39 + 45) & 4) == 0 )
goto LABEL_25;
if ( (*(_BYTE *)(db + v5 + 43) & 2) == 0 )
{
if ( (*(_BYTE *)(v39 + 43) & 2) != 0 || v38 == a1 )
{
result = 2LL;
goto LABEL_11;
}
LABEL_25:
v8 = db + v5;
v9 = *(_DWORD *)(v8 + 44);
result = v9 & 0x1000000;
if ( (v9 & 0x1000000) != 0 )
{
result = 0LL;
goto LABEL_11;
}
v10 = *(_DWORD *)(v8 + 24);
if ( v10 < 0 )
{
result = (v9 & 0x200000) == 0;
goto LABEL_11;
}
if ( v10 >= mudstate[1830] )
{
if ( (v9 & 0x200000) != 0 )
goto LABEL_11;
result = 1LL;
if ( v10 >= mudstate[1830] )
goto LABEL_11;
}
else
{
v11 = db + 88LL * v10;
if ( (*(_DWORD *)(v11 + 40) & 7u) <= 4 && (*(_BYTE *)(v11 + 47) & 1) != 0 || (v9 & 0x200000) != 0 )
goto LABEL_11;
}
v12 = 88LL * v10 + db;
result = 1LL;
if ( (*(_DWORD *)(v12 + 40) & 7u) <= 4 )
result = (*(_BYTE *)(v12 + 46) & 0x20) == 0;
goto LABEL_11;
}
goto LABEL_103;
}
}
v56 = *(_DWORD *)(db + v5 + 24);
v57 = *(_DWORD *)(db + 88LL * v56 + 40);
if ( (v57 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v57) & 0x2000000) != 0 || v56 == a1) )
goto LABEL_103;
goto LABEL_110;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_147;
}
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v53 = *(_DWORD *)(db + v5 + 40);
if ( (v53 & 0x200000) != 0 )
goto LABEL_103;
v54 = *(_DWORD *)(db + v5 + 24);
v55 = *(_DWORD *)(db + 88LL * v54 + 40);
if ( (v55 & 0x200000) != 0 )
{
if ( ((v55 | v53) & 0x2000000) != 0 || v54 == a1 )
goto LABEL_103;
goto LABEL_147;
}
}
v51 = *(_DWORD *)(db + v5 + 24);
v52 = *(_DWORD *)(db + 88LL * v51 + 40);
if ( (v52 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v52) & 0x2000000) != 0 || v51 == a1) )
goto LABEL_103;
LABEL_147:
v49 = *(_DWORD *)(db + v5 + 24);
v50 = db + 88LL * v49;
if ( (*(_BYTE *)(v50 + 45) & 1) != 0
&& ((*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v50 + 43) & 2) != 0 || v49 == a1) )
{
goto LABEL_103;
}
goto LABEL_108;
}
if ( (*(_BYTE *)(db + v5 + 47) & 0x20) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 3LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
goto LABEL_118;
}
if ( (*(_BYTE *)(db + v5 + 45) & 1) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 4LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
if ( (*(_BYTE *)(db + v5 + 40) & 0x10) != 0 )
goto LABEL_103;
if ( (unsigned int)evlevchk(a1, 5LL) )
{
if ( mudstate[2077] )
goto LABEL_103;
}
else
{
v46 = *(_DWORD *)(db + v5 + 40);
if ( (v46 & 0x200000) != 0 )
goto LABEL_103;
v47 = *(_DWORD *)(db + v5 + 24);
v48 = *(_DWORD *)(db + 88LL * v47 + 40);
if ( (v48 & 0x200000) != 0 )
{
if ( ((v48 | v46) & 0x2000000) != 0 || v47 == a1 )
goto LABEL_103;
goto LABEL_124;
}
}
v44 = *(_DWORD *)(db + v5 + 24);
v45 = *(_DWORD *)(db + 88LL * v44 + 40);
if ( (v45 & 0x10) != 0 && (((*(_DWORD *)(db + v5 + 40) | v45) & 0x2000000) != 0 || v44 == a1) )
goto LABEL_103;
}
LABEL_124:
v42 = *(_DWORD *)(db + v5 + 24);
v43 = db + 88LL * v42;
if ( (*(_BYTE *)(v43 + 45) & 1) != 0 )
{
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 || (*(_BYTE *)(v43 + 43) & 2) != 0 || v42 == a1 )
goto LABEL_103;
v40 = *(_DWORD *)(db + v5 + 24);
v41 = 88LL * v40 + db;
if ( (*(_BYTE *)(v41 + 47) & 0x20) == 0 )
goto LABEL_106;
goto LABEL_129;
}
LABEL_118:
v40 = *(_DWORD *)(db + v5 + 24);
v41 = db + 88LL * v40;
if ( (*(_BYTE *)(v41 + 47) & 0x20) == 0 )
goto LABEL_106;
if ( (*(_BYTE *)(db + v5 + 43) & 2) != 0 )
goto LABEL_103;
LABEL_129:
if ( (*(_BYTE *)(v41 + 43) & 2) != 0 || a1 == v40 )
goto LABEL_103;
goto LABEL_106;
}
}
LABEL_52:
result = 4LL;
}
LABEL_11:
if ( debugmem )
{
v7 = *(_DWORD *)(debugmem + 12LL);
if ( v7 <= 0 )
{
printf("Debug Stack Underflow! (line %d of fp %d)\n", 47LL, 58LL);
exit(1);
}
*(_DWORD *)(debugmem + 12LL) = v7 - 1;
}
return result;
}

original_code:
int bittype(dbref player) {
  int level = 0;
  {if(debugmem && debugmem->stacktop < 1000) { debugmem->callstack[debugmem->stacktop].filenum = UTILS_C; debugmem->callstack[debugmem->stacktop++].linenum = 26; debugmem->stackval = (debugmem->stacktop > debugmem->stackval ? debugmem->stacktop : debugmem->stackval); } else if(debugmem) { printf("Debug Stack Overflow! (line %d of fp %d)\n", 26, UTILS_C); exit(1); }};
  if ( !((((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) && !((db[player].flags & 0x00004000) != 0) && !((db[player].flags2 & 0x00400000) != 0)) )
     return 0;
  if( ((player) == ((dbref) 1)) ) {
    level = 7;
  } else if( (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 6;
  } else if( (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 5;
  } else if( (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 4;
  } else if( (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 3;
  } else if( (evlevchk(player,1) ? mudstate.evalresult : ((db[player].flags2 & 0x00000400) || (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((dbref) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000400) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 2;
  } else if( (((db[player].flags2 & 0x01000000) != 0) || ((((db[player].owner) >= 0) && ((db[player].owner) < mudstate.db_top) && ((db[db[player].owner].flags & 0x7) <= 0x4)) && (db[db[player].owner].flags2 & 0x01000000) != 0)) || (((db[player].flags2 & 0x00200000) != 0) || ((((db[player].owner) >= 0) && ((db[player].owner) < mudstate.db_top) && ((db[db[player].owner].flags & 0x7) <= 0x4)) && (db[db[player].owner].flags2 & 0x00200000) != 0)) ) {
    level = 0;
  } else {
    level = 1;
  }
  {{if(debugmem && debugmem->stacktop > 0) { debugmem->stacktop--; } else if(debugmem) { printf("Debug Stack Underflow! (line %d of fp %d)\n",47, UTILS_C); exit(1); }}; return (level);};
}

canonical_original_code:
int bittype(int player) {
  int level = 0;
  {if(debugmem && debugmem->stacktop < 1000) { debugmem->callstack[debugmem->stacktop].filenum = UTILS_C; debugmem->callstack[debugmem->stacktop++].linenum = 26; debugmem->stackval = (debugmem->stacktop > debugmem->stackval ? debugmem->stacktop : debugmem->stackval); } else if(debugmem) { printf("Debug Stack Overflow! (line %d of fp %d)\n", 26, UTILS_C); exit(1); }};
  if ( !((((player) >= 0) && ((player) < mudstate.db_top) && ((db[player].flags & 0x7) <= 0x4)) && !((db[player].flags & 0x00004000) != 0) && !((db[player].flags2 & 0x00400000) != 0)) )
     return 0;
  if( ((player) == ((int) 1)) ) {
    level = 7;
  } else if( (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 6;
  } else if( (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 5;
  } else if( (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 4;
  } else if( (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 3;
  } else if( (evlevchk(player,1) ? mudstate.evalresult : ((db[player].flags2 & 0x00000400) || (evlevchk(player,2) ? mudstate.evalresult : ((db[player].flags2 & 0x20000000) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x20000000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || (evlevchk(player,3) ? mudstate.evalresult : ((db[player].flags2 & 0x00000100) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000100) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || (evlevchk(player,4) ? mudstate.evalresult : ((db[player].flags & 0x00000010) || (evlevchk(player,5) ? mudstate.evalresult : ((db[player].flags & 0x00200000) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00200000) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((player) == ((int) 1)) || ((db[db[player].owner].flags & 0x00000010) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) || ((db[db[player].owner].flags2 & 0x00000400) && (((db[player].flags & 0x02000000) != 0) || ((db[db[player].owner].flags & 0x02000000) != 0) || ((player) == db[player].owner))))) ) {
    level = 2;
  } else if( (((db[player].flags2 & 0x01000000) != 0) || ((((db[player].owner) >= 0) && ((db[player].owner) < mudstate.db_top) && ((db[db[player].owner].flags & 0x7) <= 0x4)) && (db[db[player].owner].flags2 & 0x01000000) != 0)) || (((db[player].flags2 & 0x00200000) != 0) || ((((db[player].owner) >= 0) && ((db[player].owner) < mudstate.db_top) && ((db[db[player].owner].flags & 0x7) <= 0x4)) && (db[db[player].owner].flags2 & 0x00200000) != 0)) ) {
    level = 0;
  } else {
    level = 1;
  }
  {{if(debugmem && debugmem->stacktop > 0) { debugmem->stacktop--; } else if(debugmem) { printf("Debug Stack Underflow! (line %d of fp %d)\n",47, UTILS_C); exit(1); }}; return (level);};
}

variable_types: level int


decompiled_code:
void __fastcall log_db_err(unsigned int a1, unsigned int a2, __int64 a3)
{
if ( mudconf[2026] < 0 && (unsigned int)start_log("DBM", "ERROR") )
{
log_text("Could not ");
log_text(a3);
log_text(" object #");
log_number(a1);
if ( a2 != -1 )
{
log_text(" attr #");
log_number(a2);
}
end_log();
}
}

canonical_decompiled_code:
void __fastcall func0(unsigned int a1, unsigned int a2, __int64 a3)
{
if ( mudconf[2026] < 0 && (unsigned int)start_log("DBM", "ERROR") )
{
log_text("Could not ");
log_text(a3);
log_text(" object #");
log_number(a1);
if ( a2 != -1 )
{
log_text(" attr #");
log_number(a2);
}
end_log();
}
}

original_code:
void log_db_err (int obj, int attr, const char *txt)
{
 if ((((0x80000000) & mudconf.log_options) != 0) && start_log("DBM", "ERROR")) {
  log_text((char *)"Could not ");
  log_text((char *)txt);
  log_text((char *)" object #");
  log_number(obj);
  if (attr != (-1)) {
   log_text((char *)" attr #");
   log_number(attr);
  }
 end_log(); }
}

canonical_original_code:
void log_db_err(int obj, int attr, char *txt)
{
 if ((((0x80000000) & mudconf.log_options) != 0) && start_log("DBM", "ERROR")) {
  log_text((char *)"Could not ");
  log_text((char *)txt);
  log_text((char *)" object #");
  log_number(obj);
  if (attr != (-1)) {
   log_text((char *)" attr #");
   log_number(attr);
  }
 end_log(); }
}

variable_types: obj int

variable_types: attr int

variable_types:
txt
char *


shmConnect

decompiled_code:
void *__fastcall shmConnect(key_t key, int a2, int *a3)
{
int v4; // ebx
char *v5; // rax
void *result; // rax
int v7; // edi
int v8; // eax
int v9; // eax

v4 = a2 == 0 ? 448 : 1984;
*a3 = shmget(key, 0x1F54uLL, v4);
v5 = getenv("DEBUG_OVERRIDE");
if ( *a3 < 0 && v5 )
{
if ( strcmp(v5, "1") )
goto LABEL_10;
v9 = shmget(key, 0x1F54uLL, 960);
*a3 = v9;
if ( v9 < 0 )
{
fprintf(stderr, "** Warning - debug_id '%d' not able to be attached to ** \n", (unsigned int)key);
}
else if ( shmctl(v9, 0, 0LL) < 0 )
{
fprintf(stderr, "** Warning - debug_id '%d' was unable to be cleared **\n", (unsigned int)key);
}
else
{
fprintf(stderr, "** Warning - debug_id '%d' overridden and cleared **\n", (unsigned int)key);
}
*a3 = shmget(key, 0x1F54uLL, v4);
}
if ( *a3 >= 0 )
{
result = shmat(*a3, 0LL, 0);
v7 = 0;
if ( result == (void *)-1LL )
{
perror("** IPC Error (shmat)");
shmdt((const void *)0xFFFFFFFFFFFFFFFFLL);
shmctl(*a3, 0, 0LL);
v7 = 2;
result = 0LL;
}
goto LABEL_6;
}
LABEL_10:
v8 = *_errno_location();
if ( v8 == 17 )
{
fprintf(
stderr,
"** Error - possible clash detected for debug_id **\n** Shared memory region already exists for '%d' **\n",
(unsigned int)key);
v7 = 1;
result = 0LL;
}
else
{
if ( v8 != 2 )
{
perror("** IPC Error (shmget)");
v7 = 1;
if ( !a2 )
{
fwrite("** Try changing debug_id? ** \n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
LABEL_13:
exit(v7);
}
fprintf(stderr, "** No shared memory region could be found for debug_id '%d'**\n", (unsigned int)key);
v7 = 1;
result = 0LL;
}
LABEL_6:
if ( !result && a2 )
goto LABEL_13;
return result;
}

canonical_decompiled_code:
void *__fastcall func0(key_t key, int a2, int *a3)
{
int v4; // ebx
char *v5; // rax
void *result; // rax
int v7; // edi
int v8; // eax
int v9; // eax

v4 = a2 == 0 ? 448 : 1984;
*a3 = shmget(key, 0x1F54uLL, v4);
v5 = getenv("DEBUG_OVERRIDE");
if ( *a3 < 0 && v5 )
{
if ( strcmp(v5, "1") )
goto LABEL_10;
v9 = shmget(key, 0x1F54uLL, 960);
*a3 = v9;
if ( v9 < 0 )
{
fprintf(stderr, "** Warning - debug_id '%d' not able to be attached to ** \n", (unsigned int)key);
}
else if ( shmctl(v9, 0, 0LL) < 0 )
{
fprintf(stderr, "** Warning - debug_id '%d' was unable to be cleared **\n", (unsigned int)key);
}
else
{
fprintf(stderr, "** Warning - debug_id '%d' overridden and cleared **\n", (unsigned int)key);
}
*a3 = shmget(key, 0x1F54uLL, v4);
}
if ( *a3 >= 0 )
{
result = shmat(*a3, 0LL, 0);
v7 = 0;
if ( result == (void *)-1LL )
{
perror("** IPC Error (shmat)");
shmdt((const void *)0xFFFFFFFFFFFFFFFFLL);
shmctl(*a3, 0, 0LL);
v7 = 2;
result = 0LL;
}
goto LABEL_6;
}
LABEL_10:
v8 = *_errno_location();
if ( v8 == 17 )
{
fprintf(
stderr,
"** Error - possible clash detected for debug_id **\n** Shared memory region already exists for '%d' **\n",
(unsigned int)key);
v7 = 1;
result = 0LL;
}
else
{
if ( v8 != 2 )
{
perror("** IPC Error (shmget)");
v7 = 1;
if ( !a2 )
{
fwrite("** Try changing debug_id? ** \n", 1uLL, 0x1EuLL, stderr);
return 0LL;
}
LABEL_13:
exit(v7);
}
fprintf(stderr, "** No shared memory region could be found for debug_id '%d'**\n", (unsigned int)key);
v7 = 1;
result = 0LL;
}
LABEL_6:
if ( !result && a2 )
goto LABEL_13;
return result;
}

original_code:
Debugmem * shmConnect(int debug_id, int bCreate, int *pShmid) {
  char *shm = ((void *)0), *env_var = ((void *)0);
  int exitCode = 0;
  int mask = 0700;
  if (bCreate) mask |= 01000 | 02000;
  (*pShmid) = shmget(debug_id, sizeof(Debugmem), mask );
  env_var = getenv("DEBUG_OVERRIDE");
  if ( ((*pShmid) < 0) && (env_var != ((void *)0)) && (strcmp(env_var, "1") == 0) ) {
     (*pShmid) = shmget(debug_id, sizeof(Debugmem), (0700 | 01000) );
     if ( (*pShmid) < 0 ) {
        fprintf(stderr, "** Warning - debug_id '%d' not able to be attached to ** \n", debug_id);
     } else {
        exitCode = shmctl((*pShmid), 0, ((void *)0));
        if ( exitCode < 0 )
           fprintf(stderr, "** Warning - debug_id '%d' was unable to be cleared **\n", debug_id);
        else
           fprintf(stderr, "** Warning - debug_id '%d' overridden and cleared **\n", debug_id);
        exitCode = 0;
     }
     (*pShmid) = shmget(debug_id, sizeof(Debugmem), mask );
  }
  if ((*pShmid) < 0 ) {
    if ((*__errno_location ()) == 17) {
      fprintf(stderr,
       "** Error - possible clash detected for debug_id **\n"
       "** Shared memory region already exists for '%d' **\n", debug_id);
    } else if ((*__errno_location ()) == 2) {
      fprintf(stderr,
       "** No shared memory region could be found for debug_id '%d'**\n",
       debug_id);
    } else {
      perror("** IPC Error (shmget)");
      if (!bCreate) fprintf(stderr, "** Try changing debug_id? ** \n");
    }
    shm = ((void *)0);
    exitCode = 1;
  } else {
    if((shm = shmat((*pShmid), ((void *)0), 0)) == (char *) -1) {
      perror("** IPC Error (shmat)");
      shmdt(shm);
      shmctl((*pShmid), 0, ((void *)0));
      shm = ((void *)0);
      exitCode = 2;
    }
  }
  if (shm || !bCreate) {
    return (Debugmem *) shm;
  } else {
    exit(exitCode);
  }
}

canonical_original_code:
struct Debugmem *shmConnect(int debug_id, int bCreate, int *pShmid) {
  char *shm = ((void *)0); char *env_var = ((void *)0);
  int exitCode = 0;
  int mask = 0700;
  if (bCreate) mask |= 01000 | 02000;
  (*pShmid) = shmget(debug_id, sizeof(Debugmem), mask );
  env_var = getenv("DEBUG_OVERRIDE");
  if ( ((*pShmid) < 0) && (env_var != ((void *)0)) && (strcmp(env_var, "1") == 0) ) {
     (*pShmid) = shmget(debug_id, sizeof(Debugmem), (0700 | 01000) );
     if ( (*pShmid) < 0 ) {
        fprintf(stderr, "** Warning - debug_id '%d' not able to be attached to ** \n", debug_id);
     } else {
        exitCode = shmctl((*pShmid), 0, ((void *)0));
        if ( exitCode < 0 )
           fprintf(stderr, "** Warning - debug_id '%d' was unable to be cleared **\n", debug_id);
        else
           fprintf(stderr, "** Warning - debug_id '%d' overridden and cleared **\n", debug_id);
        exitCode = 0;
     }
     (*pShmid) = shmget(debug_id, sizeof(Debugmem), mask );
  }
  if ((*pShmid) < 0 ) {
    if ((*__errno_location ()) == 17) {
      fprintf(stderr,
       "** Error - possible clash detected for debug_id **\n"
       "** Shared memory region already exists for '%d' **\n", debug_id);
    } else if ((*__errno_location ()) == 2) {
      fprintf(stderr,
       "** No shared memory region could be found for debug_id '%d'**\n",
       debug_id);
    } else {
      perror("** IPC Error (shmget)");
      if (!bCreate) fprintf(stderr, "** Try changing debug_id? ** \n");
    }
    shm = ((void *)0);
    exitCode = 1;
  } else {
    if((shm = shmat((*pShmid), ((void *)0), 0)) == (char *) -1) {
      perror("** IPC Error (shmat)");
      shmdt(shm);
      shmctl((*pShmid), 0, ((void *)0));
      shm = ((void *)0);
      exitCode = 2;
    }
  }
  if (shm || !bCreate) {
    return (struct Debugmem *) shm;
  } else {
    exit(exitCode);
  }
}

variable_types: bCreate int

variable_types:
pShmid
int *

variable_types:
shm
char *

variable_types: exitCode int

variable_types: mask int

return_type: struct Debugmem { int mushport; int debugport; int lastdbfetch; int stacktop; int stackval; struct { int filenum; int linenum; } callstack[1000]; } *


sorttopics

original_code:
void sorttopics( void )
{
  int j, k;
  help_indx temp;
  for( j = 0; j < ntopics; j++ ) {
    for( k = j + 1; k < ntopics; k++ ) {
      if( strcmp(alltopicslc[j].topic, alltopicslc[k].topic) > 0 ) {
        memcpy( &temp, &alltopicslc[j], sizeof(help_indx));
        memcpy( &alltopicslc[j], &alltopicslc[k], sizeof(help_indx));
        memcpy( &alltopicslc[k], &temp, sizeof(help_indx));
        memcpy( &temp, &alltopics[j], sizeof(help_indx));
        memcpy( &alltopics[j], &alltopics[k], sizeof(help_indx));
        memcpy( &alltopics[k], &temp, sizeof(help_indx));
      }
    }
  }
}

canonical_original_code:
void sorttopics()
{
  int j; int k;
  struct help_indx temp;
  for( j = 0; j < ntopics; j++ ) {
    for( k = j + 1; k < ntopics; k++ ) {
      if( strcmp(alltopicslc[j].topic, alltopicslc[k].topic) > 0 ) {
        memcpy( &temp, &alltopicslc[j], sizeof(help_indx));
        memcpy( &alltopicslc[j], &alltopicslc[k], sizeof(help_indx));
        memcpy( &alltopicslc[k], &temp, sizeof(help_indx));
        memcpy( &temp, &alltopics[j], sizeof(help_indx));
        memcpy( &alltopics[j], &alltopics[k], sizeof(help_indx));
        memcpy( &alltopics[k], &temp, sizeof(help_indx));
      }
    }
  }
}

variable_types: j int

variable_types: k int

variable_types: struct help_indx { long pos; int len; char topic[-1]; }


decompiled_code:
__int64 __fastcall real_hashval(char *a1, unsigned int a2)
{
char v3; // al
int v4; // esi

if ( !a1 )
return 0LL;
v3 = *a1;
if ( *a1 )
{
v4 = 0;
do
{
v4 = v3 + 33 * v4;
v3 = *++a1;
}
while ( *a1 );
}
else
{
v4 = 0;
}
return v4 & a2;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, unsigned int a2)
{
char v3; // al
int v4; // esi

if ( !a1 )
return 0LL;
v3 = *a1;
if ( *a1 )
{
v4 = 0;
do
{
v4 = v3 + 33 * v4;
v3 = *++a1;
}
while ( *a1 );
}
else
{
v4 = 0;
}
return v4 & a2;
}

original_code:
int real_hashval(char *str, int hashmask, const char *fileName, int lineNo)
{
    int hash;
    char *sp;
    if (str == ((void *)0))
 return 0;
    hash = 0;
    for (sp = str; *sp; sp++)
 hash = (hash << 5) + hash + *sp;
    return (hash & hashmask);
}

canonical_original_code:
int real_hashval(char *str, int hashmask, char *fileName, int lineNo)
{
    int hash;
    char *sp;
    if (str == ((void *)0))
 return 0;
    hash = 0;
    for (sp = str; *sp; sp++)
 hash = (hash << 5) + hash + *sp;
    return (hash & hashmask);
}

variable_types:
str
char *

variable_types: hashmask int

variable_types:
fileName
char *

variable_types: lineNo int

variable_types: hash int

variable_types:
sp
char *


info

decompiled_code:
int __fastcall info(int a1, int a2, unsigned int a3)
{
const char *v4; // rdx

if ( a1 == 3 )
{
v4 = "TinyMUD";
}
else if ( a1 > 3 )
{
v4 = "*unknown*";
if ( a1 == 4 )
v4 = "TinyMUCK";
}
else
{
v4 = "TinyMUSH";
if ( a1 != 1 )
{
v4 = "*unknown*";
if ( a1 == 2 )
v4 = "TinyMUSE";
}
}
fprintf(stderr, "%s version %d:", v4, a3);
if ( (a2 & 0x100) != 0 )
fwrite(" Zone", 1uLL, 5uLL, stderr);
if ( (a2 & 0x200) != 0 )
fwrite(" Link", 1uLL, 5uLL, stderr);
if ( (a2 & 0x400) != 0 )
fwrite(" GDBM", 1uLL, 5uLL, stderr);
if ( (a2 & 0x800) != 0 )
fwrite(" AtrName", 1uLL, 8uLL, stderr);
if ( (a2 & 0x1000) != 0 )
{
if ( a1 == 1 && a3 == 2 )
fwrite(" ExtLocks", 1uLL, 9uLL, stderr);
else
fwrite(" AtrKey", 1uLL, 7uLL, stderr);
}
if ( (a2 & 0x2000) != 0 )
fwrite(" Parent", 1uLL, 7uLL, stderr);
if ( (a2 & 0x4000) != 0 )
fwrite(" Comm", 1uLL, 5uLL, stderr);
if ( (a2 & 0x8000) != 0 )
fwrite(" AtrMoney", 1uLL, 9uLL, stderr);
if ( (a2 & 0x10000) != 0 )
fwrite(" ExtFlags", 1uLL, 9uLL, stderr);
return fputc(10, stderr);
}

canonical_decompiled_code:
int __fastcall func0(int a1, int a2, unsigned int a3)
{
const char *v4; // rdx

if ( a1 == 3 )
{
v4 = "TinyMUD";
}
else if ( a1 > 3 )
{
v4 = "*unknown*";
if ( a1 == 4 )
v4 = "TinyMUCK";
}
else
{
v4 = "TinyMUSH";
if ( a1 != 1 )
{
v4 = "*unknown*";
if ( a1 == 2 )
v4 = "TinyMUSE";
}
}
fprintf(stderr, "%s version %d:", v4, a3);
if ( (a2 & 0x100) != 0 )
fwrite(" Zone", 1uLL, 5uLL, stderr);
if ( (a2 & 0x200) != 0 )
fwrite(" Link", 1uLL, 5uLL, stderr);
if ( (a2 & 0x400) != 0 )
fwrite(" GDBM", 1uLL, 5uLL, stderr);
if ( (a2 & 0x800) != 0 )
fwrite(" AtrName", 1uLL, 8uLL, stderr);
if ( (a2 & 0x1000) != 0 )
{
if ( a1 == 1 && a3 == 2 )
fwrite(" ExtLocks", 1uLL, 9uLL, stderr);
else
fwrite(" AtrKey", 1uLL, 7uLL, stderr);
}
if ( (a2 & 0x2000) != 0 )
fwrite(" Parent", 1uLL, 7uLL, stderr);
if ( (a2 & 0x4000) != 0 )
fwrite(" Comm", 1uLL, 5uLL, stderr);
if ( (a2 & 0x8000) != 0 )
fwrite(" AtrMoney", 1uLL, 9uLL, stderr);
if ( (a2 & 0x10000) != 0 )
fwrite(" ExtFlags", 1uLL, 9uLL, stderr);
return fputc(10, stderr);
}

original_code:
void
info(int fmt, int flags, int ver)
{
    const char *cp;
    switch (fmt) {
    case 1:
 cp = "TinyMUSH";
 break;
    case 2:
 cp = "TinyMUSE";
 break;
    case 3:
 cp = "TinyMUD";
 break;
    case 4:
 cp = "TinyMUCK";
 break;
    default:
 cp = "*unknown*";
 break;
    }
    fprintf(stderr, "%s version %d:", cp, ver);
    if (flags & 0x00000100)
 fprintf(stderr, " Zone");
    if (flags & 0x00000200)
 fprintf(stderr, " Link");
    if (flags & 0x00000400)
 fprintf(stderr, " GDBM");
    if (flags & 0x00000800)
 fprintf(stderr, " AtrName");
    if (flags & 0x00001000) {
 if ((fmt == 1) && (ver == 2))
     fprintf(stderr, " ExtLocks");
 else
     fprintf(stderr, " AtrKey");
    }
    if (flags & 0x00002000)
 fprintf(stderr, " Parent");
    if (flags & 0x00004000)
 fprintf(stderr, " Comm");
    if (flags & 0x00008000)
 fprintf(stderr, " AtrMoney");
    if (flags & 0x00010000)
 fprintf(stderr, " ExtFlags");
    fprintf(stderr, "\n");
}

canonical_original_code:
void info(int fmt, int flags, int ver)
{
    char *cp;
    switch (fmt) {
    case 1:
 cp = "TinyMUSH";
 break;
    case 2:
 cp = "TinyMUSE";
 break;
    case 3:
 cp = "TinyMUD";
 break;
    case 4:
 cp = "TinyMUCK";
 break;
    default:
 cp = "*unknown*";
 break;
    }
    fprintf(stderr, "%s version %d:", cp, ver);
    if (flags & 0x00000100)
 fprintf(stderr, " Zone");
    if (flags & 0x00000200)
 fprintf(stderr, " Link");
    if (flags & 0x00000400)
 fprintf(stderr, " GDBM");
    if (flags & 0x00000800)
 fprintf(stderr, " AtrName");
    if (flags & 0x00001000) {
 if ((fmt == 1) && (ver == 2))
     fprintf(stderr, " ExtLocks");
 else
     fprintf(stderr, " AtrKey");
    }
    if (flags & 0x00002000)
 fprintf(stderr, " Parent");
    if (flags & 0x00004000)
 fprintf(stderr, " Comm");
    if (flags & 0x00008000)
 fprintf(stderr, " AtrMoney");
    if (flags & 0x00010000)
 fprintf(stderr, " ExtFlags");
    fprintf(stderr, "\n");
}

variable_types: fmt int

variable_types: flags int

variable_types: ver int

variable_types:
cp
char *


usage

decompiled_code:
size_t __fastcall usage(const char *a1)
{
fprintf(stderr, "Usage: %s gdbm-file [flags] [<in-file] [>out-file]\n", a1);
fwrite(" Available flags are:\n", 1uLL, 0x18uLL, stderr);
fwrite(" C - Perform consistency check\n", 1uLL, 0x24uLL, stderr);
fwrite(" G - Write in gdbm format g - Write in flat file format\n", 1uLL, 0x44uLL, stderr);
fwrite(" K - Store key as an attribute k - Store key in the header\n", 1uLL, 0x42uLL, stderr);
fwrite(" L - Include link information l - Don't include link information\n", 1uLL, 0x49uLL, stderr);
fwrite(" M - Store attr map if GDBM m - Don't store attr map if GDBM\n", 1uLL, 0x47uLL, stderr);
fwrite(" N - Store name as an attribute n - Store name in the header\n", 1uLL, 0x43uLL, stderr);
fwrite(" P - Include parent information p - Don't include parent information\n", 1uLL, 0x4BuLL, stderr);
fwrite(" W - Write the output file b w - Don't write the output file.\n", 1uLL, 0x47uLL, stderr);
fwrite(" X - Create a default GDBM db x - Create a default flat file db\n", 1uLL, 0x48uLL, stderr);
fwrite(" Z - Include zone information z - Don't include zone information\n", 1uLL, 0x49uLL, stderr);
return fwrite(" <number> - Set output version number\n", 1uLL, 0x2BuLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func1(const char *a1)
{
fprintf(stderr, "Usage: %s gdbm-file [flags] [<in-file] [>out-file]\n", a1);
fwrite(" Available flags are:\n", 1uLL, 0x18uLL, stderr);
fwrite(" C - Perform consistency check\n", 1uLL, 0x24uLL, stderr);
fwrite(" G - Write in gdbm format g - Write in flat file format\n", 1uLL, 0x44uLL, stderr);
fwrite(" K - Store key as an attribute k - Store key in the header\n", 1uLL, 0x42uLL, stderr);
fwrite(" L - Include link information l - Don't include link information\n", 1uLL, 0x49uLL, stderr);
fwrite(" M - Store attr map if GDBM m - Don't store attr map if GDBM\n", 1uLL, 0x47uLL, stderr);
fwrite(" N - Store name as an attribute n - Store name in the header\n", 1uLL, 0x43uLL, stderr);
fwrite(" P - Include parent information p - Don't include parent information\n", 1uLL, 0x4BuLL, stderr);
fwrite(" W - Write the output file b w - Don't write the output file.\n", 1uLL, 0x47uLL, stderr);
fwrite(" X - Create a default GDBM db x - Create a default flat file db\n", 1uLL, 0x48uLL, stderr);
fwrite(" Z - Include zone information z - Don't include zone information\n", 1uLL, 0x49uLL, stderr);
return fwrite(" <number> - Set output version number\n", 1uLL, 0x2BuLL, stderr);
}

original_code:
void
usage(char *prog)
{
    fprintf(stderr, "Usage: %s gdbm-file [flags] [<in-file] [>out-file]\n", prog);
    fprintf(stderr, "   Available flags are:\n");
    fprintf(stderr, "      C - Perform consistency check\n");
    fprintf(stderr, "      G - Write in gdbm format        g - Write in flat file format\n");
    fprintf(stderr, "      K - Store key as an attribute   k - Store key in the header\n");
    fprintf(stderr, "      L - Include link information    l - Don't include link information\n");
    fprintf(stderr, "      M - Store attr map if GDBM      m - Don't store attr map if GDBM\n");
    fprintf(stderr, "      N - Store name as an attribute  n - Store name in the header\n");
    fprintf(stderr, "      P - Include parent information  p - Don't include parent information\n");
    fprintf(stderr, "      W - Write the output file  b    w - Don't write the output file.\n");
    fprintf(stderr, "      X - Create a default GDBM db    x - Create a default flat file db\n");
    fprintf(stderr, "      Z - Include zone information    z - Don't include zone information\n");
    fprintf(stderr, "      <number> - Set output version number\n");
}

variable_types:
prog
char *


strpcmp

decompiled_code:
int __fastcall strpcmp(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

canonical_decompiled_code:
int __fastcall func0(const void *a1, const void *a2)
{
return strcmp(*(const char **)a1, *(const char **)a2);
}

original_code:
int strpcmp(const void *ap, const void *bp){
  char *a, *b;
  a = *(char **)ap;
  b = *(char **)bp;
  return strcmp(a, b);
}

canonical_original_code:
int strpcmp(void *ap, void *bp){
  char *a; char *b;
  a = *(char **)ap;
  b = *(char **)bp;
  return strcmp(a, b);
}

variable_types:
ap
void *

variable_types:
bp
void *

variable_types:
a
char *

variable_types:
b
char *


usage

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
fprintf(stderr, "%s: usage: %s i|s|h|q|Q|p|ip|sp|hp|qp|Qp rnum\n", a1, a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(const char *a1)
{
fprintf(stderr, "%s: usage: %s i|s|h|q|Q|p|ip|sp|hp|qp|Qp rnum\n", a1, a1);
exit(1);
}

original_code:
void usage(const char *progname){
  fprintf(stderr, "%s: usage: %s i|s|h|q|Q|p|ip|sp|hp|qp|Qp rnum\n", progname, progname);
  exit(1);
}

canonical_original_code:
void usage(char *progname){
  fprintf(stderr, "%s: usage: %s i|s|h|q|Q|p|ip|sp|hp|qp|Qp rnum\n", progname, progname);
  exit(1);
}

variable_types:
progname
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
const char **v4; // r14
const char **v5; // rbx
const char **v6; // r13
const char **v7; // rbp
int v8; // eax
unsigned int v9; // eax
char s[88]; // [rsp+10h] [rbp-58h] BYREF

if ( argc != 3 )
usage(*argv);
v3 = atoi(argv[2]);
if ( v3 <= 0 )
usage(*argv);
if ( !strchr("ishqQp", *argv[1]) )
usage(*argv);
v4 = (const char **)cbmalloc(8LL * v3);
v5 = v4;
v6 = &v4[v3];
v7 = v4;
do
{
v8 = rand();
v9 = sprintf(s, "%08d", (unsigned int)(v8 % v3 + 1));
*v7++ = (const char *)cbmemdup(s, v9);
}
while ( v7 != v6 );
switch ( *argv[1] )
{
case 'Q':
qsort(v4, v3, 8uLL, strpcmp);
break;
case 'h':
cbhsort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 'i':
cbisort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 'q':
cbqsort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 's':
cbssort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
default:
break;
}
if ( strchr(argv[1], 112) )
{
do
{
puts(*v5);
free((void *)*v5++);
}
while ( v5 != v6 );
}
else
{
do
free((void *)*v5++);
while ( v5 != v6 );
}
free(v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
const char **v4; // r14
const char **v5; // rbx
const char **v6; // r13
const char **v7; // rbp
int v8; // eax
unsigned int v9; // eax
char s[88]; // [rsp+10h] [rbp-58h] BYREF

if ( argc != 3 )
func1(*argv);
v3 = atoi(argv[2]);
if ( v3 <= 0 )
func1(*argv);
if ( !strchr("ishqQp", *argv[1]) )
func1(*argv);
v4 = (const char **)cbmalloc(8LL * v3);
v5 = v4;
v6 = &v4[v3];
v7 = v4;
do
{
v8 = rand();
v9 = sprintf(s, "%08d", (unsigned int)(v8 % v3 + 1));
*v7++ = (const char *)cbmemdup(s, v9);
}
while ( v7 != v6 );
switch ( *argv[1] )
{
case 'Q':
qsort(v4, v3, 8uLL, strpcmp);
break;
case 'h':
cbhsort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 'i':
cbisort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 'q':
cbqsort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
case 's':
cbssort(v4, (unsigned int)v3, 8LL, strpcmp);
break;
default:
break;
}
if ( strchr(argv[1], 112) )
{
do
{
puts(*v5);
free((void *)*v5++);
}
while ( v5 != v6 );
}
else
{
do
free((void *)*v5++);
while ( v5 != v6 );
}
free(v4);
return 0;
}

original_code:
int main(int argc, char **argv){
  int i, rnum, len;
  char **ivector, buf[32];
  if(argc != 3) usage(argv[0]);
  if((rnum = atoi(argv[2])) < 1) usage(argv[0]);
  if(!strchr("ishqQp", argv[1][0])) usage(argv[0]);
  ivector = cbmalloc(rnum * sizeof(ivector[0]));
  for(i = 0; i < rnum; i++){
    len = sprintf(buf, "%08d", rand() % rnum + i * 0 + 1);
    ivector[i] = cbmemdup(buf, len);
  }
  switch(argv[1][0]){
  case 'i':
    cbisort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 's':
    cbssort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'h':
    cbhsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'q':
    cbqsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'Q':
    qsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  }
  if(strchr(argv[1], 'p')){
    for(i = 0; i < rnum; i++){
      printf("%s\n", ivector[i]);
      free(ivector[i]);
    }
  } else {
    for(i = 0; i < rnum; i++){
      free(ivector[i]);
    }
  }
  free(ivector);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv){
  int i; int rnum; int len;
  char **ivector; char buf[32];
  if(argc != 3) usage(argv[0]);
  if((rnum = atoi(argv[2])) < 1) usage(argv[0]);
  if(!strchr("ishqQp", argv[1][0])) usage(argv[0]);
  ivector = cbmalloc(rnum * sizeof(ivector[0]));
  for(i = 0; i < rnum; i++){
    len = sprintf(buf, "%08d", rand() % rnum + i * 0 + 1);
    ivector[i] = cbmemdup(buf, len);
  }
  switch(argv[1][0]){
  case 'i':
    cbisort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 's':
    cbssort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'h':
    cbhsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'q':
    cbqsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  case 'Q':
    qsort(ivector, rnum, sizeof(ivector[0]), strpcmp);
    break;
  }
  if(strchr(argv[1], 'p')){
    for(i = 0; i < rnum; i++){
      printf("%s\n", ivector[i]);
      free(ivector[i]);
    }
  } else {
    for(i = 0; i < rnum; i++){
      free(ivector[i]);
    }
  }
  free(ivector);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types: rnum int

variable_types: len int

variable_types:
ivector
char **

variable_types:
buf
char [32]


canonical_decompiled_code:
char *func2(const char *a1, unsigned int a2, char *a3, __int64 *a4, const char *a5, ...)
{
char *v5; // r12
int v8; // ebx
int v9; // ebp
int v10; // eax
int v11; // er13
char *v12; // rbp
__int64 v13; // rsi
char *v14; // rax
bool v15; // cl
bool v16; // dl
gcc_va_list arg; // [rsp+10h] [rbp-108h] BYREF
char *v19; // [rsp+28h] [rbp-F0h] BYREF

va_start(arg, a5);
v5 = a3;
if ( !a3 )
{
v5 = (char *)func0();
v19 = v5;
a4 = (__int64 *)&v19;
}
v8 = func1(v5);
v9 = v8 - 1;
if ( v8 <= 0 )
fprintf(stderr, "ERR: (%s:%d) Unknown pool passed to safe_tprintf.\n", a1, a2);
else
v8 = (_DWORD)v5 + v9 - *(_DWORD *)a4;
if ( v8 < 0 )
{
fprintf(stderr, "WRN: (%s:%d) Zero length buffer in safe_tprintf.\n", a1, a2);
v8 = 0;
}
v10 = vsnprintf(v5, v8, a5, arg);
v11 = v10;
v12 = &v5[v9];
*v12 = 0;
if ( v10 < 0 )
fprintf(stderr, "ERR: (%s:%d) vsnprintf returned error code (%d).\n", a1, a2, (unsigned int)v10);
if ( v8 < v11 )
{
v13 = *a4;
if ( v12 != (char *)*a4 && v13 )
{
v14 = (char *)(v13 + 1);
do
{
v13 = (__int64)v14;
v15 = v12 != v14;
v16 = v14++ != 0LL;
}
while ( v16 && v15 );
}
*a4 = v13;
}
else
{
*a4 += v11 + 1LL;
}
return v5;
}

variable_types:
filename
char *

variable_types: lineNo int

variable_types:
buff
char *

variable_types:
bp
char **

variable_types:
format
char *

variable_types: length int

variable_types: end int

variable_types: ret int


getBufferSize

decompiled_code:
__int64 getBufferSize()
{
return 10000LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 10000LL;
}

original_code:
int getBufferSize(char *buffer) {
  return 10000;
}

variable_types:
buffer
char *


repo: kennyyu/workshop

decompiled_code:
__int64 __fastcall maximal_subarray_dumb(_DWORD *a1, int a2)
{
__int64 v4; // rbp
__int64 v5; // rbx
unsigned int v6; // edi
int v7; // edx
_DWORD *v8; // rax
int v9; // esi
_DWORD *v10; // rcx

if ( a2 <= 0 )
return 0LL;
v4 = (unsigned int)a2;
v5 = 0LL;
v6 = 0;
do
{
v9 = v5;
if ( a2 > (int)v5 )
{
v10 = a1 + 1;
do
{
v8 = a1;
v7 = 0;
if ( v9 >= (int)v5 )
{
do
v7 += *v8++;
while ( v8 != v10 );
}
if ( (int)v6 < v7 )
v6 = v7;
++v9;
++v10;
}
while ( a2 != v9 );
}
++v5;
++a1;
}
while ( v5 != v4 );
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, int a2)
{
__int64 v4; // rbp
__int64 v5; // rbx
unsigned int v6; // edi
int v7; // edx
_DWORD *v8; // rax
int v9; // esi
_DWORD *v10; // rcx

if ( a2 <= 0 )
return 0LL;
v4 = (unsigned int)a2;
v5 = 0LL;
v6 = 0;
do
{
v9 = v5;
if ( a2 > (int)v5 )
{
v10 = a1 + 1;
do
{
v8 = a1;
v7 = 0;
if ( v9 >= (int)v5 )
{
do
v7 += *v8++;
while ( v8 != v10 );
}
if ( (int)v6 < v7 )
v6 = v7;
++v9;
++v10;
}
while ( a2 != v9 );
}
++v5;
++a1;
}
while ( v5 != v4 );
return v6;
}

original_code:
int maximal_subarray_dumb(int *array, int n) {
  int max_sum = 0;
  for (int start = 0; start < n; start++) {
    for (int end = start; end < n; end++) {
      int sum = 0;
      for (int i = start; i <= end; i++) {
        sum += array[i];
      }
      max_sum = ((max_sum) > (sum) ? (max_sum) : (sum));
    }
  }
  return max_sum;
}

variable_types:
array
int *

variable_types: n int

variable_types: start int

variable_types: sum int


original_code:
int maximal_subarray_space(int *array, int n) {
  int *subproblems = (int *) malloc(n * sizeof(int));
  subproblems[0] = ((array[0]) > (0) ? (array[0]) : (0));
  for (int i = 1; i < n; i++) {
    subproblems[i] = ((subproblems[i-1] + array[i]) > (0) ? (subproblems[i-1] + array[i]) : (0));
  }
  int max = 0;
  for (int i = 0; i < n; i++) {
    max = ((max) > (subproblems[i]) ? (max) : (subproblems[i]));
  }
  free(subproblems);
  return max;
}

variable_types:
subproblems
int *

variable_types: i int

variable_types: max int


decompiled_code:
__int64 __fastcall maximal_subarray(_DWORD *a1, int a2)
{
_DWORD *v2; // rdx
__int64 v3; // rdi
int v4; // eax
int v5; // ecx

if ( a2 <= 0 )
{
v5 = 0;
}
else
{
v2 = a1;
v3 = (__int64)&a1[a2 - 1 + 1];
v4 = 0;
v5 = 0;
do
{
v4 += *v2;
if ( v4 < 0 )
v4 = 0;
if ( v5 < v4 )
v5 = v4;
++v2;
}
while ( v2 != (_DWORD *)v3 );
}
return (unsigned int)v5;
}

original_code:
int maximal_subarray(int *array, int n) {
  int max_sum_so_far = 0;
  int current_sum_so_far = 0;
  for (int i = 0; i < n; i++) {
    current_sum_so_far = ((current_sum_so_far + array[i]) > (0) ? (current_sum_so_far + array[i]) : (0));
    max_sum_so_far = ((max_sum_so_far) > (current_sum_so_far) ? (max_sum_so_far) : (current_sum_so_far));
  }
  return max_sum_so_far;
}


swap

decompiled_code:
__int64 __fastcall swap(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

original_code:
static inline void swap(int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}

variable_types:
x
int *

variable_types:
y
int *

variable_types: temp int


decompiled_code:
__int64 __fastcall my_random(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1) + a1);
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1, int a2)
{
return (unsigned int)(rand() % (a2 - a1) + a1);
}

original_code:
static inline int my_random(int i, int j) {
  return i + rand() % (j - i);
}

variable_types: j int


shuffle

decompiled_code:
void __fastcall shuffle(__int64 a1, int a2)
{
__int64 i; // rbx
int v3; // eax

if ( a2 > 0 )
{
for ( i = 0LL; i != a2; swap((_DWORD *)(a1 + 4 * i++), (_DWORD *)(a1 + 4LL * v3)) )
v3 = my_random(i, a2);
}
}

original_code:
void shuffle(int *array, int n) {
  for (int i = 0; i < n; i++) {
    swap(&array[i], &array[my_random(i, n)]);
  }
}


decompiled_code:
void __fastcall make_list(_DWORD *a1, int a2)
{
int v2; // eax
int v3; // esi

if ( a2 > 0 )
{
v2 = a2 / -2;
v3 = a2 - a2 / 2;
do
*a1++ = v2++;
while ( v2 != v3 );
}
}

canonical_decompiled_code:
void __fastcall func15(_DWORD *a1, int a2)
{
int v2; // eax
int v3; // esi

if ( a2 > 0 )
{
v2 = a2 / -2;
v3 = a2 - a2 / 2;
do
*a1++ = v2++;
while ( v2 != v3 );
}
}

original_code:
void make_list(int *array, int n) {
  int half = n / 2;
  for (int i = 0; i < n; i++) {
    array[i] = i - half;
  }
}

variable_types: half int


decompiled_code:
int __fastcall print_list(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
printf("%d ", *v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func16(unsigned int *a1, int a2)
{
unsigned int *v2; // rbx

if ( a2 > 0 )
{
v2 = a1;
do
printf("%d ", *v2++);
while ( v2 != &a1[a2 - 1 + 1] );
}
return putchar(10);
}

original_code:
void print_list(int *array, int n) {
  for (int i = 0; i < n; i++) {
    printf("%d ", array[i]);
  }
  printf("\n");
}


recurse

repo: kensmith/studies

decompiled_code:
int __fastcall recurse(int a1)
{
int v1; // ebx
int v2; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 7LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v1 = 0;
do
{
fputc(46, _bss_start);
++v1;
}
while ( GENUTIL_function_call_depth > v1 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "recurse(int depth)");
fflush(_bss_start);
++GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): ", "gentest.c", 8LL);
fprintf(_bss_start, "depth: %d", (unsigned int)a1);
fputc(10, _bss_start);
fflush(_bss_start);
if ( a1 > 0 )
{
puts("weeee!");
recurse((unsigned int)(a1 - 1));
}
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 15LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v2 = 0;
do
{
fputc(46, _bss_start);
++v2;
}
while ( GENUTIL_function_call_depth > v2 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "recurse(int depth)", 0LL);
return fflush(_bss_start);
}

canonical_decompiled_code:
int __fastcall func7(int a1)
{
int v1; // ebx
int v2; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 7LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v1 = 0;
do
{
fputc(46, _bss_start);
++v1;
}
while ( GENUTIL_function_call_depth > v1 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "recurse(int depth)");
fflush(_bss_start);
++GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): ", "gentest.c", 8LL);
fprintf(_bss_start, "depth: %d", (unsigned int)a1);
fputc(10, _bss_start);
fflush(_bss_start);
if ( a1 > 0 )
{
puts("weeee!");
func7((unsigned int)(a1 - 1));
}
--GENUTIL_function_call_depth;
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 15LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v2 = 0;
do
{
fputc(46, _bss_start);
++v2;
}
while ( GENUTIL_function_call_depth > v2 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "recurse(int depth)", 0LL);
return fflush(_bss_start);
}

original_code:
void recurse(int depth) {
 char *GENUTIL_function_name = "recurse(int depth)"; do { int GENUTIL_i; fprintf(stdout, "%s(%d): ENTERING", "gentest.c", 7); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s\n", GENUTIL_function_name); fflush(stdout); GENUTIL_function_call_depth++; } while (0);
 do { fprintf(stdout, "%s(%d): ", "gentest.c", 8); fprintf(stdout, "depth: %d", depth); fprintf(stdout, "\n"); fflush(stdout); } while (0);
 if (depth > 0) {
  printf("weeee!\n");
  recurse(depth - 1);
 }
 GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 15); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 0); fflush(stdout); } while (0);
 return;
}

variable_types: depth int


initialize

decompiled_code:
__int64 initialize()
{
int v0; // ebx
int v1; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 20LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v0 = 0;
do
{
fputc(46, _bss_start);
++v0;
}
while ( GENUTIL_function_call_depth > v0 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "initialize()");
fflush(_bss_start);
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 22LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v1 = 0;
do
{
fputc(46, _bss_start);
++v1;
}
while ( GENUTIL_function_call_depth > v1 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "initialize()", 4LL);
fflush(_bss_start);
return 4LL;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // ebx
int v1; // ebx

fprintf(_bss_start, "%s(%d): ENTERING", "gentest.c", 20LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v0 = 0;
do
{
fputc(46, _bss_start);
++v0;
}
while ( GENUTIL_function_call_depth > v0 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s\n", "initialize()");
fflush(_bss_start);
fprintf(_bss_start, "%s(%d): LEAVING", "gentest.c", 22LL);
if ( GENUTIL_function_call_depth < 0 )
{
fprintf(
_bss_start,
"genutil: The function call depth indicator fell to %d, this indicates that not\n"
"genutil: all of the functions are utilizing the entering_function and\n"
"genutil: leaving_function macros correctly. Make sure that all function\n"
"genutil: entrance points contain a call to entering_function and that all\n"
"genutil: function exit points contain a call to leaving_function.\n",
(unsigned int)GENUTIL_function_call_depth);
exit(-1);
}
fprintf(_bss_start, "(depth:%d)", (unsigned int)GENUTIL_function_call_depth);
if ( GENUTIL_function_call_depth > 0 )
{
v1 = 0;
do
{
fputc(46, _bss_start);
++v1;
}
while ( GENUTIL_function_call_depth > v1 );
}
fwrite("> ", 1uLL, 2uLL, _bss_start);
fprintf(_bss_start, "%s [%d]\n", "initialize()", 4LL);
fflush(_bss_start);
return 4LL;
}

original_code:
int initialize() {
 char *GENUTIL_function_name = "initialize()"; do { int GENUTIL_i; fprintf(stdout, "%s(%d): ENTERING", "gentest.c", 20); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s\n", GENUTIL_function_name); fflush(stdout); GENUTIL_function_call_depth++; } while (0);
 GENUTIL_function_call_depth--; do { int GENUTIL_i; fprintf(stdout, "%s(%d): LEAVING", "gentest.c", 22); if (GENUTIL_function_call_depth < 0) { fprintf(stdout,"genutil: The function call depth indicator fell to %d, this indicates that not\n" "genutil: all of the functions are utilizing the entering_function and\n" "genutil: leaving_function macros correctly.  Make sure that all function\n" "genutil: entrance points contain a call to entering_function and that all\n" "genutil: function exit points contain a call to leaving_function.\n", GENUTIL_function_call_depth); exit(-1); } fprintf(stdout, "(depth:%d)", GENUTIL_function_call_depth); for (GENUTIL_i = 0; GENUTIL_i < GENUTIL_function_call_depth; GENUTIL_i++) { fprintf(stdout, "."); } fprintf(stdout, "> "); fprintf(stdout, "%s [%d]\n", GENUTIL_function_name, (int) 4); fflush(stdout); } while (0);
 return 4;
}