selected

decompiled_code:
__int64 selected()
{
__int64 result; // rax
char **v1; // rbx
__int64 v2; // rbp

result = (unsigned int)dbug_on;
if ( dbug_on )
{
result = 0LL;
v1 = (char **)dbug_cfg;
v2 = *((_QWORD *)dbug_cfg + 10);
if ( *(_DWORD *)(v2 + 8) <= *((_DWORD *)dbug_cfg + 9) )
{
result = match_set(*((char **)dbug_cfg + 6), *((char **)dbug_cfg + 1));
if ( (_DWORD)result )
{
result = match_set(v1[7], *(char **)(*(_QWORD *)(v2 + 24) + 8LL));
if ( (_DWORD)result )
result = match_set(v1[8], *(char **)v2);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
char **v1; // rbx
__int64 v2; // rbp

result = (unsigned int)dbug_on;
if ( dbug_on )
{
result = 0LL;
v1 = (char **)dbug_cfg;
v2 = *((_QWORD *)dbug_cfg + 10);
if ( *(_DWORD *)(v2 + 8) <= *((_DWORD *)dbug_cfg + 9) )
{
result = func0(*((char **)dbug_cfg + 6), *((char **)dbug_cfg + 1));
if ( (_DWORD)result )
{
result = func0(v1[7], *(char **)(*(_QWORD *)(v2 + 24) + 8LL));
if ( (_DWORD)result )
result = func0(v1[8], *(char **)v2);
}
}
}
return result;
}

original_code:
static int
selected(void)
{
 return (dbug_on
      && (dbug_cfg->ctx->depth <= dbug_cfg->maxdepth)
      && match_set(dbug_cfg->proc_list, dbug_cfg->process)
      && match_set(dbug_cfg->unit_list, dbug_cfg->ctx->unit->unit)
      && match_set(dbug_cfg->fn_list, dbug_cfg->ctx->name));
}

canonical_original_code:
static int selected()
{
 return (dbug_on
      && (dbug_cfg->ctx->depth <= dbug_cfg->maxdepth)
      && match_set(dbug_cfg->proc_list, dbug_cfg->process)
      && match_set(dbug_cfg->unit_list, dbug_cfg->ctx->unit->unit)
      && match_set(dbug_cfg->fn_list, dbug_cfg->ctx->name));
}


decompiled_code:
int __fastcall call_trace(void **a1)
{
void **v2; // rdi
int result; // eax

if ( a1 && a1 != &base_ctx )
{
v2 = (void **)a1[4];
if ( v2 == &base_ctx || !v2 )
{
result = fprintf(*((FILE **)dbug_cfg + 3), "%.31s", (const char *)*a1);
}
else
{
call_trace();
result = fprintf(*((FILE **)dbug_cfg + 3), ",%.31s", (const char *)*a1);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(void **a1)
{
void **v2; // rdi
int result; // eax

if ( a1 && a1 != &base_ctx )
{
v2 = (void **)a1[4];
if ( v2 == &base_ctx || !v2 )
{
result = fprintf(*((FILE **)dbug_cfg + 3), "%.31s", (const char *)*a1);
}
else
{
func2();
result = fprintf(*((FILE **)dbug_cfg + 3), ",%.31s", (const char *)*a1);
}
}
return result;
}

original_code:
static void
call_trace(struct dbug_ctx_t *ctx)
{
 if (ctx && (ctx != &base_ctx)) {
  if (ctx->caller && (ctx->caller != &base_ctx)) {
   call_trace(ctx->caller);
   fprintf(dbug_cfg->output, ",%.31s", ctx->name);
  } else {
   fprintf(dbug_cfg->output, "%.31s", ctx->name);
  }
 }
 return;
}

variable_types: struct dbug_ctx_t { char *name; int depth; int line; char *keyword; struct dbug_unit_t { char *name; char *unit; } *unit; struct dbug_ctx_t *caller; } *

return_type: void

user_defined_types: struct dbug_ctx_t { char *name; int depth; int line; char *keyword; struct dbug_unit_t *unit; struct dbug_ctx_t *caller; }


decompiled_code:
char *__fastcall mk_string(const char *a1)
{
char v1; // al
const char *v2; // rsi
const char *v3; // rax
char v4; // dl
unsigned int v5; // eax
size_t v6; // rdx

v1 = *a1;
v2 = a1;
if ( *a1 == 44 )
{
v1 = a1[1];
v2 = a1 + 1;
}
if ( !v1 || v1 == 58 )
{
v6 = 0LL;
}
else
{
v3 = v2;
do
v4 = *++v3;
while ( v4 && v4 != 58 );
v5 = (_DWORD)v3 - (_DWORD)v2;
v6 = (int)v5;
if ( v5 >= 0x100 )
v6 = 255LL;
}
memset(buf_0, 0, sizeof(buf_0));
strncpy(buf_0, v2, v6);
return buf_0;
}

canonical_decompiled_code:
char *__fastcall func3(const char *a1)
{
char v1; // al
const char *v2; // rsi
const char *v3; // rax
char v4; // dl
unsigned int v5; // eax
size_t v6; // rdx

v1 = *a1;
v2 = a1;
if ( *a1 == 44 )
{
v1 = a1[1];
v2 = a1 + 1;
}
if ( !v1 || v1 == 58 )
{
v6 = 0LL;
}
else
{
v3 = v2;
do
v4 = *++v3;
while ( v4 && v4 != 58 );
v5 = (_DWORD)v3 - (_DWORD)v2;
v6 = (int)v5;
if ( v5 >= 0x100 )
v6 = 255LL;
}
memset(buf_0, 0, sizeof(buf_0));
strncpy(buf_0, v2, v6);
return buf_0;
}

original_code:
static char *
mk_string(char *p)
{
 static char buf[256];
 char *q;
 int n;
 if (*p == ',') {
  ++p;
 }
 for (q = p; *q && (*q != ':'); ++q)
  ;
 n = (int)(q - p);
 if (n > (sizeof(buf) - 1)) {
  n = (sizeof(buf) - 1);
 }
 memset(buf, '\0', sizeof(buf));
 strncpy(buf, p, n);
 return buf;
}

canonical_original_code:
static char *mk_string(char *p)
{
 static char buf[256];
 char *q;
 int n;
 if (*p == ',') {
  ++p;
 }
 for (q = p; *q && (*q != ':'); ++q)
  ;
 n = (int)(q - p);
 if (n > (sizeof(buf) - 1)) {
  n = (sizeof(buf) - 1);
 }
 memset(buf, '\0', sizeof(buf));
 strncpy(buf, p, n);
 return buf;
}

variable_types:
p
char *

variable_types:
buf
char [256]

variable_types:
q
char *

variable_types: n int

return_type: char *


prefix

decompiled_code:
int prefix()
{
int result; // eax
FILE **v1; // rdx
const char **v2; // rdi
int v3; // ebx
struct tm *v4; // rax
FILE *v5; // rdi
__int64 v6; // rdx
time_t timer; // [rsp+0h] [rbp-10h] BYREF

result = dbug_on;
if ( !dbug_on )
return result;
if ( (dbug_on & 0x100) != 0 )
{
v5 = (FILE *)*((_QWORD *)dbug_cfg + 3);
v6 = (unsigned int)(*((_DWORD *)dbug_cfg + 10) + 1);
*((_DWORD *)dbug_cfg + 10) = v6;
fprintf(v5, "%05d:", v6);
result = dbug_on;
if ( (dbug_on & 0x1000) == 0 )
{
LABEL_4:
if ( (result & 0x2000) == 0 )
goto LABEL_5;
goto LABEL_28;
}
}
else if ( (dbug_on & 0x1000) == 0 )
{
goto LABEL_4;
}
fprintf(*((FILE **)dbug_cfg + 3), "%.8s:", *((const char **)dbug_cfg + 1));
result = dbug_on;
if ( (dbug_on & 0x2000) == 0 )
{
LABEL_5:
if ( (result & 0x200) == 0 )
goto LABEL_6;
goto LABEL_26;
}
LABEL_28:
fprintf(*((FILE **)dbug_cfg + 3), "%05u:", *((unsigned int *)dbug_cfg + 4));
result = dbug_on;
if ( (dbug_on & 0x200) == 0 )
{
LABEL_6:
if ( (result & 0x400) == 0 )
goto LABEL_7;
goto LABEL_24;
}
LABEL_26:
time(&timer);
v4 = localtime(&timer);
fprintf(
*((FILE **)dbug_cfg + 3),
"%02d/%02d %02d.%02d.%02d:",
(unsigned int)(v4->tm_mon + 1),
(unsigned int)v4->tm_mday,
(unsigned int)v4->tm_hour,
(unsigned int)v4->tm_min,
(unsigned int)v4->tm_sec);
result = dbug_on;
if ( (dbug_on & 0x400) == 0 )
{
LABEL_7:
if ( (result & 0x800) == 0 )
goto LABEL_8;
goto LABEL_22;
}
LABEL_24:
fprintf(*((FILE **)dbug_cfg + 3), "%14.14s:", **(const char ***)(*((_QWORD *)dbug_cfg + 10) + 24LL));
result = dbug_on;
if ( (dbug_on & 0x800) == 0 )
{
LABEL_8:
if ( (result & 0x4000) == 0 )
goto LABEL_9;
goto LABEL_20;
}
LABEL_22:
fprintf(*((FILE **)dbug_cfg + 3), "%-5d ", *(unsigned int *)(*((_QWORD *)dbug_cfg + 10) + 12LL));
result = dbug_on;
if ( (dbug_on & 0x4000) == 0 )
{
LABEL_9:
if ( (result & 0x8000) == 0 )
goto LABEL_10;
goto LABEL_18;
}
LABEL_20:
fprintf(*((FILE **)dbug_cfg + 3), "%8.8s:", *(const char **)(*(_QWORD *)(*((_QWORD *)dbug_cfg + 10) + 24LL) + 8LL));
result = dbug_on;
if ( (dbug_on & 0x8000) == 0 )
{
LABEL_10:
v1 = (FILE **)dbug_cfg;
v2 = (const char **)*((_QWORD *)dbug_cfg + 10);
if ( (result & 4) == 0 )
goto LABEL_11;
LABEL_17:
call_trace((void **)v2);
return fputc(32, *((FILE **)dbug_cfg + 3));
}
LABEL_18:
fprintf(*((FILE **)dbug_cfg + 3), "%02d ", *(unsigned int *)(*((_QWORD *)dbug_cfg + 10) + 8LL));
v1 = (FILE **)dbug_cfg;
result = dbug_on;
v2 = (const char **)*((_QWORD *)dbug_cfg + 10);
if ( (dbug_on & 4) != 0 )
goto LABEL_17;
LABEL_11:
if ( (result & 2) == 0 )
return fprintf(v1[3], "%.31s ", *v2);
v3 = *((_DWORD *)v2 + 2);
if ( v3 > 0 )
{
while ( 1 )
{
result = fprintf(v1[3], "%-*s", *((_DWORD *)v1 + 8), "|");
if ( !--v3 )
break;
v1 = (FILE **)dbug_cfg;
}
}
return result;
}

canonical_decompiled_code:
int func6()
{
int result; // eax
FILE **v1; // rdx
const char **v2; // rdi
int v3; // ebx
struct tm *v4; // rax
FILE *v5; // rdi
__int64 v6; // rdx
time_t timer; // [rsp+0h] [rbp-10h] BYREF

result = dbug_on;
if ( !dbug_on )
return result;
if ( (dbug_on & 0x100) != 0 )
{
v5 = (FILE *)*((_QWORD *)dbug_cfg + 3);
v6 = (unsigned int)(*((_DWORD *)dbug_cfg + 10) + 1);
*((_DWORD *)dbug_cfg + 10) = v6;
fprintf(v5, "%05d:", v6);
result = dbug_on;
if ( (dbug_on & 0x1000) == 0 )
{
LABEL_4:
if ( (result & 0x2000) == 0 )
goto LABEL_5;
goto LABEL_28;
}
}
else if ( (dbug_on & 0x1000) == 0 )
{
goto LABEL_4;
}
fprintf(*((FILE **)dbug_cfg + 3), "%.8s:", *((const char **)dbug_cfg + 1));
result = dbug_on;
if ( (dbug_on & 0x2000) == 0 )
{
LABEL_5:
if ( (result & 0x200) == 0 )
goto LABEL_6;
goto LABEL_26;
}
LABEL_28:
fprintf(*((FILE **)dbug_cfg + 3), "%05u:", *((unsigned int *)dbug_cfg + 4));
result = dbug_on;
if ( (dbug_on & 0x200) == 0 )
{
LABEL_6:
if ( (result & 0x400) == 0 )
goto LABEL_7;
goto LABEL_24;
}
LABEL_26:
time(&timer);
v4 = localtime(&timer);
fprintf(
*((FILE **)dbug_cfg + 3),
"%02d/%02d %02d.%02d.%02d:",
(unsigned int)(v4->tm_mon + 1),
(unsigned int)v4->tm_mday,
(unsigned int)v4->tm_hour,
(unsigned int)v4->tm_min,
(unsigned int)v4->tm_sec);
result = dbug_on;
if ( (dbug_on & 0x400) == 0 )
{
LABEL_7:
if ( (result & 0x800) == 0 )
goto LABEL_8;
goto LABEL_22;
}
LABEL_24:
fprintf(*((FILE **)dbug_cfg + 3), "%14.14s:", **(const char ***)(*((_QWORD *)dbug_cfg + 10) + 24LL));
result = dbug_on;
if ( (dbug_on & 0x800) == 0 )
{
LABEL_8:
if ( (result & 0x4000) == 0 )
goto LABEL_9;
goto LABEL_20;
}
LABEL_22:
fprintf(*((FILE **)dbug_cfg + 3), "%-5d ", *(unsigned int *)(*((_QWORD *)dbug_cfg + 10) + 12LL));
result = dbug_on;
if ( (dbug_on & 0x4000) == 0 )
{
LABEL_9:
if ( (result & 0x8000) == 0 )
goto LABEL_10;
goto LABEL_18;
}
LABEL_20:
fprintf(*((FILE **)dbug_cfg + 3), "%8.8s:", *(const char **)(*(_QWORD *)(*((_QWORD *)dbug_cfg + 10) + 24LL) + 8LL));
result = dbug_on;
if ( (dbug_on & 0x8000) == 0 )
{
LABEL_10:
v1 = (FILE **)dbug_cfg;
v2 = (const char **)*((_QWORD *)dbug_cfg + 10);
if ( (result & 4) == 0 )
goto LABEL_11;
LABEL_17:
func2((void **)v2);
return fputc(32, *((FILE **)dbug_cfg + 3));
}
LABEL_18:
fprintf(*((FILE **)dbug_cfg + 3), "%02d ", *(unsigned int *)(*((_QWORD *)dbug_cfg + 10) + 8LL));
v1 = (FILE **)dbug_cfg;
result = dbug_on;
v2 = (const char **)*((_QWORD *)dbug_cfg + 10);
if ( (dbug_on & 4) != 0 )
goto LABEL_17;
LABEL_11:
if ( (result & 2) == 0 )
return fprintf(v1[3], "%.31s ", *v2);
v3 = *((_DWORD *)v2 + 2);
if ( v3 > 0 )
{
while ( 1 )
{
result = fprintf(v1[3], "%-*s", *((_DWORD *)v1 + 8), "|");
if ( !--v3 )
break;
v1 = (FILE **)dbug_cfg;
}
}
return result;
}

original_code:
static void
prefix(void)
{
 if (!dbug_on) {
  return;
 }
 if (dbug_on & (0x0100)) {
  fprintf(dbug_cfg->output, "%05d:", ++dbug_cfg->line_cnt);
 }
 if (dbug_on & (0x1000)) {
  fprintf(dbug_cfg->output, "%.8s:", dbug_cfg->process);
 }
 if (dbug_on & (0x2000)) {
  fprintf(dbug_cfg->output, "%05u:", dbug_cfg->proc_id);
 }
 if (dbug_on & (0x0200)) {
  time_t t;
  struct tm *tm;
  time(&t);
  tm = localtime(&t);
  fprintf(dbug_cfg->output, "%02d/%02d %02d.%02d.%02d:",
   tm->tm_mon + 1, tm->tm_mday,
   tm->tm_hour, tm->tm_min, tm->tm_sec);
 }
 if (dbug_on & (0x0400)) {
  fprintf(dbug_cfg->output, "%14.14s:",
   dbug_cfg->ctx->unit->name);
 }
 if (dbug_on & (0x0800)) {
  fprintf(dbug_cfg->output, "%-5d ", dbug_cfg->ctx->line);
 }
 if (dbug_on & (0x4000)) {
  fprintf(dbug_cfg->output, "%8.8s:",
   dbug_cfg->ctx->unit->unit);
 }
 if (dbug_on & (0x8000)) {
  fprintf(dbug_cfg->output, "%02d ", dbug_cfg->ctx->depth);
 }
 if (dbug_on & (0x0004)) {
  call_trace(dbug_cfg->ctx);
  fputc(' ', dbug_cfg->output);
 } else if (dbug_on & (0x0002)) {
  int i;
  for (i = dbug_cfg->ctx->depth; i > 0; --i) {
   fprintf(dbug_cfg->output, "%-*s",
    dbug_cfg->indent, "|");
  }
 } else {
  fprintf(dbug_cfg->output, "%.31s ", dbug_cfg->ctx->name);
 }
 return;
}

canonical_original_code:
static void prefix()
{
 if (!dbug_on) {
  return;
 }
 if (dbug_on & (0x0100)) {
  fprintf(dbug_cfg->output, "%05d:", ++dbug_cfg->line_cnt);
 }
 if (dbug_on & (0x1000)) {
  fprintf(dbug_cfg->output, "%.8s:", dbug_cfg->process);
 }
 if (dbug_on & (0x2000)) {
  fprintf(dbug_cfg->output, "%05u:", dbug_cfg->proc_id);
 }
 if (dbug_on & (0x0200)) {
  long t;
  struct tm *tm;
  time(&t);
  tm = localtime(&t);
  fprintf(dbug_cfg->output, "%02d/%02d %02d.%02d.%02d:",
   tm->tm_mon + 1, tm->tm_mday,
   tm->tm_hour, tm->tm_min, tm->tm_sec);
 }
 if (dbug_on & (0x0400)) {
  fprintf(dbug_cfg->output, "%14.14s:",
   dbug_cfg->ctx->unit->name);
 }
 if (dbug_on & (0x0800)) {
  fprintf(dbug_cfg->output, "%-5d ", dbug_cfg->ctx->line);
 }
 if (dbug_on & (0x4000)) {
  fprintf(dbug_cfg->output, "%8.8s:",
   dbug_cfg->ctx->unit->unit);
 }
 if (dbug_on & (0x8000)) {
  fprintf(dbug_cfg->output, "%02d ", dbug_cfg->ctx->depth);
 }
 if (dbug_on & (0x0004)) {
  call_trace(dbug_cfg->ctx);
  fputc(' ', dbug_cfg->output);
 } else if (dbug_on & (0x0002)) {
  int i;
  for (i = dbug_cfg->ctx->depth; i > 0; --i) {
   fprintf(dbug_cfg->output, "%-*s",
    dbug_cfg->indent, "|");
  }
 } else {
  fprintf(dbug_cfg->output, "%.31s ", dbug_cfg->ctx->name);
 }
 return;
}

variable_types: t long

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

variable_types: i int


decompiled_code:
void __noreturn io_error()
{
int *v0; // rax

v0 = _errno_location();
dbug_fatal("i/o error on dbug output file (errno=%d)", (unsigned int)*v0);
}

canonical_decompiled_code:
void __noreturn func7()
{
int *v0; // rax

v0 = _errno_location();
func4("i/o error on dbug output file (errno=%d)", (unsigned int)*v0);
}

original_code:
static void
io_error(void)
{
 dbug_fatal("i/o error on dbug output file (errno=%d)", (*__errno_location ()));
 return;
}

canonical_original_code:
static void io_error()
{
 dbug_fatal("i/o error on dbug output file (errno=%d)", (*__errno_location ()));
 return;
}


decompiled_code:
__int64 __fastcall dbug_keyword(char *s2)
{
__int64 result; // rax

result = selected();
if ( (_DWORD)result )
result = match_set(*((char **)dbug_cfg + 9), s2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *s2)
{
__int64 result; // rax

result = func1();
if ( (_DWORD)result )
result = func0(*((char **)dbug_cfg + 9), s2);
return result;
}

original_code:
int
dbug_keyword(char *key)
{
 return (selected() && match_set(dbug_cfg->kw_list, key));
}

variable_types:
key
char *

return_type: int


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

*((_QWORD *)dbug_cfg + 10) = a1;
result = selected();
if ( result )
{
if ( (dbug_on & 2) != 0 )
{
prefix();
fprintf(*((FILE **)dbug_cfg + 3), ">%.31s\n", *(const char **)a1);
result = fflush(*((FILE **)dbug_cfg + 3));
if ( result == -1 )
io_error();
}
}
++*(_DWORD *)(a1 + 8);
return result;
}

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

*((_QWORD *)dbug_cfg + 10) = a1;
result = func1();
if ( result )
{
if ( (dbug_on & 2) != 0 )
{
func6();
fprintf(*((FILE **)dbug_cfg + 3), ">%.31s\n", *(const char **)a1);
result = fflush(*((FILE **)dbug_cfg + 3));
if ( result == -1 )
func7();
}
}
++*(_DWORD *)(a1 + 8);
return result;
}

original_code:
void
dbug_enter(struct dbug_ctx_t *ctx)
{
 dbug_cfg->ctx = ctx;
 if (selected() && (dbug_on & (0x0002))) {
  prefix();
  fprintf(dbug_cfg->output, ">%.31s\n", ctx->name);
  if (fflush(dbug_cfg->output) == (-1)) {
   io_error();
  }
 }
 ++ctx->depth;
 return;
}

user_defined_types: struct dbug_unit_t { char *name; char *unit; }


decompiled_code:
int dbug_print(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
prefix();
fprintf(*((FILE **)dbug_cfg + 3), "%.31s: ", *(const char **)(*((_QWORD *)dbug_cfg + 10) + 16LL));
fflush(*((FILE **)dbug_cfg + 3));
vfprintf(*((FILE **)dbug_cfg + 3), format, arg);
fputc(10, *((FILE **)dbug_cfg + 3));
result = fflush(*((FILE **)dbug_cfg + 3));
if ( result == -1 )
io_error();
return result;
}

canonical_decompiled_code:
int func14(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
func6();
fprintf(*((FILE **)dbug_cfg + 3), "%.31s: ", *(const char **)(*((_QWORD *)dbug_cfg + 10) + 16LL));
fflush(*((FILE **)dbug_cfg + 3));
vfprintf(*((FILE **)dbug_cfg + 3), format, arg);
fputc(10, *((FILE **)dbug_cfg + 3));
result = fflush(*((FILE **)dbug_cfg + 3));
if ( result == -1 )
func7();
return result;
}

original_code:
void
dbug_print(char *fmt, ...)
{
 va_list va;
 prefix();
 fprintf(dbug_cfg->output, "%.31s: ", dbug_cfg->ctx->keyword);
 fflush(dbug_cfg->output);
 __builtin_va_start(va,fmt);
 vfprintf(dbug_cfg->output, fmt, va);
 __builtin_va_end(va);
 fputc('\n', dbug_cfg->output);
 if (fflush(dbug_cfg->output) == (-1)) {
  io_error();
 }
 return;
}

canonical_original_code:
void dbug_print(char *fmt, ...)
{
 __builtin_va_list va;
 prefix();
 fprintf(dbug_cfg->output, "%.31s: ", dbug_cfg->ctx->keyword);
 fflush(dbug_cfg->output);
 __builtin_va_start(va,fmt);
 vfprintf(dbug_cfg->output, fmt, va);
 __builtin_va_end(va);
 fputc('\n', dbug_cfg->output);
 if (fflush(dbug_cfg->output) == (-1)) {
  io_error();
 }
 return;
}

variable_types:
fmt
char *


decompiled_code:
__int64 __fastcall dbug_return(__int64 a1)
{
_QWORD *v1; // rbp
__int64 v2; // rax
__int64 result; // rax

v1 = dbug_cfg;
v2 = *((_QWORD *)dbug_cfg + 10);
if ( v2 != a1 )
dbug_fatal(
"missing DBUG_RETURN detected in '%s' (%s:%d)",
*(const char **)v2,
**(const char ***)(v2 + 24),
*(unsigned int *)(v2 + 12));
--*(_DWORD *)(a1 + 8);
if ( (unsigned int)selected() && (dbug_on & 2) != 0 )
{
prefix();
fprintf(*((FILE **)dbug_cfg + 3), "<%.31s\n", *(const char **)a1);
if ( fflush(*((FILE **)dbug_cfg + 3)) == -1 )
io_error();
result = *(_QWORD *)(a1 + 32);
*((_QWORD *)dbug_cfg + 10) = result;
}
else
{
result = *(_QWORD *)(a1 + 32);
v1[10] = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
_QWORD *v1; // rbp
__int64 v2; // rax
__int64 result; // rax

v1 = dbug_cfg;
v2 = *((_QWORD *)dbug_cfg + 10);
if ( v2 != a1 )
func4(
"missing DBUG_RETURN detected in '%s' (%s:%d)",
*(const char **)v2,
**(const char ***)(v2 + 24),
*(unsigned int *)(v2 + 12));
--*(_DWORD *)(a1 + 8);
if ( (unsigned int)func1() && (dbug_on & 2) != 0 )
{
func6();
fprintf(*((FILE **)dbug_cfg + 3), "<%.31s\n", *(const char **)a1);
if ( fflush(*((FILE **)dbug_cfg + 3)) == -1 )
func7();
result = *(_QWORD *)(a1 + 32);
*((_QWORD *)dbug_cfg + 10) = result;
}
else
{
result = *(_QWORD *)(a1 + 32);
v1[10] = result;
}
return result;
}

original_code:
void
dbug_return(struct dbug_ctx_t *ctx)
{
 if (ctx != dbug_cfg->ctx) {
  dbug_fatal("missing DBUG_RETURN detected in '%s' (%s:%d)",
   dbug_cfg->ctx->name,
   dbug_cfg->ctx->unit->name,
   dbug_cfg->ctx->line);
 }
 --ctx->depth;
 if (selected() && (dbug_on & (0x0002))) {
  prefix();
  fprintf(dbug_cfg->output, "<%.31s\n", ctx->name);
  if (fflush(dbug_cfg->output) == (-1)) {
   io_error();
  }
 }
 dbug_cfg->ctx = ctx->caller;
 return;
}


original_code:
void
dbug_hexdump(void *p, int n)
{
 unsigned char *bp = p;
 char asc[16 + 1];
 int i;
 int c;
 while (n > 0) {
  fprintf(dbug_cfg->output, "%p  ", bp);
  for (i = 0; i < 16; ++i) {
   if (i < n) {
    c = bp[i];
    if ((c >= ' ') && (c < 0x7F)) {
     asc[i] = c;
    } else {
     asc[i] = '.';
    }
    fprintf(dbug_cfg->output, " %02x", c);
   } else {
    asc[i] = ' ';
    fprintf(dbug_cfg->output, "   ");
   }
  }
  asc[16] = '\0';
  fprintf(dbug_cfg->output, "  |%16.16s|\n", asc);
  bp += 16;
  n -= 16;
 }
 fflush(dbug_cfg->output);
}

canonical_original_code:
void dbug_hexdump(void *p, int n)
{
 unsigned char *bp = p;
 char asc[-1];
 int i;
 int c;
 while (n > 0) {
  fprintf(dbug_cfg->output, "%p  ", bp);
  for (i = 0; i < 16; ++i) {
   if (i < n) {
    c = bp[i];
    if ((c >= ' ') && (c < 0x7F)) {
     asc[i] = c;
    } else {
     asc[i] = '.';
    }
    fprintf(dbug_cfg->output, " %02x", c);
   } else {
    asc[i] = ' ';
    fprintf(dbug_cfg->output, "   ");
   }
  }
  asc[16] = '\0';
  fprintf(dbug_cfg->output, "  |%16.16s|\n", asc);
  bp += 16;
  n -= 16;
 }
 fflush(dbug_cfg->output);
}

variable_types:
p
void *

variable_types:
bp
unsigned char *

variable_types:
asc
char [-1]

variable_types: c int


decompiled_code:
__int64 __fastcall countdown_ring(__int64 a1)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // r13
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rax
const void *v8; // r15
__int64 v9; // rax
int v10; // edx
__int64 v11; // r13
__int64 v13; // rdi
const void *v14; // rax
const char *v15; // [rsp+0h] [rbp-68h] BYREF
int v16; // [rsp+8h] [rbp-60h]
int v17; // [rsp+Ch] [rbp-5Ch]
void *v18; // [rsp+10h] [rbp-58h]
char **v19; // [rsp+18h] [rbp-50h]
__int64 v20; // [rsp+20h] [rbp-48h]

v2 = cdr(*(_QWORD *)(a1 + 48));
v3 = car(*(_QWORD *)(a1 + 48));
v4 = mine(v3);
v5 = lu_atom(&unk_64B);
v6 = map_get_def(v4, v5, 0LL);
v7 = lu_atom(&unk_64D);
v15 = "countdown_ring";
v8 = (const void *)map_get_def(v4, v7, 0LL);
v9 = *(_QWORD *)(dbug_cfg + 80LL);
v10 = *(_DWORD *)(v9 + 8);
v17 = 46;
v18 = &unk_65E;
v16 = v10;
v19 = dbug_unit;
v20 = v9;
dbug_enter(&v15);
if ( !dbug_on )
{
v11 = v2 >> 2;
goto LABEL_3;
}
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_65E;
if ( (unsigned int)dbug_keyword(&unk_65E) )
{
v13 = *(_QWORD *)(a1 + 48);
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 47;
v14 = (const void *)car(v13);
dbug_print("self=%p", v14);
}
LODWORD(v11) = v2 >> 2;
if ( !dbug_on || (*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_65E, !(unsigned int)dbug_keyword(&unk_65E)) )
{
LABEL_3:
if ( (int)v11 >= 0 )
goto LABEL_4;
LABEL_14:
abe__send(a1, v8, v6);
goto LABEL_7;
}
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 48;
dbug_print("m=%d n=%d a=%p", (unsigned int)(v2 >> 2), v6 >> 2, v8);
if ( (int)v11 < 0 )
goto LABEL_14;
LABEL_4:
if ( (int)(v6 >> 2) > 0 )
{
abe__send(a1, v8, v2);
}
else if ( (_DWORD)v11 )
{
abe__send(a1, v8, 4LL * ((int)v11 - 1) + 3);
}
LABEL_7:
v17 = 56;
return dbug_return(&v15);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 v2; // r14
__int64 v3; // rax
__int64 v4; // r13
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rax
const void *v8; // r15
__int64 v9; // rax
int v10; // edx
__int64 v11; // r13
__int64 v13; // rdi
const void *v14; // rax
const char *v15; // [rsp+0h] [rbp-68h] BYREF
int v16; // [rsp+8h] [rbp-60h]
int v17; // [rsp+Ch] [rbp-5Ch]
void *v18; // [rsp+10h] [rbp-58h]
char **v19; // [rsp+18h] [rbp-50h]
__int64 v20; // [rsp+20h] [rbp-48h]

v2 = cdr(*(_QWORD *)(a1 + 48));
v3 = car(*(_QWORD *)(a1 + 48));
v4 = mine(v3);
v5 = lu_atom(&unk_64B);
v6 = map_get_def(v4, v5, 0LL);
v7 = lu_atom(&unk_64D);
v15 = "countdown_ring";
v8 = (const void *)map_get_def(v4, v7, 0LL);
v9 = *(_QWORD *)(dbug_cfg + 80LL);
v10 = *(_DWORD *)(v9 + 8);
v17 = 46;
v18 = &unk_65E;
v16 = v10;
v19 = dbug_unit;
v20 = v9;
dbug_enter(&v15);
if ( !dbug_on )
{
v11 = v2 >> 2;
goto LABEL_3;
}
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_65E;
if ( (unsigned int)dbug_keyword(&unk_65E) )
{
v13 = *(_QWORD *)(a1 + 48);
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 47;
v14 = (const void *)car(v13);
dbug_print("self=%p", v14);
}
LODWORD(v11) = v2 >> 2;
if ( !dbug_on || (*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_65E, !(unsigned int)dbug_keyword(&unk_65E)) )
{
LABEL_3:
if ( (int)v11 >= 0 )
goto LABEL_4;
LABEL_14:
abe__send(a1, v8, v6);
goto LABEL_7;
}
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 48;
dbug_print("m=%d n=%d a=%p", (unsigned int)(v2 >> 2), v6 >> 2, v8);
if ( (int)v11 < 0 )
goto LABEL_14;
LABEL_4:
if ( (int)(v6 >> 2) > 0 )
{
abe__send(a1, v8, v2);
}
else if ( (_DWORD)v11 )
{
abe__send(a1, v8, 4LL * ((int)v11 - 1) + 3);
}
LABEL_7:
v17 = 56;
return dbug_return(&v15);
}

original_code:
void countdown_ring (CONFIG* abe__config)
{
 CONS* m = _cdr((abe__config)->q_entry);
 CONS* state = _mine(_car((abe__config)->q_entry));
 CONS* n = map_get_def((state), (lu_atom("n")), ((void *)0));
 CONS* a = map_get_def((state), (lu_atom("a")), ((void *)0));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 46; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 47; dbug_print ("self=%p", _car((abe__config)->q_entry)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 48; dbug_print ("m=%d n=%d a=%p", ((int)(((WORD)(m))>>2)), ((int)(((WORD)(n))>>2)), a); }}while(0);
 if (((int)(((WORD)(m))>>2)) < 0) {
  abe__send((abe__config),(a),(n));
 } else if (0 < ((int)(((WORD)(n))>>2))) {
  abe__send((abe__config),(a),(m));
 } else if (0 < ((int)(((WORD)(m))>>2))) {
  abe__send((abe__config),(a),(((CONS*)((((WORD)(((int)(((WORD)(m))>>2)) - 1))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 56; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void countdown_ring(struct config *abe__config)
{
 struct cons *m = _cdr((abe__config)->q_entry);
 struct cons *state = _mine(_car((abe__config)->q_entry));
 struct cons *n = map_get_def((state), (lu_atom("n")), ((void *)0));
 struct cons *a = map_get_def((state), (lu_atom("a")), ((void *)0));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 46; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 47; dbug_print ("self=%p", _car((abe__config)->q_entry)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 48; dbug_print ("m=%d n=%d a=%p", ((int)(((WORD)(m))>>2)), ((int)(((WORD)(n))>>2)), a); }}while(0);
 if (((int)(((WORD)(m))>>2)) < 0) {
  abe__send((abe__config),(a),(n));
 } else if (0 < ((int)(((WORD)(n))>>2))) {
  abe__send((abe__config),(a),(m));
 } else if (0 < ((int)(((WORD)(m))>>2))) {
  abe__send((abe__config),(a),(((struct cons *)((((WORD)(((int)(((WORD)(m))>>2)) - 1))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 56; dbug_return (&dbug_ctx); return;
}

variable_types: struct config { struct cell { struct cons { struct cons *first; struct cons *rest; } *first; struct cons *rest; long _prev; long _next; } msg_queue; struct cons *gc_root; int q_count; struct cons *q_entry; int msg_cnt_hi; int msg_cnt_lo; int q_limit; long t_epoch; long t_now_s; long t_now_us; struct cons *t_queue; int t_count; } *

variable_types: struct dbug_ctx_t { char *name; int depth; int line; char *keyword; struct dbug_unit_t { char *name; char *unit; } *unit; struct dbug_ctx_t *caller; }

user_defined_types: struct config { struct cell msg_queue; struct cons *gc_root; int q_count; struct cons *q_entry; int msg_cnt_hi; int msg_cnt_lo; int q_limit; long t_epoch; long t_now_s; long t_now_us; struct cons *t_queue; int t_count; }

user_defined_types: struct cell { struct cons *first; struct cons *rest; long _prev; long _next; }


challenge

original_code:
void challenge (CONFIG* abe__config)
{
 CONS* msg = _cdr((abe__config)->q_entry);
 CONS* state = _mine(_car((abe__config)->q_entry));
 CONS* n = map_get_def((state), (lu_atom("n")), ((void *)0));
 CONS* a = map_get_def((state), (lu_atom("a")), ((void *)0));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 81; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 82; dbug_print ("self=%p", _car((abe__config)->q_entry)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 83; dbug_print ("msg=%p n=%d a=%p", msg, ((int)(((WORD)(n))>>2)), a); }}while(0);
 if (0 < ((int)(((WORD)(n))>>2))) {
  a = abe__actor((abe__config),(challenge),(map_put(((CONS*)(&nil__cons)), lu_atom("n"), ((CONS*)((((WORD)(((int)(((WORD)(n))>>2)) - 1))<<2) | ((WORD)(0x00000003)))))));
  abe__become(_car((abe__config)->q_entry),(countdown_ring),(map_put(state, lu_atom("a"), a)));
  abe__send((abe__config),(a),(msg));
 } else {
  state = ((CONS*)(&nil__cons));
  state = map_put(state, lu_atom("a"), msg);
  state = map_put(state, lu_atom("n"), n);
  abe__become(_car((abe__config)->q_entry),(countdown_ring),(state));
  abe__send((abe__config),(msg),(((CONS*)((((WORD)((100)))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 95; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void challenge(struct config *abe__config)
{
 struct cons *msg = _cdr((abe__config)->q_entry);
 struct cons *state = _mine(_car((abe__config)->q_entry));
 struct cons *n = map_get_def((state), (lu_atom("n")), ((void *)0));
 struct cons *a = map_get_def((state), (lu_atom("a")), ((void *)0));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 81; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 82; dbug_print ("self=%p", _car((abe__config)->q_entry)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 83; dbug_print ("msg=%p n=%d a=%p", msg, ((int)(((WORD)(n))>>2)), a); }}while(0);
 if (0 < ((int)(((WORD)(n))>>2))) {
  a = abe__actor((abe__config),(challenge),(map_put(((struct cons *)(&nil__cons)), lu_atom("n"), ((struct cons *)((((WORD)(((int)(((WORD)(n))>>2)) - 1))<<2) | ((WORD)(0x00000003)))))));
  abe__become(_car((abe__config)->q_entry),(countdown_ring),(map_put(state, lu_atom("a"), a)));
  abe__send((abe__config),(a),(msg));
 } else {
  state = ((struct cons *)(&nil__cons));
  state = map_put(state, lu_atom("a"), msg);
  state = map_put(state, lu_atom("n"), n);
  abe__become(_car((abe__config)->q_entry),(countdown_ring),(state));
  abe__send((abe__config),(msg),(((struct cons *)((((WORD)((100)))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 95; dbug_return (&dbug_ctx); return;
}

variable_types: struct cons { struct cons *first; struct cons *rest; } *


decompiled_code:
__int64 __fastcall test_erlang_challenge(int a1)
{
int v1; // edx
__int64 v2; // r12
__int64 v3; // rax
unsigned int v4; // ebp
__int64 v5; // rax
__int64 v6; // rax
const char *v8; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+8h] [rbp-40h]
int v10; // [rsp+Ch] [rbp-3Ch]
void *v11; // [rsp+10h] [rbp-38h]
char **v12; // [rsp+18h] [rbp-30h]
__int64 v13; // [rsp+20h] [rbp-28h]

v8 = "test_erlang_challenge";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v13 = *(_QWORD *)(dbug_cfg + 80LL);
v10 = 110;
v9 = v1;
v11 = &unk_65E;
v12 = dbug_unit;
dbug_enter(&v8);
v2 = new_configuration(10LL);
v3 = lu_atom(&unk_64B);
v4 = 1;
v5 = map_put(&nil__cons, v3, 4LL * a1 + 3);
v6 = abe__actor(v2, challenge, v5);
abe__send(v2, v6, v6);
do
{
run_configuration(v2, 1000000LL);
if ( *(int *)(v2 + 40) <= 0 )
break;
++v4;
}
while ( v4 != 1000000 );
printf("~%dM messages delivered.\n", v4);
report_actor_usage(v2);
v10 = 123;
return dbug_return(&v8);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
int v1; // edx
__int64 v2; // r12
__int64 v3; // rax
unsigned int v4; // ebp
__int64 v5; // rax
__int64 v6; // rax
const char *v8; // [rsp+0h] [rbp-48h] BYREF
int v9; // [rsp+8h] [rbp-40h]
int v10; // [rsp+Ch] [rbp-3Ch]
void *v11; // [rsp+10h] [rbp-38h]
char **v12; // [rsp+18h] [rbp-30h]
__int64 v13; // [rsp+20h] [rbp-28h]

v8 = "test_erlang_challenge";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v13 = *(_QWORD *)(dbug_cfg + 80LL);
v10 = 110;
v9 = v1;
v11 = &unk_65E;
v12 = dbug_unit;
dbug_enter(&v8);
v2 = new_configuration(10LL);
v3 = lu_atom(&unk_64B);
v4 = 1;
v5 = map_put(&nil__cons, v3, 4LL * a1 + 3);
v6 = abe__actor(v2, challenge, v5);
abe__send(v2, v6, v6);
do
{
run_configuration(v2, 1000000LL);
if ( *(int *)(v2 + 40) <= 0 )
break;
++v4;
}
while ( v4 != 1000000 );
printf("~%dM messages delivered.\n", v4);
report_actor_usage(v2);
v10 = 123;
return dbug_return(&v8);
}

original_code:
void
test_erlang_challenge(int counter)
{
 CONFIG* cfg;
 CONS* actor;
 int n;
 int m;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_erlang_challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 110; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 cfg = new_configuration(10);
 actor = abe__actor((cfg),(challenge),(map_put(((CONS*)(&nil__cons)), lu_atom("n"), ((CONS*)((((WORD)(counter))<<2) | ((WORD)(0x00000003)))))));
 abe__send((cfg),(actor),(actor));
 for (m = 1; m < 1000000; ++m) {
  n = run_configuration(cfg, 1000000);
  if (cfg->q_count <= 0) {
   break;
  }
 }
 printf("~%dM messages delivered.\n", m);
 report_actor_usage(cfg);
 dbug_ctx.line = 123; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void test_erlang_challenge(int counter)
{
 struct config *cfg;
 struct cons *actor;
 int n;
 int m;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_erlang_challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 110; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 cfg = new_configuration(10);
 actor = abe__actor((cfg),(challenge),(map_put(((struct cons *)(&nil__cons)), lu_atom("n"), ((struct cons *)((((WORD)(counter))<<2) | ((WORD)(0x00000003)))))));
 abe__send((cfg),(actor),(actor));
 for (m = 1; m < 1000000; ++m) {
  n = run_configuration(cfg, 1000000);
  if (cfg->q_count <= 0) {
   break;
  }
 }
 printf("~%dM messages delivered.\n", m);
 report_actor_usage(cfg);
 dbug_ctx.line = 123; dbug_return (&dbug_ctx); return;
}

variable_types: counter int

variable_types: m int

user_defined_types: struct cons { struct cons *first; struct cons *rest; }


banner

decompiled_code:
int banner()
{
return printf("%s v%s -- %s\n", Program, Version, Copyright);
}

canonical_decompiled_code:
int func5()
{
return printf("%s v%s -- %s\n", Program, Version, Copyright);
}

original_code:
void
banner(void)
{
 printf("%s v%s -- %s\n", _Program, _Version, _Copyright);
}

canonical_original_code:
void banner()
{
 printf("%s v%s -- %s\n", _Program, _Version, _Copyright);
}


decompiled_code:
__int64 lu_cons()
{
__int64 result; // rax

result = gc_perm();
++lu_cons_cnt;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

result = gc_perm();
++lu_cons_cnt;
return result;
}

original_code:
CONS*
lu_cons(CONS* a, CONS* d)
{
 CONS* p = ((void *)0);
 p = gc_perm(a, d);
 ++lu_cons_cnt;
 ;
 return p;
}

canonical_original_code:
struct cons *lu_cons(struct cons *a, struct cons *d)
{
 struct cons *p = ((void *)0);
 p = gc_perm(a, d);
 ++lu_cons_cnt;
 ;
 return p;
}

variable_types:
a
struct cons *

variable_types:
d
struct cons *

return_type: struct cons { struct cons *first; struct cons *rest; } *


decompiled_code:
unsigned __int64 __fastcall lu_extend_atom(void *a1, int a2)
{
__int64 v2; // r13
__int64 v3; // r12
unsigned __int64 v4; // r13
unsigned __int64 v5; // rdi
__int64 v6; // rax
__int64 v7; // rax
void *v8; // rax
unsigned __int64 v9; // rbp
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax

v2 = (__int64)a1;
v3 = 4LL * a2 + 3;
if ( !lu_atom_root )
lu_atom_root = lu_cons(&nil__cons) & 0xFFFFFFFFFFFFFFFCLL | 2;
if ( a1 == &nil__cons || !a1 )
v2 = lu_atom_root;
if ( (v2 & 3) != 2 )
_assert_fail("atomp(atom)", "atom.c", 0x2Eu, "lu_extend_atom");
v4 = v2 & 0xFFFFFFFFFFFFFFFCLL;
v5 = v4;
do
{
v8 = (void *)cdr(v5);
v9 = (unsigned __int64)v8;
if ( v8 == &nil__cons )
{
car(v4);
v10 = lu_cons(v3);
v11 = lu_cons(v10);
cdr(v4);
v12 = lu_cons(v11);
rplacd(v4, v12);
return v11 & 0xFFFFFFFFFFFFFFFCLL | 2;
}
v6 = car(v8);
v7 = car(v6);
v5 = v9;
}
while ( v3 != car(v7) );
v11 = car(v9);
return v11 & 0xFFFFFFFFFFFFFFFCLL | 2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(void *a1, int a2)
{
__int64 v2; // r13
__int64 v3; // r12
unsigned __int64 v4; // r13
unsigned __int64 v5; // rdi
__int64 v6; // rax
__int64 v7; // rax
void *v8; // rax
unsigned __int64 v9; // rbp
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax

v2 = (__int64)a1;
v3 = 4LL * a2 + 3;
if ( !lu_atom_root )
lu_atom_root = func0(&nil__cons) & 0xFFFFFFFFFFFFFFFCLL | 2;
if ( a1 == &nil__cons || !a1 )
v2 = lu_atom_root;
if ( (v2 & 3) != 2 )
_assert_fail("atomp(atom)", "atom.c", 0x2Eu, "lu_extend_atom");
v4 = v2 & 0xFFFFFFFFFFFFFFFCLL;
v5 = v4;
do
{
v8 = (void *)cdr(v5);
v9 = (unsigned __int64)v8;
if ( v8 == &nil__cons )
{
car(v4);
v10 = func0(v3);
v11 = func0(v10);
cdr(v4);
v12 = func0(v11);
rplacd(v4, v12);
return v11 & 0xFFFFFFFFFFFFFFFCLL | 2;
}
v6 = car(v8);
v7 = car(v6);
v5 = v9;
}
while ( v3 != car(v7) );
v11 = car(v9);
return v11 & 0xFFFFFFFFFFFFFFFCLL | 2;
}

canonical_original_code:
struct cons *lu_extend_atom(struct cons *atom, int c)
{
 struct cons *root;
 struct cons *node;
 struct cons *ch = ((CONS*)((((WORD)(c))<<2) | ((WORD)(0x00000003))));
 ;
 ;
 ;
 if (lu_atom_root == ((void *)0)) {
  root = lu_cons(((struct cons *)(&nil__cons)), ((struct cons *)(&nil__cons)));
  ;
  lu_atom_root = ((struct cons *)((((WORD)(root)) & ~((WORD)(0x00000003))) | ((WORD)(0x00000002))));
 }
 if ((atom == ((void *)0)) || ((BOOL)((atom)==((struct cons *)(&nil__cons))))) {
  atom = lu_atom_root;
 }
 ((((BOOL)((((WORD)(atom)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("atomp(atom)", "atom.c", 46, __extension__ __PRETTY_FUNCTION__));
 root = ((struct cons *)((((WORD)(atom)) & ~((WORD)(0x00000003))) | ((WORD)(0x00000000))));
 ;
 node = _cdr(root);
 for (;;) {
  ;
  if (((BOOL)((node)==((struct cons *)(&nil__cons))))) {
   ;
   node = lu_cons(ch, _car(root));
   node = lu_cons(node, ((struct cons *)(&nil__cons)));
   rplacd(root, lu_cons(node, _cdr(root)));
   break;
  }
  if (_car(_car(_car(node))) == ch) {
   ;
   node = _car(node);
   break;
  }
  node = _cdr(node);
 }
 atom = ((struct cons *)((((WORD)(node)) & ~((WORD)(0x00000003))) | ((WORD)(0x00000002))));
 ((((BOOL)((((WORD)(atom)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("atomp(atom)", "atom.c", 69, __extension__ __PRETTY_FUNCTION__));
 return atom;
}

variable_types:
atom
struct cons *


decompiled_code:
void *__fastcall lu_atom(_BYTE *a1)
{
int v1; // esi
char *v2; // rbx
void *i; // rdi
unsigned __int64 v4; // rax

if ( !a1 )
return &nil__cons;
v1 = (char)*a1;
if ( !*a1 )
return &nil__cons;
v2 = a1 + 1;
for ( i = &nil__cons; v1; i = (void *)v4 )
{
v4 = lu_extend_atom(i, v1);
v1 = *v2++;
}
if ( ((unsigned __int8)i & 3) != 2LL )
_assert_fail("atomp(atom)", "atom.c", 0x5Au, "lu_atom");
return i;
}

canonical_decompiled_code:
void *__fastcall func2(_BYTE *a1)
{
int v1; // esi
char *v2; // rbx
void *i; // rdi
unsigned __int64 v4; // rax

if ( !a1 )
return &nil__cons;
v1 = (char)*a1;
if ( !*a1 )
return &nil__cons;
v2 = a1 + 1;
for ( i = &nil__cons; v1; i = (void *)v4 )
{
v4 = func1(i, v1);
v1 = *v2++;
}
if ( ((unsigned __int8)i & 3) != 2LL )
_assert_fail("atomp(atom)", "atom.c", 0x5Au, "lu_atom");
return i;
}

original_code:
CONS*
lu_atom(char* s)
{
 CONS* atom;
 int c;
 ;
 ;
 if ((s == ((void *)0)) || (*s == '\0')) {
  ;
  return ((CONS*)(&nil__cons));
 }
 atom = ((CONS*)(&nil__cons));
 while ((c = *s++) != '\0') {
  atom = lu_extend_atom(atom, c);
 }
 ((((BOOL)((((WORD)(atom)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("atomp(atom)", "atom.c", 90, __extension__ __PRETTY_FUNCTION__));
 ;
 return atom;
}

canonical_original_code:
struct cons *lu_atom(char *s)
{
 struct cons *atom;
 int c;
 ;
 ;
 if ((s == ((void *)0)) || (*s == '\0')) {
  ;
  return ((struct cons *)(&nil__cons));
 }
 atom = ((struct cons *)(&nil__cons));
 while ((c = *s++) != '\0') {
  atom = lu_extend_atom(atom, c);
 }
 ((((BOOL)((((WORD)(atom)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("atomp(atom)", "atom.c", 90, __extension__ __PRETTY_FUNCTION__));
 ;
 return atom;
}

variable_types:
s
char *


decompiled_code:
char *__fastcall atom_str(__int64 a1)
{
char *result; // rax
void *v2; // rbp
unsigned int v3; // eax
unsigned int v4; // er12
__int64 v5; // rbx

if ( !a1 )
return (char *)&unk_903;
result = (char *)&unk_903;
if ( (a1 & 3) != 2 )
return result;
v2 = (void *)car(a1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = length(v2);
v4 = v3;
if ( v3 <= 0xFF )
{
LODWORD(v5) = v3 - 1;
s_3[v3] = 0;
if ( !v3 )
goto LABEL_8;
}
else
{
do
{
--v4;
v2 = (void *)cdr(v2);
}
while ( v4 != 255 );
byte_8DF = 0;
LODWORD(v5) = 254;
}
v5 = (int)v5;
do
{
byte_7E1[--v5] = car(v2) >> 2;
v2 = (void *)cdr(v2);
}
while ( (_DWORD)v5 != -1 );
LABEL_8:
if ( v2 != &nil__cons )
_assert_fail("nilp(p)", "atom.c", 0x76u, "atom_str");
return s_3;
}

canonical_decompiled_code:
char *__fastcall func3(__int64 a1)
{
char *result; // rax
void *v2; // rbp
unsigned int v3; // eax
unsigned int v4; // er12
__int64 v5; // rbx

if ( !a1 )
return (char *)&unk_903;
result = (char *)&unk_903;
if ( (a1 & 3) != 2 )
return result;
v2 = (void *)car(a1 & 0xFFFFFFFFFFFFFFFCLL);
v3 = length(v2);
v4 = v3;
if ( v3 <= 0xFF )
{
LODWORD(v5) = v3 - 1;
s_3[v3] = 0;
if ( !v3 )
goto LABEL_8;
}
else
{
do
{
--v4;
v2 = (void *)cdr(v2);
}
while ( v4 != 255 );
byte_8DF = 0;
LODWORD(v5) = 254;
}
v5 = (int)v5;
do
{
byte_7E1[--v5] = car(v2) >> 2;
v2 = (void *)cdr(v2);
}
while ( (_DWORD)v5 != -1 );
LABEL_8:
if ( v2 != &nil__cons )
_assert_fail("nilp(p)", "atom.c", 0x76u, "atom_str");
return s_3;
}

variable_types:
s
char [256]

variable_types: n int


decompiled_code:
__int64 test_atom()
{
int v0; // edx
void *v1; // rbx
void *v2; // rax
void *v3; // rbx
void *v4; // rbp
void *v5; // rax
void *v6; // rbx
bool v7; // cf
bool v8; // zf
char *v9; // rax
const char *v10; // rsi
__int64 v11; // rcx
char *v12; // rdi
__int64 v14; // rbx
const char *v15; // [rsp+0h] [rbp-148h] BYREF
int v16; // [rsp+8h] [rbp-140h]
int v17; // [rsp+Ch] [rbp-13Ch]
void *v18; // [rsp+10h] [rbp-138h]
char **v19; // [rsp+18h] [rbp-130h]
__int64 v20; // [rsp+20h] [rbp-128h]
__int64 v21[35]; // [rsp+30h] [rbp-118h] BYREF

v15 = "test_atom";
v0 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v20 = *(_QWORD *)(dbug_cfg + 80LL);
v17 = 130;
v16 = v0;
v18 = &unk_903;
v19 = &dbug_unit;
dbug_enter(&v15);
puts("--test_atom--");
v1 = lu_atom(0LL);
v2 = lu_atom(&unk_903);
if ( v1 != &nil__cons )
_assert_fail("nilp(p)", "atom.c", 0x86u, "test_atom");
if ( v2 != &nil__cons )
_assert_fail("p == q", "atom.c", 0x87u, "test_atom");
if ( *atom_str((__int64)&nil__cons) )
_assert_fail("atom_str(q)[0] == '\\0'", "atom.c", 0x88u, "test_atom");
v21[0] = 84LL;
v3 = lu_atom("T");
if ( v3 != lu_atom(v21) )
_assert_fail("p == q", "atom.c", 0x8Eu, "test_atom");
v4 = lu_atom("n");
if ( v3 == v4 )
_assert_fail("p != q", "atom.c", 0x90u, "test_atom");
v21[0] = 7104878LL;
v5 = lu_atom("nil");
v6 = v5;
if ( v4 == v5 )
_assert_fail("p != q", "atom.c", 0x94u, "test_atom");
v9 = atom_str((__int64)v5);
v10 = "nil";
v11 = 4LL;
v12 = v9;
do
{
if ( !v11 )
break;
v7 = (unsigned int)*v10 < (unsigned __int8)*v12;
v8 = *v10++ == (unsigned __int8)*v12++;
--v11;
}
while ( v8 );
if ( (!v7 && !v8) != v7 )
_assert_fail("strcmp(s, atom_str(p)) == 0", "atom.c", 0x95u, "test_atom");
if ( v6 != lu_atom(v21) )
_assert_fail("p == q", "atom.c", 0x97u, "test_atom");
if ( v6 == lu_atom("F") )
_assert_fail("p != q", "atom.c", 0x99u, "test_atom");
if ( dbug_on )
{
v14 = lu_atom_root;
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, v10) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 156;
v10 = (const char *)cons_to_str(v14 & 0xFFFFFFFFFFFFFFFCLL);
dbug_print("lu_atom_root=%s", v10);
}
}
v17 = 157;
return dbug_return(&v15, v10);
}

canonical_decompiled_code:
__int64 func4()
{
int v0; // edx
void *v1; // rbx
void *v2; // rax
void *v3; // rbx
void *v4; // rbp
void *v5; // rax
void *v6; // rbx
bool v7; // cf
bool v8; // zf
char *v9; // rax
const char *v10; // rsi
__int64 v11; // rcx
char *v12; // rdi
__int64 v14; // rbx
const char *v15; // [rsp+0h] [rbp-148h] BYREF
int v16; // [rsp+8h] [rbp-140h]
int v17; // [rsp+Ch] [rbp-13Ch]
void *v18; // [rsp+10h] [rbp-138h]
char **v19; // [rsp+18h] [rbp-130h]
__int64 v20; // [rsp+20h] [rbp-128h]
__int64 v21[35]; // [rsp+30h] [rbp-118h] BYREF

v15 = "test_atom";
v0 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v20 = *(_QWORD *)(dbug_cfg + 80LL);
v17 = 130;
v16 = v0;
v18 = &unk_903;
v19 = &dbug_unit;
dbug_enter(&v15);
puts("--test_atom--");
v1 = func2(0LL);
v2 = func2(&unk_903);
if ( v1 != &nil__cons )
_assert_fail("nilp(p)", "atom.c", 0x86u, "test_atom");
if ( v2 != &nil__cons )
_assert_fail("p == q", "atom.c", 0x87u, "test_atom");
if ( *func3((__int64)&nil__cons) )
_assert_fail("atom_str(q)[0] == '\\0'", "atom.c", 0x88u, "test_atom");
v21[0] = 84LL;
v3 = func2("T");
if ( v3 != func2(v21) )
_assert_fail("p == q", "atom.c", 0x8Eu, "test_atom");
v4 = func2("n");
if ( v3 == v4 )
_assert_fail("p != q", "atom.c", 0x90u, "test_atom");
v21[0] = 7104878LL;
v5 = func2("nil");
v6 = v5;
if ( v4 == v5 )
_assert_fail("p != q", "atom.c", 0x94u, "test_atom");
v9 = func3((__int64)v5);
v10 = "nil";
v11 = 4LL;
v12 = v9;
do
{
if ( !v11 )
break;
v7 = (unsigned int)*v10 < (unsigned __int8)*v12;
v8 = *v10++ == (unsigned __int8)*v12++;
--v11;
}
while ( v8 );
if ( (!v7 && !v8) != v7 )
_assert_fail("strcmp(s, atom_str(p)) == 0", "atom.c", 0x95u, "test_atom");
if ( v6 != func2(v21) )
_assert_fail("p == q", "atom.c", 0x97u, "test_atom");
if ( v6 == func2("F") )
_assert_fail("p != q", "atom.c", 0x99u, "test_atom");
if ( dbug_on )
{
v14 = lu_atom_root;
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, v10) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 156;
v10 = (const char *)cons_to_str(v14 & 0xFFFFFFFFFFFFFFFCLL);
dbug_print("lu_atom_root=%s", v10);
}
}
v17 = 157;
return dbug_return(&v15, v10);
}

original_code:
void
test_atom()
{
 CONS* p;
 CONS* q;
 char* s;
 char buf[256];
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_atom"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 130; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 printf("--test_atom--\n");
 p = lu_atom(((void *)0));
 q = lu_atom("");
 ((((BOOL)((p)==((CONS*)(&nil__cons))))) ? (void) (0) : __assert_fail ("nilp(p)", "atom.c", 134, __extension__ __PRETTY_FUNCTION__));
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 135, __extension__ __PRETTY_FUNCTION__));
 ((atom_str(q)[0] == '\0') ? (void) (0) : __assert_fail ("atom_str(q)[0] == '\\0'", "atom.c", 136, __extension__ __PRETTY_FUNCTION__));
 s = "T";
 strncpy(buf, s, sizeof(buf - 1));
 p = lu_atom(s);
 q = lu_atom(buf);
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 142, __extension__ __PRETTY_FUNCTION__));
 q = lu_atom("n");
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 144, __extension__ __PRETTY_FUNCTION__));
 s = "nil";
 strncpy(buf, s, sizeof(buf - 1));
 p = lu_atom(s);
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 148, __extension__ __PRETTY_FUNCTION__));
 ((strcmp(s, atom_str(p)) == 0) ? (void) (0) : __assert_fail ("strcmp(s, atom_str(p)) == 0", "atom.c", 149, __extension__ __PRETTY_FUNCTION__));
 q = lu_atom(buf);
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 151, __extension__ __PRETTY_FUNCTION__));
 p = lu_atom("F");
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 153, __extension__ __PRETTY_FUNCTION__));
 p = ((CONS*)((((WORD)(lu_atom_root)) & ~((WORD)(0x00000003))) | ((WORD)(0x00000000))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 156; dbug_print ("lu_atom_root=%s", cons_to_str(p)); }}while(0);
 dbug_ctx.line = 157; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void test_atom()
{
 struct cons *p;
 struct cons *q;
 char *s;
 char buf[256];
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_atom"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 130; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 printf("--test_atom--\n");
 p = lu_atom(((void *)0));
 q = lu_atom("");
 ((((BOOL)((p)==((struct cons *)(&nil__cons))))) ? (void) (0) : __assert_fail ("nilp(p)", "atom.c", 134, __extension__ __PRETTY_FUNCTION__));
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 135, __extension__ __PRETTY_FUNCTION__));
 ((atom_str(q)[0] == '\0') ? (void) (0) : __assert_fail ("atom_str(q)[0] == '\\0'", "atom.c", 136, __extension__ __PRETTY_FUNCTION__));
 s = "T";
 strncpy(buf, s, sizeof(buf - 1));
 p = lu_atom(s);
 q = lu_atom(buf);
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 142, __extension__ __PRETTY_FUNCTION__));
 q = lu_atom("n");
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 144, __extension__ __PRETTY_FUNCTION__));
 s = "nil";
 strncpy(buf, s, sizeof(buf - 1));
 p = lu_atom(s);
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 148, __extension__ __PRETTY_FUNCTION__));
 ((strcmp(s, atom_str(p)) == 0) ? (void) (0) : __assert_fail ("strcmp(s, atom_str(p)) == 0", "atom.c", 149, __extension__ __PRETTY_FUNCTION__));
 q = lu_atom(buf);
 ((p == q) ? (void) (0) : __assert_fail ("p == q", "atom.c", 151, __extension__ __PRETTY_FUNCTION__));
 p = lu_atom("F");
 ((p != q) ? (void) (0) : __assert_fail ("p != q", "atom.c", 153, __extension__ __PRETTY_FUNCTION__));
 p = ((struct cons *)((((WORD)(lu_atom_root)) & ~((WORD)(0x00000003))) | ((WORD)(0x00000000))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 156; dbug_print ("lu_atom_root=%s", cons_to_str(p)); }}while(0);
 dbug_ctx.line = 157; dbug_return (&dbug_ctx); return;
}

variable_types:
buf
char [256]


decompiled_code:
int report_atom_usage()
{
return printf("lu_cons_cnt=%d\n", (unsigned int)lu_cons_cnt);
}

canonical_decompiled_code:
int func5()
{
return printf("lu_cons_cnt=%d\n", (unsigned int)lu_cons_cnt);
}

original_code:
void
report_atom_usage()
{
 printf("lu_cons_cnt=%d\n", lu_cons_cnt);
}


decompiled_code:
__int64 __fastcall test_number(__int64 a1, __int64 a2)
{
int v2; // edx
const char *v4; // [rsp+0h] [rbp-38h] BYREF
int v5; // [rsp+8h] [rbp-30h]
int v6; // [rsp+Ch] [rbp-2Ch]
void *v7; // [rsp+10h] [rbp-28h]
char **v8; // [rsp+18h] [rbp-20h]
__int64 v9; // [rsp+20h] [rbp-18h]

v4 = "test_number";
v2 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v9 = *(_QWORD *)(dbug_cfg + 80LL);
v6 = 173;
v5 = v2;
v7 = &unk_903;
v8 = &dbug_unit;
dbug_enter(&v4);
puts("--test_number--");
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 178;
dbug_print("NUMBER(%d)=16#%08lx", 0LL, 3LL);
}
a2 = dbug_on;
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 1LL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 196;
dbug_print("NUMBER(%d)=16#%08lx", 1LL, 7LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 212;
dbug_print("NUMBER(%d)=16#%08lx", 0xFFFFFFFFLL, -1LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 0x7FFFFFFLL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 228;
dbug_print("NUMBER(%d)=16#%08lx", 0x7FFFFFFLL, 0x1FFFFFFFLL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 4160749569LL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 235;
dbug_print("NUMBER(%d)=16#%08lx", 4160749569LL, -536870905LL);
}
}
}
}
}
}
v6 = 240;
return dbug_return(&v4, a2);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
int v2; // edx
const char *v4; // [rsp+0h] [rbp-38h] BYREF
int v5; // [rsp+8h] [rbp-30h]
int v6; // [rsp+Ch] [rbp-2Ch]
void *v7; // [rsp+10h] [rbp-28h]
char **v8; // [rsp+18h] [rbp-20h]
__int64 v9; // [rsp+20h] [rbp-18h]

v4 = "test_number";
v2 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v9 = *(_QWORD *)(dbug_cfg + 80LL);
v6 = 173;
v5 = v2;
v7 = &unk_903;
v8 = &dbug_unit;
dbug_enter(&v4);
puts("--test_number--");
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 178;
dbug_print("NUMBER(%d)=16#%08lx", 0LL, 3LL);
}
a2 = dbug_on;
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 1LL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 196;
dbug_print("NUMBER(%d)=16#%08lx", 1LL, 7LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 212;
dbug_print("NUMBER(%d)=16#%08lx", 0xFFFFFFFFLL, -1LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 0x7FFFFFFLL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 228;
dbug_print("NUMBER(%d)=16#%08lx", 0x7FFFFFFLL, 0x1FFFFFFFLL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_903;
if ( (unsigned int)dbug_keyword(&unk_903, a2) )
{
a2 = 4160749569LL;
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 235;
dbug_print("NUMBER(%d)=16#%08lx", 4160749569LL, -536870905LL);
}
}
}
}
}
}
v6 = 240;
return dbug_return(&v4, a2);
}

canonical_original_code:
void test_number()
{
 int i;
 int j;
 struct cons *p;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_number"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 173; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 printf("--test_number--\n");
 j = 0;
 p = ((struct cons *)((((WORD)(j))<<2) | ((WORD)(0x00000003))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 178; dbug_print ("NUMBER(%d)=16#%08lx", j, (unsigned long)p); }}while(0);
 ((((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(p)", "atom.c", 179, __extension__ __PRETTY_FUNCTION__));
 i = ((int)(((WORD)(p))>>2));
 ((0 == i) ? (void) (0) : __assert_fail ("0 == i", "atom.c", 181, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((p)==((struct cons *)(&nil__cons))))) ? (void) (0) : __assert_fail ("!nilp(p)", "atom.c", 182, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)(((p)!=((BOOL)(0)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000000)))))) ? (void) (0) : __assert_fail ("!consp(p)", "atom.c", 183, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("!atomp(p)", "atom.c", 184, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(((p)!=((BOOL)(1)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003)))))) ? (void) (0) : __assert_fail ("funcp(p)", "atom.c", 187, __extension__ __PRETTY_FUNCTION__));
 ((!(((p)==((BOOL)(0)))||((p)==((BOOL)(1))))) ? (void) (0) : __assert_fail ("!boolp(p)", "atom.c", 188, __extension__ __PRETTY_FUNCTION__));
 j = 1;
 p = ((struct cons *)((((WORD)(j))<<2) | ((WORD)(0x00000003))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 196; dbug_print ("NUMBER(%d)=16#%08lx", j, (unsigned long)p); }}while(0);
 ((((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(p)", "atom.c", 197, __extension__ __PRETTY_FUNCTION__));
 i = ((int)(((WORD)(p))>>2));
 ((i == j) ? (void) (0) : __assert_fail ("i == j", "atom.c", 199, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((p)==((struct cons *)(&nil__cons))))) ? (void) (0) : __assert_fail ("!nilp(p)", "atom.c", 200, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)(((p)!=((BOOL)(0)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000000)))))) ? (void) (0) : __assert_fail ("!consp(p)", "atom.c", 201, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("!atomp(p)", "atom.c", 202, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(((p)!=((BOOL)(1)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003)))))) ? (void) (0) : __assert_fail ("funcp(p)", "atom.c", 204, __extension__ __PRETTY_FUNCTION__));
 ((!(((p)==((BOOL)(0)))||((p)==((BOOL)(1))))) ? (void) (0) : __assert_fail ("!boolp(p)", "atom.c", 208, __extension__ __PRETTY_FUNCTION__));
 j = -1;
 p = ((struct cons *)((((WORD)(j))<<2) | ((WORD)(0x00000003))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 212; dbug_print ("NUMBER(%d)=16#%08lx", j, (unsigned long)p); }}while(0);
 ((((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(p)", "atom.c", 213, __extension__ __PRETTY_FUNCTION__));
 i = ((int)(((WORD)(p))>>2));
 ((i == j) ? (void) (0) : __assert_fail ("i == j", "atom.c", 215, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((p)==((struct cons *)(&nil__cons))))) ? (void) (0) : __assert_fail ("!nilp(p)", "atom.c", 216, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)(((p)!=((BOOL)(0)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000000)))))) ? (void) (0) : __assert_fail ("!consp(p)", "atom.c", 217, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000002))))) ? (void) (0) : __assert_fail ("!atomp(p)", "atom.c", 218, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(((p)!=((BOOL)(1)))&&((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003)))))) ? (void) (0) : __assert_fail ("funcp(p)", "atom.c", 220, __extension__ __PRETTY_FUNCTION__));
 ((!(((p)==((BOOL)(0)))||((p)==((BOOL)(1))))) ? (void) (0) : __assert_fail ("!boolp(p)", "atom.c", 224, __extension__ __PRETTY_FUNCTION__));
 j = 0x07FFFFFF;
 p = ((struct cons *)((((WORD)(j))<<2) | ((WORD)(0x00000003))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 228; dbug_print ("NUMBER(%d)=16#%08lx", j, (unsigned long)p); }}while(0);
 ((((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(p)", "atom.c", 229, __extension__ __PRETTY_FUNCTION__));
 i = ((int)(((WORD)(p))>>2));
 ((i == j) ? (void) (0) : __assert_fail ("i == j", "atom.c", 231, __extension__ __PRETTY_FUNCTION__));
 j = -j;
 p = ((struct cons *)((((WORD)(j))<<2) | ((WORD)(0x00000003))));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 235; dbug_print ("NUMBER(%d)=16#%08lx", j, (unsigned long)p); }}while(0);
 ((((BOOL)((((WORD)(p)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(p)", "atom.c", 236, __extension__ __PRETTY_FUNCTION__));
 i = ((int)(((WORD)(p))>>2));
 ((i == j) ? (void) (0) : __assert_fail ("i == j", "atom.c", 238, __extension__ __PRETTY_FUNCTION__));
 dbug_ctx.line = 240; dbug_return (&dbug_ctx); return;
}

variable_types: i int

variable_types: j int


decompiled_code:
char *__fastcall clear_sbuf(__int64 *a1)
{
__int64 v1; // rax

v1 = *a1;
a1[1] = 0LL;
return strncpy((char *)a1[2], &src, v1 + 1);
}

canonical_decompiled_code:
char *__fastcall func0(__int64 *a1)
{
__int64 v1; // rax

v1 = *a1;
a1[1] = 0LL;
return strncpy((char *)a1[2], &src, v1 + 1);
}

original_code:
void
clear_sbuf(SBUF* sbuf)
{
 sbuf->offset = 0;
 strncpy(sbuf->buf, "", sbuf->limit + 1);
}

canonical_original_code:
void clear_sbuf(struct string_buffer *sbuf)
{
 sbuf->offset = 0;
 strncpy(sbuf->buf, "", sbuf->limit + 1);
}

variable_types: struct string_buffer { unsigned long limit; unsigned long offset; char *buf; } *


decompiled_code:
__int64 __fastcall free_sbuf(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *ptr)
{
free(*((void **)ptr + 2));
free(ptr);
return 0LL;
}

original_code:
SBUF*
free_sbuf(SBUF* sbuf)
{
 free(sbuf->buf);
 free(sbuf);
 return ((void *)0);
}

canonical_original_code:
struct string_buffer *free_sbuf(struct string_buffer *sbuf)
{
 free(sbuf->buf);
 free(sbuf);
 return ((void *)0);
}

variable_types:
sbuf
struct string_buffer *

return_type: struct string_buffer { unsigned long limit; unsigned long offset; char *buf; } *


decompiled_code:
void __noreturn test_pre()
{
int v0; // edx
const char *v1; // [rsp+0h] [rbp-38h] BYREF
int v2; // [rsp+8h] [rbp-30h]
int v3; // [rsp+Ch] [rbp-2Ch]
void *v4; // [rsp+10h] [rbp-28h]
char **v5; // [rsp+18h] [rbp-20h]
__int64 v6; // [rsp+20h] [rbp-18h]

v1 = "test_pre";
v0 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v6 = *(_QWORD *)(dbug_cfg + 80LL);
v3 = 28;
v2 = v0;
v4 = &unk_2D1;
v5 = dbug_unit;
dbug_enter(&v1);
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 30;
dbug_print("sizeof(int)=%d", 4LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 31;
dbug_print("sizeof(CONS*)=%d", 8LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 32;
dbug_print("sizeof(BEH)=%d", 8LL);
}
}
}
}
_assert_fail("sizeof(int) == sizeof(CONS*)", "abe.c", 0x21u, "test_pre");
}

canonical_decompiled_code:
void __noreturn func0()
{
int v0; // edx
const char *v1; // [rsp+0h] [rbp-38h] BYREF
int v2; // [rsp+8h] [rbp-30h]
int v3; // [rsp+Ch] [rbp-2Ch]
void *v4; // [rsp+10h] [rbp-28h]
char **v5; // [rsp+18h] [rbp-20h]
__int64 v6; // [rsp+20h] [rbp-18h]

v1 = "test_pre";
v0 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v6 = *(_QWORD *)(dbug_cfg + 80LL);
v3 = 28;
v2 = v0;
v4 = &unk_2D1;
v5 = dbug_unit;
dbug_enter(&v1);
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 30;
dbug_print("sizeof(int)=%d", 4LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 31;
dbug_print("sizeof(CONS*)=%d", 8LL);
}
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_2D1;
if ( (unsigned int)dbug_keyword(&unk_2D1) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 32;
dbug_print("sizeof(BEH)=%d", 8LL);
}
}
}
}
_assert_fail("sizeof(int) == sizeof(CONS*)", "abe.c", 0x21u, "test_pre");
}

original_code:
void
test_pre()
{
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_pre"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 28; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 30; dbug_print ("sizeof(int)=%d", sizeof(int)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 31; dbug_print ("sizeof(CONS*)=%d", sizeof(CONS*)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 32; dbug_print ("sizeof(BEH)=%d", sizeof(BEH)); }}while(0);
 ((sizeof(int) == sizeof(CONS*)) ? (void) (0) : __assert_fail ("sizeof(int) == sizeof(CONS*)", "abe.c", 33, __extension__ __PRETTY_FUNCTION__));
 ((sizeof(BEH) == sizeof(CONS*)) ? (void) (0) : __assert_fail ("sizeof(BEH) == sizeof(CONS*)", "abe.c", 34, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 36; dbug_print ("NIL=16#%08lx (%p)", ((CONS*)(&nil__cons)), ((CONS*)(&nil__cons))); }}while(0);
 ((((BOOL)((((CONS*)(&nil__cons)))==((CONS*)(&nil__cons))))) ? (void) (0) : __assert_fail ("nilp(NIL)", "abe.c", 37, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)((((CONS*)(&nil__cons)))==((CONS*)(&nil__cons)))) == _nilp(((CONS*)(&nil__cons)))) ? (void) (0) : __assert_fail ("nilp(NIL) == _nilp(NIL)", "abe.c", 38, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 40; dbug_print ("sizeof(BOOL)=%d", sizeof(BOOL)); }}while(0);
 ((sizeof(BOOL) == sizeof(CONS*)) ? (void) (0) : __assert_fail ("sizeof(BOOL) == sizeof(CONS*)", "abe.c", 41, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 42; dbug_print ("TRUE=16#%08lx (%p)", ((BOOL)(1)), ((BOOL)(1))); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 43; dbug_print ("FALSE=16#%08lx (%p)", ((BOOL)(0)), ((BOOL)(0))); }}while(0);
 ((((BOOL)(1))) ? (void) (0) : __assert_fail ("TRUE", "abe.c", 44, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)(0))) ? (void) (0) : __assert_fail ("!FALSE", "abe.c", 45, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(1)) == ((BOOL)(0 == 0))) ? (void) (0) : __assert_fail ("TRUE == ((BOOL)(0 == 0))", "abe.c", 46, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(0)) == ((BOOL)(0 != 0))) ? (void) (0) : __assert_fail ("FALSE == ((BOOL)(0 != 0))", "abe.c", 47, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 53; dbug_print ("Type tag in LSB[1:0]"); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 61; dbug_print ("_Program[]=16#%08lx (%p)", _Program, _Program); }}while(0);
 ((_Program == ((void*)(((WORD)(((CONS*)((((WORD)(_Program))<<2) | ((WORD)(0x00000003))))))>>2))) ? (void) (0) : __assert_fail ("_Program == MK_PTR(MK_REF(_Program))", "abe.c", 62, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 69; dbug_print ("test_pre()=16#%08lx (%p)", test_pre, test_pre); }}while(0);
 ((test_pre == ((BEH)((ptrdiff_t)((void*)(((WORD)(((CONS*)((((WORD)(test_pre))<<2) | ((WORD)(0x00000003))))))>>2))))) ? (void) (0) : __assert_fail ("test_pre == MK_BEH(MK_FUNC(test_pre))", "abe.c", 70, __extension__ __PRETTY_FUNCTION__));
 dbug_ctx.line = 72; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void test_pre()
{
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("test_pre"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 28; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 30; dbug_print ("sizeof(int)=%d", sizeof(int)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 31; dbug_print ("sizeof(CONS*)=%d", sizeof(struct cons *)); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 32; dbug_print ("sizeof(BEH)=%d", sizeof(BEH)); }}while(0);
 ((sizeof(int) == sizeof(struct cons *)) ? (void) (0) : __assert_fail ("sizeof(int) == sizeof(CONS*)", "abe.c", 33, __extension__ __PRETTY_FUNCTION__));
 ((sizeof(BEH) == sizeof(struct cons *)) ? (void) (0) : __assert_fail ("sizeof(BEH) == sizeof(CONS*)", "abe.c", 34, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 36; dbug_print ("NIL=16#%08lx (%p)", ((struct cons *)(&nil__cons)), ((struct cons *)(&nil__cons))); }}while(0);
 ((((BOOL)((((struct cons *)(&nil__cons)))==((struct cons *)(&nil__cons))))) ? (void) (0) : __assert_fail ("nilp(NIL)", "abe.c", 37, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)((((struct cons *)(&nil__cons)))==((struct cons *)(&nil__cons)))) == _nilp(((struct cons *)(&nil__cons)))) ? (void) (0) : __assert_fail ("nilp(NIL) == _nilp(NIL)", "abe.c", 38, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 40; dbug_print ("sizeof(BOOL)=%d", sizeof(BOOL)); }}while(0);
 ((sizeof(BOOL) == sizeof(struct cons *)) ? (void) (0) : __assert_fail ("sizeof(BOOL) == sizeof(CONS*)", "abe.c", 41, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 42; dbug_print ("TRUE=16#%08lx (%p)", ((BOOL)(1)), ((BOOL)(1))); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 43; dbug_print ("FALSE=16#%08lx (%p)", ((BOOL)(0)), ((BOOL)(0))); }}while(0);
 ((((BOOL)(1))) ? (void) (0) : __assert_fail ("TRUE", "abe.c", 44, __extension__ __PRETTY_FUNCTION__));
 ((!((BOOL)(0))) ? (void) (0) : __assert_fail ("!FALSE", "abe.c", 45, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(1)) == ((BOOL)(0 == 0))) ? (void) (0) : __assert_fail ("TRUE == ((BOOL)(0 == 0))", "abe.c", 46, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(0)) == ((BOOL)(0 != 0))) ? (void) (0) : __assert_fail ("FALSE == ((BOOL)(0 != 0))", "abe.c", 47, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 53; dbug_print ("Type tag in LSB[1:0]"); }}while(0);
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 61; dbug_print ("_Program[]=16#%08lx (%p)", _Program, _Program); }}while(0);
 ((_Program == ((void *)(((WORD)(((struct cons *)((((WORD)(_Program))<<2) | ((WORD)(0x00000003))))))>>2))) ? (void) (0) : __assert_fail ("_Program == MK_PTR(MK_REF(_Program))", "abe.c", 62, __extension__ __PRETTY_FUNCTION__));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 69; dbug_print ("test_pre()=16#%08lx (%p)", test_pre, test_pre); }}while(0);
 ((test_pre == ((BEH)((long)((void *)(((WORD)(((struct cons *)((((WORD)(test_pre))<<2) | ((WORD)(0x00000003))))))>>2))))) ? (void) (0) : __assert_fail ("test_pre == MK_BEH(MK_FUNC(test_pre))", "abe.c", 70, __extension__ __PRETTY_FUNCTION__));
 dbug_ctx.line = 72; dbug_return (&dbug_ctx); return;
}


decompiled_code:
__int64 system_info()
{
__int64 v0; // r12
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // r12
__int64 v7; // rax

v0 = lu_atom(Program);
v1 = lu_atom("Program");
v2 = map_put(&nil__cons, v1, v0);
v3 = lu_atom(Version);
v4 = lu_atom("Version");
v5 = map_put(v2, v4, v3);
v6 = lu_atom(Copyright);
v7 = lu_atom("Copyright");
return map_put(v5, v7, v6);
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // r12
__int64 v1; // rax
__int64 v2; // rbp
__int64 v3; // r12
__int64 v4; // rax
__int64 v5; // rbp
__int64 v6; // r12
__int64 v7; // rax

v0 = lu_atom(Program);
v1 = lu_atom("Program");
v2 = map_put(&nil__cons, v1, v0);
v3 = lu_atom(Version);
v4 = lu_atom("Version");
v5 = map_put(v2, v4, v3);
v6 = lu_atom(Copyright);
v7 = lu_atom("Copyright");
return map_put(v5, v7, v6);
}

original_code:
CONS*
system_info()
{
 CONS* info = ((CONS*)(&nil__cons));
 info = map_put(info, lu_atom("Program"), lu_atom(_Program));
 info = map_put(info, lu_atom("Version"), lu_atom(_Version));
 info = map_put(info, lu_atom("Copyright"), lu_atom(_Copyright));
 return info;
}

canonical_original_code:
struct cons *system_info()
{
 struct cons *info = ((CONS*)(&nil__cons));
 info = map_put(info, lu_atom("Program"), lu_atom(_Program));
 info = map_put(info, lu_atom("Version"), lu_atom(_Version));
 info = map_put(info, lu_atom("Copyright"), lu_atom(_Copyright));
 return info;
}


canonical_decompiled_code:
int func4()
{
return printf("%s v%s -- %s\n", Program, Version, Copyright);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("Doing something in main...");
somethingInFile2("Doing something in main...", argv);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("Doing something in main...");
func7("Doing something in main...", argv);
return 0;
}

original_code:
int main()
{
 printf("Doing something in main...\n");
 somethingInFile2();
 return 0;
}


decompiled_code:
int somethingInFile2()
{
return puts("Doing something in file2...");
}

canonical_decompiled_code:
int func7()
{
return puts("Doing something in file2...");
}

original_code:
void somethingInFile2()
{
 printf("Doing something in file2...\n");
}


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

if ( argc == 3 )
{
if ( (unsigned int)load_factory(argv[1], argv[2], envp) )
{
result = 0;
}
else
{
puts("[ERROR] Cannot load factory");
result = -1;
}
}
else
{
puts("[ERROR] Invalid syntax: ./production <belts> <robots>");
result = -2;
}
return result;
}

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

if ( argc == 3 )
{
if ( (unsigned int)func9(argv[1], argv[2], envp) )
{
result = 0;
}
else
{
puts("[ERROR] Cannot load factory");
result = -1;
}
}
else
{
puts("[ERROR] Invalid syntax: ./production <belts> <robots>");
result = -2;
}
return result;
}

original_code:
int main (int argc, char ** argv){
 int result = 0;
 if(argc == 3){
  if(load_factory(argv[1], argv[2])){
   finish_production_factory();
  }else{
   printf("[ERROR] Cannot load factory\n");
   result = -1;
  }
 }else{
  printf("[ERROR] Invalid syntax: ./production <belts> <robots>\n");
  result = -2;
 }
 return result;
}

canonical_original_code:
int main(int argc, char **argv){
 int result = 0;
 if(argc == 3){
  if(load_factory(argv[1], argv[2])){
   finish_production_factory();
  }else{
   printf("[ERROR] Cannot load factory\n");
   result = -1;
  }
 }else{
  printf("[ERROR] Invalid syntax: ./production <belts> <robots>\n");
  result = -2;
 }
 return result;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: result int


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

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

original_code:
void * conveyor_belt(void * data){
 return ((void *)0);
}

canonical_original_code:
void *conveyor_belt(void *data){
 return ((void *)0);
}

variable_types:
data
void *

return_type: void *


decompiled_code:
// attributes: thunk
__int64 assembly_robot()
{
return conveyor_belt();
}

canonical_decompiled_code:
__int64 func8()
{
return func7();
}

original_code:
void * assembly_robot(void * data){
 return ((void *)0);
}

canonical_original_code:
void *assembly_robot(void *data){
 return ((void *)0);
}


decompiled_code:
void finish_production_factory()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
void finish_production_factory(){
}

canonical_original_code:
void finish_production_factory(){
}


timestring

repo: dandavison/shellfish

decompiled_code:
char *timestring()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
v0 = localtime(&timer);
strftime(buff_0, 0x64uLL, "%a %d %b %H:%M:%S", v0);
return buff_0;
}

canonical_decompiled_code:
char *func0()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
v0 = localtime(&timer);
strftime(buff_0, 0x64uLL, "%a %d %b %H:%M:%S", v0);
return buff_0;
}

original_code:
char *timestring() {
    static char buff[100] ;
    time_t t ;
    time(&t) ;
    strftime(buff, 100, "%a %d %b %H:%M:%S", localtime(&t)) ;
    return buff ;
}

canonical_original_code:
char *timestring() {
    static char buff[100];
    long t;
    time(&t) ;
    strftime(buff, 100, "%a %d %b %H:%M:%S", localtime(&t)) ;
    return buff ;
}

variable_types:
buff
char [100]

variable_types: t long


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

va_start(arg, format);
fflush(stdout);
vfprintf(stdout, format, arg);
return fflush(stdout);
}

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

va_start(arg, format);
fflush(stdout);
vfprintf(stdout, format, arg);
return fflush(stdout);
}

original_code:
void print_stdout(char *fmt, ...) {
    va_list args;
    fflush(stdout);
    __builtin_va_start(args,fmt);
    vfprintf(stdout, fmt, args);
    __builtin_va_end(args);
    fflush(stdout) ;
}

canonical_original_code:
void print_stdout(char *fmt, ...) {
    __builtin_va_list args;
    fflush(stdout);
    __builtin_va_start(args,fmt);
    vfprintf(stdout, fmt, args);
    __builtin_va_end(args);
    fflush(stdout) ;
}

variable_types:
fmt
char *


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

va_start(arg, format);
fflush(stderr);
vfprintf(stderr, format, arg);
return fflush(stderr);
}

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

va_start(arg, format);
fflush(stderr);
vfprintf(stderr, format, arg);
return fflush(stderr);
}

original_code:
void print_stderr(char *fmt, ...) {
    va_list args;
    fflush(stderr);
    __builtin_va_start(args,fmt);
    vfprintf(stderr, fmt, args);
    __builtin_va_end(args);
    fflush(stderr) ;
}

canonical_original_code:
void print_stderr(char *fmt, ...) {
    __builtin_va_list args;
    fflush(stderr);
    __builtin_va_start(args,fmt);
    vfprintf(stderr, fmt, args);
    __builtin_va_end(args);
    fflush(stderr) ;
}


eprintf

decompiled_code:
void __noreturn eprintf(char *s, ...)
{
int *v1; // rax
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, s);
fflush(stdout);
vfprintf(stderr, s, arg);
if ( *s )
{
if ( s[strlen(s) - 1] == 58 )
{
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, " %s", v2);
}
}
fputc(10, stderr);
exit(2);
}

canonical_decompiled_code:
void __noreturn func3(char *s, ...)
{
int *v1; // rax
char *v2; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, s);
fflush(stdout);
vfprintf(stderr, s, arg);
if ( *s )
{
if ( s[strlen(s) - 1] == 58 )
{
v1 = _errno_location();
v2 = strerror(*v1);
fprintf(stderr, " %s", v2);
}
}
fputc(10, stderr);
exit(2);
}

original_code:
void eprintf(char *fmt, ...)
{
    va_list args;
    fflush(stdout);
    __builtin_va_start(args,fmt);
    vfprintf(stderr, fmt, args);
    __builtin_va_end(args);
    if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':')
 fprintf(stderr, " %s", strerror((*__errno_location ())));
    fprintf(stderr, "\n");
    exit(2);
}

canonical_original_code:
void eprintf(char *fmt, ...)
{
    __builtin_va_list args;
    fflush(stdout);
    __builtin_va_start(args,fmt);
    vfprintf(stderr, fmt, args);
    __builtin_va_end(args);
    if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':')
 fprintf(stderr, " %s", strerror((*__errno_location ())));
    fprintf(stderr, "\n");
    exit(2);
}


decompiled_code:
void *__fastcall malloc_dan(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
eprintf("malloc failed:");
return result;
}

canonical_decompiled_code:
void *__fastcall func4(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
func3("malloc failed:");
return result;
}

original_code:
void *malloc_dan(size_t size) {
    void *p = malloc(size) ;
    if(p == ((void *)0)) eprintf("malloc failed:") ;
    return p ;
}

canonical_original_code:
void *malloc_dan(unsigned long size) {
    void *p = malloc(size);
    if(p == ((void *)0)) eprintf("malloc failed:") ;
    return p ;
}

variable_types:
size
unsigned long

variable_types:
p
void *


decompiled_code:
void *__fastcall calloc_dan(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
eprintf("calloc failed:");
return result;
}

canonical_decompiled_code:
void *__fastcall func5(size_t a1, size_t a2)
{
void *result; // rax

result = calloc(a1, a2);
if ( !result )
func3("calloc failed:");
return result;
}

original_code:
void *calloc_dan(size_t nmemb, size_t size) {
    void *p = calloc(nmemb, size) ;
    if(p == ((void *)0)) eprintf("calloc failed:") ;
    return p ;
}

canonical_original_code:
void *calloc_dan(unsigned long nmemb, unsigned long size) {
    void *p = calloc(nmemb, size);
    if(p == ((void *)0)) eprintf("calloc failed:") ;
    return p ;
}

variable_types:
nmemb
unsigned long


weprintf

decompiled_code:
int weprintf(char *s, ...)
{
int *v2; // rax
char *v3; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, s);
fflush(stdout);
fwrite("warning: ", 1uLL, 9uLL, stderr);
vfprintf(stderr, s, arg);
if ( !*s || s[strlen(s) - 1] != 58 )
return fputc(10, stderr);
v2 = _errno_location();
v3 = strerror(*v2);
return fprintf(stderr, " %s\n", v3);
}

canonical_decompiled_code:
int func6(char *s, ...)
{
int *v2; // rax
char *v3; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, s);
fflush(stdout);
fwrite("warning: ", 1uLL, 9uLL, stderr);
vfprintf(stderr, s, arg);
if ( !*s || s[strlen(s) - 1] != 58 )
return fputc(10, stderr);
v2 = _errno_location();
v3 = strerror(*v2);
return fprintf(stderr, " %s\n", v3);
}

original_code:
void weprintf(char *fmt, ...)
{
 va_list args;
 fflush(stdout);
 fprintf(stderr, "warning: ");
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
 if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':')
  fprintf(stderr, " %s\n", strerror((*__errno_location ())));
 else
  fprintf(stderr, "\n");
}

canonical_original_code:
void weprintf(char *fmt, ...)
{
 __builtin_va_list args;
 fflush(stdout);
 fprintf(stderr, "warning: ");
 __builtin_va_start(args,fmt);
 vfprintf(stderr, fmt, args);
 __builtin_va_end(args);
 if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':')
  fprintf(stderr, " %s\n", strerror((*__errno_location ())));
 else
  fprintf(stderr, "\n");
}


ERROR

decompiled_code:
void __fastcall __noreturn ERROR(const char *a1)
{
fputs(a1, stderr);
fputc(10, stderr);
exit(2);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1)
{
fputs(a1, stderr);
fputc(10, stderr);
exit(2);
}

original_code:
void ERROR (char *msg) {
    fputs(msg, stderr) ;
    fputc('\n', stderr) ;
    exit(2) ;
}

canonical_original_code:
void ERROR(char *msg) {
    fputs(msg, stderr) ;
    fputc('\n', stderr) ;
    exit(2) ;
}

variable_types:
msg
char *


usage

decompiled_code:
void __noreturn usage()
{
ERROR("lines -f linenumfile < inputfile ");
}

canonical_decompiled_code:
void __noreturn func8()
{
func7("lines -f linenumfile < inputfile ");
}

original_code:
void usage() {
    ERROR("lines -f linenumfile < inputfile ") ;
}


fseekerrormsg

decompiled_code:
void __noreturn fseekerrormsg()
{
ERROR(
"fseek error (Did you use a pipe and ask for non-monotonically increasing lines? You can't use a pipe in that case.) :");
}

canonical_decompiled_code:
void __noreturn func9()
{
func7(
"fseek error (Did you use a pipe and ask for non-monotonically increasing lines? You can't use a pipe in that case.) :");
}

original_code:
void fseekerrormsg() {
    ERROR("fseek error (Did you use a pipe and ask for non-monotonically increasing lines? You can't use a pipe in that case.) :") ;
}


eigen

decompiled_code:
void __fastcall eigen(__int64 a1, int a2, int a3, int a4, __int64 a5, __int64 a6)
{
void *v7; // r12
void *v8; // rbp
void *v9; // rbx
int v12[3]; // [rsp+1Ch] [rbp-8Ch] BYREF
char v13; // [rsp+29h] [rbp-7Fh] BYREF
char v14; // [rsp+2Ah] [rbp-7Eh] BYREF
char v15; // [rsp+2Bh] [rbp-7Dh] BYREF
int v16; // [rsp+2Ch] [rbp-7Ch] BYREF
int v17; // [rsp+30h] [rbp-78h] BYREF
int v18; // [rsp+34h] [rbp-74h] BYREF
char v19[4]; // [rsp+38h] [rbp-70h] BYREF
int v20; // [rsp+3Ch] [rbp-6Ch] BYREF
int v21; // [rsp+40h] [rbp-68h] BYREF
int v22; // [rsp+44h] [rbp-64h] BYREF
unsigned int v23; // [rsp+48h] [rbp-60h] BYREF
int v24; // [rsp+4Ch] [rbp-5Ch] BYREF
__int64 v25; // [rsp+50h] [rbp-58h] BYREF
__int64 v26; // [rsp+58h] [rbp-50h] BYREF
double v27; // [rsp+60h] [rbp-48h] BYREF
double v28[8]; // [rsp+68h] [rbp-40h] BYREF

v12[0] = a2;
v13 = a4 == 0 ? 86 : 78;
v15 = 76;
v16 = a2;
v20 = a2;
v27 = dlamch_constprop_0();
if ( a3 <= 0 || a2 <= a3 )
{
v14 = 65;
a3 = a2;
v18 = -1;
v17 = -1;
}
else
{
v14 = 73;
v18 = a2;
v17 = a2 - a3 + 1;
}
v22 = -1;
v21 = -1;
v26 = LC0;
v25 = LC0;
dsyevr_(
&v13,
&v14,
&v15,
v12,
a1,
&v16,
&v25,
&v26,
&v17,
&v18,
&v27,
v19,
a5,
a6,
&v20,
0LL,
v28,
&v21,
&v24,
&v22,
&v23);
if ( v23 )
{
print_stdout("INFO = %d", v23);
eprintf("eigen: dsyevr returned with error code when computing optimal size of work arrays.\n");
}
v22 = v24;
v21 = (int)v28[0];
v7 = (void *)malloc_dan(8LL * (int)v28[0]);
v8 = (void *)malloc_dan(4LL * v22);
v9 = (void *)malloc_dan(8LL * a3);
dsyevr_(
&v13,
&v14,
&v15,
v12,
a1,
&v16,
&v25,
&v26,
&v17,
&v18,
&v27,
v19,
a5,
a6,
&v20,
v9,
v7,
&v21,
v8,
&v22,
&v23);
if ( v23 )
{
print_stdout("INFO = %d", v23);
eprintf("eigen: dsyevr returned with error code.\n");
}
free(v7);
free(v8);
free(v9);
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, int a2, int a3, int a4, __int64 a5, __int64 a6)
{
void *v7; // r12
void *v8; // rbp
void *v9; // rbx
int v12[3]; // [rsp+1Ch] [rbp-8Ch] BYREF
char v13; // [rsp+29h] [rbp-7Fh] BYREF
char v14; // [rsp+2Ah] [rbp-7Eh] BYREF
char v15; // [rsp+2Bh] [rbp-7Dh] BYREF
int v16; // [rsp+2Ch] [rbp-7Ch] BYREF
int v17; // [rsp+30h] [rbp-78h] BYREF
int v18; // [rsp+34h] [rbp-74h] BYREF
char v19[4]; // [rsp+38h] [rbp-70h] BYREF
int v20; // [rsp+3Ch] [rbp-6Ch] BYREF
int v21; // [rsp+40h] [rbp-68h] BYREF
int v22; // [rsp+44h] [rbp-64h] BYREF
unsigned int v23; // [rsp+48h] [rbp-60h] BYREF
int v24; // [rsp+4Ch] [rbp-5Ch] BYREF
__int64 v25; // [rsp+50h] [rbp-58h] BYREF
__int64 v26; // [rsp+58h] [rbp-50h] BYREF
double v27; // [rsp+60h] [rbp-48h] BYREF
double v28[8]; // [rsp+68h] [rbp-40h] BYREF

v12[0] = a2;
v13 = a4 == 0 ? 86 : 78;
v15 = 76;
v16 = a2;
v20 = a2;
v27 = func0();
if ( a3 <= 0 || a2 <= a3 )
{
v14 = 65;
a3 = a2;
v18 = -1;
v17 = -1;
}
else
{
v14 = 73;
v18 = a2;
v17 = a2 - a3 + 1;
}
v22 = -1;
v21 = -1;
v26 = LC0;
v25 = LC0;
dsyevr_(
&v13,
&v14,
&v15,
v12,
a1,
&v16,
&v25,
&v26,
&v17,
&v18,
&v27,
v19,
a5,
a6,
&v20,
0LL,
v28,
&v21,
&v24,
&v22,
&v23);
if ( v23 )
{
print_stdout("INFO = %d", v23);
eprintf("eigen: dsyevr returned with error code when computing optimal size of work arrays.\n");
}
v22 = v24;
v21 = (int)v28[0];
v7 = (void *)malloc_dan(8LL * (int)v28[0]);
v8 = (void *)malloc_dan(4LL * v22);
v9 = (void *)malloc_dan(8LL * a3);
dsyevr_(
&v13,
&v14,
&v15,
v12,
a1,
&v16,
&v25,
&v26,
&v17,
&v18,
&v27,
v19,
a5,
a6,
&v20,
v9,
v7,
&v21,
v8,
&v22,
&v23);
if ( v23 )
{
print_stdout("INFO = %d", v23);
eprintf("eigen: dsyevr returned with error code.\n");
}
free(v7);
free(v8);
free(v9);
}

original_code:
void eigen(double *A, int dim, int nvecs, bool values_only, double *evals, double *evecs) {
    extern void dsyevr_(char *JOBZp, char *RANGEp, char *UPLOp, int *Np,
   double *A, int *LDAp, double *VLp, double *VUp,
   int *ILp, int *IUp, double *ABSTOLp, int *Mp,
   double *W, double *Z, int *LDZp, int *ISUPPZ,
   double *WORK, int *LWORKp, int *IWORK, int *LIWORKp,
   int *INFOp);
    char
 JOBZ = values_only ? 'N' : 'V',
 RANGE,
 UPLO = 'L' ;
    int
 LDA = dim,
 IL, IU,
 M,
 LDZ = dim,
 *ISUPPZ,
 LWORK,
 *IWORK,
 LIWORK,
 INFO,
 tmp_int ;
    double
 VL, VU,
 ABSTOL=dlamch('S'),
 *WORK,
 tmp_double ;
    if (nvecs > 0 && nvecs < dim) {
 RANGE = 'I' ;
 IL = dim - nvecs + 1;
 IU = dim ;
    }
    else {
 RANGE = 'A' ;
 nvecs = dim ;
 IL = IU = -1.0 ;
    }
    VL = VU = -1.0 ;
    LWORK = LIWORK = -1 ;
       dsyevr_(&JOBZ, &RANGE, &UPLO, &dim, A, &LDA, &VL, &VU,
     &IL, &IU, &ABSTOL, &M, evals, evecs, &LDZ, ISUPPZ,
     &tmp_double, &LWORK, &tmp_int, &LIWORK, &INFO);
    if(INFO != 0) {
 print_stdout("INFO = %d", INFO) ;
 eprintf("eigen: dsyevr returned with error code when computing optimal size of work arrays.\n") ;
    }
    LWORK = (int) tmp_double ;
    LIWORK = tmp_int ;
    WORK = (double *) malloc_dan((LWORK) * sizeof(double)) ;
    IWORK = (int *) malloc_dan((LIWORK) * sizeof(int)) ;
    ISUPPZ = (int *) malloc_dan((2 * nvecs) * sizeof(int)) ;
    dsyevr_(&JOBZ, &RANGE, &UPLO, &dim, A, &LDA, &VL, &VU,
     &IL, &IU, &ABSTOL, &M, evals, evecs, &LDZ, ISUPPZ,
     WORK, &LWORK, IWORK, &LIWORK, &INFO);
    if(INFO != 0) {
 print_stdout("INFO = %d", INFO) ;
 eprintf("eigen: dsyevr returned with error code.\n") ;
    }
    free(WORK) ;
    free(IWORK) ;
    free(ISUPPZ) ;
}

canonical_original_code:
void eigen(double *A, int dim, int nvecs, int values_only, double *evals, double *evecs) {
    extern void dsyevr_(char *JOBZp, char *RANGEp, char *UPLOp, int *Np, double *A, int *LDAp, double *VLp, double *VUp, int *ILp, int *IUp, double *ABSTOLp, int *Mp, double *W, double *Z, int *LDZp, int *ISUPPZ, double *WORK, int *LWORKp, int *IWORK, int *LIWORKp, int *INFOp);
    char JOBZ = values_only ? 'N' : 'V'; char RANGE; char UPLO = 'L';
    int LDA = dim; int IL; int IU; int M; int LDZ = dim; int *ISUPPZ; int LWORK; int *IWORK; int LIWORK; int INFO; int tmp_int;
    double VL; double VU; double ABSTOL = dlamch('S'); double *WORK; double tmp_double;
    if (nvecs > 0 && nvecs < dim) {
 RANGE = 'I' ;
 IL = dim - nvecs + 1;
 IU = dim ;
    }
    else {
 RANGE = 'A' ;
 nvecs = dim ;
 IL = IU = -1.0 ;
    }
    VL = VU = -1.0 ;
    LWORK = LIWORK = -1 ;
       dsyevr_(&JOBZ, &RANGE, &UPLO, &dim, A, &LDA, &VL, &VU,
     &IL, &IU, &ABSTOL, &M, evals, evecs, &LDZ, ISUPPZ,
     &tmp_double, &LWORK, &tmp_int, &LIWORK, &INFO);
    if(INFO != 0) {
 print_stdout("INFO = %d", INFO) ;
 eprintf("eigen: dsyevr returned with error code when computing optimal size of work arrays.\n") ;
    }
    LWORK = (int) tmp_double ;
    LIWORK = tmp_int ;
    WORK = (double *) malloc_dan((LWORK) * sizeof(double)) ;
    IWORK = (int *) malloc_dan((LIWORK) * sizeof(int)) ;
    ISUPPZ = (int *) malloc_dan((2 * nvecs) * sizeof(int)) ;
    dsyevr_(&JOBZ, &RANGE, &UPLO, &dim, A, &LDA, &VL, &VU,
     &IL, &IU, &ABSTOL, &M, evals, evecs, &LDZ, ISUPPZ,
     WORK, &LWORK, IWORK, &LIWORK, &INFO);
    if(INFO != 0) {
 print_stdout("INFO = %d", INFO) ;
 eprintf("eigen: dsyevr returned with error code.\n") ;
    }
    free(WORK) ;
    free(IWORK) ;
    free(ISUPPZ) ;
}

variable_types:
A
double *

variable_types: dim int

variable_types: nvecs int

variable_types:
evals
double *

variable_types:
evecs
double *

variable_types: void (char *JOBZp, char *RANGEp, char *UPLOp, int *Np, double *A, int *LDAp, double *VLp, double *VUp, int *ILp, int *IUp, double *ABSTOLp, int *Mp, double *W, double *Z, int *LDZp, int *ISUPPZ, double *WORK, int *LWORKp, int *IWORK, int *LIWORKp, int *INFOp)

variable_types: JOBZ char

variable_types: RANGE char

variable_types: UPLO char

variable_types: LDA int

variable_types: IL int

variable_types: IU int

variable_types: M int

variable_types: LDZ int

variable_types:
ISUPPZ
int *

variable_types: LWORK int

variable_types:
IWORK
int *

variable_types: LIWORK int

variable_types: INFO int

variable_types: VL double

variable_types: VU double

variable_types: ABSTOL double

variable_types:
WORK
double *


XTX

decompiled_code:
__int64 __fastcall XTX(__int64 a1, unsigned int a2, unsigned int a3, double a4)
{
__int64 v4; // r12
__int64 v5; // r13

v4 = a3;
v5 = calloc_dan((int)(a3 * a3), 8LL);
if ( !v5 )
eprintf("XTX alloc error\n");
cblas_dsyrk(102LL, 122LL, 112LL, (unsigned int)v4, a2, a1, a4, 0.0, a2, v5, v4);
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int a2, unsigned int a3, double a4)
{
__int64 v4; // r12
__int64 v5; // r13

v4 = a3;
v5 = calloc_dan((int)(a3 * a3), 8LL);
if ( !v5 )
eprintf("XTX alloc error\n");
cblas_dsyrk(102LL, 122LL, 112LL, (unsigned int)v4, a2, a1, a4, 0.0, a2, v5, v4);
return v5;
}

original_code:
double *XTX(double *X, int nrow, int ncol, double alpha) {
    double *ans = (double *) calloc_dan((ncol * ncol), sizeof(double)) ; if(ans == ((void *)0)) eprintf("XTX alloc error\n") ;
    cblas_dsyrk(CblasColMajor,
  CblasLower,
  CblasTrans,
  ncol,
  nrow,
  alpha,
  X,
  nrow,
  0.0,
  ans,
  ncol) ;
    return ans ;
}

canonical_original_code:
double *XTX(double *X, int nrow, int ncol, double alpha) {
    double *ans = (double *) calloc_dan((ncol * ncol), sizeof(double)); if(ans == ((void *)0)) eprintf("XTX alloc error\n") ;
    cblas_dsyrk(CblasColMajor,
  CblasLower,
  CblasTrans,
  ncol,
  nrow,
  alpha,
  X,
  nrow,
  0.0,
  ans,
  ncol) ;
    return ans ;
}

variable_types:
X
double *

variable_types: nrow int

variable_types: ncol int

variable_types: alpha double

variable_types:
ans
double *

return_type: double *


decompiled_code:
__int64 __fastcall matprod_general(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7, unsigned int a8, __int64 a9)
{
unsigned int v9; // eax
__int64 v11; // rcx
unsigned int v12; // er9
__int64 v13; // r8
unsigned int v14; // er13

v9 = a5;
v11 = a6;
v12 = a5;
v13 = a8;
if ( !a3 )
{
v12 = v11;
v11 = v9;
}
if ( !a4 )
{
if ( v12 == a7 )
{
v14 = 111;
goto LABEL_8;
}
LODWORD(v13) = a7;
LABEL_10:
print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", v12, (unsigned int)v13);
exit(1);
}
if ( v12 != a8 )
goto LABEL_10;
v13 = a7;
v14 = 112;
LABEL_8:
cblas_dgemm(102LL, 111 - ((unsigned int)(a3 == 0) - 1), v14, v11, v13);
return a9;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7, unsigned int a8, __int64 a9)
{
unsigned int v9; // eax
__int64 v11; // rcx
unsigned int v12; // er9
__int64 v13; // r8
unsigned int v14; // er13

v9 = a5;
v11 = a6;
v12 = a5;
v13 = a8;
if ( !a3 )
{
v12 = v11;
v11 = v9;
}
if ( !a4 )
{
if ( v12 == a7 )
{
v14 = 111;
goto LABEL_8;
}
LODWORD(v13) = a7;
LABEL_10:
print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", v12, (unsigned int)v13);
exit(1);
}
if ( v12 != a8 )
goto LABEL_10;
v13 = a7;
v14 = 112;
LABEL_8:
cblas_dgemm(102LL, 111 - ((unsigned int)(a3 == 0) - 1), v14, v11, v13);
return a9;
}

original_code:
double *matprod_general(double *A, double *B, bool Atranspose, bool Btranspose,
   int nrowA, int ncolA, int nrowB, int ncolB, double alpha, double beta, double *C) {
    int nrowL, ncolL,
 nrowR, ncolR ;
    int K ;
    if(Atranspose) {
 nrowL = ncolA ;
 ncolL = nrowA ;
    }
    else {
 nrowL = nrowA ;
 ncolL = ncolA ;
    }
    if(Btranspose) {
 nrowR = ncolB ;
 ncolR = nrowB ;
    }
    else {
 nrowR = nrowB ;
 ncolR = ncolB ;
    }
    if(ncolL != nrowR) {
 print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", ncolL, nrowR) ;
 exit(1) ;
    }
    K = ncolL ;
    cblas_dgemm(CblasColMajor,
  Atranspose ? CblasTrans : CblasNoTrans,
  Btranspose ? CblasTrans : CblasNoTrans,
  nrowL,
  ncolR,
  K,
  alpha,
  A,
  nrowA,
  B,
  nrowB,
  beta,
  C,
  nrowL
  ) ;
    return C ;
}

canonical_original_code:
double *matprod_general(double *A, double *B, int Atranspose, int Btranspose, int nrowA, int ncolA, int nrowB, int ncolB, double alpha, double beta, double *C) {
    int nrowL; int ncolL; int nrowR; int ncolR;
    int K;
    if(Atranspose) {
 nrowL = ncolA ;
 ncolL = nrowA ;
    }
    else {
 nrowL = nrowA ;
 ncolL = ncolA ;
    }
    if(Btranspose) {
 nrowR = ncolB ;
 ncolR = nrowB ;
    }
    else {
 nrowR = nrowB ;
 ncolR = ncolB ;
    }
    if(ncolL != nrowR) {
 print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", ncolL, nrowR) ;
 exit(1) ;
    }
    K = ncolL ;
    cblas_dgemm(CblasColMajor,
  Atranspose ? CblasTrans : CblasNoTrans,
  Btranspose ? CblasTrans : CblasNoTrans,
  nrowL,
  ncolR,
  K,
  alpha,
  A,
  nrowA,
  B,
  nrowB,
  beta,
  C,
  nrowL
  ) ;
    return C ;
}

variable_types:
A
double *

variable_types:
B
double *

variable_types: Atranspose int

variable_types: Btranspose int

variable_types: nrowA int

variable_types: ncolA int

variable_types: nrowB int

variable_types: ncolB int

variable_types: beta double

variable_types:
C
double *

variable_types: nrowL int

variable_types: ncolL int

variable_types: nrowR int

variable_types: ncolR int

variable_types: K int


matprod

decompiled_code:
__int64 __fastcall matprod(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7, unsigned int a8)
{
unsigned int v13; // ebx
__int64 v14; // rsi
unsigned int v15; // edi
unsigned int v16; // eax
__int64 v17; // rdx
__int64 v18; // rax

v13 = a5;
if ( a3 )
{
v14 = a5;
v15 = a6;
if ( !a4 )
goto LABEL_3;
}
else
{
v14 = a6;
v15 = a5;
if ( !a4 )
{
LABEL_3:
v16 = a8;
v17 = a7;
goto LABEL_4;
}
}
v16 = a7;
v17 = a8;
LABEL_4:
if ( (_DWORD)v14 != (_DWORD)v17 )
{
print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", v14, v17);
exit(1);
}
v18 = calloc_dan((int)(v16 * v15), 8LL);
return matprod_general(a1, a2, a3, a4, v13, a6, a7, a8, v18);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, int a3, int a4, unsigned int a5, unsigned int a6, unsigned int a7, unsigned int a8)
{
unsigned int v13; // ebx
__int64 v14; // rsi
unsigned int v15; // edi
unsigned int v16; // eax
__int64 v17; // rdx
__int64 v18; // rax

v13 = a5;
if ( a3 )
{
v14 = a5;
v15 = a6;
if ( !a4 )
goto LABEL_3;
}
else
{
v14 = a6;
v15 = a5;
if ( !a4 )
{
LABEL_3:
v16 = a8;
v17 = a7;
goto LABEL_4;
}
}
v16 = a7;
v17 = a8;
LABEL_4:
if ( (_DWORD)v14 != (_DWORD)v17 )
{
print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", v14, v17);
exit(1);
}
v18 = calloc_dan((int)(v16 * v15), 8LL);
return func3(a1, a2, a3, a4, v13, a6, a7, a8, v18);
}

original_code:
double *matprod(double *A, double *B, bool Atranspose, bool Btranspose,
  int nrowA, int ncolA, int nrowB, int ncolB, double alpha) {
    int nrowL, ncolL,
 nrowR, ncolR ;
    int K ;
    double *ans, beta ;
    if(Atranspose) {
 nrowL = ncolA ;
 ncolL = nrowA ;
    }
    else {
 nrowL = nrowA ;
 ncolL = ncolA ;
    }
    if(Btranspose) {
 nrowR = ncolB ;
 ncolR = nrowB ;
    }
    else {
 nrowR = nrowB ;
 ncolR = ncolB ;
    }
    if(ncolL != nrowR) {
 print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", ncolL, nrowR) ;
 exit(1) ;
    }
    K = ncolL ;
    ans = (double *) calloc_dan((nrowL * ncolR), sizeof(double)) ;
    beta = 0.0 ;
    return matprod_general(A, B, Atranspose, Btranspose, nrowA, ncolA, nrowB, ncolB, alpha, beta, ans) ;
    eprintf("matprod now redefined as call to matprod general") ;
    return ans ;
}

canonical_original_code:
double *matprod(double *A, double *B, int Atranspose, int Btranspose, int nrowA, int ncolA, int nrowB, int ncolB, double alpha) {
    int nrowL; int ncolL; int nrowR; int ncolR;
    int K;
    double *ans; double beta;
    if(Atranspose) {
 nrowL = ncolA ;
 ncolL = nrowA ;
    }
    else {
 nrowL = nrowA ;
 ncolL = ncolA ;
    }
    if(Btranspose) {
 nrowR = ncolB ;
 ncolR = nrowB ;
    }
    else {
 nrowR = nrowB ;
 ncolR = ncolB ;
    }
    if(ncolL != nrowR) {
 print_stdout("matprod non-conformable error!\nncolL = %d\tnrowR = %d\n", ncolL, nrowR) ;
 exit(1) ;
    }
    K = ncolL ;
    ans = (double *) calloc_dan((nrowL * ncolR), sizeof(double)) ;
    beta = 0.0 ;
    return matprod_general(A, B, Atranspose, Btranspose, nrowA, ncolA, nrowB, ncolB, alpha, beta, ans) ;
    eprintf("matprod now redefined as call to matprod general") ;
    return ans ;
}

variable_types: alpha double


variable_types:
A
double []

variable_types:
B
double []

variable_types:
ans
double *