getmouseevent

decompiled_code:
int __fastcall getmouseevent(_DWORD *a1)
{
int result; // eax
int v2; // ecx
int v3; // esi
MEVENT v4; // [rsp+0h] [rbp-28h] BYREF

result = getmouse(&v4);
if ( result )
return 0;
if ( LODWORD(v4.bstate) == 4 )
{
if ( v4.y < yDice || v4.y > yDice + 4 )
{
LABEL_10:
if ( v4.y == yButton && v4.x >= xButton && v4.x <= xButton + 12 )
{
*a1 = 5;
result = 1;
}
else if ( v4.y >= ySlots && v4.y <= ySlots + 7 )
{
if ( v4.x < xSlots || v4.x > xSlots + 19 )
{
if ( v4.x > xSlots + 26 && v4.x <= xSlots + 46 )
{
*a1 = v4.y - ySlots + 14;
result = 1;
}
}
else
{
*a1 = v4.y - ySlots + 6;
result = 1;
}
}
}
else
{
v2 = xDice;
v3 = 0;
while ( v4.x < v2 || v4.x > v2 + 8 )
{
++v3;
v2 += 11;
if ( v3 == 5 )
goto LABEL_10;
}
*a1 = v3;
result = 1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(_DWORD *a1)
{
int result; // eax
int v2; // ecx
int v3; // esi
MEVENT v4; // [rsp+0h] [rbp-28h] BYREF

result = getmouse(&v4);
if ( result )
return 0;
if ( LODWORD(v4.bstate) == 4 )
{
if ( v4.y < yDice || v4.y > yDice + 4 )
{
LABEL_10:
if ( v4.y == yButton && v4.x >= xButton && v4.x <= xButton + 12 )
{
*a1 = 5;
result = 1;
}
else if ( v4.y >= ySlots && v4.y <= ySlots + 7 )
{
if ( v4.x < xSlots || v4.x > xSlots + 19 )
{
if ( v4.x > xSlots + 26 && v4.x <= xSlots + 46 )
{
*a1 = v4.y - ySlots + 14;
result = 1;
}
}
else
{
*a1 = v4.y - ySlots + 6;
result = 1;
}
}
}
else
{
v2 = xDice;
v3 = 0;
while ( v4.x < v2 || v4.x > v2 + 8 )
{
++v3;
v2 += 11;
if ( v3 == 5 )
goto LABEL_10;
}
*a1 = v3;
result = 1;
}
}
return result;
}

original_code:
static int getmouseevent(int *control)
{
    MEVENT event;
    int i, x;
    if (getmouse(&event) != (0) || event.bstate != ((004L) << (((1) - 1) * 5)))
 return 0;
    if (event.y >= yDice && event.y < yDice + cyDie) {
 x = xDice;
 for (i = (0) ; i < ((0) + 5) ; ++i) {
     if (event.x >= x && event.x < x + cxDie) {
  *control = i;
  return 1;
     }
     x += cxDie + cxDieSpacing;
 }
    }
    if (event.y == yButton && event.x >= xButton
      && event.x < xButton + cxButton) {
 *control = (((0) + 5));
 return 1;
    }
    if (event.y >= ySlots && event.y < ySlots + cySlots) {
 if (event.x >= xSlots && event.x < xSlots + cxSlot) {
     *control = ((((0) + 5)) + 1) + (event.y - ySlots);
     return 1;
 }
 if (event.x >= xSlots + cxSlot + cxSlotSpacing &&
   event.x < xSlots + cxSlot * 2 + cxSlotSpacing) {
     *control = ((((0) + 5)) + 1) + (16 / 2) + (event.y - ySlots);
     return 1;
 }
    }
    return 0;
}

canonical_original_code:
static int getmouseevent(int *control)
{
    struct MEVENT event;
    int i; int x;
    if (getmouse(&event) != (0) || event.bstate != ((004L) << (((1) - 1) * 5)))
 return 0;
    if (event.y >= yDice && event.y < yDice + cyDie) {
 x = xDice;
 for (i = (0) ; i < ((0) + 5) ; ++i) {
     if (event.x >= x && event.x < x + cxDie) {
  *control = i;
  return 1;
     }
     x += cxDie + cxDieSpacing;
 }
    }
    if (event.y == yButton && event.x >= xButton
      && event.x < xButton + cxButton) {
 *control = (((0) + 5));
 return 1;
    }
    if (event.y >= ySlots && event.y < ySlots + cySlots) {
 if (event.x >= xSlots && event.x < xSlots + cxSlot) {
     *control = ((((0) + 5)) + 1) + (event.y - ySlots);
     return 1;
 }
 if (event.x >= xSlots + cxSlot + cxSlotSpacing &&
   event.x < xSlots + cxSlot * 2 + cxSlotSpacing) {
     *control = ((((0) + 5)) + 1) + (16 / 2) + (event.y - ySlots);
     return 1;
 }
    }
    return 0;
}

variable_types:
control
int *

variable_types: struct MEVENT { short id; int x; unsigned int bstate; }


runtextdisplay

decompiled_code:
__int64 __fastcall runtextdisplay(char *a1, char **a2)
{
char *v2; // rax
char **v3; // r12
int v4; // ebp
int v5; // ebx
int v6; // eax
unsigned int v7; // er8
char *v9; // [rsp+8h] [rbp-20h] BYREF

werase(stdscr);
if ( wmove(stdscr, 0, xDice + 4) != -1 )
waddnstr(stdscr, a1, -1);
v2 = *a2;
if ( *a2 )
{
v3 = a2 + 1;
v4 = 2;
do
{
while ( 1 )
{
v9 = v2;
if ( !*v2 )
break;
v5 = textbreak(&v9, 72LL);
if ( wmove(stdscr, v4, 4) != -1 )
waddnstr(stdscr, v9, v5);
++v4;
v2 = &v9[v5];
}
v2 = *v3++;
}
while ( v2 );
}
wmove(stdscr, cyScreen - 1, 0);
wrefresh(stdscr);
v6 = wgetch(stdscr);
v7 = 0;
if ( v6 != 3 && v6 != 24 )
{
render();
v7 = 1;
}
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1, char **a2)
{
char *v2; // rax
char **v3; // r12
int v4; // ebp
int v5; // ebx
int v6; // eax
unsigned int v7; // er8
char *v9; // [rsp+8h] [rbp-20h] BYREF

werase(stdscr);
if ( wmove(stdscr, 0, xDice + 4) != -1 )
waddnstr(stdscr, a1, -1);
v2 = *a2;
if ( *a2 )
{
v3 = a2 + 1;
v4 = 2;
do
{
while ( 1 )
{
v9 = v2;
if ( !*v2 )
break;
v5 = textbreak(&v9, 72LL);
if ( wmove(stdscr, v4, 4) != -1 )
waddnstr(stdscr, v9, v5);
++v4;
v2 = &v9[v5];
}
v2 = *v3++;
}
while ( v2 );
}
wmove(stdscr, cyScreen - 1, 0);
wrefresh(stdscr);
v6 = wgetch(stdscr);
v7 = 0;
if ( v6 != 3 && v6 != 24 )
{
func4();
v7 = 1;
}
return v7;
}

original_code:
static int runtextdisplay(char const *title, char const *lines[])
{
    char const *line;
    int y, i, n;
    werase(stdscr);
    (wmove((stdscr),((0)),((xDice + 4))) == (-1) ? (-1) : waddnstr((stdscr),((title)),-1));
    y = 2;
    for (i = 0 ; lines[i] ; ++i) {
 line = lines[i];
 while (*line) {
     n = textbreak(&line, 72);
     (wmove((stdscr),((y)),((4))) == (-1) ? (-1) : waddnstr((stdscr),((line)),((n))));
     ++y;
     line += n;
 }
    }
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
    for (;;) {
 switch (wgetch(stdscr)) {
   case '\003':
   case '\030':
     return 0;
   default:
     render();
     return 1;
 }
    }
}

canonical_original_code:
static int runtextdisplay(char *title, char *lines[])
{
    char *line;
    int y; int i; int n;
    werase(stdscr);
    (wmove((stdscr),((0)),((xDice + 4))) == (-1) ? (-1) : waddnstr((stdscr),((title)),-1));
    y = 2;
    for (i = 0 ; lines[i] ; ++i) {
 line = lines[i];
 while (*line) {
     n = textbreak(&line, 72);
     (wmove((stdscr),((y)),((4))) == (-1) ? (-1) : waddnstr((stdscr),((line)),((n))));
     ++y;
     line += n;
 }
    }
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
    for (;;) {
 switch (wgetch(stdscr)) {
   case '\003':
   case '\030':
     return 0;
   default:
     render();
     return 1;
 }
    }
}

variable_types:
title
char *

variable_types:
lines
char *[]

variable_types:
line
char *

variable_types: y int

variable_types: i int

variable_types: n int

return_type: int


runruleshelp

decompiled_code:
__int64 runruleshelp()
{
return runtextdisplay("Rules of the Game", &rulesinfo);
}

canonical_decompiled_code:
__int64 func7()
{
return func6("Rules of the Game", &rulesinfo);
}

original_code:
static int runruleshelp(void)
{
    return runtextdisplay("Rules of the Game", rulesinfo);
}

canonical_original_code:
static int runruleshelp()
{
    return runtextdisplay("Rules of the Game", rulesinfo);
}


runlicensedisplay

decompiled_code:
__int64 runlicensedisplay()
{
return runtextdisplay("Version and License", &licenseinfo);
}

canonical_decompiled_code:
__int64 func8()
{
return func6("Version and License", &licenseinfo);
}

original_code:
static int runlicensedisplay(void)
{
    return runtextdisplay("Version and License", licenseinfo);
}

canonical_original_code:
static int runlicensedisplay()
{
    return runtextdisplay("Version and License", licenseinfo);
}


decompiled_code:
__int64 curses_initializeio()
{
WINDOW *v0; // r8
__int64 result; // rax

v0 = initscr();
result = 0LL;
if ( v0 )
{
atexit(shutdown);
initlayout();
cbreak();
noecho();
keypad(stdscr, 1);
mousemask(4uLL, 0LL);
if ( has_colors() )
{
start_color();
init_pair(1, 0, 0);
init_pair(2, 6, 0);
init_pair(3, 3, 0);
init_pair(4, 4, 0);
dword_DA0 = 2098176;
*(_QWORD *)&attrs = 0x20010000000000LL;
*(_QWORD *)&qword_D98 = 0x30000000200LL;
}
else
{
dword_DA0 = 0x200000;
*(_QWORD *)&attrs = 0x10000000000000LL;
*(_QWORD *)&qword_D98 = 0x1000000100000LL;
}
changediechars(0);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 func10()
{
WINDOW *v0; // r8
__int64 result; // rax

v0 = initscr();
result = 0LL;
if ( v0 )
{
atexit(shutdown);
func0();
cbreak();
noecho();
keypad(stdscr, 1);
mousemask(4uLL, 0LL);
if ( has_colors() )
{
start_color();
init_pair(1, 0, 0);
init_pair(2, 6, 0);
init_pair(3, 3, 0);
init_pair(4, 4, 0);
dword_DA0 = 2098176;
*(_QWORD *)&attrs = 0x20010000000000LL;
*(_QWORD *)&qword_D98 = 0x30000000200LL;
}
else
{
dword_DA0 = 0x200000;
*(_QWORD *)&attrs = 0x10000000000000LL;
*(_QWORD *)&qword_D98 = 0x1000000100000LL;
}
func1(0);
result = 1LL;
}
return result;
}


decompiled_code:
__int64 __fastcall curses_runio(_DWORD *a1)
{
int v1; // eax
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

LABEL_1:
while ( 2 )
{
while ( 1 )
{
render();
v1 = wgetch(stdscr);
v2 = tolower(v1);
if ( v2 <= 63 )
break;
if ( v2 == 409 )
{
if ( getmouseevent(a1) )
return 1LL;
}
else if ( v2 <= 409 )
{
switch ( v2 )
{
case 265:
if ( !(unsigned int)runhelp() )
return 0LL;
break;
case 343:
LABEL_14:
*a1 = 5;
return 1LL;
case 113:
LABEL_16:
if ( *((_WORD *)&controls + 10) == 2 )
return 0LL;
break;
default:
goto LABEL_4;
}
}
else
{
if ( v2 != 410 )
goto LABEL_4;
initlayout();
}
}
if ( v2 >= -1 )
{
switch ( v2 )
{
case -1:
exit(1);
case 1:
changediechars(1);
continue;
case 3:
case 24:
return 0LL;
case 10:
case 13:
goto LABEL_14;
case 12:
clearok(stdscr, 1);
continue;
case 18:
if ( (unsigned int)runruleshelp() )
continue;
result = 0LL;
break;
case 22:
if ( (unsigned int)runlicensedisplay() )
continue;
result = 0LL;
break;
case 27:
goto LABEL_16;
default:
goto LABEL_4;
}
return result;
}
break;
}
LABEL_4:
v3 = 0LL;
while ( v2 != *((unsigned __int8 *)&controls + 4 * v3 + 2) )
{
if ( ++v3 == 22 )
goto LABEL_1;
}
*a1 = v3;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(_DWORD *a1)
{
int v1; // eax
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

LABEL_1:
while ( 2 )
{
while ( 1 )
{
func4();
v1 = wgetch(stdscr);
v2 = tolower(v1);
if ( v2 <= 63 )
break;
if ( v2 == 409 )
{
if ( func5(a1) )
return 1LL;
}
else if ( v2 <= 409 )
{
switch ( v2 )
{
case 265:
if ( !(unsigned int)func9() )
return 0LL;
break;
case 343:
LABEL_14:
*a1 = 5;
return 1LL;
case 113:
LABEL_16:
if ( *((_WORD *)&controls + 10) == 2 )
return 0LL;
break;
default:
goto LABEL_4;
}
}
else
{
if ( v2 != 410 )
goto LABEL_4;
func0();
}
}
if ( v2 >= -1 )
{
switch ( v2 )
{
case -1:
exit(1);
case 1:
func1(1);
continue;
case 3:
case 24:
return 0LL;
case 10:
case 13:
goto LABEL_14;
case 12:
clearok(stdscr, 1);
continue;
case 18:
if ( (unsigned int)func7() )
continue;
result = 0LL;
break;
case 22:
if ( (unsigned int)func8() )
continue;
result = 0LL;
break;
case 27:
goto LABEL_16;
default:
goto LABEL_4;
}
return result;
}
break;
}
LABEL_4:
v3 = 0LL;
while ( v2 != *((unsigned __int8 *)&controls + 4 * v3 + 2) )
{
if ( ++v3 == 22 )
goto LABEL_1;
}
*a1 = v3;
return 1LL;
}

original_code:
int curses_runio(int *control)
{
    int ch, i;
    for (;;) {
 render();
 ch = tolower(wgetch(stdscr));
 switch (ch) {
   case '\r':
   case '\n':
   case 0527:
     *control = (((0) + 5));
     return 1;
   case 0631:
     if (getmouseevent(control))
  return 1;
     break;
   case '?':
   case (0410 +(1)):
     if (!runhelp())
  return 0;
     break;
   case '\022':
     if (!runruleshelp())
  return 0;
     break;
   case '\026':
     if (!runlicensedisplay())
  return 0;
     break;
   case '\001':
     changediechars(+1);
     break;
   case '\f':
     clearok(stdscr, 1);
     break;
   case 0632:
     initlayout();
     break;
   case '\003':
   case '\030':
     return 0;
   case 'q':
   case '\033':
     if (controls[(((0) + 5))].value == 2)
  return 0;
     break;
   case (-1):
     exit(1);
   default:
     for (i = 0 ; i < ((((((0) + 5)) + 1) + 16)) ; ++i) {
  if (controls[i].key == ch) {
      *control = i;
      return 1;
  }
     }
 }
    }
}

canonical_original_code:
int curses_runio(int *control)
{
    int ch; int i;
    for (;;) {
 render();
 ch = tolower(wgetch(stdscr));
 switch (ch) {
   case '\r':
   case '\n':
   case 0527:
     *control = (((0) + 5));
     return 1;
   case 0631:
     if (getmouseevent(control))
  return 1;
     break;
   case '?':
   case (0410 +(1)):
     if (!runhelp())
  return 0;
     break;
   case '\022':
     if (!runruleshelp())
  return 0;
     break;
   case '\026':
     if (!runlicensedisplay())
  return 0;
     break;
   case '\001':
     changediechars(+1);
     break;
   case '\f':
     clearok(stdscr, 1);
     break;
   case 0632:
     initlayout();
     break;
   case '\003':
   case '\030':
     return 0;
   case 'q':
   case '\033':
     if (controls[(((0) + 5))].value == 2)
  return 0;
     break;
   case (-1):
     exit(1);
   default:
     for (i = 0 ; i < ((((((0) + 5)) + 1) + 16)) ; ++i) {
  if (controls[i].key == ch) {
      *control = i;
      return 1;
  }
     }
 }
    }
}

variable_types: ch int


initlayout

decompiled_code:
__int64 initlayout()
{
int v0; // edx
int v1; // eax
int v2; // edx
__int64 result; // rax

if ( !stdscr )
{
cyScreen = -1;
goto LABEL_6;
}
cyScreen = stdscr->_maxy + 1;
v0 = stdscr->_maxx;
v1 = (v0 - 52) / 2;
xDice = v1;
if ( v0 <= 53 )
{
LABEL_6:
xDice = 1;
result = 4LL;
v2 = 21;
goto LABEL_4;
}
v2 = v1 + 20;
result = (unsigned int)(v1 + 3);
LABEL_4:
xButton = v2;
xSlots = result;
yDice = 0;
yButton = 6;
ySlots = 8;
return result;
}

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

if ( !stdscr )
{
cyScreen = -1;
goto LABEL_6;
}
cyScreen = stdscr->_maxy + 1;
v0 = stdscr->_maxx;
v1 = (v0 - 52) / 2;
xDice = v1;
if ( v0 <= 53 )
{
LABEL_6:
xDice = 1;
result = 4LL;
v2 = 21;
goto LABEL_4;
}
v2 = v1 + 20;
result = (unsigned int)(v1 + 3);
LABEL_4:
xButton = v2;
xSlots = result;
yDice = 0;
yButton = 6;
ySlots = 8;
return result;
}

original_code:
static void initlayout(void)
{
    (cyScreen = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), cxScreen = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
    xDice = (cxScreen - cxDice) / 2;
    if (xDice < 1)
 xDice = 1;
    xButton = xDice + (cxDice - cxButton) / 2;
    xSlots = xDice + (cxDice - cxSlots) / 2;
    yDice = 0;
    yButton = yDice + cyDie + 1;
    ySlots = yButton + 2;
}

canonical_original_code:
static void initlayout()
{
    (cyScreen = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), cxScreen = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
    xDice = (cxScreen - cxDice) / 2;
    if (xDice < 1)
 xDice = 1;
    xButton = xDice + (cxDice - cxButton) / 2;
    xSlots = xDice + (cxDice - cxSlots) / 2;
    yDice = 0;
    yButton = yDice + cyDie + 1;
    ySlots = yButton + 2;
}

return_type: void


shutdown

decompiled_code:
void shutdown(void)
{
if ( !isendwin() )
endwin();
}

canonical_decompiled_code:
void func2(void)
{
if ( !isendwin() )
endwin();
}

original_code:
static void shutdown(void)
{
    if (!isendwin())
 endwin();
}

canonical_original_code:
static void shutdown()
{
    if (!isendwin())
 endwin();
}


render

decompiled_code:
int render()
{
__int64 v0; // rbx
int v1; // ebp
const char *v2; // rbp
char v3; // al
int v4; // er12
__int64 v5; // r13
const char *v6; // r14
__int64 v7; // rbx
int v8; // ebp

v0 = 0LL;
werase(stdscr);
v1 = xDice;
do
{
if ( (*((_BYTE *)&controls + v0 + 3) & 1) != 0 )
wattrset(stdscr, qword_D98);
drawacsdie(yDice, v1, *(__int16 *)((char *)&controls + v0));
if ( (*((_BYTE *)&controls + v0 + 3) & 1) != 0 )
wattrset(stdscr, attrs);
v0 += 4LL;
v1 += 11;
}
while ( v0 != 20 );
v2 = (&buttontext_1)[*((__int16 *)&controls + 10)];
wmove(stdscr, yButton, xButton);
v3 = *((_BYTE *)&controls + 23);
if ( (v3 & 2) != 0 )
{
wattrset(stdscr, *(&attrs + 1));
printw("| %s |", v2);
wattrset(stdscr, attrs);
}
else if ( (v3 & 1) != 0 )
{
waddnstr(stdscr, "[[", -1);
wattrset(stdscr, *(&qword_D98 + 1));
waddnstr(stdscr, v2, -1);
wattrset(stdscr, attrs);
waddnstr(stdscr, "]]", -1);
}
else
{
printw("[ %s ]", v2);
}
v4 = xSlots;
v5 = 6LL;
v6 = "Ones";
while ( 1 )
{
v7 = v5;
v8 = 0;
while ( 1 )
{
wmove(stdscr, v8 + ySlots, v4);
if ( (*((_BYTE *)&controls + 4 * v7 + 3) & 1) != 0 )
wattrset(stdscr, *(&qword_D98 + 1));
printw("%-*s", 17LL, v6);
if ( *((__int16 *)&controls + 2 * v7) >= 0 && (*((_BYTE *)&controls + 4 * v7 + 3) & 3) != 0 )
printw("%3d", (unsigned int)*((__int16 *)&controls + 2 * v7));
++v8;
++v7;
wattrset(stdscr, attrs);
if ( v8 == 8 )
break;
v6 = (const char *)*(&off_1330 + v7);
}
v5 += 8LL;
if ( v5 == 22 )
break;
v6 = (const char *)*(&off_1330 + v5);
v4 += 27;
}
wmove(stdscr, cyScreen - 1, 0);
return wrefresh(stdscr);
}

canonical_decompiled_code:
int func4()
{
__int64 v0; // rbx
int v1; // ebp
const char *v2; // rbp
char v3; // al
int v4; // er12
__int64 v5; // r13
const char *v6; // r14
__int64 v7; // rbx
int v8; // ebp

v0 = 0LL;
werase(stdscr);
v1 = xDice;
do
{
if ( (*((_BYTE *)&controls + v0 + 3) & 1) != 0 )
wattrset(stdscr, qword_D98);
func3(yDice, v1, *(__int16 *)((char *)&controls + v0));
if ( (*((_BYTE *)&controls + v0 + 3) & 1) != 0 )
wattrset(stdscr, attrs);
v0 += 4LL;
v1 += 11;
}
while ( v0 != 20 );
v2 = (&buttontext_1)[*((__int16 *)&controls + 10)];
wmove(stdscr, yButton, xButton);
v3 = *((_BYTE *)&controls + 23);
if ( (v3 & 2) != 0 )
{
wattrset(stdscr, *(&attrs + 1));
printw("| %s |", v2);
wattrset(stdscr, attrs);
}
else if ( (v3 & 1) != 0 )
{
waddnstr(stdscr, "[[", -1);
wattrset(stdscr, *(&qword_D98 + 1));
waddnstr(stdscr, v2, -1);
wattrset(stdscr, attrs);
waddnstr(stdscr, "]]", -1);
}
else
{
printw("[ %s ]", v2);
}
v4 = xSlots;
v5 = 6LL;
v6 = "Ones";
while ( 1 )
{
v7 = v5;
v8 = 0;
while ( 1 )
{
wmove(stdscr, v8 + ySlots, v4);
if ( (*((_BYTE *)&controls + 4 * v7 + 3) & 1) != 0 )
wattrset(stdscr, *(&qword_D98 + 1));
printw("%-*s", 17LL, v6);
if ( *((__int16 *)&controls + 2 * v7) >= 0 && (*((_BYTE *)&controls + 4 * v7 + 3) & 3) != 0 )
printw("%3d", (unsigned int)*((__int16 *)&controls + 2 * v7));
++v8;
++v7;
wattrset(stdscr, attrs);
if ( v8 == 8 )
break;
v6 = (const char *)*(&off_1330 + v7);
}
v5 += 8LL;
if ( v5 == 22 )
break;
v6 = (const char *)*(&off_1330 + v5);
v4 += 27;
}
wmove(stdscr, cyScreen - 1, 0);
return wrefresh(stdscr);
}

original_code:
static void render(void)
{
    static char const *buttontext[3] = {
 "Roll Dice", "  Score  ", "  Again  "
    };
    static char const *slottext[16] = {
 "Ones", "Twos", "Threes", "Fours", "Fives", "Sixes", "Subtotal",
 "Bonus", "Three of a Kind", "Four of a Kind", "Full House",
 "Small Straight", "Large Straight", "Yahtzee", "Chance", "Total Score"
    };
    char const *text;
    int i, n, x;
    werase(stdscr);
    x = xDice;
    for (i = (0) ; i < ((0) + 5) ; ++i) {
 if (((controls[i]).flags & 0x01))
     ((void)wattrset(stdscr,(attrs[a_marked])));
 drawacsdie(yDice, x, controls[i].value);
 if (((controls[i]).flags & 0x01))
     ((void)wattrset(stdscr,(attrs[a_normal])));
 x += cxDie + cxDieSpacing;
    }
    text = buttontext[controls[(((0) + 5))].value];
    wmove(stdscr,(yButton),(xButton));
    if (((controls[(((0) + 5))]).flags & 0x02)) {
 ((void)wattrset(stdscr,(attrs[a_dim])));
 printw("| %s |", text);
 ((void)wattrset(stdscr,(attrs[a_normal])));
    } else if (((controls[(((0) + 5))]).flags & 0x01)) {
 waddnstr(stdscr,("[["),-1);
 ((void)wattrset(stdscr,(attrs[a_selected])));
 waddnstr(stdscr,(text),-1);
 ((void)wattrset(stdscr,(attrs[a_normal])));
 waddnstr(stdscr,("]]"),-1);
    } else {
 printw("[ %s ]", text);
    }
    i = ((((0) + 5)) + 1);
    x = xSlots;
    while (i < (((((0) + 5)) + 1) + 16)) {
 for (n = 0 ; n < 16 / 2 ; ++n, ++i) {
     wmove(stdscr,(ySlots + n),(x));
     if (((controls[i]).flags & 0x01))
  ((void)wattrset(stdscr,(attrs[a_selected])));
     printw("%-*s", cxSlot - 3, slottext[i - ((((0) + 5)) + 1)]);
     if (controls[i].value >= 0) {
  if (((controls[i]).flags & 0x02) || ((controls[i]).flags & 0x01))
      printw("%3d", controls[i].value);
     }
     ((void)wattrset(stdscr,(attrs[a_normal])));
 }
 x += cxSlot + cxSlotSpacing;
    }
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
}

canonical_original_code:
static void render()
{
    static char *buttontext[3] = {
 "Roll Dice", "  Score  ", "  Again  "
    };
    static char *slottext[16] = {
 "Ones", "Twos", "Threes", "Fours", "Fives", "Sixes", "Subtotal",
 "Bonus", "Three of a Kind", "Four of a Kind", "Full House",
 "Small Straight", "Large Straight", "Yahtzee", "Chance", "Total Score"
    };
    char *text;
    int i; int n; int x;
    werase(stdscr);
    x = xDice;
    for (i = (0) ; i < ((0) + 5) ; ++i) {
 if (((controls[i]).flags & 0x01))
     ((void)wattrset(stdscr,(attrs[a_marked])));
 drawacsdie(yDice, x, controls[i].value);
 if (((controls[i]).flags & 0x01))
     ((void)wattrset(stdscr,(attrs[a_normal])));
 x += cxDie + cxDieSpacing;
    }
    text = buttontext[controls[(((0) + 5))].value];
    wmove(stdscr,(yButton),(xButton));
    if (((controls[(((0) + 5))]).flags & 0x02)) {
 ((void)wattrset(stdscr,(attrs[a_dim])));
 printw("| %s |", text);
 ((void)wattrset(stdscr,(attrs[a_normal])));
    } else if (((controls[(((0) + 5))]).flags & 0x01)) {
 waddnstr(stdscr,("[["),-1);
 ((void)wattrset(stdscr,(attrs[a_selected])));
 waddnstr(stdscr,(text),-1);
 ((void)wattrset(stdscr,(attrs[a_normal])));
 waddnstr(stdscr,("]]"),-1);
    } else {
 printw("[ %s ]", text);
    }
    i = ((((0) + 5)) + 1);
    x = xSlots;
    while (i < (((((0) + 5)) + 1) + 16)) {
 for (n = 0 ; n < 16 / 2 ; ++n, ++i) {
     wmove(stdscr,(ySlots + n),(x));
     if (((controls[i]).flags & 0x01))
  ((void)wattrset(stdscr,(attrs[a_selected])));
     printw("%-*s", cxSlot - 3, slottext[i - ((((0) + 5)) + 1)]);
     if (controls[i].value >= 0) {
  if (((controls[i]).flags & 0x02) || ((controls[i]).flags & 0x01))
      printw("%3d", controls[i].value);
     }
     ((void)wattrset(stdscr,(attrs[a_normal])));
 }
 x += cxSlot + cxSlotSpacing;
    }
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
}

variable_types:
buttontext
char *[3]

variable_types:
slottext
char *[16]

variable_types:
text
char *

variable_types: x int


runhelp

decompiled_code:
__int64 runhelp()
{
__int64 v0; // rbx
const __int32_t **v1; // r12
int v2; // ebp
__int64 v3; // rdx
int v4; // esi
__int64 v5; // rbp
int v6; // er13
int v7; // er14
__int64 i; // rbx
__int64 v9; // rax
int v10; // edi
int v11; // ebx
int v12; // eax
unsigned int v14; // er8

wattrset(stdscr, dword_DA0);
if ( wmove(stdscr, yDice, xDice - 1) != -1 )
waddnstr(stdscr, "Use these letter keys to select the dice:", -1);
v0 = 0LL;
v1 = _ctype_toupper_loc();
v2 = xDice + 6;
do
{
v3 = *((unsigned __int8 *)&controls + 4 * v0 + 2);
v4 = v2;
++v0;
v2 += 11;
mvprintw(yDice + 3, v4, "(%c)", (unsigned int)(*v1)[v3]);
}
while ( v0 != 5 );
if ( wmove(stdscr, yButton - 1, xDice - 1) != -1 )
waddnstr(stdscr, "Use (space) or (return)", -1);
if ( wmove(stdscr, yButton, xDice + 1) != -1 )
waddnstr(stdscr, "to push the button:", -1);
if ( wmove(stdscr, ySlots - 1, xDice - 1) != -1 )
waddnstr(stdscr, "Use these keys to select a scoring slot:", -1);
v5 = 24LL;
v6 = 6;
v7 = xSlots - 4;
do
{
for ( i = 0LL; i != 8; ++i )
{
while ( 1 )
{
v9 = *((unsigned __int8 *)&controls + 4 * i + v5 + 2);
if ( (_BYTE)v9 )
break;
if ( ++i == 8 )
goto LABEL_16;
}
v10 = i + ySlots;
mvprintw(v10, v7, "(%c)", (unsigned int)(*v1)[v9]);
}
LABEL_16:
v6 += 8;
v7 += 27;
v5 += 32LL;
}
while ( v6 != 22 );
v11 = ySlots;
if ( wmove(stdscr, ySlots + 8, xDice - 1) != -1 )
waddnstr(stdscr, "(ctrl A) changes how the dice are drawn.", -1);
if ( wmove(stdscr, v11 + 9, xDice - 1) != -1 )
waddnstr(stdscr, "Use (?) or (F1) to view this help again.", -1);
if ( wmove(stdscr, v11 + 10, xDice - 1) != -1 )
waddnstr(stdscr, "Use (ctrl R) to view the rules.", -1);
if ( wmove(stdscr, v11 + 11, xDice - 1) != -1 )
waddnstr(stdscr, "Use (ctrl V) to see version and license information.", -1);
if ( wmove(stdscr, v11 + 13, xDice + 20) != -1 )
waddnstr(stdscr, "Use (ctrl X) to exit the program.", -1);
wattrset(stdscr, attrs);
wmove(stdscr, cyScreen - 1, 0);
wrefresh(stdscr);
v12 = wgetch(stdscr);
if ( v12 == 22 )
return runlicensedisplay();
if ( v12 > 22 )
{
v14 = 0;
if ( v12 == 24 )
return v14;
LABEL_33:
render();
return 1;
}
if ( v12 != 3 )
{
if ( v12 == 18 )
return runruleshelp();
goto LABEL_33;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbx
const __int32_t **v1; // r12
int v2; // ebp
__int64 v3; // rdx
int v4; // esi
__int64 v5; // rbp
int v6; // er13
int v7; // er14
__int64 i; // rbx
__int64 v9; // rax
int v10; // edi
int v11; // ebx
int v12; // eax
unsigned int v14; // er8

wattrset(stdscr, dword_DA0);
if ( wmove(stdscr, yDice, xDice - 1) != -1 )
waddnstr(stdscr, "Use these letter keys to select the dice:", -1);
v0 = 0LL;
v1 = _ctype_toupper_loc();
v2 = xDice + 6;
do
{
v3 = *((unsigned __int8 *)&controls + 4 * v0 + 2);
v4 = v2;
++v0;
v2 += 11;
mvprintw(yDice + 3, v4, "(%c)", (unsigned int)(*v1)[v3]);
}
while ( v0 != 5 );
if ( wmove(stdscr, yButton - 1, xDice - 1) != -1 )
waddnstr(stdscr, "Use (space) or (return)", -1);
if ( wmove(stdscr, yButton, xDice + 1) != -1 )
waddnstr(stdscr, "to push the button:", -1);
if ( wmove(stdscr, ySlots - 1, xDice - 1) != -1 )
waddnstr(stdscr, "Use these keys to select a scoring slot:", -1);
v5 = 24LL;
v6 = 6;
v7 = xSlots - 4;
do
{
for ( i = 0LL; i != 8; ++i )
{
while ( 1 )
{
v9 = *((unsigned __int8 *)&controls + 4 * i + v5 + 2);
if ( (_BYTE)v9 )
break;
if ( ++i == 8 )
goto LABEL_16;
}
v10 = i + ySlots;
mvprintw(v10, v7, "(%c)", (unsigned int)(*v1)[v9]);
}
LABEL_16:
v6 += 8;
v7 += 27;
v5 += 32LL;
}
while ( v6 != 22 );
v11 = ySlots;
if ( wmove(stdscr, ySlots + 8, xDice - 1) != -1 )
waddnstr(stdscr, "(ctrl A) changes how the dice are drawn.", -1);
if ( wmove(stdscr, v11 + 9, xDice - 1) != -1 )
waddnstr(stdscr, "Use (?) or (F1) to view this help again.", -1);
if ( wmove(stdscr, v11 + 10, xDice - 1) != -1 )
waddnstr(stdscr, "Use (ctrl R) to view the rules.", -1);
if ( wmove(stdscr, v11 + 11, xDice - 1) != -1 )
waddnstr(stdscr, "Use (ctrl V) to see version and license information.", -1);
if ( wmove(stdscr, v11 + 13, xDice + 20) != -1 )
waddnstr(stdscr, "Use (ctrl X) to exit the program.", -1);
wattrset(stdscr, attrs);
wmove(stdscr, cyScreen - 1, 0);
wrefresh(stdscr);
v12 = wgetch(stdscr);
if ( v12 == 22 )
return func8();
if ( v12 > 22 )
{
v14 = 0;
if ( v12 == 24 )
return v14;
LABEL_33:
func4();
return 1;
}
if ( v12 != 3 )
{
if ( v12 == 18 )
return func7();
goto LABEL_33;
}
return 0LL;
}

original_code:
static int runhelp(void)
{
    int i, n, x, y;
    ((void)wattrset(stdscr,(attrs[a_overlay])));
    (wmove((stdscr),((yDice)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use these letter keys to select the dice:")),-1));
    x = xDice + cxDie;
    for (i = (0) ; i < ((0) + 5) ; ++i) {
 mvprintw(yDice + cyDie - 2, x - 3, "(%c)", toupper(controls[i].key));
 x += cxDie + cxDieSpacing;
    }
    (wmove((stdscr),((yButton - 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (space) or (return)")),-1));
    (wmove((stdscr),((yButton)),((xDice + 1))) == (-1) ? (-1) : waddnstr((stdscr),(("to push the button:")),-1));
    (wmove((stdscr),((ySlots - 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use these keys to select a scoring slot:")),-1));
    i = ((((0) + 5)) + 1);
    x = xSlots;
    while (i < (((((0) + 5)) + 1) + 16)) {
 for (n = 0 ; n < 16 / 2 ; ++n, ++i)
     if (controls[i].key)
  mvprintw(ySlots + n, x - 4, "(%c)", toupper(controls[i].key));
 x += cxSlot + cxSlotSpacing;
    }
    y = ySlots + cySlots;
    (wmove((stdscr),((y + 0)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("(ctrl A) changes how the dice are drawn.")),-1));
    (wmove((stdscr),((y + 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (?) or (F1) to view this help again.")),-1));
    (wmove((stdscr),((y + 2)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl R) to view the rules.")),-1));
    (wmove((stdscr),((y + 3)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl V) to see version and license information.")),-1));
    (wmove((stdscr),((y + 5)),((xDice + cxDice - 33))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl X) to exit the program.")),-1));
    ((void)wattrset(stdscr,(attrs[a_normal])));
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
    for (;;) {
 switch (wgetch(stdscr)) {
   case '\003':
   case '\030':
     return 0;
   case '\022':
     return runruleshelp();
     break;
   case '\026':
     return runlicensedisplay();
     break;
   default:
     render();
     return 1;
 }
    }
}

canonical_original_code:
static int runhelp()
{
    int i; int n; int x; int y;
    ((void)wattrset(stdscr,(attrs[a_overlay])));
    (wmove((stdscr),((yDice)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use these letter keys to select the dice:")),-1));
    x = xDice + cxDie;
    for (i = (0) ; i < ((0) + 5) ; ++i) {
 mvprintw(yDice + cyDie - 2, x - 3, "(%c)", toupper(controls[i].key));
 x += cxDie + cxDieSpacing;
    }
    (wmove((stdscr),((yButton - 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (space) or (return)")),-1));
    (wmove((stdscr),((yButton)),((xDice + 1))) == (-1) ? (-1) : waddnstr((stdscr),(("to push the button:")),-1));
    (wmove((stdscr),((ySlots - 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use these keys to select a scoring slot:")),-1));
    i = ((((0) + 5)) + 1);
    x = xSlots;
    while (i < (((((0) + 5)) + 1) + 16)) {
 for (n = 0 ; n < 16 / 2 ; ++n, ++i)
     if (controls[i].key)
  mvprintw(ySlots + n, x - 4, "(%c)", toupper(controls[i].key));
 x += cxSlot + cxSlotSpacing;
    }
    y = ySlots + cySlots;
    (wmove((stdscr),((y + 0)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("(ctrl A) changes how the dice are drawn.")),-1));
    (wmove((stdscr),((y + 1)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (?) or (F1) to view this help again.")),-1));
    (wmove((stdscr),((y + 2)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl R) to view the rules.")),-1));
    (wmove((stdscr),((y + 3)),((xDice - 1))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl V) to see version and license information.")),-1));
    (wmove((stdscr),((y + 5)),((xDice + cxDice - 33))) == (-1) ? (-1) : waddnstr((stdscr),(("Use (ctrl X) to exit the program.")),-1));
    ((void)wattrset(stdscr,(attrs[a_normal])));
    wmove(stdscr,(cyScreen - 1),(0));
    wrefresh(stdscr);
    for (;;) {
 switch (wgetch(stdscr)) {
   case '\003':
   case '\030':
     return 0;
   case '\022':
     return runruleshelp();
     break;
   case '\026':
     return runlicensedisplay();
     break;
   default:
     render();
     return 1;
 }
    }
}


repo: BYUHPC/uft

original_code:
void initialize_limits_struct(limits *limits) {
 strcpy(limits->memory_limit_in_bytes, "9223372036854775807");
 strcpy(limits->memory_memsw_limit_in_bytes, "9223372036854775807");
 strcpy(limits->cpu_shares, "1024");
}

canonical_original_code:
void initialize_limits_struct(struct limits *limits) {
 strcpy(limits->memory_limit_in_bytes, "9223372036854775807");
 strcpy(limits->memory_memsw_limit_in_bytes, "9223372036854775807");
 strcpy(limits->cpu_shares, "1024");
}

variable_types: struct limits { char memory_limit_in_bytes[24]; char memory_memsw_limit_in_bytes[24]; char cpu_shares[24]; } *


decompiled_code:
void __fastcall del_fvec(void *ptr)
{
unsigned int v1; // ebx
__int64 v2; // rdx

if ( *((_DWORD *)ptr + 1) )
{
v1 = 0;
do
{
v2 = v1++;
free(*(void **)(*((_QWORD *)ptr + 1) + 8 * v2));
}
while ( *((_DWORD *)ptr + 1) > v1 );
}
free(*((void **)ptr + 1));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
unsigned int v1; // ebx
__int64 v2; // rdx

if ( *((_DWORD *)ptr + 1) )
{
v1 = 0;
do
{
v2 = v1++;
free(*(void **)(*((_QWORD *)ptr + 1) + 8 * v2));
}
while ( *((_DWORD *)ptr + 1) > v1 );
}
free(*((void **)ptr + 1));
free(ptr);
}

original_code:
void del_fvec(fvec_t *s) {
  uint_t i;
  for (i=0; i<s->channels; i++) {
    free(s->data[i]);
  }
  free(s->data);
  free(s);
}

canonical_original_code:
void del_fvec(struct _fvec_t *s) {
  unsigned int i;
  for (i=0; i<s->channels; i++) {
    free(s->data[i]);
  }
  free(s->data);
  free(s);
}

variable_types: struct _fvec_t { unsigned int length; unsigned int channels; float **data; } *

variable_types:
i
unsigned int


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

original_code:
void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position) {
  s->data[channel][position] = data;
}

canonical_original_code:
void fvec_write_sample(struct _fvec_t *s, float data, unsigned int channel, unsigned int position) {
  s->data[channel][position] = data;
}

variable_types: data float

variable_types:
channel
unsigned int

variable_types:
position
unsigned int

user_defined_types: struct _fvec_t { unsigned int length; unsigned int channels; float **data; }


decompiled_code:
float __fastcall fvec_read_sample(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
float __fastcall func2(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + 4LL * a3);
}

original_code:
smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position) {
  return s->data[channel][position];
}

canonical_original_code:
float fvec_read_sample(struct _fvec_t *s, unsigned int channel, unsigned int position) {
  return s->data[channel][position];
}

return_type: float


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

result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

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

result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

original_code:
void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel) {
  s->data[channel] = data;
}

canonical_original_code:
void fvec_put_channel(struct _fvec_t *s, float *data, unsigned int channel) {
  s->data[channel] = data;
}

variable_types:
data
float *


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

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

original_code:
smpl_t * fvec_get_channel(fvec_t *s, uint_t channel) {
  return s->data[channel];
}

canonical_original_code:
float *fvec_get_channel(struct _fvec_t *s, unsigned int channel) {
  return s->data[channel];
}

return_type: float *


decompiled_code:
__int64 __fastcall fvec_get_data(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
smpl_t ** fvec_get_data(fvec_t *s) {
  return s->data;
}

canonical_original_code:
float **fvec_get_data(struct _fvec_t *s) {
  return s->data;
}

return_type: float **


decompiled_code:
void __fastcall del_cvec(void *ptr)
{
unsigned int v1; // ebx
__int64 v2; // r12

if ( *((_DWORD *)ptr + 1) )
{
v1 = 0;
do
{
v2 = v1++;
free(*(void **)(*((_QWORD *)ptr + 1) + 8 * v2));
free(*(void **)(*((_QWORD *)ptr + 2) + 8 * v2));
}
while ( *((_DWORD *)ptr + 1) > v1 );
}
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
unsigned int v1; // ebx
__int64 v2; // r12

if ( *((_DWORD *)ptr + 1) )
{
v1 = 0;
do
{
v2 = v1++;
free(*(void **)(*((_QWORD *)ptr + 1) + 8 * v2));
free(*(void **)(*((_QWORD *)ptr + 2) + 8 * v2));
}
while ( *((_DWORD *)ptr + 1) > v1 );
}
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(ptr);
}

original_code:
void del_cvec(cvec_t *s) {
  uint_t i;
  for (i=0; i<s->channels; i++) {
    free(s->norm[i]);
    free(s->phas[i]);
  }
  free(s->norm);
  free(s->phas);
  free(s);
}

canonical_original_code:
void del_cvec(struct _cvec_t *s) {
  unsigned int i;
  for (i=0; i<s->channels; i++) {
    free(s->norm[i]);
    free(s->phas[i]);
  }
  free(s->norm);
  free(s->phas);
  free(s);
}

variable_types: struct _cvec_t { unsigned int length; unsigned int channels; float **norm; float **phas; } *


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

original_code:
void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
  s->norm[channel][position] = data;
}

canonical_original_code:
void cvec_write_norm(struct _cvec_t *s, float data, unsigned int channel, unsigned int position) {
  s->norm[channel][position] = data;
}

user_defined_types: struct _cvec_t { unsigned int length; unsigned int channels; float **norm; float **phas; }


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

result = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

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

result = *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2);
*(float *)(result + 4LL * a3) = a4;
return result;
}

original_code:
void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position) {
  s->phas[channel][position] = data;
}

canonical_original_code:
void cvec_write_phas(struct _cvec_t *s, float data, unsigned int channel, unsigned int position) {
  s->phas[channel][position] = data;
}


decompiled_code:
float __fastcall cvec_read_norm(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
float __fastcall func9(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * a2) + 4LL * a3);
}

original_code:
smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position) {
  return s->norm[channel][position];
}

canonical_original_code:
float cvec_read_norm(struct _cvec_t *s, unsigned int channel, unsigned int position) {
  return s->norm[channel][position];
}


decompiled_code:
float __fastcall cvec_read_phas(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
float __fastcall func10(__int64 a1, unsigned int a2, unsigned int a3)
{
return *(float *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3);
}

original_code:
smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position) {
  return s->phas[channel][position];
}

canonical_original_code:
float cvec_read_phas(struct _cvec_t *s, unsigned int channel, unsigned int position) {
  return s->phas[channel][position];
}


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

result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

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

result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

original_code:
void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel) {
  s->norm[channel] = data;
}

canonical_original_code:
void cvec_put_norm_channel(struct _cvec_t *s, float *data, unsigned int channel) {
  s->norm[channel] = data;
}


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

result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

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

result = *(_QWORD *)(a1 + 16);
*(_QWORD *)(result + 8LL * a3) = a2;
return result;
}

original_code:
void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel) {
  s->phas[channel] = data;
}

canonical_original_code:
void cvec_put_phas_channel(struct _cvec_t *s, float *data, unsigned int channel) {
  s->phas[channel] = data;
}


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

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

original_code:
smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel) {
  return s->norm[channel];
}

canonical_original_code:
float *cvec_get_norm_channel(struct _cvec_t *s, unsigned int channel) {
  return s->norm[channel];
}


decompiled_code:
__int64 __fastcall cvec_get_phas_channel(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2);
}

original_code:
smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel) {
  return s->phas[channel];
}

canonical_original_code:
float *cvec_get_phas_channel(struct _cvec_t *s, unsigned int channel) {
  return s->phas[channel];
}


decompiled_code:
__int64 __fastcall cvec_get_norm(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
return *(_QWORD *)(a1 + 8);
}

original_code:
smpl_t ** cvec_get_norm(cvec_t *s) {
  return s->norm;
}

canonical_original_code:
float **cvec_get_norm(struct _cvec_t *s) {
  return s->norm;
}


decompiled_code:
__int64 __fastcall cvec_get_phas(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1)
{
return *(_QWORD *)(a1 + 16);
}

original_code:
smpl_t ** cvec_get_phas(cvec_t *s) {
  return s->phas;
}

canonical_original_code:
float **cvec_get_phas(struct _cvec_t *s) {
  return s->phas;
}


freqconvpass

decompiled_code:
void freqconvpass()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
smpl_t freqconvpass(smpl_t f,uint_t srate __attribute__((unused)),uint_t bufsize __attribute__((unused))){
        return f;
}

canonical_original_code:
float freqconvpass(float f, unsigned int srate, unsigned int bufsize){
        return f;
}

variable_types: f float

variable_types:
srate
unsigned int

variable_types:
bufsize
unsigned int


freqconvbin

decompiled_code:
__int64 __fastcall freqconvbin(int a1, int a2, double a3)
{
return aubio_freqtobin(a3, (float)a1, (float)a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2, double a3)
{
return aubio_freqtobin(a3, (float)a1, (float)a2);
}

original_code:
smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize){
        return aubio_freqtobin(f,srate,bufsize);
}

canonical_original_code:
float freqconvbin(float f, unsigned int srate, unsigned int bufsize){
        return aubio_freqtobin(f,srate,bufsize);
}


freqconvmidi

decompiled_code:
// attributes: thunk
__int64 freqconvmidi()
{
return aubio_freqtomidi();
}

canonical_decompiled_code:
__int64 func2()
{
return aubio_freqtomidi();
}

original_code:
smpl_t freqconvmidi(smpl_t f,uint_t srate __attribute__((unused)),uint_t bufsize __attribute__((unused))){
        return aubio_freqtomidi(f);
}

canonical_original_code:
float freqconvmidi(float f, unsigned int srate, unsigned int bufsize){
        return aubio_freqtomidi(f);
}


decompiled_code:
int __fastcall send_noteon(int a1, unsigned int a2)
{
int result; // eax
double v3; // xmm1_8
double v4; // xmm1_8
__m128d v5; // xmm0
float v6; // xmm0_4
__m128d v7; // xmm3

aubio_freqtomidi((float)a1);
result = samplerate;
v3 = (float)((float)(overlap_size * frames) / (float)samplerate) * 48.0;
v4 = v3 + v3;
note_pos = (int)v4;
if ( a1 > 0 )
{
v5.m128d_f64[0] = (float)a1 + 0.5;
if ( COERCE_DOUBLE(*(_QWORD *)&v5.m128d_f64[0] & LC3) < 4.503599627370496e15 )
{
result = (int)v5.m128d_f64[0];
v7.m128d_f64[0] = (double)(int)v5.m128d_f64[0];
*(_QWORD *)&v5.m128d_f64[0] = COERCE_UNSIGNED_INT64(v7.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v5) & LC4)) | ~LC3 & *(_QWORD *)&v5.m128d_f64[0];
}
v6 = v5.m128d_f64[0];
if ( v6 > 0.0 && v6 <= 127.0 && a2 <= 0x7F )
result = fprintf(midi_text, "%d On ch=1 n=%.0f v=%d\n", (unsigned int)(int)v4, v6, a2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(int a1, unsigned int a2)
{
int result; // eax
double v3; // xmm1_8
double v4; // xmm1_8
__m128d v5; // xmm0
float v6; // xmm0_4
__m128d v7; // xmm3

aubio_freqtomidi((float)a1);
result = samplerate;
v3 = (float)((float)(overlap_size * frames) / (float)samplerate) * 48.0;
v4 = v3 + v3;
note_pos = (int)v4;
if ( a1 > 0 )
{
v5.m128d_f64[0] = (float)a1 + 0.5;
if ( COERCE_DOUBLE(*(_QWORD *)&v5.m128d_f64[0] & LC3) < 4.503599627370496e15 )
{
result = (int)v5.m128d_f64[0];
v7.m128d_f64[0] = (double)(int)v5.m128d_f64[0];
*(_QWORD *)&v5.m128d_f64[0] = COERCE_UNSIGNED_INT64(v7.m128d_f64[0] - COERCE_DOUBLE(*(_OWORD *)&_mm_cmpgt_sd(v7, v5) & LC4)) | ~LC3 & *(_QWORD *)&v5.m128d_f64[0];
}
v6 = v5.m128d_f64[0];
if ( v6 > 0.0 && v6 <= 127.0 && a2 <= 0x7F )
result = fprintf(midi_text, "%d On ch=1 n=%.0f v=%d\n", (unsigned int)(int)v4, v6, a2);
}
return result;
}

original_code:
void send_noteon(int pitch, int velo) {
    smpl_t mpitch = floor(aubio_freqtomidi(pitch) + 0.5);
    double curr = frames * overlap_size / (float) samplerate;
    note_pos = curr * note_velocity * 2;
    if (pitch <= 0 || mpitch <=0 || mpitch > 127 || velo < 0 || velo > 127) return;
    fprintf(midi_text, "%d On ch=1 n=%.0f v=%d\n", note_pos, mpitch, velo);
}

canonical_original_code:
void send_noteon(int pitch, int velo) {
    float mpitch = floor(aubio_freqtomidi(pitch) + 0.5);
    double curr = frames * overlap_size / (float) samplerate;
    note_pos = curr * note_velocity * 2;
    if (pitch <= 0 || mpitch <=0 || mpitch > 127 || velo < 0 || velo > 127) return;
    fprintf(midi_text, "%d On ch=1 n=%.0f v=%d\n", note_pos, mpitch, velo);
}

variable_types: pitch int

variable_types: velo int

variable_types: mpitch float

variable_types: curr double


decompiled_code:
unsigned __int64 __fastcall note_append(__int64 a1, float a2)
{
float *v2; // rcx
unsigned __int64 result; // rax
size_t v4; // rbx

v2 = **(float ***)(a1 + 8);
result = (unsigned int)(*(_DWORD *)a1 - 1);
if ( *(_DWORD *)a1 == 1 )
{
*v2 = a2;
}
else
{
v4 = 4LL * (unsigned int)result;
result = (unsigned __int64)memmove(v2, v2 + 1, v4);
*(float *)(v4 + result) = a2;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__int64 a1, float a2)
{
float *v2; // rcx
unsigned __int64 result; // rax
size_t v4; // rbx

v2 = **(float ***)(a1 + 8);
result = (unsigned int)(*(_DWORD *)a1 - 1);
if ( *(_DWORD *)a1 == 1 )
{
*v2 = a2;
}
else
{
v4 = 4LL * (unsigned int)result;
result = (unsigned __int64)memmove(v2, v2 + 1, v4);
*(float *)(v4 + result) = a2;
}
return result;
}

original_code:
void note_append(fvec_t * note_buffer, smpl_t curnote) {
  uint_t i = 0;
  for (i = 0; i < note_buffer->length - 1; i++) {
      note_buffer->data[0][i] = note_buffer->data[0][i+1];
  }
  note_buffer->data[0][note_buffer->length - 1] = curnote;
  return;
}

canonical_original_code:
void note_append(struct _fvec_t *note_buffer, float curnote) {
  unsigned int i = 0;
  for (i = 0; i < note_buffer->length - 1; i++) {
      note_buffer->data[0][i] = note_buffer->data[0][i+1];
  }
  note_buffer->data[0][note_buffer->length - 1] = curnote;
  return;
}

variable_types: curnote float


decompiled_code:
__int64 __fastcall get_note(unsigned int *a1, __int64 a2)
{
__int64 v4; // rdx
__int64 v5; // rsi
__int64 v6; // rcx
__int64 i; // rax

v4 = *a1;
if ( (_DWORD)v4 )
{
v5 = **((_QWORD **)a1 + 1);
v6 = **(_QWORD **)(a2 + 8);
for ( i = 0LL; i != v4; ++i )
*(_DWORD *)(v6 + 4 * i) = *(_DWORD *)(v5 + 4 * i);
}
return (unsigned int)(int)vec_median(a2);
}

original_code:
uint_t get_note(fvec_t *note_buffer, fvec_t *note_buffer2) {
  uint_t i = 0;
  for (i = 0; i < note_buffer->length; i++) {
      note_buffer2->data[0][i] = note_buffer->data[0][i];
  }
  return vec_median(note_buffer2);
}

canonical_original_code:
unsigned int get_note(struct _fvec_t *note_buffer, struct _fvec_t *note_buffer2) {
  unsigned int i = 0;
  for (i = 0; i < note_buffer->length; i++) {
      note_buffer2->data[0][i] = note_buffer->data[0][i];
  }
  return vec_median(note_buffer2);
}

return_type: unsigned int


process

decompiled_code:
__int64 __fastcall process(__int64 a1, __int64 a2, int a3)
{
int v4; // edx
int i; // ebx
__int64 v6; // rdi
float v7; // xmm0_4
float v8; // xmm0_4
int v10; // eax
float v11; // xmm0_4
float v12; // xmm1_4
__m128 v13; // xmm3

v4 = pos;
if ( a3 )
{
for ( i = 0; i != a3; ++i )
{
while ( overlap_size - 1 != v4 )
{
++v4;
++i;
pos = v4;
if ( i == a3 )
return 1LL;
}
aubio_pvoc_do(pv, ibuf, fftgrain);
aubio_onsetdetection(o, fftgrain, onset);
v6 = onset;
if ( usedoubled )
{
aubio_onsetdetection(o2, fftgrain, onset2);
v6 = onset;
***(float ***)(onset + 8LL) = ***(float ***)(onset + 8LL) * ***(float ***)(onset2 + 8LL);
}
isonset = aubio_peakpick_pimrt(v6, parms);
v7 = aubio_pitchdetection(pitchdet, ibuf);
pitch = LODWORD(v7);
if ( median )
note_append(note_buffer, v7);
v8 = aubio_level_detection(ibuf, silence);
curlevel = LODWORD(v8);
if ( isonset )
{
if ( COERCE_FLOAT(COERCE_UNSIGNED_INT(v8 - 1.0) & LC9) < 0.000001 )
{
isonset = 0;
isready = 0;
send_noteon((int)curnote, 0);
v4 = 0;
goto LABEL_13;
}
isready = 1;
}
else
{
v10 = isready;
if ( isready )
v10 = ++isready;
if ( median == v10 )
{
send_noteon((int)curnote, 0);
v11 = (float)(int)get_note(note_buffer, note_buffer2);
newnote = v11;
curnote = v11;
if ( v11 > 45.0 )
{
v12 = curlevel;
if ( COERCE_FLOAT(LC13 & curlevel) < 8388608.0 )
{
v13.m128_f32[0] = (float)(int)curlevel;
LODWORD(v12) = COERCE_UNSIGNED_INT(v13.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v13, (__m128)curlevel).m128_u32[0] & LC8)) | _mm_andnot_ps((__m128)(unsigned int)LC13, (__m128)curlevel).m128_u32[0];
}
send_noteon((int)v11, (int)v12 + 127);
v4 = 0;
goto LABEL_13;
}
}
}
v4 = 0;
LABEL_13:
pos = 0;
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
int v4; // edx
int i; // ebx
__int64 v6; // rdi
float v7; // xmm0_4
float v8; // xmm0_4
int v10; // eax
float v11; // xmm0_4
float v12; // xmm1_4
__m128 v13; // xmm3

v4 = pos;
if ( a3 )
{
for ( i = 0; i != a3; ++i )
{
while ( overlap_size - 1 != v4 )
{
++v4;
++i;
pos = v4;
if ( i == a3 )
return 1LL;
}
aubio_pvoc_do(pv, ibuf, fftgrain);
aubio_onsetdetection(o, fftgrain, onset);
v6 = onset;
if ( usedoubled )
{
aubio_onsetdetection(o2, fftgrain, onset2);
v6 = onset;
***(float ***)(onset + 8LL) = ***(float ***)(onset + 8LL) * ***(float ***)(onset2 + 8LL);
}
isonset = aubio_peakpick_pimrt(v6, parms);
v7 = aubio_pitchdetection(pitchdet, ibuf);
pitch = LODWORD(v7);
if ( median )
func1(note_buffer, v7);
v8 = aubio_level_detection(ibuf, silence);
curlevel = LODWORD(v8);
if ( isonset )
{
if ( COERCE_FLOAT(COERCE_UNSIGNED_INT(v8 - 1.0) & LC9) < 0.000001 )
{
isonset = 0;
isready = 0;
func0((int)curnote, 0);
v4 = 0;
goto LABEL_13;
}
isready = 1;
}
else
{
v10 = isready;
if ( isready )
v10 = ++isready;
if ( median == v10 )
{
func0((int)curnote, 0);
v11 = (float)(int)func2(note_buffer, note_buffer2);
newnote = v11;
curnote = v11;
if ( v11 > 45.0 )
{
v12 = curlevel;
if ( COERCE_FLOAT(LC13 & curlevel) < 8388608.0 )
{
v13.m128_f32[0] = (float)(int)curlevel;
LODWORD(v12) = COERCE_UNSIGNED_INT(v13.m128_f32[0] - COERCE_FLOAT(_mm_cmpgt_ss(v13, (__m128)curlevel).m128_u32[0] & LC8)) | _mm_andnot_ps((__m128)(unsigned int)LC13, (__m128)curlevel).m128_u32[0];
}
func0((int)v11, (int)v12 + 127);
v4 = 0;
goto LABEL_13;
}
}
}
v4 = 0;
LABEL_13:
pos = 0;
}
}
return 1LL;
}

original_code:
int process(float **input, float **output, int nframes) {
  unsigned int i;
  unsigned int j;
  for (j=0;j<(unsigned)nframes;j++) {
    if (pos == overlap_size - 1) {
      aubio_pvoc_do(pv, ibuf, fftgrain);
      aubio_onsetdetection(o, fftgrain, onset);
      if (usedoubled) {
        aubio_onsetdetection(o2, fftgrain, onset2);
        onset->data[0][0] *= onset2->data[0][0];
      }
      isonset = aubio_peakpick_pimrt(onset,parms);
      pitch = aubio_pitchdetection(pitchdet,ibuf);
      if (median) {
        note_append(note_buffer, pitch);
      }
      curlevel = aubio_level_detection(ibuf, silence);
      if (isonset) {
        if (fabs(curlevel - 1) < 1e-6) {
          isonset = 0;
          isready = 0;
          send_noteon(curnote, 0);
        } else {
          isready = 1;
        }
      } else {
        if (isready > 0) {
          isready++;
        }
        if (isready == median) {
          send_noteon(curnote, 0);
          newnote = get_note(note_buffer, note_buffer2);
          curnote = newnote;
          if (curnote > 45) {
            send_noteon(curnote, 127 + (int)floor(curlevel));
          }
        }
      }
      pos = -1;
    }
    pos++;
  }
  return 1;
}

canonical_original_code:
int process(float **input, float **output, int nframes) {
  unsigned int i;
  unsigned int j;
  for (j=0;j<(unsigned int)nframes;j++) {
    if (pos == overlap_size - 1) {
      aubio_pvoc_do(pv, ibuf, fftgrain);
      aubio_onsetdetection(o, fftgrain, onset);
      if (usedoubled) {
        aubio_onsetdetection(o2, fftgrain, onset2);
        onset->data[0][0] *= onset2->data[0][0];
      }
      isonset = aubio_peakpick_pimrt(onset,parms);
      pitch = aubio_pitchdetection(pitchdet,ibuf);
      if (median) {
        note_append(note_buffer, pitch);
      }
      curlevel = aubio_level_detection(ibuf, silence);
      if (isonset) {
        if (fabs(curlevel - 1) < 1e-6) {
          isonset = 0;
          isready = 0;
          send_noteon(curnote, 0);
        } else {
          isready = 1;
        }
      } else {
        if (isready > 0) {
          isready++;
        }
        if (isready == median) {
          send_noteon(curnote, 0);
          newnote = get_note(note_buffer, note_buffer2);
          curnote = newnote;
          if (curnote > 45) {
            send_noteon(curnote, 127 + (int)floor(curlevel));
          }
        }
      }
      pos = -1;
    }
    pos++;
  }
  return 1;
}

variable_types:
input
float **

variable_types:
output
float **

variable_types: nframes int

variable_types:
j
unsigned int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
common_init(argc, argv, envp);
midi_text = fopen("notes.txt", "w");
fprintf(midi_text, "MFile 0 1 %d\n", 48LL);
fwrite("MTrk\n", 1uLL, 5uLL, midi_text);
fwrite("0 Meta Text \"Notes\"\n", 1uLL, 0x14uLL, midi_text);
common_process(process);
send_noteon((int)curnote, 0);
common_del();
note_pos += 192;
fprintf(midi_text, "%d Meta TrkEnd\n", (unsigned int)note_pos);
fwrite("TrkEnd\n", 1uLL, 7uLL, midi_text);
fclose(midi_text);
toMIDI("notes.txt", "notes.mid");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
common_init(argc, argv, envp);
midi_text = fopen("notes.txt", "w");
fprintf(midi_text, "MFile 0 1 %d\n", 48LL);
fwrite("MTrk\n", 1uLL, 5uLL, midi_text);
fwrite("0 Meta Text \"Notes\"\n", 1uLL, 0x14uLL, midi_text);
common_process(process);
func0((int)curnote, 0);
common_del();
note_pos += 192;
fprintf(midi_text, "%d Meta TrkEnd\n", (unsigned int)note_pos);
fwrite("TrkEnd\n", 1uLL, 7uLL, midi_text);
fclose(midi_text);
toMIDI("notes.txt", "notes.mid");
return 0;
}

original_code:
int main(int argc, char **argv) {
  common_init(argc, argv);
  midi_text = fopen("notes.txt", "w");
  fprintf(midi_text, "MFile 0 1 %d\n", note_velocity);
  fprintf(midi_text, "MTrk\n");
  fprintf(midi_text, "0 Meta Text \"Notes\"\n");
  common_process(process);
  send_noteon(curnote, 0);
  common_del();
  note_pos += note_velocity * 2 * 2;
  fprintf(midi_text, "%d Meta TrkEnd\n", note_pos);
  fprintf(midi_text, "TrkEnd\n");
  fclose(midi_text);
  toMIDI("notes.txt", "notes.mid");
  return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 yy_get_previous_state()
{
int v0; // er8
char *v1; // rdi
int v2; // er11
__int64 v3; // r10
char v4; // r9
__int64 v5; // rax
int v6; // esi
__int64 v7; // rdx
__int64 v8; // rax

v0 = yy_start;
v1 = (char *)yytext;
if ( yy_doing_yy_more )
v1 = (char *)(yy_more_len + yytext);
if ( yy_c_buf_p > (unsigned __int64)v1 )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
do
{
v5 = *v1;
v6 = 1;
if ( (_BYTE)v5 )
v6 = yy_ec[v5];
v7 = v0;
if ( yy_accept[v0] )
v3 = (__int64)v1;
if ( yy_accept[v0] )
{
v2 = v0;
if ( yy_accept[v0] )
v4 = 1;
}
v8 = v6 + yy_base[v0];
if ( yy_chk[v8] != v0 )
{
do
{
v7 = yy_def[v7];
v8 = v6 + yy_base[v7];
}
while ( (_WORD)v7 != yy_chk[v8] );
}
v0 = yy_nxt[v8];
++v1;
}
while ( v1 != (char *)yy_c_buf_p );
if ( v4 )
{
yy_last_accepting_state = v2;
yy_last_accepting_cpos = v3;
}
}
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // er8
char *v1; // rdi
int v2; // er11
__int64 v3; // r10
char v4; // r9
__int64 v5; // rax
int v6; // esi
__int64 v7; // rdx
__int64 v8; // rax

v0 = yy_start;
v1 = (char *)yytext;
if ( yy_doing_yy_more )
v1 = (char *)(yy_more_len + yytext);
if ( yy_c_buf_p > (unsigned __int64)v1 )
{
v2 = yy_last_accepting_state;
v3 = yy_last_accepting_cpos;
v4 = 0;
do
{
v5 = *v1;
v6 = 1;
if ( (_BYTE)v5 )
v6 = yy_ec[v5];
v7 = v0;
if ( yy_accept[v0] )
v3 = (__int64)v1;
if ( yy_accept[v0] )
{
v2 = v0;
if ( yy_accept[v0] )
v4 = 1;
}
v8 = v6 + yy_base[v0];
if ( yy_chk[v8] != v0 )
{
do
{
v7 = yy_def[v7];
v8 = v6 + yy_base[v7];
}
while ( (_WORD)v7 != yy_chk[v8] );
}
v0 = yy_nxt[v8];
++v1;
}
while ( v1 != (char *)yy_c_buf_p );
if ( v4 )
{
yy_last_accepting_state = v2;
yy_last_accepting_cpos = v3;
}
}
return (unsigned int)v0;
}

original_code:
static yy_state_type yy_get_previous_state()
    {
    register yy_state_type yy_current_state;
    register char *yy_cp;
    yy_current_state = yy_start;
    for ( yy_cp = yytext + (yy_doing_yy_more ? yy_more_len : 0); yy_cp < yy_c_buf_p; ++yy_cp )
 {
 register char yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
 if ( yy_accept[yy_current_state] )
     {
     yy_last_accepting_state = yy_current_state;
     yy_last_accepting_cpos = yy_cp;
     }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
     {
     yy_current_state = yy_def[yy_current_state];
     }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 }
    return ( yy_current_state );
    }

canonical_original_code:
static int yy_get_previous_state()
    {
    register int yy_current_state;
    register char *yy_cp;
    yy_current_state = yy_start;
    for ( yy_cp = yytext + (yy_doing_yy_more ? yy_more_len : 0); yy_cp < yy_c_buf_p; ++yy_cp )
 {
 register char yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
 if ( yy_accept[yy_current_state] )
     {
     yy_last_accepting_state = yy_current_state;
     yy_last_accepting_cpos = yy_cp;
     }
 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
     {
     yy_current_state = yy_def[yy_current_state];
     }
 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 }
    return ( yy_current_state );
    }


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

v1 = a1;
if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v2 = yy_base[a1] + 1;
if ( a1 != yy_chk[v2] )
{
do
{
v1 = yy_def[v1];
v2 = yy_base[v1] + 1;
}
while ( (_WORD)v1 != yy_chk[v2] );
}
result = (unsigned int)yy_nxt[v2];
if ( (_DWORD)result == 184 )
result = 0LL;
return result;
}

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

v1 = a1;
if ( yy_accept[a1] )
{
yy_last_accepting_state = a1;
yy_last_accepting_cpos = yy_c_buf_p;
}
v2 = yy_base[a1] + 1;
if ( a1 != yy_chk[v2] )
{
do
{
v1 = yy_def[v1];
v2 = yy_base[v1] + 1;
}
while ( (_WORD)v1 != yy_chk[v2] );
}
result = (unsigned int)yy_nxt[v2];
if ( (_DWORD)result == 184 )
result = 0LL;
return result;
}

original_code:
static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
    {
    register int yy_is_jam;
    register char *yy_cp = yy_c_buf_p;
    register char yy_c = 1;
    if ( yy_accept[yy_current_state] )
 {
 yy_last_accepting_state = yy_current_state;
 yy_last_accepting_cpos = yy_cp;
 }
    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 {
 yy_current_state = yy_def[yy_current_state];
 }
    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
    yy_is_jam = (yy_current_state == 184);
    return ( yy_is_jam ? 0 : yy_current_state );
    }

canonical_original_code:
static int yy_try_NUL_trans(int yy_current_state)
    {
    register int yy_is_jam;
    register char *yy_cp = yy_c_buf_p;
    register char yy_c = 1;
    if ( yy_accept[yy_current_state] )
 {
 yy_last_accepting_state = yy_current_state;
 yy_last_accepting_cpos = yy_cp;
 }
    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 {
 yy_current_state = yy_def[yy_current_state];
 }
    yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
    yy_is_jam = (yy_current_state == 184);
    return ( yy_is_jam ? 0 : yy_current_state );
    }


decompiled_code:
__int64 yy_get_next_buffer()
{
__int64 v0; // r8
__int64 v1; // rcx
__int64 v2; // rsi
int v3; // ebx
__int64 v4; // rax
__int64 v5; // rdi
__int64 v6; // rdx
unsigned int v7; // er12
int v8; // er13
void *v9; // rbp
int v10; // eax
int v11; // eax
bool v12; // zf
int v13; // eax
__int64 v14; // rdx
size_t v16; // rdx
const char *v17; // rdi
FILE *v18; // rcx

v0 = yy_current_buffer;
v1 = yytext;
v2 = *(_QWORD *)(yy_current_buffer + 8);
if ( yy_c_buf_p > (unsigned __int64)(v2 + yy_n_chars + 1) )
{
v16 = 55LL;
v17 = "fatal flex scanner internal error--end of buffer missed";
v18 = stderr;
goto LABEL_16;
}
v3 = yy_c_buf_p - yytext;
v4 = 0LL;
v5 = (unsigned int)(yy_c_buf_p - yytext - 1);
if ( (int)yy_c_buf_p - (int)yytext > 0 )
{
do
{
*(_BYTE *)(v2 + v4) = *(_BYTE *)(v1 + v4 - 1);
v6 = v4++;
}
while ( v6 != v5 );
}
v7 = *(_DWORD *)(v0 + 32);
if ( !v7 )
{
v8 = *(_DWORD *)(v0 + 24) + ~v3;
if ( v8 > 0x2000 )
{
v8 = 0x2000;
}
else if ( v8 <= 0 )
{
v16 = 43LL;
v17 = "fatal error - scanner input buffer overflow";
v18 = stderr;
goto LABEL_16;
}
v9 = (void *)(*(_QWORD *)(v0 + 8) + v3);
v10 = fileno(yyin);
v11 = read(v10, v9, (unsigned int)v8);
yy_n_chars = v11;
v12 = v11 == 0;
if ( v11 >= 0 )
{
v0 = yy_current_buffer;
v13 = v11 + v3;
if ( !v12 )
goto LABEL_9;
goto LABEL_11;
}
v16 = 29LL;
v17 = "read() in flex scanner failed";
v18 = stderr;
LABEL_16:
fwrite(v17, 1uLL, v16, v18);
putc(10, stderr);
exit(1);
}
v13 = v3;
LABEL_11:
if ( v3 == 1 )
{
*(_DWORD *)(v0 + 32) = 2;
v7 = 1;
}
else
{
*(_DWORD *)(v0 + 32) = 1;
v7 = 2;
}
LABEL_9:
v14 = *(_QWORD *)(v0 + 8);
yy_n_chars = v13;
*(_BYTE *)(v14 + v13) = 0;
*(_BYTE *)(*(_QWORD *)(v0 + 8) + v13 + 1LL) = 0;
yytext = *(_QWORD *)(v0 + 8) + 1LL;
return v7;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // r8
__int64 v1; // rcx
__int64 v2; // rsi
int v3; // ebx
__int64 v4; // rax
__int64 v5; // rdi
__int64 v6; // rdx
unsigned int v7; // er12
int v8; // er13
void *v9; // rbp
int v10; // eax
int v11; // eax
bool v12; // zf
int v13; // eax
__int64 v14; // rdx
size_t v16; // rdx
const char *v17; // rdi
FILE *v18; // rcx

v0 = yy_current_buffer;
v1 = yytext;
v2 = *(_QWORD *)(yy_current_buffer + 8);
if ( yy_c_buf_p > (unsigned __int64)(v2 + yy_n_chars + 1) )
{
v16 = 55LL;
v17 = "fatal flex scanner internal error--end of buffer missed";
v18 = stderr;
goto LABEL_16;
}
v3 = yy_c_buf_p - yytext;
v4 = 0LL;
v5 = (unsigned int)(yy_c_buf_p - yytext - 1);
if ( (int)yy_c_buf_p - (int)yytext > 0 )
{
do
{
*(_BYTE *)(v2 + v4) = *(_BYTE *)(v1 + v4 - 1);
v6 = v4++;
}
while ( v6 != v5 );
}
v7 = *(_DWORD *)(v0 + 32);
if ( !v7 )
{
v8 = *(_DWORD *)(v0 + 24) + ~v3;
if ( v8 > 0x2000 )
{
v8 = 0x2000;
}
else if ( v8 <= 0 )
{
v16 = 43LL;
v17 = "fatal error - scanner input buffer overflow";
v18 = stderr;
goto LABEL_16;
}
v9 = (void *)(*(_QWORD *)(v0 + 8) + v3);
v10 = fileno(yyin);
v11 = read(v10, v9, (unsigned int)v8);
yy_n_chars = v11;
v12 = v11 == 0;
if ( v11 >= 0 )
{
v0 = yy_current_buffer;
v13 = v11 + v3;
if ( !v12 )
goto LABEL_9;
goto LABEL_11;
}
v16 = 29LL;
v17 = "read() in flex scanner failed";
v18 = stderr;
LABEL_16:
fwrite(v17, 1uLL, v16, v18);
putc(10, stderr);
exit(1);
}
v13 = v3;
LABEL_11:
if ( v3 == 1 )
{
*(_DWORD *)(v0 + 32) = 2;
v7 = 1;
}
else
{
*(_DWORD *)(v0 + 32) = 1;
v7 = 2;
}
LABEL_9:
v14 = *(_QWORD *)(v0 + 8);
yy_n_chars = v13;
*(_BYTE *)(v14 + v13) = 0;
*(_BYTE *)(*(_QWORD *)(v0 + 8) + v13 + 1LL) = 0;
yytext = *(_QWORD *)(v0 + 8) + 1LL;
return v7;
}

original_code:
static int yy_get_next_buffer()
    {
    register char *dest = yy_current_buffer->yy_ch_buf;
    register char *source = yytext - 1;
    register int number_to_move, i;
    int ret_val;
    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
 do { (void) fputs( "fatal flex scanner internal error--end of buffer missed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
    number_to_move = yy_c_buf_p - yytext;
    for ( i = 0; i < number_to_move; ++i )
 *(dest++) = *(source++);
    if ( yy_current_buffer->yy_eof_status != 0 )
 yy_n_chars = 0;
    else
 {
 int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
 if ( num_to_read > 8192 )
     num_to_read = 8192;
 else if ( num_to_read <= 0 )
     do { (void) fputs( "fatal error - scanner input buffer overflow", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
 if ( (yy_n_chars = read( fileno(yyin), (char *) (&yy_current_buffer->yy_ch_buf[number_to_move]), num_to_read )) < 0 ) do { (void) fputs( "read() in flex scanner failed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );;
 }
    if ( yy_n_chars == 0 )
 {
 if ( number_to_move == 1 )
     {
     ret_val = 1;
     yy_current_buffer->yy_eof_status = 2;
     }
 else
     {
     ret_val = 2;
     yy_current_buffer->yy_eof_status = 1;
     }
 }
    else
 ret_val = 0;
    yy_n_chars += number_to_move;
    yy_current_buffer->yy_ch_buf[yy_n_chars] = 0;
    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = 0;
    yytext = &yy_current_buffer->yy_ch_buf[1];
    return ( ret_val );
    }

canonical_original_code:
static int yy_get_next_buffer()
    {
    register char *dest = yy_current_buffer->yy_ch_buf;
    register char *source = yytext - 1;
    register int number_to_move; register int i;
    int ret_val;
    if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
 do { (void) fputs( "fatal flex scanner internal error--end of buffer missed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
    number_to_move = yy_c_buf_p - yytext;
    for ( i = 0; i < number_to_move; ++i )
 *(dest++) = *(source++);
    if ( yy_current_buffer->yy_eof_status != 0 )
 yy_n_chars = 0;
    else
 {
 int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
 if ( num_to_read > 8192 )
     num_to_read = 8192;
 else if ( num_to_read <= 0 )
     do { (void) fputs( "fatal error - scanner input buffer overflow", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
 if ( (yy_n_chars = read( fileno(yyin), (char *) (&yy_current_buffer->yy_ch_buf[number_to_move]), num_to_read )) < 0 ) do { (void) fputs( "read() in flex scanner failed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );;
 }
    if ( yy_n_chars == 0 )
 {
 if ( number_to_move == 1 )
     {
     ret_val = 1;
     yy_current_buffer->yy_eof_status = 2;
     }
 else
     {
     ret_val = 2;
     yy_current_buffer->yy_eof_status = 1;
     }
 }
    else
 ret_val = 0;
    yy_n_chars += number_to_move;
    yy_current_buffer->yy_ch_buf[yy_n_chars] = 0;
    yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = 0;
    yytext = &yy_current_buffer->yy_ch_buf[1];
    return ( ret_val );
    }

variable_types:
dest
char *

variable_types:
source
char *

variable_types: i int


decompiled_code:
__int64 yy_load_buffer_state()
{
FILE *v0; // rdx
__int64 result; // rax

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
v0 = *(FILE **)yy_current_buffer;
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = yy_c_buf_p;
yyin = v0;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
FILE *v0; // rdx
__int64 result; // rax

yy_n_chars = *(_DWORD *)(yy_current_buffer + 28);
v0 = *(FILE **)yy_current_buffer;
yy_c_buf_p = *(_QWORD *)(yy_current_buffer + 16);
yytext = yy_c_buf_p;
yyin = v0;
result = *(unsigned __int8 *)yy_c_buf_p;
yy_hold_char = *(_BYTE *)yy_c_buf_p;
return result;
}

original_code:
void yy_load_buffer_state( void )
    {
    yy_n_chars = yy_current_buffer->yy_n_chars;
    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
    yyin = yy_current_buffer->yy_input_file;
    yy_hold_char = *yy_c_buf_p;
    }

canonical_original_code:
void yy_load_buffer_state()
    {
    yy_n_chars = yy_current_buffer->yy_n_chars;
    yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
    yyin = yy_current_buffer->yy_input_file;
    yy_hold_char = *yy_c_buf_p;
    }


yylex

decompiled_code:
__int64 yylex()
{
__int64 v0; // r10
__int64 v1; // rdi
__int16 v2; // r14
int v3; // eax
char *v4; // rbx
__int64 v5; // rdx
int v6; // er9
__int64 v7; // r8
__int64 v8; // r13
__int64 v9; // rcx
_BYTE *v10; // rbp
int v11; // esi
int v12; // edx
__int64 v13; // rax
__int64 v14; // r11
int v15; // eax
unsigned __int64 v16; // rdx
struct _IO_FILE *v17; // r8
__int64 v18; // rdi
__int64 result; // rax
__int64 v20; // rdx
int v21; // ebx
int v22; // eax
size_t v23; // rdx
const char *v24; // rdi
FILE *v25; // rcx
int v26; // eax
int v27; // eax
__int64 v28; // rax
__int64 v29; // rbx
int v30; // eax
int v31; // eax
__int64 v32; // rax

if ( do_hex )
{
v0 = 5LL;
yy_start = 5;
do_hex = 0;
eol_seen = 0;
if ( !yy_init )
goto LABEL_3;
LABEL_23:
v17 = yyin;
if ( !yyin )
goto LABEL_32;
LABEL_24:
if ( !yyout )
goto LABEL_35;
goto LABEL_25;
}
v0 = yy_start;
eol_seen = 0;
if ( !yy_init )
goto LABEL_3;
if ( yy_start )
goto LABEL_23;
v17 = yyin;
yy_start = 1;
if ( yyin )
goto LABEL_24;
LABEL_32:
v17 = stdin;
yyin = stdin;
if ( !yyout )
{
LABEL_35:
v18 = yy_current_buffer;
yyout = (__int64)stdout;
if ( !yy_current_buffer )
goto LABEL_34;
goto LABEL_26;
}
LABEL_25:
v18 = yy_current_buffer;
if ( !yy_current_buffer )
{
LABEL_34:
yy_current_buffer = yy_create_buffer((__int64)v17, 0x4000);
goto LABEL_27;
}
LABEL_26:
yy_init_buffer(v18, (__int64)v17);
LABEL_27:
yy_load_buffer_state();
v0 = yy_start;
yy_init = 0;
LABEL_3:
v1 = yy_more_flag;
v2 = yy_accept[(int)v0];
v3 = yy_base[(int)v0];
LABEL_4:
yy_more_len = 0;
yy_doing_yy_more = v1;
if ( (_DWORD)v1 )
{
v1 = yyleng;
yy_more_flag = 0;
yy_more_len = yyleng;
}
v4 = (char *)yy_c_buf_p;
v5 = yy_hold_char;
v6 = yy_last_accepting_state;
v7 = yy_last_accepting_cpos;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v8 = (__int64)v4;
LABEL_7:
v9 = v6;
v10 = (_BYTE *)v7;
v11 = 0;
while ( 1 )
{
v12 = yy_ec[v5];
if ( v2 )
v9 = v0;
if ( v2 )
{
v10 = v4;
v11 = 1;
}
v13 = v12 + v3;
if ( (_DWORD)v0 != yy_chk[v13] )
{
v14 = (int)v0;
do
{
v14 = yy_def[v14];
v13 = v12 + yy_base[v14];
}
while ( (_WORD)v14 != yy_chk[v13] );
}
v0 = yy_nxt[v13];
++v4;
if ( (_DWORD)v0 == 184 )
break;
v5 = *v4;
v2 = yy_accept[yy_nxt[v13]];
v3 = yy_base[yy_nxt[v13]];
}
if ( (_BYTE)v11 )
{
yy_last_accepting_cpos = (__int64)v10;
yy_last_accepting_state = v9;
}
else
{
v10 = (_BYTE *)v7;
v9 = v6;
}
while ( 1 )
{
v15 = yy_accept[v9];
yy_c_buf_p = (__int64)v10;
yytext = v8 - v1;
yyleng = (_DWORD)v10 - (v8 - v1);
v16 = (unsigned __int8)*v10;
*v10 = 0;
yy_hold_char = v16;
LABEL_21:
switch ( v15 )
{
case 0:
v9 = yy_last_accepting_state;
v1 = yy_more_len;
*v10 = yy_hold_char;
v10 = (_BYTE *)yy_last_accepting_cpos;
continue;
case 1:
v0 = yy_start;
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 2:
case 48:
v0 = yy_start;
++lineno;
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 3:
return 256LL;
case 4:
return 257LL;
case 5:
return 258LL;
case 6:
return 144LL;
case 7:
return 128LL;
case 8:
return 160LL;
case 9:
return 176LL;
case 10:
return 224LL;
case 11:
return 192LL;
case 12:
return 208LL;
case 13:
return 240LL;
case 14:
return 273LL;
case 15:
return 401LL;
case 16:
return 275LL;
case 17:
return 276LL;
case 18:
return 277LL;
case 19:
return 278LL;
case 20:
return 279LL;
case 21:
return 280LL;
case 22:
return 281LL;
case 23:
return 274LL;
case 24:
return 363LL;
case 25:
return 355LL;
case 26:
return 362LL;
case 27:
return 358LL;
case 28:
return 259LL;
case 29:
return 47LL;
case 30:
return 260LL;
case 31:
return 261LL;
case 32:
return 262LL;
case 33:
return 263LL;
case 34:
return 264LL;
case 35:
return 265LL;
case 36:
return 266LL;
case 37:
_isoc99_sscanf(yytext, "%ld", &yyval);
return 267LL;
case 38:
_isoc99_sscanf(yytext + 2, "%lx", &yyval);
return 267LL;
case 39:
yyval = bankno(yytext + 1, (unsigned int)(yyleng - 1));
return 267LL;
case 40:
_isoc99_sscanf(yytext, "%lx", &yyval);
return 267LL;
case 41:
return 271LL;
case 42:
yy_start = 3;
v1 = yy_more_flag;
v3 = 36;
v2 = 43;
v0 = 3LL;
goto LABEL_4;
case 43:
case 45:
v0 = yy_start;
v1 = 1LL;
yy_more_flag = 1;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 44:
yy_start = 1;
return 268LL;
case 46:
error((int)"unterminated string", v11, (const char *)v16);
++lineno;
result = 272LL;
++eol_seen;
yy_start = 1;
return result;
case 49:
++lineno;
result = 272LL;
++eol_seen;
yy_start = 1;
return result;
case 50:
case 51:
yy_start = 1;
return 270LL;
case 52:
case 53:
return 270LL;
case 55:
v23 = 19LL;
v24 = "flex scanner jammed";
v25 = stderr;
goto LABEL_95;
case 56:
v20 = yy_current_buffer;
v21 = (_DWORD)v10 - yytext - 1;
*v10 = yy_hold_char;
if ( yy_c_buf_p <= (unsigned __int64)(*(_QWORD *)(v20 + 8) + yy_n_chars) )
{
v29 = yytext + v21;
yy_c_buf_p = v29;
v30 = yy_get_previous_state();
v31 = yy_try_NUL_trans(v30);
v1 = yy_more_len;
v7 = yy_last_accepting_cpos;
v0 = v31;
v32 = yy_doing_yy_more;
v6 = yy_last_accepting_state;
v10 = (_BYTE *)yy_last_accepting_cpos;
v9 = yy_last_accepting_state;
if ( yy_doing_yy_more )
v32 = yy_more_len;
v8 = yytext + v32;
if ( (_DWORD)v0 )
{
v4 = (char *)(v29 + 1);
yy_c_buf_p = (__int64)v4;
LABEL_100:
v5 = *v4;
v2 = yy_accept[(int)v0];
v3 = yy_base[(int)v0];
goto LABEL_7;
}
}
else
{
v22 = yy_get_next_buffer();
if ( v22 == 1 )
{
v11 = yy_doing_yy_more;
v28 = yytext;
if ( yy_doing_yy_more )
v28 = yy_more_len + yytext;
yy_c_buf_p = v28;
v16 = (unsigned int)(yy_start - 1);
v15 = (yy_start - 1) / 2 + 57;
goto LABEL_21;
}
if ( v22 != 2 )
{
if ( v22 )
{
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v0 = yy_start;
v3 = yy_base[yy_start];
goto LABEL_4;
}
v4 = (char *)(yytext + v21);
yy_c_buf_p = (__int64)v4;
v26 = yy_get_previous_state();
v8 = yytext;
v1 = yy_more_len;
v0 = v26;
if ( yy_doing_yy_more )
v8 = yy_more_len + yytext;
v6 = yy_last_accepting_state;
v7 = yy_last_accepting_cpos;
goto LABEL_100;
}
v10 = (_BYTE *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v10;
v27 = yy_get_previous_state();
v1 = yy_more_len;
v9 = v27;
v8 = yy_more_len + yytext;
if ( !yy_doing_yy_more )
v8 = yytext;
}
break;
case 57:
case 59:
return 0xFFFFFFFFLL;
case 58:
error((int)"EOF in string", v11, (const char *)v16);
return 0xFFFFFFFFLL;
default:
v23 = 50LL;
v24 = "fatal flex scanner internal error--no action found";
v25 = stderr;
LABEL_95:
fwrite(v24, 1uLL, v23, v25);
putc(10, stderr);
exit(1);
}
}
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // r10
__int64 v1; // rdi
__int16 v2; // r14
int v3; // eax
char *v4; // rbx
__int64 v5; // rdx
int v6; // er9
__int64 v7; // r8
__int64 v8; // r13
__int64 v9; // rcx
_BYTE *v10; // rbp
int v11; // esi
int v12; // edx
__int64 v13; // rax
__int64 v14; // r11
int v15; // eax
unsigned __int64 v16; // rdx
struct _IO_FILE *v17; // r8
__int64 v18; // rdi
__int64 result; // rax
__int64 v20; // rdx
int v21; // ebx
int v22; // eax
size_t v23; // rdx
const char *v24; // rdi
FILE *v25; // rcx
int v26; // eax
int v27; // eax
__int64 v28; // rax
__int64 v29; // rbx
int v30; // eax
int v31; // eax
__int64 v32; // rax

if ( do_hex )
{
v0 = 5LL;
yy_start = 5;
do_hex = 0;
eol_seen = 0;
if ( !yy_init )
goto LABEL_3;
LABEL_23:
v17 = yyin;
if ( !yyin )
goto LABEL_32;
LABEL_24:
if ( !yyout )
goto LABEL_35;
goto LABEL_25;
}
v0 = yy_start;
eol_seen = 0;
if ( !yy_init )
goto LABEL_3;
if ( yy_start )
goto LABEL_23;
v17 = yyin;
yy_start = 1;
if ( yyin )
goto LABEL_24;
LABEL_32:
v17 = stdin;
yyin = stdin;
if ( !yyout )
{
LABEL_35:
v18 = yy_current_buffer;
yyout = (__int64)stdout;
if ( !yy_current_buffer )
goto LABEL_34;
goto LABEL_26;
}
LABEL_25:
v18 = yy_current_buffer;
if ( !yy_current_buffer )
{
LABEL_34:
yy_current_buffer = func8((__int64)v17, 0x4000);
goto LABEL_27;
}
LABEL_26:
func6(v18, (__int64)v17);
LABEL_27:
func3();
v0 = yy_start;
yy_init = 0;
LABEL_3:
v1 = yy_more_flag;
v2 = yy_accept[(int)v0];
v3 = yy_base[(int)v0];
LABEL_4:
yy_more_len = 0;
yy_doing_yy_more = v1;
if ( (_DWORD)v1 )
{
v1 = yyleng;
yy_more_flag = 0;
yy_more_len = yyleng;
}
v4 = (char *)yy_c_buf_p;
v5 = yy_hold_char;
v6 = yy_last_accepting_state;
v7 = yy_last_accepting_cpos;
*(_BYTE *)yy_c_buf_p = yy_hold_char;
v8 = (__int64)v4;
LABEL_7:
v9 = v6;
v10 = (_BYTE *)v7;
v11 = 0;
while ( 1 )
{
v12 = yy_ec[v5];
if ( v2 )
v9 = v0;
if ( v2 )
{
v10 = v4;
v11 = 1;
}
v13 = v12 + v3;
if ( (_DWORD)v0 != yy_chk[v13] )
{
v14 = (int)v0;
do
{
v14 = yy_def[v14];
v13 = v12 + yy_base[v14];
}
while ( (_WORD)v14 != yy_chk[v13] );
}
v0 = yy_nxt[v13];
++v4;
if ( (_DWORD)v0 == 184 )
break;
v5 = *v4;
v2 = yy_accept[yy_nxt[v13]];
v3 = yy_base[yy_nxt[v13]];
}
if ( (_BYTE)v11 )
{
yy_last_accepting_cpos = (__int64)v10;
yy_last_accepting_state = v9;
}
else
{
v10 = (_BYTE *)v7;
v9 = v6;
}
while ( 1 )
{
v15 = yy_accept[v9];
yy_c_buf_p = (__int64)v10;
yytext = v8 - v1;
yyleng = (_DWORD)v10 - (v8 - v1);
v16 = (unsigned __int8)*v10;
*v10 = 0;
yy_hold_char = v16;
LABEL_21:
switch ( v15 )
{
case 0:
v9 = yy_last_accepting_state;
v1 = yy_more_len;
*v10 = yy_hold_char;
v10 = (_BYTE *)yy_last_accepting_cpos;
continue;
case 1:
v0 = yy_start;
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 2:
case 48:
v0 = yy_start;
++lineno;
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 3:
return 256LL;
case 4:
return 257LL;
case 5:
return 258LL;
case 6:
return 144LL;
case 7:
return 128LL;
case 8:
return 160LL;
case 9:
return 176LL;
case 10:
return 224LL;
case 11:
return 192LL;
case 12:
return 208LL;
case 13:
return 240LL;
case 14:
return 273LL;
case 15:
return 401LL;
case 16:
return 275LL;
case 17:
return 276LL;
case 18:
return 277LL;
case 19:
return 278LL;
case 20:
return 279LL;
case 21:
return 280LL;
case 22:
return 281LL;
case 23:
return 274LL;
case 24:
return 363LL;
case 25:
return 355LL;
case 26:
return 362LL;
case 27:
return 358LL;
case 28:
return 259LL;
case 29:
return 47LL;
case 30:
return 260LL;
case 31:
return 261LL;
case 32:
return 262LL;
case 33:
return 263LL;
case 34:
return 264LL;
case 35:
return 265LL;
case 36:
return 266LL;
case 37:
_isoc99_sscanf(yytext, "%ld", &yyval);
return 267LL;
case 38:
_isoc99_sscanf(yytext + 2, "%lx", &yyval);
return 267LL;
case 39:
yyval = bankno(yytext + 1, (unsigned int)(yyleng - 1));
return 267LL;
case 40:
_isoc99_sscanf(yytext, "%lx", &yyval);
return 267LL;
case 41:
return 271LL;
case 42:
yy_start = 3;
v1 = yy_more_flag;
v3 = 36;
v2 = 43;
v0 = 3LL;
goto LABEL_4;
case 43:
case 45:
v0 = yy_start;
v1 = 1LL;
yy_more_flag = 1;
v2 = yy_accept[yy_start];
v3 = yy_base[yy_start];
goto LABEL_4;
case 44:
yy_start = 1;
return 268LL;
case 46:
error((int)"unterminated string", v11, (const char *)v16);
++lineno;
result = 272LL;
++eol_seen;
yy_start = 1;
return result;
case 49:
++lineno;
result = 272LL;
++eol_seen;
yy_start = 1;
return result;
case 50:
case 51:
yy_start = 1;
return 270LL;
case 52:
case 53:
return 270LL;
case 55:
v23 = 19LL;
v24 = "flex scanner jammed";
v25 = stderr;
goto LABEL_95;
case 56:
v20 = yy_current_buffer;
v21 = (_DWORD)v10 - yytext - 1;
*v10 = yy_hold_char;
if ( yy_c_buf_p <= (unsigned __int64)(*(_QWORD *)(v20 + 8) + yy_n_chars) )
{
v29 = yytext + v21;
yy_c_buf_p = v29;
v30 = func0();
v31 = func1(v30);
v1 = yy_more_len;
v7 = yy_last_accepting_cpos;
v0 = v31;
v32 = yy_doing_yy_more;
v6 = yy_last_accepting_state;
v10 = (_BYTE *)yy_last_accepting_cpos;
v9 = yy_last_accepting_state;
if ( yy_doing_yy_more )
v32 = yy_more_len;
v8 = yytext + v32;
if ( (_DWORD)v0 )
{
v4 = (char *)(v29 + 1);
yy_c_buf_p = (__int64)v4;
LABEL_100:
v5 = *v4;
v2 = yy_accept[(int)v0];
v3 = yy_base[(int)v0];
goto LABEL_7;
}
}
else
{
v22 = func2();
if ( v22 == 1 )
{
v11 = yy_doing_yy_more;
v28 = yytext;
if ( yy_doing_yy_more )
v28 = yy_more_len + yytext;
yy_c_buf_p = v28;
v16 = (unsigned int)(yy_start - 1);
v15 = (yy_start - 1) / 2 + 57;
goto LABEL_21;
}
if ( v22 != 2 )
{
if ( v22 )
{
v1 = yy_more_flag;
v2 = yy_accept[yy_start];
v0 = yy_start;
v3 = yy_base[yy_start];
goto LABEL_4;
}
v4 = (char *)(yytext + v21);
yy_c_buf_p = (__int64)v4;
v26 = func0();
v8 = yytext;
v1 = yy_more_len;
v0 = v26;
if ( yy_doing_yy_more )
v8 = yy_more_len + yytext;
v6 = yy_last_accepting_state;
v7 = yy_last_accepting_cpos;
goto LABEL_100;
}
v10 = (_BYTE *)(*(_QWORD *)(yy_current_buffer + 8) + yy_n_chars);
yy_c_buf_p = (__int64)v10;
v27 = func0();
v1 = yy_more_len;
v9 = v27;
v8 = yy_more_len + yytext;
if ( !yy_doing_yy_more )
v8 = yytext;
}
break;
case 57:
case 59:
return 0xFFFFFFFFLL;
case 58:
error((int)"EOF in string", v11, (const char *)v16);
return 0xFFFFFFFFLL;
default:
v23 = 50LL;
v24 = "fatal flex scanner internal error--no action found";
v25 = stderr;
LABEL_95:
fwrite(v24, 1uLL, v23, v25);
putc(10, stderr);
exit(1);
}
}
}

original_code:
int yylex ( void )
    {
    register yy_state_type yy_current_state;
    register char *yy_cp, *yy_bp;
    register int yy_act;
 if (do_hex) {
  yy_start = 1 + 2 *(2);
  do_hex = 0;
 }
 eol_seen = 0;
    if ( yy_init )
 {
 ;
 if ( ! yy_start )
     yy_start = 1;
 if ( ! yyin )
     yyin = stdin;
 if ( ! yyout )
     yyout = stdout;
 if ( yy_current_buffer )
     yy_init_buffer( yy_current_buffer, yyin );
 else
     yy_current_buffer = yy_create_buffer( yyin, (8192 * 2) );
 yy_load_buffer_state();
 yy_init = 0;
 }
    while ( 1 )
 {
 yy_more_len = 0;
 yy_doing_yy_more = yy_more_flag;
 if ( yy_doing_yy_more )
     {
     yy_more_len = yyleng;
     yy_more_flag = 0;
     }
 yy_cp = yy_c_buf_p;
 *yy_cp = yy_hold_char;
 yy_bp = yy_cp;
 yy_current_state = yy_start;
yy_match:
 do
     {
     register char yy_c = yy_ec[*yy_cp];
     if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = yy_def[yy_current_state];
  }
     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
     ++yy_cp;
     }
 while ( yy_current_state != 184 );
 yy_cp = yy_last_accepting_cpos;
 yy_current_state = yy_last_accepting_state;
yy_find_action:
 yy_act = yy_accept[yy_current_state];
 yytext = yy_bp; yytext -= yy_more_len; yyleng = yy_cp - yytext; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
 ;
do_action:
 switch ( yy_act )
     {
     case 0:
     *yy_cp = yy_hold_char;
     yy_cp = yy_last_accepting_cpos;
     yy_current_state = yy_last_accepting_state;
     goto yy_find_action;
case 1:
                     ;
 break;
case 2:
                   lineno++;
 break;
case 3:
return 256;
 break;
case 4:
return 257;
 break;
case 5:
return 258;
 break;
case 6:
return 0x90;
 break;
case 7:
return 0x80;
 break;
case 8:
return 0xa0;
 break;
case 9:
return 0xb0;
 break;
case 10:
return 0xe0;
 break;
case 11:
return 0xc0;
 break;
case 12:
return 0xd0;
 break;
case 13:
return 0xf0;
 break;
case 14:
return 273;
 break;
case 15:
return (273 +1+0x7f);
 break;
case 16:
return (273 +1+0x01);
 break;
case 17:
return (273 +1+0x02);
 break;
case 18:
return (273 +1+0x03);
 break;
case 19:
return (273 +1+0x04);
 break;
case 20:
return (273 +1+0x05);
 break;
case 21:
return (273 +1+0x06);
 break;
case 22:
return (273 +1+0x07);
 break;
case 23:
return (273 +1+0x00);
 break;
case 24:
return (273 +1+0x59);
 break;
case 25:
return (273 +1+0x51);
 break;
case 26:
return (273 +1+0x58);
 break;
case 27:
return (273 +1+0x54);
 break;
case 28:
return 259;
 break;
case 29:
return '/';
 break;
case 30:
return 260;
 break;
case 31:
return 261;
 break;
case 32:
return 262;
 break;
case 33:
return 263;
 break;
case 34:
return 264;
 break;
case 35:
return 265;
 break;
case 36:
return 266;
 break;
case 37:
sscanf (yytext, "%ld", &yyval); return 267;
 break;
case 38:
sscanf (yytext+2, "%lx", &yyval); return 267;
 break;
case 39:
yyval = bankno (yytext+1, yyleng-1); return 267;
 break;
case 40:
sscanf (yytext, "%lx", &yyval); return 267;
 break;
case 41:
return 271;
 break;
case 42:
yy_start = 1 + 2 * (1);
 break;
case 43:
{ yy_more_flag = 1; };
 break;
case 44:
yy_start = 1 + 2 * (0); return 268;
 break;
case 45:
{ yy_more_flag = 1; };
 break;
case 46:
{ error ("unterminated string");
     lineno++; eol_seen++; yy_start = 1 + 2 *(0); return 272;
   }
 break;
case (56 + 1 + 1):
error ("EOF in string"); return (-1);
 break;
case 48:
lineno++;
 break;
case 49:
lineno++; eol_seen++; yy_start = 1 + 2 *(0); return 272;
 break;
case 50:
yy_start = 1 + 2 * (0); return 270;
 break;
case 51:
yy_start = 1 + 2 * (0); return 270;
 break;
case 52:
return 270;
 break;
case 53:
return 270;
 break;
case (56 + 0 + 1):
case (56 + 2 + 1):
return (-1);
 break;
case 55:
do { (void) fputs( "flex scanner jammed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
 break;
     case 56:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
      {
      yy_state_type yy_next_state;
      yy_c_buf_p = yytext + yy_amount_of_matched_text;
      yy_current_state = yy_get_previous_state();
      yy_next_state = yy_try_NUL_trans( yy_current_state );
      yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
      if ( yy_next_state )
   {
   yy_cp = ++yy_c_buf_p;
   yy_current_state = yy_next_state;
   goto yy_match;
   }
      else
   {
       yy_cp = yy_last_accepting_cpos;
       yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
   }
      }
  else switch ( yy_get_next_buffer() )
      {
      case 1:
   {
   yy_did_buffer_switch_on_eof = 0;
   if ( 1 )
       {
       yy_c_buf_p = yytext + (yy_doing_yy_more ? yy_more_len : 0);
       yy_act = (56 + (yy_start - 1) / 2 + 1);
       goto do_action;
       }
   else
       {
       if ( ! yy_did_buffer_switch_on_eof )
    do { yy_init_buffer( yy_current_buffer, yyin ); yy_load_buffer_state(); } while ( 0 );
       }
   }
   break;
      case 0:
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_cp = yy_c_buf_p;
   yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
   goto yy_match;
      case 2:
   yy_c_buf_p =
       &yy_current_buffer->yy_ch_buf[yy_n_chars];
   yy_current_state = yy_get_previous_state();
   yy_cp = yy_c_buf_p;
   yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
   goto yy_find_action;
      }
  break;
  }
     default:
  do { (void) fputs( "fatal flex scanner internal error--no action found", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
     }
 }
    }

canonical_original_code:
int yylex()
    {
    register int yy_current_state;
    register char *yy_cp; register char *yy_bp;
    register int yy_act;
 if (do_hex) {
  yy_start = 1 + 2 *(2);
  do_hex = 0;
 }
 eol_seen = 0;
    if ( yy_init )
 {
 ;
 if ( ! yy_start )
     yy_start = 1;
 if ( ! yyin )
     yyin = stdin;
 if ( ! yyout )
     yyout = stdout;
 if ( yy_current_buffer )
     yy_init_buffer( yy_current_buffer, yyin );
 else
     yy_current_buffer = yy_create_buffer( yyin, (8192 * 2) );
 yy_load_buffer_state();
 yy_init = 0;
 }
    while ( 1 )
 {
 yy_more_len = 0;
 yy_doing_yy_more = yy_more_flag;
 if ( yy_doing_yy_more )
     {
     yy_more_len = yyleng;
     yy_more_flag = 0;
     }
 yy_cp = yy_c_buf_p;
 *yy_cp = yy_hold_char;
 yy_bp = yy_cp;
 yy_current_state = yy_start;
yy_match:
 do
     {
     register char yy_c = yy_ec[*yy_cp];
     if ( yy_accept[yy_current_state] )
  {
  yy_last_accepting_state = yy_current_state;
  yy_last_accepting_cpos = yy_cp;
  }
     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  {
  yy_current_state = yy_def[yy_current_state];
  }
     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
     ++yy_cp;
     }
 while ( yy_current_state != 184 );
 yy_cp = yy_last_accepting_cpos;
 yy_current_state = yy_last_accepting_state;
yy_find_action:
 yy_act = yy_accept[yy_current_state];
 yytext = yy_bp; yytext -= yy_more_len; yyleng = yy_cp - yytext; yy_hold_char = *yy_cp; *yy_cp = '\0'; yy_c_buf_p = yy_cp;;
 ;
do_action:
 switch ( yy_act )
     {
     case 0:
     *yy_cp = yy_hold_char;
     yy_cp = yy_last_accepting_cpos;
     yy_current_state = yy_last_accepting_state;
     goto yy_find_action;
case 1:
                     ;
 break;
case 2:
                   lineno++;
 break;
case 3:
return 256;
 break;
case 4:
return 257;
 break;
case 5:
return 258;
 break;
case 6:
return 0x90;
 break;
case 7:
return 0x80;
 break;
case 8:
return 0xa0;
 break;
case 9:
return 0xb0;
 break;
case 10:
return 0xe0;
 break;
case 11:
return 0xc0;
 break;
case 12:
return 0xd0;
 break;
case 13:
return 0xf0;
 break;
case 14:
return 273;
 break;
case 15:
return (273 +1+0x7f);
 break;
case 16:
return (273 +1+0x01);
 break;
case 17:
return (273 +1+0x02);
 break;
case 18:
return (273 +1+0x03);
 break;
case 19:
return (273 +1+0x04);
 break;
case 20:
return (273 +1+0x05);
 break;
case 21:
return (273 +1+0x06);
 break;
case 22:
return (273 +1+0x07);
 break;
case 23:
return (273 +1+0x00);
 break;
case 24:
return (273 +1+0x59);
 break;
case 25:
return (273 +1+0x51);
 break;
case 26:
return (273 +1+0x58);
 break;
case 27:
return (273 +1+0x54);
 break;
case 28:
return 259;
 break;
case 29:
return '/';
 break;
case 30:
return 260;
 break;
case 31:
return 261;
 break;
case 32:
return 262;
 break;
case 33:
return 263;
 break;
case 34:
return 264;
 break;
case 35:
return 265;
 break;
case 36:
return 266;
 break;
case 37:
sscanf (yytext, "%ld", &yyval); return 267;
 break;
case 38:
sscanf (yytext+2, "%lx", &yyval); return 267;
 break;
case 39:
yyval = bankno (yytext+1, yyleng-1); return 267;
 break;
case 40:
sscanf (yytext, "%lx", &yyval); return 267;
 break;
case 41:
return 271;
 break;
case 42:
yy_start = 1 + 2 * (1);
 break;
case 43:
{ yy_more_flag = 1; };
 break;
case 44:
yy_start = 1 + 2 * (0); return 268;
 break;
case 45:
{ yy_more_flag = 1; };
 break;
case 46:
{ error ("unterminated string");
     lineno++; eol_seen++; yy_start = 1 + 2 *(0); return 272;
   }
 break;
case (56 + 1 + 1):
error ("EOF in string"); return (-1);
 break;
case 48:
lineno++;
 break;
case 49:
lineno++; eol_seen++; yy_start = 1 + 2 *(0); return 272;
 break;
case 50:
yy_start = 1 + 2 * (0); return 270;
 break;
case 51:
yy_start = 1 + 2 * (0); return 270;
 break;
case 52:
return 270;
 break;
case 53:
return 270;
 break;
case (56 + 0 + 1):
case (56 + 2 + 1):
return (-1);
 break;
case 55:
do { (void) fputs( "flex scanner jammed", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
 break;
     case 56:
  {
  int yy_amount_of_matched_text = yy_cp - yytext - 1;
  *yy_cp = yy_hold_char;
  if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
      {
      int yy_next_state;
      yy_c_buf_p = yytext + yy_amount_of_matched_text;
      yy_current_state = yy_get_previous_state();
      yy_next_state = yy_try_NUL_trans( yy_current_state );
      yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
      if ( yy_next_state )
   {
   yy_cp = ++yy_c_buf_p;
   yy_current_state = yy_next_state;
   goto yy_match;
   }
      else
   {
       yy_cp = yy_last_accepting_cpos;
       yy_current_state = yy_last_accepting_state;
   goto yy_find_action;
   }
      }
  else switch ( yy_get_next_buffer() )
      {
      case 1:
   {
   yy_did_buffer_switch_on_eof = 0;
   if ( 1 )
       {
       yy_c_buf_p = yytext + (yy_doing_yy_more ? yy_more_len : 0);
       yy_act = (56 + (yy_start - 1) / 2 + 1);
       goto do_action;
       }
   else
       {
       if ( ! yy_did_buffer_switch_on_eof )
    do { yy_init_buffer( yy_current_buffer, yyin ); yy_load_buffer_state(); } while ( 0 );
       }
   }
   break;
      case 0:
   yy_c_buf_p = yytext + yy_amount_of_matched_text;
   yy_current_state = yy_get_previous_state();
   yy_cp = yy_c_buf_p;
   yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
   goto yy_match;
      case 2:
   yy_c_buf_p =
       &yy_current_buffer->yy_ch_buf[yy_n_chars];
   yy_current_state = yy_get_previous_state();
   yy_cp = yy_c_buf_p;
   yy_bp = yytext + (yy_doing_yy_more ? yy_more_len : 0);
   goto yy_find_action;
      }
  break;
  }
     default:
  do { (void) fputs( "fatal flex scanner internal error--no action found", stderr ); (void) putc( '\n', stderr ); exit( 1 ); } while ( 0 );
     }
 }
    }


decompiled_code:
void __fastcall del_aubio_pitchschmitt(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

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

original_code:
void del_aubio_pitchschmitt (aubio_pitchschmitt_t *p)
{
  free(p->schmittBuffer);
  free(p);
}

canonical_original_code:
void del_aubio_pitchschmitt(struct _aubio_pitchschmitt_t *p)
{
  free(p->schmittBuffer);
  free(p);
}

variable_types: struct _aubio_pitchschmitt_t { unsigned int blockSize; unsigned int rate; short *schmittBuffer; short *schmittPointer; } *


original_code:
void aubio_filter_do(aubio_filter_t * f, fvec_t * in) {
  uint_t i,j,l, order = f->order;
  lsmp_t *x = f->x;
  lsmp_t *y = f->y;
  lsmp_t *a = f->a;
  lsmp_t *b = f->b;
  i=0;
  for (j = 0; j < in->length; j++) {
    x[0] = in->data[i][j];
    y[0] = b[0] * x[0];
    for (l=1;l<order; l++) {
      y[0] += b[l] * x[l];
      y[0] -= a[l] * y[l];
    }
    in->data[i][j] = y[0];
    for (l=order-1; l>0; l--){
      x[l] = x[l-1];
      y[l] = y[l-1];
    }
  }
  f->x = x;
  f->y = y;
}

canonical_original_code:
void aubio_filter_do(struct _aubio_filter_t *f, struct _fvec_t *in) {
  unsigned int i; unsigned int j; unsigned int l; unsigned int order = f->order;
  double *x = f->x;
  double *y = f->y;
  double *a = f->a;
  double *b = f->b;
  i=0;
  for (j = 0; j < in->length; j++) {
    x[0] = in->data[i][j];
    y[0] = b[0] * x[0];
    for (l=1;l<order; l++) {
      y[0] += b[l] * x[l];
      y[0] -= a[l] * y[l];
    }
    in->data[i][j] = y[0];
    for (l=order-1; l>0; l--){
      x[l] = x[l-1];
      y[l] = y[l-1];
    }
  }
  f->x = x;
  f->y = y;
}

variable_types: struct _aubio_filter_t { unsigned int order; double *a; double *b; double *y; double *x; } *

variable_types: struct _fvec_t { unsigned int length; unsigned int channels; float **data; } *

variable_types:
i
unsigned int

variable_types:
l
unsigned int

variable_types:
order
unsigned int

variable_types:
x
double *

variable_types:
y
double *

variable_types:
a
double *

variable_types:
b
double *


original_code:
void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) {
  uint_t i,j,l, order = f->order;
  lsmp_t *x = f->x;
  lsmp_t *y = f->y;
  lsmp_t *a = f->a;
  lsmp_t *b = f->b;
  i=0;
  for (j = 0; j < in->length; j++) {
    x[0] = in->data[i][j];
    y[0] = b[0] * x[0];
    for (l=1;l<order; l++) {
      y[0] += b[l] * x[l];
      y[0] -= a[l] * y[l];
    }
    out->data[i][j] = y[0];
    for (l=order-1; l>0; l--){
      x[l] = x[l-1];
      y[l] = y[l-1];
    }
  }
  f->x = x;
  f->y = y;
}

canonical_original_code:
void aubio_filter_do_outplace(struct _aubio_filter_t *f, struct _fvec_t *in, struct _fvec_t *out) {
  unsigned int i; unsigned int j; unsigned int l; unsigned int order = f->order;
  double *x = f->x;
  double *y = f->y;
  double *a = f->a;
  double *b = f->b;
  i=0;
  for (j = 0; j < in->length; j++) {
    x[0] = in->data[i][j];
    y[0] = b[0] * x[0];
    for (l=1;l<order; l++) {
      y[0] += b[l] * x[l];
      y[0] -= a[l] * y[l];
    }
    out->data[i][j] = y[0];
    for (l=order-1; l>0; l--){
      x[l] = x[l-1];
      y[l] = y[l-1];
    }
  }
  f->x = x;
  f->y = y;
}

variable_types:
out
struct _fvec_t *

user_defined_types: struct _aubio_filter_t { unsigned int order; double *a; double *b; double *y; double *x; }


decompiled_code:
__int64 __fastcall aubio_filter_do_filtfilt(__int64 a1, __int64 a2, __int64 a3)
{
int v5; // ebx
unsigned int v6; // ebx
__int64 v7; // rsi
int *v8; // rdx
unsigned int v9; // eax
int v10; // xmm0_4
__int64 v11; // rcx
__int64 v12; // rcx
__int64 result; // rax
__int64 v14; // rdx

v5 = *(_DWORD *)a2;
aubio_filter_do(a1, a2);
if ( !v5 )
return aubio_filter_do(a1, a3);
v6 = v5 - 1;
v7 = **(_QWORD **)(a3 + 8);
v8 = **(int ***)(a2 + 8);
v9 = v6;
do
{
v10 = *v8;
v11 = v9--;
++v8;
*(_DWORD *)(v7 + 4 * v11) = v10;
}
while ( v9 != -1 );
aubio_filter_do(a1, a3);
v12 = **(_QWORD **)(a3 + 8);
result = **(_QWORD **)(a2 + 8);
do
{
v14 = v6--;
result += 4LL;
*(_DWORD *)(result - 4) = *(_DWORD *)(v12 + 4 * v14);
}
while ( v6 != -1 );
return result;
}

original_code:
void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp) {
  uint_t j,i=0;
  uint_t length = in->length;
  aubio_filter_do(f,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  aubio_filter_do(f,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

canonical_original_code:
void aubio_filter_do_filtfilt(struct _aubio_filter_t *f, struct _fvec_t *in, struct _fvec_t *tmp) {
  unsigned int j; unsigned int i = 0;
  unsigned int length = in->length;
  aubio_filter_do(f,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  aubio_filter_do(f,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

variable_types:
tmp
struct _fvec_t *

variable_types:
j
unsigned int

variable_types:
length
unsigned int


decompiled_code:
void __fastcall del_aubio_filter(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 4));
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 4));
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void del_aubio_filter(aubio_filter_t * f) {
  free(f->a);
  free(f->b);
  free(f->x);
  free(f->y);
  free(f);
  return;
}

canonical_original_code:
void del_aubio_filter(struct _aubio_filter_t *f) {
  free(f->a);
  free(f->b);
  free(f->x);
  free(f->y);
  free(f);
  return;
}