peekStream

decompiled_code:
__int64 __fastcall peekStream(__int64 a1, int a2)
{
int v2; // esi
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 4) + a2;
if ( v2 >= *(_DWORD *)a1 || v2 < 0 )
result = 0LL;
else
result = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + v2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2)
{
int v2; // esi
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 4) + a2;
if ( v2 >= *(_DWORD *)a1 || v2 < 0 )
result = 0LL;
else
result = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + v2);
return result;
}

original_code:
char peekStream(const Stream* s, int offset)
{
 if(s->offset+offset>=s->length || s->offset+offset<0)
  return '\0';
 else
  return s->data[s->offset+offset];
}

canonical_original_code:
char peekStream(struct Stream *s, int offset)
{
 if(s->offset+offset>=s->length || s->offset+offset<0)
  return '\0';
 else
  return s->data[s->offset+offset];
}

return_type: char


getStream

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

if ( *(_DWORD *)a1 <= a2 || a2 < 0 )
result = 0LL;
else
result = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + a2);
return result;
}

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

if ( *(_DWORD *)a1 <= a2 || a2 < 0 )
result = 0LL;
else
result = *(unsigned __int8 *)(*(_QWORD *)(a1 + 8) + a2);
return result;
}

original_code:
char getStream(const Stream* s, int position)
{
 if(position>=s->length || position<0)
  return '\0';
 else
  return s->data[position];
}

canonical_original_code:
char getStream(struct Stream *s, int position)
{
 if(position>=s->length || position<0)
  return '\0';
 else
  return s->data[position];
}

variable_types: struct Stream { int length; int offset; char *data; char *filename; void (*errorHandler)(); } *

variable_types: position int


printContext

decompiled_code:
void __fastcall printContext(int *a1, int a2, int a3)
{
int i; // ebx
char v5; // al
unsigned __int8 v6; // bp
bool v7; // al
int j; // ebp
char v9; // al
int v10; // er15
char v11; // al
bool v12; // al

if ( *a1 > a2 )
{
for ( i = a2; ; --i )
{
v5 = getStream((__int64)a1, i);
if ( !v5 || v5 == 10 )
break;
}
while ( 1 )
{
v6 = getStream((__int64)a1, i);
v7 = charIsWhitespace(v6);
if ( v6 )
{
if ( !v7 )
break;
}
++i;
}
for ( j = i; ; ++j )
{
v9 = getStream((__int64)a1, j);
if ( !v9 || v9 == 10 )
break;
}
fputc(9, stderr);
if ( i < j )
{
v10 = i;
do
{
v11 = getStream((__int64)a1, v10);
if ( v11 == 9 )
fputc(32, stderr);
else
fputc(v11, stderr);
++v10;
}
while ( j != v10 );
}
fputc(10, stderr);
fputc(9, stderr);
v12 = i < a3;
if ( j > a3 )
j = a3;
if ( i < j )
{
do
{
if ( a2 <= i && v12 )
fputc(94, stderr);
else
fputc(32, stderr);
v12 = a3 > ++i;
}
while ( i != j );
}
fputc(10, stderr);
}
}

canonical_decompiled_code:
void __fastcall func7(int *a1, int a2, int a3)
{
int i; // ebx
char v5; // al
unsigned __int8 v6; // bp
bool v7; // al
int j; // ebp
char v9; // al
int v10; // er15
char v11; // al
bool v12; // al

if ( *a1 > a2 )
{
for ( i = a2; ; --i )
{
v5 = func6((__int64)a1, i);
if ( !v5 || v5 == 10 )
break;
}
while ( 1 )
{
v6 = func6((__int64)a1, i);
v7 = func0(v6);
if ( v6 )
{
if ( !v7 )
break;
}
++i;
}
for ( j = i; ; ++j )
{
v9 = func6((__int64)a1, j);
if ( !v9 || v9 == 10 )
break;
}
fputc(9, stderr);
if ( i < j )
{
v10 = i;
do
{
v11 = func6((__int64)a1, v10);
if ( v11 == 9 )
fputc(32, stderr);
else
fputc(v11, stderr);
++v10;
}
while ( j != v10 );
}
fputc(10, stderr);
fputc(9, stderr);
v12 = i < a3;
if ( j > a3 )
j = a3;
if ( i < j )
{
do
{
if ( a2 <= i && v12 )
fputc(94, stderr);
else
fputc(32, stderr);
v12 = a3 > ++i;
}
while ( i != j );
}
fputc(10, stderr);
}
}

original_code:
static void printContext(const Stream* s, int start, int end)
{
 if(start<s->length)
 {
  int quote_start=start;
  while((getStream(s,quote_start))!='\n' && getStream(s,quote_start)!='\0')
   quote_start--;
  while(charIsWhitespace(getStream(s,quote_start)) || getStream(s,quote_start)=='\0')
   quote_start++;
  int quote_end=quote_start;
  while((getStream(s,quote_end))!='\n' && getStream(s,quote_end)!='\0')
   quote_end++;
  fprintf(stderr, "\t");
  for(int i=quote_start;i<quote_end;i++)
  {
   if(getStream(s,i)=='\t')
    fprintf(stderr," ");
   else
    fprintf(stderr,"%c",getStream(s,i));
  }
  fprintf(stderr, "\n");
  fprintf(stderr, "\t");
  for(int i=quote_start;i<quote_end && i<end;i++)
  {
   if(i>=start && i<end)
    fprintf(stderr, "^");
   else
    fprintf(stderr, " ");
  }
  fprintf(stderr, "\n");
 }
}

canonical_original_code:
static void printContext(struct Stream *s, int start, int end)
{
 if(start<s->length)
 {
  int quote_start = start;
  while((getStream(s,quote_start))!='\n' && getStream(s,quote_start)!='\0')
   quote_start--;
  while(charIsWhitespace(getStream(s,quote_start)) || getStream(s,quote_start)=='\0')
   quote_start++;
  int quote_end = quote_start;
  while((getStream(s,quote_end))!='\n' && getStream(s,quote_end)!='\0')
   quote_end++;
  fprintf(stderr, "\t");
  for(int i = quote_start;i<quote_end;i++)
  {
   if(getStream(s,i)=='\t')
    fprintf(stderr," ");
   else
    fprintf(stderr,"%c",getStream(s,i));
  }
  fprintf(stderr, "\n");
  fprintf(stderr, "\t");
  for(int i = quote_start;i<quote_end && i<end;i++)
  {
   if(i>=start && i<end)
    fprintf(stderr, "^");
   else
    fprintf(stderr, " ");
  }
  fprintf(stderr, "\n");
 }
}

variable_types: start int

variable_types: end int

variable_types: i int

return_type: void

user_defined_types: struct Stream { int length; int offset; char *data; char *filename; void (*errorHandler)(); }


seekStream

decompiled_code:
void __fastcall seekStream(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) += a2;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) += a2;
}

original_code:
void seekStream(Stream* s, int offset)
{
 s->offset+=offset;
}

canonical_original_code:
void seekStream(struct Stream *s, int offset)
{
 s->offset+=offset;
}

variable_types: offset int


makeString

decompiled_code:
void __fastcall makeString(__int64 a1, int a2, int a3, __int64 a4)
{
if ( a4 )
{
*(_DWORD *)a4 = a2;
*(_DWORD *)(a4 + 4) = a3;
*(_QWORD *)(a4 + 8) = a1;
}
}

original_code:
void makeString(Stream* s, int start, int end, String* out)
{
 if(out==((void *)0))
  return;
 *out=(String){
  .offset=start,
  .length=end,
  .stream=s,
 };
}

canonical_original_code:
void makeString(struct Stream *s, int start, int end, struct String *out)
{
 if(out==((void *)0))
  return;
 *out=(struct String){
  .offset=start,
  .length=end,
  .stream=s,
 };
}

variable_types: struct String { int offset; int length; struct Stream *stream; } *


compareString

original_code:
_Bool compareString(const String* a, const String* b)
{
 if(a->length!=b->length)
  return 0;
 for(int i=0;i<a->length;i++)
  if(a->stream->data[a->offset+i]!=b->stream->data[b->offset+i])
   return 0;
 return 1;
}

canonical_original_code:
_Bool compareString(struct String *a, struct String *b)
{
 if(a->length!=b->length)
  return 0;
 for(int i = 0;i<a->length;i++)
  if(a->stream->data[a->offset+i]!=b->stream->data[b->offset+i])
   return 0;
 return 1;
}

variable_types: struct String { int offset; int length; struct Stream { int length; int offset; char *data; char *filename; void (*errorHandler)(); } *stream; } *

variable_types:
b
struct String *

user_defined_types: struct String { int offset; int length; struct Stream *stream; }


warnStream

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

va_start(arg, a2);
printPosition(a1, *(_DWORD *)(a1 + 4), 0);
fwrite("warning: ", 1uLL, 9uLL, stderr);
vfprintf(stderr, a2, arg);
return fputc(10, stderr);
}

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

va_start(arg, a2);
func2(a1, *(_DWORD *)(a1 + 4), 0);
fwrite("warning: ", 1uLL, 9uLL, stderr);
vfprintf(stderr, a2, arg);
return fputc(10, stderr);
}

original_code:
void warnStream(const Stream* s, const char* format, ...)
{
    printPosition(s,s->offset,0);
 fprintf(stderr, "warning: ");
 va_list args;
 __builtin_va_start(args,format);
 vfprintf(stderr,format,args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
}

canonical_original_code:
void warnStream(struct Stream *s, char *format, ...)
{
    printPosition(s,s->offset,0);
 fprintf(stderr, "warning: ");
 __builtin_va_list args;
 __builtin_va_start(args,format);
 vfprintf(stderr,format,args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
}

variable_types:
format
char *


vpanicString

decompiled_code:
__int64 __fastcall vpanicString(__int64 a1, const char *a2, void *a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
__int64 v9; // rdi
int v10; // edx
int v11; // ecx
int v12; // er8
int v13; // er9

if ( !a1 )
goto LABEL_4;
v9 = *(_QWORD *)(a1 + 8);
if ( v9 )
{
printPosition(v9, *(_DWORD *)a1, *(_DWORD *)(a1 + 4));
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, a3);
fputc(10, stderr);
printContext(*(int **)(a1 + 8), *(_DWORD *)a1, *(_DWORD *)(a1 + 4) + *(_DWORD *)a1);
(*(void (**)(void))(*(_QWORD *)(a1 + 8) + 24LL))();
LABEL_4:
panic("stream.c", 206LL, "failed assertion: %s", "s!=NULL");
}
panic("stream.c", 207LL, "failed assertion: %s", "s->stream!=NULL");
return panicString((unsigned int)"stream.c", 207, v10, v11, v12, v13, a7);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, const char *a2, void *a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
__int64 v9; // rdi
int v10; // edx
int v11; // ecx
int v12; // er8
int v13; // er9

if ( !a1 )
goto LABEL_4;
v9 = *(_QWORD *)(a1 + 8);
if ( v9 )
{
func2(v9, *(_DWORD *)a1, *(_DWORD *)(a1 + 4));
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, a3);
fputc(10, stderr);
func7(*(int **)(a1 + 8), *(_DWORD *)a1, *(_DWORD *)(a1 + 4) + *(_DWORD *)a1);
(*(void (**)(void))(*(_QWORD *)(a1 + 8) + 24LL))();
LABEL_4:
panic("stream.c", 206LL, "failed assertion: %s", "s!=NULL");
}
panic("stream.c", 207LL, "failed assertion: %s", "s->stream!=NULL");
return func13((unsigned int)"stream.c", 207, v10, v11, v12, v13, a7);
}

original_code:
void vpanicString(const String* s, const char* format, va_list args)
{
 {if(!(s!=((void *)0))){panic("stream.c",206,"failed assertion: %s","s!=NULL");}};
 {if(!(s->stream!=((void *)0))){panic("stream.c",207,"failed assertion: %s","s->stream!=NULL");}};
 printPosition(s->stream,s->offset,s->length);
    fprintf(stderr, "error: ");
 vfprintf(stderr,format,args);
 fprintf(stderr, "\n");
 printContext(s->stream,s->offset,s->offset+s->length);
 s->stream->errorHandler();
 {if(!(0)){panic("stream.c",220,"failed assertion: %s","false");}};
}

canonical_original_code:
void vpanicString(struct String *s, char *format, __builtin_va_list args)
{
 {if(!(s!=((void *)0))){panic("stream.c",206,"failed assertion: %s","s!=NULL");}};
 {if(!(s->stream!=((void *)0))){panic("stream.c",207,"failed assertion: %s","s->stream!=NULL");}};
 printPosition(s->stream,s->offset,s->length);
    fprintf(stderr, "error: ");
 vfprintf(stderr,format,args);
 fprintf(stderr, "\n");
 printContext(s->stream,s->offset,s->offset+s->length);
 s->stream->errorHandler();
 {if(!(0)){panic("stream.c",220,"failed assertion: %s","false");}};
}


panicString

decompiled_code:
__int64 panicString(__int64 a1, const char *a2, ...)
{
char v3; // [rsp+0h] [rbp-D8h]
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF
__int64 v5; // [rsp+30h] [rbp-A8h]
__int64 v6; // [rsp+38h] [rbp-A0h]
__int64 v7; // [rsp+40h] [rbp-98h]
__int64 v8; // [rsp+48h] [rbp-90h]

va_start(va, a2);
v5 = va_arg(va, _QWORD);
v6 = va_arg(va, _QWORD);
v7 = va_arg(va, _QWORD);
v8 = va_arg(va, _QWORD);
va_end(va);
va_start(va, a2);
vpanicString(a1, a2, va, v6, v7, v8, v3);
return panicStream();
}

canonical_decompiled_code:
__int64 func13(__int64 a1, const char *a2, ...)
{
char v3; // [rsp+0h] [rbp-D8h]
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF
__int64 v5; // [rsp+30h] [rbp-A8h]
__int64 v6; // [rsp+38h] [rbp-A0h]
__int64 v7; // [rsp+40h] [rbp-98h]
__int64 v8; // [rsp+48h] [rbp-90h]

va_start(va, a2);
v5 = va_arg(va, _QWORD);
v6 = va_arg(va, _QWORD);
v7 = va_arg(va, _QWORD);
v8 = va_arg(va, _QWORD);
va_end(va);
va_start(va, a2);
func12(a1, a2, va, v6, v7, v8, v3);
return func14();
}

original_code:
void panicString(const String* s, const char* format, ...)
{
 va_list args;
 __builtin_va_start(args,format);
 vpanicString(s,format,args);
 __builtin_va_end(args);
}

canonical_original_code:
void panicString(struct String *s, char *format, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,format);
 vpanicString(s,format,args);
 __builtin_va_end(args);
}


panicStream

decompiled_code:
__int64 panicStream(__int64 a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, a2);
printPosition(a1, *(_DWORD *)(a1 + 4), 0);
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, arg);
fputc(10, stderr);
printContext((int *)a1, *(_DWORD *)(a1 + 4), *(_DWORD *)(a1 + 4) + 1);
(*(void (**)(void))(a1 + 24))();
return strdupString();
}

canonical_decompiled_code:
__int64 func14(__int64 a1, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-E0h] BYREF

va_start(arg, a2);
func2(a1, *(_DWORD *)(a1 + 4), 0);
fwrite("error: ", 1uLL, 7uLL, stderr);
vfprintf(stderr, a2, arg);
fputc(10, stderr);
func7((int *)a1, *(_DWORD *)(a1 + 4), *(_DWORD *)(a1 + 4) + 1);
(*(void (**)(void))(a1 + 24))();
return func15();
}

original_code:
_Bool panicStream(const Stream* s, const char* format, ...)
{
    printPosition(s,s->offset,0);
    fprintf(stderr, "error: ");
 va_list args;
 __builtin_va_start(args,format);
 vfprintf(stderr,format,args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
 printContext(s,s->offset,s->offset+1);
 s->errorHandler();
 {if(!(0)){panic("stream.c",249,"failed assertion: %s","false");}};
}

canonical_original_code:
_Bool panicStream(struct Stream *s, char *format, ...)
{
    printPosition(s,s->offset,0);
    fprintf(stderr, "error: ");
 __builtin_va_list args;
 __builtin_va_start(args,format);
 vfprintf(stderr,format,args);
 __builtin_va_end(args);
 fprintf(stderr, "\n");
 printContext(s,s->offset,s->offset+1);
 s->errorHandler();
 {if(!(0)){panic("stream.c",249,"failed assertion: %s","false");}};
}


strdupString

decompiled_code:
__int64 __fastcall strdupString(int *a1)
{
return (int)strndup((const char *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL) + *a1), (unsigned int)a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func15(int *a1)
{
return (int)strndup((const char *)(*(_QWORD *)(*((_QWORD *)a1 + 1) + 8LL) + *a1), (unsigned int)a1[1]);
}

original_code:
char* strdupString(const String* s)
{
 return strndup(s->stream->data+s->offset,s->length);
}

canonical_original_code:
char *strdupString(struct String *s)
{
 return strndup(s->stream->data+s->offset,s->length);
}

return_type: char *


copyString

original_code:
char* copyString(const String* s, char* buf, int len)
{
 int min(int a, int b)
 {
  return a>b?b:a;
 }
 for(int i=0;i<len&&i<s->length;i++)
  buf[i]=s->stream->data[s->offset+i];
 buf[min(len-1,s->length)]='\0';
 return buf;
}

canonical_original_code:
char *copyString(struct String *s, char *buf, int len)
{
 int min(int a, int b)
 {
  return a>b?b:a;
 }
 for(int i = 0;i<len&&i<s->length;i++)
  buf[i]=s->stream->data[s->offset+i];
 buf[min(len-1,s->length)]='\0';
 return buf;
}

variable_types:
buf
char *

variable_types: len int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
const char *v6; // r10
int v7; // eax
__int64 v8; // rdx
const char **v9; // rsi
const char *v10; // r8

if ( argc <= 1 )
goto LABEL_15;
v3 = 0x10000;
v6 = "out.bc";
v7 = 1;
while ( 1 )
{
v8 = v7;
v9 = &argv[v8];
v10 = argv[v8];
if ( !*v10 )
goto LABEL_5;
if ( *v10 != 45 )
return run(v3, (__int64)v6, argc - v7, v9);
if ( !strcmp(argv[v7], "--dump-pt") )
{
LOBYTE(v3) = 1;
goto LABEL_5;
}
if ( strcmp(argv[v7], "--dump-llvm") )
break;
BYTE1(v3) = 1;
LABEL_5:
if ( argc <= ++v7 )
goto LABEL_15;
}
if ( strcmp(argv[v7], "--output") )
goto LABEL_14;
v3 &= 0xFF00FFFF;
if ( ++v7 < argc )
{
v6 = argv[v8 + 1];
goto LABEL_5;
}
panic("lang.c", 79LL, "failed assertion: %s", "i+1<argc");
LABEL_14:
panic("lang.c", 85LL, "unknown option: %s", v10);
LABEL_15:
v9 = (const char **)(&loc_5E + 1);
v7 = panic("lang.c", 95LL, "no filename specified");
return run(v3, (__int64)v6, argc - v7, v9);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
const char *v6; // r10
int v7; // eax
__int64 v8; // rdx
const char **v9; // rsi
const char *v10; // r8

if ( argc <= 1 )
goto LABEL_15;
v3 = 0x10000;
v6 = "out.bc";
v7 = 1;
while ( 1 )
{
v8 = v7;
v9 = &argv[v8];
v10 = argv[v8];
if ( !*v10 )
goto LABEL_5;
if ( *v10 != 45 )
return func0(v3, (__int64)v6, argc - v7, v9);
if ( !strcmp(argv[v7], "--dump-pt") )
{
LOBYTE(v3) = 1;
goto LABEL_5;
}
if ( strcmp(argv[v7], "--dump-llvm") )
break;
BYTE1(v3) = 1;
LABEL_5:
if ( argc <= ++v7 )
goto LABEL_15;
}
if ( strcmp(argv[v7], "--output") )
goto LABEL_14;
v3 &= 0xFF00FFFF;
if ( ++v7 < argc )
{
v6 = argv[v8 + 1];
goto LABEL_5;
}
panic("lang.c", 79LL, "failed assertion: %s", "i+1<argc");
LABEL_14:
panic("lang.c", 85LL, "unknown option: %s", v10);
LABEL_15:
v9 = (const char **)(&loc_5E + 1);
v7 = panic("lang.c", 95LL, "no filename specified");
return func0(v3, (__int64)v6, argc - v7, v9);
}

original_code:
int main(int argc, const char* argv[])
{
 Config config={
  .output="out.bc",
  .run=1
 };
 for(int i=1;i<argc;i++)
 {
  if(strlen(argv[i])>0)
  {
   if(argv[i][0]=='-')
   {
    if(strcmp(argv[i],"--dump-pt")==0)
    {
     config.dumpPT=1;
    }
    else if(strcmp(argv[i],"--dump-llvm")==0)
    {
     config.dumpLLVM=1;
    }
    else if(strcmp(argv[i],"--output")==0)
    {
     config.run=0;
     {if(!(i+1<argc)){panic("lang.c",79,"failed assertion: %s","i+1<argc");}};
     config.output=argv[i+1];
     i++;
    }
    else
    {
     panic("lang.c",85,"unknown option: %s",argv[i]);
    }
   }
   else
   {
    return run(config,argc-i,&argv[i]);
   }
  }
 }
 panic("lang.c",95,"no filename specified");
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct Config config = {
  .output="out.bc",
  .run=1
 };
 for(int i = 1;i<argc;i++)
 {
  if(strlen(argv[i])>0)
  {
   if(argv[i][0]=='-')
   {
    if(strcmp(argv[i],"--dump-pt")==0)
    {
     config.dumpPT=1;
    }
    else if(strcmp(argv[i],"--dump-llvm")==0)
    {
     config.dumpLLVM=1;
    }
    else if(strcmp(argv[i],"--output")==0)
    {
     config.run=0;
     {if(!(i+1<argc)){panic("lang.c",79,"failed assertion: %s","i+1<argc");}};
     config.output=argv[i+1];
     i++;
    }
    else
    {
     panic("lang.c",85,"unknown option: %s",argv[i]);
    }
   }
   else
   {
    return run(config,argc-i,&argv[i]);
   }
  }
 }
 panic("lang.c",95,"no filename specified");
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct Config { _Bool dumpPT; _Bool dumpLLVM; _Bool run; char *output; }

return_type: int


parseOperator

decompiled_code:
__int64 __fastcall parseOperator(__int64 a1, unsigned int *a2, char a3)
{
unsigned int i; // ebx
__int64 result; // rax

for ( i = 0; i <= 0x17; ++i )
{
if ( (*((_DWORD *)&operators + 14 * i + 2) == 1) == a3 )
{
result = readString(a1, *((_QWORD *)&operators + 7 * i + 3));
if ( (_BYTE)result )
{
*a2 = i;
return result;
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int *a2, char a3)
{
unsigned int i; // ebx
__int64 result; // rax

for ( i = 0; i <= 0x17; ++i )
{
if ( (*((_DWORD *)&operators + 14 * i + 2) == 1) == a3 )
{
result = readString(a1, *((_QWORD *)&operators + 7 * i + 3));
if ( (_BYTE)result )
{
*a2 = i;
return result;
}
}
}
return 0LL;
}

original_code:
_Bool parseOperator(Stream* s, OperatorId* out, _Bool prefix)
{
 for(OperatorId op=0;op<OPERATOR_LAST;op++)
 {
  if((operators[op].type==PREFIX) == prefix)
   if(readString(s,operators[op].chars))
   {
    *out=op;
    return 1;
   }
 }
 return 0;
}

canonical_original_code:
_Bool parseOperator(struct Stream *s, enum OperatorId *out, _Bool prefix)
{
 for(enum OperatorId op = 0;op<OPERATOR_LAST;op++)
 {
  if((operators[op].type==PREFIX) == prefix)
   if(readString(s,operators[op].chars))
   {
    *out=op;
    return 1;
   }
 }
 return 0;
}

variable_types: enum OperatorId { OPERATOR_ELEMENT=0, OPERATOR_INDEX=1, OPERATOR_CALL=2, OPERATOR_POSTFIX_INCREMENT=3, OPERATOR_POSTFIX_DECREMENT=4, OPERATOR_DEREF=5, OPERATOR_ADDRESS=6, OPERATOR_PREFIX_INCREMENT=7, OPERATOR_PREFIX_DECREMENT=8, OPERATOR_PREFIX_PLUS=9, OPERATOR_PREFIX_MINUS=10, OPERATOR_MUL=11, OPERATOR_DIV=12, OPERATOR_IDIV=13, OPERATOR_MOD=14, OPERATOR_PLUS=15, OPERATOR_MINUS=16, OPERATOR_LT=17, OPERATOR_GT=18, OPERATOR_LE=19, OPERATOR_GE=20, OPERATOR_EQ=21, OPERATOR_NE=22, OPERATOR_ASSIGMENT=23, OPERATOR_LAST=24 } *


parseIdentifier

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

v2 = readIdentifier(a1, a2 + 8);
if ( (_BYTE)v2 )
{
*(_DWORD *)a2 = 1;
*(_QWORD *)(a2 + 24) = strdupString(a2 + 8);
}
return v2;
}

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

v2 = readIdentifier(a1, a2 + 8);
if ( (_BYTE)v2 )
{
*(_DWORD *)a2 = 1;
*(_QWORD *)(a2 + 24) = strdupString(a2 + 8);
}
return v2;
}

original_code:
_Bool parseIdentifier(Stream* s, Node* out)
{
 if(readIdentifier(s,&out->source))
 {
  out->type=IDENTIFIER;
  out->value=strdupString(&out->source);
  return 1;
 }
 else
 {
  return 0;
 }
}

canonical_original_code:
_Bool parseIdentifier(struct Stream *s, struct Node *out)
{
 if(readIdentifier(s,&out->source))
 {
  out->type=IDENTIFIER;
  out->value=strdupString(&out->source);
  return 1;
 }
 else
 {
  return 0;
 }
}

variable_types: struct Node { int type; struct String { int offset; int length; struct Stream *stream; } source; char *value; enum OperatorId { OPERATOR_ELEMENT=0, OPERATOR_INDEX=1, OPERATOR_CALL=2, OPERATOR_POSTFIX_INCREMENT=3, OPERATOR_POSTFIX_DECREMENT=4, OPERATOR_DEREF=5, OPERATOR_ADDRESS=6, OPERATOR_PREFIX_INCREMENT=7, OPERATOR_PREFIX_DECREMENT=8, OPERATOR_PREFIX_PLUS=9, OPERATOR_PREFIX_MINUS=10, OPERATOR_MUL=11, OPERATOR_DIV=12, OPERATOR_IDIV=13, OPERATOR_MOD=14, OPERATOR_PLUS=15, OPERATOR_MINUS=16, OPERATOR_LT=17, OPERATOR_GT=18, OPERATOR_LE=19, OPERATOR_GE=20, OPERATOR_EQ=21, OPERATOR_NE=22, OPERATOR_ASSIGMENT=23, OPERATOR_LAST=24 } operator; struct Node *child; struct Node *next; } *

user_defined_types: struct Node { int type; struct String source; char *value; enum OperatorId operator; struct Node *child; struct Node *next; }


parseExpresion

decompiled_code:
__int64 __fastcall parseExpresion(__int64 a1, __int64 a2)
{
return parseOperatorExpresion(a1, a2, parseSimpleExpresion, parseOperator);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return parseOperatorExpresion(a1, a2, parseSimpleExpresion, parseOperator);
}

original_code:
_Bool parseExpresion(Stream*s, Node* out)
{
 return parseOperatorExpresion(s, out, parseSimpleExpresion,parseOperator);
}

canonical_original_code:
_Bool parseExpresion(struct Stream *s, struct Node *out)
{
 return parseOperatorExpresion(s, out, parseSimpleExpresion,parseOperator);
}

variable_types: struct Stream { int length; int offset; char *data; char *filename; void (*errorHandler)(); } *

user_defined_types: enum OperatorId { OPERATOR_ELEMENT=0, OPERATOR_INDEX=1, OPERATOR_CALL=2, OPERATOR_POSTFIX_INCREMENT=3, OPERATOR_POSTFIX_DECREMENT=4, OPERATOR_DEREF=5, OPERATOR_ADDRESS=6, OPERATOR_PREFIX_INCREMENT=7, OPERATOR_PREFIX_DECREMENT=8, OPERATOR_PREFIX_PLUS=9, OPERATOR_PREFIX_MINUS=10, OPERATOR_MUL=11, OPERATOR_DIV=12, OPERATOR_IDIV=13, OPERATOR_MOD=14, OPERATOR_PLUS=15, OPERATOR_MINUS=16, OPERATOR_LT=17, OPERATOR_GT=18, OPERATOR_LE=19, OPERATOR_GE=20, OPERATOR_EQ=21, OPERATOR_NE=22, OPERATOR_ASSIGMENT=23, OPERATOR_LAST=24 }


parseSimpleExpresion

decompiled_code:
__int64 __fastcall parseSimpleExpresion(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v5; // er13

v2 = readString(a1, "null");
if ( (_BYTE)v2 )
{
v3 = v2;
*(_DWORD *)a2 = 7;
}
else
{
v3 = readString(a1, "true");
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 8;
}
else
{
v3 = readString(a1, "false");
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 9;
}
else
{
v3 = parseIdentifier(a1, a2);
if ( !(_BYTE)v3 )
{
v3 = readNumber(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 3;
*(_QWORD *)(a2 + 24) = strdupString(a2 + 8);
}
else
{
if ( (unsigned __int8)readString(a1, "(") )
{
v3 = parseExpresion(a1, a2);
if ( (_BYTE)v3 )
{
expect(a1, asc_BC4);
return v3;
}
panicStream(a1, "expected expresion");
}
v5 = readString(a1, &asc_BC4[1]);
if ( (_BYTE)v5 )
{
*(_DWORD *)a2 = 6;
while ( 1 )
{
v3 = readString(a1, &asc_BC4[2]);
if ( (_BYTE)v3 )
break;
v3 = childParse(a1, a2, parseExpresion);
if ( !(_BYTE)v3 )
{
expect(a1, &asc_BC4[2]);
return v5;
}
if ( !(unsigned __int8)readString(a1, &asc_BC4[3]) )
{
expect(a1, &asc_BC4[2]);
return v3;
}
}
}
else
{
v3 = readStringConstant(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 5;
*(_QWORD *)(a2 + 24) = unquoteString(a2 + 8);
}
else
{
v3 = readCharConstant(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 4;
*(_QWORD *)(a2 + 24) = unquoteString(a2 + 8);
}
}
}
}
}
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
unsigned int v5; // er13

v2 = readString(a1, "null");
if ( (_BYTE)v2 )
{
v3 = v2;
*(_DWORD *)a2 = 7;
}
else
{
v3 = readString(a1, "true");
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 8;
}
else
{
v3 = readString(a1, "false");
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 9;
}
else
{
v3 = func1(a1, a2);
if ( !(_BYTE)v3 )
{
v3 = readNumber(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 3;
*(_QWORD *)(a2 + 24) = strdupString(a2 + 8);
}
else
{
if ( (unsigned __int8)readString(a1, "(") )
{
v3 = func2(a1, a2);
if ( (_BYTE)v3 )
{
expect(a1, asc_BC4);
return v3;
}
panicStream(a1, "expected expresion");
}
v5 = readString(a1, &asc_BC4[1]);
if ( (_BYTE)v5 )
{
*(_DWORD *)a2 = 6;
while ( 1 )
{
v3 = readString(a1, &asc_BC4[2]);
if ( (_BYTE)v3 )
break;
v3 = childParse(a1, a2, parseExpresion);
if ( !(_BYTE)v3 )
{
expect(a1, &asc_BC4[2]);
return v5;
}
if ( !(unsigned __int8)readString(a1, &asc_BC4[3]) )
{
expect(a1, &asc_BC4[2]);
return v3;
}
}
}
else
{
v3 = readStringConstant(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 5;
*(_QWORD *)(a2 + 24) = unquoteString(a2 + 8);
}
else
{
v3 = readCharConstant(a1, a2 + 8);
if ( (_BYTE)v3 )
{
*(_DWORD *)a2 = 4;
*(_QWORD *)(a2 + 24) = unquoteString(a2 + 8);
}
}
}
}
}
}
}
}
return v3;
}

original_code:
_Bool parseSimpleExpresion(Stream* s, Node* out)
{
 if(readString(s,"null"))
 {
  out->type=NULL_CONSTANT;
 }
 else if(readString(s,"true"))
 {
  out->type=TRUE_CONSTANT;
 }
 else if(readString(s,"false"))
 {
  out->type=FALSE_CONSTANT;
 }
 else if(parseIdentifier(s,out))
 {
 }
 else if(readNumber(s,&out->source))
 {
  out->type=NUMERIC_CONSTANT;
  out->value=strdupString(&out->source);
 }
 else if(readString(s,"("))
 {
  parseExpresion(s,out) ?0: panicStream(s,"expected expresion");
  expect(s,")");
 }
 else if(readString(s,"{"))
 {
  out->type=STRUCT_CONSTANT;
  while(readString(s,"}")==0)
  {
   if(childParse(s,out,parseExpresion)==0)
   {
    expect(s,"}");
    break;
   }
   if(readString(s,",")==0)
   {
    expect(s,"}");
    break;
   }
  }
 }
 else if(readStringConstant(s,&out->source))
 {
  out->type=STRING_CONSTANT;
  out->value=unquoteString(&out->source);
 }
 else if(readCharConstant(s,&out->source))
 {
  out->type=CHAR_CONSTANT;
  out->value=unquoteString(&out->source);
 }
 else
 {
  return 0;
 }
 return 1;
}

canonical_original_code:
_Bool parseSimpleExpresion(struct Stream *s, struct Node *out)
{
 if(readString(s,"null"))
 {
  out->type=NULL_CONSTANT;
 }
 else if(readString(s,"true"))
 {
  out->type=TRUE_CONSTANT;
 }
 else if(readString(s,"false"))
 {
  out->type=FALSE_CONSTANT;
 }
 else if(parseIdentifier(s,out))
 {
 }
 else if(readNumber(s,&out->source))
 {
  out->type=NUMERIC_CONSTANT;
  out->value=strdupString(&out->source);
 }
 else if(readString(s,"("))
 {
  parseExpresion(s,out) ?0: panicStream(s,"expected expresion");
  expect(s,")");
 }
 else if(readString(s,"{"))
 {
  out->type=STRUCT_CONSTANT;
  while(readString(s,"}")==0)
  {
   if(childParse(s,out,parseExpresion)==0)
   {
    expect(s,"}");
    break;
   }
   if(readString(s,",")==0)
   {
    expect(s,"}");
    break;
   }
  }
 }
 else if(readStringConstant(s,&out->source))
 {
  out->type=STRING_CONSTANT;
  out->value=unquoteString(&out->source);
 }
 else if(readCharConstant(s,&out->source))
 {
  out->type=CHAR_CONSTANT;
  out->value=unquoteString(&out->source);
 }
 else
 {
  return 0;
 }
 return 1;
}


parseStructBody

decompiled_code:
__int64 __fastcall parseStructBody(__int64 a1, _DWORD *a2)
{
*a2 = 16;
expect(a1, &asc_BC4[1]);
parseTerminated(a1, a2, parseVariableDeclaration, &asc_BC4[4]);
expect(a1, &asc_BC4[2]);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2)
{
*a2 = 16;
expect(a1, &asc_BC4[1]);
parseTerminated(a1, a2, parseVariableDeclaration, &asc_BC4[4]);
expect(a1, &asc_BC4[2]);
return 1LL;
}

original_code:
static _Bool parseStructBody(Stream* s, Node* out) {
 out->type=STRUCT_TYPE;
 expect(s,"{");
 parseTerminated(s,out,parseVariableDeclaration,";");
 expect(s,"}");
 return 1;
}

canonical_original_code:
static _Bool parseStructBody(struct Stream *s, struct Node *out) {
 out->type=STRUCT_TYPE;
 expect(s,"{");
 parseTerminated(s,out,parseVariableDeclaration,";");
 expect(s,"}");
 return 1;
}


parseBlock

decompiled_code:
__int64 __fastcall parseBlock(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er13
unsigned int v3; // er12

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
v3 = readString(a1, &asc_BC4[1]);
if ( (_BYTE)v3 )
{
*a2 = 26;
parseTerminated(a1, a2, parseStatement, &asc_BC4[4]);
expect(a1, &asc_BC4[2]);
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er13
unsigned int v3; // er12

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
v3 = readString(a1, &asc_BC4[1]);
if ( (_BYTE)v3 )
{
*a2 = 26;
parseTerminated(a1, a2, parseStatement, &asc_BC4[4]);
expect(a1, &asc_BC4[2]);
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
}
return v3;
}

original_code:
_Bool parseBlock(Stream* s, Node* out)
{
 readWhitespace(s);
 int start=s->offset;
 if(!readString(s,"{"))
  return 0;
 out->type=BLOCK;
 parseTerminated(s,out,parseStatement,";");
 expect(s,"}");
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

canonical_original_code:
_Bool parseBlock(struct Stream *s, struct Node *out)
{
 readWhitespace(s);
 int start = s->offset;
 if(!readString(s,"{"))
  return 0;
 out->type=BLOCK;
 parseTerminated(s,out,parseStatement,";");
 expect(s,"}");
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}


parseVariableDeclaration

decompiled_code:
__int64 __fastcall parseVariableDeclaration(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er13
unsigned int v3; // ebp

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
v3 = childParse(a1, a2, parseIdentifier);
if ( !(_BYTE)v3 )
return v3;
*a2 = 12;
expect(a1, &asc_BC4[5]);
v3 = childParse(a1, a2, parseType);
if ( (_BYTE)v3 )
{
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return v3;
}
panicStream(a1, "expected type name");
return parseFunctionType();
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er13
unsigned int v3; // ebp

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
v3 = childParse(a1, a2, parseIdentifier);
if ( !(_BYTE)v3 )
return v3;
*a2 = 12;
expect(a1, &asc_BC4[5]);
v3 = childParse(a1, a2, parseType);
if ( (_BYTE)v3 )
{
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return v3;
}
panicStream(a1, "expected type name");
return func7();
}

original_code:
_Bool parseVariableDeclaration(Stream* s, Node* out)
{
 readWhitespace(s);
 int start=s->offset;
 if(!childParse(s,out,parseIdentifier))
  return 0;
 out->type = VARIABLE_DECLARATION;
 expect(s,":");
 childParse(s,out,parseType) ?0: panicStream(s,"expected type name");
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

canonical_original_code:
_Bool parseVariableDeclaration(struct Stream *s, struct Node *out)
{
 readWhitespace(s);
 int start = s->offset;
 if(!childParse(s,out,parseIdentifier))
  return 0;
 out->type = VARIABLE_DECLARATION;
 expect(s,":");
 childParse(s,out,parseType) ?0: panicStream(s,"expected type name");
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}


parseFunctionType

decompiled_code:
__int64 __fastcall parseFunctionType(__int64 a1, __int64 a2)
{
unsigned int v3; // er12
__int64 v4[10]; // [rsp+8h] [rbp-50h] BYREF

expect(a1, "(");
while ( (unsigned __int8)childParse(a1, a2, parseVariableDeclaration) )
{
if ( !(unsigned __int8)readString(a1, &asc_BC4[3]) )
goto LABEL_4;
}
v3 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "...") )
{
v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
v4[5] = 0LL;
makeString(a1, v3, *(_DWORD *)(a1 + 4) - v3, v4);
addChild(a2);
}
LABEL_4:
expect(a1, asc_BC4);
expect(a1, &asc_BC4[5]);
childParse(a1, a2, parseType);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
unsigned int v3; // er12
__int64 v4[10]; // [rsp+8h] [rbp-50h] BYREF

expect(a1, "(");
while ( (unsigned __int8)childParse(a1, a2, parseVariableDeclaration) )
{
if ( !(unsigned __int8)readString(a1, &asc_BC4[3]) )
goto LABEL_4;
}
v3 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "...") )
{
v4[0] = 0LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
v4[5] = 0LL;
makeString(a1, v3, *(_DWORD *)(a1 + 4) - v3, v4);
addChild(a2);
}
LABEL_4:
expect(a1, asc_BC4);
expect(a1, &asc_BC4[5]);
childParse(a1, a2, parseType);
return 1LL;
}

original_code:
_Bool parseFunctionType(Stream* s, Node* out)
{
 expect(s,"(");
 while(1)
 {
  if(!childParse(s,out,parseVariableDeclaration))
  {
   int start=s->offset;
   if(readString(s,"..."))
   {
    Node ellipsis={.type=ELLIPSIS};
    makeString(s, start, s->offset-start, &ellipsis.source);
    addChild(out,ellipsis);
   }
   break;
  }
  if(!readString(s,","))
   break;
 }
 expect(s,")");
 expect(s,":");
 childParse(s,out,parseType);
 return 1;
}

canonical_original_code:
_Bool parseFunctionType(struct Stream *s, struct Node *out)
{
 expect(s,"(");
 while(1)
 {
  if(!childParse(s,out,parseVariableDeclaration))
  {
   int start = s->offset;
   if(readString(s,"..."))
   {
    struct Node ellipsis = {.type=ELLIPSIS};
    makeString(s, start, s->offset-start, &ellipsis.source);
    addChild(out,ellipsis);
   }
   break;
  }
  if(!readString(s,","))
   break;
 }
 expect(s,")");
 expect(s,":");
 childParse(s,out,parseType);
 return 1;
}

variable_types: struct Node { int type; struct String { int offset; int length; struct Stream { int length; int offset; char *data; char *filename; void (*errorHandler)(); } *stream; } source; char *value; enum OperatorId { OPERATOR_ELEMENT=0, OPERATOR_INDEX=1, OPERATOR_CALL=2, OPERATOR_POSTFIX_INCREMENT=3, OPERATOR_POSTFIX_DECREMENT=4, OPERATOR_DEREF=5, OPERATOR_ADDRESS=6, OPERATOR_PREFIX_INCREMENT=7, OPERATOR_PREFIX_DECREMENT=8, OPERATOR_PREFIX_PLUS=9, OPERATOR_PREFIX_MINUS=10, OPERATOR_MUL=11, OPERATOR_DIV=12, OPERATOR_IDIV=13, OPERATOR_MOD=14, OPERATOR_PLUS=15, OPERATOR_MINUS=16, OPERATOR_LT=17, OPERATOR_GT=18, OPERATOR_LE=19, OPERATOR_GE=20, OPERATOR_EQ=21, OPERATOR_NE=22, OPERATOR_ASSIGMENT=23, OPERATOR_LAST=24 } operator; struct Node *child; struct Node *next; }


parseType

decompiled_code:
__int64 __fastcall parseType(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "struct") )
{
parseStructBody(a1, a2);
LABEL_3:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
if ( (unsigned __int8)readString(a1, "function") )
{
*a2 = 17;
parseFunctionType(a1, (__int64)a2);
goto LABEL_3;
}
if ( (unsigned __int8)readString(a1, "*") )
{
*a2 = 14;
childParse(a1, a2, parseType);
goto LABEL_3;
}
if ( (unsigned __int8)readString(a1, "[") )
{
*a2 = 15;
childParse(a1, a2, parseExpresion);
expect(a1, "]");
childParse(a1, a2, parseType);
goto LABEL_3;
}
result = parseIdentifier(a1, (__int64)a2);
if ( (_BYTE)result )
goto LABEL_3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "struct") )
{
func4(a1, a2);
LABEL_3:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
if ( (unsigned __int8)readString(a1, "function") )
{
*a2 = 17;
func7(a1, (__int64)a2);
goto LABEL_3;
}
if ( (unsigned __int8)readString(a1, "*") )
{
*a2 = 14;
childParse(a1, a2, parseType);
goto LABEL_3;
}
if ( (unsigned __int8)readString(a1, "[") )
{
*a2 = 15;
childParse(a1, a2, parseExpresion);
expect(a1, "]");
childParse(a1, a2, parseType);
goto LABEL_3;
}
result = func1(a1, (__int64)a2);
if ( (_BYTE)result )
goto LABEL_3;
return result;
}

original_code:
_Bool parseType(Stream* s, Node* out)
{
 readWhitespace(s);
 int start=s->offset;
 if(readString(s,"struct"))
 {
  parseStructBody(s,out);
 }
 else if(readString(s,"function"))
 {
  out->type=FUNCTION_TYPE;
  parseFunctionType(s,out);
 }
 else if(readString(s,"*"))
 {
  out->type=POINTER_TYPE;
  childParse(s,out,parseType);
 }
 else if(readString(s,"["))
 {
  out->type=ARRAY_TYPE;
  childParse(s,out,parseExpresion);
  expect(s,"]");
  childParse(s,out,parseType);
 }
 else if(parseIdentifier(s,out))
 {
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

canonical_original_code:
_Bool parseType(struct Stream *s, struct Node *out)
{
 readWhitespace(s);
 int start = s->offset;
 if(readString(s,"struct"))
 {
  parseStructBody(s,out);
 }
 else if(readString(s,"function"))
 {
  out->type=FUNCTION_TYPE;
  parseFunctionType(s,out);
 }
 else if(readString(s,"*"))
 {
  out->type=POINTER_TYPE;
  childParse(s,out,parseType);
 }
 else if(readString(s,"["))
 {
  out->type=ARRAY_TYPE;
  childParse(s,out,parseExpresion);
  expect(s,"]");
  childParse(s,out,parseType);
 }
 else if(parseIdentifier(s,out))
 {
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

variable_types: start int


parseDeclaration

decompiled_code:
__int64 __fastcall parseDeclaration(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax
__int64 v4[11]; // [rsp+0h] [rbp-58h] BYREF

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "struct") )
{
*a2 = 11;
childParse(a1, a2, parseIdentifier);
childParse(a1, a2, parseStructBody);
LABEL_3:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
if ( (unsigned __int8)readString(a1, "var") )
{
*a2 = 12;
parseVariableDeclaration(a1, a2);
if ( (unsigned __int8)readString(a1, "=") )
childParse(a1, a2, parseExpresion);
goto LABEL_3;
}
result = readString(a1, "function");
if ( (_BYTE)result )
{
*a2 = 13;
childParse(a1, a2, parseIdentifier);
v4[0] = 17LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
v4[5] = 0LL;
v4[6] = 0LL;
parseFunctionType(a1, (__int64)v4);
addChild(a2);
childParse(a1, a2, parseBlock);
goto LABEL_3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax
__int64 v4[11]; // [rsp+0h] [rbp-58h] BYREF

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( (unsigned __int8)readString(a1, "struct") )
{
*a2 = 11;
childParse(a1, a2, parseIdentifier);
childParse(a1, a2, parseStructBody);
LABEL_3:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
if ( (unsigned __int8)readString(a1, "var") )
{
*a2 = 12;
func6(a1, a2);
if ( (unsigned __int8)readString(a1, "=") )
childParse(a1, a2, parseExpresion);
goto LABEL_3;
}
result = readString(a1, "function");
if ( (_BYTE)result )
{
*a2 = 13;
childParse(a1, a2, parseIdentifier);
v4[0] = 17LL;
v4[1] = 0LL;
v4[2] = 0LL;
v4[3] = 0LL;
v4[4] = 0LL;
v4[5] = 0LL;
v4[6] = 0LL;
func7(a1, (__int64)v4);
addChild(a2);
childParse(a1, a2, parseBlock);
goto LABEL_3;
}
return result;
}

original_code:
_Bool parseDeclaration(Stream* s, Node* out)
{
 readWhitespace(s);
 int start=s->offset;
 if(readString(s,"struct"))
 {
  out->type = STRUCT_DECLARATION;
  childParse(s,out,parseIdentifier);
  childParse(s,out,parseStructBody);
 }
 else if(readString(s,"var"))
 {
  out->type = VARIABLE_DECLARATION;
  parseVariableDeclaration(s,out);
  if(readString(s,"="))
  {
   childParse(s,out,parseExpresion);
  }
 }
 else if(readString(s,"function"))
 {
  out->type = FUNCTION_DECLARATION;
  childParse(s,out,parseIdentifier);
  Node type={.type=FUNCTION_TYPE};
  parseFunctionType(s,&type);
  addChild(out,type);
  childParse(s,out,parseBlock);
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

canonical_original_code:
_Bool parseDeclaration(struct Stream *s, struct Node *out)
{
 readWhitespace(s);
 int start = s->offset;
 if(readString(s,"struct"))
 {
  out->type = STRUCT_DECLARATION;
  childParse(s,out,parseIdentifier);
  childParse(s,out,parseStructBody);
 }
 else if(readString(s,"var"))
 {
  out->type = VARIABLE_DECLARATION;
  parseVariableDeclaration(s,out);
  if(readString(s,"="))
  {
   childParse(s,out,parseExpresion);
  }
 }
 else if(readString(s,"function"))
 {
  out->type = FUNCTION_DECLARATION;
  childParse(s,out,parseIdentifier);
  struct Node type = {.type=FUNCTION_TYPE};
  parseFunctionType(s,&type);
  addChild(out,type);
  childParse(s,out,parseBlock);
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}


parseStatement

decompiled_code:
__int64 __fastcall parseStatement(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( !(unsigned __int8)readString(a1, "if") )
goto LABEL_10;
*a2 = 19;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseExpresion) )
{
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
{
if ( !(unsigned __int8)readString(a1, "else") )
{
LABEL_5:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
goto LABEL_8;
}
}
else
{
panicStream(a1, "expected expresion");
}
panicStream(a1, "expected statement");
LABEL_8:
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
LABEL_10:
if ( (unsigned __int8)readString(a1, "while") )
{
*a2 = 20;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseExpresion) )
{
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
}
panicStream(a1, "expected expresion");
}
if ( (unsigned __int8)readString(a1, "break") )
{
*a2 = 24;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "continue") )
{
*a2 = 25;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "for") )
{
*a2 = 21;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
{
expect(a1, &asc_BC4[4]);
if ( !(unsigned __int8)childParse(a1, a2, parseExpresion) )
{
LABEL_26:
panicStream(a1, "expected expresion");
goto LABEL_27;
}
expect(a1, &asc_BC4[4]);
if ( !(unsigned __int8)childParse(a1, a2, parseStatement) )
{
LABEL_27:
panicStream(a1, "expected statement");
goto LABEL_28;
}
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
}
panicStream(a1, "expected statement");
goto LABEL_26;
}
LABEL_28:
if ( (unsigned __int8)readString(a1, "return") )
{
*a2 = 22;
childParse(a1, a2, parseExpresion);
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "assert") )
{
*a2 = 23;
childParse(a1, a2, parseExpresion);
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "break") )
{
*a2 = 24;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "continue") )
{
*a2 = 25;
goto LABEL_5;
}
if ( (unsigned __int8)parseBlock(a1, a2) )
goto LABEL_5;
if ( (unsigned __int8)parseDeclaration(a1, a2) )
goto LABEL_5;
result = parseExpresion(a1, (__int64)a2);
if ( (_BYTE)result )
goto LABEL_5;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, _DWORD *a2)
{
unsigned int v2; // er12
__int64 result; // rax

readWhitespace();
v2 = *(_DWORD *)(a1 + 4);
if ( !(unsigned __int8)readString(a1, "if") )
goto LABEL_10;
*a2 = 19;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseExpresion) )
{
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
{
if ( !(unsigned __int8)readString(a1, "else") )
{
LABEL_5:
makeString(a1, v2, *(_DWORD *)(a1 + 4) - v2, a2 + 2);
return 1LL;
}
goto LABEL_8;
}
}
else
{
panicStream(a1, "expected expresion");
}
panicStream(a1, "expected statement");
LABEL_8:
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
LABEL_10:
if ( (unsigned __int8)readString(a1, "while") )
{
*a2 = 20;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseExpresion) )
{
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
}
panicStream(a1, "expected expresion");
}
if ( (unsigned __int8)readString(a1, "break") )
{
*a2 = 24;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "continue") )
{
*a2 = 25;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "for") )
{
*a2 = 21;
expect(a1, "(");
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
{
expect(a1, &asc_BC4[4]);
if ( !(unsigned __int8)childParse(a1, a2, parseExpresion) )
{
LABEL_26:
panicStream(a1, "expected expresion");
goto LABEL_27;
}
expect(a1, &asc_BC4[4]);
if ( !(unsigned __int8)childParse(a1, a2, parseStatement) )
{
LABEL_27:
panicStream(a1, "expected statement");
goto LABEL_28;
}
expect(a1, asc_BC4);
if ( (unsigned __int8)childParse(a1, a2, parseStatement) )
goto LABEL_5;
panicStream(a1, "expected statement");
}
panicStream(a1, "expected statement");
goto LABEL_26;
}
LABEL_28:
if ( (unsigned __int8)readString(a1, "return") )
{
*a2 = 22;
childParse(a1, a2, parseExpresion);
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "assert") )
{
*a2 = 23;
childParse(a1, a2, parseExpresion);
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "break") )
{
*a2 = 24;
goto LABEL_5;
}
if ( (unsigned __int8)readString(a1, "continue") )
{
*a2 = 25;
goto LABEL_5;
}
if ( (unsigned __int8)func5(a1, a2) )
goto LABEL_5;
if ( (unsigned __int8)func9(a1, a2) )
goto LABEL_5;
result = func2(a1, (__int64)a2);
if ( (_BYTE)result )
goto LABEL_5;
return result;
}

original_code:
_Bool parseStatement(Stream* s, Node* out)
{
 readWhitespace(s);
 int start=s->offset;
 if(readString(s,"if"))
 {
  out->type=IF_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  if(readString(s,"else"))
  {
   childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  }
 }
 else if(readString(s,"while"))
 {
  out->type=WHILE_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
 }
 else if(readString(s,"break"))
 {
  out->type=BREAK_STATEMENT;
 }
 else if(readString(s,"continue"))
 {
  out->type=CONTINUE_STATEMENT;
 }
 else if(readString(s,"for"))
 {
  out->type=FOR_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  expect(s,";");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,";");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
 }
 else if(readString(s,"return"))
 {
  out->type=RETURN_STATEMENT;
  childParse(s,out,parseExpresion);
 }
 else if(readString(s,"assert"))
 {
  out->type=ASSERT_STATEMENT;
  childParse(s,out,parseExpresion);
 }
 else if(readString(s,"break"))
 {
  out->type=BREAK_STATEMENT;
 }
 else if(readString(s,"continue"))
 {
  out->type=CONTINUE_STATEMENT;
 }
 else if(parseBlock(s,out))
 {
 }
 else if(parseDeclaration(s, out))
 {
 }
 else if(parseExpresion(s,out))
 {
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}

canonical_original_code:
_Bool parseStatement(struct Stream *s, struct Node *out)
{
 readWhitespace(s);
 int start = s->offset;
 if(readString(s,"if"))
 {
  out->type=IF_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  if(readString(s,"else"))
  {
   childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  }
 }
 else if(readString(s,"while"))
 {
  out->type=WHILE_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
 }
 else if(readString(s,"break"))
 {
  out->type=BREAK_STATEMENT;
 }
 else if(readString(s,"continue"))
 {
  out->type=CONTINUE_STATEMENT;
 }
 else if(readString(s,"for"))
 {
  out->type=FOR_STATEMENT;
  expect(s,"(");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  expect(s,";");
  childParse(s,out,parseExpresion) ?0: panicStream(s,"expected expresion");
  expect(s,";");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
  expect(s,")");
  childParse(s,out,parseStatement) ?0: panicStream(s,"expected statement");
 }
 else if(readString(s,"return"))
 {
  out->type=RETURN_STATEMENT;
  childParse(s,out,parseExpresion);
 }
 else if(readString(s,"assert"))
 {
  out->type=ASSERT_STATEMENT;
  childParse(s,out,parseExpresion);
 }
 else if(readString(s,"break"))
 {
  out->type=BREAK_STATEMENT;
 }
 else if(readString(s,"continue"))
 {
  out->type=CONTINUE_STATEMENT;
 }
 else if(parseBlock(s,out))
 {
 }
 else if(parseDeclaration(s, out))
 {
 }
 else if(parseExpresion(s,out))
 {
 }
 else
 {
  return 0;
 }
 makeString(s, start, s->offset-start, &out->source);
 return 1;
}


parseModule

decompiled_code:
__int64 __fastcall parseModule(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // ebx
unsigned int v9; // ebp
jmp_buf env; // [rsp+20h] [rbp-E8h] BYREF
char *v11; // [rsp+E8h] [rbp-20h]

v11 = &a7;
*a2 = 0LL;
a2[1] = 0LL;
a2[2] = 0LL;
a2[3] = 0LL;
a2[4] = 0LL;
a2[5] = 0LL;
a2[6] = 0LL;
if ( setjmp(env) )
{
freeNode(a2);
v7 = 0;
}
else
{
readWhitespace(a1);
v9 = *(_DWORD *)(a1 + 4);
parseTerminated(a1, a2, parseDeclaration, &asc_BC4[4]);
v7 = isEof(a1);
if ( !(_BYTE)v7 )
{
panicStream(a1, "expected declaration");
JUMPOUT(0xB9DLL);
}
makeString(a1, v9, *(_DWORD *)(a1 + 4) - v9, a2 + 1);
*(_QWORD *)(a1 + 24) = &abort;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, _QWORD *a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, char a7)
{
unsigned int v7; // ebx
unsigned int v9; // ebp
jmp_buf env; // [rsp+20h] [rbp-E8h] BYREF
char *v11; // [rsp+E8h] [rbp-20h]

v11 = &a7;
*a2 = 0LL;
a2[1] = 0LL;
a2[2] = 0LL;
a2[3] = 0LL;
a2[4] = 0LL;
a2[5] = 0LL;
a2[6] = 0LL;
if ( setjmp(env) )
{
freeNode(a2);
v7 = 0;
}
else
{
readWhitespace(a1);
v9 = *(_DWORD *)(a1 + 4);
parseTerminated(a1, a2, parseDeclaration, &asc_BC4[4]);
v7 = isEof(a1);
if ( !(_BYTE)v7 )
{
panicStream(a1, "expected declaration");
JUMPOUT(0xB9DLL);
}
makeString(a1, v9, *(_DWORD *)(a1 + 4) - v9, a2 + 1);
*(_QWORD *)(a1 + 24) = &abort;
}
return v7;
}

original_code:
_Bool parseModule(Stream* s, Node* m)
{
 *m=(Node){0};
 jmp_buf env;
 if(_setjmp (env))
 {
  freeNode(m);
  return 0;
 }
 __attribute__((noreturn)) void errorHandler()
 {
  longjmp(env,1);
 }
 readWhitespace(s);
 int start=s->offset;
 parseTerminated(s,m,parseDeclaration,";");
 if(!isEof(s))
  panicStream(s,"expected declaration");
 makeString(s, start, s->offset-start, &m->source);
 s->errorHandler=abort;
 return 1;
}

canonical_original_code:
_Bool parseModule(struct Stream *s, struct Node *m)
{
 *m=(struct Node){0};
 struct __jmp_buf_tag env[1];
 if(_setjmp (env))
 {
  freeNode(m);
  return 0;
 }
 __attribute__((noreturn)) void errorHandler()
 {
  longjmp(env,1);
 }
 readWhitespace(s);
 int start = s->offset;
 parseTerminated(s,m,parseDeclaration,";");
 if(!isEof(s))
  panicStream(s,"expected declaration");
 makeString(s, start, s->offset-start, &m->source);
 s->errorHandler=abort;
 return 1;
}

variable_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } [1]

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


panic

decompiled_code:
void __noreturn panic(const char *a1, unsigned int a2, const char *a3, ...)
{
int v4; // edi
char *v5; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
fprintf(stderr, "%s:%i: ", a1, a2);
vfprintf(stderr, a3, arg);
v4 = *_errno_location();
if ( v4 )
{
v5 = strerror(v4);
fprintf(stderr, ": %s", v5);
}
fputc(10, stderr);
abort();
}

canonical_decompiled_code:
void __noreturn func0(const char *a1, unsigned int a2, const char *a3, ...)
{
int v4; // edi
char *v5; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
fprintf(stderr, "%s:%i: ", a1, a2);
vfprintf(stderr, a3, arg);
v4 = *_errno_location();
if ( v4 )
{
v5 = strerror(v4);
fprintf(stderr, ": %s", v5);
}
fputc(10, stderr);
abort();
}

original_code:
__attribute__((__noreturn__)) void panic(char* file,int line,char *format,...)
{
 va_list args;
 __builtin_va_start(args,format);
 fprintf(stderr, "%s:%i: ", file,line);
 vfprintf(stderr,format,args);
 if((*__errno_location ())!=0)
  fprintf(stderr,": %s",strerror((*__errno_location ())));
 fprintf(stderr,"\n");
 __builtin_va_end(args);
    abort();
}

canonical_original_code:
void panic(char *file, int line, char *format, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,format);
 fprintf(stderr, "%s:%i: ", file,line);
 vfprintf(stderr,format,args);
 if((*__errno_location ())!=0)
  fprintf(stderr,": %s",strerror((*__errno_location ())));
 fprintf(stderr,"\n");
 __builtin_va_end(args);
    abort();
}

variable_types:
file
char *

variable_types: line int


echoOff

repo: bard/spock

decompiled_code:
int __fastcall echoOff(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = isatty(fd);
if ( result )
{
tcgetattr(fd, &v2);
v2.c_lflag &= 0xFFFFFFF7;
result = tcsetattr(fd, 2, &v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = isatty(fd);
if ( result )
{
tcgetattr(fd, &v2);
v2.c_lflag &= 0xFFFFFFF7;
result = tcsetattr(fd, 2, &v2);
}
return result;
}

original_code:
static void echoOff(int fd)
{
    if (isatty(fd)) {
 struct termios tio;
 tcgetattr(fd, &tio);
 tio.c_lflag &= ~0000010;
 tcsetattr(fd, 2, &tio);
    }
}

variable_types: fd int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


echoOn

decompiled_code:
int __fastcall echoOn(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = isatty(fd);
if ( result )
{
tcgetattr(fd, &v2);
v2.c_lflag |= 8u;
result = tcsetattr(fd, 2, &v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int fd)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

result = isatty(fd);
if ( result )
{
tcgetattr(fd, &v2);
v2.c_lflag |= 8u;
result = tcsetattr(fd, 2, &v2);
}
return result;
}

original_code:
static void echoOn(int fd)
{
    if (isatty(fd)) {
 struct termios tio;
 tcgetattr(fd, &tio);
 tio.c_lflag |= 0000010;
 tcsetattr(fd, 2, &tio);
    }
}

user_defined_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
__int64 __fastcall SEC_CheckPassword(const char *a1)
{
const char *v1; // rbx
int v2; // eax
unsigned int v3; // edx

v1 = a1;
v2 = strlen(a1);
v3 = 0;
if ( v2 > 7 )
{
while ( v1 < &a1[v2] )
{
if ( (unsigned __int8)((*v1++ & 0xDF) - 65) > 0x19u )
return 1;
}
v3 = 0;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1)
{
const char *v1; // rbx
int v2; // eax
unsigned int v3; // edx

v1 = a1;
v2 = strlen(a1);
v3 = 0;
if ( v2 > 7 )
{
while ( v1 < &a1[v2] )
{
if ( (unsigned __int8)((*v1++ & 0xDF) - 65) > 0x19u )
return 1;
}
v3 = 0;
}
return v3;
}

original_code:
PRBool SEC_CheckPassword(char *cp)
{
    int len;
    char *end;
    len = strlen(cp);
    if (len < 8) {
 return 0;
    }
    end = cp + len;
    while (cp < end) {
 unsigned char ch = *cp++;
 if (!((ch >= 'A') && (ch <= 'Z')) &&
     !((ch >= 'a') && (ch <= 'z'))) {
     return 1;
 }
    }
    return 0;
}

canonical_original_code:
int SEC_CheckPassword(char *cp)
{
    int len;
    char *end;
    len = strlen(cp);
    if (len < 8) {
 return 0;
    }
    end = cp + len;
    while (cp < end) {
 unsigned char ch = *cp++;
 if (!((ch >= 'A') && (ch <= 'Z')) &&
     !((ch >= 'a') && (ch <= 'z'))) {
     return 1;
 }
    }
    return 0;
}

variable_types:
cp
char *

variable_types:
end
char *

variable_types:
ch
unsigned char


decompiled_code:
_BOOL8 __fastcall SEC_BlindCheckPassword(__int64 a1)
{
return a1 != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1)
{
return a1 != 0;
}

original_code:
PRBool SEC_BlindCheckPassword(char *cp)
{
    if (cp != ((void *)0)) {
 return 1;
    }
    return 0;
}

canonical_original_code:
int SEC_BlindCheckPassword(char *cp)
{
    if (cp != ((void *)0)) {
 return 1;
    }
    return 0;
}


decompiled_code:
__int64 SECU_RegisterDynamicOids()
{
char *v0; // rbx
unsigned int v1; // ebp

v0 = (char *)&oids;
v1 = 0;
do
{
if ( !(unsigned int)SECOID_AddEntry(v0) )
v1 = -1;
v0 += 56;
}
while ( v0 != (char *)&vcp4 );
return v1;
}

canonical_decompiled_code:
__int64 func0()
{
char *v0; // rbx
unsigned int v1; // ebp

v0 = (char *)&oids;
v1 = 0;
do
{
if ( !(unsigned int)SECOID_AddEntry(v0) )
v1 = -1;
v0 += 56;
}
while ( v0 != (char *)&vcp4 );
return v1;
}

original_code:
SECStatus
SECU_RegisterDynamicOids(void)
{
    unsigned int i;
    SECStatus rv = SECSuccess;
    for (i = 0; i < numOids; ++i) {
 SECOidTag tag = SECOID_AddEntry(&oids[i]);
 if (tag == SEC_OID_UNKNOWN) {
     rv = SECFailure;
 }
    }
    return rv;
}

canonical_original_code:
enum _SECStatus SECU_RegisterDynamicOids()
{
    unsigned int i;
    enum _SECStatus rv = SECSuccess;
    for (i = 0; i < numOids; ++i) {
 enum SECOidTag tag = SECOID_AddEntry(&oids[i]);
 if (tag == SEC_OID_UNKNOWN) {
     rv = SECFailure;
 }
    }
    return rv;
}

variable_types:
i
unsigned int

variable_types: enum _SECStatus { SECWouldBlock=-2, SECFailure=-1, SECSuccess=0 }

variable_types: enum SECOidTag { SEC_OID_UNKNOWN=0, SEC_OID_MD2=1, SEC_OID_MD4=2, SEC_OID_MD5=3, SEC_OID_SHA1=4, SEC_OID_RC2_CBC=5, SEC_OID_RC4=6, SEC_OID_DES_EDE3_CBC=7, SEC_OID_RC5_CBC_PAD=8, SEC_OID_DES_ECB=9, SEC_OID_DES_CBC=10, SEC_OID_DES_OFB=11, SEC_OID_DES_CFB=12, SEC_OID_DES_MAC=13, SEC_OID_DES_EDE=14, SEC_OID_ISO_SHA_WITH_RSA_SIGNATURE=15, SEC_OID_PKCS1_RSA_ENCRYPTION=16, SEC_OID_PKCS1_MD2_WITH_RSA_ENCRYPTION=17, SEC_OID_PKCS1_MD4_WITH_RSA_ENCRYPTION=18, SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION=19, SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION=20, SEC_OID_PKCS5_PBE_WITH_MD2_AND_DES_CBC=21, SEC_OID_PKCS5_PBE_WITH_MD5_AND_DES_CBC=22, SEC_OID_PKCS5_PBE_WITH_SHA1_AND_DES_CBC=23, SEC_OID_PKCS7=24, SEC_OID_PKCS7_DATA=25, SEC_OID_PKCS7_SIGNED_DATA=26, SEC_OID_PKCS7_ENVELOPED_DATA=27, SEC_OID_PKCS7_SIGNED_ENVELOPED_DATA=28, SEC_OID_PKCS7_DIGESTED_DATA=29, SEC_OID_PKCS7_ENCRYPTED_DATA=30, SEC_OID_PKCS9_EMAIL_ADDRESS=31, SEC_OID_PKCS9_UNSTRUCTURED_NAME=32, SEC_OID_PKCS9_CONTENT_TYPE=33, SEC_OID_PKCS9_MESSAGE_DIGEST=34, SEC_OID_PKCS9_SIGNING_TIME=35, SEC_OID_PKCS9_COUNTER_SIGNATURE=36, SEC_OID_PKCS9_CHALLENGE_PASSWORD=37, SEC_OID_PKCS9_UNSTRUCTURED_ADDRESS=38, SEC_OID_PKCS9_EXTENDED_CERTIFICATE_ATTRIBUTES=39, SEC_OID_PKCS9_SMIME_CAPABILITIES=40, SEC_OID_AVA_COMMON_NAME=41, SEC_OID_AVA_COUNTRY_NAME=42, SEC_OID_AVA_LOCALITY=43, SEC_OID_AVA_STATE_OR_PROVINCE=44, SEC_OID_AVA_ORGANIZATION_NAME=45, SEC_OID_AVA_ORGANIZATIONAL_UNIT_NAME=46, SEC_OID_AVA_DN_QUALIFIER=47, SEC_OID_AVA_DC=48, SEC_OID_NS_TYPE_GIF=49, SEC_OID_NS_TYPE_JPEG=50, SEC_OID_NS_TYPE_URL=51, SEC_OID_NS_TYPE_HTML=52, SEC_OID_NS_TYPE_CERT_SEQUENCE=53, SEC_OID_MISSI_KEA_DSS_OLD=54, SEC_OID_MISSI_DSS_OLD=55, SEC_OID_MISSI_KEA_DSS=56, SEC_OID_MISSI_DSS=57, SEC_OID_MISSI_KEA=58, SEC_OID_MISSI_ALT_KEA=59, SEC_OID_NS_CERT_EXT_NETSCAPE_OK=60, SEC_OID_NS_CERT_EXT_ISSUER_LOGO=61, SEC_OID_NS_CERT_EXT_SUBJECT_LOGO=62, SEC_OID_NS_CERT_EXT_CERT_TYPE=63, SEC_OID_NS_CERT_EXT_BASE_URL=64, SEC_OID_NS_CERT_EXT_REVOCATION_URL=65, SEC_OID_NS_CERT_EXT_CA_REVOCATION_URL=66, SEC_OID_NS_CERT_EXT_CA_CRL_URL=67, SEC_OID_NS_CERT_EXT_CA_CERT_URL=68, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_URL=69, SEC_OID_NS_CERT_EXT_CA_POLICY_URL=70, SEC_OID_NS_CERT_EXT_HOMEPAGE_URL=71, SEC_OID_NS_CERT_EXT_ENTITY_LOGO=72, SEC_OID_NS_CERT_EXT_USER_PICTURE=73, SEC_OID_NS_CERT_EXT_SSL_SERVER_NAME=74, SEC_OID_NS_CERT_EXT_COMMENT=75, SEC_OID_NS_CERT_EXT_LOST_PASSWORD_URL=76, SEC_OID_NS_CERT_EXT_CERT_RENEWAL_TIME=77, SEC_OID_NS_KEY_USAGE_GOVT_APPROVED=78, SEC_OID_X509_SUBJECT_DIRECTORY_ATTR=79, SEC_OID_X509_SUBJECT_KEY_ID=80, SEC_OID_X509_KEY_USAGE=81, SEC_OID_X509_PRIVATE_KEY_USAGE_PERIOD=82, SEC_OID_X509_SUBJECT_ALT_NAME=83, SEC_OID_X509_ISSUER_ALT_NAME=84, SEC_OID_X509_BASIC_CONSTRAINTS=85, SEC_OID_X509_NAME_CONSTRAINTS=86, SEC_OID_X509_CRL_DIST_POINTS=87, SEC_OID_X509_CERTIFICATE_POLICIES=88, SEC_OID_X509_POLICY_MAPPINGS=89, SEC_OID_X509_POLICY_CONSTRAINTS=90, SEC_OID_X509_AUTH_KEY_ID=91, SEC_OID_X509_EXT_KEY_USAGE=92, SEC_OID_X509_AUTH_INFO_ACCESS=93, SEC_OID_X509_CRL_NUMBER=94, SEC_OID_X509_REASON_CODE=95, SEC_OID_X509_INVALID_DATE=96, SEC_OID_X500_RSA_ENCRYPTION=97, SEC_OID_RFC1274_UID=98, SEC_OID_RFC1274_MAIL=99, SEC_OID_PKCS12=100, SEC_OID_PKCS12_MODE_IDS=101, SEC_OID_PKCS12_ESPVK_IDS=102, SEC_OID_PKCS12_BAG_IDS=103, SEC_OID_PKCS12_CERT_BAG_IDS=104, SEC_OID_PKCS12_OIDS=105, SEC_OID_PKCS12_PBE_IDS=106, SEC_OID_PKCS12_SIGNATURE_IDS=107, SEC_OID_PKCS12_ENVELOPING_IDS=108, SEC_OID_PKCS12_PKCS8_KEY_SHROUDING=109, SEC_OID_PKCS12_KEY_BAG_ID=110, SEC_OID_PKCS12_CERT_AND_CRL_BAG_ID=111, SEC_OID_PKCS12_SECRET_BAG_ID=112, SEC_OID_PKCS12_X509_CERT_CRL_BAG=113, SEC_OID_PKCS12_SDSI_CERT_BAG=114, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC4=115, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC4=116, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_TRIPLE_DES_CBC=117, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=118, SEC_OID_PKCS12_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=119, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_128_BIT_RC4=120, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_40_BIT_RC4=121, SEC_OID_PKCS12_RSA_ENCRYPTION_WITH_TRIPLE_DES=122, SEC_OID_PKCS12_RSA_SIGNATURE_WITH_SHA1_DIGEST=123, SEC_OID_ANSIX9_DSA_SIGNATURE=124, SEC_OID_ANSIX9_DSA_SIGNATURE_WITH_SHA1_DIGEST=125, SEC_OID_BOGUS_DSA_SIGNATURE_WITH_SHA1_DIGEST=126, SEC_OID_VERISIGN_USER_NOTICES=127, SEC_OID_PKIX_CPS_POINTER_QUALIFIER=128, SEC_OID_PKIX_USER_NOTICE_QUALIFIER=129, SEC_OID_PKIX_OCSP=130, SEC_OID_PKIX_OCSP_BASIC_RESPONSE=131, SEC_OID_PKIX_OCSP_NONCE=132, SEC_OID_PKIX_OCSP_CRL=133, SEC_OID_PKIX_OCSP_RESPONSE=134, SEC_OID_PKIX_OCSP_NO_CHECK=135, SEC_OID_PKIX_OCSP_ARCHIVE_CUTOFF=136, SEC_OID_PKIX_OCSP_SERVICE_LOCATOR=137, SEC_OID_PKIX_REGCTRL_REGTOKEN=138, SEC_OID_PKIX_REGCTRL_AUTHENTICATOR=139, SEC_OID_PKIX_REGCTRL_PKIPUBINFO=140, SEC_OID_PKIX_REGCTRL_PKI_ARCH_OPTIONS=141, SEC_OID_PKIX_REGCTRL_OLD_CERT_ID=142, SEC_OID_PKIX_REGCTRL_PROTOCOL_ENC_KEY=143, SEC_OID_PKIX_REGINFO_UTF8_PAIRS=144, SEC_OID_PKIX_REGINFO_CERT_REQUEST=145, SEC_OID_EXT_KEY_USAGE_SERVER_AUTH=146, SEC_OID_EXT_KEY_USAGE_CLIENT_AUTH=147, SEC_OID_EXT_KEY_USAGE_CODE_SIGN=148, SEC_OID_EXT_KEY_USAGE_EMAIL_PROTECT=149, SEC_OID_EXT_KEY_USAGE_TIME_STAMP=150, SEC_OID_OCSP_RESPONDER=151, SEC_OID_NETSCAPE_SMIME_KEA=152, SEC_OID_FORTEZZA_SKIPJACK=153, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC4=154, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC4=155, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_3KEY_TRIPLE_DES_CBC=156, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_2KEY_TRIPLE_DES_CBC=157, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_128_BIT_RC2_CBC=158, SEC_OID_PKCS12_V2_PBE_WITH_SHA1_AND_40_BIT_RC2_CBC=159, SEC_OID_PKCS12_SAFE_CONTENTS_ID=160, SEC_OID_PKCS12_PKCS8_SHROUDED_KEY_BAG_ID=161, SEC_OID_PKCS12_V1_KEY_BAG_ID=162, SEC_OID_PKCS12_V1_PKCS8_SHROUDED_KEY_BAG_ID=163, SEC_OID_PKCS12_V1_CERT_BAG_ID=164, SEC_OID_PKCS12_V1_CRL_BAG_ID=165, SEC_OID_PKCS12_V1_SECRET_BAG_ID=166, SEC_OID_PKCS12_V1_SAFE_CONTENTS_BAG_ID=167, SEC_OID_PKCS9_X509_CERT=168, SEC_OID_PKCS9_SDSI_CERT=169, SEC_OID_PKCS9_X509_CRL=170, SEC_OID_PKCS9_FRIENDLY_NAME=171, SEC_OID_PKCS9_LOCAL_KEY_ID=172, SEC_OID_BOGUS_KEY_USAGE=173, SEC_OID_X942_DIFFIE_HELMAN_KEY=174, SEC_OID_NETSCAPE_NICKNAME=175, SEC_OID_NETSCAPE_RECOVERY_REQUEST=176, SEC_OID_CERT_RENEWAL_LOCATOR=177, SEC_OID_NS_CERT_EXT_SCOPE_OF_USE=178, SEC_OID_CMS_EPHEMERAL_STATIC_DIFFIE_HELLMAN=179, SEC_OID_CMS_3DES_KEY_WRAP=180, SEC_OID_CMS_RC2_KEY_WRAP=181, SEC_OID_SMIME_ENCRYPTION_KEY_PREFERENCE=182, SEC_OID_AES_128_ECB=183, SEC_OID_AES_128_CBC=184, SEC_OID_AES_192_ECB=185, SEC_OID_AES_192_CBC=186, SEC_OID_AES_256_ECB=187, SEC_OID_AES_256_CBC=188, SEC_OID_SDN702_DSA_SIGNATURE=189, SEC_OID_MS_SMIME_ENCRYPTION_KEY_PREFERENCE=190, SEC_OID_SHA256=191, SEC_OID_SHA384=192, SEC_OID_SHA512=193, SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION=194, SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION=195, SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION=196, SEC_OID_AES_128_KEY_WRAP=197, SEC_OID_AES_192_KEY_WRAP=198, SEC_OID_AES_256_KEY_WRAP=199, SEC_OID_ANSIX962_EC_PUBLIC_KEY=200, SEC_OID_ANSIX962_ECDSA_SHA1_SIGNATURE=201, SEC_OID_ANSIX962_EC_PRIME192V1=202, SEC_OID_ANSIX962_EC_PRIME192V2=203, SEC_OID_ANSIX962_EC_PRIME192V3=204, SEC_OID_ANSIX962_EC_PRIME239V1=205, SEC_OID_ANSIX962_EC_PRIME239V2=206, SEC_OID_ANSIX962_EC_PRIME239V3=207, SEC_OID_ANSIX962_EC_PRIME256V1=208, SEC_OID_SECG_EC_SECP112R1=209, SEC_OID_SECG_EC_SECP112R2=210, SEC_OID_SECG_EC_SECP128R1=211, SEC_OID_SECG_EC_SECP128R2=212, SEC_OID_SECG_EC_SECP160K1=213, SEC_OID_SECG_EC_SECP160R1=214, SEC_OID_SECG_EC_SECP160R2=215, SEC_OID_SECG_EC_SECP192K1=216, SEC_OID_SECG_EC_SECP224K1=217, SEC_OID_SECG_EC_SECP224R1=218, SEC_OID_SECG_EC_SECP256K1=219, SEC_OID_SECG_EC_SECP384R1=220, SEC_OID_SECG_EC_SECP521R1=221, SEC_OID_ANSIX962_EC_C2PNB163V1=222, SEC_OID_ANSIX962_EC_C2PNB163V2=223, SEC_OID_ANSIX962_EC_C2PNB163V3=224, SEC_OID_ANSIX962_EC_C2PNB176V1=225, SEC_OID_ANSIX962_EC_C2TNB191V1=226, SEC_OID_ANSIX962_EC_C2TNB191V2=227, SEC_OID_ANSIX962_EC_C2TNB191V3=228, SEC_OID_ANSIX962_EC_C2ONB191V4=229, SEC_OID_ANSIX962_EC_C2ONB191V5=230, SEC_OID_ANSIX962_EC_C2PNB208W1=231, SEC_OID_ANSIX962_EC_C2TNB239V1=232, SEC_OID_ANSIX962_EC_C2TNB239V2=233, SEC_OID_ANSIX962_EC_C2TNB239V3=234, SEC_OID_ANSIX962_EC_C2ONB239V4=235, SEC_OID_ANSIX962_EC_C2ONB239V5=236, SEC_OID_ANSIX962_EC_C2PNB272W1=237, SEC_OID_ANSIX962_EC_C2PNB304W1=238, SEC_OID_ANSIX962_EC_C2TNB359V1=239, SEC_OID_ANSIX962_EC_C2PNB368W1=240, SEC_OID_ANSIX962_EC_C2TNB431R1=241, SEC_OID_SECG_EC_SECT113R1=242, SEC_OID_SECG_EC_SECT113R2=243, SEC_OID_SECG_EC_SECT131R1=244, SEC_OID_SECG_EC_SECT131R2=245, SEC_OID_SECG_EC_SECT163K1=246, SEC_OID_SECG_EC_SECT163R1=247, SEC_OID_SECG_EC_SECT163R2=248, SEC_OID_SECG_EC_SECT193R1=249, SEC_OID_SECG_EC_SECT193R2=250, SEC_OID_SECG_EC_SECT233K1=251, SEC_OID_SECG_EC_SECT233R1=252, SEC_OID_SECG_EC_SECT239K1=253, SEC_OID_SECG_EC_SECT283K1=254, SEC_OID_SECG_EC_SECT283R1=255, SEC_OID_SECG_EC_SECT409K1=256, SEC_OID_SECG_EC_SECT409R1=257, SEC_OID_SECG_EC_SECT571K1=258, SEC_OID_SECG_EC_SECT571R1=259, SEC_OID_NETSCAPE_AOLSCREENNAME=260, SEC_OID_AVA_SURNAME=261, SEC_OID_AVA_SERIAL_NUMBER=262, SEC_OID_AVA_STREET_ADDRESS=263, SEC_OID_AVA_TITLE=264, SEC_OID_AVA_POSTAL_ADDRESS=265, SEC_OID_AVA_POSTAL_CODE=266, SEC_OID_AVA_POST_OFFICE_BOX=267, SEC_OID_AVA_GIVEN_NAME=268, SEC_OID_AVA_INITIALS=269, SEC_OID_AVA_GENERATION_QUALIFIER=270, SEC_OID_AVA_HOUSE_IDENTIFIER=271, SEC_OID_AVA_PSEUDONYM=272, SEC_OID_PKIX_CA_ISSUERS=273, SEC_OID_PKCS9_EXTENSION_REQUEST=274, SEC_OID_ANSIX962_ECDSA_SIGNATURE_RECOMMENDED_DIGEST=275, SEC_OID_ANSIX962_ECDSA_SIGNATURE_SPECIFIED_DIGEST=276, SEC_OID_ANSIX962_ECDSA_SHA224_SIGNATURE=277, SEC_OID_ANSIX962_ECDSA_SHA256_SIGNATURE=278, SEC_OID_ANSIX962_ECDSA_SHA384_SIGNATURE=279, SEC_OID_ANSIX962_ECDSA_SHA512_SIGNATURE=280, SEC_OID_X509_HOLD_INSTRUCTION_CODE=281, SEC_OID_X509_DELTA_CRL_INDICATOR=282, SEC_OID_X509_ISSUING_DISTRIBUTION_POINT=283, SEC_OID_X509_CERT_ISSUER=284, SEC_OID_X509_FRESHEST_CRL=285, SEC_OID_X509_INHIBIT_ANY_POLICY=286, SEC_OID_X509_SUBJECT_INFO_ACCESS=287, SEC_OID_CAMELLIA_128_CBC=288, SEC_OID_CAMELLIA_192_CBC=289, SEC_OID_CAMELLIA_256_CBC=290, SEC_OID_PKCS5_PBKDF2=291, SEC_OID_PKCS5_PBES2=292, SEC_OID_PKCS5_PBMAC1=293, SEC_OID_HMAC_SHA1=294, SEC_OID_HMAC_SHA224=295, SEC_OID_HMAC_SHA256=296, SEC_OID_HMAC_SHA384=297, SEC_OID_HMAC_SHA512=298, SEC_OID_PKIX_TIMESTAMPING=299, SEC_OID_PKIX_CA_REPOSITORY=300, SEC_OID_ISO_SHA1_WITH_RSA_SIGNATURE=301, SEC_OID_SEED_CBC=302, SEC_OID_X509_ANY_POLICY=303, SEC_OID_PKCS1_RSA_OAEP_ENCRYPTION=304, SEC_OID_PKCS1_MGF1=305, SEC_OID_PKCS1_PSPECIFIED=306, SEC_OID_PKCS1_RSA_PSS_SIGNATURE=307, SEC_OID_PKCS1_SHA224_WITH_RSA_ENCRYPTION=308, SEC_OID_SHA224=309, SEC_OID_EV_INCORPORATION_LOCALITY=310, SEC_OID_EV_INCORPORATION_STATE=311, SEC_OID_EV_INCORPORATION_COUNTRY=312, SEC_OID_BUSINESS_CATEGORY=313, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA224_DIGEST=314, SEC_OID_NIST_DSA_SIGNATURE_WITH_SHA256_DIGEST=315, SEC_OID_MS_EXT_KEY_USAGE_CTL_SIGNING=316, SEC_OID_AVA_NAME=317, SEC_OID_AES_128_GCM=318, SEC_OID_AES_192_GCM=319, SEC_OID_AES_256_GCM=320, SEC_OID_IDEA_CBC=321, SEC_OID_RC2_40_CBC=322, SEC_OID_DES_40_CBC=323, SEC_OID_RC4_40=324, SEC_OID_RC4_56=325, SEC_OID_NULL_CIPHER=326, SEC_OID_HMAC_MD5=327, SEC_OID_TLS_RSA=328, SEC_OID_TLS_DHE_RSA=329, SEC_OID_TLS_DHE_DSS=330, SEC_OID_TLS_DH_RSA=331, SEC_OID_TLS_DH_DSS=332, SEC_OID_TLS_DH_ANON=333, SEC_OID_TLS_ECDHE_ECDSA=334, SEC_OID_TLS_ECDHE_RSA=335, SEC_OID_TLS_ECDH_ECDSA=336, SEC_OID_TLS_ECDH_RSA=337, SEC_OID_TLS_ECDH_ANON=338, SEC_OID_TLS_RSA_EXPORT=339, SEC_OID_TLS_DHE_RSA_EXPORT=340, SEC_OID_TLS_DHE_DSS_EXPORT=341, SEC_OID_TLS_DH_RSA_EXPORT=342, SEC_OID_TLS_DH_DSS_EXPORT=343, SEC_OID_TLS_DH_ANON_EXPORT=344, SEC_OID_APPLY_SSL_POLICY=345, SEC_OID_CHACHA20_POLY1305=346, SEC_OID_TLS_ECDHE_PSK=347, SEC_OID_TLS_DHE_PSK=348, SEC_OID_TLS_FFDHE_2048=349, SEC_OID_TLS_FFDHE_3072=350, SEC_OID_TLS_FFDHE_4096=351, SEC_OID_TLS_FFDHE_6144=352, SEC_OID_TLS_FFDHE_8192=353, SEC_OID_TLS_DHE_CUSTOM=354, SEC_OID_CURVE25519=355, SEC_OID_TLS13_KEA_ANY=356, SEC_OID_X509_ANY_EXT_KEY_USAGE=357, SEC_OID_EXT_KEY_USAGE_IPSEC_IKE=358, SEC_OID_IPSEC_IKE_END=359, SEC_OID_IPSEC_IKE_INTERMEDIATE=360, SEC_OID_TOTAL=361 }


decompiled_code:
__int64 __fastcall SECU_Strerror(int a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rcx
int v4; // ecx
int v5; // esi
int v6; // eax
int v7; // edx
__int64 result; // rax

if ( !initDone_0 )
{
v1 = 0LL;
v2 = 0x80000000;
do
{
v3 = v2;
v2 = errStrings[2 * v1];
if ( (int)v2 <= (int)v3 )
fprintf(
stderr,
"sequence error in error strings at item %d\nerror %d (%s)\nshould come after \nerror %d (%s)\n",
(unsigned int)v1,
v3,
(const char *)errStrings[2 * v1 - 1],
v2,
(const char *)errStrings[2 * v1 + 1]);
++v1;
}
while ( v1 != 338 );
initDone_0 = 1;
}
v4 = 337;
v5 = 0;
while ( v5 + 1 < v4 )
{
v6 = (v4 + v5) / 2;
v7 = errStrings[2 * v6];
if ( a1 == v7 )
return errStrings[2 * v6 + 1];
if ( a1 >= v7 )
v5 = (v4 + v5) / 2;
else
v4 = (v4 + v5) / 2;
}
if ( LODWORD(errStrings[2 * v5]) == a1 )
return errStrings[2 * v5 + 1];
result = 0LL;
if ( LODWORD(errStrings[2 * v4]) == a1 )
result = errStrings[2 * v4 + 1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v1; // rbx
unsigned int v2; // ebp
__int64 v3; // rcx
int v4; // ecx
int v5; // esi
int v6; // eax
int v7; // edx
__int64 result; // rax

if ( !initDone_0 )
{
v1 = 0LL;
v2 = 0x80000000;
do
{
v3 = v2;
v2 = errStrings[2 * v1];
if ( (int)v2 <= (int)v3 )
fprintf(
stderr,
"sequence error in error strings at item %d\nerror %d (%s)\nshould come after \nerror %d (%s)\n",
(unsigned int)v1,
v3,
(const char *)errStrings[2 * v1 - 1],
v2,
(const char *)errStrings[2 * v1 + 1]);
++v1;
}
while ( v1 != 338 );
initDone_0 = 1;
}
v4 = 337;
v5 = 0;
while ( v5 + 1 < v4 )
{
v6 = (v4 + v5) / 2;
v7 = errStrings[2 * v6];
if ( a1 == v7 )
return errStrings[2 * v6 + 1];
if ( a1 >= v7 )
v5 = (v4 + v5) / 2;
else
v4 = (v4 + v5) / 2;
}
if ( LODWORD(errStrings[2 * v5]) == a1 )
return errStrings[2 * v5 + 1];
result = 0LL;
if ( LODWORD(errStrings[2 * v4]) == a1 )
result = errStrings[2 * v4 + 1];
return result;
}

original_code:
const char *
SECU_Strerror(PRErrorCode errNum) {
    PRInt32 low = 0;
    PRInt32 high = numStrings - 1;
    PRInt32 i;
    PRErrorCode num;
    static int initDone;
    if (!initDone) {
 PRErrorCode lastNum = ((PRInt32)0x80000000);
     for (i = low; i <= high; ++i) {
     num = errStrings[i].errNum;
     if (num <= lastNum) {
      fprintf(stderr,
"sequence error in error strings at item %d\n"
"error %d (%s)\n"
"should come after \n"
"error %d (%s)\n",
          i, lastNum, errStrings[i-1].errString,
   num, errStrings[i].errString);
     }
     lastNum = num;
 }
 initDone = 1;
    }
    while (low + 1 < high) {
     i = (low + high) / 2;
 num = errStrings[i].errNum;
 if (errNum == num)
     return errStrings[i].errString;
        if (errNum < num)
     high = i;
 else
     low = i;
    }
    if (errNum == errStrings[low].errNum)
     return errStrings[low].errString;
    if (errNum == errStrings[high].errNum)
     return errStrings[high].errString;
    return ((void *)0);
}

canonical_original_code:
char *SECU_Strerror(int errNum) {
    int low = 0;
    int high = numStrings - 1;
    int i;
    int num;
    static int initDone;
    if (!initDone) {
 int lastNum = ((PRInt32)0x80000000);
     for (i = low; i <= high; ++i) {
     num = errStrings[i].errNum;
     if (num <= lastNum) {
      fprintf(stderr,
"sequence error in error strings at item %d\n"
"error %d (%s)\n"
"should come after \n"
"error %d (%s)\n",
          i, lastNum, errStrings[i-1].errString,
   num, errStrings[i].errString);
     }
     lastNum = num;
 }
 initDone = 1;
    }
    while (low + 1 < high) {
     i = (low + high) / 2;
 num = errStrings[i].errNum;
 if (errNum == num)
     return errStrings[i].errString;
        if (errNum < num)
     high = i;
 else
     low = i;
    }
    if (errNum == errStrings[low].errNum)
     return errStrings[low].errString;
    if (errNum == errStrings[high].errNum)
     return errStrings[high].errString;
    return ((void *)0);
}

variable_types: errNum int

variable_types: low int

variable_types: high int

variable_types: i int

variable_types: num int

variable_types: initDone int

variable_types: lastNum int


verbose

repo: bartoszp/killfd

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

va_start(arg, format);
result = (int)arg[0].reg_save_area;
if ( flag_verbose )
result = vfprintf(stderr, format, arg);
return result;
}

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

va_start(arg, format);
result = (int)arg[0].reg_save_area;
if ( flag_verbose )
result = vfprintf(stderr, format, arg);
return result;
}

original_code:
void verbose(char *fmt, ...) {
 va_list ap;
 __builtin_va_start(ap,fmt);
 if (flag_verbose)
  vfprintf(stderr, fmt, ap);
 __builtin_va_end(ap);
}

canonical_original_code:
void verbose(char *fmt, ...) {
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 if (flag_verbose)
  vfprintf(stderr, fmt, ap);
 __builtin_va_end(ap);
}

variable_types:
fmt
char *


error

decompiled_code:
void __noreturn error(int status, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
vfprintf(stderr, a2, arg);
exit(status);
}

canonical_decompiled_code:
void __noreturn func8(int status, const char *a2, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
vfprintf(stderr, a2, arg);
exit(status);
}

original_code:
void error(int exit_code, char *fmt, ...) {
 va_list ap;
 __builtin_va_start(ap,fmt);
 vfprintf(stderr, fmt, ap);
 __builtin_va_end(ap);
 exit(exit_code);
}

canonical_original_code:
void error(int exit_code, char *fmt, ...) {
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 vfprintf(stderr, fmt, ap);
 __builtin_va_end(ap);
 exit(exit_code);
}


decompiled_code:
unsigned __int64 __fastcall find_syscall(unsigned int a1)
{
int v1; // eax
int v2; // ebp
int v3; // ebx
unsigned int v4; // er13
char *v5; // rax
__int64 v6; // rax
unsigned __int64 v7; // rbx
int v8; // eax
_BOOL4 v9; // er13
__int64 v10; // rax
_BOOL4 v11; // edx
_BOOL8 v12; // rcx
char v14[8]; // [rsp+0h] [rbp-278h]
__int64 v15; // [rsp+8h] [rbp-270h]
char s[32]; // [rsp+10h] [rbp-268h] BYREF
char v17[523]; // [rsp+30h] [rbp-248h] BYREF
char v18[4]; // [rsp+23Bh] [rbp-3Dh] BYREF
char v19; // [rsp+23Fh] [rbp-39h] BYREF
__int64 v20; // [rsp+240h] [rbp-38h]
unsigned __int64 v21; // [rsp+248h] [rbp-30h]
_QWORD v22[5]; // [rsp+250h] [rbp-28h] BYREF

*(_QWORD *)v14 = 0LL;
v15 = 0LL;
snprintf(s, 0x20uLL, "/proc/%d/maps", a1);
verbose("Opening process's maps file: %s\n", s);
v1 = open(s, 0);
if ( v1 < 0 )
error(1, "Error when trying to open maps file: %s\n", s);
v2 = v1;
v3 = 0;
while ( read(v2, &v17[v3], 1uLL) == 1 )
{
v6 = v3++;
if ( v17[v6] == 10 )
{
v17[v6] = 0;
verbose("Read line: %s\n", v17);
__isoc99_sscanf();
v19 = 0;
v5 = v18;
v4 = 0;
do
{
if ( *v5 == 120 )
{
v4 |= 2u;
}
else if ( *v5 == 114 )
{
v4 |= 1u;
}
++v5;
}
while ( v5 != &v19 );
verbose("start: %lx, stop: %lx, delta: %d; perm: %s, %d\n", v21, v20, v20 - v21, v18, v4);
v3 = 0;
if ( v4 == 3 )
{
verbose("Found readable and executable memory area\n");
v7 = v21;
*(_QWORD *)v14 = ptrace(PTRACE_PEEKTEXT, a1, v21, 0LL);
if ( v7 >= v20 - 1 )
{
v3 = 0;
}
else
{
v8 = 0;
v9 = 0;
do
{
if ( v8 == 7 )
{
v10 = ptrace(PTRACE_PEEKTEXT, a1, v7 + 1, 0LL);
v11 = !v9;
*(_QWORD *)&v14[8 * !v9] = v10;
v12 = v9;
v9 = v11;
v8 = 0;
if ( v14[8 * v12 + 7] == magic )
{
if ( v14[8 * v11] == byte_404099 )
return v7;
v8 = 0;
}
}
else
{
if ( *((_BYTE *)&v22[v9 - 74] + v8) == magic && *((_BYTE *)&v22[v9 - 74] + v8 + 1) == byte_404099 )
return v7;
++v8;
}
++v7;
}
while ( v7 < v20 - 1 );
v3 = 0;
}
}
}
}
return 0LL;
}

original_code:
unsigned char *find_syscall(int pid) {
 unsigned char *t;
 int a, fd, idx, i, seg, j;
 long long start, stop;
 char perm[5];
 int permissions;
 char line[512];
 long long peek_data;
 char filename[32];
 unsigned char data[2][8];
 memset(data[0], 0, 8);
 memset(data[1], 0, 8);
 snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
 verbose("Opening process's maps file: %s\n", filename);
 fd = open(filename, 00);
 if (fd < 0)
  error(1, "Error when trying to open maps file: %s\n", filename);
 idx = 0;
 while (1) {
  if (read(fd, &line[idx], 1) != 1) {
   line[idx] = '\0';
   break;
  }
  if (line[idx] == '\n') {
   line[idx] = '\0';
   verbose("Read line: %s\n", line);
   sscanf(line, "%lx-%lx %4c", &start, &stop, perm);
   perm[4] = '\0';
   permissions = 0;
   for (i = 0; i < 4; i++) {
    if (perm[i] == 'x')
     permissions |= 2;
    if (perm[i] == 'r')
     permissions |= 1;
   }
   verbose("start: %lx, stop: %lx, delta: %d; perm: %s, %d\n", start, stop, stop - start, perm, permissions);
   if (permissions == (2 | 1)) {
    verbose("Found readable and executable memory area\n");
    t = (unsigned char *) start;
    seg = 0;
    peek_data = ptrace(PTRACE_PEEKTEXT, pid, t, ((void *)0));
    memcpy(data[seg], &peek_data, 8);
    j = 0;
    while (t < (unsigned char *) (stop - 1)) {
     if (j == (8 - 1)) {
      peek_data = ptrace(PTRACE_PEEKTEXT, pid, t + 1, ((void *)0));
      memcpy(data[!seg], &peek_data, 8);
      if (data[seg][8 - 1] == magic[0] && data[!seg][0] == magic[1])
       return t;
      seg = !seg;
      j = 0;
     } else {
      if (data[seg][j] == magic[0] && data[seg][j + 1] == magic[1])
       return t;
      j++;
     }
     t++;
    }
   }
   idx = 0;
   continue;
  }
  idx++;
 }
 return ((void *)0);
}

canonical_original_code:
unsigned char *find_syscall(int pid) {
 unsigned char *t;
 int a; int fd; int idx; int i; int seg; int j;
 long long start; long long stop;
 char perm[5];
 int permissions;
 char line[512];
 long long peek_data;
 char filename[32];
 unsigned char data[2][8];
 memset(data[0], 0, 8);
 memset(data[1], 0, 8);
 snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
 verbose("Opening process's maps file: %s\n", filename);
 fd = open(filename, 00);
 if (fd < 0)
  error(1, "Error when trying to open maps file: %s\n", filename);
 idx = 0;
 while (1) {
  if (read(fd, &line[idx], 1) != 1) {
   line[idx] = '\0';
   break;
  }
  if (line[idx] == '\n') {
   line[idx] = '\0';
   verbose("Read line: %s\n", line);
   sscanf(line, "%lx-%lx %4c", &start, &stop, perm);
   perm[4] = '\0';
   permissions = 0;
   for (i = 0; i < 4; i++) {
    if (perm[i] == 'x')
     permissions |= 2;
    if (perm[i] == 'r')
     permissions |= 1;
   }
   verbose("start: %lx, stop: %lx, delta: %d; perm: %s, %d\n", start, stop, stop - start, perm, permissions);
   if (permissions == (2 | 1)) {
    verbose("Found readable and executable memory area\n");
    t = (unsigned char *) start;
    seg = 0;
    peek_data = ptrace(PTRACE_PEEKTEXT, pid, t, ((void *)0));
    memcpy(data[seg], &peek_data, 8);
    j = 0;
    while (t < (unsigned char *) (stop - 1)) {
     if (j == (8 - 1)) {
      peek_data = ptrace(PTRACE_PEEKTEXT, pid, t + 1, ((void *)0));
      memcpy(data[!seg], &peek_data, 8);
      if (data[seg][8 - 1] == magic[0] && data[!seg][0] == magic[1])
       return t;
      seg = !seg;
      j = 0;
     } else {
      if (data[seg][j] == magic[0] && data[seg][j + 1] == magic[1])
       return t;
      j++;
     }
     t++;
    }
   }
   idx = 0;
   continue;
  }
  idx++;
 }
 return ((void *)0);
}

variable_types: pid int

variable_types:
t
unsigned char *

variable_types: a int

variable_types: idx int

variable_types: seg int

variable_types: j int

variable_types:
start
long long

variable_types:
stop
long long

variable_types:
perm
char [5]

variable_types: permissions int

variable_types:
line
char [512]

variable_types:
filename
char [32]

variable_types:
data
unsigned char [2][8]

return_type: unsigned char *


usage

decompiled_code:
void __fastcall __noreturn usage(const char **a1)
{
fprintf(stderr, "Usage: %s -p process_id file_descriptor_number\n", *a1);
fwrite("\n\n", 1uLL, 2uLL, stderr);
fwrite("This program closes a file descriptor/socket in a process <process_id>\n", 1uLL, 0x47uLL, stderr);
exit(2);
}

canonical_decompiled_code:
void __fastcall __noreturn func10(const char **a1)
{
fprintf(stderr, "Usage: %s -p process_id file_descriptor_number\n", *a1);
fwrite("\n\n", 1uLL, 2uLL, stderr);
fwrite("This program closes a file descriptor/socket in a process <process_id>\n", 1uLL, 0x47uLL, stderr);
exit(2);
}

original_code:
void usage(char **argv) {
 fprintf(stderr, "Usage: %s -p process_id file_descriptor_number\n", argv[0]);
 fprintf(stderr, "\n\n");
 fprintf(stderr, "This program closes a file descriptor/socket in a process <process_id>\n");
 exit(2);
}

variable_types:
argv
char **


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
unsigned int v4; // er13
char v5; // al
unsigned int v6; // ebp
int v7; // ebx
unsigned int v8; // ebx
_DWORD *v9; // rdi
char *v10; // rsi
__int64 i; // rcx
unsigned __int64 v12; // rax
unsigned int v13; // ebx
unsigned int v14; // ebp
unsigned int v15; // ebx
unsigned int v16; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1ECh] BYREF
__int64 v18; // [rsp+60h] [rbp-198h]
__int64 v19; // [rsp+80h] [rbp-178h]
unsigned __int64 v20; // [rsp+90h] [rbp-168h]
char v21[264]; // [rsp+F0h] [rbp-108h] BYREF

verbose("user_regs_struct size: %d\n", 216LL);
v4 = -1;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "vp:");
if ( v5 == -1 )
break;
switch ( v5 )
{
case 'p':
v4 = atoi(optarg);
break;
case 'v':
flag_verbose = 1;
break;
case '?':
if ( optopt == 112 )
error(1, "-p requires an argument (pid of the process)\n");
break;
default:
abort();
}
}
if ( v4 == -1 || optind + 1 < argc || optind == argc )
usage(argv);
if ( optind < argc )
v3 = atol(argv[optind]);
v6 = ptrace(PTRACE_ATTACH, v4, 0LL, 0LL);
v7 = v6;
verbose("ptrace attach: %d\n", v6);
if ( !v6 )
{
while ( 1 )
{
wait((__WAIT_STATUS)&stat_loc);
verbose("wait: %d, %x\n", LODWORD(stat_loc.__uptr), LODWORD(stat_loc.__uptr));
if ( v7 )
break;
if ( ((__int64)stat_loc.__uptr & 0x7F) == 0 )
error(1, "The process has terminated\n");
if ( LOBYTE(stat_loc.__uptr) == 127 )
{
verbose("Child received signal: %d\n", BYTE1(stat_loc.__uptr));
v8 = ptrace(PTRACE_GETREGS, v4, 0LL, v21);
verbose("ptrace getregs: %d\n", v8);
if ( v8 )
error(1, "ptrace getregs error: %d\n", v8);
v9 = (_DWORD *)&stat_loc.__iptr + 1;
v10 = v21;
for ( i = 54LL; i; --i )
{
*v9 = *(_DWORD *)v10;
v10 += 4;
++v9;
}
v12 = find_syscall(v4);
if ( !v12 )
error(1, "Couldn't find system call machine code\n");
v18 = 3LL;
v19 = v3;
v20 = v12;
v13 = ptrace(PTRACE_SETREGS, v4, 0LL, (char *)&stat_loc.__iptr + 4);
verbose("setregs: %d\n", v13);
if ( v13 )
error(1, "ptrace setregs error: %d\n", v13);
v14 = ptrace(PTRACE_SINGLESTEP, v4, 0LL, 0LL);
verbose("ptrace singlestep: %d\n", v14);
v7 = 1;
if ( v14 )
error(1, "ptrace singlestep error: %d\n", v14);
}
}
v15 = ptrace(PTRACE_SETREGS, v4, 0LL, v21);
verbose("setregs: %d\n", v15);
if ( v15 )
error(1, "ptrace setregs error: %d\n", v15);
v16 = ptrace(PTRACE_DETACH, v4, 0LL, 18LL);
verbose("detach(): %d\n", v16);
if ( v16 )
error(1, "ptrace detach error: %d\n", v16);
exit(0);
}
error(
1,
"error in ptrace attach: %d to pid: %d; is the process running and are you allowed to attach to it?\n",
v6,
v4);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
unsigned int v4; // er13
char v5; // al
unsigned int v6; // ebp
int v7; // ebx
unsigned int v8; // ebx
_DWORD *v9; // rdi
char *v10; // rsi
__int64 i; // rcx
unsigned __int64 v12; // rax
unsigned int v13; // ebx
unsigned int v14; // ebp
unsigned int v15; // ebx
unsigned int v16; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-1ECh] BYREF
__int64 v18; // [rsp+60h] [rbp-198h]
__int64 v19; // [rsp+80h] [rbp-178h]
unsigned __int64 v20; // [rsp+90h] [rbp-168h]
char v21[264]; // [rsp+F0h] [rbp-108h] BYREF

func7("user_regs_struct size: %d\n", 216LL);
v4 = -1;
while ( 1 )
{
v5 = getopt(argc, (char *const *)argv, "vp:");
if ( v5 == -1 )
break;
switch ( v5 )
{
case 'p':
v4 = atoi(optarg);
break;
case 'v':
flag_verbose = 1;
break;
case '?':
if ( optopt == 112 )
func8(1, "-p requires an argument (pid of the process)\n");
break;
default:
abort();
}
}
if ( v4 == -1 || optind + 1 < argc || optind == argc )
func10(argv);
if ( optind < argc )
v3 = atol(argv[optind]);
v6 = ptrace(PTRACE_ATTACH, v4, 0LL, 0LL);
v7 = v6;
func7("ptrace attach: %d\n", v6);
if ( !v6 )
{
while ( 1 )
{
wait((__WAIT_STATUS)&stat_loc);
func7("wait: %d, %x\n", LODWORD(stat_loc.__uptr), LODWORD(stat_loc.__uptr));
if ( v7 )
break;
if ( ((__int64)stat_loc.__uptr & 0x7F) == 0 )
func8(1, "The process has terminated\n");
if ( LOBYTE(stat_loc.__uptr) == 127 )
{
func7("Child received signal: %d\n", BYTE1(stat_loc.__uptr));
v8 = ptrace(PTRACE_GETREGS, v4, 0LL, v21);
func7("ptrace getregs: %d\n", v8);
if ( v8 )
func8(1, "ptrace getregs error: %d\n", v8);
v9 = (_DWORD *)&stat_loc.__iptr + 1;
v10 = v21;
for ( i = 54LL; i; --i )
{
*v9 = *(_DWORD *)v10;
v10 += 4;
++v9;
}
v12 = func9(v4);
if ( !v12 )
func8(1, "Couldn't find system call machine code\n");
v18 = 3LL;
v19 = v3;
v20 = v12;
v13 = ptrace(PTRACE_SETREGS, v4, 0LL, (char *)&stat_loc.__iptr + 4);
func7("setregs: %d\n", v13);
if ( v13 )
func8(1, "ptrace setregs error: %d\n", v13);
v14 = ptrace(PTRACE_SINGLESTEP, v4, 0LL, 0LL);
func7("ptrace singlestep: %d\n", v14);
v7 = 1;
if ( v14 )
func8(1, "ptrace singlestep error: %d\n", v14);
}
}
v15 = ptrace(PTRACE_SETREGS, v4, 0LL, v21);
func7("setregs: %d\n", v15);
if ( v15 )
func8(1, "ptrace setregs error: %d\n", v15);
v16 = ptrace(PTRACE_DETACH, v4, 0LL, 18LL);
func7("detach(): %d\n", v16);
if ( v16 )
func8(1, "ptrace detach error: %d\n", v16);
exit(0);
}
func8(
1,
"error in ptrace attach: %d to pid: %d; is the process running and are you allowed to attach to it?\n",
v6,
v4);
}

original_code:
int main (int argc, char **argv) {
        struct user_regs_struct orig_regs, new_regs;
        int pid = -1, status, last_status = 0;
        int data = 0, done = 0, i, *p, fd, ec;
        char c;
        unsigned char *t;
 long int file_desc_no;
        verbose("user_regs_struct size: %d\n", sizeof(struct user_regs_struct));
 while ((c = getopt (argc, argv, "vp:")) != -1)
  switch (c) {
   case 'p':
    pid = atoi(optarg);
    break;
   case 'v':
    flag_verbose = 1;
    break;
   case '?':
    if (optopt == 'p')
     error(1, "-p requires an argument (pid of the process)\n");
    break;
   default:
    abort ();
  }
 if (pid == -1 || (optind + 1 < argc) || (optind == argc)) {
  usage(argv);
 }
 if (optind < argc) {
  file_desc_no = atol(argv[optind]);
 }
        i = 0;
        if (1) {
  ec = ptrace(PTRACE_ATTACH, pid, 0, 0);
                verbose("ptrace attach: %d\n", ec);
  if (ec)
   error(1, "error in ptrace attach: %d to pid: %d; is the process running and are you allowed to attach to it?\n", ec, pid);
                while (1) {
                        data = 0;
                        wait(&status);
                        verbose("wait: %d, %x\n", status, status);
                        if (done) {
                                p = (int *) &orig_regs;
                                ec = ptrace(PTRACE_SETREGS, pid, 0, &orig_regs);
    verbose("setregs: %d\n", ec);
    if (ec)
     error(1, "ptrace setregs error: %d\n", ec);
    ec = ptrace(PTRACE_DETACH, pid, 0, 18);
                                verbose("detach(): %d\n", ec);
    if (ec)
     error(1, "ptrace detach error: %d\n", ec);
                                exit(0);
                        }
                        if ((((status) & 0x7f) == 0)) {
    error(1, "The process has terminated\n");
                        }
                        if ((((status) & 0xff) == 0x7f)) {
                                verbose("Child received signal: %d\n", (((status) & 0xff00) >> 8));
                                if ((((status) & 0xff00) >> 8) != 5)
                                        data = (((status) & 0xff00) >> 8);
                                p = (int *) &orig_regs;
    ec = ptrace(PTRACE_GETREGS, pid, 0, &orig_regs);
                                verbose("ptrace getregs: %d\n", ec);
    if (ec)
     error(1, "ptrace getregs error: %d\n", ec);
                                memcpy(&new_regs, &orig_regs, sizeof(orig_regs));
    t = find_syscall(pid);
    if (!t)
     error(1, "Couldn't find system call machine code\n");
                                new_regs.rax = 3;
                                new_regs.rdi = file_desc_no;
                                new_regs.rip = (long int) t;
    ec = ptrace(PTRACE_SETREGS, pid, 0, &new_regs);
                                verbose("setregs: %d\n", ec);
    if (ec)
     error(1, "ptrace setregs error: %d\n", ec);
    ec = ptrace(PTRACE_SINGLESTEP, pid, 0, 0);
                                verbose("ptrace singlestep: %d\n", ec);
    if (ec)
     error(1, "ptrace singlestep error: %d\n", ec);
                                done = 1;
                        }
                }
                verbose("This is the end\n");
        }
}

canonical_original_code:
int main(int argc, char **argv) {
        struct user_regs_struct orig_regs; struct user_regs_struct new_regs;
        int pid = -1; int status; int last_status = 0;
        int data = 0; int done = 0; int i; int *p; int fd; int ec;
        char c;
        unsigned char *t;
 long file_desc_no;
        verbose("user_regs_struct size: %d\n", sizeof(struct user_regs_struct));
 while ((c = getopt (argc, argv, "vp:")) != -1)
  switch (c) {
   case 'p':
    pid = atoi(optarg);
    break;
   case 'v':
    flag_verbose = 1;
    break;
   case '?':
    if (optopt == 'p')
     error(1, "-p requires an argument (pid of the process)\n");
    break;
   default:
    abort ();
  }
 if (pid == -1 || (optind + 1 < argc) || (optind == argc)) {
  usage(argv);
 }
 if (optind < argc) {
  file_desc_no = atol(argv[optind]);
 }
        i = 0;
        if (1) {
  ec = ptrace(PTRACE_ATTACH, pid, 0, 0);
                verbose("ptrace attach: %d\n", ec);
  if (ec)
   error(1, "error in ptrace attach: %d to pid: %d; is the process running and are you allowed to attach to it?\n", ec, pid);
                while (1) {
                        data = 0;
                        wait(&status);
                        verbose("wait: %d, %x\n", status, status);
                        if (done) {
                                p = (int *) &orig_regs;
                                ec = ptrace(PTRACE_SETREGS, pid, 0, &orig_regs);
    verbose("setregs: %d\n", ec);
    if (ec)
     error(1, "ptrace setregs error: %d\n", ec);
    ec = ptrace(PTRACE_DETACH, pid, 0, 18);
                                verbose("detach(): %d\n", ec);
    if (ec)
     error(1, "ptrace detach error: %d\n", ec);
                                exit(0);
                        }
                        if ((((status) & 0x7f) == 0)) {
    error(1, "The process has terminated\n");
                        }
                        if ((((status) & 0xff) == 0x7f)) {
                                verbose("Child received signal: %d\n", (((status) & 0xff00) >> 8));
                                if ((((status) & 0xff00) >> 8) != 5)
                                        data = (((status) & 0xff00) >> 8);
                                p = (int *) &orig_regs;
    ec = ptrace(PTRACE_GETREGS, pid, 0, &orig_regs);
                                verbose("ptrace getregs: %d\n", ec);
    if (ec)
     error(1, "ptrace getregs error: %d\n", ec);
                                memcpy(&new_regs, &orig_regs, sizeof(orig_regs));
    t = find_syscall(pid);
    if (!t)
     error(1, "Couldn't find system call machine code\n");
                                new_regs.rax = 3;
                                new_regs.rdi = file_desc_no;
                                new_regs.rip = (long) t;
    ec = ptrace(PTRACE_SETREGS, pid, 0, &new_regs);
                                verbose("setregs: %d\n", ec);
    if (ec)
     error(1, "ptrace setregs error: %d\n", ec);
    ec = ptrace(PTRACE_SINGLESTEP, pid, 0, 0);
                                verbose("ptrace singlestep: %d\n", ec);
    if (ec)
     error(1, "ptrace singlestep error: %d\n", ec);
                                done = 1;
                        }
                }
                verbose("This is the end\n");
        }
}

variable_types: argc int

variable_types: struct user_regs_struct { unsigned long long r15; unsigned long long r14; unsigned long long r13; unsigned long long r12; unsigned long long rbp; unsigned long long rbx; unsigned long long r11; unsigned long long r10; unsigned long long r9; unsigned long long r8; unsigned long long rax; unsigned long long rcx; unsigned long long rdx; unsigned long long rsi; unsigned long long rdi; unsigned long long orig_rax; unsigned long long rip; unsigned long long cs; unsigned long long eflags; unsigned long long rsp; unsigned long long ss; unsigned long long fs_base; unsigned long long gs_base; unsigned long long ds; unsigned long long es; unsigned long long fs; unsigned long long gs; }

variable_types: status int

variable_types: data int

variable_types: done int

variable_types: i int

variable_types:
p
int *

variable_types: fd int

variable_types: ec int

variable_types: c char