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

result = 0LL;
if ( a1 <= 0x1A )
result = (unsigned __int8)variables[a1];
return result;
}

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

result = 0LL;
if ( a1 <= 0x1A )
result = (unsigned __int8)variables[a1];
return result;
}

original_code:
char
ubasic_get_variable(int varnum)
{
  if(varnum >= 0 && varnum <= 26) {
    return variables[varnum];
  }
  return 0;
}

return_type: char


varfactor

repo: adamdunkels/ubasic

decompiled_code:
__int64 varfactor()
{
unsigned int v0; // eax
char v1; // bl

v0 = tokenizer_variable_num();
v1 = ubasic_get_variable(v0);
accept(4);
return (unsigned int)v1;
}

canonical_decompiled_code:
__int64 func14()
{
unsigned int v0; // eax
char v1; // bl

v0 = tokenizer_variable_num();
v1 = func13(v0);
func2(4);
return (unsigned int)v1;
}

original_code:
static int
varfactor(void)
{
  int r;
  ;
  r = ubasic_get_variable(tokenizer_variable_num());
  accept(TOKENIZER_VARIABLE);
  return r;
}

canonical_original_code:
static int varfactor()
{
  int r;
  ;
  r = ubasic_get_variable(tokenizer_variable_num());
  accept(TOKENIZER_VARIABLE);
  return r;
}

variable_types: r int

return_type: int


factor

decompiled_code:
__int64 factor()
{
int v0; // eax
unsigned int v1; // ebx

v0 = tokenizer_token();
if ( v0 == 2 )
{
v1 = (char)tokenizer_num();
accept(2);
}
else if ( v0 == 31 )
{
accept(31);
v1 = (char)expr();
accept(32);
}
else
{
v1 = varfactor();
}
return v1;
}

canonical_decompiled_code:
__int64 func15()
{
int v0; // eax
unsigned int v1; // ebx

v0 = tokenizer_token();
if ( v0 == 2 )
{
v1 = (char)tokenizer_num();
func2(2);
}
else if ( v0 == 31 )
{
func2(31);
v1 = (char)func17();
func2(32);
}
else
{
v1 = func14();
}
return v1;
}

original_code:
static int
factor(void)
{
  int r;
  ;
  switch(tokenizer_token()) {
  case TOKENIZER_NUMBER:
    r = tokenizer_num();
    ;
    accept(TOKENIZER_NUMBER);
    break;
  case TOKENIZER_LEFTPAREN:
    accept(TOKENIZER_LEFTPAREN);
    r = expr();
    accept(TOKENIZER_RIGHTPAREN);
    break;
  default:
    r = varfactor();
    break;
  }
  return r;
}

canonical_original_code:
static int factor()
{
  int r;
  ;
  switch(tokenizer_token()) {
  case TOKENIZER_NUMBER:
    r = tokenizer_num();
    ;
    accept(TOKENIZER_NUMBER);
    break;
  case TOKENIZER_LEFTPAREN:
    accept(TOKENIZER_LEFTPAREN);
    r = expr();
    accept(TOKENIZER_RIGHTPAREN);
    break;
  default:
    r = varfactor();
    break;
  }
  return r;
}


term

decompiled_code:
__int64 __fastcall term(__int64 a1, __int64 a2)
{
int v2; // ebp
int i; // ebx
__int64 v5; // rdx
int v6; // eax

v2 = factor();
for ( i = ((__int64 (*)(void))tokenizer_token)(); (unsigned int)(i - 27) <= 2; i = tokenizer_token(a1, a2, v5) )
{
tokenizer_next();
v6 = factor();
switch ( i )
{
case 28:
v5 = (unsigned int)(v2 >> 31);
LODWORD(v5) = v2 % v6;
v2 /= v6;
break;
case 29:
v5 = (unsigned int)(v2 >> 31);
LODWORD(v5) = v2 % v6;
v2 %= v6;
break;
case 27:
v2 *= v6;
break;
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2)
{
int v2; // ebp
int i; // ebx
__int64 v5; // rdx
int v6; // eax

v2 = func15();
for ( i = ((__int64 (*)(void))tokenizer_token)(); (unsigned int)(i - 27) <= 2; i = tokenizer_token(a1, a2, v5) )
{
tokenizer_next();
v6 = func15();
switch ( i )
{
case 28:
v5 = (unsigned int)(v2 >> 31);
LODWORD(v5) = v2 % v6;
v2 /= v6;
break;
case 29:
v5 = (unsigned int)(v2 >> 31);
LODWORD(v5) = v2 % v6;
v2 %= v6;
break;
case 27:
v2 *= v6;
break;
}
}
return (unsigned int)v2;
}

original_code:
static int
term(void)
{
  int f1, f2;
  int op;
  f1 = factor();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_ASTR ||
       op == TOKENIZER_SLASH ||
       op == TOKENIZER_MOD) {
    tokenizer_next();
    f2 = factor();
    ;
    switch(op) {
    case TOKENIZER_ASTR:
      f1 = f1 * f2;
      break;
    case TOKENIZER_SLASH:
      f1 = f1 / f2;
      break;
    case TOKENIZER_MOD:
      f1 = f1 % f2;
      break;
    }
    op = tokenizer_token();
  }
  ;
  return f1;
}

canonical_original_code:
static int term()
{
  int f1; int f2;
  int op;
  f1 = factor();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_ASTR ||
       op == TOKENIZER_SLASH ||
       op == TOKENIZER_MOD) {
    tokenizer_next();
    f2 = factor();
    ;
    switch(op) {
    case TOKENIZER_ASTR:
      f1 = f1 * f2;
      break;
    case TOKENIZER_SLASH:
      f1 = f1 / f2;
      break;
    case TOKENIZER_MOD:
      f1 = f1 % f2;
      break;
    }
    op = tokenizer_token();
  }
  ;
  return f1;
}

variable_types: op int


expr

decompiled_code:
__int64 __fastcall expr(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 v3; // rdx
int i; // ebx
int v6; // eax
int v7; // eax
__int64 v8; // rdx

v2 = term(a1, a2);
for ( i = tokenizer_token(a1, a2, v3); (unsigned int)(i - 23) <= 3; i = tokenizer_token(a1, a2, v8) )
{
tokenizer_next();
v7 = term(a1, a2);
if ( i == 25 )
{
v2 &= v7;
}
else if ( i > 25 )
{
v6 = v2 | v7;
if ( i == 26 )
v2 = v6;
}
else if ( i == 23 )
{
v2 += v7;
}
else if ( i == 24 )
{
v2 -= v7;
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2)
{
unsigned int v2; // ebp
__int64 v3; // rdx
int i; // ebx
int v6; // eax
int v7; // eax
__int64 v8; // rdx

v2 = func16(a1, a2);
for ( i = tokenizer_token(a1, a2, v3); (unsigned int)(i - 23) <= 3; i = tokenizer_token(a1, a2, v8) )
{
tokenizer_next();
v7 = func16(a1, a2);
if ( i == 25 )
{
v2 &= v7;
}
else if ( i > 25 )
{
v6 = v2 | v7;
if ( i == 26 )
v2 = v6;
}
else if ( i == 23 )
{
v2 += v7;
}
else if ( i == 24 )
{
v2 -= v7;
}
}
return v2;
}

original_code:
static char
expr(void)
{
  int t1, t2;
  int op;
  t1 = term();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_PLUS ||
       op == TOKENIZER_MINUS ||
       op == TOKENIZER_AND ||
       op == TOKENIZER_OR) {
    tokenizer_next();
    t2 = term();
    ;
    switch(op) {
    case TOKENIZER_PLUS:
      t1 = t1 + t2;
      break;
    case TOKENIZER_MINUS:
      t1 = t1 - t2;
      break;
    case TOKENIZER_AND:
      t1 = t1 & t2;
      break;
    case TOKENIZER_OR:
      t1 = t1 | t2;
      break;
    }
    op = tokenizer_token();
  }
  ;
  return t1;
}

canonical_original_code:
static char expr()
{
  int t1; int t2;
  int op;
  t1 = term();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_PLUS ||
       op == TOKENIZER_MINUS ||
       op == TOKENIZER_AND ||
       op == TOKENIZER_OR) {
    tokenizer_next();
    t2 = term();
    ;
    switch(op) {
    case TOKENIZER_PLUS:
      t1 = t1 + t2;
      break;
    case TOKENIZER_MINUS:
      t1 = t1 - t2;
      break;
    case TOKENIZER_AND:
      t1 = t1 & t2;
      break;
    case TOKENIZER_OR:
      t1 = t1 | t2;
      break;
    }
    op = tokenizer_token();
  }
  ;
  return t1;
}


decompiled_code:
__int64 __fastcall print_statement(__int64 a1, __int64 a2)
{
const char *v2; // rdi
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx

v2 = (_BYTE *)(index_find + 6);
accept(6);
while ( 1 )
{
if ( (unsigned int)tokenizer_token(v2, a2, v3) == 3 )
{
tokenizer_string(string, 40LL);
a2 = (__int64)string;
v2 = "%s";
printf("%s", string);
tokenizer_next();
goto LABEL_3;
}
if ( (unsigned int)tokenizer_token(v2, a2, v6) == 21 )
{
v2 = (_BYTE *)&locret_20;
putchar(32);
tokenizer_next();
goto LABEL_3;
}
if ( (unsigned int)tokenizer_token(v2, a2, v7) != 22 )
break;
tokenizer_next();
LABEL_3:
if ( (unsigned int)tokenizer_token(v2, a2, v4) == 36 || (unsigned int)tokenizer_token(v2, a2, v5) == 1 )
goto LABEL_13;
}
if ( (unsigned int)tokenizer_token(v2, a2, v8) == 4 || (unsigned int)tokenizer_token(v2, a2, v9) == 2 )
{
a2 = (unsigned int)(char)expr((__int64)v2, a2);
v2 = "%d";
printf("%d", a2);
goto LABEL_3;
}
LABEL_13:
putchar(10);
return tokenizer_next();
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2)
{
const char *v2; // rdi
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx
__int64 v8; // rdx
__int64 v9; // rdx

v2 = (_BYTE *)(index_find + 6);
func2(6);
while ( 1 )
{
if ( (unsigned int)tokenizer_token(v2, a2, v3) == 3 )
{
tokenizer_string(string, 40LL);
a2 = (__int64)string;
v2 = "%s";
printf("%s", string);
tokenizer_next();
goto LABEL_3;
}
if ( (unsigned int)tokenizer_token(v2, a2, v6) == 21 )
{
v2 = (_BYTE *)&locret_20;
putchar(32);
tokenizer_next();
goto LABEL_3;
}
if ( (unsigned int)tokenizer_token(v2, a2, v7) != 22 )
break;
tokenizer_next();
LABEL_3:
if ( (unsigned int)tokenizer_token(v2, a2, v4) == 36 || (unsigned int)tokenizer_token(v2, a2, v5) == 1 )
goto LABEL_13;
}
if ( (unsigned int)tokenizer_token(v2, a2, v8) == 4 || (unsigned int)tokenizer_token(v2, a2, v9) == 2 )
{
a2 = (unsigned int)(char)func17((__int64)v2, a2);
v2 = "%d";
printf("%d", a2);
goto LABEL_3;
}
LABEL_13:
putchar(10);
return tokenizer_next();
}

original_code:
static void
print_statement(void)
{
  accept(TOKENIZER_PRINT);
  do {
    ;
    if(tokenizer_token() == TOKENIZER_STRING) {
      tokenizer_string(string, sizeof(string));
      printf("%s", string);
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_COMMA) {
      printf(" ");
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_SEMICOLON) {
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_VARIABLE ||
          tokenizer_token() == TOKENIZER_NUMBER) {
      printf("%d", expr());
    } else {
      break;
    }
  } while(tokenizer_token() != TOKENIZER_CR &&
      tokenizer_token() != TOKENIZER_ENDOFINPUT);
  printf("\n");
  ;
  tokenizer_next();
}

canonical_original_code:
static void print_statement()
{
  accept(TOKENIZER_PRINT);
  do {
    ;
    if(tokenizer_token() == TOKENIZER_STRING) {
      tokenizer_string(string, sizeof(string));
      printf("%s", string);
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_COMMA) {
      printf(" ");
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_SEMICOLON) {
      tokenizer_next();
    } else if(tokenizer_token() == TOKENIZER_VARIABLE ||
          tokenizer_token() == TOKENIZER_NUMBER) {
      printf("%d", expr());
    } else {
      break;
    }
  } while(tokenizer_token() != TOKENIZER_CR &&
      tokenizer_token() != TOKENIZER_ENDOFINPUT);
  printf("\n");
  ;
  tokenizer_next();
}

return_type: void


relation

decompiled_code:
__int64 __fastcall relation(__int64 a1, __int64 a2)
{
signed int v2; // ebp
__int64 v3; // rdx
int i; // ebx
int v6; // eax
__int64 v7; // rdx

v2 = (char)expr(a1, a2);
for ( i = tokenizer_token(a1, a2, v3); (unsigned int)(i - 33) <= 2; i = tokenizer_token(a1, a2, v7) )
{
tokenizer_next();
v6 = (char)expr(a1, a2);
switch ( i )
{
case '"':
v2 = v6 < v2;
break;
case '#':
v2 = v6 == v2;
break;
case '!':
v2 = v6 > v2;
break;
}
}
return (unsigned int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2)
{
signed int v2; // ebp
__int64 v3; // rdx
int i; // ebx
int v6; // eax
__int64 v7; // rdx

v2 = (char)func17(a1, a2);
for ( i = tokenizer_token(a1, a2, v3); (unsigned int)(i - 33) <= 2; i = tokenizer_token(a1, a2, v7) )
{
tokenizer_next();
v6 = (char)func17(a1, a2);
switch ( i )
{
case '"':
v2 = v6 < v2;
break;
case '#':
v2 = v6 == v2;
break;
case '!':
v2 = v6 > v2;
break;
}
}
return (unsigned int)v2;
}

original_code:
static int
relation(void)
{
  int r1, r2;
  int op;
  r1 = expr();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_LT ||
       op == TOKENIZER_GT ||
       op == TOKENIZER_EQ) {
    tokenizer_next();
    r2 = expr();
    ;
    switch(op) {
    case TOKENIZER_LT:
      r1 = r1 < r2;
      break;
    case TOKENIZER_GT:
      r1 = r1 > r2;
      break;
    case TOKENIZER_EQ:
      r1 = r1 == r2;
      break;
    }
    op = tokenizer_token();
  }
  return r1;
}

canonical_original_code:
static int relation()
{
  int r1; int r2;
  int op;
  r1 = expr();
  op = tokenizer_token();
  ;
  while(op == TOKENIZER_LT ||
       op == TOKENIZER_GT ||
       op == TOKENIZER_EQ) {
    tokenizer_next();
    r2 = expr();
    ;
    switch(op) {
    case TOKENIZER_LT:
      r1 = r1 < r2;
      break;
    case TOKENIZER_GT:
      r1 = r1 > r2;
      break;
    case TOKENIZER_EQ:
      r1 = r1 == r2;
      break;
    }
    op = tokenizer_token();
  }
  return r1;
}


decompiled_code:
__int64 __fastcall for_statement(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
char v3; // al
__int64 v4; // rsi
char v5; // bp
__int64 result; // rax
char v7; // al
int v8; // ecx
__int64 v9; // rdi

accept(10);
v2 = tokenizer_variable_num();
accept(4);
accept(35);
v3 = expr(35LL, a2);
v4 = (unsigned int)v3;
ubasic_set_variable(v2, v3);
accept(11);
v5 = expr(11LL, v4);
result = accept(36);
if ( for_stack_ptr <= 3 )
{
v7 = tokenizer_num();
v8 = for_stack_ptr;
v9 = 3LL * for_stack_ptr;
for_stack[v9] = v7;
dword_944[v9] = v2;
result = (unsigned int)v5;
dword_948[v9] = result;
for_stack_ptr = v8 + 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
char v3; // al
__int64 v4; // rsi
char v5; // bp
__int64 result; // rax
char v7; // al
int v8; // ecx
__int64 v9; // rdi

func2(10);
v2 = tokenizer_variable_num();
func2(4);
func2(35);
v3 = func17(35LL, a2);
v4 = (unsigned int)v3;
func12(v2, v3);
func2(11);
v5 = func17(11LL, v4);
result = func2(36);
if ( for_stack_ptr <= 3 )
{
v7 = tokenizer_num();
v8 = for_stack_ptr;
v9 = 3LL * for_stack_ptr;
for_stack[v9] = v7;
dword_944[v9] = v2;
result = (unsigned int)v5;
dword_948[v9] = result;
for_stack_ptr = v8 + 1;
}
return result;
}

original_code:
static void
for_statement(void)
{
  int for_variable, to;
  accept(TOKENIZER_FOR);
  for_variable = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_EQ);
  ubasic_set_variable(for_variable, expr());
  accept(TOKENIZER_TO);
  to = expr();
  accept(TOKENIZER_CR);
  if(for_stack_ptr < 4) {
    for_stack[for_stack_ptr].line_after_for = tokenizer_num();
    for_stack[for_stack_ptr].for_variable = for_variable;
    for_stack[for_stack_ptr].to = to;
    ;
    for_stack_ptr++;
  } else {
    ;
  }
}

canonical_original_code:
static void for_statement()
{
  int for_variable; int to;
  accept(TOKENIZER_FOR);
  for_variable = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_EQ);
  ubasic_set_variable(for_variable, expr());
  accept(TOKENIZER_TO);
  to = expr();
  accept(TOKENIZER_CR);
  if(for_stack_ptr < 4) {
    for_stack[for_stack_ptr].line_after_for = tokenizer_num();
    for_stack[for_stack_ptr].for_variable = for_variable;
    for_stack[for_stack_ptr].to = to;
    ;
    for_stack_ptr++;
  } else {
    ;
  }
}

variable_types: to int


decompiled_code:
void __fastcall peek_statement(__int64 a1, __int64 a2)
{
char v2; // bl
unsigned int v3; // ebp
char v4; // al

accept(18);
v2 = expr(18LL, a2);
accept(21);
v3 = tokenizer_variable_num();
accept(4);
accept(36);
v4 = peek_function((unsigned int)v2);
ubasic_set_variable(v3, v4);
}

canonical_decompiled_code:
void __fastcall func21(__int64 a1, __int64 a2)
{
char v2; // bl
unsigned int v3; // ebp
char v4; // al

func2(18);
v2 = func17(18LL, a2);
func2(21);
v3 = tokenizer_variable_num();
func2(4);
func2(36);
v4 = peek_function((unsigned int)v2);
func12(v3, v4);
}

original_code:
static void
peek_statement(void)
{
  char peek_addr;
  int var;
  accept(TOKENIZER_PEEK);
  peek_addr = expr();
  accept(TOKENIZER_COMMA);
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_CR);
  ubasic_set_variable(var, peek_function(peek_addr));
}

canonical_original_code:
static void peek_statement()
{
  char peek_addr;
  int var;
  accept(TOKENIZER_PEEK);
  peek_addr = expr();
  accept(TOKENIZER_COMMA);
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_CR);
  ubasic_set_variable(var, peek_function(peek_addr));
}

variable_types: var int


decompiled_code:
__int64 __fastcall poke_statement(__int64 a1, __int64 a2)
{
char v2; // bl
char v3; // bp

accept(19);
v2 = expr(19LL, a2);
accept(21);
v3 = expr(21LL, a2);
accept(36);
return poke_function((unsigned int)v2, (unsigned int)v3);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, __int64 a2)
{
char v2; // bl
char v3; // bp

func2(19);
v2 = func17(19LL, a2);
func2(21);
v3 = func17(21LL, a2);
func2(36);
return poke_function((unsigned int)v2, (unsigned int)v3);
}

original_code:
static void
poke_statement(void)
{
  char poke_addr;
  char value;
  accept(TOKENIZER_POKE);
  poke_addr = expr();
  accept(TOKENIZER_COMMA);
  value = expr();
  accept(TOKENIZER_CR);
  poke_function(poke_addr, value);
}

canonical_original_code:
static void poke_statement()
{
  char poke_addr;
  char value;
  accept(TOKENIZER_POKE);
  poke_addr = expr();
  accept(TOKENIZER_COMMA);
  value = expr();
  accept(TOKENIZER_CR);
  poke_function(poke_addr, value);
}

variable_types: value char


decompiled_code:
__int64 __fastcall let_statement(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
char v3; // al

v2 = tokenizer_variable_num();
accept(4);
accept(35);
v3 = expr(35LL, a2);
ubasic_set_variable(v2, v3);
return accept(36);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, __int64 a2)
{
unsigned int v2; // ebx
char v3; // al

v2 = tokenizer_variable_num();
func2(4);
func2(35);
v3 = func17(35LL, a2);
func12(v2, v3);
return func2(36);
}

original_code:
static void
let_statement(void)
{
  int var;
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_EQ);
  ubasic_set_variable(var, expr());
  ;
  accept(TOKENIZER_CR);
}

canonical_original_code:
static void let_statement()
{
  int var;
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  accept(TOKENIZER_EQ);
  ubasic_set_variable(var, expr());
  ;
  accept(TOKENIZER_CR);
}


decompiled_code:
__int64 next_statement()
{
unsigned int v0; // ebp
int v1; // ebx
char v3; // al

accept(12);
v0 = tokenizer_variable_num();
accept(4);
if ( for_stack_ptr <= 0 )
return accept(36);
v1 = for_stack_ptr - 1;
if ( dword_944[3 * for_stack_ptr - 3] != v0 )
return accept(36);
v3 = ubasic_get_variable(v0);
ubasic_set_variable(v0, v3 + 1);
if ( (char)ubasic_get_variable(v0) <= dword_948[3 * v1] )
return jump_linenum(for_stack[3 * v1]);
for_stack_ptr = v1;
return accept(36);
}

canonical_decompiled_code:
__int64 func24()
{
unsigned int v0; // ebp
int v1; // ebx
char v3; // al

func2(12);
v0 = tokenizer_variable_num();
func2(4);
if ( for_stack_ptr <= 0 )
return func2(36);
v1 = for_stack_ptr - 1;
if ( dword_944[3 * for_stack_ptr - 3] != v0 )
return func2(36);
v3 = func13(v0);
func12(v0, v3 + 1);
if ( (char)func13(v0) <= dword_948[3 * v1] )
return func5(for_stack[3 * v1]);
for_stack_ptr = v1;
return func2(36);
}

original_code:
static void
next_statement(void)
{
  int var;
  accept(TOKENIZER_NEXT);
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  if(for_stack_ptr > 0 &&
     var == for_stack[for_stack_ptr - 1].for_variable) {
    ubasic_set_variable(var,
                       ubasic_get_variable(var) + 1);
    if(ubasic_get_variable(var) <= for_stack[for_stack_ptr - 1].to) {
      jump_linenum(for_stack[for_stack_ptr - 1].line_after_for);
    } else {
      for_stack_ptr--;
      accept(TOKENIZER_CR);
    }
  } else {
    ;
    accept(TOKENIZER_CR);
  }
}

canonical_original_code:
static void next_statement()
{
  int var;
  accept(TOKENIZER_NEXT);
  var = tokenizer_variable_num();
  accept(TOKENIZER_VARIABLE);
  if(for_stack_ptr > 0 &&
     var == for_stack[for_stack_ptr - 1].for_variable) {
    ubasic_set_variable(var,
                       ubasic_get_variable(var) + 1);
    if(ubasic_get_variable(var) <= for_stack[for_stack_ptr - 1].to) {
      jump_linenum(for_stack[for_stack_ptr - 1].line_after_for);
    } else {
      for_stack_ptr--;
      accept(TOKENIZER_CR);
    }
  } else {
    ;
    accept(TOKENIZER_CR);
  }
}


statement

decompiled_code:
void __fastcall statement(__int64 a1, __int64 a2, __int64 a3)
{
switch ( (unsigned int)tokenizer_token(a1, a2, a3) )
{
case 4u:
goto LABEL_13;
case 5u:
a1 = 5LL;
accept(5);
LABEL_13:
let_statement(a1, a2);
break;
case 6u:
print_statement(a1, a2);
break;
case 7u:
if_statement();
break;
case 0xAu:
for_statement(a1, a2);
break;
case 0xCu:
next_statement();
break;
case 0xDu:
goto_statement();
break;
case 0xEu:
gosub_statement();
break;
case 0xFu:
return_statement();
break;
case 0x12u:
peek_statement(a1, a2);
break;
case 0x13u:
poke_statement(a1, a2);
break;
case 0x14u:
end_statement();
break;
default:
exit(1);
}
}

canonical_decompiled_code:
void __fastcall func25(__int64 a1, __int64 a2, __int64 a3)
{
switch ( (unsigned int)tokenizer_token(a1, a2, a3) )
{
case 4u:
goto LABEL_13;
case 5u:
a1 = 5LL;
func2(5);
LABEL_13:
func23(a1, a2);
break;
case 6u:
func18(a1, a2);
break;
case 7u:
func28();
break;
case 0xAu:
func20(a1, a2);
break;
case 0xCu:
func24();
break;
case 0xDu:
func6();
break;
case 0xEu:
func7();
break;
case 0xFu:
func8();
break;
case 0x12u:
func21(a1, a2);
break;
case 0x13u:
func22(a1, a2);
break;
case 0x14u:
func3();
break;
default:
exit(1);
}
}

original_code:
static void
statement(void)
{
  int token;
  token = tokenizer_token();
  switch(token) {
  case TOKENIZER_PRINT:
    print_statement();
    break;
  case TOKENIZER_IF:
    if_statement();
    break;
  case TOKENIZER_GOTO:
    goto_statement();
    break;
  case TOKENIZER_GOSUB:
    gosub_statement();
    break;
  case TOKENIZER_RETURN:
    return_statement();
    break;
  case TOKENIZER_FOR:
    for_statement();
    break;
  case TOKENIZER_PEEK:
    peek_statement();
    break;
  case TOKENIZER_POKE:
    poke_statement();
    break;
  case TOKENIZER_NEXT:
    next_statement();
    break;
  case TOKENIZER_END:
    end_statement();
    break;
  case TOKENIZER_LET:
    accept(TOKENIZER_LET);
  case TOKENIZER_VARIABLE:
    let_statement();
    break;
  default:
    ;
    exit(1);
  }
}

canonical_original_code:
static void statement()
{
  int token;
  token = tokenizer_token();
  switch(token) {
  case TOKENIZER_PRINT:
    print_statement();
    break;
  case TOKENIZER_IF:
    if_statement();
    break;
  case TOKENIZER_GOTO:
    goto_statement();
    break;
  case TOKENIZER_GOSUB:
    gosub_statement();
    break;
  case TOKENIZER_RETURN:
    return_statement();
    break;
  case TOKENIZER_FOR:
    for_statement();
    break;
  case TOKENIZER_PEEK:
    peek_statement();
    break;
  case TOKENIZER_POKE:
    poke_statement();
    break;
  case TOKENIZER_NEXT:
    next_statement();
    break;
  case TOKENIZER_END:
    end_statement();
    break;
  case TOKENIZER_LET:
    accept(TOKENIZER_LET);
  case TOKENIZER_VARIABLE:
    let_statement();
    break;
  default:
    ;
    exit(1);
  }
}

variable_types: token int


decompiled_code:
void line_statement()
{
__int64 v0; // rbx
char v1; // al
__int64 v2; // rdx

v0 = tokenizer_pos();
v1 = tokenizer_num();
index_add(v1, v0);
accept(2);
statement(2LL, v0, v2);
}

canonical_decompiled_code:
void func26()
{
__int64 v0; // rbx
char v1; // al
__int64 v2; // rdx

v0 = tokenizer_pos();
v1 = tokenizer_num();
index_add(v1, v0);
func2(2);
func25(2LL, v0, v2);
}

original_code:
static void
line_statement(void)
{
  ;
  index_add(tokenizer_num(), tokenizer_pos());
  accept(TOKENIZER_NUMBER);
  statement();
  return;
}

canonical_original_code:
static void line_statement()
{
  ;
  index_add(tokenizer_num(), tokenizer_pos());
  accept(TOKENIZER_NUMBER);
  statement();
  return;
}


decompiled_code:
void ubasic_run()
{
if ( !(unsigned int)tokenizer_finished() )
line_statement();
}

canonical_decompiled_code:
void func27()
{
if ( !(unsigned int)tokenizer_finished() )
func26();
}

original_code:
void
ubasic_run(void)
{
  if(tokenizer_finished()) {
    ;
    return;
  }
  line_statement();
}

canonical_original_code:
void ubasic_run()
{
  if(tokenizer_finished()) {
    ;
    return;
  }
  line_statement();
}


decompiled_code:
void __fastcall if_statement(__int64 a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx

accept(7);
v2 = relation(7LL, a2);
accept(8);
if ( v2 )
{
statement(8LL, a2, v3);
}
else
{
do
tokenizer_next();
while ( (unsigned int)tokenizer_token(8LL, a2, v4) != 9
&& (unsigned int)tokenizer_token(8LL, a2, v5) != 36
&& (unsigned int)tokenizer_token(8LL, a2, v5) != 1 );
if ( (unsigned int)tokenizer_token(8LL, a2, v5) == 9 )
{
tokenizer_next();
statement(8LL, a2, v7);
}
else if ( (unsigned int)tokenizer_token(8LL, a2, v6) == 36 )
{
tokenizer_next();
}
}
}

canonical_decompiled_code:
void __fastcall func28(__int64 a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rdx

func2(7);
v2 = func19(7LL, a2);
func2(8);
if ( v2 )
{
func25(8LL, a2, v3);
}
else
{
do
tokenizer_next();
while ( (unsigned int)tokenizer_token(8LL, a2, v4) != 9
&& (unsigned int)tokenizer_token(8LL, a2, v5) != 36
&& (unsigned int)tokenizer_token(8LL, a2, v5) != 1 );
if ( (unsigned int)tokenizer_token(8LL, a2, v5) == 9 )
{
tokenizer_next();
func25(8LL, a2, v7);
}
else if ( (unsigned int)tokenizer_token(8LL, a2, v6) == 36 )
{
tokenizer_next();
}
}
}

original_code:
static void
if_statement(void)
{
  int r;
  accept(TOKENIZER_IF);
  r = relation();
  ;
  accept(TOKENIZER_THEN);
  if(r) {
    statement();
  } else {
    do {
      tokenizer_next();
    } while(tokenizer_token() != TOKENIZER_ELSE &&
        tokenizer_token() != TOKENIZER_CR &&
        tokenizer_token() != TOKENIZER_ENDOFINPUT);
    if(tokenizer_token() == TOKENIZER_ELSE) {
      tokenizer_next();
      statement();
    } else if(tokenizer_token() == TOKENIZER_CR) {
      tokenizer_next();
    }
  }
}

canonical_original_code:
static void if_statement()
{
  int r;
  accept(TOKENIZER_IF);
  r = relation();
  ;
  accept(TOKENIZER_THEN);
  if(r) {
    statement();
  } else {
    do {
      tokenizer_next();
    } while(tokenizer_token() != TOKENIZER_ELSE &&
        tokenizer_token() != TOKENIZER_CR &&
        tokenizer_token() != TOKENIZER_ENDOFINPUT);
    if(tokenizer_token() == TOKENIZER_ELSE) {
      tokenizer_next();
      statement();
    } else if(tokenizer_token() == TOKENIZER_CR) {
      tokenizer_next();
    }
  }
}


singlechar

decompiled_code:
__int64 singlechar()
{
char v0; // al
bool v1; // zf
__int64 result; // rax

v0 = *ptr;
if ( *ptr == 10 )
return 36LL;
switch ( v0 )
{
case ',':
return 21LL;
case ';':
return 22LL;
case '+':
return 23LL;
case '-':
return 24LL;
case '&':
return 25LL;
case '|':
return 26LL;
case '*':
return 27LL;
case '/':
return 28LL;
case '%':
return 29LL;
case '(':
return 31LL;
case '#':
return 30LL;
case ')':
return 32LL;
case '<':
return 33LL;
case '>':
return 34LL;
}
v1 = v0 == 61;
result = 0LL;
if ( v1 )
result = 35LL;
return result;
}

canonical_decompiled_code:
__int64 func0()
{
char v0; // al
bool v1; // zf
__int64 result; // rax

v0 = *ptr;
if ( *ptr == 10 )
return 36LL;
switch ( v0 )
{
case ',':
return 21LL;
case ';':
return 22LL;
case '+':
return 23LL;
case '-':
return 24LL;
case '&':
return 25LL;
case '|':
return 26LL;
case '*':
return 27LL;
case '/':
return 28LL;
case '%':
return 29LL;
case '(':
return 31LL;
case '#':
return 30LL;
case ')':
return 32LL;
case '<':
return 33LL;
case '>':
return 34LL;
}
v1 = v0 == 61;
result = 0LL;
if ( v1 )
result = 35LL;
return result;
}

original_code:
static int
singlechar(void)
{
  if(*ptr == '\n') {
    return TOKENIZER_CR;
  } else if(*ptr == ',') {
    return TOKENIZER_COMMA;
  } else if(*ptr == ';') {
    return TOKENIZER_SEMICOLON;
  } else if(*ptr == '+') {
    return TOKENIZER_PLUS;
  } else if(*ptr == '-') {
    return TOKENIZER_MINUS;
  } else if(*ptr == '&') {
    return TOKENIZER_AND;
  } else if(*ptr == '|') {
    return TOKENIZER_OR;
  } else if(*ptr == '*') {
    return TOKENIZER_ASTR;
  } else if(*ptr == '/') {
    return TOKENIZER_SLASH;
  } else if(*ptr == '%') {
    return TOKENIZER_MOD;
  } else if(*ptr == '(') {
    return TOKENIZER_LEFTPAREN;
  } else if(*ptr == '#') {
    return TOKENIZER_HASH;
  } else if(*ptr == ')') {
    return TOKENIZER_RIGHTPAREN;
  } else if(*ptr == '<') {
    return TOKENIZER_LT;
  } else if(*ptr == '>') {
    return TOKENIZER_GT;
  } else if(*ptr == '=') {
    return TOKENIZER_EQ;
  }
  return 0;
}

canonical_original_code:
static int singlechar()
{
  if(*ptr == '\n') {
    return TOKENIZER_CR;
  } else if(*ptr == ',') {
    return TOKENIZER_COMMA;
  } else if(*ptr == ';') {
    return TOKENIZER_SEMICOLON;
  } else if(*ptr == '+') {
    return TOKENIZER_PLUS;
  } else if(*ptr == '-') {
    return TOKENIZER_MINUS;
  } else if(*ptr == '&') {
    return TOKENIZER_AND;
  } else if(*ptr == '|') {
    return TOKENIZER_OR;
  } else if(*ptr == '*') {
    return TOKENIZER_ASTR;
  } else if(*ptr == '/') {
    return TOKENIZER_SLASH;
  } else if(*ptr == '%') {
    return TOKENIZER_MOD;
  } else if(*ptr == '(') {
    return TOKENIZER_LEFTPAREN;
  } else if(*ptr == '#') {
    return TOKENIZER_HASH;
  } else if(*ptr == ')') {
    return TOKENIZER_RIGHTPAREN;
  } else if(*ptr == '<') {
    return TOKENIZER_LT;
  } else if(*ptr == '>') {
    return TOKENIZER_GT;
  } else if(*ptr == '=') {
    return TOKENIZER_EQ;
  }
  return 0;
}


original_code:
static int
get_next_token(void)
{
  struct keyword_token const *kt;
  int i;
  ;
  if(*ptr == 0) {
    return TOKENIZER_ENDOFINPUT;
  }
  if(((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short int) _ISdigit)) {
    for(i = 0; i < 6; ++i) {
      if(!((*__ctype_b_loc ())[(int) ((ptr[i]))] & (unsigned short int) _ISdigit)) {
        if(i > 0) {
          nextptr = ptr + i;
          return TOKENIZER_NUMBER;
        } else {
          ;
          return TOKENIZER_ERROR;
        }
      }
      if(!((*__ctype_b_loc ())[(int) ((ptr[i]))] & (unsigned short int) _ISdigit)) {
        ;
        return TOKENIZER_ERROR;
      }
    }
    ;
    return TOKENIZER_ERROR;
  } else if(singlechar()) {
    nextptr = ptr + 1;
    return singlechar();
  } else if(*ptr == '"') {
    nextptr = ptr;
    do {
      ++nextptr;
    } while(*nextptr != '"');
    ++nextptr;
    return TOKENIZER_STRING;
  } else {
    for(kt = keywords; kt->keyword != ((void *)0); ++kt) {
      if(strncmp(ptr, kt->keyword, strlen(kt->keyword)) == 0) {
        nextptr = ptr + strlen(kt->keyword);
        return kt->token;
      }
    }
  }
  if(*ptr >= 'a' && *ptr <= 'z') {
    nextptr = ptr + 1;
    return TOKENIZER_VARIABLE;
  }
  return TOKENIZER_ERROR;
}

canonical_original_code:
static int get_next_token()
{
  struct keyword_token *kt;
  int i;
  ;
  if(*ptr == 0) {
    return TOKENIZER_ENDOFINPUT;
  }
  if(((*__ctype_b_loc ())[(int) ((*ptr))] & (unsigned short) _ISdigit)) {
    for(i = 0; i < 6; ++i) {
      if(!((*__ctype_b_loc ())[(int) ((ptr[i]))] & (unsigned short) _ISdigit)) {
        if(i > 0) {
          nextptr = ptr + i;
          return TOKENIZER_NUMBER;
        } else {
          ;
          return TOKENIZER_ERROR;
        }
      }
      if(!((*__ctype_b_loc ())[(int) ((ptr[i]))] & (unsigned short) _ISdigit)) {
        ;
        return TOKENIZER_ERROR;
      }
    }
    ;
    return TOKENIZER_ERROR;
  } else if(singlechar()) {
    nextptr = ptr + 1;
    return singlechar();
  } else if(*ptr == '"') {
    nextptr = ptr;
    do {
      ++nextptr;
    } while(*nextptr != '"');
    ++nextptr;
    return TOKENIZER_STRING;
  } else {
    for(kt = keywords; kt->keyword != ((void *)0); ++kt) {
      if(strncmp(ptr, kt->keyword, strlen(kt->keyword)) == 0) {
        nextptr = ptr + strlen(kt->keyword);
        return kt->token;
      }
    }
  }
  if(*ptr >= 'a' && *ptr <= 'z') {
    nextptr = ptr + 1;
    return TOKENIZER_VARIABLE;
  }
  return TOKENIZER_ERROR;
}

variable_types: struct keyword_token { char *keyword; int token; } *

variable_types: i int


decompiled_code:
__int64 __fastcall tokenizer_goto(char *a1)
{
__int64 result; // rax

ptr = a1;
result = get_next_token();
current_token = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *a1)
{
__int64 result; // rax

ptr = a1;
result = func1();
current_token = result;
return result;
}

original_code:
void
tokenizer_goto(const char *program)
{
  ptr = program;
  current_token = get_next_token();
}

canonical_original_code:
void tokenizer_goto(char *program)
{
  ptr = program;
  current_token = get_next_token();
}

variable_types:
program
char *


decompiled_code:
__int64 __fastcall tokenizer_init(char *a1)
{
__int64 result; // rax

tokenizer_goto(a1);
result = get_next_token();
current_token = result;
return result;
}

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

func2(a1);
result = func1();
current_token = result;
return result;
}

original_code:
void
tokenizer_init(const char *program)
{
  tokenizer_goto(program);
  current_token = get_next_token();
}

canonical_original_code:
void tokenizer_init(char *program)
{
  tokenizer_goto(program);
  current_token = get_next_token();
}


decompiled_code:
__int64 tokenizer_token()
{
return (unsigned int)current_token;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)current_token;
}

original_code:
int
tokenizer_token(void)
{
  return current_token;
}

canonical_original_code:
int tokenizer_token()
{
  return current_token;
}


decompiled_code:
int tokenizer_num()
{
return atoi(ptr);
}

canonical_decompiled_code:
int func5()
{
return atoi(ptr);
}

original_code:
char
tokenizer_num(void)
{
  return atoi(ptr);
}

canonical_original_code:
char tokenizer_num()
{
  return atoi(ptr);
}


decompiled_code:
void *__fastcall tokenizer_string(void *dest, int a2)
{
void *result; // rax
int v3; // er13
char *v4; // r12
int v5; // eax
__int64 v6; // rbx

result = (void *)tokenizer_token();
if ( (_DWORD)result == 3 )
{
v3 = (int)ptr;
v4 = ptr + 1;
result = strchr(ptr + 1, 34);
if ( result )
{
v5 = (_DWORD)result - v3 - 1;
if ( v5 > a2 )
v5 = a2;
v6 = v5;
result = memcpy(dest, v4, v5);
*((_BYTE *)dest + v6) = 0;
}
}
return result;
}

canonical_decompiled_code:
void *__fastcall func6(void *dest, int a2)
{
void *result; // rax
int v3; // er13
char *v4; // r12
int v5; // eax
__int64 v6; // rbx

result = (void *)func4();
if ( (_DWORD)result == 3 )
{
v3 = (int)ptr;
v4 = ptr + 1;
result = strchr(ptr + 1, 34);
if ( result )
{
v5 = (_DWORD)result - v3 - 1;
if ( v5 > a2 )
v5 = a2;
v6 = v5;
result = memcpy(dest, v4, v5);
*((_BYTE *)dest + v6) = 0;
}
}
return result;
}

original_code:
void
tokenizer_string(char *dest, int len)
{
  char *string_end;
  int string_len;
  if(tokenizer_token() != TOKENIZER_STRING) {
    return;
  }
  string_end = strchr(ptr + 1, '"');
  if(string_end == ((void *)0)) {
    return;
  }
  string_len = string_end - ptr - 1;
  if(len < string_len) {
    string_len = len;
  }
  memcpy(dest, ptr + 1, string_len);
  dest[string_len] = 0;
}

variable_types:
dest
char *

variable_types: len int


decompiled_code:
void tokenizer_error_print()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void
tokenizer_error_print(void)
{
  ;
}

canonical_original_code:
void tokenizer_error_print()
{
  ;
}


decompiled_code:
_BOOL8 tokenizer_finished()
{
_BOOL8 result; // rax

result = 1LL;
if ( *ptr )
result = current_token == 1;
return result;
}

canonical_decompiled_code:
_BOOL8 func8()
{
_BOOL8 result; // rax

result = 1LL;
if ( *ptr )
result = current_token == 1;
return result;
}

original_code:
int
tokenizer_finished(void)
{
  return *ptr == 0 || current_token == TOKENIZER_ENDOFINPUT;
}

canonical_original_code:
int tokenizer_finished()
{
  return *ptr == 0 || current_token == TOKENIZER_ENDOFINPUT;
}


decompiled_code:
__int64 tokenizer_next()
{
__int64 result; // rax
__int64 v1; // rax
char *v2; // rdx
_BYTE *v3; // rbx

result = tokenizer_finished();
if ( !(_DWORD)result )
{
ptr = (char *)nextptr;
if ( *(_BYTE *)nextptr == 32 )
{
v1 = nextptr + 1;
do
v2 = (char *)v1++;
while ( *(_BYTE *)(v1 - 1) == 32 );
ptr = v2;
}
result = get_next_token();
current_token = result;
if ( (_DWORD)result == 17 )
{
v3 = (_BYTE *)nextptr;
if ( *(_BYTE *)nextptr == 10 )
{
LABEL_11:
nextptr = (__int64)(v3 + 1);
}
else
{
while ( !tokenizer_finished() )
{
nextptr = (__int64)++v3;
if ( *v3 == 10 )
goto LABEL_11;
}
}
result = tokenizer_next();
}
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 result; // rax
__int64 v1; // rax
char *v2; // rdx
_BYTE *v3; // rbx

result = func8();
if ( !(_DWORD)result )
{
ptr = (char *)nextptr;
if ( *(_BYTE *)nextptr == 32 )
{
v1 = nextptr + 1;
do
v2 = (char *)v1++;
while ( *(_BYTE *)(v1 - 1) == 32 );
ptr = v2;
}
result = func1();
current_token = result;
if ( (_DWORD)result == 17 )
{
v3 = (_BYTE *)nextptr;
if ( *(_BYTE *)nextptr == 10 )
{
LABEL_11:
nextptr = (__int64)(v3 + 1);
}
else
{
while ( !func8() )
{
nextptr = (__int64)++v3;
if ( *v3 == 10 )
goto LABEL_11;
}
}
result = func9();
}
}
return result;
}

original_code:
void
tokenizer_next(void)
{
  if(tokenizer_finished()) {
    return;
  }
  ;
  ptr = nextptr;
  while(*ptr == ' ') {
    ++ptr;
  }
  current_token = get_next_token();
  if(current_token == TOKENIZER_REM) {
      while(!(*nextptr == '\n' || tokenizer_finished())) {
        ++nextptr;
      }
      if(*nextptr == '\n') {
        ++nextptr;
      }
      tokenizer_next();
  }
  ;
  return;
}

canonical_original_code:
void tokenizer_next()
{
  if(tokenizer_finished()) {
    return;
  }
  ;
  ptr = nextptr;
  while(*ptr == ' ') {
    ++ptr;
  }
  current_token = get_next_token();
  if(current_token == TOKENIZER_REM) {
      while(!(*nextptr == '\n' || tokenizer_finished())) {
        ++nextptr;
      }
      if(*nextptr == '\n') {
        ++nextptr;
      }
      tokenizer_next();
  }
  ;
  return;
}


decompiled_code:
__int64 tokenizer_variable_num()
{
return (unsigned int)(*ptr - 97);
}

canonical_decompiled_code:
__int64 func10()
{
return (unsigned int)(*ptr - 97);
}

original_code:
int
tokenizer_variable_num(void)
{
  return *ptr - 'a';
}

canonical_original_code:
int tokenizer_variable_num()
{
  return *ptr - 'a';
}


decompiled_code:
char *tokenizer_pos()
{
return ptr;
}

canonical_decompiled_code:
char *func11()
{
return ptr;
}

original_code:
char const *
tokenizer_pos(void)
{
    return ptr;
}

canonical_original_code:
char *tokenizer_pos()
{
    return ptr;
}

return_type: char *


peek

decompiled_code:
__int64 __fastcall peek(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return a1;
}

original_code:
char peek(char arg) {
    return arg;
}

canonical_original_code:
char peek(char arg) {
    return arg;
}

variable_types: arg char


poke

decompiled_code:
void __fastcall poke(char a1, char a2)
{
if ( a1 != a2 )
_assert_fail("arg == value", "tests.c", 0x55u, "poke");
}

canonical_decompiled_code:
void __fastcall func1(char a1, char a2)
{
if ( a1 != a2 )
_assert_fail("arg == value", "tests.c", 0x55u, "poke");
}

original_code:
void poke(char arg, char value) {
    ((void) sizeof ((arg == value) ? 1 : 0), __extension__ ({ if (arg == value) ; else __assert_fail ("arg == value", "tests.c", 85, __extension__ __PRETTY_FUNCTION__); }));
}


run

decompiled_code:
int __fastcall run(__int64 a1)
{
int v1; // ebx
int v2; // eax

printf("Running test #%u... ", (unsigned int)++test_num_1);
fflush(stdout);
v1 = clock();
ubasic_init_peek_poke(a1, peek, poke);
do
ubasic_run();
while ( !(unsigned int)ubasic_finished() );
v2 = clock();
return printf("done. Run time: %.3f s\n", (double)(v2 - v1) / 1000000.0);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
int v1; // ebx
int v2; // eax

printf("Running test #%u... ", (unsigned int)++test_num_1);
fflush(stdout);
v1 = clock();
ubasic_init_peek_poke(a1, peek, poke);
do
ubasic_run();
while ( !(unsigned int)ubasic_finished() );
v2 = clock();
return printf("done. Run time: %.3f s\n", (double)(v2 - v1) / 1000000.0);
}

original_code:
void run(const char program[]) {
  static int test_num = 0;
  test_num++;
  printf("Running test #%u... ", test_num);
  fflush(stdout);
  clock_t start_t, end_t;
  double delta_t;
  start_t = clock();
  ubasic_init_peek_poke(program, &peek, &poke);
  do {
    ubasic_run();
  } while(!ubasic_finished());
  end_t = clock();
  delta_t = (double)(end_t - start_t) / ((__clock_t) 1000000);
  printf("done. Run time: %.3f s\n", delta_t);
}

canonical_original_code:
void run(char program[]) {
  static int test_num = 0;
  test_num++;
  printf("Running test #%u... ", test_num);
  fflush(stdout);
  long start_t; long end_t;
  double delta_t;
  start_t = clock();
  ubasic_init_peek_poke(program, &peek, &poke);
  do {
    ubasic_run();
  } while(!ubasic_finished());
  end_t = clock();
  delta_t = (double)(end_t - start_t) / ((long) 1000000);
  printf("done. Run time: %.3f s\n", delta_t);
}

variable_types:
program
char []


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
run((__int64)"10 let a = 42\n20 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 42 )
_assert_fail("ubasic_get_variable(0) == 42", "tests.c", 0x75u, "main");
run((__int64)"10 goto 50\n20 goto 40\n30 goto 60\n40 goto 30\n50 goto 20\n60 let c = 108\n70 end\n");
if ( (unsigned __int8)ubasic_get_variable(2LL, argv) != 108 )
_assert_fail("ubasic_get_variable(2) == 108", "tests.c", 0x78u, "main");
run((__int64)"10 for i = 0 to 126\n"
"20 for j = 0 to 126\n"
"30 for k = 0 to 10\n"
"40 let a = i * j * k\n"
"rem 45 print a, i, j, k\n"
"50 next k\n"
"60 next j\n"
"70 next i\n"
"80 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 40 )
_assert_fail("ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10)", "tests.c", 0x7Bu, "main");
run((__int64)"20 let a = 1\n"
"40 let b = 1\n"
"60 for i = 0 to 8\n"
"80 let b = a + b\n"
"100 let a = b - a\n"
"rem 120 print a, b\n"
"140 next i\n"
"160 end\n");
if ( (unsigned __int8)ubasic_get_variable(1LL, argv) != 89 )
_assert_fail("ubasic_get_variable(1) == 89", "tests.c", 0x7Eu, "main");
run((__int64)"10 peek 100 + 20 + 3, a\n20 peek 123, z\n30 poke 100 - 1, 99\n40 poke 0, 0\n50 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 123 )
_assert_fail("ubasic_get_variable(0) == 123", "tests.c", 0x81u, "main");
if ( (unsigned __int8)ubasic_get_variable(25LL, argv) != 123 )
_assert_fail("ubasic_get_variable(25) == 123", "tests.c", 0x82u, "main");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func2((__int64)"10 let a = 42\n20 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 42 )
_assert_fail("ubasic_get_variable(0) == 42", "tests.c", 0x75u, "main");
func2((__int64)"10 goto 50\n20 goto 40\n30 goto 60\n40 goto 30\n50 goto 20\n60 let c = 108\n70 end\n");
if ( (unsigned __int8)ubasic_get_variable(2LL, argv) != 108 )
_assert_fail("ubasic_get_variable(2) == 108", "tests.c", 0x78u, "main");
func2((__int64)"10 for i = 0 to 126\n"
"20 for j = 0 to 126\n"
"30 for k = 0 to 10\n"
"40 let a = i * j * k\n"
"rem 45 print a, i, j, k\n"
"50 next k\n"
"60 next j\n"
"70 next i\n"
"80 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 40 )
_assert_fail("ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10)", "tests.c", 0x7Bu, "main");
func2((__int64)"20 let a = 1\n"
"40 let b = 1\n"
"60 for i = 0 to 8\n"
"80 let b = a + b\n"
"100 let a = b - a\n"
"rem 120 print a, b\n"
"140 next i\n"
"160 end\n");
if ( (unsigned __int8)ubasic_get_variable(1LL, argv) != 89 )
_assert_fail("ubasic_get_variable(1) == 89", "tests.c", 0x7Eu, "main");
func2((__int64)"10 peek 100 + 20 + 3, a\n20 peek 123, z\n30 poke 100 - 1, 99\n40 poke 0, 0\n50 end\n");
if ( (unsigned __int8)ubasic_get_variable(0LL, argv) != 123 )
_assert_fail("ubasic_get_variable(0) == 123", "tests.c", 0x81u, "main");
if ( (unsigned __int8)ubasic_get_variable(25LL, argv) != 123 )
_assert_fail("ubasic_get_variable(25) == 123", "tests.c", 0x82u, "main");
return 0;
}

original_code:
int
main(void)
{
  run(program_let);
  ((void) sizeof ((ubasic_get_variable(0) == 42) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == 42) ; else __assert_fail ("ubasic_get_variable(0) == 42", "tests.c", 117, __extension__ __PRETTY_FUNCTION__); }));
  run(program_goto);
  ((void) sizeof ((ubasic_get_variable(2) == 108) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(2) == 108) ; else __assert_fail ("ubasic_get_variable(2) == 108", "tests.c", 120, __extension__ __PRETTY_FUNCTION__); }));
  run(program_loop);
  ((void) sizeof ((ubasic_get_variable(0) == (char)(126 * 126 * 10)) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == (char)(126 * 126 * 10)) ; else __assert_fail ("ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10)", "tests.c", 123, __extension__ __PRETTY_FUNCTION__); }));
  run(program_fibs);
  ((void) sizeof ((ubasic_get_variable(1) == 89) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(1) == 89) ; else __assert_fail ("ubasic_get_variable(1) == 89", "tests.c", 126, __extension__ __PRETTY_FUNCTION__); }));
  run(program_peek_poke);
  ((void) sizeof ((ubasic_get_variable(0) == 123) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == 123) ; else __assert_fail ("ubasic_get_variable(0) == 123", "tests.c", 129, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ubasic_get_variable(25) == 123) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(25) == 123) ; else __assert_fail ("ubasic_get_variable(25) == 123", "tests.c", 130, __extension__ __PRETTY_FUNCTION__); }));
  return 0;
}

canonical_original_code:
int main()
{
  run(program_let);
  ((void) sizeof ((ubasic_get_variable(0) == 42) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == 42) ; else __assert_fail ("ubasic_get_variable(0) == 42", "tests.c", 117, __extension__ __PRETTY_FUNCTION__); }));
  run(program_goto);
  ((void) sizeof ((ubasic_get_variable(2) == 108) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(2) == 108) ; else __assert_fail ("ubasic_get_variable(2) == 108", "tests.c", 120, __extension__ __PRETTY_FUNCTION__); }));
  run(program_loop);
  ((void) sizeof ((ubasic_get_variable(0) == (char)(126 * 126 * 10)) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == (char)(126 * 126 * 10)) ; else __assert_fail ("ubasic_get_variable(0) == (VARIABLE_TYPE)(126 * 126 * 10)", "tests.c", 123, __extension__ __PRETTY_FUNCTION__); }));
  run(program_fibs);
  ((void) sizeof ((ubasic_get_variable(1) == 89) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(1) == 89) ; else __assert_fail ("ubasic_get_variable(1) == 89", "tests.c", 126, __extension__ __PRETTY_FUNCTION__); }));
  run(program_peek_poke);
  ((void) sizeof ((ubasic_get_variable(0) == 123) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(0) == 123) ; else __assert_fail ("ubasic_get_variable(0) == 123", "tests.c", 129, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((ubasic_get_variable(25) == 123) ? 1 : 0), __extension__ ({ if (ubasic_get_variable(25) == 123) ; else __assert_fail ("ubasic_get_variable(25) == 123", "tests.c", 130, __extension__ __PRETTY_FUNCTION__); }));
  return 0;
}


decompiled_code:
__int64 __fastcall get_token_symbol(int a1)
{
return (__int64)*(&token_symbols + a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (__int64)*(&token_symbols + a1);
}

original_code:
const char *get_token_symbol(token_type t) {
  return token_symbols[(int)t];
}

canonical_original_code:
char *get_token_symbol(enum token_type t) {
  return token_symbols[(int)t];
}

variable_types: enum token_type { nulsym=1, identsym=2, numbersym=3, plussym=4, minussym=5, multsym=6, slashsym=7, oddsym=8, eqsym=9, neqsym=10, lessym=11, leqsym=12, gtrsym=13, geqsym=14, lparentsym=15, rparentsym=16, commasym=17, semicolonsym=18, periodsym=19, becomessym=20, beginsym=21, endsym=22, ifsym=23, thensym=24, whilesym=25, dosym=26, callsym=27, constsym=28, intsym=29, procsym=30, outsym=31, insym=32, elsesym=33 }


decompiled_code:
__int64 __fastcall get_reserved_word_sym(const char *a1)
{
unsigned int v1; // ecx

v1 = 21;
if ( strcmp(a1, "begin") )
{
v1 = 22;
if ( strcmp(a1, "end") )
{
v1 = 23;
if ( strcmp(a1, "if") )
{
v1 = 24;
if ( strcmp(a1, "then") )
{
v1 = 25;
if ( strcmp(a1, "while") )
{
v1 = 26;
if ( strcmp(a1, "do") )
{
v1 = 27;
if ( strcmp(a1, "call") )
{
v1 = 28;
if ( strcmp(a1, "const") )
{
v1 = 29;
if ( strcmp(a1, "int") )
{
v1 = 30;
if ( strcmp(a1, "procedure") )
{
v1 = 31;
if ( strcmp(a1, "out") )
{
v1 = 32;
if ( strcmp(a1, "in") )
{
v1 = 33;
if ( strcmp(a1, "else") )
v1 = strcmp(a1, "odd") == 0 ? 8 : 2;
}
}
}
}
}
}
}
}
}
}
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
unsigned int v1; // ecx

v1 = 21;
if ( strcmp(a1, "begin") )
{
v1 = 22;
if ( strcmp(a1, "end") )
{
v1 = 23;
if ( strcmp(a1, "if") )
{
v1 = 24;
if ( strcmp(a1, "then") )
{
v1 = 25;
if ( strcmp(a1, "while") )
{
v1 = 26;
if ( strcmp(a1, "do") )
{
v1 = 27;
if ( strcmp(a1, "call") )
{
v1 = 28;
if ( strcmp(a1, "const") )
{
v1 = 29;
if ( strcmp(a1, "int") )
{
v1 = 30;
if ( strcmp(a1, "procedure") )
{
v1 = 31;
if ( strcmp(a1, "out") )
{
v1 = 32;
if ( strcmp(a1, "in") )
{
v1 = 33;
if ( strcmp(a1, "else") )
v1 = strcmp(a1, "odd") == 0 ? 8 : 2;
}
}
}
}
}
}
}
}
}
}
}
}
return v1;
}

canonical_original_code:
enum token_type get_reserved_word_sym(char *str) {
  if(strcmp(str, "begin")==0) {
    return beginsym;
  } else if(strcmp(str, "end")==0) {
    return endsym;
  } else if(strcmp(str, "if")==0) {
    return ifsym;
  } else if(strcmp(str, "then")==0) {
    return thensym;
  } else if(strcmp(str, "while")==0) {
    return whilesym;
  } else if(strcmp(str, "do")==0) {
    return dosym;
  } else if(strcmp(str, "call")==0) {
    return callsym;
  } else if(strcmp(str, "const")==0) {
    return constsym;
  } else if(strcmp(str, "int")==0) {
    return intsym;
  } else if(strcmp(str, "procedure")==0) {
    return procsym;
  } else if(strcmp(str, "out")==0) {
    return outsym;
  } else if(strcmp(str, "in")==0) {
    return insym;
  } else if(strcmp(str, "else")==0) {
    return elsesym;
  } else if(strcmp(str, "odd")==0) {
    return oddsym;
  } else {
    return identsym;
  }
}

variable_types:
str
char *

return_type: enum token_type { nulsym=1, identsym=2, numbersym=3, plussym=4, minussym=5, multsym=6, slashsym=7, oddsym=8, eqsym=9, neqsym=10, lessym=11, leqsym=12, gtrsym=13, geqsym=14, lparentsym=15, rparentsym=16, commasym=17, semicolonsym=18, periodsym=19, becomessym=20, beginsym=21, endsym=22, ifsym=23, thensym=24, whilesym=25, dosym=26, callsym=27, constsym=28, intsym=29, procsym=30, outsym=31, insym=32, elsesym=33 }


original_code:
token_type get_special_symbol_sym (char *str) {
  if(strcmp(str, "+")==0) {
    return plussym;
  } else if(strcmp(str, "-")==0) {
    return minussym;
  } else if(strcmp(str, "*")==0) {
    return multsym;
  } else if(strcmp(str, "/")==0) {
    return slashsym;
  } else if(strcmp(str, "=")==0) {
    return eqsym;
  } else if(strcmp(str, "<>")==0) {
    return neqsym;
  } else if(strcmp(str, "<")==0) {
    return lessym;
  } else if(strcmp(str, "<=")==0) {
    return leqsym;
  } else if(strcmp(str, ">")==0) {
    return gtrsym;
  } else if(strcmp(str, ">=")==0) {
    return geqsym;
  } else if(strcmp(str, "(")==0) {
    return lparentsym;
  } else if(strcmp(str, ")")==0) {
    return rparentsym;
  } else if(strcmp(str, ",")==0) {
    return commasym;
  } else if(strcmp(str, ";")==0) {
    return semicolonsym;
  } else if(strcmp(str, ".")==0) {
    return periodsym;
  } else if(strcmp(str, ":=")==0) {
    return becomessym;
  } else {
    return nulsym;
  }
}

canonical_original_code:
enum token_type get_special_symbol_sym(char *str) {
  if(strcmp(str, "+")==0) {
    return plussym;
  } else if(strcmp(str, "-")==0) {
    return minussym;
  } else if(strcmp(str, "*")==0) {
    return multsym;
  } else if(strcmp(str, "/")==0) {
    return slashsym;
  } else if(strcmp(str, "=")==0) {
    return eqsym;
  } else if(strcmp(str, "<>")==0) {
    return neqsym;
  } else if(strcmp(str, "<")==0) {
    return lessym;
  } else if(strcmp(str, "<=")==0) {
    return leqsym;
  } else if(strcmp(str, ">")==0) {
    return gtrsym;
  } else if(strcmp(str, ">=")==0) {
    return geqsym;
  } else if(strcmp(str, "(")==0) {
    return lparentsym;
  } else if(strcmp(str, ")")==0) {
    return rparentsym;
  } else if(strcmp(str, ",")==0) {
    return commasym;
  } else if(strcmp(str, ";")==0) {
    return semicolonsym;
  } else if(strcmp(str, ".")==0) {
    return periodsym;
  } else if(strcmp(str, ":=")==0) {
    return becomessym;
  } else {
    return nulsym;
  }
}

user_defined_types: enum token_type { nulsym=1, identsym=2, numbersym=3, plussym=4, minussym=5, multsym=6, slashsym=7, oddsym=8, eqsym=9, neqsym=10, lessym=11, leqsym=12, gtrsym=13, geqsym=14, lparentsym=15, rparentsym=16, commasym=17, semicolonsym=18, periodsym=19, becomessym=20, beginsym=21, endsym=22, ifsym=23, thensym=24, whilesym=25, dosym=26, callsym=27, constsym=28, intsym=29, procsym=30, outsym=31, insym=32, elsesym=33 }


decompiled_code:
__int64 __fastcall is_reserved_word(char *s1)
{
const char **v1; // rbx

v1 = (const char **)reserved_words;
while ( strcmp(s1, *v1) )
{
if ( ++v1 == (const char **)(unsigned int)((_DWORD)reserved_words + 104) )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1)
{
const char **v1; // rbx

v1 = (const char **)reserved_words;
while ( strcmp(s1, *v1) )
{
if ( ++v1 == (const char **)(unsigned int)((_DWORD)reserved_words + 104) )
return 0LL;
}
return 1LL;
}

original_code:
int is_reserved_word(char *str) {
  int i;
  for(i = 0; i < 13; i++) {
    if(strcmp(str, reserved_words[i])==0) {
      return 1;
    }
  }
  return 0;
}


decompiled_code:
_BOOL8 __fastcall is_letter(char a1)
{
return (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(char a1)
{
return (unsigned __int8)((a1 & 0xDF) - 65) <= 0x19u;
}

original_code:
int is_letter(char c) {
  if((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
    return 1;
  return 0;
}

variable_types: c char


decompiled_code:
_BOOL8 __fastcall is_digit(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(char a1)
{
return (unsigned __int8)(a1 - 48) <= 9u;
}

original_code:
int is_digit(char c) {
  if(c >= '0' && c <= '9')
    return 1;
  return 0;
}


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

v1 = &special_symbols;
while ( *v1 != a1 )
{
if ( ++v1 == (_BYTE *)(unsigned int)((_DWORD)&special_symbols + 13) )
return 0LL;
}
return 1LL;
}

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

v1 = &special_symbols;
while ( *v1 != a1 )
{
if ( ++v1 == (_BYTE *)(unsigned int)((_DWORD)&special_symbols + 13) )
return 0LL;
}
return 1LL;
}

original_code:
int is_special_symbol(char c) {
  int i;
  for(i = 0; i < 13; i++)
    if(c == special_symbols[i]) {
      return 1;
    }
  return 0;
}


decompiled_code:
_BOOL8 __fastcall is_invisible_character(char a1)
{
switch ( a1 )
{
case 32:
return 1LL;
case 9:
return 1LL;
case 10:
return 1LL;
case 13:
return 1LL;
}
return a1 == -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(char a1)
{
switch ( a1 )
{
case 32:
return 1LL;
case 9:
return 1LL;
case 10:
return 1LL;
case 13:
return 1LL;
}
return a1 == -1;
}

original_code:
int is_invisible_character(char c) {
  int i;
  for(i = 0; i < 4; i++) {
    if(c == invisible_characters[i]) {
      return 1;
    }
  }
  if(c == (-1))
    return 1;
  return 0;
}


decompiled_code:
_BOOL8 __fastcall is_relation(int a1)
{
return (unsigned int)(a1 - 9) <= 5;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(int a1)
{
return (unsigned int)(a1 - 9) <= 5;
}

original_code:
int is_relation(token_type token) {
  switch(token) {
    case eqsym:
    case neqsym:
    case lessym:
    case leqsym:
    case gtrsym:
    case geqsym:
      return 1;
      break;
    default:
      return 0;
  }
}

canonical_original_code:
int is_relation(enum token_type token) {
  switch(token) {
    case eqsym:
    case neqsym:
    case lessym:
    case leqsym:
    case gtrsym:
    case geqsym:
      return 1;
      break;
    default:
      return 0;
  }
}


decompiled_code:
void *__fastcall add_lexeme(void *a1, const char *a2, int a3)
{
void *v3; // r12
_QWORD *v5; // rax
_QWORD *v6; // rbx
_DWORD *v7; // rbp
size_t v8; // rax
char *v9; // rax
void *v11; // rax

v3 = a1;
v5 = a1;
if ( !a1 )
{
v11 = malloc(0x18uLL);
v3 = v11;
if ( !v11 )
return v3;
v7 = v11;
goto LABEL_4;
}
do
{
v6 = v5;
v5 = (_QWORD *)v5[2];
}
while ( v5 );
v7 = malloc(0x18uLL);
v6[2] = v7;
if ( v7 )
{
LABEL_4:
v8 = strlen(a2);
v9 = (char *)malloc(v8 + 1);
*(_QWORD *)v7 = v9;
strcpy(v9, a2);
v7[2] = a3;
*((_QWORD *)v7 + 2) = 0LL;
}
return v3;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1, const char *a2, int a3)
{
void *v3; // r12
_QWORD *v5; // rax
_QWORD *v6; // rbx
_DWORD *v7; // rbp
size_t v8; // rax
char *v9; // rax
void *v11; // rax

v3 = a1;
v5 = a1;
if ( !a1 )
{
v11 = malloc(0x18uLL);
v3 = v11;
if ( !v11 )
return v3;
v7 = v11;
goto LABEL_4;
}
do
{
v6 = v5;
v5 = (_QWORD *)v5[2];
}
while ( v5 );
v7 = malloc(0x18uLL);
v6[2] = v7;
if ( v7 )
{
LABEL_4:
v8 = strlen(a2);
v9 = (char *)malloc(v8 + 1);
*(_QWORD *)v7 = v9;
strcpy(v9, a2);
v7[2] = a3;
*((_QWORD *)v7 + 2) = 0LL;
}
return v3;
}

original_code:
lexeme_list *add_lexeme(lexeme_list *lexemes, char *lex, token_type t) {
  lexeme_list *pos = lexemes;
  if(!lexemes) {
    lexemes = (lexeme_list *)malloc(sizeof(lexeme_list));
    if(!lexemes) return ((void *)0);
    pos = lexemes;
  } else {
    while(pos->next) pos = pos->next;
    pos->next = (lexeme_list *)malloc(sizeof(lexeme_list));
    if(!pos->next) {
      pos->next = ((void *)0);
      return lexemes;
    }
    pos = pos->next;
  }
  pos->lex = (char *)malloc((strlen(lex) + 1) * sizeof(char));
  strcpy(pos->lex, lex);
  pos->t = t;
  pos->next = ((void *)0);
  return lexemes;
}

canonical_original_code:
struct lexeme_list *add_lexeme(struct lexeme_list *lexemes, char *lex, enum token_type t) {
  struct lexeme_list *pos = lexemes;
  if(!lexemes) {
    lexemes = (struct lexeme_list *)malloc(sizeof(lexeme_list));
    if(!lexemes) return ((void *)0);
    pos = lexemes;
  } else {
    while(pos->next) pos = pos->next;
    pos->next = (struct lexeme_list *)malloc(sizeof(lexeme_list));
    if(!pos->next) {
      pos->next = ((void *)0);
      return lexemes;
    }
    pos = pos->next;
  }
  pos->lex = (char *)malloc((strlen(lex) + 1) * sizeof(char));
  strcpy(pos->lex, lex);
  pos->t = t;
  pos->next = ((void *)0);
  return lexemes;
}

variable_types:
lexemes
struct lexeme_list *

variable_types:
lex
char *

variable_types: struct lexeme_list { char *lex; enum token_type { nulsym=1, identsym=2, numbersym=3, plussym=4, minussym=5, multsym=6, slashsym=7, oddsym=8, eqsym=9, neqsym=10, lessym=11, leqsym=12, gtrsym=13, geqsym=14, lparentsym=15, rparentsym=16, commasym=17, semicolonsym=18, periodsym=19, becomessym=20, beginsym=21, endsym=22, ifsym=23, thensym=24, whilesym=25, dosym=26, callsym=27, constsym=28, intsym=29, procsym=30, outsym=31, insym=32, elsesym=33 } t; struct lexeme_list *next; } *

user_defined_types: struct lexeme_list { char *lex; enum token_type t; struct lexeme_list *next; }


decompiled_code:
void __fastcall destroy_lexemes(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

v1 = (void **)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (void **)v1[2];
free(*v2);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

v1 = (void **)ptr;
if ( ptr )
{
do
{
v2 = v1;
v1 = (void **)v1[2];
free(*v2);
free(v2);
}
while ( v1 );
}
}

original_code:
void destroy_lexemes(lexeme_list *lexemes) {
  lexeme_list *del;
  while(lexemes) {
    del = lexemes;
    lexemes = lexemes->next;
    free(del->lex);
    free(del);
  }
}

canonical_original_code:
void destroy_lexemes(struct lexeme_list *lexemes) {
  struct lexeme_list *del;
  while(lexemes) {
    del = lexemes;
    lexemes = lexemes->next;
    free(del->lex);
    free(del);
  }
}


decompiled_code:
int __fastcall print_lexeme_table(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

v1 = a1;
puts("Lexeme Table:");
puts("----------------------");
puts("lexeme token type");
result = puts("----------------------");
if ( a1 )
{
do
{
result = printf("%-11s %d\n", *(const char **)v1, *(unsigned int *)(v1 + 8));
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

v1 = a1;
puts("Lexeme Table:");
puts("----------------------");
puts("lexeme token type");
result = puts("----------------------");
if ( a1 )
{
do
{
result = printf("%-11s %d\n", *(const char **)v1, *(unsigned int *)(v1 + 8));
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
return result;
}

original_code:
void print_lexeme_table(lexeme_list *lexemes) {
  lexeme_list *pos = lexemes;
  printf("Lexeme Table:\n");
  printf("----------------------\n");
  printf("lexeme      token type\n");
  printf("----------------------\n");
  while(pos) {
    printf("%-11s %d\n", pos->lex, pos->t);
    pos = pos->next;
  }
}

canonical_original_code:
void print_lexeme_table(struct lexeme_list *lexemes) {
  struct lexeme_list *pos = lexemes;
  printf("Lexeme Table:\n");
  printf("----------------------\n");
  printf("lexeme      token type\n");
  printf("----------------------\n");
  while(pos) {
    printf("%-11s %d\n", pos->lex, pos->t);
    pos = pos->next;
  }
}


decompiled_code:
int __fastcall print_lexeme_list(__int64 a1)
{
__int64 v1; // rbx

v1 = a1;
puts("Lexeme List:");
puts("------------");
if ( a1 )
{
do
{
printf("%d", *(unsigned int *)(v1 + 8));
if ( (unsigned int)(*(_DWORD *)(v1 + 8) - 2) <= 1 )
{
if ( *(_QWORD *)(v1 + 16) )
putchar(32);
printf("%s", *(const char **)v1);
}
if ( !*(_QWORD *)(v1 + 16) )
break;
printf(" | ");
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
return putchar(10);
}

original_code:
void print_lexeme_list(lexeme_list *lexemes) {
  lexeme_list *pos = lexemes;
  printf("Lexeme List:\n");
  printf("------------\n");
  while(pos) {
    printf("%d", pos->t);
    if(pos->t == identsym || pos->t == numbersym) {
      if(pos->next) printf(" ");
      printf("%s", pos->lex);
    }
    if(pos->next) printf(" | ");
    pos = pos->next;
  }
  printf("\n");
}

canonical_original_code:
void print_lexeme_list(struct lexeme_list *lexemes) {
  struct lexeme_list *pos = lexemes;
  printf("Lexeme List:\n");
  printf("------------\n");
  while(pos) {
    printf("%d", pos->t);
    if(pos->t == identsym || pos->t == numbersym) {
      if(pos->next) printf(" ");
      printf("%s", pos->lex);
    }
    if(pos->next) printf(" | ");
    pos = pos->next;
  }
  printf("\n");
}


decompiled_code:
__int64 __fastcall get_lexeme_list_str(__int64 a1)
{
__int64 v1; // rbp
__int64 *v2; // rbx
__int64 v3; // rbp
char s[27]; // [rsp+Dh] [rbp-1Bh] BYREF

v1 = a1;
if ( a1 )
{
v2 = 0LL;
do
{
sprintf(s, "%d", *(unsigned int *)(v1 + 8));
v2 = (__int64 *)fancy_append(v2, s);
if ( (unsigned int)(*(_DWORD *)(v1 + 8) - 2) <= 1 )
{
if ( *(_QWORD *)(v1 + 16) )
v2 = (__int64 *)fancy_push(v2, 32LL);
v2 = (__int64 *)fancy_append(v2, *(_QWORD *)v1);
}
if ( !*(_QWORD *)(v1 + 16) )
break;
v2 = (__int64 *)fancy_push(v2, 32LL);
v1 = *(_QWORD *)(v1 + 16);
}
while ( v1 );
}
else
{
v2 = 0LL;
}
v3 = *v2;
free(v2);
return v3;
}

original_code:
char *get_lexeme_list_str(lexeme_list *lexemes) {
  lexeme_list *pos = lexemes;
  char tmp_t[3];
  fancy_string *lexeme_list_str = ((void *)0);
  while(pos) {
    sprintf(tmp_t, "%d", pos->t);
    lexeme_list_str = fancy_append(lexeme_list_str, tmp_t);
    if(pos->t == 2 || pos->t == 3) {
      if(pos->next)
        lexeme_list_str = fancy_push(lexeme_list_str, ' ');
      lexeme_list_str = fancy_append(lexeme_list_str, pos->lex);
    }
    if(pos->next) {
      lexeme_list_str = fancy_push(lexeme_list_str, ' ');
    }
    pos = pos->next;
  }
  char *return_str = lexeme_list_str->value;
  free(lexeme_list_str);
  return return_str;
}

canonical_original_code:
char *get_lexeme_list_str(struct lexeme_list *lexemes) {
  struct lexeme_list *pos = lexemes;
  char tmp_t[3];
  struct fancy_string *lexeme_list_str = ((void *)0);
  while(pos) {
    sprintf(tmp_t, "%d", pos->t);
    lexeme_list_str = fancy_append(lexeme_list_str, tmp_t);
    if(pos->t == 2 || pos->t == 3) {
      if(pos->next)
        lexeme_list_str = fancy_push(lexeme_list_str, ' ');
      lexeme_list_str = fancy_append(lexeme_list_str, pos->lex);
    }
    if(pos->next) {
      lexeme_list_str = fancy_push(lexeme_list_str, ' ');
    }
    pos = pos->next;
  }
  char *return_str = lexeme_list_str->value;
  free(lexeme_list_str);
  return return_str;
}

variable_types: struct fancy_string { char *value; unsigned int size; } *


decompiled_code:
_DWORD *fancy_initialize()
{
_DWORD *v0; // rbx
_BYTE *v1; // rax

v0 = malloc(0x10uLL);
v1 = malloc(1uLL);
*(_QWORD *)v0 = v1;
*v1 = 0;
v0[2] = 0;
return v0;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *v0; // rbx
_BYTE *v1; // rax

v0 = malloc(0x10uLL);
v1 = malloc(1uLL);
*(_QWORD *)v0 = v1;
*v1 = 0;
v0[2] = 0;
return v0;
}

original_code:
fancy_string *fancy_initialize(fancy_string *str) {
  str = (fancy_string *)malloc(sizeof(fancy_string));
  str->value = (char *)malloc(sizeof(char));
  str->value[0] = 0;
  str->size = 0;
  return str;
}

canonical_original_code:
struct fancy_string *fancy_initialize(struct fancy_string *str) {
  str = (struct fancy_string *)malloc(sizeof(fancy_string));
  str->value = (char *)malloc(sizeof(char));
  str->value[0] = 0;
  str->size = 0;
  return str;
}

variable_types:
str
struct fancy_string *

return_type: struct fancy_string { char *value; unsigned int size; } *


decompiled_code:
__int64 __fastcall fancy_pop(__int64 a1)
{
unsigned int v1; // eax
_BYTE *v2; // rax
unsigned int v3; // ebp

if ( !a1 )
return (unsigned int)-1;
v1 = *(_DWORD *)(a1 + 8) - 1;
*(_DWORD *)(a1 + 8) = v1;
v2 = (_BYTE *)(*(_QWORD *)a1 + v1);
v3 = (unsigned __int8)*v2;
*v2 = 0;
*(_QWORD *)a1 = realloc(*(void **)a1, (unsigned int)(*(_DWORD *)(a1 + 8) + 1));
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
unsigned int v1; // eax
_BYTE *v2; // rax
unsigned int v3; // ebp

if ( !a1 )
return (unsigned int)-1;
v1 = *(_DWORD *)(a1 + 8) - 1;
*(_DWORD *)(a1 + 8) = v1;
v2 = (_BYTE *)(*(_QWORD *)a1 + v1);
v3 = (unsigned __int8)*v2;
*v2 = 0;
*(_QWORD *)a1 = realloc(*(void **)a1, (unsigned int)(*(_DWORD *)(a1 + 8) + 1));
return v3;
}

original_code:
char fancy_pop(fancy_string *dst) {
  if(!dst) {
    return -1;
  }
  dst->size--;
  char c = dst->value[dst->size];
  dst->value[dst->size] = 0;
  dst->value = (char *)realloc(dst->value, (dst->size + 1) * sizeof(char));
  return c;
}

canonical_original_code:
char fancy_pop(struct fancy_string *dst) {
  if(!dst) {
    return -1;
  }
  dst->size--;
  char c = dst->value[dst->size];
  dst->value[dst->size] = 0;
  dst->value = (char *)realloc(dst->value, (dst->size + 1) * sizeof(char));
  return c;
}

user_defined_types: struct fancy_string { char *value; unsigned int size; }


decompiled_code:
void __fastcall fancy_free(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

original_code:
void fancy_free(fancy_string *str) {
  if(str) {
    free(str->value);
    free(str);
  }
}

canonical_original_code:
void fancy_free(struct fancy_string *str) {
  if(str) {
    free(str->value);
    free(str);
  }
}


decompiled_code:
void *__fastcall get_op_code_symbol(int a1)
{
void *result; // rax

switch ( a1 )
{
case 1:
result = &unk_AEC;
break;
case 2:
result = &unk_B0C;
break;
case 3:
result = &unk_AF0;
break;
case 4:
result = &unk_AF4;
break;
case 5:
result = &unk_AF8;
break;
case 6:
result = &unk_AFC;
break;
case 7:
result = &unk_B00;
break;
case 8:
result = &unk_B04;
break;
case 9:
result = &unk_B08;
break;
case 10:
result = &unk_B08;
break;
default:
result = &unk_AE8;
break;
}
return result;
}

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

switch ( a1 )
{
case 1:
result = &unk_AEC;
break;
case 2:
result = &unk_B0C;
break;
case 3:
result = &unk_AF0;
break;
case 4:
result = &unk_AF4;
break;
case 5:
result = &unk_AF8;
break;
case 6:
result = &unk_AFC;
break;
case 7:
result = &unk_B00;
break;
case 8:
result = &unk_B04;
break;
case 9:
result = &unk_B08;
break;
case 10:
result = &unk_B08;
break;
default:
result = &unk_AE8;
break;
}
return result;
}

original_code:
const char *get_op_code_symbol(int op) {
  switch(op) {
    case 1:
      return "LIT";
      break;
    case 2:
      return "OPR";
      break;
    case 3:
      return "LOD";
      break;
    case 4:
      return "STO";
      break;
    case 5:
      return "CAL";
      break;
    case 6:
      return "INC";
      break;
    case 7:
      return "JMP";
      break;
    case 8:
      return "JPC";
      break;
    case 9:
      return "SIO";
      break;
    case 10:
      return "SIO";
      break;
  }
  return "ERR";
}

variable_types: op int


decompiled_code:
const char *__fastcall get_opr_symbol(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "OPR_RET";
break;
case 1:
result = "OPR_NEG";
break;
case 2:
result = "OPR_ADD";
break;
case 3:
result = "OPR_SUB";
break;
case 4:
result = "OPR_MUL";
break;
case 5:
result = "OPR_DIV";
break;
case 6:
result = "OPR_ODD";
break;
case 7:
result = "OPR_MOD";
break;
case 8:
result = "OPR_EQL";
break;
case 9:
result = "OPR_NEQ";
break;
case 10:
result = "OPR_LSS";
break;
case 11:
result = "OPR_LEQ";
break;
case 12:
result = "OPR_GTR";
break;
case 13:
result = "OPR_GEQ";
break;
default:
result = (const char *)&unk_AE8;
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "OPR_RET";
break;
case 1:
result = "OPR_NEG";
break;
case 2:
result = "OPR_ADD";
break;
case 3:
result = "OPR_SUB";
break;
case 4:
result = "OPR_MUL";
break;
case 5:
result = "OPR_DIV";
break;
case 6:
result = "OPR_ODD";
break;
case 7:
result = "OPR_MOD";
break;
case 8:
result = "OPR_EQL";
break;
case 9:
result = "OPR_NEQ";
break;
case 10:
result = "OPR_LSS";
break;
case 11:
result = "OPR_LEQ";
break;
case 12:
result = "OPR_GTR";
break;
case 13:
result = "OPR_GEQ";
break;
default:
result = (const char *)&unk_AE8;
break;
}
return result;
}

original_code:
const char *get_opr_symbol(int op) {
  switch(op) {
    case 0:
      return "OPR_RET";
      break;
    case 1:
      return "OPR_NEG";
      break;
    case 2:
      return "OPR_ADD";
      break;
    case 3:
      return "OPR_SUB";
      break;
    case 4:
      return "OPR_MUL";
      break;
    case 5:
      return "OPR_DIV";
      break;
    case 6:
      return "OPR_ODD";
      break;
    case 7:
      return "OPR_MOD";
      break;
    case 8:
      return "OPR_EQL";
      break;
    case 9:
      return "OPR_NEQ";
      break;
    case 10:
      return "OPR_LSS";
      break;
    case 11:
      return "OPR_LEQ";
      break;
    case 12:
      return "OPR_GTR";
      break;
    case 13:
      return "OPR_GEQ";
      break;
  }
  return "ERR";
}


base

decompiled_code:
__int64 __fastcall base(__int64 a1, int a2, unsigned int a3)
{
__int64 result; // rax

result = a3;
if ( a2 > 0 )
{
do
{
result = *(unsigned int *)(a1 + 4LL * (int)result - 4);
--a2;
}
while ( a2 );
}
return result;
}

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

result = a3;
if ( a2 > 0 )
{
do
{
result = *(unsigned int *)(a1 + 4LL * (int)result - 4);
--a2;
}
while ( a2 );
}
return result;
}

original_code:
int base(int *stack, int l, int bp) {
  int base = bp;
  while(l > 0) {
    base = stack[base - 1];
    l--;
  }
  return base;
}

variable_types:
stack
int *

variable_types: l int

variable_types: bp int

variable_types: base int


decompiled_code:
int __fastcall print_stack(__int64 a1, int a2, _DWORD *a3, int a4)
{
int v5; // er15
int result; // eax
__int64 v7; // rbx
int i; // ebp
__int64 v9; // rbx
int v10; // [rsp+4h] [rbp-44h]
int v11; // [rsp+8h] [rbp-40h]

v11 = a4;
if ( !a4 )
{
if ( a2 <= 0 )
return result;
goto LABEL_18;
}
if ( a4 < 0 )
{
v10 = 0;
}
else
{
v10 = 0;
v5 = 0;
do
{
result = v10;
v7 = v10 + 1;
for ( i = 0; i < *a3; ++v7 )
{
v10 = v7;
result = printf("%2d", *(unsigned int *)(a1 + 4 * v7 - 4));
if ( ++i >= *a3 )
break;
result = putchar(32);
}
if ( v11 > v5 )
result = printf(" | ");
++v5;
++a3;
}
while ( v11 >= v5 );
}
if ( v10 < a2 )
{
putchar(32);
v11 = v10;
LABEL_18:
v9 = v11;
while ( 1 )
{
result = printf("%2d", *(unsigned int *)(a1 + 4 * v9++));
if ( a2 <= (int)v9 )
break;
putchar(32);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, int a2, _DWORD *a3, int a4)
{
int v5; // er15
int result; // eax
__int64 v7; // rbx
int i; // ebp
__int64 v9; // rbx
int v10; // [rsp+4h] [rbp-44h]
int v11; // [rsp+8h] [rbp-40h]

v11 = a4;
if ( !a4 )
{
if ( a2 <= 0 )
return result;
goto LABEL_18;
}
if ( a4 < 0 )
{
v10 = 0;
}
else
{
v10 = 0;
v5 = 0;
do
{
result = v10;
v7 = v10 + 1;
for ( i = 0; i < *a3; ++v7 )
{
v10 = v7;
result = printf("%2d", *(unsigned int *)(a1 + 4 * v7 - 4));
if ( ++i >= *a3 )
break;
result = putchar(32);
}
if ( v11 > v5 )
result = printf(" | ");
++v5;
++a3;
}
while ( v11 >= v5 );
}
if ( v10 < a2 )
{
putchar(32);
v11 = v10;
LABEL_18:
v9 = v11;
while ( 1 )
{
result = printf("%2d", *(unsigned int *)(a1 + 4 * v9++));
if ( a2 <= (int)v9 )
break;
putchar(32);
}
}
return result;
}

original_code:
void print_stack(int *stack, int sp, int *activation_records, int ar) {
  int i, j, s = 0;
  if(ar != 0) {
    for(i = 0; i <= ar; i++) {
      for(j = 0; j < activation_records[i]; j++) {
        printf("%2d", stack[s++]);
        if(j + 1 < activation_records[i])
          printf(" ");
      }
      if(i + 1 <= ar)
        printf("  | ");
    }
  }
  if(s < sp && ar != 0)
    printf(" ");
  while(s < sp) {
    printf("%2d", stack[s++]);
    if(s < sp)
      printf(" ");
  }
}

canonical_original_code:
void print_stack(int *stack, int sp, int *activation_records, int ar) {
  int i; int j; int s = 0;
  if(ar != 0) {
    for(i = 0; i <= ar; i++) {
      for(j = 0; j < activation_records[i]; j++) {
        printf("%2d", stack[s++]);
        if(j + 1 < activation_records[i])
          printf(" ");
      }
      if(i + 1 <= ar)
        printf("  | ");
    }
  }
  if(s < sp && ar != 0)
    printf(" ");
  while(s < sp) {
    printf("%2d", stack[s++]);
    if(s < sp)
      printf(" ");
  }
}

variable_types: sp int

variable_types: ar int

variable_types: i int

variable_types: j int

variable_types: s int


decompiled_code:
const char *__fastcall get_parse_error(unsigned int a1)
{
const char *result; // rax

result = "Invalid error code.";
if ( a1 <= 0x1E )
result = (&parse_errors)[a1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func3(unsigned int a1)
{
const char *result; // rax

result = "Invalid error code.";
if ( a1 <= 0x1E )
result = (&parse_errors)[a1];
return result;
}

original_code:
const char *get_parse_error(int e) {
  if(e < 0 || e > 30)
    return "Invalid error code.";
  return parse_errors[e];
}

variable_types: e int


emit

decompiled_code:
__int64 __fastcall emit(int a1, int a2, int a3)
{
int v6; // eax
unsigned int v7; // edx
__int64 v8; // r9

v6 = dword_1580;
v7 = 25;
if ( dword_1580 <= 999 )
{
v8 = 3LL * dword_1580;
code[v8] = a1;
code[v8 + 1] = a2;
code[v8 + 2] = a3;
dword_1580 = v6 + 1;
v7 = 0;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2, int a3)
{
int v6; // eax
unsigned int v7; // edx
__int64 v8; // r9

v6 = dword_1580;
v7 = 25;
if ( dword_1580 <= 999 )
{
v8 = 3LL * dword_1580;
code[v8] = a1;
code[v8 + 1] = a2;
code[v8 + 2] = a3;
dword_1580 = v6 + 1;
v7 = 0;
}
return v7;
}

original_code:
int emit(int op, int l, int m) {
  if(cx >= 1000)
    return 25;
  else {
    if(0) {
      printf("DEBUG: cx = %d, op = %d (%s), l = %d, m = %d", cx, op, get_op_code_symbol(op), l, m);
      if(op == OPR)
        printf(" (%s)", get_opr_symbol(m));
      printf("\n");
    }
    code[cx].op = op;
    code[cx].l = l;
    code[cx].m = m;
    cx++;
  }
  return 0;
}

variable_types: m int


decompiled_code:
__m128i *proc_cleanup()
{
__m128i *result; // rax
int v1; // edx

result = (__m128i *)&symbol_table;
do
{
v1 = curr_l;
if ( result[1].m128i_i32[1] == curr_l )
{
*result = _mm_loadu_si128((const __m128i *)&EMPTY_SYMBOL);
result[1].m128i_i64[0] = *((_QWORD *)&EMPTY_SYMBOL + 2);
result[1].m128i_i32[2] = *((_DWORD *)&EMPTY_SYMBOL + 6);
}
result = (__m128i *)((char *)result + 28);
}
while ( result != (__m128i *)(unsigned int)((_DWORD)&symbol_table + 2800) );
curr_l = v1 - 1;
return result;
}

canonical_decompiled_code:
__m128i *func10()
{
__m128i *result; // rax
int v1; // edx

result = (__m128i *)&symbol_table;
do
{
v1 = curr_l;
if ( result[1].m128i_i32[1] == curr_l )
{
*result = _mm_loadu_si128((const __m128i *)&EMPTY_SYMBOL);
result[1].m128i_i64[0] = *((_QWORD *)&EMPTY_SYMBOL + 2);
result[1].m128i_i32[2] = *((_DWORD *)&EMPTY_SYMBOL + 6);
}
result = (__m128i *)((char *)result + 28);
}
while ( result != (__m128i *)(unsigned int)((_DWORD)&symbol_table + 2800) );
curr_l = v1 - 1;
return result;
}

original_code:
void proc_cleanup() {
  int i;
  for(i = 0; i < 100; i++) {
    if(symbol_table[i].level == curr_l) {
      if(0) printf("Clearing symbol \"%s\" at level %d\n", symbol_table[i].name, symbol_table[i].level);
      symbol_table[i] = EMPTY_SYMBOL;
    }
  }
  curr_l--;
}


decompiled_code:
__int64 __fastcall symbol_hash(char *s1, int a2)
{
char v2; // bl
unsigned int v4; // ebp
unsigned int v5; // ebx
const char *v6; // rsi

v2 = *s1;
if ( a2 < 0 || !v2 )
return (unsigned int)-1;
v4 = abs32(403 * (v2 + s1[strlen(s1) - 1]) % 100);
v5 = v4;
while ( 1 )
{
v6 = (const char *)&symbol_table[7 * v5 + 1];
if ( !*v6 || !strcmp(s1, v6) && (symbol_table[7 * v5] == 1 || symbol_table[7 * v5 + 5] == a2) )
break;
v5 = (int)(v5 + 1) % 100;
if ( v4 == v5 )
return (unsigned int)-1;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1, int a2)
{
char v2; // bl
unsigned int v4; // ebp
unsigned int v5; // ebx
const char *v6; // rsi

v2 = *s1;
if ( a2 < 0 || !v2 )
return (unsigned int)-1;
v4 = abs32(403 * (v2 + s1[strlen(s1) - 1]) % 100);
v5 = v4;
while ( 1 )
{
v6 = (const char *)&symbol_table[7 * v5 + 1];
if ( !*v6 || !strcmp(s1, v6) && (symbol_table[7 * v5] == 1 || symbol_table[7 * v5 + 5] == a2) )
break;
v5 = (int)(v5 + 1) % 100;
if ( v4 == v5 )
return (unsigned int)-1;
}
return v5;
}

original_code:
int symbol_hash(char *value, int level) {
  int hash = -1;
  int extra = 'a' + 'd' + 'a' + 'm';
  if(strlen(value) && level >= 0) {
    hash = abs(((value[0] + value[strlen(value) - 1]) * extra) % 100);
    if(0) printf("DEBUG: initial hash: %d\n", hash);
    int tmp = hash;
    while(strlen(symbol_table[hash].name) && (strcmp(value, symbol_table[hash].name) != 0 || (symbol_table[hash].kind != 1 && symbol_table[hash].level != level))) {
      hash = (hash + 1) % 100;
      if(tmp == hash)
        return -1;
    }
  }
  if(0) printf("DEBUG: final hash: %d\n", hash);
  return hash;
}

variable_types:
value
char *

variable_types: level int

variable_types: hash int

variable_types: extra int

variable_types: tmp int


system

repo: adamel/chrome-deps

decompiled_code:
__int64 __fastcall system(char *haystack)
{
char *v1; // r12
char *v2; // rbp
__int64 (__fastcall *v3)(char *); // r13
unsigned int v4; // ebx

v1 = getenv("LD_LIBRARY_PATH");
v2 = getenv("LD_PRELOAD");
v3 = (__int64 (__fastcall *)(char *))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "system");
if ( v1 && *v1 )
snprintf(&pathsavebuf_7, 0x2000uLL, "LD_LIBRARY_PATH=%s", v1);
else
pathsavebuf_7 = 0;
if ( v2 && *v2 )
snprintf(&preloadsavebuf_6, 0x2000uLL, "LD_PRELOAD=%s", v2);
else
preloadsavebuf_6 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v4 = v3(haystack);
if ( pathsavebuf_7 )
putenv(&pathsavebuf_7);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_6 )
putenv(&preloadsavebuf_6);
else
unsetenv("LD_PRELOAD");
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *haystack)
{
char *v1; // r12
char *v2; // rbp
__int64 (__fastcall *v3)(char *); // r13
unsigned int v4; // ebx

v1 = getenv("LD_LIBRARY_PATH");
v2 = getenv("LD_PRELOAD");
v3 = (__int64 (__fastcall *)(char *))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "system");
if ( v1 && *v1 )
snprintf(&pathsavebuf_7, 0x2000uLL, "LD_LIBRARY_PATH=%s", v1);
else
pathsavebuf_7 = 0;
if ( v2 && *v2 )
snprintf(&preloadsavebuf_6, 0x2000uLL, "LD_PRELOAD=%s", v2);
else
preloadsavebuf_6 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v4 = v3(haystack);
if ( pathsavebuf_7 )
putenv(&pathsavebuf_7);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_6 )
putenv(&preloadsavebuf_6);
else
unsetenv("LD_PRELOAD");
return v4;
}

original_code: int system(const char * cmd) { char *pathenvptr=getenv("LD_LIBRARY_PATH"), *preloadenvptr=getenv("LD_PRELOAD"); static char pathsavebuf[8192],preloadsavebuf[8192]; int retval; int (*original_system)(const char *); original_system=dlsym(((void *) -1l),"system"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(cmd,"/")==(char *)((void *)0) || strstr(cmd,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(cmd,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_system)(cmd); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

canonical_original_code: int system(char *cmd) { char *pathenvptr = getenv("LD_LIBRARY_PATH"); char *preloadenvptr = getenv("LD_PRELOAD"); static char pathsavebuf[8192]; static char preloadsavebuf[8192]; int retval; int (*original_system)(char *); original_system=dlsym(((void *) -1l),"system"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(cmd,"/")==(char *)((void *)0) || strstr(cmd,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(cmd,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_system)(cmd); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

variable_types:
cmd
char *

variable_types:
pathenvptr
char *

variable_types:
preloadenvptr
char *

variable_types:
pathsavebuf
char [8192]

variable_types:
preloadsavebuf
char [8192]

variable_types: retval int


execvp

decompiled_code:
__int64 __fastcall execvp(char *haystack, __int64 a2)
{
char *v2; // r12
char *v3; // rbp
__int64 (__fastcall *v4)(char *, __int64); // r13
unsigned int v5; // ebx

v2 = getenv("LD_LIBRARY_PATH");
v3 = getenv("LD_PRELOAD");
v4 = (__int64 (__fastcall *)(char *, __int64))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execvp");
if ( v2 && *v2 )
snprintf(&pathsavebuf_5, 0x2000uLL, "LD_LIBRARY_PATH=%s", v2);
else
pathsavebuf_5 = 0;
if ( v3 && *v3 )
snprintf(&preloadsavebuf_4, 0x2000uLL, "LD_PRELOAD=%s", v3);
else
preloadsavebuf_4 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v5 = v4(haystack, a2);
if ( pathsavebuf_5 )
putenv(&pathsavebuf_5);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_4 )
putenv(&preloadsavebuf_4);
else
unsetenv("LD_PRELOAD");
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *haystack, __int64 a2)
{
char *v2; // r12
char *v3; // rbp
__int64 (__fastcall *v4)(char *, __int64); // r13
unsigned int v5; // ebx

v2 = getenv("LD_LIBRARY_PATH");
v3 = getenv("LD_PRELOAD");
v4 = (__int64 (__fastcall *)(char *, __int64))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execvp");
if ( v2 && *v2 )
snprintf(&pathsavebuf_5, 0x2000uLL, "LD_LIBRARY_PATH=%s", v2);
else
pathsavebuf_5 = 0;
if ( v3 && *v3 )
snprintf(&preloadsavebuf_4, 0x2000uLL, "LD_PRELOAD=%s", v3);
else
preloadsavebuf_4 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v5 = v4(haystack, a2);
if ( pathsavebuf_5 )
putenv(&pathsavebuf_5);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_4 )
putenv(&preloadsavebuf_4);
else
unsetenv("LD_PRELOAD");
return v5;
}

original_code: int execvp(const char * file,const char ** argv) { char *pathenvptr=getenv("LD_LIBRARY_PATH"), *preloadenvptr=getenv("LD_PRELOAD"); static char pathsavebuf[8192],preloadsavebuf[8192]; int retval; int (*original_execvp)(const char *,const char **); original_execvp=dlsym(((void *) -1l),"execvp"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(file,"/")==(char *)((void *)0) || strstr(file,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(file,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_execvp)(file,argv); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

canonical_original_code: int execvp(char *file, char **argv) { char *pathenvptr = getenv("LD_LIBRARY_PATH"); char *preloadenvptr = getenv("LD_PRELOAD"); static char pathsavebuf[8192]; static char preloadsavebuf[8192]; int retval; int (*original_execvp)(char *, char **); original_execvp=dlsym(((void *) -1l),"execvp"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(file,"/")==(char *)((void *)0) || strstr(file,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(file,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_execvp)(file,argv); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

variable_types:
file
char *

variable_types:
argv
char **


execve

decompiled_code:
__int64 __fastcall execve(char *haystack, __int64 a2, __int64 a3)
{
char *v4; // r12
char *v5; // rbp
__int64 (__fastcall *v6)(char *, __int64, __int64); // r13
unsigned int v7; // ebx

v4 = getenv("LD_LIBRARY_PATH");
v5 = getenv("LD_PRELOAD");
v6 = (__int64 (__fastcall *)(char *, __int64, __int64))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execve");
if ( v4 && *v4 )
snprintf(&pathsavebuf_3, 0x2000uLL, "LD_LIBRARY_PATH=%s", v4);
else
pathsavebuf_3 = 0;
if ( v5 && *v5 )
snprintf(&preloadsavebuf_2, 0x2000uLL, "LD_PRELOAD=%s", v5);
else
preloadsavebuf_2 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v7 = v6(haystack, a2, a3);
if ( pathsavebuf_3 )
putenv(&pathsavebuf_3);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_2 )
putenv(&preloadsavebuf_2);
else
unsetenv("LD_PRELOAD");
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func8(char *haystack, __int64 a2, __int64 a3)
{
char *v4; // r12
char *v5; // rbp
__int64 (__fastcall *v6)(char *, __int64, __int64); // r13
unsigned int v7; // ebx

v4 = getenv("LD_LIBRARY_PATH");
v5 = getenv("LD_PRELOAD");
v6 = (__int64 (__fastcall *)(char *, __int64, __int64))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execve");
if ( v4 && *v4 )
snprintf(&pathsavebuf_3, 0x2000uLL, "LD_LIBRARY_PATH=%s", v4);
else
pathsavebuf_3 = 0;
if ( v5 && *v5 )
snprintf(&preloadsavebuf_2, 0x2000uLL, "LD_PRELOAD=%s", v5);
else
preloadsavebuf_2 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
v7 = v6(haystack, a2, a3);
if ( pathsavebuf_3 )
putenv(&pathsavebuf_3);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_2 )
putenv(&preloadsavebuf_2);
else
unsetenv("LD_PRELOAD");
return v7;
}

original_code: int execve(const char * filename,const char ** argv,const char ** envp) { char *pathenvptr=getenv("LD_LIBRARY_PATH"), *preloadenvptr=getenv("LD_PRELOAD"); static char pathsavebuf[8192],preloadsavebuf[8192]; int retval; int (*original_execve)(const char *,const char **,const char **); original_execve=dlsym(((void *) -1l),"execve"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(filename,"/")==(char *)((void *)0) || strstr(filename,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(filename,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_execve)(filename,argv,envp); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

canonical_original_code: int execve(char *filename, char **argv, char **envp) { char *pathenvptr = getenv("LD_LIBRARY_PATH"); char *preloadenvptr = getenv("LD_PRELOAD"); static char pathsavebuf[8192]; static char preloadsavebuf[8192]; int retval; int (*original_execve)(char *, char **, char **); original_execve=dlsym(((void *) -1l),"execve"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(filename,"/")==(char *)((void *)0) || strstr(filename,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(filename,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); retval=(*original_execve)(filename,argv,envp); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

variable_types:
filename
char *

variable_types:
envp
char **


execlp

decompiled_code:
__int64 execlp(char *haystack, __int64 a2, ...)
{
char *v2; // r12
char *v3; // rbp
__int64 (__fastcall *v4)(char *, __int64, __va_list_tag *); // r13
unsigned int v5; // ebx
gcc_va_list va; // [rsp+8h] [rbp-F0h] BYREF

v2 = getenv("LD_LIBRARY_PATH");
v3 = getenv("LD_PRELOAD");
v4 = (__int64 (__fastcall *)(char *, __int64, __va_list_tag *))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execlp");
if ( v2 && *v2 )
snprintf(&pathsavebuf_1, 0x2000uLL, "LD_LIBRARY_PATH=%s", v2);
else
pathsavebuf_1 = 0;
if ( v3 && *v3 )
snprintf(&preloadsavebuf_0, 0x2000uLL, "LD_PRELOAD=%s", v3);
else
preloadsavebuf_0 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
va_start(va, a2);
v5 = v4(haystack, a2, va);
if ( pathsavebuf_1 )
putenv(&pathsavebuf_1);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_0 )
putenv(&preloadsavebuf_0);
else
unsetenv("LD_PRELOAD");
return v5;
}

canonical_decompiled_code:
__int64 func9(char *haystack, __int64 a2, ...)
{
char *v2; // r12
char *v3; // rbp
__int64 (__fastcall *v4)(char *, __int64, __va_list_tag *); // r13
unsigned int v5; // ebx
gcc_va_list va; // [rsp+8h] [rbp-F0h] BYREF

v2 = getenv("LD_LIBRARY_PATH");
v3 = getenv("LD_PRELOAD");
v4 = (__int64 (__fastcall *)(char *, __int64, __va_list_tag *))dlsym((void *)0xFFFFFFFFFFFFFFFFLL, "execlp");
if ( v2 && *v2 )
snprintf(&pathsavebuf_1, 0x2000uLL, "LD_LIBRARY_PATH=%s", v2);
else
pathsavebuf_1 = 0;
if ( v3 && *v3 )
snprintf(&preloadsavebuf_0, 0x2000uLL, "LD_PRELOAD=%s", v3);
else
preloadsavebuf_0 = 0;
if ( !strchr(haystack, 47)
|| strstr(haystack, "/opt/google/talkplugin/")
|| !strcmp(haystack, "/opt/google/chrome/google-chrome") )
{
unsetenv("LD_LIBRARY_PATH");
}
unsetenv("LD_PRELOAD");
va_start(va, a2);
v5 = v4(haystack, a2, va);
if ( pathsavebuf_1 )
putenv(&pathsavebuf_1);
else
unsetenv("LD_LIBRARY_PATH");
if ( preloadsavebuf_0 )
putenv(&preloadsavebuf_0);
else
unsetenv("LD_PRELOAD");
return v5;
}

original_code: int execlp(const char * file,const char * arg,...) { va_list args; char *pathenvptr=getenv("LD_LIBRARY_PATH"), *preloadenvptr=getenv("LD_PRELOAD"); static char pathsavebuf[8192],preloadsavebuf[8192]; int retval; int (*original_execlp)(const char *,const char *,...); original_execlp=dlsym(((void *) -1l),"execlp"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(file,"/")==(char *)((void *)0) || strstr(file,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(file,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); __builtin_va_start(args,arg); retval=(*original_execlp)(file,arg,args); __builtin_va_end(args); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

canonical_original_code: int execlp(char *file, char *arg, ...) { __builtin_va_list args; char *pathenvptr = getenv("LD_LIBRARY_PATH"); char *preloadenvptr = getenv("LD_PRELOAD"); static char pathsavebuf[8192]; static char preloadsavebuf[8192]; int retval; int (*original_execlp)(char *, char *, ...); original_execlp=dlsym(((void *) -1l),"execlp"); if (pathenvptr!=(char *)((void *)0) && pathenvptr[0]!='\0') (void)snprintf(pathsavebuf,8192,"LD_LIBRARY_PATH" "=%s",pathenvptr); else pathsavebuf[0]='\0'; if (preloadenvptr!=(char *)((void *)0) && preloadenvptr[0]!='\0') (void)snprintf(preloadsavebuf,8192,"LD_PRELOAD" "=%s",preloadenvptr); else preloadsavebuf[0]='\0'; if (strstr(file,"/")==(char *)((void *)0) || strstr(file,"/opt/google/talkplugin/")!=(char *)((void *)0) || !strcmp(file,"/opt/google/chrome/google-chrome")) unsetenv("LD_LIBRARY_PATH"); unsetenv("LD_PRELOAD"); __builtin_va_start(args,arg); retval=(*original_execlp)(file,arg,args); __builtin_va_end(args); if (pathsavebuf[0]) putenv(pathsavebuf); else unsetenv("LD_LIBRARY_PATH"); if (preloadsavebuf[0]) putenv(preloadsavebuf); else unsetenv("LD_PRELOAD"); return(retval); }

variable_types:
arg
char *


decompiled_code:
void __fastcall add_node_at(_QWORD *a1, _QWORD **a2, int a3)
{
_QWORD *v3; // rax
_QWORD *v4; // rdx

if ( a1 )
{
if ( a3 <= 0 )
{
add_node();
}
else
{
v3 = *a2;
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
}
while ( v3 );
*a1 = 0LL;
*v4 = a1;
}
}
}

canonical_decompiled_code:
void __fastcall func0(_QWORD *a1, _QWORD **a2, int a3)
{
_QWORD *v3; // rax
_QWORD *v4; // rdx

if ( a1 )
{
if ( a3 <= 0 )
{
add_node();
}
else
{
v3 = *a2;
do
{
v4 = v3;
v3 = (_QWORD *)*v3;
}
while ( v3 );
*a1 = 0LL;
*v4 = a1;
}
}
}

original_code:
void add_node_at(t_node *node, t_node **head, int n)
{
  int i;
  t_node *search;
  search = *head;
  if(node==((void *)0) || head==((void *)0))
    return;
  if (n<=0)
    add_node(node, head);
  else
    {
      for(i=1;i<n,search->next!=((void *)0);i++)
 {
   search = search->next;
 }
      node->next = search->next;
      search->next = node;
    }
}

canonical_original_code:
void add_node_at(struct s_node *node, struct s_node **head, int n)
{
  int i;
  struct s_node *search;
  search = *head;
  if(node==((void *)0) || head==((void *)0))
    return;
  if (n<=0)
    add_node(node, head);
  else
    {
      for(i=1;i<n,search->next!=((void *)0);i++)
 {
   search = search->next;
 }
      node->next = search->next;
      search->next = node;
    }
}

variable_types: struct s_node { struct s_node *next; void *elem; } *

variable_types:
head
struct s_node **

variable_types: n int

variable_types: i int


original_code:
char* my_strconcat(char* s1, char* s2)
{
  int i=0;
  int j=0;
  int lens1=my_strlen(s1);
  int lens2=my_strlen(s2);
  char* s3 = (char*)xmalloc(lens1+lens2+1);
  if (s1==((void *)0) && s2==((void *)0))
    return ((void *)0);
  if (s2==((void *)0))
    return s1;
  if (s1==((void *)0))
    return s3=s2;
  for(i;i<lens1;i++)
    {
      s3[i]=s1[i];
    }
  for(j;j<lens2;i++,j++)
    {
      s3[i]=s2[j];
    }
  s3[i]='\0';
  return s3;
}

canonical_original_code:
char *my_strconcat(char *s1, char *s2)
{
  int i = 0;
  int j = 0;
  int lens1 = my_strlen(s1);
  int lens2 = my_strlen(s2);
  char *s3 = (char*)xmalloc(lens1+lens2+1);
  if (s1==((void *)0) && s2==((void *)0))
    return ((void *)0);
  if (s2==((void *)0))
    return s1;
  if (s1==((void *)0))
    return s3=s2;
  for(i;i<lens1;i++)
    {
      s3[i]=s1[i];
    }
  for(j;j<lens2;i++,j++)
    {
      s3[i]=s2[j];
    }
  s3[i]='\0';
  return s3;
}

variable_types: j int


decompiled_code:
__int64 __fastcall my_strindex(char *a1, char a2)
{
char v2; // dl
__int64 v3; // rax
unsigned int v4; // ecx

if ( !a1 )
return (unsigned int)-1;
v2 = *a1;
if ( !*a1 )
return (unsigned int)-1;
v3 = 0LL;
while ( 1 )
{
v4 = v3;
if ( a2 == v2 )
break;
v2 = a1[++v3];
if ( !v2 )
return (unsigned int)-1;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char a2)
{
char v2; // dl
__int64 v3; // rax
unsigned int v4; // ecx

if ( !a1 )
return (unsigned int)-1;
v2 = *a1;
if ( !*a1 )
return (unsigned int)-1;
v3 = 0LL;
while ( 1 )
{
v4 = v3;
if ( a2 == v2 )
break;
v2 = a1[++v3];
if ( !v2 )
return (unsigned int)-1;
}
return v4;
}

original_code:
int my_strindex(char* str, char c)
{
  int i;
  if(str==((void *)0))
    return -1;
  else
    {
      for(i=0;str[i]!='\0';i++)
 {
   if(c==str[i])
     return i;
 }
      return -1;
    }
}

canonical_original_code:
int my_strindex(char *str, char c)
{
  int i;
  if(str==((void *)0))
    return -1;
  else
    {
      for(i=0;str[i]!='\0';i++)
 {
   if(c==str[i])
     return i;
 }
      return -1;
    }
}

variable_types:
str
char *

variable_types: c char