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

result = *a1;
if ( *a1 == finddrawwin )
{
dbl_click();
result = get_motion_hints(finddrawwin, 0LL);
}
else if ( result == repdrawwin )
{
dbl_click();
result = get_motion_hints(repdrawwin, 0LL);
}
return result;
}

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

result = *a1;
if ( *a1 == finddrawwin )
{
dbl_click();
result = get_motion_hints(finddrawwin, 0LL);
}
else if ( result == repdrawwin )
{
dbl_click();
result = get_motion_hints(repdrawwin, 0LL);
}
return result;
}

original_code:
static void double_click_func(void *data)
{
    if (*((Window*) data)== finddrawwin) {
 dbl_click();
 get_motion_hints(finddrawwin,0);
    } else if (*((Window*) data) == repdrawwin) {
 dbl_click();
 get_motion_hints(repdrawwin,0);
    }
}

canonical_original_code:
static void double_click_func(void *data)
{
    if (*((unsigned long *) data)== finddrawwin) {
 dbl_click();
 get_motion_hints(finddrawwin,0);
    } else if (*((unsigned long *) data) == repdrawwin) {
 dbl_click();
 get_motion_hints(repdrawwin,0);
    }
}


repo: jff/mathspad

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

if ( (!menu_is_open || (result = menu_iconized) != 0)
&& (!notation_is_open || (result = notation_iconized) != 0)
&& (!notadef_is_open || (result = notadef_iconized) != 0)
&& (!buffer_is_open || (result = buffer_iconized) != 0)
&& (!find_is_open || (result = find_iconized) != 0)
&& (!default_is_open || (result = default_iconized) != 0)
&& (!symbol_is_open || (result = symbol_iconized) != 0) )
{
result = 1LL;
if ( edit_is_open )
result = edit_iconized != 0;
}
return result;
}

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

if ( (!menu_is_open || (result = menu_iconized) != 0)
&& (!notation_is_open || (result = notation_iconized) != 0)
&& (!notadef_is_open || (result = notadef_iconized) != 0)
&& (!buffer_is_open || (result = buffer_iconized) != 0)
&& (!find_is_open || (result = find_iconized) != 0)
&& (!default_is_open || (result = default_iconized) != 0)
&& (!symbol_is_open || (result = symbol_iconized) != 0) )
{
result = 1LL;
if ( edit_is_open )
result = edit_iconized != 0;
}
return result;
}

original_code:
static int all_iconized(void)
{
    return ((!menu_is_open || menu_iconized) &&
     (!notation_is_open || notation_iconized) &&
     (!notadef_is_open || notadef_iconized) &&
     (!buffer_is_open || buffer_iconized) &&
     (!find_is_open || find_iconized) &&
     (!default_is_open || default_iconized) &&
     (!symbol_is_open || symbol_iconized) &&
     (!edit_is_open || edit_iconized)) ;
}

canonical_original_code:
static int all_iconized()
{
    return ((!menu_is_open || menu_iconized) &&
     (!notation_is_open || notation_iconized) &&
     (!notadef_is_open || notadef_iconized) &&
     (!buffer_is_open || buffer_iconized) &&
     (!find_is_open || find_iconized) &&
     (!default_is_open || default_iconized) &&
     (!symbol_is_open || symbol_iconized) &&
     (!edit_is_open || edit_iconized)) ;
}

return_type: int


decompiled_code:
__int64 __fastcall do_motion_notify(int a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = a1;
v3 = a2;
if ( when_motion_window && when_motion_window != motion_window )
{
motion_window = when_motion_window;
when_motion_window = 0LL;
goto LABEL_5;
}
when_motion_window = 0LL;
if ( (v4[0] & v3) == -1 )
{
LABEL_5:
result = motion_get_pos(v4, &v3);
if ( !(_DWORD)result )
return result;
}
if ( mouse_old_x != v4[0] || (result = v3, mouse_old_y != v3) )
{
set_info(motion_window);
mouse_old_x = v4[0];
mouse_old_y = v3;
is_click = 0;
result = *(_QWORD *)(eventfunc[wt] + 40LL);
if ( result && (!remark_is_open || wt == 14 || pwt == 14) )
result = ((__int64 (__fastcall *)(__int64))result)(data);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+8h] [rbp-10h] BYREF
int v4[3]; // [rsp+Ch] [rbp-Ch] BYREF

v4[0] = a1;
v3 = a2;
if ( when_motion_window && when_motion_window != motion_window )
{
motion_window = when_motion_window;
when_motion_window = 0LL;
goto LABEL_5;
}
when_motion_window = 0LL;
if ( (v4[0] & v3) == -1 )
{
LABEL_5:
result = motion_get_pos(v4, &v3);
if ( !(_DWORD)result )
return result;
}
if ( mouse_old_x != v4[0] || (result = v3, mouse_old_y != v3) )
{
set_info(motion_window);
mouse_old_x = v4[0];
mouse_old_y = v3;
is_click = 0;
result = *(_QWORD *)(eventfunc[wt] + 40LL);
if ( result && (!remark_is_open || wt == 14 || pwt == 14) )
result = ((__int64 (__fastcall *)(__int64))result)(data);
}
return result;
}

original_code:
static void do_motion_notify(int x, int y)
{
    int get_pos = (x==-1 && y==-1);
    if (when_motion_window && when_motion_window != motion_window) {
 motion_window=when_motion_window;
 get_pos = 1;
    }
    when_motion_window = 0;
    if (get_pos)
 if (!motion_get_pos(&x,&y)) return;
    if ((mouse_old_x == x && mouse_old_y == y)) return;
    set_info(motion_window);
    mouse_old_x=x;
    mouse_old_y=y;
    is_click = 0;
    if (eventfunc[wt]->motion)
 if (!remark_is_open || wt==REMARKWINDOW || pwt==REMARKWINDOW)
     (*(eventfunc[wt]->motion))(data, x, y);
}

variable_types: x int

variable_types: y int

return_type: void


decompiled_code:
void get_events()
{
Time v0; // r12
void (__fastcall *v1)(__int64); // rax
void (__fastcall *v2)(__int64, XEvent *); // rax
_BOOL4 v3; // edx
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rbx
char *v7; // rax
__int64 v8; // rax
void (__fastcall *v9)(__int64); // rax
void (__fastcall *v10)(__int64); // rax
int v11; // [rsp+8h] [rbp-60h] BYREF
int v12; // [rsp+Ch] [rbp-5Ch] BYREF
unsigned __int64 v13; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v14; // [rsp+18h] [rbp-50h] BYREF
Atom v15; // [rsp+20h] [rbp-48h] BYREF
unsigned __int8 *v16; // [rsp+28h] [rbp-40h] BYREF
char v17[4]; // [rsp+30h] [rbp-38h] BYREF
char v18[4]; // [rsp+34h] [rbp-34h] BYREF
unsigned int v19; // [rsp+38h] [rbp-30h] BYREF
int v20[11]; // [rsp+3Ch] [rbp-2Ch] BYREF

v0 = 0LL;
while ( 1 )
{
XEventsQueued(display, 2);
XNextEvent(display, &report);
set_info(report.pad[4]);
convert_event(&report, v18, v17);
can_auto_save = 0;
switch ( report.type )
{
case 2:
v0 = report.xkey.time;
last_time = report.xkey.time;
do_key_press(&report);
goto LABEL_52;
case 4:
if ( !(unsigned int)mouse_press(report.xkey.state, report.xkey.keycode) )
goto LABEL_36;
press_time = report.xkey.time;
v3 = 0;
if ( report.xany.window == first_click )
v3 = report.xkey.time - release_time < wait_time;
double_click = v3;
mouse_old_y = report.xkey.y;
mouse_old_x = report.xkey.x;
push_keymap(0LL);
if ( double_click && *(_QWORD *)(eventfunc[wt] + 144LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
(*(void (__fastcall **)(__int64))(eventfunc[wt] + 144LL))(data);
}
else
{
double_click = 0;
first_click = report.pad[4];
if ( *(_QWORD *)(eventfunc[wt] + 24LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
{
(*(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 24LL))(data, &report);
}
else
{
v4 = translate("Please handle the popup first. (It should be visible by now)");
message(0LL, v4);
}
}
}
goto LABEL_52;
case 5:
if ( (unsigned int)mouse_release(report.xkey.state, report.xkey.keycode) )
{
v0 = report.xkey.time;
last_time = report.xkey.time;
release_time = report.xkey.time;
if ( motion_window )
set_info(motion_window);
pop_keymap();
if ( *(_QWORD *)(eventfunc[wt] + 32LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
(*(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 32LL))(data, &report);
else
remark_raise();
}
when_motion_window = 0LL;
}
else
{
LABEL_36:
do_motion_notify(-1, 0xFFFFFFFF);
}
goto LABEL_52;
case 6:
while ( XCheckMaskEvent(display, 0x2000LL, &report) )
;
if ( when_motion_window && when_motion_window != motion_window )
motion_window = when_motion_window;
when_motion_window = 0LL;
if ( (unsigned int)motion_get_pos(v20, &v19) && (unsigned int)is_drag(report.xkey.time) )
do_motion_notify(v20[0], v19);
goto LABEL_52;
case 7:
v0 = report.xkey.time;
last_time = report.xkey.time;
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 72LL);
if ( v1 )
goto LABEL_78;
goto LABEL_52;
case 8:
v0 = report.xkey.time;
last_time = report.xkey.time;
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 64LL);
if ( v1 )
goto LABEL_78;
goto LABEL_52;
case 9:
if ( window_keyboard(report.xany.window) )
{
v5 = window_keyboard(report.xany.window);
set_keyboard_stack(v5);
}
goto LABEL_52;
case 0xC:
case 0xD:
if ( !report.xexpose.count )
{
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 8LL);
if ( v1 )
goto LABEL_78;
}
goto LABEL_52;
case 0xF:
change_visibility(report.xany.window, report.xcookie.cookie);
goto LABEL_52;
case 0x11:
destroy_window(report.xany.window);
goto LABEL_52;
case 0x12:
change_mapped(report.xany.window, 0LL);
v9 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 48LL);
if ( v9 )
v9(data);
if ( remark_is_open && (unsigned int)all_iconized() )
remark_unmap();
goto LABEL_52;
case 0x13:
change_mapped(report.xany.window, 1LL);
v10 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 56LL);
if ( v10 )
{
v10(data);
if ( remark_is_open )
remark_raise();
}
goto LABEL_52;
case 0x16:
v2 = *(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 16LL);
if ( v2 )
goto LABEL_13;
goto LABEL_52;
case 0x1C:
v2 = *(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 152LL);
if ( v2 )
LABEL_13:
v2(data, &report);
goto LABEL_52;
case 0x1E:
send_selection(&report);
goto LABEL_52;
case 0x1F:
if ( report.xkey.time )
{
v14 = 0LL;
XGetWindowProperty(
display,
report.xany.window,
report.xkey.time,
0LL,
3000LL,
0,
0LL,
&v15,
&v11,
&v13,
&v14,
&v16);
v0 = report.xselectionrequest.property;
last_time = report.xselectionrequest.property;
if ( v16 && v13 )
{
v6 = 0LL;
while ( v14 )
{
wmselection = v16;
handle_key(80LL, 5832793LL);
v6 += 3000LL;
XGetWindowProperty(
display,
report.xany.window,
report.xkey.time,
v6,
3000LL,
0,
0LL,
&v15,
&v11,
&v13,
&v14,
&v16);
}
wmselection = v16;
if ( v13 && v16 )
handle_key(80LL, 5832793LL);
goto LABEL_65;
}
wmselection = XFetchBytes(display, &v12);
v13 = v12;
if ( v12 )
{
if ( !wmselection )
{
LABEL_65:
wmselection = 0LL;
XDeleteProperty(display, report.xany.window, report.xkey.time);
goto LABEL_52;
}
handle_key(80LL, 5832793LL);
}
if ( wmselection )
XFree(wmselection);
goto LABEL_65;
}
v7 = XFetchBytes(display, (int *)&v16);
wmselection = v7;
if ( (_DWORD)v16 && v7 )
handle_key(80LL, 5832793LL);
XFree(wmselection);
wmselection = 0LL;
LABEL_52:
can_auto_save = 1;
call_auto_save(v0);
break;
case 0x21:
if ( WM_SAVE_YOURSELF == report.xkey.time )
{
v8 = translate(".mpproject");
save_project(v8);
menu_set_command();
}
else if ( WM_DELETE_WINDOW == report.xkey.time )
{
XDestroyWindow(display, report.xany.window);
v1 = *(void (__fastcall **)(__int64))eventfunc[wt];
if ( v1 )
LABEL_78:
v1(data);
}
goto LABEL_52;
case 0x22:
if ( report.xfocus.mode == 1 )
XRefreshKeyboardMapping((XMappingEvent *)&report);
goto LABEL_52;
default:
goto LABEL_52;
}
}
}

canonical_decompiled_code:
void func3()
{
Time v0; // r12
void (__fastcall *v1)(__int64); // rax
void (__fastcall *v2)(__int64, XEvent *); // rax
_BOOL4 v3; // edx
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rbx
char *v7; // rax
__int64 v8; // rax
void (__fastcall *v9)(__int64); // rax
void (__fastcall *v10)(__int64); // rax
int v11; // [rsp+8h] [rbp-60h] BYREF
int v12; // [rsp+Ch] [rbp-5Ch] BYREF
unsigned __int64 v13; // [rsp+10h] [rbp-58h] BYREF
unsigned __int64 v14; // [rsp+18h] [rbp-50h] BYREF
Atom v15; // [rsp+20h] [rbp-48h] BYREF
unsigned __int8 *v16; // [rsp+28h] [rbp-40h] BYREF
char v17[4]; // [rsp+30h] [rbp-38h] BYREF
char v18[4]; // [rsp+34h] [rbp-34h] BYREF
unsigned int v19; // [rsp+38h] [rbp-30h] BYREF
int v20[11]; // [rsp+3Ch] [rbp-2Ch] BYREF

v0 = 0LL;
while ( 1 )
{
XEventsQueued(display, 2);
XNextEvent(display, &report);
set_info(report.pad[4]);
convert_event(&report, v18, v17);
can_auto_save = 0;
switch ( report.type )
{
case 2:
v0 = report.xkey.time;
last_time = report.xkey.time;
func2(&report);
goto LABEL_52;
case 4:
if ( !(unsigned int)mouse_press(report.xkey.state, report.xkey.keycode) )
goto LABEL_36;
press_time = report.xkey.time;
v3 = 0;
if ( report.xany.window == first_click )
v3 = report.xkey.time - release_time < wait_time;
double_click = v3;
mouse_old_y = report.xkey.y;
mouse_old_x = report.xkey.x;
push_keymap(0LL);
if ( double_click && *(_QWORD *)(eventfunc[wt] + 144LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
(*(void (__fastcall **)(__int64))(eventfunc[wt] + 144LL))(data);
}
else
{
double_click = 0;
first_click = report.pad[4];
if ( *(_QWORD *)(eventfunc[wt] + 24LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
{
(*(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 24LL))(data, &report);
}
else
{
v4 = translate("Please handle the popup first. (It should be visible by now)");
message(0LL, v4);
}
}
}
goto LABEL_52;
case 5:
if ( (unsigned int)mouse_release(report.xkey.state, report.xkey.keycode) )
{
v0 = report.xkey.time;
last_time = report.xkey.time;
release_time = report.xkey.time;
if ( motion_window )
set_info(motion_window);
pop_keymap();
if ( *(_QWORD *)(eventfunc[wt] + 32LL) )
{
if ( !remark_is_open || (unsigned int)remark_removable() || wt == 14 || pwt == 14 )
(*(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 32LL))(data, &report);
else
remark_raise();
}
when_motion_window = 0LL;
}
else
{
LABEL_36:
func1(-1, 0xFFFFFFFF);
}
goto LABEL_52;
case 6:
while ( XCheckMaskEvent(display, 0x2000LL, &report) )
;
if ( when_motion_window && when_motion_window != motion_window )
motion_window = when_motion_window;
when_motion_window = 0LL;
if ( (unsigned int)motion_get_pos(v20, &v19) && (unsigned int)is_drag(report.xkey.time) )
func1(v20[0], v19);
goto LABEL_52;
case 7:
v0 = report.xkey.time;
last_time = report.xkey.time;
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 72LL);
if ( v1 )
goto LABEL_78;
goto LABEL_52;
case 8:
v0 = report.xkey.time;
last_time = report.xkey.time;
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 64LL);
if ( v1 )
goto LABEL_78;
goto LABEL_52;
case 9:
if ( window_keyboard(report.xany.window) )
{
v5 = window_keyboard(report.xany.window);
set_keyboard_stack(v5);
}
goto LABEL_52;
case 0xC:
case 0xD:
if ( !report.xexpose.count )
{
v1 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 8LL);
if ( v1 )
goto LABEL_78;
}
goto LABEL_52;
case 0xF:
change_visibility(report.xany.window, report.xcookie.cookie);
goto LABEL_52;
case 0x11:
destroy_window(report.xany.window);
goto LABEL_52;
case 0x12:
change_mapped(report.xany.window, 0LL);
v9 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 48LL);
if ( v9 )
v9(data);
if ( remark_is_open && (unsigned int)func0() )
remark_unmap();
goto LABEL_52;
case 0x13:
change_mapped(report.xany.window, 1LL);
v10 = *(void (__fastcall **)(__int64))(eventfunc[wt] + 56LL);
if ( v10 )
{
v10(data);
if ( remark_is_open )
remark_raise();
}
goto LABEL_52;
case 0x16:
v2 = *(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 16LL);
if ( v2 )
goto LABEL_13;
goto LABEL_52;
case 0x1C:
v2 = *(void (__fastcall **)(__int64, XEvent *))(eventfunc[wt] + 152LL);
if ( v2 )
LABEL_13:
v2(data, &report);
goto LABEL_52;
case 0x1E:
send_selection(&report);
goto LABEL_52;
case 0x1F:
if ( report.xkey.time )
{
v14 = 0LL;
XGetWindowProperty(
display,
report.xany.window,
report.xkey.time,
0LL,
3000LL,
0,
0LL,
&v15,
&v11,
&v13,
&v14,
&v16);
v0 = report.xselectionrequest.property;
last_time = report.xselectionrequest.property;
if ( v16 && v13 )
{
v6 = 0LL;
while ( v14 )
{
wmselection = v16;
handle_key(80LL, 5832793LL);
v6 += 3000LL;
XGetWindowProperty(
display,
report.xany.window,
report.xkey.time,
v6,
3000LL,
0,
0LL,
&v15,
&v11,
&v13,
&v14,
&v16);
}
wmselection = v16;
if ( v13 && v16 )
handle_key(80LL, 5832793LL);
goto LABEL_65;
}
wmselection = XFetchBytes(display, &v12);
v13 = v12;
if ( v12 )
{
if ( !wmselection )
{
LABEL_65:
wmselection = 0LL;
XDeleteProperty(display, report.xany.window, report.xkey.time);
goto LABEL_52;
}
handle_key(80LL, 5832793LL);
}
if ( wmselection )
XFree(wmselection);
goto LABEL_65;
}
v7 = XFetchBytes(display, (int *)&v16);
wmselection = v7;
if ( (_DWORD)v16 && v7 )
handle_key(80LL, 5832793LL);
XFree(wmselection);
wmselection = 0LL;
LABEL_52:
can_auto_save = 1;
call_auto_save(v0);
break;
case 0x21:
if ( WM_SAVE_YOURSELF == report.xkey.time )
{
v8 = translate(".mpproject");
save_project(v8);
menu_set_command();
}
else if ( WM_DELETE_WINDOW == report.xkey.time )
{
XDestroyWindow(display, report.xany.window);
v1 = *(void (__fastcall **)(__int64))eventfunc[wt];
if ( v1 )
LABEL_78:
v1(data);
}
goto LABEL_52;
case 0x22:
if ( report.xfocus.mode == 1 )
XRefreshKeyboardMapping((XMappingEvent *)&report);
goto LABEL_52;
default:
goto LABEL_52;
}
}
}

original_code:
void get_events(void)
{
    Atom matom;
    int x,y;
    unsigned long auto_save = 0;
    KeyNum keynum;
    KeyMode keymode;
    char buffer[5000];
    while (1) {
 (void) XEventsQueued(display, 2);
 XNextEvent(display, &report);
 set_info(report.xany.window);
 if (convert_event((void*)(&report), &keynum, &keymode)) {
 }
 can_auto_save = 0;
 switch (report.type) {
 case 13:
 case 12:
     if (!report.xexpose.count && eventfunc[wt]->draw)
         (*(eventfunc[wt]->draw))(data);
     break;
 case 6:
     while (XCheckMaskEvent(display, (1L<<13), &report));
     if (when_motion_window && when_motion_window != motion_window) {
  motion_window=when_motion_window;
     }
     when_motion_window = 0;
     if (motion_get_pos(&x,&y) && is_drag(report.xmotion.time))
  do_motion_notify(x,y);
     break;
 case 22:
     if (eventfunc[wt]->configure)
  (*(eventfunc[wt]->configure))(data, &report.xconfigure);
     break;
 case 7:
     auto_save = last_time = report.xcrossing.time;
     if (eventfunc[wt]->enter) (*(eventfunc[wt]->enter))(data);
     break;
 case 8:
     auto_save = last_time = report.xcrossing.time;
     if (eventfunc[wt]->leave) (*(eventfunc[wt]->leave))(data);
     break;
 case 4:
     if (mouse_press(report.xbutton.state, report.xbutton.button)) {
  press_time = report.xbutton.time;
  double_click = (first_click==report.xany.window) &&
                 (press_time-release_time)<(unsigned int)wait_time;
  mouse_old_x = report.xbutton.x;
  mouse_old_y = report.xbutton.y;
  push_keymap(0);
  if (double_click && eventfunc[wt]->dbl_click) {
    if (!remark_is_open || remark_removable() ||
        wt==REMARKWINDOW || pwt==REMARKWINDOW)
      (*(eventfunc[wt]->dbl_click))(data);
      } else {
    double_click = 0;
    first_click = report.xany.window;
    if (eventfunc[wt]->press) {
      if (!remark_is_open || remark_removable() ||
   wt==REMARKWINDOW || pwt==REMARKWINDOW)
        (*(eventfunc[wt]->press))(data, &report.xbutton);
      else message(0, translate("Please handle the popup first. "
     "(It should be visible by now)"));
    }
  }
     } else
  do_motion_notify(-1,-1);
     break;
 case 5:
     if (mouse_release(report.xbutton.state, report.xbutton.button)) {
  auto_save = release_time = last_time = report.xbutton.time;
  if (motion_window) set_info(motion_window);
  pop_keymap();
  if (eventfunc[wt]->release) {
      if (!remark_is_open || remark_removable() ||
   wt==REMARKWINDOW || pwt==REMARKWINDOW)
   (*(eventfunc[wt]->release))(data, &report.xbutton);
      else
   remark_raise();
  }
  when_motion_window=0;
     } else
  do_motion_notify(-1,-1);
     break;
 case 28:
     if (eventfunc[wt]->property_change)
  (*eventfunc[wt]->property_change)(data, &report.xproperty);
     break;
 case 17:
     destroy_window(report.xany.window);
     break;
 case 2:
     auto_save = last_time = report.xkey.time;
     do_key_press(&report.xkey);
     break;
 case 9:
   if (window_keyboard(report.xany.window)) {
     set_keyboard_stack(window_keyboard(report.xany.window));
   }
   break;
 case 10:
   break;
 case 34:
     if (report.xmapping.request == 1)
  XRefreshKeyboardMapping(&report.xmapping);
     break;
 case 30:
     send_selection(&report.xselectionrequest);
     break;
 case 31:
     if (report.xselection.property!= 0L) {
  long start=0;
  unsigned long nit, byte_af=0;
  Atom act_type;
  int act_form;
  int l;
  int freeit=0;
  unsigned char *wmdata;
  XGetWindowProperty(display, report.xselection.requestor,
       report.xselection.property, 0, 3000, 0,
       0L, &act_type, &act_form,
       &nit, &byte_af, &wmdata);
  auto_save = last_time = report.xselection.time;
  if (!wmdata || !nit) {
      freeit = 1;
      wmselection = XFetchBytes(display, &l);
      nit = l;
  } else {
      while (byte_af) {
   wmselection = (char*) wmdata;
   handle_key('P',((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
   start+=3000;
   XGetWindowProperty(display,report.xselection.requestor,
        report.xselection.property, start,
        3000, 0, 0L,
        &act_type, &act_form, &nit,
        &byte_af, &wmdata);
      }
      wmselection = (char*) wmdata;
  }
  if (nit && wmselection)
      handle_key('P',((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
  if (freeit && wmselection) XFree(wmselection);
  wmselection = ((void *)0);
  XDeleteProperty(display, report.xselection.requestor,
    report.xselection.property);
     } else {
  int l;
  wmselection = XFetchBytes(display, &l);
  if (l && wmselection)
      handle_key('P', ((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
  XFree(wmselection);
  wmselection = ((void *)0);
     }
     break;
 case 33:
     matom = (Atom) report.xclient.data.l[0];
     if (matom == WM_SAVE_YOURSELF) {
  save_project(translate(".mpproject"));
  menu_set_command();
     } else if (matom == WM_DELETE_WINDOW) {
  XDestroyWindow(display, report.xany.window);
  if (eventfunc[wt]->bad_end) (*(eventfunc[wt]->bad_end))(data);
     }
     break;
 case 15:
     change_visibility(report.xvisibility.window, report.xvisibility.state);
     break;
 case 18:
     change_mapped(report.xany.window, 0);
     if (eventfunc[wt]->iconize) (*(eventfunc[wt]->iconize))(data);
     if (remark_is_open && all_iconized()) remark_unmap();
     break;
 case 19:
     change_mapped(report.xany.window, 1);
     if (eventfunc[wt]->deiconize) {
  (*(eventfunc[wt]->deiconize))(data);
  if (remark_is_open) remark_raise();
     }
     break;
 default:
     break;
 }
 can_auto_save = 1;
        call_auto_save(auto_save);
    }
}

canonical_original_code:
void get_events()
{
    unsigned long matom;
    int x; int y;
    unsigned long auto_save = 0;
    unsigned int keynum;
    unsigned int keymode;
    char buffer[5000];
    while (1) {
 (void) XEventsQueued(display, 2);
 XNextEvent(display, &report);
 set_info(report.xany.window);
 if (convert_event((void *)(&report), &keynum, &keymode)) {
 }
 can_auto_save = 0;
 switch (report.type) {
 case 13:
 case 12:
     if (!report.xexpose.count && eventfunc[wt]->draw)
         (*(eventfunc[wt]->draw))(data);
     break;
 case 6:
     while (XCheckMaskEvent(display, (1L<<13), &report));
     if (when_motion_window && when_motion_window != motion_window) {
  motion_window=when_motion_window;
     }
     when_motion_window = 0;
     if (motion_get_pos(&x,&y) && is_drag(report.xmotion.time))
  do_motion_notify(x,y);
     break;
 case 22:
     if (eventfunc[wt]->configure)
  (*(eventfunc[wt]->configure))(data, &report.xconfigure);
     break;
 case 7:
     auto_save = last_time = report.xcrossing.time;
     if (eventfunc[wt]->enter) (*(eventfunc[wt]->enter))(data);
     break;
 case 8:
     auto_save = last_time = report.xcrossing.time;
     if (eventfunc[wt]->leave) (*(eventfunc[wt]->leave))(data);
     break;
 case 4:
     if (mouse_press(report.xbutton.state, report.xbutton.button)) {
  press_time = report.xbutton.time;
  double_click = (first_click==report.xany.window) &&
                 (press_time-release_time)<(unsigned int)wait_time;
  mouse_old_x = report.xbutton.x;
  mouse_old_y = report.xbutton.y;
  push_keymap(0);
  if (double_click && eventfunc[wt]->dbl_click) {
    if (!remark_is_open || remark_removable() ||
        wt==REMARKWINDOW || pwt==REMARKWINDOW)
      (*(eventfunc[wt]->dbl_click))(data);
      } else {
    double_click = 0;
    first_click = report.xany.window;
    if (eventfunc[wt]->press) {
      if (!remark_is_open || remark_removable() ||
   wt==REMARKWINDOW || pwt==REMARKWINDOW)
        (*(eventfunc[wt]->press))(data, &report.xbutton);
      else message(0, translate("Please handle the popup first. "
     "(It should be visible by now)"));
    }
  }
     } else
  do_motion_notify(-1,-1);
     break;
 case 5:
     if (mouse_release(report.xbutton.state, report.xbutton.button)) {
  auto_save = release_time = last_time = report.xbutton.time;
  if (motion_window) set_info(motion_window);
  pop_keymap();
  if (eventfunc[wt]->release) {
      if (!remark_is_open || remark_removable() ||
   wt==REMARKWINDOW || pwt==REMARKWINDOW)
   (*(eventfunc[wt]->release))(data, &report.xbutton);
      else
   remark_raise();
  }
  when_motion_window=0;
     } else
  do_motion_notify(-1,-1);
     break;
 case 28:
     if (eventfunc[wt]->property_change)
  (*eventfunc[wt]->property_change)(data, &report.xproperty);
     break;
 case 17:
     destroy_window(report.xany.window);
     break;
 case 2:
     auto_save = last_time = report.xkey.time;
     do_key_press(&report.xkey);
     break;
 case 9:
   if (window_keyboard(report.xany.window)) {
     set_keyboard_stack(window_keyboard(report.xany.window));
   }
   break;
 case 10:
   break;
 case 34:
     if (report.xmapping.request == 1)
  XRefreshKeyboardMapping(&report.xmapping);
     break;
 case 30:
     send_selection(&report.xselectionrequest);
     break;
 case 31:
     if (report.xselection.property!= 0L) {
  long start = 0;
  unsigned long nit; unsigned long byte_af = 0;
  unsigned long act_type;
  int act_form;
  int l;
  int freeit = 0;
  unsigned char *wmdata;
  XGetWindowProperty(display, report.xselection.requestor,
       report.xselection.property, 0, 3000, 0,
       0L, &act_type, &act_form,
       &nit, &byte_af, &wmdata);
  auto_save = last_time = report.xselection.time;
  if (!wmdata || !nit) {
      freeit = 1;
      wmselection = XFetchBytes(display, &l);
      nit = l;
  } else {
      while (byte_af) {
   wmselection = (char *) wmdata;
   handle_key('P',((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
   start+=3000;
   XGetWindowProperty(display,report.xselection.requestor,
        report.xselection.property, start,
        3000, 0, 0L,
        &act_type, &act_form, &nit,
        &byte_af, &wmdata);
      }
      wmselection = (char *) wmdata;
  }
  if (nit && wmselection)
      handle_key('P',((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
  if (freeit && wmselection) XFree(wmselection);
  wmselection = ((void *)0);
  XDeleteProperty(display, report.xselection.requestor,
    report.xselection.property);
     } else {
  int l;
  wmselection = XFetchBytes(display, &l);
  if (l && wmselection)
      handle_key('P', ((((((((0)|(((0x01)<<16)|(0x01))))|(((0x08)<<16)|(0x08))))|(((0x10)<<16)|(0x10))))|(((0x40)<<16)|(0x40))));
  XFree(wmselection);
  wmselection = ((void *)0);
     }
     break;
 case 33:
     matom = (unsigned long) report.xclient.data.l[0];
     if (matom == WM_SAVE_YOURSELF) {
  save_project(translate(".mpproject"));
  menu_set_command();
     } else if (matom == WM_DELETE_WINDOW) {
  XDestroyWindow(display, report.xany.window);
  if (eventfunc[wt]->bad_end) (*(eventfunc[wt]->bad_end))(data);
     }
     break;
 case 15:
     change_visibility(report.xvisibility.window, report.xvisibility.state);
     break;
 case 18:
     change_mapped(report.xany.window, 0);
     if (eventfunc[wt]->iconize) (*(eventfunc[wt]->iconize))(data);
     if (remark_is_open && all_iconized()) remark_unmap();
     break;
 case 19:
     change_mapped(report.xany.window, 1);
     if (eventfunc[wt]->deiconize) {
  (*(eventfunc[wt]->deiconize))(data);
  if (remark_is_open) remark_raise();
     }
     break;
 default:
     break;
 }
 can_auto_save = 1;
        call_auto_save(auto_save);
    }
}

variable_types:
matom
unsigned long

variable_types:
keynum
unsigned int

variable_types:
keymode
unsigned int

variable_types:
buffer
char [5000]

variable_types: start long

variable_types:
nit
unsigned long

variable_types: l int

variable_types: freeit int

variable_types:
wmdata
unsigned char *


decompiled_code:
__int64 typepool_init()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-48h] BYREF
int v2; // [rsp+4h] [rbp-44h]
const char *v3; // [rsp+8h] [rbp-40h]
__int64 v4; // [rsp+10h] [rbp-38h]
__int64 v5; // [rsp+18h] [rbp-30h]
__int64 v6; // [rsp+20h] [rbp-28h]
int v7; // [rsp+28h] [rbp-20h]

if ( dword_3E8 <= 4 )
{
v7 = 0;
v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
v1 = 0;
v2 = 0;
v3 = "NoValidType";
fx_add(&typepool, &v1);
v1 = 1;
v2 = 4;
v3 = "Int";
fx_add(&typepool, &v1);
v1 = 2;
v2 = 8;
v3 = "String";
fx_add(&typepool, &v1);
v1 = 3;
v2 = 8;
v3 = "Real";
fx_add(&typepool, &v1);
v1 = 4;
v2 = 8;
v3 = "Lazy";
result = fx_add(&typepool, &v1);
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
int v1; // [rsp+0h] [rbp-48h] BYREF
int v2; // [rsp+4h] [rbp-44h]
const char *v3; // [rsp+8h] [rbp-40h]
__int64 v4; // [rsp+10h] [rbp-38h]
__int64 v5; // [rsp+18h] [rbp-30h]
__int64 v6; // [rsp+20h] [rbp-28h]
int v7; // [rsp+28h] [rbp-20h]

if ( dword_3E8 <= 4 )
{
v7 = 0;
v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
v1 = 0;
v2 = 0;
v3 = "NoValidType";
fx_add(&typepool, &v1);
v1 = 1;
v2 = 4;
v3 = "Int";
fx_add(&typepool, &v1);
v1 = 2;
v2 = 8;
v3 = "String";
fx_add(&typepool, &v1);
v1 = 3;
v2 = 8;
v3 = "Real";
fx_add(&typepool, &v1);
v1 = 4;
v2 = 8;
v3 = "Lazy";
result = fx_add(&typepool, &v1);
}
return result;
}

original_code:
static void typepool_init(void)
{
  TypeConstruct tc;
  if (((&typepool)->nr)>=5) return;
  tc.conskind=0;
  tc.construct=0;
  tc.destruct=0;
  tc.copy=0;
  tc.pos=0;
  tc.conssize=0;
  tc.name="NoValidType";
  fx_add(&typepool, &(tc));
  tc.pos=1;
  tc.conssize=sizeof(int);
  tc.name="Int";
  fx_add(&typepool, &(tc));
  tc.pos=2;
  tc.conssize=sizeof(Uchar*);
  tc.name="String";
  fx_add(&typepool, &(tc));
  tc.pos=3;
  tc.conssize=sizeof(double);
  tc.name="Real";
  fx_add(&typepool, &(tc));
  tc.pos=4;
  tc.conssize=sizeof(void*);
  tc.name="Lazy";
  fx_add(&typepool, &(tc));
}

canonical_original_code:
static void typepool_init()
{
  struct TypeConstruct tc;
  if (((&typepool)->nr)>=5) return;
  tc.conskind=0;
  tc.construct=0;
  tc.destruct=0;
  tc.copy=0;
  tc.pos=0;
  tc.conssize=0;
  tc.name="NoValidType";
  fx_add(&typepool, &(tc));
  tc.pos=1;
  tc.conssize=sizeof(int);
  tc.name="Int";
  fx_add(&typepool, &(tc));
  tc.pos=2;
  tc.conssize=sizeof(unsigned short *);
  tc.name="String";
  fx_add(&typepool, &(tc));
  tc.pos=3;
  tc.conssize=sizeof(double);
  tc.name="Real";
  fx_add(&typepool, &(tc));
  tc.pos=4;
  tc.conssize=sizeof(void *);
  tc.name="Lazy";
  fx_add(&typepool, &(tc));
}

variable_types: struct TypeConstruct { unsigned int pos; int conssize; char *name; void (*construct)(void **); void (*destruct)(void *); void (*copy)(void **, void *); int conskind; union { void *record; } cons; }


decompiled_code:
int __fastcall type_cmp(__int64 a1, __int64 a2)
{
return strcmp(*(const char **)(a1 + 8), *(const char **)(a2 + 8));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2)
{
return strcmp(*(const char **)(a1 + 8), *(const char **)(a2 + 8));
}

original_code:
static int type_cmp(const void *type1, const void *type2)
{
  return strcmp(((TypeConstruct*)type1)->name,
  ((TypeConstruct*)type2)->name);
}

canonical_original_code:
static int type_cmp(void *type1, void *type2)
{
  return strcmp(((struct TypeConstruct *)type1)->name,
  ((struct TypeConstruct *)type2)->name);
}

user_defined_types: struct TypeConstruct { unsigned int pos; int conssize; char *name; void (*construct)(void **); void (*destruct)(void *); void (*copy)(void **, void *); int conskind; union { void *record; } cons; }


original_code:
Type define_type(char *name, int size,
   void (*construct)(void**),
   void (*destruct)(void*),
   void (*copy)(void**, void*))
{
  TypeConstruct tc;
  int type_exists;
  if (!((&typepool)->nr)) typepool_init();
  tc.pos=((&typepool)->nr);
  tc.conssize=size;
  tc.name=name;
  type_exists = fx_contains(&typepool, &(tc));
  if (type_exists) {
    Type t=type_exists-1;
    if (!((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).construct)) {
      (*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).construct=construct;
    }
    if (!((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).destruct)) {
      (*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).destruct=destruct;
    }
    if (!((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).copy)) {
      (*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).copy=copy;
    }
    return t;
  }
  tc.construct=construct;
  tc.destruct=destruct;
  tc.copy=copy;
  tc.conskind=0;
  fx_add(&typepool, &(tc));
  return tc.pos;
}

canonical_original_code:
unsigned int define_type(char *name, int size, void (*construct)(void **), void (*destruct)(void *), void (*copy)(void **, void *))
{
  struct TypeConstruct tc;
  int type_exists;
  if (!((&typepool)->nr)) typepool_init();
  tc.pos=((&typepool)->nr);
  tc.conssize=size;
  tc.name=name;
  type_exists = fx_contains(&typepool, &(tc));
  if (type_exists) {
    unsigned int t = type_exists-1;
    if (!((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).construct)) {
      (*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).construct=construct;
    }
    if (!((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).destruct)) {
      (*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).destruct=destruct;
    }
    if (!((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).copy)) {
      (*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).copy=copy;
    }
    return t;
  }
  tc.construct=construct;
  tc.destruct=destruct;
  tc.copy=copy;
  tc.conskind=0;
  fx_add(&typepool, &(tc));
  return tc.pos;
}

variable_types:
name
char *

variable_types: size int

variable_types:
construct
void (*)(void **)

variable_types:
destruct
void (*)(void *)

variable_types:
copy
void (*)(void **, void *)

variable_types:
t
unsigned int

return_type: unsigned int


decompiled_code:
__int16 __fastcall lookup_type(char *src)
{
int v1; // eax
int v2; // edx
__int16 result; // ax
int v4; // edx
char v5[3]; // [rsp+1h] [rbp-44Bh] BYREF
char v6[1024]; // [rsp+4h] [rbp-448h] BYREF
char v7[8]; // [rsp+404h] [rbp-48h] BYREF
char *v8; // [rsp+40Ch] [rbp-40h]

if ( !dword_3E8 )
typepool_init();
strcpy(v6, src);
v1 = strlen(v6);
if ( !strcmp(&v5[v1], "Ref") )
{
v6[v1 - 3] = 0;
v8 = v6;
v2 = fx_contains(&typepool, v7);
LOBYTE(result) = v2 - 1;
HIBYTE(result) = ((unsigned __int16)(v2 - 1) >> 8) | 0x80;
if ( !v2 )
result = 0;
}
else
{
v8 = v6;
v4 = fx_contains(&typepool, v7);
result = v4 - 1;
if ( !v4 )
result = 0;
}
return result;
}

canonical_decompiled_code:
__int16 __fastcall func3(char *src)
{
int v1; // eax
int v2; // edx
__int16 result; // ax
int v4; // edx
char v5[3]; // [rsp+1h] [rbp-44Bh] BYREF
char v6[1024]; // [rsp+4h] [rbp-448h] BYREF
char v7[8]; // [rsp+404h] [rbp-48h] BYREF
char *v8; // [rsp+40Ch] [rbp-40h]

if ( !dword_3E8 )
func0();
strcpy(v6, src);
v1 = strlen(v6);
if ( !strcmp(&v5[v1], "Ref") )
{
v6[v1 - 3] = 0;
v8 = v6;
v2 = fx_contains(&typepool, v7);
LOBYTE(result) = v2 - 1;
HIBYTE(result) = ((unsigned __int16)(v2 - 1) >> 8) | 0x80;
if ( !v2 )
result = 0;
}
else
{
v8 = v6;
v4 = fx_contains(&typepool, v7);
result = v4 - 1;
if ( !v4 )
result = 0;
}
return result;
}

original_code:
Type lookup_type(char *name)
{
  TypeConstruct tc;
  char unrefname[1024];
  int isref, len,i;
  if (!((&typepool)->nr)) typepool_init();
  isref=0;
  strcpy(unrefname, name);
  len=strlen(unrefname);
  if (!strcmp(unrefname+len-refextlen, refext)) {
    unrefname[len-refextlen]=0;
    isref=1;
  }
  tc.name=unrefname;
  i = fx_contains(&typepool, &(tc));
  if (i) {
    if (isref) return ((i-1)|0x8000);
    else return i-1;
  } else
    return 0;
}

canonical_original_code:
unsigned int lookup_type(char *name)
{
  struct TypeConstruct tc;
  char unrefname[1024];
  int isref; int len; int i;
  if (!((&typepool)->nr)) typepool_init();
  isref=0;
  strcpy(unrefname, name);
  len=strlen(unrefname);
  if (!strcmp(unrefname+len-refextlen, refext)) {
    unrefname[len-refextlen]=0;
    isref=1;
  }
  tc.name=unrefname;
  i = fx_contains(&typepool, &(tc));
  if (i) {
    if (isref) return ((i-1)|0x8000);
    else return i-1;
  } else
    return 0;
}

variable_types:
unrefname
char [1024]

variable_types: isref int

variable_types: len int

variable_types: i int


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

if ( (a1 & 0x8000) != 0 )
a1 &= 0x7FFFu;
result = "???";
if ( a1 )
{
if ( dword_3E8 > a1 )
result = *(const char **)(typepool + dword_3F0 * a1 + 8);
}
return result;
}

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

if ( (a1 & 0x8000) != 0 )
a1 &= 0x7FFFu;
result = "???";
if ( a1 )
{
if ( dword_3E8 > a1 )
result = *(const char **)(typepool + dword_3F0 * a1 + 8);
}
return result;
}

original_code:
char *lookup_typename(Type t)
{
  if ((((t)&0x8000)>0)) t=((t)&0x7fff);
  if (t<1 || t>=((&typepool)->nr)) return "???";
  return (*((TypeConstruct*) (((char*)(&typepool)->arr) + ((t))*((&typepool)->size)))).name;
}

canonical_original_code:
char *lookup_typename(unsigned int t)
{
  if ((((t)&0x8000)>0)) t=((t)&0x7fff);
  if (t<1 || t>=((&typepool)->nr)) return "???";
  return (*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((t))*((&typepool)->size)))).name;
}

return_type: char *


ConstructValue

decompiled_code:
void __fastcall ConstructValue(__int64 a1)
{
void (__fastcall *v1)(__int64); // rax

if ( a1 )
{
if ( (BYTE1(*(_DWORD *)a1) & 0x80u) == 0 )
{
v1 = *(void (__fastcall **)(__int64))(typepool + dword_3F0 * (*(_DWORD *)a1 & 0x1FFFu) + 16);
if ( v1 )
v1(a1 + 8);
else
*(_QWORD *)(a1 + 8) = 0LL;
}
else
{
*(_QWORD *)(a1 + 8) = 0LL;
}
}
}

original_code:
void ConstructValue(Value* v)
{
  Type t;
  if (!v) return;
  t=v->type;
  if ((((t)&0x8000)>0)) {
    v->val.stval=0;
  } else {
    if ((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).construct) {
      (*((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).construct))(&v->val.stval);
    } else {
      v->val.stval=0;
    }
  }
}

canonical_original_code:
void ConstructValue(struct Value *v)
{
  unsigned int t;
  if (!v) return;
  t=v->type;
  if ((((t)&0x8000)>0)) {
    v->val.stval=0;
  } else {
    if ((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).construct) {
      (*((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).construct))(&v->val.stval);
    } else {
      v->val.stval=0;
    }
  }
}

variable_types: struct Value { unsigned int type; union TVal { int ival; double rval; void *stval; int *iref; double *rref; void **stref; } val; } *

user_defined_types: struct Value { unsigned int type; union TVal val; }


CopyValue

decompiled_code:
__int64 __fastcall CopyValue(unsigned int *a1, __int64 a2)
{
__int64 result; // rax
__int64 (__fastcall *v3)(unsigned int *, _QWORD); // rax
__int64 (__fastcall *v4)(unsigned int *, _QWORD); // rax

result = *a1;
if ( (result & 0x8000) == 0 )
{
if ( (*(_DWORD *)a2 & 0x8000) != 0 )
{
v3 = *(__int64 (__fastcall **)(unsigned int *, _QWORD))(typepool + dword_3F0 * (*a1 & 0x1FFF) + 32);
if ( v3 )
{
result = v3(a1 + 2, **(_QWORD **)(a2 + 8));
}
else
{
result = **(_QWORD **)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
}
else
{
v4 = *(__int64 (__fastcall **)(unsigned int *, _QWORD))(typepool + dword_3F0 * (*a1 & 0x1FFF) + 32);
if ( v4 )
{
result = v4(a1 + 2, *(_QWORD *)(a2 + 8));
}
else
{
result = *(_QWORD *)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
}
}
else if ( (*(_DWORD *)a2 & 0x8000) != 0 )
{
result = *(_QWORD *)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
else
{
*((_QWORD *)a1 + 1) = a2 + 8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int *a1, __int64 a2)
{
__int64 result; // rax
__int64 (__fastcall *v3)(unsigned int *, _QWORD); // rax
__int64 (__fastcall *v4)(unsigned int *, _QWORD); // rax

result = *a1;
if ( (result & 0x8000) == 0 )
{
if ( (*(_DWORD *)a2 & 0x8000) != 0 )
{
v3 = *(__int64 (__fastcall **)(unsigned int *, _QWORD))(typepool + dword_3F0 * (*a1 & 0x1FFF) + 32);
if ( v3 )
{
result = v3(a1 + 2, **(_QWORD **)(a2 + 8));
}
else
{
result = **(_QWORD **)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
}
else
{
v4 = *(__int64 (__fastcall **)(unsigned int *, _QWORD))(typepool + dword_3F0 * (*a1 & 0x1FFF) + 32);
if ( v4 )
{
result = v4(a1 + 2, *(_QWORD *)(a2 + 8));
}
else
{
result = *(_QWORD *)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
}
}
else if ( (*(_DWORD *)a2 & 0x8000) != 0 )
{
result = *(_QWORD *)(a2 + 8);
*((_QWORD *)a1 + 1) = result;
}
else
{
*((_QWORD *)a1 + 1) = a2 + 8;
}
return result;
}

original_code:
void CopyValue(Value* dest, Value* orig)
{
  if ((((dest->type)&0x8000)>0)) {
    if ((((orig->type)&0x8000)>0)) {
      dest->val.stref=orig->val.stref;
    } else {
      dest->val.stref=(void*) (&(orig->val));
    }
  } else {
    if ((((orig->type)&0x8000)>0)) {
      if ((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy) {
 (*((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy))(&dest->val.stval,
            *(orig->val.stref));
      } else {
 memcpy(&dest->val, orig->val.stref, sizeof(TVal));
      }
    } else {
      if ((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy) {
 (*((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy))(&dest->val.stval,
            orig->val.stval);
      } else {
 dest->val=orig->val;
      }
    }
  }
}

canonical_original_code:
void CopyValue(struct Value *dest, struct Value *orig)
{
  if ((((dest->type)&0x8000)>0)) {
    if ((((orig->type)&0x8000)>0)) {
      dest->val.stref=orig->val.stref;
    } else {
      dest->val.stref=(void *) (&(orig->val));
    }
  } else {
    if ((((orig->type)&0x8000)>0)) {
      if ((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy) {
 (*((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy))(&dest->val.stval,
            *(orig->val.stref));
      } else {
 memcpy(&dest->val, orig->val.stref, sizeof(TVal));
      }
    } else {
      if ((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy) {
 (*((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((dest->type)&0x1fff)))*((&typepool)->size)))).copy))(&dest->val.stval,
            orig->val.stval);
      } else {
 dest->val=orig->val;
      }
    }
  }
}

variable_types:
orig
struct Value *

user_defined_types: union TVal { int ival; double rval; void *stval; int *iref; double *rref; void **stref; }


DestructValue

decompiled_code:
void __fastcall DestructValue(__int64 a1)
{
void (__fastcall *v1)(_QWORD); // rax

if ( a1 && (BYTE1(*(_DWORD *)a1) & 0x80u) == 0 )
{
v1 = *(void (__fastcall **)(_QWORD))(typepool + dword_3F0 * (*(_DWORD *)a1 & 0x1FFFu) + 24);
if ( v1 )
v1(*(_QWORD *)(a1 + 8));
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
void (__fastcall *v1)(_QWORD); // rax

if ( a1 && (BYTE1(*(_DWORD *)a1) & 0x80u) == 0 )
{
v1 = *(void (__fastcall **)(_QWORD))(typepool + dword_3F0 * (*(_DWORD *)a1 & 0x1FFFu) + 24);
if ( v1 )
v1(*(_QWORD *)(a1 + 8));
}
}

original_code:
void DestructValue(Value* v)
{
  Type t;
  if (!v) return;
  t=v->type;
  if (!(((t)&0x8000)>0)) {
    if ((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).destruct) {
      (*((*((TypeConstruct*) (((char*)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).destruct))(v->val.stval);
    }
  }
}

canonical_original_code:
void DestructValue(struct Value *v)
{
  unsigned int t;
  if (!v) return;
  t=v->type;
  if (!(((t)&0x8000)>0)) {
    if ((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).destruct) {
      (*((*((struct TypeConstruct *) (((char *)(&typepool)->arr) + ((((t)&0x1fff)))*((&typepool)->size)))).destruct))(v->val.stval);
    }
  }
}


original_code:
static int expand_flex(FlexArray *fl, int sz)
{
    if (fl->max < sz+1) {
        void *temp;
 if (fl->arr)
     temp = (void *) realloc(fl->arr, fl->size * (32 * ((sz+1)/32 +1)));
 else
     temp = (void*) malloc(fl->size * (32 * ((sz+1)/32 +1)));
 if (!temp) return 0;
 fl->arr = temp;
 fl->max = (32 * ((sz+1)/32 +1));
    }
    return 1;
}

canonical_original_code:
static int expand_flex(struct FlexArray *fl, int sz)
{
    if (fl->max < sz+1) {
        void *temp;
 if (fl->arr)
     temp = (void *) realloc(fl->arr, fl->size * (32 * ((sz+1)/32 +1)));
 else
     temp = (void *) malloc(fl->size * (32 * ((sz+1)/32 +1)));
 if (!temp) return 0;
 fl->arr = temp;
 fl->max = (32 * ((sz+1)/32 +1));
    }
    return 1;
}

variable_types: struct FlexArray { void *arr; int nr; int max; int size; int (*comp)(void *, void *); } *

variable_types: sz int

variable_types:
temp
void *


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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

original_code:
int int_cmp(const void *x, const void *y)
{
    return (*((int*)x) < *((int*)y) ? -1 : (*((int*)x) == *((int*)y) ? 0 : 1));
}

variable_types:
x
void *

variable_types:
y
void *


decompiled_code:
__int64 __fastcall fx_contains(__int64 a1, __int64 a2)
{
int v2; // ebp

if ( *(int *)(a1 + 8) <= 0 )
return 0LL;
v2 = 0;
while ( (*(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 24))(*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * v2, a2) )
{
if ( *(_DWORD *)(a1 + 8) <= ++v2 )
return 0LL;
}
return (unsigned int)(v2 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
int v2; // ebp

if ( *(int *)(a1 + 8) <= 0 )
return 0LL;
v2 = 0;
while ( (*(unsigned int (__fastcall **)(_QWORD, __int64))(a1 + 24))(*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * v2, a2) )
{
if ( *(_DWORD *)(a1 + 8) <= ++v2 )
return 0LL;
}
return (unsigned int)(v2 + 1);
}

original_code:
int fx_contains(FlexArray *fl, void *item)
{
    int i=0;
    if (!fl->nr) return 0;
    while (i<fl->nr) {
 if (!(fl->comp((char*)fl->arr+i*fl->size, item)))
     return i+1;
 i++;
    }
    return 0;
}

canonical_original_code:
int fx_contains(struct FlexArray *fl, void *item)
{
    int i = 0;
    if (!fl->nr) return 0;
    while (i<fl->nr) {
 if (!(fl->comp((char *)fl->arr+i*fl->size, item)))
     return i+1;
 i++;
    }
    return 0;
}

variable_types:
item
void *

user_defined_types: struct FlexArray { void *arr; int nr; int max; int size; int (*comp)(void *, void *); }


decompiled_code:
__int64 __fastcall fx_remove(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // er12
int v4; // ebp
int v5; // eax

result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result )
{
if ( (int)result <= 0 )
{
v3 = 0;
}
else
{
v3 = 0;
v4 = 0;
do
{
v5 = (*(__int64 (__fastcall **)(_QWORD, __int64))(a1 + 24))(*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * v4, a2);
if ( v3 && v5 )
membwd(
*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * (v4 - v3),
*(_QWORD *)a1 + v4 * *(_DWORD *)(a1 + 16),
*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * (v4 + 1));
else
v3 += v5 == 0;
++v4;
LODWORD(result) = *(_DWORD *)(a1 + 8);
}
while ( (int)result > v4 );
}
result = (unsigned int)(result - v3);
*(_DWORD *)(a1 + 8) = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v3; // er12
int v4; // ebp
int v5; // eax

result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result )
{
if ( (int)result <= 0 )
{
v3 = 0;
}
else
{
v3 = 0;
v4 = 0;
do
{
v5 = (*(__int64 (__fastcall **)(_QWORD, __int64))(a1 + 24))(*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * v4, a2);
if ( v3 && v5 )
func0(
*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * (v4 - v3),
*(_QWORD *)a1 + v4 * *(_DWORD *)(a1 + 16),
*(_QWORD *)a1 + *(_DWORD *)(a1 + 16) * (v4 + 1));
else
v3 += v5 == 0;
++v4;
LODWORD(result) = *(_DWORD *)(a1 + 8);
}
while ( (int)result > v4 );
}
result = (unsigned int)(result - v3);
*(_DWORD *)(a1 + 8) = result;
}
return result;
}

original_code:
void fx_remove(FlexArray *fl, void *item)
{
    int i,delta,cmpres;
    if (!fl->nr) return;
    delta=0;
    for (i=0; i<fl->nr; i++) {
 cmpres = !(fl->comp((char*)fl->arr+i*fl->size, item));
 if (delta && !cmpres)
     membwd((char*)fl->arr+(i-delta)*fl->size,
     (char*)fl->arr+i*fl->size,
     (char*)fl->arr+(i+1)*fl->size);
 if (cmpres) delta++;
    }
    fl->nr = fl->nr-delta;
}

canonical_original_code:
void fx_remove(struct FlexArray *fl, void *item)
{
    int i; int delta; int cmpres;
    if (!fl->nr) return;
    delta=0;
    for (i=0; i<fl->nr; i++) {
 cmpres = !(fl->comp((char *)fl->arr+i*fl->size, item));
 if (delta && !cmpres)
     membwd((char *)fl->arr+(i-delta)*fl->size,
     (char *)fl->arr+i*fl->size,
     (char *)fl->arr+(i+1)*fl->size);
 if (cmpres) delta++;
    }
    fl->nr = fl->nr-delta;
}

variable_types: delta int

variable_types: cmpres int


original_code:
void fx_add(FlexArray *fl, void *item)
{
    if (!expand_flex(fl, fl->nr)) return;
    membwd((char*)fl->arr+fl->nr*fl->size,(char*)item,(char*)item+fl->size);
    fl->nr++;
}

canonical_original_code:
void fx_add(struct FlexArray *fl, void *item)
{
    if (!expand_flex(fl, fl->nr)) return;
    membwd((char *)fl->arr+fl->nr*fl->size,(char *)item,(char *)item+fl->size);
    fl->nr++;
}


original_code:
int fx_switch(FlexArray *fl, void *olditem, void *newitem)
{
    int i,changed=0;
    i=0;
    while (i<fl->nr) {
 if (!fl->comp((char*)fl->arr+i*fl->size, olditem)) {
     membwd((char*)fl->arr+i*fl->size,(char*)newitem,(char*)newitem+fl->size);
     changed=i+1;
 }
 i++;
    }
    return changed;
}

canonical_original_code:
int fx_switch(struct FlexArray *fl, void *olditem, void *newitem)
{
    int i; int changed = 0;
    i=0;
    while (i<fl->nr) {
 if (!fl->comp((char *)fl->arr+i*fl->size, olditem)) {
     membwd((char *)fl->arr+i*fl->size,(char *)newitem,(char *)newitem+fl->size);
     changed=i+1;
 }
 i++;
    }
    return changed;
}

variable_types:
olditem
void *

variable_types:
newitem
void *

variable_types: changed int


original_code:
void fx_init(FlexArray *fl, int sz, int (*cmp)(const void*,const void*))
{
    fl->size=sz;
    fl->comp=cmp;
    fl->max=0;
    fl->nr=0;
    fl->arr=((void *)0);
}

canonical_original_code:
void fx_init(struct FlexArray *fl, int sz, int (*cmp)(void *, void *))
{
    fl->size=sz;
    fl->comp=cmp;
    fl->max=0;
    fl->nr=0;
    fl->arr=((void *)0);
}

variable_types:
cmp
int (*)(void *, void *)


original_code:
void fx_clear(FlexArray *fl)
{
    fl->max=0;
    fl->nr=0;
    if (fl->arr) free(fl->arr);
    fl->arr = 0;
}

canonical_original_code:
void fx_clear(struct FlexArray *fl)
{
    fl->max=0;
    fl->nr=0;
    if (fl->arr) free(fl->arr);
    fl->arr = 0;
}


decompiled_code:
__int64 __fastcall fx_set(__int64 a1, int a2, __int64 a3)
{
__int64 result; // rax
int v4; // ebp
int v6; // esi
int v7; // eax

result = 0LL;
if ( a2 >= 0 )
{
v4 = a2;
v6 = *(_DWORD *)(a1 + 8);
if ( v6 > v4 || (result = expand_flex(a1, v6), (_DWORD)result) )
{
if ( *(_DWORD *)(a1 + 8) <= v4 )
v4 = *(_DWORD *)(a1 + 8);
membwd(*(_QWORD *)a1 + v4 * *(_DWORD *)(a1 + 16), a3, a3 + *(int *)(a1 + 16));
v7 = *(_DWORD *)(a1 + 8);
if ( v4 == v7 )
*(_DWORD *)(a1 + 8) = v7 + 1;
result = (unsigned int)(v4 + 1);
}
}
return result;
}

original_code:
int fx_set(FlexArray *fl, int pos, void *item)
{
    if (pos<0) return 0;
    if (pos>=fl->nr && !expand_flex(fl,fl->nr)) return 0;
    if (pos>=fl->nr) pos = fl->nr;
    membwd((char*)fl->arr+pos*fl->size,(char*)item,(char*)item+fl->size);
    if (pos==fl->nr) fl->nr++;
    return pos+1;
}

canonical_original_code:
int fx_set(struct FlexArray *fl, int pos, void *item)
{
    if (pos<0) return 0;
    if (pos>=fl->nr && !expand_flex(fl,fl->nr)) return 0;
    if (pos>=fl->nr) pos = fl->nr;
    membwd((char *)fl->arr+pos*fl->size,(char *)item,(char *)item+fl->size);
    if (pos==fl->nr) fl->nr++;
    return pos+1;
}

variable_types: pos int


decompiled_code:
void *__fastcall fx_copy(__int64 a1)
{
size_t v1; // rbx
void *v2; // rax
void *v3; // rbp

v1 = *(_DWORD *)(a1 + 8) * *(_DWORD *)(a1 + 16);
v2 = malloc(v1);
v3 = v2;
if ( v2 )
memcpy(v2, *(const void **)a1, v1);
return v3;
}

canonical_decompiled_code:
void *__fastcall func10(__int64 a1)
{
size_t v1; // rbx
void *v2; // rax
void *v3; // rbp

v1 = *(_DWORD *)(a1 + 8) * *(_DWORD *)(a1 + 16);
v2 = malloc(v1);
v3 = v2;
if ( v2 )
memcpy(v2, *(const void **)a1, v1);
return v3;
}

original_code:
void *fx_copy(FlexArray *fl)
{
    void *res;
    res = malloc(fl->size*fl->nr);
    if (res) memcpy(res, fl->arr, fl->size*fl->nr);
    return res;
}

canonical_original_code:
void *fx_copy(struct FlexArray *fl)
{
    void *res;
    res = malloc(fl->size*fl->nr);
    if (res) memcpy(res, fl->arr, fl->size*fl->nr);
    return res;
}

variable_types:
res
void *

return_type: void *


decompiled_code:
void func_free()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
static void func_free(void *var __attribute__((unused)))
{
}

canonical_original_code:
static void func_free(void *var)
{
}

variable_types:
var
void *


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

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

original_code:
static int func_cmp(const void *func1, const void *func2)
{
    return strcmp(((FunctionDef*)func1)->name, ((FunctionDef*)func2)->name);
}

canonical_original_code:
static int func_cmp(void *func1, void *func2)
{
    return strcmp(((struct FunctionDef *)func1)->name, ((struct FunctionDef *)func2)->name);
}

user_defined_types: struct FunctionDef { char *name; char *description; char nr_args; char functype; unsigned int restype; struct Prototype *prototype; void (*funcptr)(); }

user_defined_types: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); }


original_code:
FuncRef define_function(char *name, char *description,
   Prototype *prototype, void (*funcptr)())
{
    FunctionDef fdef;
    fdef.name=name;
    fdef.description=description;
    fdef.nr_args=((prototype)->n);
    fdef.restype=((prototype)->restype);
    fdef.prototype=prototype;
    fdef.funcptr=funcptr;
    LT_insert(&funcpool, &fdef);
    return (FuncRef) LT_found_leaf();
}

canonical_original_code:
struct FuncDef *define_function(char *name, char *description, struct Prototype *prototype, void (*funcptr)())
{
    struct FunctionDef fdef;
    fdef.name=name;
    fdef.description=description;
    fdef.nr_args=((prototype)->n);
    fdef.restype=((prototype)->restype);
    fdef.prototype=prototype;
    fdef.funcptr=funcptr;
    LT_insert(&funcpool, &fdef);
    return (struct FuncDef *) LT_found_leaf();
}

variable_types:
name
char *

variable_types:
description
char *

variable_types:
funcptr
void (*)()

variable_types: struct FunctionDef { char *name; char *description; char nr_args; char functype; unsigned int restype; struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *prototype; void (*funcptr)(); }

return_type: struct FuncDef { char *name; char *description; char nr_args; char functype; unsigned int rettype; void *prototype; } *


decompiled_code:
__int64 __fastcall lookup_function(__int64 a1)
{
__int64 result; // rax
__int64 v2[7]; // [rsp+0h] [rbp-38h] BYREF

v2[0] = a1;
result = LT_member(&funcpool, v2);
if ( result )
result = LT_found_leaf();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
__int64 v2[7]; // [rsp+0h] [rbp-38h] BYREF

v2[0] = a1;
result = LT_member(&funcpool, v2);
if ( result )
result = LT_found_leaf();
return result;
}

original_code:
FuncRef lookup_function(char *name)
{
    FunctionDef fdef;
    fdef.name=name;
    if (LT_member(&funcpool,&fdef)) {
 return LT_found_leaf();
    } else {
 return 0;
    }
}

canonical_original_code:
struct FuncDef *lookup_function(char *name)
{
    struct FunctionDef fdef;
    fdef.name=name;
    if (LT_member(&funcpool,&fdef)) {
 return LT_found_leaf();
    } else {
 return 0;
    }
}

user_defined_types: struct FuncDef { char *name; char *description; char nr_args; char functype; unsigned int rettype; void *prototype; }


decompiled_code:
__int64 __fastcall proto_function(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = *(_QWORD *)(a1 + 24);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
__int64 result; // rax

if ( a1 )
result = *(_QWORD *)(a1 + 24);
else
result = 0LL;
return result;
}

original_code:
Prototype *proto_function(FuncRef function)
{
    return (Prototype*) (function?function->prototype:0);
}

canonical_original_code:
struct Prototype *proto_function(struct FuncDef *function)
{
    return (struct Prototype *) (function?function->prototype:0);
}

variable_types: struct FuncDef { char *name; char *description; char nr_args; char functype; unsigned int rettype; void *prototype; } *

return_type: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *


decompiled_code:
__int64 __fastcall restype_function(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 + 20);
}

original_code:
Type restype_function(FuncRef function)
{
    return ((FunctionDef*)function)->restype;
}

canonical_original_code:
unsigned int restype_function(struct FuncDef *function)
{
    return ((struct FunctionDef *)function)->restype;
}


original_code:
int call_function(FuncRef function, Value **list)
{
    Type t;
    FunctionDef *fdef = (FunctionDef*) function;
    void *refval[50];
    void *argval[50];
    Value *v;
    int i,n;
    if (error_status) return error_status;
    if (!((fdef->prototype)->caller)) {
 error_status = 2;
 return 2;
    }
    n=((fdef->prototype)->n);
    for (i=0; i<n; i++) {
 v=list[i];
 t = (((i)<0||(i)>=(fdef->prototype)->n) ? 0 : (fdef->prototype)->type[i]);
        if (!((!(((t)^(v->type))&0x1FFF)) && (((t)^(v->type))!=0xC000))) {
     error_status = 1;
     return 1;
 }
 if ((((t)&0x8000)>0)) {
     if ((((v->type)&0x8000)>0)) {
  argval[i]=&v->val;
     } else {
  refval[i]=&v->val;
  argval[i]=&refval[i];
     }
 } else {
     if ((((v->type)&0x8000)>0)) {
  argval[i]= *((void**)(&v->val));
     } else {
  argval[i]=&v->val;
     }
 }
    }
    t=fdef->restype;
    if (t) {
      v=list[i];
      t=((t)|0x8000);
      if ((((v->type)&0x8000)>0)) {
 argval[i]=&v->val;
      } else {
 refval[i]=&v->val;
 argval[i]=&refval[i];
      }
    }
    (((fdef->prototype)->caller))(fdef->funcptr, &argval);
    return error_status;
}

canonical_original_code:
int call_function(struct FuncDef *function, struct Value **list)
{
    unsigned int t;
    struct FunctionDef *fdef = (FunctionDef*) function;
    void *refval[50];
    void *argval[50];
    struct Value *v;
    int i; int n;
    if (error_status) return error_status;
    if (!((fdef->prototype)->caller)) {
 error_status = 2;
 return 2;
    }
    n=((fdef->prototype)->n);
    for (i=0; i<n; i++) {
 v=list[i];
 t = (((i)<0||(i)>=(fdef->prototype)->n) ? 0 : (fdef->prototype)->type[i]);
        if (!((!(((t)^(v->type))&0x1FFF)) && (((t)^(v->type))!=0xC000))) {
     error_status = 1;
     return 1;
 }
 if ((((t)&0x8000)>0)) {
     if ((((v->type)&0x8000)>0)) {
  argval[i]=&v->val;
     } else {
  refval[i]=&v->val;
  argval[i]=&refval[i];
     }
 } else {
     if ((((v->type)&0x8000)>0)) {
  argval[i]= *((void **)(&v->val));
     } else {
  argval[i]=&v->val;
     }
 }
    }
    t=fdef->restype;
    if (t) {
      v=list[i];
      t=((t)|0x8000);
      if ((((v->type)&0x8000)>0)) {
 argval[i]=&v->val;
      } else {
 refval[i]=&v->val;
 argval[i]=&refval[i];
      }
    }
    (((fdef->prototype)->caller))(fdef->funcptr, &argval);
    return error_status;
}

variable_types: struct Value { unsigned int type; union TVal { int ival; double rval; void *stval; int *iref; double *rref; void **stref; } val; } **

variable_types:
t
unsigned int

variable_types: struct FunctionDef { char *name; char *description; char nr_args; char functype; unsigned int restype; struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *prototype; void (*funcptr)(); } *

variable_types:
refval
void *[50]

variable_types:
argval
void *[50]

variable_types: i int

variable_types: n int


decompiled_code:
__int64 __fastcall font_handle(int a1, _DWORD *a2)
{
*a2 = font_change_attribute((unsigned int)*a2, (a1 >> 5) & 0x1F, a1 & 0x1F);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, _DWORD *a2)
{
*a2 = font_change_attribute((unsigned int)*a2, (a1 >> 5) & 0x1F, a1 & 0x1F);
return 0LL;
}

original_code:
static Uchar *font_handle(int lowvalue, Attribute *attr, RedirectFunc *func)
{
    int attribute,value;
    int curattr;
    curattr=attr->font;
    attribute=(lowvalue&0x3e0)>>5;
    value=(lowvalue&0x1f);
    attr->font=font_change_attribute(curattr, attribute, value);
    return 0;
}

canonical_original_code:
static unsigned short *font_handle(int lowvalue, struct _attribs *attr, int (**func)(unsigned short))
{
    int attribute; int value;
    int curattr;
    curattr=attr->font;
    attribute=(lowvalue&0x3e0)>>5;
    value=(lowvalue&0x1f);
    attr->font=font_change_attribute(curattr, attribute, value);
    return 0;
}

variable_types: lowvalue int

variable_types: struct _attribs { int font; int fgcolor; int bgcolor; int language; int country; int direction; int text; int plane; void *object; int pos; int posdelta; } *

variable_types:
func
int (**)(unsigned short)

variable_types: attribute int

variable_types: value int

variable_types: curattr int

return_type: unsigned short *


decompiled_code:
int font_markup_init()
{
int result; // eax
__int64 v1; // rax
const char *v2; // rax

result = add_markup_handler(56193LL, font_print, font_handle);
if ( !result )
{
v1 = translate("Unable to add font handler.\n");
v2 = (const char *)UstrtoLocale(v1);
result = fprintf(stderr, v2);
}
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
__int64 v1; // rax
const char *v2; // rax

result = add_markup_handler(56193LL, font_print, font_handle);
if ( !result )
{
v1 = translate("Unable to add font handler.\n");
v2 = (const char *)UstrtoLocale(v1);
result = fprintf(stderr, v2);
}
return result;
}

original_code:
void font_markup_init(void)
{
    if (!add_markup_handler(FontAttrib, font_print, font_handle)) {
 fprintf(stderr,
  UstrtoLocale(translate("Unable to add font handler.\n")));
    }
}

canonical_original_code:
void font_markup_init()
{
    if (!add_markup_handler(FontAttrib, font_print, font_handle)) {
 fprintf(stderr,
  UstrtoLocale(translate("Unable to add font handler.\n")));
    }
}


decompiled_code:
int check_property()
{
_BOOL4 v0; // eax
unsigned __int8 *v2; // [rsp+8h] [rbp-30h] BYREF
unsigned __int64 v3; // [rsp+10h] [rbp-28h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-20h] BYREF
int v5; // [rsp+24h] [rbp-14h] BYREF
Atom v6[2]; // [rsp+28h] [rbp-10h] BYREF

XGetWindowProperty(display, testwin, testend, 0LL, 512LL, 0, textprop, v6, &v5, &v4, &v3, &v2);
v0 = 0;
if ( v4 == 3 )
v0 = strcmp((const char *)v2, "Yes") == 0;
other_prog_ex |= v0;
return XFree(v2);
}

canonical_decompiled_code:
int func2()
{
_BOOL4 v0; // eax
unsigned __int8 *v2; // [rsp+8h] [rbp-30h] BYREF
unsigned __int64 v3; // [rsp+10h] [rbp-28h] BYREF
unsigned __int64 v4; // [rsp+18h] [rbp-20h] BYREF
int v5; // [rsp+24h] [rbp-14h] BYREF
Atom v6[2]; // [rsp+28h] [rbp-10h] BYREF

XGetWindowProperty(display, testwin, testend, 0LL, 512LL, 0, textprop, v6, &v5, &v4, &v3, &v2);
v0 = 0;
if ( v4 == 3 )
v0 = strcmp((const char *)v2, "Yes") == 0;
other_prog_ex |= v0;
return XFree(v2);
}

original_code:
static void check_property(void)
{
    Atom actt;
    int actf;
    unsigned long nit, baf;
    unsigned char *prp;
    XGetWindowProperty(display, testwin, testend, 0, 512, 0, textprop,
         &actt, &actf, &nit, &baf, &prp);
    other_prog_ex |= (nit==3 && !strcmp((char*)prp, "Yes"));
    XFree(prp);
}

canonical_original_code:
static void check_property()
{
    unsigned long actt;
    int actf;
    unsigned long nit; unsigned long baf;
    unsigned char *prp;
    XGetWindowProperty(display, testwin, testend, 0, 512, 0, textprop,
         &actt, &actf, &nit, &baf, &prp);
    other_prog_ex |= (nit==3 && !strcmp((char *)prp, "Yes"));
    XFree(prp);
}

variable_types:
actt
unsigned long

variable_types: actf int

variable_types:
nit
unsigned long

variable_types:
baf
unsigned long

variable_types:
prp
unsigned char *


decompiled_code:
int check_event()
{
Window v0; // rax

LODWORD(v0) = event.type;
if ( event.type == 28 )
{
v0 = event.xkey.root;
if ( v0 == dummy && event.xexpose.count == 1 )
{
propempty = 1;
}
else if ( v0 == testend )
{
if ( event.xexpose.count )
{
if ( event.xexpose.count == 1 )
{
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
exit(0);
}
}
else
{
LODWORD(v0) = check_property();
}
}
}
else if ( event.type == 17 )
{
LODWORD(v0) = testwin;
if ( event.xkey.root == testwin )
exit(0);
}
return v0;
}

canonical_decompiled_code:
int func4()
{
Window v0; // rax

LODWORD(v0) = event.type;
if ( event.type == 28 )
{
v0 = event.xkey.root;
if ( v0 == dummy && event.xexpose.count == 1 )
{
propempty = 1;
}
else if ( v0 == testend )
{
if ( event.xexpose.count )
{
if ( event.xexpose.count == 1 )
{
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
exit(0);
}
}
else
{
LODWORD(v0) = func2();
}
}
}
else if ( event.type == 17 )
{
LODWORD(v0) = testwin;
if ( event.xkey.root == testwin )
exit(0);
}
return v0;
}

original_code:
static void check_event(void)
{
    if (event.type==28 &&
 event.xproperty.atom==dummy &&
 event.xproperty.state==1)
 propempty=1;
    else if (event.type==28 &&
      event.xproperty.atom==testend &&
      event.xproperty.state==0)
 check_property();
    else if (event.type==28 &&
      event.xproperty.atom==testend &&
      event.xproperty.state==1) {
 XDeleteProperty(display, testwin, testend);
 XCloseDisplay(display);
 exit(0);
    } else if (event.type==17 &&
        event.xdestroywindow.window==testwin)
 exit(0);
}

canonical_original_code:
static void check_event()
{
    if (event.type==28 &&
 event.xproperty.atom==dummy &&
 event.xproperty.state==1)
 propempty=1;
    else if (event.type==28 &&
      event.xproperty.atom==testend &&
      event.xproperty.state==0)
 check_property();
    else if (event.type==28 &&
      event.xproperty.atom==testend &&
      event.xproperty.state==1) {
 XDeleteProperty(display, testwin, testend);
 XCloseDisplay(display);
 exit(0);
    } else if (event.type==17 &&
        event.xdestroywindow.window==testwin)
 exit(0);
}


decompiled_code:
int read_input()
{
__int64 v0; // rdx
_QWORD *v1; // rbx
int v2; // er12
int *v3; // rbp
int v4; // ebx
__int64 v5; // rbx
int v6; // ebp
_DWORD *v7; // r12
int result; // eax

v0 = (unsigned int)oldfileflag;
BYTE1(v0) = BYTE1(oldfileflag) | 8;
fcntl(filenof, 4, v0);
do
{
v5 = endstack;
if ( endstack )
{
v6 = allocsize;
if ( allocsize - *(_DWORD *)(endstack + 8) <= 99 )
{
v7 = malloc(0x18uLL);
*(_QWORD *)(v5 + 16) = v7;
endstack = (__int64)v7;
*(_QWORD *)v7 = malloc(v6);
v7[2] = 0;
*((_QWORD *)v7 + 2) = 0LL;
}
}
else
{
v1 = malloc(0x18uLL);
endstack = (__int64)v1;
beginstack = v1;
*v1 = malloc(allocsize);
*((_DWORD *)v1 + 2) = 0;
v1[2] = 0LL;
}
v2 = allocsize - *(_DWORD *)(endstack + 8);
v3 = _errno_location();
*v3 = 0;
v4 = fread((void *)(*(_QWORD *)endstack + *(int *)(endstack + 8)), 1uLL, v2, f);
if ( *v3 )
clearerr(f);
if ( v4 > 0 )
{
*(_DWORD *)(endstack + 8) += v4;
totlen += v4;
}
}
while ( v2 == v4 );
result = fcntl(filenof, 4, (unsigned int)oldfileflag);
*v3 = 0;
return result;
}

canonical_decompiled_code:
int func5()
{
__int64 v0; // rdx
_QWORD *v1; // rbx
int v2; // er12
int *v3; // rbp
int v4; // ebx
__int64 v5; // rbx
int v6; // ebp
_DWORD *v7; // r12
int result; // eax

v0 = (unsigned int)oldfileflag;
BYTE1(v0) = BYTE1(oldfileflag) | 8;
fcntl(filenof, 4, v0);
do
{
v5 = endstack;
if ( endstack )
{
v6 = allocsize;
if ( allocsize - *(_DWORD *)(endstack + 8) <= 99 )
{
v7 = malloc(0x18uLL);
*(_QWORD *)(v5 + 16) = v7;
endstack = (__int64)v7;
*(_QWORD *)v7 = malloc(v6);
v7[2] = 0;
*((_QWORD *)v7 + 2) = 0LL;
}
}
else
{
v1 = malloc(0x18uLL);
endstack = (__int64)v1;
beginstack = v1;
*v1 = malloc(allocsize);
*((_DWORD *)v1 + 2) = 0;
v1[2] = 0LL;
}
v2 = allocsize - *(_DWORD *)(endstack + 8);
v3 = _errno_location();
*v3 = 0;
v4 = fread((void *)(*(_QWORD *)endstack + *(int *)(endstack + 8)), 1uLL, v2, f);
if ( *v3 )
clearerr(f);
if ( v4 > 0 )
{
*(_DWORD *)(endstack + 8) += v4;
totlen += v4;
}
}
while ( v2 == v4 );
result = fcntl(filenof, 4, (unsigned int)oldfileflag);
*v3 = 0;
return result;
}

original_code:
static void read_input(void)
{
    int i,c;
    i=c=0;
    fcntl(filenof,4,oldfileflag|04000|0|04000);
    while (i==c) {
 if (!endstack) {
     beginstack=endstack=(STRSTACK*) malloc(sizeof(STRSTACK));
     endstack->str=(char*) malloc(sizeof(char)*allocsize);
     endstack->len=0;
     endstack->next=((void *)0);
 } else if (allocsize-endstack->len < 100) {
     endstack->next = (STRSTACK*) malloc(sizeof(STRSTACK));
     endstack=endstack->next;
     endstack->str=(char*) malloc(sizeof(char)*allocsize);
     endstack->len=0;
     endstack->next=0;
 }
 c=allocsize-endstack->len;
 (*__errno_location ())=0;
 i= fread(endstack->str+endstack->len, 1, c, f);
 if ((*__errno_location ())) clearerr(f);
 if (i>0) {
     endstack->len+=i;
     totlen+=i;
 }
    }
    fcntl(filenof,4,oldfileflag);
    (*__errno_location ())=0;
}

canonical_original_code:
static void read_input()
{
    int i; int c;
    i=c=0;
    fcntl(filenof,4,oldfileflag|04000|0|04000);
    while (i==c) {
 if (!endstack) {
     beginstack=endstack=(struct STRSTACK *) malloc(sizeof(STRSTACK));
     endstack->str=(char *) malloc(sizeof(char)*allocsize);
     endstack->len=0;
     endstack->next=((void *)0);
 } else if (allocsize-endstack->len < 100) {
     endstack->next = (struct STRSTACK *) malloc(sizeof(STRSTACK));
     endstack=endstack->next;
     endstack->str=(char *) malloc(sizeof(char)*allocsize);
     endstack->len=0;
     endstack->next=0;
 }
 c=allocsize-endstack->len;
 (*__errno_location ())=0;
 i= fread(endstack->str+endstack->len, 1, c, f);
 if ((*__errno_location ())) clearerr(f);
 if (i>0) {
     endstack->len+=i;
     totlen+=i;
 }
    }
    fcntl(filenof,4,oldfileflag);
    (*__errno_location ())=0;
}

variable_types: c int

user_defined_types: struct STRSTACK { char *str; int len; struct STRSTACK *next; }


decompiled_code:
int check_events()
{
int result; // eax
int v1; // ebx

while ( 1 )
{
result = XEventsQueued(display, 2);
v1 = result;
if ( !result )
break;
do
{
--v1;
XNextEvent(display, &event);
check_event();
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int func6()
{
int result; // eax
int v1; // ebx

while ( 1 )
{
result = XEventsQueued(display, 2);
v1 = result;
if ( !result )
break;
do
{
--v1;
XNextEvent(display, &event);
func4();
}
while ( v1 );
}
return result;
}

original_code:
static void check_events(void)
{
    int n=1,i;
    while (n) {
 i=n=XEventsQueued(display, 2);
 while (i) {
     i--;
     XNextEvent(display, &event);
     check_event();
 }
    }
}

canonical_original_code:
static void check_events()
{
    int n = 1; int i;
    while (n) {
 i=n=XEventsQueued(display, 2);
 while (i) {
     i--;
     XNextEvent(display, &event);
     check_event();
 }
    }
}


decompiled_code:
void __fastcall set_property(int a1)
{
unsigned __int8 *v2; // rax
unsigned __int8 *v3; // r14
_DWORD *v4; // r13
unsigned __int8 *v5; // rbp
int v6; // ebx
__int64 v7; // rdi
__int64 j; // rcx
unsigned __int8 *v9; // rax
int i; // edx

v2 = (unsigned __int8 *)malloc(a1);
v3 = v2;
v4 = beginstack;
if ( !beginstack || a1 <= 0 )
{
v6 = 0;
goto LABEL_16;
}
v5 = v2;
v6 = 0;
while ( 1 )
{
v9 = *(unsigned __int8 **)v4;
for ( i = v4[2]; i && a1 > v6; --i )
{
++v6;
*v5++ = *v9++;
}
if ( i )
{
v7 = *(_QWORD *)v4;
v4[2] = i;
for ( j = 0LL; j != i; ++j )
*(_BYTE *)(v7 + j) = v9[j];
v5 = (unsigned __int8 *)(v7 + (unsigned int)(i - 1) + 1);
goto LABEL_7;
}
free(*(void **)v4);
beginstack = (void *)*((_QWORD *)v4 + 2);
free(v4);
v4 = beginstack;
if ( !beginstack )
break;
LABEL_7:
if ( !v4 || a1 <= v6 )
goto LABEL_16;
}
endstack = 0LL;
LABEL_16:
totlen -= v6;
XChangeProperty(display, testwin, dummy, textprop, 8, 2, v3, v6);
XFlush(display);
propempty = 0;
free(v3);
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
unsigned __int8 *v2; // rax
unsigned __int8 *v3; // r14
_DWORD *v4; // r13
unsigned __int8 *v5; // rbp
int v6; // ebx
__int64 v7; // rdi
__int64 j; // rcx
unsigned __int8 *v9; // rax
int i; // edx

v2 = (unsigned __int8 *)malloc(a1);
v3 = v2;
v4 = beginstack;
if ( !beginstack || a1 <= 0 )
{
v6 = 0;
goto LABEL_16;
}
v5 = v2;
v6 = 0;
while ( 1 )
{
v9 = *(unsigned __int8 **)v4;
for ( i = v4[2]; i && a1 > v6; --i )
{
++v6;
*v5++ = *v9++;
}
if ( i )
{
v7 = *(_QWORD *)v4;
v4[2] = i;
for ( j = 0LL; j != i; ++j )
*(_BYTE *)(v7 + j) = v9[j];
v5 = (unsigned __int8 *)(v7 + (unsigned int)(i - 1) + 1);
goto LABEL_7;
}
free(*(void **)v4);
beginstack = (void *)*((_QWORD *)v4 + 2);
free(v4);
v4 = beginstack;
if ( !beginstack )
break;
LABEL_7:
if ( !v4 || a1 <= v6 )
goto LABEL_16;
}
endstack = 0LL;
LABEL_16:
totlen -= v6;
XChangeProperty(display, testwin, dummy, textprop, 8, 2, v3, v6);
XFlush(display);
propempty = 0;
free(v3);
}

original_code:
static void set_property(int size)
{
    STRSTACK *h;
    char *info=((void *)0);
    char *c,*d;
    int i=0,j=0;
    c = info = (char*) malloc(size*sizeof(char));
    h = beginstack;
    while (h && j<size) {
 d = h->str;
 i = h->len;
 while (i && j<size) {
     i--;j++;
     *c++=*d++;
 }
 if (!i) {
     free(h->str);
     beginstack = h->next;
     free(h);
     h = beginstack;
     if (!h) endstack=((void *)0);
 } else {
     c=h->str;
     h->len=i;
     while (i) {
  i--;
  *c++=*d++;
     }
 }
    }
    totlen=totlen-j;
    XChangeProperty(display,testwin,dummy,textprop,8,
      2,(unsigned char*)info,j);
    XFlush(display);
    propempty=0;
    free(info);
}

canonical_original_code:
static void set_property(int size)
{
    struct STRSTACK *h;
    char *info = ((void *)0);
    char *c; char *d;
    int i = 0; int j = 0;
    c = info = (char *) malloc(size*sizeof(char));
    h = beginstack;
    while (h && j<size) {
 d = h->str;
 i = h->len;
 while (i && j<size) {
     i--;j++;
     *c++=*d++;
 }
 if (!i) {
     free(h->str);
     beginstack = h->next;
     free(h);
     h = beginstack;
     if (!h) endstack=((void *)0);
 } else {
     c=h->str;
     h->len=i;
     while (i) {
  i--;
  *c++=*d++;
     }
 }
    }
    totlen=totlen-j;
    XChangeProperty(display,testwin,dummy,textprop,8,
      2,(unsigned char *)info,j);
    XFlush(display);
    propempty=0;
    free(info);
}

variable_types: size int

variable_types: struct STRSTACK { char *str; int len; struct STRSTACK *next; } *

variable_types:
info
char *

variable_types:
c
char *

variable_types:
d
char *

variable_types: j int


decompiled_code:
void get_and_set()
{
int v0; // edi
unsigned int v1; // edi

iosig_on = 0;
read_input();
check_events();
if ( propempty && other_prog_ex )
{
v0 = totlen;
if ( totlen < minsize )
{
v1 = 10;
if ( !alarm_needed )
goto LABEL_12;
goto LABEL_11;
}
if ( maxsize <= totlen )
v0 = maxsize;
set_property(v0);
}
if ( alarm_needed )
{
v1 = 9 * (totlen < minsize) + 1;
LABEL_11:
alarm_needed = v1;
alarm(v1);
}
LABEL_12:
iosig_on = 1;
}

canonical_decompiled_code:
void func9()
{
int v0; // edi
unsigned int v1; // edi

iosig_on = 0;
func5();
func6();
if ( propempty && other_prog_ex )
{
v0 = totlen;
if ( totlen < minsize )
{
v1 = 10;
if ( !alarm_needed )
goto LABEL_12;
goto LABEL_11;
}
if ( maxsize <= totlen )
v0 = maxsize;
func7(v0);
}
if ( alarm_needed )
{
v1 = 9 * (totlen < minsize) + 1;
LABEL_11:
alarm_needed = v1;
alarm(v1);
}
LABEL_12:
iosig_on = 1;
}

original_code:
static void get_and_set(void)
{
    iosig_on=0;
    read_input();
    check_events();
    if (propempty && other_prog_ex && totlen>=minsize)
 set_property(totlen<maxsize?totlen:maxsize);
    if (alarm_needed) {
 if (totlen>=minsize) {
     alarm_needed=1;
 } else alarm_needed=10;
 alarm(alarm_needed);
    }
    iosig_on=1;
}

canonical_original_code:
static void get_and_set()
{
    iosig_on=0;
    read_input();
    check_events();
    if (propempty && other_prog_ex && totlen>=minsize)
 set_property(totlen<maxsize?totlen:maxsize);
    if (alarm_needed) {
 if (totlen>=minsize) {
     alarm_needed=1;
 } else alarm_needed=10;
 alarm(alarm_needed);
    }
    iosig_on=1;
}


decompiled_code:
void __fastcall input_handle(int a1)
{
signal(a1, input_handle);
if ( iosig_on )
get_and_set();
*_errno_location() = 0;
}

canonical_decompiled_code:
void __fastcall func10(int a1)
{
signal(a1, input_handle);
if ( iosig_on )
func9();
*_errno_location() = 0;
}

original_code:
static void input_handle(int sig __attribute__((unused)))
{
    signal(sig, input_handle);
    if (iosig_on) get_and_set();
    (*__errno_location ())=0;
}

canonical_original_code:
static void input_handle(int sig)
{
    signal(sig, input_handle);
    if (iosig_on) get_and_set();
    (*__errno_location ())=0;
}

variable_types: sig int


decompiled_code:
void __fastcall alarm_handle(int a1)
{
signal(a1, alarm_handle);
if ( alarm_needed && iosig_on )
get_and_set();
*_errno_location() = 0;
}

canonical_decompiled_code:
void __fastcall func11(int a1)
{
signal(a1, alarm_handle);
if ( alarm_needed && iosig_on )
func9();
*_errno_location() = 0;
}

original_code:
static void alarm_handle(int sig __attribute__((unused)))
{
    signal(sig, alarm_handle);
    if (alarm_needed && iosig_on) get_and_set();
    (*__errno_location ())=0;
}

canonical_original_code:
static void alarm_handle(int sig)
{
    signal(sig, alarm_handle);
    if (alarm_needed && iosig_on) get_and_set();
    (*__errno_location ())=0;
}


decompiled_code:
int server_init()
{
Display *v0; // rax
int v1; // ebx
int result; // eax
char *v3; // rax
XSetWindowAttributes v4; // [rsp+0h] [rbp-78h] BYREF

v0 = XOpenDisplay(displayname);
display = v0;
if ( !v0 )
{
v3 = XDisplayName(displayname);
fprintf(stderr, "xpipein: Cannot connect to server %s\n", v3);
exit(-1);
}
v1 = v0->default_screen;
textprop = XInternAtom(v0, "TEXT", 1);
dummy = XInternAtom(display, propname, 0);
testend = XInternAtom(display, endname, 0);
if ( !testwin )
testwin = display->screens[(__int64)v1].root;
v4.event_mask = 4325376LL;
XSetErrorHandler((XErrorHandler)error_handler);
XSetIOErrorHandler((XIOErrorHandler)ioerror_handler);
XChangeWindowAttributes(display, testwin, 0x800uLL, &v4);
XDeleteProperty(display, testwin, dummy);
result = check_property();
propempty = 1;
return result;
}

canonical_decompiled_code:
int func3()
{
Display *v0; // rax
int v1; // ebx
int result; // eax
char *v3; // rax
XSetWindowAttributes v4; // [rsp+0h] [rbp-78h] BYREF

v0 = XOpenDisplay(displayname);
display = v0;
if ( !v0 )
{
v3 = XDisplayName(displayname);
fprintf(stderr, "xpipein: Cannot connect to server %s\n", v3);
exit(-1);
}
v1 = v0->default_screen;
textprop = XInternAtom(v0, "TEXT", 1);
dummy = XInternAtom(display, propname, 0);
testend = XInternAtom(display, endname, 0);
if ( !testwin )
testwin = display->screens[(__int64)v1].root;
v4.event_mask = 4325376LL;
XSetErrorHandler((XErrorHandler)error_handler);
XSetIOErrorHandler((XIOErrorHandler)ioerror_handler);
XChangeWindowAttributes(display, testwin, 0x800uLL, &v4);
XDeleteProperty(display, testwin, dummy);
result = func2();
propempty = 1;
return result;
}

original_code:
static void server_init(void)
{
    int i;
    XSetWindowAttributes winattr;
    if ((display=XOpenDisplay(displayname))==((void *)0)) {
 fprintf(stderr, "xpipein: Cannot connect to server %s\n",
  XDisplayName(displayname));
 exit(-1);
    }
    i = (((_XPrivDisplay)(display))->default_screen);
    textprop = XInternAtom(display, "TEXT", 1);
    dummy = XInternAtom(display, propname, 0);
    testend = XInternAtom(display, endname, 0);
    if (!testwin) testwin = ((&((_XPrivDisplay)(display))->screens[i])->root);
    winattr.event_mask = (1L<<22) | (1L<<17);
    XSetErrorHandler(error_handler);
    XSetIOErrorHandler(ioerror_handler);
    XChangeWindowAttributes(display, testwin, (1L<<11), &winattr);
    XDeleteProperty(display,testwin,dummy);
    check_property();
    propempty=1;
}

canonical_original_code:
static void server_init()
{
    int i;
    struct XSetWindowAttributes winattr;
    if ((display=XOpenDisplay(displayname))==((void *)0)) {
 fprintf(stderr, "xpipein: Cannot connect to server %s\n",
  XDisplayName(displayname));
 exit(-1);
    }
    i = (((_XPrivDisplay)(display))->default_screen);
    textprop = XInternAtom(display, "TEXT", 1);
    dummy = XInternAtom(display, propname, 0);
    testend = XInternAtom(display, endname, 0);
    if (!testwin) testwin = ((&((_XPrivDisplay)(display))->screens[i])->root);
    winattr.event_mask = (1L<<22) | (1L<<17);
    XSetErrorHandler(error_handler);
    XSetIOErrorHandler(ioerror_handler);
    XChangeWindowAttributes(display, testwin, (1L<<11), &winattr);
    XDeleteProperty(display,testwin,dummy);
    check_property();
    propempty=1;
}

variable_types: i int

variable_types: struct XSetWindowAttributes { unsigned long background_pixmap; unsigned long background_pixel; unsigned long border_pixmap; unsigned long border_pixel; int bit_gravity; int win_gravity; int backing_store; unsigned long backing_planes; unsigned long backing_pixel; int save_under; long event_mask; long do_not_propagate_mask; int override_redirect; unsigned long colormap; unsigned long cursor; }


handle

decompiled_code:
void __noreturn handle()
{
set_property(0);
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
exit(0);
}

canonical_decompiled_code:
void __noreturn func8()
{
func7(0);
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
exit(0);
}

original_code:
static void handle(int sig __attribute__((unused)))
{
    set_property(0);
    XDeleteProperty(display, testwin, testend);
    XCloseDisplay(display);
    exit(0);
}

canonical_original_code:
static void handle(int sig)
{
    set_property(0);
    XDeleteProperty(display, testwin, testend);
    XCloseDisplay(display);
    exit(0);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
int *v4; // rbx
int v5; // eax
int v6; // ebx
int v7; // edi

f = stdin;
filenof = fileno(stdin);
oldfileflag = fcntl(filenof, 3);
if ( argc > 1 )
{
for ( i = 1; i < argc; ++i )
{
if ( *(_WORD *)argv[i] == 17709 )
endname = (char *)argv[++i];
}
}
server_init();
signal(1, (__sighandler_t)handle);
signal(2, (__sighandler_t)handle);
signal(3, (__sighandler_t)handle);
signal(4, (__sighandler_t)handle);
signal(6, (__sighandler_t)handle);
signal(8, (__sighandler_t)handle);
signal(7, (__sighandler_t)handle);
signal(11, (__sighandler_t)handle);
signal(31, (__sighandler_t)handle);
signal(13, (__sighandler_t)handle);
signal(14, alarm_handle);
signal(15, (__sighandler_t)handle);
signal(23, input_handle);
signal(29, input_handle);
signal(24, (__sighandler_t)handle);
signal(25, (__sighandler_t)handle);
signal(10, (__sighandler_t)handle);
signal(12, (__sighandler_t)handle);
signal(29, input_handle);
get_and_set();
alarm(alarm_needed);
while ( !feof(f) )
{
v4 = _errno_location();
*v4 = 0;
v5 = fgetc(f);
if ( v5 != -1 && !*v4 )
{
ungetc(v5, f);
get_and_set();
}
}
alarm_needed = 0;
do
{
do
{
do
{
XNextEvent(display, &event);
check_event();
}
while ( !propempty );
}
while ( !other_prog_ex );
v6 = totlen;
v7 = totlen;
if ( maxsize <= totlen )
v7 = maxsize;
set_property(v7);
}
while ( v6 );
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int i; // ebx
int *v4; // rbx
int v5; // eax
int v6; // ebx
int v7; // edi

f = stdin;
filenof = fileno(stdin);
oldfileflag = fcntl(filenof, 3);
if ( argc > 1 )
{
for ( i = 1; i < argc; ++i )
{
if ( *(_WORD *)argv[i] == 17709 )
endname = (char *)argv[++i];
}
}
func3();
signal(1, (__sighandler_t)handle);
signal(2, (__sighandler_t)handle);
signal(3, (__sighandler_t)handle);
signal(4, (__sighandler_t)handle);
signal(6, (__sighandler_t)handle);
signal(8, (__sighandler_t)handle);
signal(7, (__sighandler_t)handle);
signal(11, (__sighandler_t)handle);
signal(31, (__sighandler_t)handle);
signal(13, (__sighandler_t)handle);
signal(14, alarm_handle);
signal(15, (__sighandler_t)handle);
signal(23, input_handle);
signal(29, input_handle);
signal(24, (__sighandler_t)handle);
signal(25, (__sighandler_t)handle);
signal(10, (__sighandler_t)handle);
signal(12, (__sighandler_t)handle);
signal(29, input_handle);
func9();
alarm(alarm_needed);
while ( !feof(f) )
{
v4 = _errno_location();
*v4 = 0;
v5 = fgetc(f);
if ( v5 != -1 && !*v4 )
{
ungetc(v5, f);
func9();
}
}
alarm_needed = 0;
do
{
do
{
do
{
XNextEvent(display, &event);
func4();
}
while ( !propempty );
}
while ( !other_prog_ex );
v6 = totlen;
v7 = totlen;
if ( maxsize <= totlen )
v7 = maxsize;
func7(v7);
}
while ( v6 );
XDeleteProperty(display, testwin, testend);
XCloseDisplay(display);
return 0;
}

original_code:
int main(int argc, char **argv)
{
    int i=1;
    int endprop=0;
    f = stdin;
    filenof=fileno(f);
    oldfileflag=fcntl(filenof,3);
    for (i=1; i<argc; i++) {
 if (argv[i][0]=='-') {
     switch (argv[i][1]) {
     case 'T': propname = argv[i+1]; i++; break;
     case 'E': endname = argv[i+1]; i++; break;
     case 'm':
  if (argv[i][2]=='i') {
      minsize = strtol(argv[i+1],((void *)0), 0);
      if (minsize<1) minsize=1;
      i++;
  } else if (argv[i][2]=='a') {
      maxsize = strtol(argv[i+1],((void *)0),0);
      if (maxsize<minsize) maxsize=minsize;
      i++;
  }
  break;
     case 'a':
         allocsize=strtol(argv[i+1],((void *)0),0);
  if (allocsize<32) allocsize=32;
  i++;
  break;
     case 'd':
  if (!strcmp(argv[i]+2, "isplay")) {
      displayname = argv[i+1];
      i++;
  }
  break;
     case 'w':
  if (!strcmp(argv[i]+2,"indow")) {
      testwin = strtol(argv[i+1],((void *)0),0);
      i++;
  }
  break;
     default: break;
     }
 }
    }
    server_init();
    signal(1, handle);
    signal(2, handle);
    signal(3, handle);
    signal(4, handle);
    signal(6, handle);
    signal(8, handle);
    signal(7, handle);
    signal(11, handle);
    signal(31, handle);
    signal(13, handle);
    signal(14, alarm_handle);
    signal(15, handle);
    signal(23, input_handle);
    signal(29, input_handle);
    signal(24, handle);
    signal(25, handle);
    signal(10, handle);
    signal(12, handle);
    signal(29, input_handle);
    get_and_set();
    alarm(alarm_needed);
    while (!feof(f)) {
 (*__errno_location ())=0;
 i=fgetc(f);
 if (i!=(-1) && !(*__errno_location ())) {
     ungetc(i,f);
     get_and_set();
 }
    }
    alarm_needed=0;
    while (!endprop) {
 XNextEvent(display, &event);
 check_event();
 if (propempty && other_prog_ex) {
     endprop = (totlen==0);
     set_property(totlen<maxsize?totlen:maxsize);
 }
    }
    XDeleteProperty(display, testwin, testend);
    XCloseDisplay(display);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
    int i = 1;
    int endprop = 0;
    f = stdin;
    filenof=fileno(f);
    oldfileflag=fcntl(filenof,3);
    for (i=1; i<argc; i++) {
 if (argv[i][0]=='-') {
     switch (argv[i][1]) {
     case 'T': propname = argv[i+1]; i++; break;
     case 'E': endname = argv[i+1]; i++; break;
     case 'm':
  if (argv[i][2]=='i') {
      minsize = strtol(argv[i+1],((void *)0), 0);
      if (minsize<1) minsize=1;
      i++;
  } else if (argv[i][2]=='a') {
      maxsize = strtol(argv[i+1],((void *)0),0);
      if (maxsize<minsize) maxsize=minsize;
      i++;
  }
  break;
     case 'a':
         allocsize=strtol(argv[i+1],((void *)0),0);
  if (allocsize<32) allocsize=32;
  i++;
  break;
     case 'd':
  if (!strcmp(argv[i]+2, "isplay")) {
      displayname = argv[i+1];
      i++;
  }
  break;
     case 'w':
  if (!strcmp(argv[i]+2,"indow")) {
      testwin = strtol(argv[i+1],((void *)0),0);
      i++;
  }
  break;
     default: break;
     }
 }
    }
    server_init();
    signal(1, handle);
    signal(2, handle);
    signal(3, handle);
    signal(4, handle);
    signal(6, handle);
    signal(8, handle);
    signal(7, handle);
    signal(11, handle);
    signal(31, handle);
    signal(13, handle);
    signal(14, alarm_handle);
    signal(15, handle);
    signal(23, input_handle);
    signal(29, input_handle);
    signal(24, handle);
    signal(25, handle);
    signal(10, handle);
    signal(12, handle);
    signal(29, input_handle);
    get_and_set();
    alarm(alarm_needed);
    while (!feof(f)) {
 (*__errno_location ())=0;
 i=fgetc(f);
 if (i!=(-1) && !(*__errno_location ())) {
     ungetc(i,f);
     get_and_set();
 }
    }
    alarm_needed=0;
    while (!endprop) {
 XNextEvent(display, &event);
 check_event();
 if (propempty && other_prog_ex) {
     endprop = (totlen==0);
     set_property(totlen<maxsize?totlen:maxsize);
 }
    }
    XDeleteProperty(display, testwin, testend);
    XCloseDisplay(display);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: endprop int


decompiled_code:
__int64 lookup_int_constant()
{
return define_int_constant();
}

canonical_decompiled_code:
__int64 func0()
{
return define_int_constant();
}

original_code:
Argument lookup_int_constant(int n)
{
    return define_int_constant(n);
}

canonical_original_code:
int lookup_int_constant(int n)
{
    return define_int_constant(n);
}

variable_types: n int


decompiled_code:
__int64 lookup_string_constant()
{
return define_string_constant();
}

canonical_decompiled_code:
__int64 func1()
{
return define_string_constant();
}

original_code:
Argument lookup_string_constant(Uchar *s)
{
    return define_string_constant(s);
}

canonical_original_code:
int lookup_string_constant(unsigned short *s)
{
    return define_string_constant(s);
}

variable_types:
s
unsigned short *


decompiled_code:
__int64 lookup_real_constant()
{
return define_real_constant();
}

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

original_code:
Argument lookup_real_constant(double r)
{
    return define_real_constant(r);
}

canonical_original_code:
int lookup_real_constant(double r)
{
    return define_real_constant(r);
}

variable_types: r double


statetomode

decompiled_code:
__int64 __fastcall statetomode(int a1)
{
return a1 & 0x7D | (a1 << 16) & 0x7D0000u;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return a1 & 0x7D | (a1 << 16) & 0x7D0000u;
}

canonical_original_code:
static unsigned int statetomode(unsigned int state)
{
    return ((state&(0x01|0x04|0x08|0x10|0x20|0x40))|((state&(0x01|0x04|0x08|0x10|0x20|0x40))<<16));
}

variable_types:
state
unsigned int


keynumtounicode

decompiled_code:
__int64 __fastcall keynumtounicode(__int16 a1)
{
if ( !keynummap )
keynummap = umap_load_file("X11keysym", 2LL, 3LL, 0LL);
return *(unsigned __int16 *)(*(_QWORD *)(keynummap + 8LL * HIBYTE(a1)) + 2LL * (unsigned __int8)a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1)
{
if ( !keynummap )
keynummap = umap_load_file("X11keysym", 2LL, 3LL, 0LL);
return *(unsigned __int16 *)(*(_QWORD *)(keynummap + 8LL * HIBYTE(a1)) + 2LL * (unsigned __int8)a1);
}

original_code:
static int keynumtounicode(KeyNum keynum)
{
  if (!keynummap) {
    (keynummap)=(MapUchar) umap_load_file((mapkeysymname), sizeof(Uchar), 3, 0);
  }
  return ((keynummap)[((Uchar)(keynum&0xffff))/256][((Uchar)(keynum&0xffff))%256]);
}

canonical_original_code:
static int keynumtounicode(unsigned int keynum)
{
  if (!keynummap) {
    (keynummap)=(unsigned short **) umap_load_file((mapkeysymname), sizeof(Uchar), 3, 0);
  }
  return ((keynummap)[((Uchar)(keynum&0xffff))/256][((Uchar)(keynum&0xffff))%256]);
}

variable_types:
keynum
unsigned int


keyandmodetochar

decompiled_code:
__int64 __fastcall keyandmodetochar(unsigned int a1, char a2)
{
unsigned int v2; // ebx
__int64 result; // rax

v2 = a1;
result = keynumtounicode(a1);
if ( (unsigned int)(result - 32) <= 0x5F )
{
if ( (a2 & 8) != 0 )
v2 = a1 + 128;
if ( (a2 & 4) != 0 && (v2 & 0x40) != 0 )
{
if ( (v2 & 0x20) != 0 )
v2 -= 32;
v2 -= 64;
}
result = v2;
}
return result;
}

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

v2 = a1;
result = func1(a1);
if ( (unsigned int)(result - 32) <= 0x5F )
{
if ( (a2 & 8) != 0 )
v2 = a1 + 128;
if ( (a2 & 4) != 0 && (v2 & 0x40) != 0 )
{
if ( (v2 & 0x20) != 0 )
v2 -= 32;
v2 -= 64;
}
result = v2;
}
return result;
}

original_code:
static int keyandmodetochar(KeyNum keynum, KeyMode keymode)
{
  int i;
  i = keynumtounicode(keynum);
  if (i > 127 || i<32) return i;
  if (keymode & 0x08) keynum=keynum+0x80;
  if (keymode & 0x04 && (keynum&0x40)) {
    if (keynum & 0x20) keynum=keynum-32;
    keynum=keynum-64;
  }
  return keynum;
}

canonical_original_code:
static int keyandmodetochar(unsigned int keynum, unsigned int keymode)
{
  int i;
  i = keynumtounicode(keynum);
  if (i > 127 || i<32) return i;
  if (keymode & 0x08) keynum=keynum+0x80;
  if (keymode & 0x04 && (keynum&0x40)) {
    if (keynum & 0x20) keynum=keynum-32;
    keynum=keynum-64;
  }
  return keynum;
}

variable_types:
keymode
unsigned int


StringToKey

decompiled_code:
KeySym __fastcall StringToKey(char *a1)
{
char *v1; // rbx
KeySym result; // rax
int v3; // edx
char v4; // al
char v5; // dl
char v6; // dl

if ( !a1 )
return 0LL;
v1 = a1;
if ( !*a1 || (result = (unsigned int)*a1, a1[1]) )
{
result = XStringToKeysym(a1);
if ( !result )
{
if ( !memcmp(a1, "double_", 7uLL) )
{
v1 += 7;
v3 = 32592;
}
else
{
v3 = 32576;
if ( !memcmp(v1, "triple_", 7uLL) )
{
v1 += 7;
v3 = 32608;
}
}
if ( !memcmp(v1, "down_", 5uLL) )
{
v3 -= 64;
v1 += 5;
}
else
{
if ( memcmp(v1, "drag_", 5uLL) )
{
if ( memcmp(v1, "mouse_", 6uLL) || (v4 = v1[6], (unsigned __int8)(v4 - 49) > 4u) )
{
LABEL_12:
if ( v3 != 32576 )
return 0LL;
result = 0LL;
if ( !memcmp(v1, "mouse_movement", 0xEuLL) )
{
v5 = v1[14];
result = 32704LL;
if ( v5 )
{
result = 0LL;
if ( v5 == 95 )
{
v6 = v1[15];
if ( (unsigned __int8)(v6 - 49) <= 4u && !v1[16] )
result = (unsigned int)(v6 + 32656);
}
}
}
return result;
}
LABEL_11:
result = (unsigned int)(v3 + v4 - 48);
if ( !v1[7] )
return result;
goto LABEL_12;
}
v3 -= 64;
v1 += 5;
}
result = 0LL;
if ( memcmp(v1, "mouse_", 6uLL) )
return result;
v4 = v1[6];
if ( (unsigned __int8)(v4 - 49) > 4u )
return 0LL;
goto LABEL_11;
}
}
return result;
}

canonical_decompiled_code:
KeySym __fastcall func3(char *a1)
{
char *v1; // rbx
KeySym result; // rax
int v3; // edx
char v4; // al
char v5; // dl
char v6; // dl

if ( !a1 )
return 0LL;
v1 = a1;
if ( !*a1 || (result = (unsigned int)*a1, a1[1]) )
{
result = XStringToKeysym(a1);
if ( !result )
{
if ( !memcmp(a1, "double_", 7uLL) )
{
v1 += 7;
v3 = 32592;
}
else
{
v3 = 32576;
if ( !memcmp(v1, "triple_", 7uLL) )
{
v1 += 7;
v3 = 32608;
}
}
if ( !memcmp(v1, "down_", 5uLL) )
{
v3 -= 64;
v1 += 5;
}
else
{
if ( memcmp(v1, "drag_", 5uLL) )
{
if ( memcmp(v1, "mouse_", 6uLL) || (v4 = v1[6], (unsigned __int8)(v4 - 49) > 4u) )
{
LABEL_12:
if ( v3 != 32576 )
return 0LL;
result = 0LL;
if ( !memcmp(v1, "mouse_movement", 0xEuLL) )
{
v5 = v1[14];
result = 32704LL;
if ( v5 )
{
result = 0LL;
if ( v5 == 95 )
{
v6 = v1[15];
if ( (unsigned __int8)(v6 - 49) <= 4u && !v1[16] )
result = (unsigned int)(v6 + 32656);
}
}
}
return result;
}
LABEL_11:
result = (unsigned int)(v3 + v4 - 48);
if ( !v1[7] )
return result;
goto LABEL_12;
}
v3 -= 64;
v1 += 5;
}
result = 0LL;
if ( memcmp(v1, "mouse_", 6uLL) )
return result;
v4 = v1[6];
if ( (unsigned __int8)(v4 - 49) > 4u )
return 0LL;
goto LABEL_11;
}
}
return result;
}

variable_types:
s
char *

variable_types:
ks
unsigned long

variable_types:
k
unsigned int