delete

decompiled_code:
xcb_void_cookie_t __fastcall delete(uint32_t *a1, int a2)
{
xcb_void_cookie_t result; // eax

if ( a1 )
{
if ( (a1[38] & 1) != 0 && !a2 )
result.sequence = sendcmessage(*a1, wm_protocols, wm_delete, 0LL);
else
result.sequence = xcb_kill_client(dpy, *a1).sequence;
}
return result;
}

canonical_decompiled_code:
xcb_void_cookie_t __fastcall func3(uint32_t *a1, int a2)
{
xcb_void_cookie_t result; // eax

if ( a1 )
{
if ( (a1[38] & 1) != 0 && !a2 )
result.sequence = sendcmessage(*a1, wm_protocols, wm_delete, 0LL);
else
result.sequence = xcb_kill_client(dpy, *a1).sequence;
}
return result;
}

original_code:
void delete(Client *c, int shift)
{
    if (c == 0)
        return;
    if ((c->proto & 1) && !shift)
        sendcmessage(c->window, wm_protocols, wm_delete, 0);
    else
        xcb_kill_client(dpy, c->window);
}

canonical_original_code:
void delete(struct Client *c, int shift)
{
    if (c == 0)
        return;
    if ((c->proto & 1) && !shift)
        sendcmessage(c->window, wm_protocols, wm_delete, 0);
    else
        xcb_kill_client(dpy, c->window);
}

variable_types: shift int


hide

decompiled_code:
int __fastcall hide(__int64 a1)
{
int v1; // eax
__int64 v2; // rax

if ( a1 && numhidden != 32 )
{
if ( *(_DWORD *)(a1 + 132) == 3 )
{
LODWORD(v2) = fprintf(stderr, "9wm: already hidden: %s\n", *(const char **)(a1 + 160));
}
else
{
xcb_unmap_window(dpy, *(_DWORD *)(a1 + 4));
xcb_unmap_window(dpy, *(_DWORD *)a1);
set_state(a1, 3LL);
if ( current == a1 )
nofocus();
v1 = numhidden;
hiddenc[numhidden] = a1;
b3items[v1 + 5] = *(char **)(a1 + 160);
numhidden = v1 + 1;
v2 = v1 + 6;
b3items[v2] = 0LL;
}
}
return v2;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
int v1; // eax
__int64 v2; // rax

if ( a1 && numhidden != 32 )
{
if ( *(_DWORD *)(a1 + 132) == 3 )
{
LODWORD(v2) = fprintf(stderr, "9wm: already hidden: %s\n", *(const char **)(a1 + 160));
}
else
{
xcb_unmap_window(dpy, *(_DWORD *)(a1 + 4));
xcb_unmap_window(dpy, *(_DWORD *)a1);
set_state(a1, 3LL);
if ( current == a1 )
nofocus();
v1 = numhidden;
hiddenc[numhidden] = a1;
b3items[v1 + 5] = *(char **)(a1 + 160);
numhidden = v1 + 1;
v2 = v1 + 6;
b3items[v2] = 0LL;
}
}
return v2;
}

original_code:
void hide(Client *c)
{
    if (c == 0 || numhidden == 32)
        return;
    if (((c)->state == XCB_ICCCM_WM_STATE_ICONIC)) {
        fprintf(stderr, "9wm: already hidden: %s\n", c->label);
        return;
    }
    xcb_unmap_window(dpy, c->parent);
    xcb_unmap_window(dpy, c->window);
    set_state(c, XCB_ICCCM_WM_STATE_ICONIC);
    if (c == current)
        nofocus();
    hiddenc[numhidden] = c;
    b3items[5 +numhidden] = c->label;
    numhidden++;
    b3items[5 +numhidden] = 0;
}

canonical_original_code:
void hide(struct Client *c)
{
    if (c == 0 || numhidden == 32)
        return;
    if (((c)->state == XCB_ICCCM_WM_STATE_ICONIC)) {
        fprintf(stderr, "9wm: already hidden: %s\n", c->label);
        return;
    }
    xcb_unmap_window(dpy, c->parent);
    xcb_unmap_window(dpy, c->window);
    set_state(c, XCB_ICCCM_WM_STATE_ICONIC);
    if (c == current)
        nofocus();
    hiddenc[numhidden] = c;
    b3items[5 +numhidden] = c->label;
    numhidden++;
    b3items[5 +numhidden] = 0;
}

variable_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; } size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *screen; } *

return_type: void

user_defined_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo *screen; }


unhide

decompiled_code:
int __fastcall unhide(__int64 a1, int a2)
{
char *v2; // rax
unsigned int *v3; // rbp
int v4; // ecx
int v5; // edx

if ( numhidden <= (int)a1 )
{
LODWORD(v2) = fprintf(stderr, "9wm: unhide: n %d numhidden %d\n", (unsigned int)a1, (unsigned int)numhidden);
}
else
{
LODWORD(v2) = a1;
v3 = (unsigned int *)hiddenc[(int)a1];
if ( v3[33] == 3 )
{
if ( a2 )
{
xcb_map_window(dpy, *v3);
xmapraised(dpy, v3[1]);
set_state(v3, 1LL);
active(v3);
LODWORD(v2) = top(v3);
}
v4 = numhidden;
v5 = numhidden - 1;
numhidden = v5;
if ( v5 > (int)a1 )
{
a1 = (int)a1;
do
{
hiddenc[a1] = hiddenc[a1 + 1];
v2 = b3items[a1 + 6];
b3items[a1++ + 5] = v2;
}
while ( v5 > (int)a1 );
}
b3items[v4 + 4] = 0LL;
}
else
{
LODWORD(v2) = fprintf(stderr, "9wm: unhide: not hidden: %s(0x%x)\n", *((const char **)v3 + 20), *v3);
}
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1, int a2)
{
char *v2; // rax
unsigned int *v3; // rbp
int v4; // ecx
int v5; // edx

if ( numhidden <= (int)a1 )
{
LODWORD(v2) = fprintf(stderr, "9wm: unhide: n %d numhidden %d\n", (unsigned int)a1, (unsigned int)numhidden);
}
else
{
LODWORD(v2) = a1;
v3 = (unsigned int *)hiddenc[(int)a1];
if ( v3[33] == 3 )
{
if ( a2 )
{
xcb_map_window(dpy, *v3);
xmapraised(dpy, v3[1]);
set_state(v3, 1LL);
active(v3);
LODWORD(v2) = top(v3);
}
v4 = numhidden;
v5 = numhidden - 1;
numhidden = v5;
if ( v5 > (int)a1 )
{
a1 = (int)a1;
do
{
hiddenc[a1] = hiddenc[a1 + 1];
v2 = b3items[a1 + 6];
b3items[a1++ + 5] = v2;
}
while ( v5 > (int)a1 );
}
b3items[v4 + 4] = 0LL;
}
else
{
LODWORD(v2) = fprintf(stderr, "9wm: unhide: not hidden: %s(0x%x)\n", *((const char **)v3 + 20), *v3);
}
}
return (int)v2;
}

original_code:
void unhide(int n, int map)
{
    Client *c;
    int i;
    uint32_t values[2];
    if (n >= numhidden) {
        fprintf(stderr, "9wm: unhide: n %d numhidden %d\n", n, numhidden);
        return;
    }
    c = hiddenc[n];
    if (!((c)->state == XCB_ICCCM_WM_STATE_ICONIC)) {
        fprintf(stderr, "9wm: unhide: not hidden: %s(0x%x)\n",
            c->label, c->window);
        return;
    }
    if (map) {
        xcb_map_window(dpy, c->window);
        xmapraised(dpy, c->parent);
        set_state(c, XCB_ICCCM_WM_STATE_NORMAL);
        active(c);
        top(c);
    }
    numhidden--;
    for (i = n; i < numhidden; i ++) {
        hiddenc[i] = hiddenc[i+1];
        b3items[5 +i] = b3items[5 +i+1];
    }
    b3items[5 +numhidden] = 0;
}

canonical_original_code:
void unhide(int n, int map)
{
    struct Client *c;
    int i;
    unsigned int values[2];
    if (n >= numhidden) {
        fprintf(stderr, "9wm: unhide: n %d numhidden %d\n", n, numhidden);
        return;
    }
    c = hiddenc[n];
    if (!((c)->state == XCB_ICCCM_WM_STATE_ICONIC)) {
        fprintf(stderr, "9wm: unhide: not hidden: %s(0x%x)\n",
            c->label, c->window);
        return;
    }
    if (map) {
        xcb_map_window(dpy, c->window);
        xmapraised(dpy, c->parent);
        set_state(c, XCB_ICCCM_WM_STATE_NORMAL);
        active(c);
        top(c);
    }
    numhidden--;
    for (i = n; i < numhidden; i ++) {
        hiddenc[i] = hiddenc[i+1];
        b3items[5 +i] = b3items[5 +i+1];
    }
    b3items[5 +numhidden] = 0;
}

variable_types: n int

variable_types: map int

variable_types: i int

variable_types:
values
unsigned int [2]

user_defined_types: struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; }

user_defined_types: struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; }


button

decompiled_code:
void __fastcall button(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rbp
__int16 v4; // ax
char v5; // al
xcb_window_t v6; // esi
char v7; // al
int v8; // edi
xcb_translate_coordinates_cookie_t v9; // eax
xcb_translate_coordinates_reply_t *v10; // rax
unsigned int *v11; // rax
unsigned int *v12; // rax
uint32_t *v13; // rax
__int64 v14; // rax
int v15[7]; // [rsp+Ch] [rbp-1Ch] BYREF

curtime = *(_DWORD *)(a1 + 4);
v1 = getscreen(*(unsigned int *)(a1 + 8));
if ( !v1 )
{
fwrite("button: getscreen failed\n", 1uLL, 0x19uLL, stderr);
fprintf(
stderr,
" e->root=%d e->event=%d e->child=%d e->detail=%d\n",
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12),
*(unsigned int *)(a1 + 16),
*(unsigned __int8 *)(a1 + 1));
return;
}
v2 = v1;
v3 = getclient(*(unsigned int *)(a1 + 12), 0LL);
if ( v3 )
{
v4 = 1 - (_WORD)border;
*(_WORD *)(a1 + 24) += *(_WORD *)(v3 + 32) + 1 - (_WORD)border;
*(_WORD *)(a1 + 26) += *(_WORD *)(v3 + 36) + v4;
v5 = *(_BYTE *)(a1 + 1);
if ( v5 != 2 )
{
if ( v5 != 3 )
{
if ( v5 == 1 )
{
xmapraised(dpy, *(unsigned int *)(v3 + 4));
top(v3);
active(v3);
}
return;
}
goto LABEL_11;
}
}
else
{
v6 = *(_DWORD *)(a1 + 12);
if ( v6 != *(_DWORD *)(a1 + 8) )
{
v9.sequence = xcb_translate_coordinates(dpy, v6, *(_DWORD *)(v2 + 4), *(_WORD *)(a1 + 24), *(_WORD *)(a1 + 26)).sequence;
v10 = xcb_translate_coordinates_reply(dpy, v9, 0LL);
if ( v10 )
{
*(_WORD *)(a1 + 24) = v10->dst_x;
*(_WORD *)(a1 + 26) = v10->dst_y;
free(v10);
}
else
{
fwrite("9wm: button: failed to translate coords\n", 1uLL, 0x28uLL, stderr);
fprintf(
stderr,
" window=%d root=%d child=%d\n",
*(unsigned int *)(a1 + 12),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 16));
}
}
v7 = *(_BYTE *)(a1 + 1);
if ( v7 != 2 )
{
if ( v7 != 3 )
return;
LABEL_11:
if ( current && *(_QWORD *)(current + 224LL) == v2 )
cmapnofocus(v2);
v8 = menuhit(a1, &b3menu);
switch ( v8 )
{
case -1:
break;
case 0:
spawn(v2);
break;
case 1:
v11 = (unsigned int *)selectwin(1LL, 0LL, v2);
reshape(v11);
break;
case 2:
v12 = (unsigned int *)selectwin(0LL, 0LL, v2);
move(v12);
break;
case 3:
v15[0] = 0;
v13 = (uint32_t *)selectwin(1LL, v15, v2);
delete(v13, v15[0]);
break;
case 4:
v14 = selectwin(1LL, 0LL, v2);
hide(v14);
break;
default:
unhide((unsigned int)(v8 - 5), 1);
break;
}
if ( current && *(_QWORD *)(current + 224LL) == v2 )
cmapfocus();
return;
}
}
if ( (*(_WORD *)(a1 + 28) & 5) == 5 )
menuhit(a1, &egg);
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r12
__int64 v3; // rbp
__int16 v4; // ax
char v5; // al
xcb_window_t v6; // esi
char v7; // al
int v8; // edi
xcb_translate_coordinates_cookie_t v9; // eax
xcb_translate_coordinates_reply_t *v10; // rax
unsigned int *v11; // rax
unsigned int *v12; // rax
uint32_t *v13; // rax
__int64 v14; // rax
int v15[7]; // [rsp+Ch] [rbp-1Ch] BYREF

curtime = *(_DWORD *)(a1 + 4);
v1 = getscreen(*(unsigned int *)(a1 + 8));
if ( !v1 )
{
fwrite("button: getscreen failed\n", 1uLL, 0x19uLL, stderr);
fprintf(
stderr,
" e->root=%d e->event=%d e->child=%d e->detail=%d\n",
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 12),
*(unsigned int *)(a1 + 16),
*(unsigned __int8 *)(a1 + 1));
return;
}
v2 = v1;
v3 = getclient(*(unsigned int *)(a1 + 12), 0LL);
if ( v3 )
{
v4 = 1 - (_WORD)border;
*(_WORD *)(a1 + 24) += *(_WORD *)(v3 + 32) + 1 - (_WORD)border;
*(_WORD *)(a1 + 26) += *(_WORD *)(v3 + 36) + v4;
v5 = *(_BYTE *)(a1 + 1);
if ( v5 != 2 )
{
if ( v5 != 3 )
{
if ( v5 == 1 )
{
xmapraised(dpy, *(unsigned int *)(v3 + 4));
top(v3);
active(v3);
}
return;
}
goto LABEL_11;
}
}
else
{
v6 = *(_DWORD *)(a1 + 12);
if ( v6 != *(_DWORD *)(a1 + 8) )
{
v9.sequence = xcb_translate_coordinates(dpy, v6, *(_DWORD *)(v2 + 4), *(_WORD *)(a1 + 24), *(_WORD *)(a1 + 26)).sequence;
v10 = xcb_translate_coordinates_reply(dpy, v9, 0LL);
if ( v10 )
{
*(_WORD *)(a1 + 24) = v10->dst_x;
*(_WORD *)(a1 + 26) = v10->dst_y;
free(v10);
}
else
{
fwrite("9wm: button: failed to translate coords\n", 1uLL, 0x28uLL, stderr);
fprintf(
stderr,
" window=%d root=%d child=%d\n",
*(unsigned int *)(a1 + 12),
*(unsigned int *)(a1 + 8),
*(unsigned int *)(a1 + 16));
}
}
v7 = *(_BYTE *)(a1 + 1);
if ( v7 != 2 )
{
if ( v7 != 3 )
return;
LABEL_11:
if ( current && *(_QWORD *)(current + 224LL) == v2 )
cmapnofocus(v2);
v8 = menuhit(a1, &b3menu);
switch ( v8 )
{
case -1:
break;
case 0:
func0(v2);
break;
case 1:
v11 = (unsigned int *)selectwin(1LL, 0LL, v2);
func1(v11);
break;
case 2:
v12 = (unsigned int *)selectwin(0LL, 0LL, v2);
func2(v12);
break;
case 3:
v15[0] = 0;
v13 = (uint32_t *)selectwin(1LL, v15, v2);
func3(v13, v15[0]);
break;
case 4:
v14 = selectwin(1LL, 0LL, v2);
func4(v14);
break;
default:
func5((unsigned int)(v8 - 5), 1);
break;
}
if ( current && *(_QWORD *)(current + 224LL) == v2 )
cmapfocus();
return;
}
}
if ( (*(_WORD *)(a1 + 28) & 5) == 5 )
menuhit(a1, &egg);
}

original_code:
void button(xcb_button_press_event_t *e)
{
    int n, shift;
    Client *c;
    xcb_window_t dw;
    ScreenInfo *s;
    uint32_t values[2];
    curtime = e->time;
    if (!(s = getscreen(e->root))) {
        fprintf(stderr, "button: getscreen failed\n");
        fprintf(stderr, " e->root=%d e->event=%d e->child=%d e->detail=%d\n",
                e->root, e->event, e->child, e->detail);
        return;
    }
    if (c = getclient(e->event, 0)) {
        e->event_x += c->x - _border + 1;
        e->event_y += c->y - _border + 1;
    }
    else if (e->event != e->root) {
        xcb_translate_coordinates_cookie_t xtrans_c;
        xcb_translate_coordinates_reply_t *xtrans_r;
        xtrans_c = xcb_translate_coordinates(dpy, e->event, s->root,
                                                            e->event_x, e->event_y);
        xtrans_r = xcb_translate_coordinates_reply(dpy, xtrans_c, ((void *)0));
        if (xtrans_r) {
            e->event_x = xtrans_r->dst_x;
            e->event_y = xtrans_r->dst_y;
            free(xtrans_r);
        }
        else {
            fprintf(stderr, "9wm: button: failed to translate coords\n");
            fprintf(stderr, " window=%d root=%d child=%d\n",
                        e->event, e->root, e->child);
        }
    }
    switch (e->detail) {
        case XCB_BUTTON_INDEX_1:
            if (c) {
                xmapraised(dpy, c->parent);
                top(c);
                active(c);
            }
            return;
        case XCB_BUTTON_INDEX_2:
            if ((e->state & (XCB_MOD_MASK_SHIFT|XCB_MOD_MASK_CONTROL)) ==
                    (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_CONTROL))
                menuhit(e, &egg);
            return;
        case XCB_BUTTON_INDEX_3:
            break;
        default:
            return;
    }
    if (current && current->screen == s)
        cmapnofocus(s);
    switch (n = menuhit(e, &b3menu)) {
        case 0:
            spawn(s);
            break;
        case 1:
            reshape(selectwin(1, 0, s));
            break;
        case 2:
            move(selectwin(0, 0, s));
            break;
        case 3:
            shift = 0;
            c = selectwin(1, &shift, s);
            delete(c, shift);
            break;
        case 4:
            hide(selectwin(1, 0, s));
            break;
        default:
            unhide(n - 5, 1);
            break;
        case -1:
            break;
    }
    if (current && current->screen == s)
        cmapfocus(current);
}

canonical_original_code:
void button(struct xcb_button_press_event_t *e)
{
    int n; int shift;
    struct Client *c;
    unsigned int dw;
    struct ScreenInfo *s;
    unsigned int values[2];
    curtime = e->time;
    if (!(s = getscreen(e->root))) {
        fprintf(stderr, "button: getscreen failed\n");
        fprintf(stderr, " e->root=%d e->event=%d e->child=%d e->detail=%d\n",
                e->root, e->event, e->child, e->detail);
        return;
    }
    if (c = getclient(e->event, 0)) {
        e->event_x += c->x - _border + 1;
        e->event_y += c->y - _border + 1;
    }
    else if (e->event != e->root) {
        struct xcb_translate_coordinates_cookie_t xtrans_c;
        struct xcb_translate_coordinates_reply_t *xtrans_r;
        xtrans_c = xcb_translate_coordinates(dpy, e->event, s->root,
                                                            e->event_x, e->event_y);
        xtrans_r = xcb_translate_coordinates_reply(dpy, xtrans_c, ((void *)0));
        if (xtrans_r) {
            e->event_x = xtrans_r->dst_x;
            e->event_y = xtrans_r->dst_y;
            free(xtrans_r);
        }
        else {
            fprintf(stderr, "9wm: button: failed to translate coords\n");
            fprintf(stderr, " window=%d root=%d child=%d\n",
                        e->event, e->root, e->child);
        }
    }
    switch (e->detail) {
        case XCB_BUTTON_INDEX_1:
            if (c) {
                xmapraised(dpy, c->parent);
                top(c);
                active(c);
            }
            return;
        case XCB_BUTTON_INDEX_2:
            if ((e->state & (XCB_MOD_MASK_SHIFT|XCB_MOD_MASK_CONTROL)) ==
                    (XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_CONTROL))
                menuhit(e, &egg);
            return;
        case XCB_BUTTON_INDEX_3:
            break;
        default:
            return;
    }
    if (current && current->screen == s)
        cmapnofocus(s);
    switch (n = menuhit(e, &b3menu)) {
        case 0:
            spawn(s);
            break;
        case 1:
            reshape(selectwin(1, 0, s));
            break;
        case 2:
            move(selectwin(0, 0, s));
            break;
        case 3:
            shift = 0;
            c = selectwin(1, &shift, s);
            delete(c, shift);
            break;
        case 4:
            hide(selectwin(1, 0, s));
            break;
        default:
            unhide(n - 5, 1);
            break;
        case -1:
            break;
    }
    if (current && current->screen == s)
        cmapfocus(current);
}

variable_types: struct xcb_button_press_event_t { unsigned char response_type; unsigned char detail; unsigned short sequence; unsigned int time; unsigned int root; unsigned int event; unsigned int child; short root_x; short root_y; short event_x; short event_y; unsigned short state; unsigned char same_screen; unsigned char pad0; } *

variable_types:
dw
unsigned int

variable_types: struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *

variable_types: struct xcb_translate_coordinates_cookie_t { unsigned int sequence; }

variable_types: struct xcb_translate_coordinates_reply_t { unsigned char response_type; unsigned char same_screen; unsigned short sequence; unsigned int length; unsigned int child; short dst_x; short dst_y; } *


unhidec

decompiled_code:
int __fastcall unhidec(unsigned int *a1, int a2)
{
__int64 v2; // rax

if ( numhidden <= 0 )
return fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n", *((const char **)a1 + 20), *a1);
v2 = 0LL;
while ( (unsigned int *)hiddenc[v2] != a1 )
{
if ( ++v2 == numhidden )
return fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n", *((const char **)a1 + 20), *a1);
}
return unhide((unsigned int)v2, a2);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int *a1, int a2)
{
__int64 v2; // rax

if ( numhidden <= 0 )
return fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n", *((const char **)a1 + 20), *a1);
v2 = 0LL;
while ( (unsigned int *)hiddenc[v2] != a1 )
{
if ( ++v2 == numhidden )
return fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n", *((const char **)a1 + 20), *a1);
}
return func5((unsigned int)v2, a2);
}

original_code:
void unhidec(Client *c, int map)
{
    int i;
    for (i = 0; i < numhidden; i++)
        if (c == hiddenc[i]) {
            unhide(i, map);
            return;
        }
    fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n",
        c->label, c->window);
}

canonical_original_code:
void unhidec(struct Client *c, int map)
{
    int i;
    for (i = 0; i < numhidden; i++)
        if (c == hiddenc[i]) {
            unhide(i, map);
            return;
        }
    fprintf(stderr, "9wm: unhidec: not hidden: %s(0x%x)\n",
        c->label, c->window);
}


renamec

decompiled_code:
const char *__fastcall renamec(__int64 a1, char *a2)
{
const char *result; // rax

result = "???";
if ( !a2 )
a2 = "???";
*(_QWORD *)(a1 + 160) = a2;
if ( *(_DWORD *)(a1 + 132) == 3 && numhidden > 0 )
{
result = 0LL;
while ( hiddenc[(_QWORD)result] != a1 )
{
if ( ++result == (const char *)(unsigned int)numhidden )
return result;
}
b3items[(int)result + 5] = a2;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func8(__int64 a1, char *a2)
{
const char *result; // rax

result = "???";
if ( !a2 )
a2 = "???";
*(_QWORD *)(a1 + 160) = a2;
if ( *(_DWORD *)(a1 + 132) == 3 && numhidden > 0 )
{
result = 0LL;
while ( hiddenc[(_QWORD)result] != a1 )
{
if ( ++result == (const char *)(unsigned int)numhidden )
return result;
}
b3items[(int)result + 5] = a2;
}
return result;
}

original_code:
void renamec(Client *c, char *name)
{
    int i;
    if (name == 0)
        name = "???";
    c->label = name;
    if (!((c)->state == XCB_ICCCM_WM_STATE_ICONIC))
        return;
    for (i = 0; i < numhidden; i++)
        if (c == hiddenc[i]) {
            b3items[5 +i] = name;
            return;
        }
}

canonical_original_code:
void renamec(struct Client *c, char *name)
{
    int i;
    if (name == 0)
        name = "???";
    c->label = name;
    if (!((c)->state == XCB_ICCCM_WM_STATE_ICONIC))
        return;
    for (i = 0; i < numhidden; i++)
        if (c == hiddenc[i]) {
            b3items[5 +i] = name;
            return;
        }
}

variable_types:
name
char *


decompiled_code:
xcb_void_cookie_t __fastcall draw_border(__int64 a1, int a2)
{
xcb_void_cookie_t result; // eax
uint32_t value_list; // [rsp+0h] [rbp-14h] BYREF
xcb_rectangle_t rectangles; // [rsp+4h] [rbp-10h] BYREF

if ( a1 )
{
if ( a2 )
{
value_list = *(_DWORD *)(*(_QWORD *)(a1 + 224) + 20LL);
xcb_change_window_attributes(dpy, *(_DWORD *)(a1 + 4), 2u, &value_list);
result.sequence = xcb_clear_area(dpy, 0, *(_DWORD *)(a1 + 4), 0, 0, 0, 0).sequence;
if ( *(_DWORD *)(a1 + 148) )
{
rectangles.x = inset;
rectangles.y = inset;
rectangles.width = *(_WORD *)(a1 + 40) + (_WORD)border - inset;
rectangles.height = *(_WORD *)(a1 + 44) + (_WORD)border - inset;
result.sequence = xcb_poly_rectangle(
dpy,
*(_DWORD *)(a1 + 4),
*(_DWORD *)(*(_QWORD *)(a1 + 224) + 16LL),
1u,
&rectangles).sequence;
}
}
else
{
value_list = *(_DWORD *)(*(_QWORD *)(a1 + 224) + 24LL);
xcb_change_window_attributes(dpy, *(_DWORD *)(a1 + 4), 2u, &value_list);
result.sequence = xcb_clear_area(dpy, 0, *(_DWORD *)(a1 + 4), 0, 0, 0, 0).sequence;
}
}
return result;
}

canonical_decompiled_code:
xcb_void_cookie_t __fastcall func0(__int64 a1, int a2)
{
xcb_void_cookie_t result; // eax
uint32_t value_list; // [rsp+0h] [rbp-14h] BYREF
xcb_rectangle_t rectangles; // [rsp+4h] [rbp-10h] BYREF

if ( a1 )
{
if ( a2 )
{
value_list = *(_DWORD *)(*(_QWORD *)(a1 + 224) + 20LL);
xcb_change_window_attributes(dpy, *(_DWORD *)(a1 + 4), 2u, &value_list);
result.sequence = xcb_clear_area(dpy, 0, *(_DWORD *)(a1 + 4), 0, 0, 0, 0).sequence;
if ( *(_DWORD *)(a1 + 148) )
{
rectangles.x = inset;
rectangles.y = inset;
rectangles.width = *(_WORD *)(a1 + 40) + (_WORD)border - inset;
rectangles.height = *(_WORD *)(a1 + 44) + (_WORD)border - inset;
result.sequence = xcb_poly_rectangle(
dpy,
*(_DWORD *)(a1 + 4),
*(_DWORD *)(*(_QWORD *)(a1 + 224) + 16LL),
1u,
&rectangles).sequence;
}
}
else
{
value_list = *(_DWORD *)(*(_QWORD *)(a1 + 224) + 24LL);
xcb_change_window_attributes(dpy, *(_DWORD *)(a1 + 4), 2u, &value_list);
result.sequence = xcb_clear_area(dpy, 0, *(_DWORD *)(a1 + 4), 0, 0, 0, 0).sequence;
}
}
return result;
}

original_code:
void draw_border(Client *c, int active)
{
    xcb_rectangle_t rect;
    uint32_t value;
    if (!c) {
        ;
        return;
    }
    value = active ? c->screen->black : c->screen->white;
    xcb_change_window_attributes(dpy, c->parent, XCB_CW_BACK_PIXEL, &value);
    xcb_clear_area(dpy, 0, c->parent, 0, 0, 0, 0);
    if (c->hold && active) {
        rect.x = _inset;
        rect.y = _inset;
        rect.width = c->dx + _border - _inset;
        rect.height = c->dy + _border - _inset;
        xcb_poly_rectangle(dpy, c->parent, c->screen->gc, 1, &rect);
    }
}

canonical_original_code:
void draw_border(struct Client *c, int active)
{
    struct xcb_rectangle_t rect;
    unsigned int value;
    if (!c) {
        ;
        return;
    }
    value = active ? c->screen->black : c->screen->white;
    xcb_change_window_attributes(dpy, c->parent, XCB_CW_BACK_PIXEL, &value);
    xcb_clear_area(dpy, 0, c->parent, 0, 0, 0, 0);
    if (c->hold && active) {
        rect.x = _inset;
        rect.y = _inset;
        rect.width = c->dx + _border - _inset;
        rect.height = c->dy + _border - _inset;
        xcb_poly_rectangle(dpy, c->parent, c->screen->gc, 1, &rect);
    }
}

variable_types: active int

variable_types: struct xcb_rectangle_t { short x; short y; unsigned short width; unsigned short height; }

variable_types:
value
unsigned int


setactive

decompiled_code:
void __fastcall setactive(unsigned int *a1, int a2)
{
xcb_window_t v2; // edx
xcb_timestamp_t v3; // eax

if ( a1 )
{
v2 = a1[1];
if ( v2 == *(_DWORD *)(*((_QWORD *)a1 + 28) + 4LL) )
{
fwrite("9wm: bad parent in setactive; dumping core\n", 1uLL, 0x2BuLL, stderr);
abort();
}
if ( a2 )
{
xcb_ungrab_button(dpy, 0, v2, 0x8000u);
v3 = timestamp();
xcb_set_input_focus(dpy, 1u, *a1, v3);
if ( (a1[38] & 2) != 0 )
sendcmessage(*a1, wm_protocols, wm_take_focus, 0LL);
cmapfocus(a1);
}
else
{
xcb_grab_button(dpy, 0, v2, 0xCu, 1u, 0, 0, 0, 0, 0x8000u);
}
draw_border((__int64)a1, a2);
}
}

canonical_decompiled_code:
void __fastcall func1(unsigned int *a1, int a2)
{
xcb_window_t v2; // edx
xcb_timestamp_t v3; // eax

if ( a1 )
{
v2 = a1[1];
if ( v2 == *(_DWORD *)(*((_QWORD *)a1 + 28) + 4LL) )
{
fwrite("9wm: bad parent in setactive; dumping core\n", 1uLL, 0x2BuLL, stderr);
abort();
}
if ( a2 )
{
xcb_ungrab_button(dpy, 0, v2, 0x8000u);
v3 = timestamp();
xcb_set_input_focus(dpy, 1u, *a1, v3);
if ( (a1[38] & 2) != 0 )
sendcmessage(*a1, wm_protocols, wm_take_focus, 0LL);
cmapfocus(a1);
}
else
{
xcb_grab_button(dpy, 0, v2, 0xCu, 1u, 0, 0, 0, 0, 0x8000u);
}
func0((__int64)a1, a2);
}
}

original_code:
void setactive(Client *c, int on)
{
    if (!c) {
        ;
        return;
    }
    if (c->parent == c->screen->root) {
        fprintf(stderr, "9wm: bad parent in setactive; dumping core\n");
        abort();
    }
    if (on) {
        xcb_ungrab_button(dpy, XCB_BUTTON_INDEX_ANY, c->parent,
                    XCB_BUTTON_MASK_ANY);
        xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT,
                    c->window, timestamp());
        if (c->proto & 2)
            sendcmessage(c->window, wm_protocols, wm_take_focus, 0);
        cmapfocus(c);
    }
    else {
        xcb_grab_button(dpy, 0, c->parent, (XCB_EVENT_MASK_BUTTON_PRESS |XCB_EVENT_MASK_BUTTON_RELEASE),
            XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC,
            0L, 0L, XCB_BUTTON_INDEX_ANY,
            XCB_MOD_MASK_ANY);
    }
    draw_border(c, on);
}

canonical_original_code:
void setactive(struct Client *c, int on)
{
    if (!c) {
        ;
        return;
    }
    if (c->parent == c->screen->root) {
        fprintf(stderr, "9wm: bad parent in setactive; dumping core\n");
        abort();
    }
    if (on) {
        xcb_ungrab_button(dpy, XCB_BUTTON_INDEX_ANY, c->parent,
                    XCB_BUTTON_MASK_ANY);
        xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT,
                    c->window, timestamp());
        if (c->proto & 2)
            sendcmessage(c->window, wm_protocols, wm_take_focus, 0);
        cmapfocus(c);
    }
    else {
        xcb_grab_button(dpy, 0, c->parent, (XCB_EVENT_MASK_BUTTON_PRESS |XCB_EVENT_MASK_BUTTON_RELEASE),
            XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_SYNC,
            0L, 0L, XCB_BUTTON_INDEX_ANY,
            XCB_MOD_MASK_ANY);
    }
    draw_border(c, on);
}

variable_types: on int


active

decompiled_code:
void __fastcall active(__int64 a1)
{
__int64 i; // rax
__int64 v2; // rax

if ( a1 && current != a1 )
{
if ( current )
{
setactive((unsigned int *)current, 0);
if ( *(_QWORD *)(current + 224) != *(_QWORD *)(a1 + 224) )
cmapnofocus();
}
setactive((unsigned int *)a1, 1);
for ( i = clients; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_QWORD *)(i + 24) == a1 )
*(_QWORD *)(i + 24) = *(_QWORD *)(a1 + 24);
}
v2 = current;
for ( *(_QWORD *)(a1 + 24) = current; v2; *(_QWORD *)(a1 + 24) = v2 )
{
if ( *(_DWORD *)(v2 + 132) == 1 )
break;
v2 = *(_QWORD *)(v2 + 24);
}
current = a1;
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
__int64 i; // rax
__int64 v2; // rax

if ( a1 && current != a1 )
{
if ( current )
{
func1((unsigned int *)current, 0);
if ( *(_QWORD *)(current + 224) != *(_QWORD *)(a1 + 224) )
cmapnofocus();
}
func1((unsigned int *)a1, 1);
for ( i = clients; i; i = *(_QWORD *)(i + 16) )
{
if ( *(_QWORD *)(i + 24) == a1 )
*(_QWORD *)(i + 24) = *(_QWORD *)(a1 + 24);
}
v2 = current;
for ( *(_QWORD *)(a1 + 24) = current; v2; *(_QWORD *)(a1 + 24) = v2 )
{
if ( *(_DWORD *)(v2 + 132) == 1 )
break;
v2 = *(_QWORD *)(v2 + 24);
}
current = a1;
}
}

original_code:
void active(Client *c)
{
    Client *cc;
    if (!c) {
        ;
        return;
    }
    if (c == current)
        return;
    if (current) {
        setactive(current, 0);
        if (current->screen != c->screen)
            cmapnofocus(current->screen);
    }
    setactive(c, 1);
    for (cc = clients; cc; cc = cc->next)
        if (cc->revert == c)
            cc->revert = c->revert;
    c->revert = current;
    while (c->revert && !((c->revert)->state == XCB_ICCCM_WM_STATE_NORMAL))
        c->revert = c->revert->revert;
    current = c;
}

canonical_original_code:
void active(struct Client *c)
{
    struct Client *cc;
    if (!c) {
        ;
        return;
    }
    if (c == current)
        return;
    if (current) {
        setactive(current, 0);
        if (current->screen != c->screen)
            cmapnofocus(current->screen);
    }
    setactive(c, 1);
    for (cc = clients; cc; cc = cc->next)
        if (cc->revert == c)
            cc->revert = c->revert;
    c->revert = current;
    while (c->revert && !((c->revert)->state == XCB_ICCCM_WM_STATE_NORMAL))
        c->revert = c->revert->revert;
    current = c;
}


nofocus

decompiled_code:
void nofocus()
{
__int64 v0; // rdi
uint32_t value_list[4]; // [rsp+8h] [rbp-10h] BYREF

if ( !current )
{
LABEL_6:
current = 0LL;
if ( !w_0 )
{
value_list[0] = 1;
w_0 = xcb_generate_id(dpy);
xcb_create_window(dpy, 0, w_0, *(_DWORD *)(screens + 4LL), 0, 0, 1u, 1u, 0, 2u, 0, 0x200u, value_list);
xcb_map_window(dpy, w_0);
}
xcb_set_input_focus(dpy, 1u, w_0, 0);
return;
}
setactive((unsigned int *)current, 0);
v0 = *(_QWORD *)(current + 24);
if ( !v0 )
{
LABEL_5:
cmapnofocus(*(_QWORD *)(current + 224));
goto LABEL_6;
}
while ( *(_DWORD *)(v0 + 132) != 1 )
{
v0 = *(_QWORD *)(v0 + 24);
if ( !v0 )
goto LABEL_5;
}
active(v0);
}

canonical_decompiled_code:
void func3()
{
__int64 v0; // rdi
uint32_t value_list[4]; // [rsp+8h] [rbp-10h] BYREF

if ( !current )
{
LABEL_6:
current = 0LL;
if ( !w_0 )
{
value_list[0] = 1;
w_0 = xcb_generate_id(dpy);
xcb_create_window(dpy, 0, w_0, *(_DWORD *)(screens + 4LL), 0, 0, 1u, 1u, 0, 2u, 0, 0x200u, value_list);
xcb_map_window(dpy, w_0);
}
xcb_set_input_focus(dpy, 1u, w_0, 0);
return;
}
func1((unsigned int *)current, 0);
v0 = *(_QWORD *)(current + 24);
if ( !v0 )
{
LABEL_5:
cmapnofocus(*(_QWORD *)(current + 224));
goto LABEL_6;
}
while ( *(_DWORD *)(v0 + 132) != 1 )
{
v0 = *(_QWORD *)(v0 + 24);
if ( !v0 )
goto LABEL_5;
}
func2(v0);
}

original_code:
void nofocus()
{
    static xcb_window_t w = 0;
    uint32_t mask;
    uint32_t values[2];
    Client *c;
    if (current) {
        setactive(current, 0);
        for (c = current->revert; c; c = c->revert)
            if (((c)->state == XCB_ICCCM_WM_STATE_NORMAL)) {
                active(c);
                return;
            }
        cmapnofocus(current->screen);
    }
    current = 0;
    if (w == 0) {
        mask = XCB_CW_OVERRIDE_REDIRECT;
        values[0] = 1;
        w = xcb_generate_id(dpy);
        xcb_create_window(dpy, 0L, w,
            screens[0].root, 0, 0, 1, 1, 0,
            XCB_WINDOW_CLASS_INPUT_ONLY, 0L,
            mask, values);
        xcb_map_window(dpy, w);
    }
    xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, w,
                0L);
}

canonical_original_code:
void nofocus()
{
    static unsigned int w = 0;
    unsigned int mask;
    unsigned int values[2];
    struct Client *c;
    if (current) {
        setactive(current, 0);
        for (c = current->revert; c; c = c->revert)
            if (((c)->state == XCB_ICCCM_WM_STATE_NORMAL)) {
                active(c);
                return;
            }
        cmapnofocus(current->screen);
    }
    current = 0;
    if (w == 0) {
        mask = XCB_CW_OVERRIDE_REDIRECT;
        values[0] = 1;
        w = xcb_generate_id(dpy);
        xcb_create_window(dpy, 0L, w,
            screens[0].root, 0, 0, 1, 1, 0,
            XCB_WINDOW_CLASS_INPUT_ONLY, 0L,
            mask, values);
        xcb_map_window(dpy, w);
    }
    xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, w,
                0L);
}

variable_types:
w
unsigned int

variable_types:
mask
unsigned int


top

decompiled_code:
void __fastcall top(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rcx
__int64 *v3; // rcx

if ( a1 )
{
v1 = clients;
if ( !clients )
{
LABEL_9:
fprintf(stderr, "9wm: %x not on client list in top()\n", a1);
return;
}
if ( a1 != clients )
{
while ( 1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
goto LABEL_9;
if ( a1 == v1 )
{
v3 = (__int64 *)(v2 + 16);
goto LABEL_7;
}
}
}
v3 = &clients;
LABEL_7:
*v3 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = clients;
clients = a1;
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rcx
__int64 *v3; // rcx

if ( a1 )
{
v1 = clients;
if ( !clients )
{
LABEL_9:
fprintf(stderr, "9wm: %x not on client list in top()\n", a1);
return;
}
if ( a1 != clients )
{
while ( 1 )
{
v2 = v1;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
goto LABEL_9;
if ( a1 == v1 )
{
v3 = (__int64 *)(v2 + 16);
goto LABEL_7;
}
}
}
v3 = &clients;
LABEL_7:
*v3 = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = clients;
clients = a1;
}
}

original_code:
void top(Client *c)
{
    Client **l, *cc;
    if (!c) {
        ;
        return;
    }
    l = &clients;
    for (cc = *l; cc; cc = *l) {
        if (cc == c) {
            *l = c->next;
            c->next = clients;
            clients = c;
            return;
        }
        l = &cc->next;
    }
    fprintf(stderr, "9wm: %x not on client list in top()\n", c);
}

canonical_original_code:
void top(struct Client *c)
{
    struct Client **l; struct Client *cc;
    if (!c) {
        ;
        return;
    }
    l = &clients;
    for (cc = *l; cc; cc = *l) {
        if (cc == c) {
            *l = c->next;
            c->next = clients;
            clients = c;
            return;
        }
        l = &cc->next;
    }
    fprintf(stderr, "9wm: %x not on client list in top()\n", c);
}

variable_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; } size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *screen; } **


getclient

decompiled_code:
__int64 __fastcall getclient(int a1, int a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = 0LL;
if ( a1 )
{
v3 = getscreen();
result = 0LL;
if ( !v3 )
{
result = clients;
if ( clients )
{
while ( *(_DWORD *)result != a1 && *(_DWORD *)(result + 4) != a1 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
goto LABEL_7;
}
}
else
{
LABEL_7:
result = 0LL;
if ( a2 )
{
result = xalloc(232LL);
*(_DWORD *)result = a1;
*(_DWORD *)(result + 132) = 0;
*(_QWORD *)(result + 16) = clients;
clients = result;
}
}
}
}
return result;
}

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

result = 0LL;
if ( a1 )
{
v3 = getscreen();
result = 0LL;
if ( !v3 )
{
result = clients;
if ( clients )
{
while ( *(_DWORD *)result != a1 && *(_DWORD *)(result + 4) != a1 )
{
result = *(_QWORD *)(result + 16);
if ( !result )
goto LABEL_7;
}
}
else
{
LABEL_7:
result = 0LL;
if ( a2 )
{
result = xalloc(232LL);
*(_DWORD *)result = a1;
*(_DWORD *)(result + 132) = 0;
*(_QWORD *)(result + 16) = clients;
clients = result;
}
}
}
}
return result;
}

original_code:
Client * getclient(xcb_window_t w, int create)
{
    Client *c = ((void *)0);
    if (w == 0 || getscreen(w))
        return 0;
    for (c = clients; c; c = c->next)
        if (c->window == w || c->parent == w)
            return c;
    if (create) {
        c = xalloc(sizeof(Client));
        c->window = w;
        c->state = XCB_ICCCM_WM_STATE_WITHDRAWN;
        c->next = clients;
        clients = c;
    }
    return c;
}

canonical_original_code:
struct Client *getclient(unsigned int w, int create)
{
    struct Client *c = ((void *)0);
    if (w == 0 || getscreen(w))
        return 0;
    for (c = clients; c; c = c->next)
        if (c->window == w || c->parent == w)
            return c;
    if (create) {
        c = xalloc(sizeof(Client));
        c->window = w;
        c->state = XCB_ICCCM_WM_STATE_WITHDRAWN;
        c->next = clients;
        clients = c;
    }
    return c;
}

variable_types: create int

variable_types: struct Client { unsigned int window; unsigned int parent; unsigned int trans; struct Client *next; struct Client *revert; int x; int y; int dx; int dy; int border; struct xcb_size_hints_t { unsigned int flags; int x; int width; int min_width; int max_width; int width_inc; int min_aspect_num; int max_aspect_num; int base_width; unsigned int win_gravity; } size; int min_dx; int min_dy; int state; int init; int reparenting; int is9term; int hold; int proto; char *label; char *instance; char *class; char *name; char *iconname; unsigned int cmap; int ncmapwins; unsigned int *cmapwins; unsigned int *wmcmaps; struct ScreenInfo { int num; unsigned int root; unsigned int menuwin; unsigned int def_cmap; unsigned int gc; unsigned int black; unsigned int white; int min_cmaps; unsigned int target; unsigned int sweep0; unsigned int boxcurs; unsigned int arrow; unsigned int root_pixmap; char display[256]; } *screen; } *


rmclient

decompiled_code:
void __fastcall rmclient(void *ptr)
{
__int64 v2; // rdx
void *v3; // rax
__int64 v4; // rdx
void *v5; // rax
xcb_window_t v6; // esi
void *v7; // rdi
void *v8; // rdi
void *v9; // rdi
void *v10; // rdi
__int64 v11; // rax
__int64 v12; // rdi

if ( ptr )
{
v2 = current;
if ( current )
{
while ( 1 )
{
v3 = *(void **)(v2 + 24);
if ( !v3 )
break;
if ( v3 == ptr )
{
v3 = (void *)*((_QWORD *)ptr + 3);
*(_QWORD *)(v2 + 24) = v3;
if ( !v3 )
break;
}
v2 = (__int64)v3;
}
}
if ( (void *)clients == ptr )
clients = *((_QWORD *)ptr + 2);
v4 = clients;
if ( clients )
{
while ( 1 )
{
v5 = *(void **)(v4 + 16);
if ( !v5 )
break;
if ( v5 == ptr )
{
v5 = (void *)*((_QWORD *)ptr + 2);
*(_QWORD *)(v4 + 16) = v5;
if ( !v5 )
break;
}
v4 = (__int64)v5;
}
}
if ( *((_DWORD *)ptr + 33) == 3 )
unhidec(ptr, 0LL);
v6 = *((_DWORD *)ptr + 1);
if ( v6 != *(_DWORD *)(*((_QWORD *)ptr + 28) + 4LL) )
xcb_destroy_window(dpy, v6);
*(_DWORD *)ptr = 0;
*((_DWORD *)ptr + 1) = 0;
if ( (void *)current == ptr )
{
v11 = *((_QWORD *)ptr + 3);
current = v11;
if ( v11 )
{
v12 = *((_QWORD *)ptr + 28);
if ( *(_QWORD *)(v11 + 224) != v12 )
cmapnofocus(v12);
setactive((unsigned int *)current, 1);
}
else
{
nofocus();
}
}
v7 = (void *)*((_QWORD *)ptr + 21);
if ( v7 )
free(v7);
v8 = (void *)*((_QWORD *)ptr + 22);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)ptr + 23);
if ( v9 )
free(v9);
v10 = (void *)*((_QWORD *)ptr + 24);
if ( v10 )
free(v10);
if ( *((_DWORD *)ptr + 51) )
{
free(*((void **)ptr + 26));
free(*((void **)ptr + 27));
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
__int64 v2; // rdx
void *v3; // rax
__int64 v4; // rdx
void *v5; // rax
xcb_window_t v6; // esi
void *v7; // rdi
void *v8; // rdi
void *v9; // rdi
void *v10; // rdi
__int64 v11; // rax
__int64 v12; // rdi

if ( ptr )
{
v2 = current;
if ( current )
{
while ( 1 )
{
v3 = *(void **)(v2 + 24);
if ( !v3 )
break;
if ( v3 == ptr )
{
v3 = (void *)*((_QWORD *)ptr + 3);
*(_QWORD *)(v2 + 24) = v3;
if ( !v3 )
break;
}
v2 = (__int64)v3;
}
}
if ( (void *)clients == ptr )
clients = *((_QWORD *)ptr + 2);
v4 = clients;
if ( clients )
{
while ( 1 )
{
v5 = *(void **)(v4 + 16);
if ( !v5 )
break;
if ( v5 == ptr )
{
v5 = (void *)*((_QWORD *)ptr + 2);
*(_QWORD *)(v4 + 16) = v5;
if ( !v5 )
break;
}
v4 = (__int64)v5;
}
}
if ( *((_DWORD *)ptr + 33) == 3 )
unhidec(ptr, 0LL);
v6 = *((_DWORD *)ptr + 1);
if ( v6 != *(_DWORD *)(*((_QWORD *)ptr + 28) + 4LL) )
xcb_destroy_window(dpy, v6);
*(_DWORD *)ptr = 0;
*((_DWORD *)ptr + 1) = 0;
if ( (void *)current == ptr )
{
v11 = *((_QWORD *)ptr + 3);
current = v11;
if ( v11 )
{
v12 = *((_QWORD *)ptr + 28);
if ( *(_QWORD *)(v11 + 224) != v12 )
cmapnofocus(v12);
func1((unsigned int *)current, 1);
}
else
{
func3();
}
}
v7 = (void *)*((_QWORD *)ptr + 21);
if ( v7 )
free(v7);
v8 = (void *)*((_QWORD *)ptr + 22);
if ( v8 )
free(v8);
v9 = (void *)*((_QWORD *)ptr + 23);
if ( v9 )
free(v9);
v10 = (void *)*((_QWORD *)ptr + 24);
if ( v10 )
free(v10);
if ( *((_DWORD *)ptr + 51) )
{
free(*((void **)ptr + 26));
free(*((void **)ptr + 27));
}
free(ptr);
}
}

original_code:
void rmclient(Client *c)
{
    Client *cc;
    if (!c) {
        ;
        return;
    }
    for (cc = current; cc && cc->revert; cc = cc->revert)
        if (cc->revert == c)
            cc->revert = cc->revert->revert;
    if (c == clients)
        clients = c->next;
    for (cc = clients; cc && cc->next; cc = cc->next)
        if (cc->next == c)
            cc->next = cc->next->next;
    if (((c)->state == XCB_ICCCM_WM_STATE_ICONIC))
        unhidec(c, 0);
    if (c->parent != c->screen->root)
        xcb_destroy_window(dpy, c->parent);
    c->parent = c->window = 0L;
    if (current == c) {
        current = c->revert;
        if (current == 0)
            nofocus();
        else {
            if (current->screen != c->screen)
                cmapnofocus(c->screen);
            setactive(current, 1);
        }
    }
    if (c->instance)
        free(c->instance);
    if (c->class)
        free(c->class);
    if (c->name)
        free(c->name);
    if (c->iconname)
        free(c->iconname);
    if (c->ncmapwins != 0) {
        free((char *)c->cmapwins);
        free((char *)c->wmcmaps);
    }
    memset(c, 0, sizeof(Client));
    free(c);
}

canonical_original_code:
void rmclient(struct Client *c)
{
    struct Client *cc;
    if (!c) {
        ;
        return;
    }
    for (cc = current; cc && cc->revert; cc = cc->revert)
        if (cc->revert == c)
            cc->revert = cc->revert->revert;
    if (c == clients)
        clients = c->next;
    for (cc = clients; cc && cc->next; cc = cc->next)
        if (cc->next == c)
            cc->next = cc->next->next;
    if (((c)->state == XCB_ICCCM_WM_STATE_ICONIC))
        unhidec(c, 0);
    if (c->parent != c->screen->root)
        xcb_destroy_window(dpy, c->parent);
    c->parent = c->window = 0L;
    if (current == c) {
        current = c->revert;
        if (current == 0)
            nofocus();
        else {
            if (current->screen != c->screen)
                cmapnofocus(c->screen);
            setactive(current, 1);
        }
    }
    if (c->instance)
        free(c->instance);
    if (c->class)
        free(c->class);
    if (c->name)
        free(c->name);
    if (c->iconname)
        free(c->iconname);
    if (c->ncmapwins != 0) {
        free((char *)c->cmapwins);
        free((char *)c->wmcmaps);
    }
    memset(c, 0, sizeof(Client));
    free(c);
}


repo: jwerle/liburl

variable_types: byte char

variable_types: set int

variable_types:
enc
char [64]

variable_types:
c
char *

return_type: char *


decompiled_code:
__int64 __fastcall url_percent_encode(const char *a1, unsigned int a2)
{
int v2; // er13
char *v3; // rbp
const char *v4; // rbx
__int64 v5; // r13
const char *v6; // rax
signed int v7; // ebx

v2 = strlen(a1);
v3 = (char *)malloc(v2);
if ( v2 > 0 )
{
v4 = a1;
v5 = (__int64)&a1[v2 - 1 + 1];
do
{
v6 = (const char *)url_percent_encode_byte((unsigned int)*v4, a2);
strcat(v3, v6);
++v4;
}
while ( v4 != (const char *)v5 );
}
v7 = (unsigned int)strdup(v3);
free(v3);
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1, unsigned int a2)
{
int v2; // er13
char *v3; // rbp
const char *v4; // rbx
__int64 v5; // r13
const char *v6; // rax
signed int v7; // ebx

v2 = strlen(a1);
v3 = (char *)malloc(v2);
if ( v2 > 0 )
{
v4 = a1;
v5 = (__int64)&a1[v2 - 1 + 1];
do
{
v6 = (const char *)func1((unsigned int)*v4, a2);
strcat(v3, v6);
++v4;
}
while ( v4 != (const char *)v5 );
}
v7 = (unsigned int)strdup(v3);
free(v3);
return v7;
}

original_code:
char *
url_percent_encode (char *str, int set) {
  char *ret = ((void *)0);
  char *byte = ((void *)0);
  char *bytes = ((void *)0);
  int len = strlen(str);
  int i = 0;
  bytes = malloc(sizeof(char) * len);
  for (; i < len; ++i) {
    byte = url_percent_encode_byte(str[i], set);
    strcat(bytes, byte);
  }
  ret = strdup(bytes);
  free(bytes);
  return ret;
}

canonical_original_code:
char *url_percent_encode(char *str, int set) {
  char *ret = ((void *)0);
  char *byte = ((void *)0);
  char *bytes = ((void *)0);
  int len = strlen(str);
  int i = 0;
  bytes = malloc(sizeof(char) * len);
  for (; i < len; ++i) {
    byte = url_percent_encode_byte(str[i], set);
    strcat(bytes, byte);
  }
  ret = strdup(bytes);
  free(bytes);
  return ret;
}

variable_types:
str
char *

variable_types:
ret
char *

variable_types:
byte
char *

variable_types:
bytes
char *

variable_types: len int

variable_types: i int


decompiled_code:
_BOOL8 __fastcall is_url_codepoint(char a1)
{
return a1 >= 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char a1)
{
return a1 >= 0;
}

variable_types: c char

return_type: int


decompiled_code:
__int64 __fastcall url_parse_host(char *s)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rdx

result = 0LL;
if ( *s == 91 )
{
v2 = (int)strlen(s);
result = 0LL;
if ( s[v2 - 1] == 93 )
{
v3 = (int)strdup(s);
result = v3 + 1;
*(_BYTE *)(v3 + v2) = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rdx

result = 0LL;
if ( *s == 91 )
{
v2 = (int)strlen(s);
result = 0LL;
if ( s[v2 - 1] == 93 )
{
v3 = (int)strdup(s);
result = v3 + 1;
*(_BYTE *)(v3 + v2) = 0;
}
}
return result;
}

original_code:
char *
url_parse_host (const char *url) {
  char *host = ((void *)0);
  char *ret = ((void *)0);
  int l = (int) strlen(url);
  if (((void *)0) == url) {
    return ((void *)0);
  }
  if ('[' == url[0]) {
    if (']' != url[l-1]) {
      return ((void *)0);
    } else {
      ret = strdup(url);
      *ret++;
      ret[l-1] = '\0';
      return ret;
    }
  }
  return ((void *)0);
}

canonical_original_code:
char *url_parse_host(char *url) {
  char *host = ((void *)0);
  char *ret = ((void *)0);
  int l = (int) strlen(url);
  if (((void *)0) == url) {
    return ((void *)0);
  }
  if ('[' == url[0]) {
    if (']' != url[l-1]) {
      return ((void *)0);
    } else {
      ret = strdup(url);
      *ret++;
      ret[l-1] = '\0';
      return ret;
    }
  }
  return ((void *)0);
}

variable_types:
url
char *

variable_types:
host
char *

variable_types: l int


decompiled_code:
const char **__fastcall url_relative_scheme(char *s1)
{
size_t v1; // r12
const char **v2; // rbx
const char **v3; // r13

v1 = strlen(s1);
v2 = (const char **)&url_relative_schemes;
while ( 1 )
{
v3 = v2;
if ( !strncmp(s1, *v2, v1) )
break;
v2 += 2;
if ( v2 == (const char **)(&url_relative_schemes + 14) )
return 0LL;
}
return v3;
}

canonical_decompiled_code:
const char **__fastcall func0(char *s1)
{
size_t v1; // r12
const char **v2; // rbx
const char **v3; // r13

v1 = strlen(s1);
v2 = (const char **)&url_relative_schemes;
while ( 1 )
{
v3 = v2;
if ( !strncmp(s1, *v2, v1) )
break;
v2 += 2;
if ( v2 == (const char **)(&url_relative_schemes + 14) )
return 0LL;
}
return v3;
}

original_code:
char **
url_relative_scheme (const char *scheme) {
  int i = 0;
  int len = sizeof(_url_relative_schemes) / sizeof(_url_relative_schemes[0]);
  char **item;
  while (i < len && ((void *)0) != (item = _url_relative_schemes[i++])) {
    if (0 == strncmp(scheme, item[0], strlen(scheme))) {
      return item;
    }
  }
  return ((void *)0);
}

canonical_original_code:
char **url_relative_scheme(char *scheme) {
  int i = 0;
  int len = sizeof(_url_relative_schemes) / sizeof(_url_relative_schemes[0]);
  char **item;
  while (i < len && ((void *)0) != (item = _url_relative_schemes[i++])) {
    if (0 == strncmp(scheme, item[0], strlen(scheme))) {
      return item;
    }
  }
  return ((void *)0);
}

variable_types:
scheme
char *

variable_types:
item
char **

return_type: char **


original_code:
char *
utf8_decode (const char *str) {
  unsigned char buf[4096];
  unsigned char bp = 0;
  unsigned char cp = 0;
  unsigned char lower = 0x80;
  unsigned char upper = 0xBF;
  unsigned int b = 0;
  int i = 0;
  int n = 0;
  int seen = 0;
  int needed = 0;
  while ('\0' != (bp = str[i++])) {
    if ((*__errno_location ()) > 0) {
      return ((void *)0);
    }
    b = (unsigned int) bp;
    if (b == (-1)) {
      if (0 != needed) {
        needed = 0;
        (*__errno_location ()) = UTF8E_EOF_BYTES_NEEDED;
      }
      buf[n++] = (-1);
      continue;
    }
    if (0 == needed) {
      if ((b >= (unsigned int) 0x00 && b <= (unsigned int) 0x7F)) {
        buf[n++] = b;
        continue;
      }
      if (0 == (b >= (unsigned int) 0xC2 && b <= (unsigned int) 0xF4)) {
        (*__errno_location ()) = UTF8E_BYTE_RANGE;
        continue;
      }
      if ((b >= (unsigned int) 0xC2 && b <= (unsigned int) 0xDF)) {
        needed = 1;
        cp = b - 0xC0;
      }
      if ((b >= (unsigned int) 0xE0 && b <= (unsigned int) 0xEF)) {
        if (b == 0xE0) {
          lower = 0xA0;
        } else if (b == 0xED) {
          upper = 0x9F;
        }
        needed = 2;
        cp = b - 0xE0;
      }
      if ((b >= (unsigned int) 0xF0 && b <= (unsigned int) 0xF4)) {
        if (b == 0xF0) {
          lower = 0x90;
        } else if (b == 0xF4) {
          upper = 0x8F;
        }
        needed = 3;
        cp = b - 0xF0;
      }
      cp = cp * pow(64, needed);
      continue;
    }
    if (0 == (b >= (unsigned int) lower && b <= (unsigned int) upper)) {
      cp = 0;
      needed = 0;
      seen = 0;
      bp = str[--i];
      lower = 0x80;
      upper = 0xBF;
      (*__errno_location ()) = UTF8E_BYTE_BOUNDARY_RANGE;
      continue;
    }
    lower = 0x80;
    upper = 0xBF;
    seen++;
    cp += (b - 0x80) * pow(64, needed - seen);
    if (seen != needed) {
      continue;
    }
    buf[n++] = cp;
    cp = 0;
    needed = 0;
    seen = 0;
  }
  buf[n] = '\0';
  return strdup((char *) buf);
}

canonical_original_code:
char *utf8_decode(char *str) {
  unsigned char buf[4096];
  unsigned char bp = 0;
  unsigned char cp = 0;
  unsigned char lower = 0x80;
  unsigned char upper = 0xBF;
  unsigned int b = 0;
  int i = 0;
  int n = 0;
  int seen = 0;
  int needed = 0;
  while ('\0' != (bp = str[i++])) {
    if ((*__errno_location ()) > 0) {
      return ((void *)0);
    }
    b = (unsigned int) bp;
    if (b == (-1)) {
      if (0 != needed) {
        needed = 0;
        (*__errno_location ()) = UTF8E_EOF_BYTES_NEEDED;
      }
      buf[n++] = (-1);
      continue;
    }
    if (0 == needed) {
      if ((b >= (unsigned int) 0x00 && b <= (unsigned int) 0x7F)) {
        buf[n++] = b;
        continue;
      }
      if (0 == (b >= (unsigned int) 0xC2 && b <= (unsigned int) 0xF4)) {
        (*__errno_location ()) = UTF8E_BYTE_RANGE;
        continue;
      }
      if ((b >= (unsigned int) 0xC2 && b <= (unsigned int) 0xDF)) {
        needed = 1;
        cp = b - 0xC0;
      }
      if ((b >= (unsigned int) 0xE0 && b <= (unsigned int) 0xEF)) {
        if (b == 0xE0) {
          lower = 0xA0;
        } else if (b == 0xED) {
          upper = 0x9F;
        }
        needed = 2;
        cp = b - 0xE0;
      }
      if ((b >= (unsigned int) 0xF0 && b <= (unsigned int) 0xF4)) {
        if (b == 0xF0) {
          lower = 0x90;
        } else if (b == 0xF4) {
          upper = 0x8F;
        }
        needed = 3;
        cp = b - 0xF0;
      }
      cp = cp * pow(64, needed);
      continue;
    }
    if (0 == (b >= (unsigned int) lower && b <= (unsigned int) upper)) {
      cp = 0;
      needed = 0;
      seen = 0;
      bp = str[--i];
      lower = 0x80;
      upper = 0xBF;
      (*__errno_location ()) = UTF8E_BYTE_BOUNDARY_RANGE;
      continue;
    }
    lower = 0x80;
    upper = 0xBF;
    seen++;
    cp += (b - 0x80) * pow(64, needed - seen);
    if (seen != needed) {
      continue;
    }
    buf[n++] = cp;
    cp = 0;
    needed = 0;
    seen = 0;
  }
  buf[n] = '\0';
  return strdup((char *) buf);
}

variable_types:
buf
unsigned char [4096]

variable_types:
bp
unsigned char

variable_types:
cp
unsigned char

variable_types:
lower
unsigned char

variable_types:
upper
unsigned char

variable_types:
b
unsigned int

variable_types: n int

variable_types: seen int

variable_types: needed int


decompiled_code:
char *__fastcall utf8_encode(char *a1)
{
char v1; // bl
int v2; // esi
char *v3; // rdx
int v4; // eax
int v5; // ecx
char *result; // rax
char v7[4120]; // [rsp+0h] [rbp-1018h] BYREF

v1 = *a1;
if ( *a1 )
{
v2 = *__errno_location();
v3 = a1 + 1;
v4 = 0;
while ( v2 <= 0 )
{
if ( v1 < 0 )
{
v5 = v4 + 1;
v7[v4] = (int)((double)(unsigned __int8)v1 * 0.015625 + 192.0);
v4 += 2;
v7[v5] = (v1 & 0x3F) + 0x80;
}
else
{
v7[v4++] = v1;
}
v1 = *v3++;
if ( !v1 )
goto LABEL_9;
}
result = 0LL;
}
else
{
v4 = 0;
LABEL_9:
v7[v4] = 0;
result = strdup(v7);
}
return result;
}

canonical_decompiled_code:
char *__fastcall func2(char *a1)
{
char v1; // bl
int v2; // esi
char *v3; // rdx
int v4; // eax
int v5; // ecx
char *result; // rax
char v7[4120]; // [rsp+0h] [rbp-1018h] BYREF

v1 = *a1;
if ( *a1 )
{
v2 = *__errno_location();
v3 = a1 + 1;
v4 = 0;
while ( v2 <= 0 )
{
if ( v1 < 0 )
{
v5 = v4 + 1;
v7[v4] = (int)((double)(unsigned __int8)v1 * 0.015625 + 192.0);
v4 += 2;
v7[v5] = (v1 & 0x3F) + 0x80;
}
else
{
v7[v4++] = v1;
}
v1 = *v3++;
if ( !v1 )
goto LABEL_9;
}
result = 0LL;
}
else
{
v4 = 0;
LABEL_9:
v7[v4] = 0;
result = strdup(v7);
}
return result;
}

original_code:
char *
utf8_encode (const char *str) {
  unsigned char buf[4096];
  unsigned char cp = 0;
  unsigned char b = 0;
  unsigned int c = 0;
  int i = 0;
  int n = 0;
  int count = 0;
  int offset = 0;
  while ('\0' != (cp = (str[i++]))) {
    if ((*__errno_location ()) > 0) {
      return ((void *)0);
    }
    c = (unsigned int) cp;
    if ((c >= (unsigned int) 0xD800 && c <= (unsigned int) 0xDFFF)) {
      (*__errno_location ()) = UTF8E_CODE_POINT_OOB;
      break;
    }
    if ((-1) == c) {
      buf[n++] = (-1);
      break;
    }
    if ((c >= (unsigned int) 0x0000 && c <= (unsigned int) 0x07F)) {
      buf[n++] = c;
      continue;
    }
    if ((c >= (unsigned int) 0x0080 && c <= (unsigned int) 0x07FF)) {
      count = 1;
      offset = 0xC0;
    } else if ((c >= (unsigned int) 0x0800 && c <= (unsigned int) 0xFFFF)) {
      count = 2;
      offset = 0xE0;
    } else if ((c >= (unsigned int) 0x10000 && c <= (unsigned int) 0x10FFFF)) {
      count = 3;
      offset = 0xF0;
    }
    buf[n++] = (c/pow(64, count)) + offset;
    while (count > 0) {
      b = c/pow(64, count - 1);
      buf[n++] = 0x80 + (b % 64);
      count--;
    }
  }
  buf[n] = '\0';
  return strdup((char *)buf);
}

canonical_original_code:
char *utf8_encode(char *str) {
  unsigned char buf[4096];
  unsigned char cp = 0;
  unsigned char b = 0;
  unsigned int c = 0;
  int i = 0;
  int n = 0;
  int count = 0;
  int offset = 0;
  while ('\0' != (cp = (str[i++]))) {
    if ((*__errno_location ()) > 0) {
      return ((void *)0);
    }
    c = (unsigned int) cp;
    if ((c >= (unsigned int) 0xD800 && c <= (unsigned int) 0xDFFF)) {
      (*__errno_location ()) = UTF8E_CODE_POINT_OOB;
      break;
    }
    if ((-1) == c) {
      buf[n++] = (-1);
      break;
    }
    if ((c >= (unsigned int) 0x0000 && c <= (unsigned int) 0x07F)) {
      buf[n++] = c;
      continue;
    }
    if ((c >= (unsigned int) 0x0080 && c <= (unsigned int) 0x07FF)) {
      count = 1;
      offset = 0xC0;
    } else if ((c >= (unsigned int) 0x0800 && c <= (unsigned int) 0xFFFF)) {
      count = 2;
      offset = 0xE0;
    } else if ((c >= (unsigned int) 0x10000 && c <= (unsigned int) 0x10FFFF)) {
      count = 3;
      offset = 0xF0;
    }
    buf[n++] = (c/pow(64, count)) + offset;
    while (count > 0) {
      b = c/pow(64, count - 1);
      buf[n++] = 0x80 + (b % 64);
      count--;
    }
  }
  buf[n] = '\0';
  return strdup((char *)buf);
}

variable_types:
str
char *

variable_types:
b
unsigned char

variable_types:
c
unsigned int

variable_types: count int

variable_types: offset int


repo: jwittkoski/GenericTunerPlugin

decompiled_code:
char *__fastcall alloc_string(char *src)
{
size_t v1; // rax
char *v2; // rbp

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
strcpy(v2, src);
return v2;
}

canonical_decompiled_code:
char *__fastcall func1(char *src)
{
size_t v1; // rax
char *v2; // rbp

if ( !src )
return 0LL;
v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
strcpy(v2, src);
return v2;
}

original_code:
char *alloc_string(char *str) {
    if ( str == ((void *)0) ) return ((void *)0);
    char *newStr = malloc(strlen(str)+1);
    strcpy((char *)newStr, (const char *)str);
    return newStr;
}

canonical_original_code:
char *alloc_string(char *str) {
    if ( str == ((void *)0) ) return ((void *)0);
    char *newStr = malloc(strlen(str)+1);
    strcpy((char *)newStr, (char *)str);
    return newStr;
}

variable_types:
newStr
char *


NeedCarrierFrequency

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

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

original_code:
int NeedCarrierFrequency() {
    return 0;
}


DeviceName

decompiled_code:
const char *DeviceName()
{
return "Generic Tuner";
}

canonical_decompiled_code:
const char *func4()
{
return "Generic Tuner";
}

original_code:
const char* DeviceName() {
    return "Generic Tuner";
}


OpenDevice

decompiled_code:
__int64 __fastcall OpenDevice(double a1)
{
double v1; // xmm0_8

v1 = log(a1);
log(v1);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(double a1)
{
double v1; // xmm0_8

v1 = func0(a1);
func0(v1);
return 1LL;
}

original_code:
int OpenDevice(int ComPort) {
    _log(6, "%s, Version %s", "Generic Tuner", "1.4.0");;
    _log(7, "OpenDevice: %d", ComPort);;
    return 1;
}

variable_types: ComPort int


CloseDevice

decompiled_code:
double __fastcall CloseDevice(double a1)
{
return log(a1);
}

canonical_decompiled_code:
double __fastcall func6(double a1)
{
return func0(a1);
}

original_code:
void CloseDevice(int devHandle) {
    _log(7, "CloseDevice: %d", devHandle);;
}

variable_types: devHandle int


FindCarrierFrequency

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

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

original_code:
unsigned long FindCarrierFrequency(int devHandle) {
    return 0;
}

return_type: unsigned long


AddRemote

decompiled_code:
__int64 __fastcall AddRemote(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *a2;
if ( *a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 32);
}
while ( result );
*(_QWORD *)(v3 + 32) = a1;
*(_QWORD *)(a1 + 32) = 0LL;
}
else
{
*a2 = a1;
*(_QWORD *)(a1 + 32) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *a2;
if ( *a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 32);
}
while ( result );
*(_QWORD *)(v3 + 32) = a1;
*(_QWORD *)(a1 + 32) = 0LL;
}
else
{
*a2 = a1;
*(_QWORD *)(a1 + 32) = 0LL;
}
return result;
}

original_code:
void AddRemote(struct remote *Remote, struct remote **head) {
    struct remote *Temp;
    if (!(*head)) {
        *head = Remote;
        (*head)->next = ((void *)0);
    } else
    {
        Temp = *head;
        while (Temp->next) {
            Temp = Temp->next;
        }
        Temp->next = Remote;
        Remote->next = ((void *)0);
    }
}

variable_types: struct remote { unsigned char *name; unsigned long carrier_freq; unsigned int bit_time; struct command { unsigned char *name; struct pattern { unsigned int bit_length; unsigned int length; char r_flag; unsigned char *bytes; struct pattern *next; } *pattern; struct command *next; } *command; struct remote *next; } *

variable_types:
head
struct remote **

user_defined_types: struct remote { unsigned char *name; unsigned long carrier_freq; unsigned int bit_time; struct command *command; struct remote *next; }

user_defined_types: struct command { unsigned char *name; struct pattern *pattern; struct command *next; }


AddCommand

decompiled_code:
__int64 __fastcall AddCommand(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *a2;
if ( *a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 16);
}
while ( result );
*(_QWORD *)(v3 + 16) = a1;
*(_QWORD *)(a1 + 16) = 0LL;
}
else
{
*a2 = a1;
*(_QWORD *)(a1 + 16) = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, __int64 *a2)
{
__int64 result; // rax
__int64 v3; // rdx

result = *a2;
if ( *a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 16);
}
while ( result );
*(_QWORD *)(v3 + 16) = a1;
*(_QWORD *)(a1 + 16) = 0LL;
}
else
{
*a2 = a1;
*(_QWORD *)(a1 + 16) = 0LL;
}
return result;
}

original_code:
void AddCommand(struct command *Command, struct command **Command_List) {
    struct command *Temp;
    if (!(*Command_List)) {
        (*Command_List) = Command;
        (*Command_List)->next = ((void *)0);
    } else {
        Temp = (*Command_List);
        while (Temp->next) {
            Temp = Temp->next;
        }
        Temp->next = Command;
        Command->next = ((void *)0);
    }
}

variable_types: struct command { unsigned char *name; struct pattern { unsigned int bit_length; unsigned int length; char r_flag; unsigned char *bytes; struct pattern *next; } *pattern; struct command *next; } *


chomp

decompiled_code:
__int64 __fastcall chomp(const char *a1)
{
__int64 result; // rax
const char *v2; // rbx

result = (unsigned int)strlen(a1) - 1;
if ( (int)result >= 0 )
{
result = (int)result;
v2 = &a1[(int)result];
if ( *v2 == 10 )
*v2 = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1)
{
__int64 result; // rax
const char *v2; // rbx

result = (unsigned int)strlen(a1) - 1;
if ( (int)result >= 0 )
{
result = (int)result;
v2 = &a1[(int)result];
if ( *v2 == 10 )
*v2 = 0;
}
return result;
}

original_code:
void chomp (char* s) {
    int end = strlen(s) - 1;
    if ( end >= 0 && s[end] == '\n' )
        s[end] = '\0';
}

canonical_original_code:
void chomp(char *s) {
    int end = strlen(s) - 1;
    if ( end >= 0 && s[end] == '\n' )
        s[end] = '\0';
}

variable_types:
s
char *

variable_types: end int


InitDevice

decompiled_code:
double __fastcall InitDevice(double a1)
{
return log(a1);
}

canonical_decompiled_code:
double __fastcall func13(double a1)
{
return func0(a1);
}

original_code:
void InitDevice() {
    _log(7, "InitDevice");;
}


RecordCommand

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

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

original_code:
command* RecordCommand(int devHandle, unsigned char *Name) {
    return 0;
}

canonical_original_code:
struct command *RecordCommand(int devHandle, unsigned char *Name) {
    return 0;
}

variable_types:
Name
unsigned char *

return_type: struct command { unsigned char *name; struct pattern { unsigned int bit_length; unsigned int length; char r_flag; unsigned char *bytes; struct pattern *next; } *pattern; struct command *next; } *


PlayCommand

decompiled_code:
void __fastcall PlayCommand(double a1, __int64 a2, const char **a3, const char *a4)
{
double v4; // xmm0_8
double v5; // xmm0_8
char v6[1048]; // [rsp-418h] [rbp-418h] BYREF

if ( a3 )
{
snprintf(v6, 0x400uLL, "%s SEND %s %s", "/opt/sagetv/server/gentuner", *a3, a4);
v4 = log(a1);
v5 = log(v4);
system(v6);
log(v5);
}
}

canonical_decompiled_code:
void __fastcall func15(double a1, __int64 a2, const char **a3, const char *a4)
{
double v4; // xmm0_8
double v5; // xmm0_8
char v6[1048]; // [rsp-418h] [rbp-418h] BYREF

if ( a3 )
{
snprintf(v6, 0x400uLL, "%s SEND %s %s", "/opt/sagetv/server/gentuner", *a3, a4);
v4 = func0(a1);
v5 = func0(v4);
system(v6);
func0(v5);
}
}

original_code:
void PlayCommand(int devHandle, remote *remote, unsigned char *name, int tx_repeats) {
    char cmd[1024];
    if ( ! remote ) {
        return;
    }
    snprintf(cmd, sizeof(cmd), "%s SEND %s %s", "/opt/sagetv/server/gentuner", remote->name, name);
    _log(7, "PlayCommand: Using command: %s", cmd);;
    _log(6, "PlayCommand: Remote: %s, Key: %s", remote->name, name);;
    if ( system(cmd) != 0 ) {
        _log(3, "PlayCommand: Failed to execute SEND command: %s", cmd);;
    } else {
        _log(7, "PlayCommand: Executed SEND command without error: %s", cmd);;
    }
}

canonical_original_code:
void PlayCommand(int devHandle, struct remote *remote, unsigned char *name, int tx_repeats) {
    char cmd[1024];
    if ( ! remote ) {
        return;
    }
    snprintf(cmd, sizeof(cmd), "%s SEND %s %s", "/opt/sagetv/server/gentuner", remote->name, name);
    _log(7, "PlayCommand: Using command: %s", cmd);;
    _log(6, "PlayCommand: Remote: %s, Key: %s", remote->name, name);;
    if ( system(cmd) != 0 ) {
        _log(3, "PlayCommand: Failed to execute SEND command: %s", cmd);;
    } else {
        _log(7, "PlayCommand: Executed SEND command without error: %s", cmd);;
    }
}

variable_types:
name
unsigned char *

variable_types:
cmd
char [1024]

user_defined_types: struct pattern { unsigned int bit_length; unsigned int length; char r_flag; unsigned char *bytes; struct pattern *next; }


FreeRemotes

original_code:
void FreeRemotes(remote **head) {
    _log(7, "FreeRemotes");;
    command *Temp_Com;
    remote *Temp_Rem;
    pattern *temp_pat;
    while (*head) {
        Temp_Rem = *head;
        Temp_Com = (*head)->command;
        while (Temp_Com) {
            (*head)->command = (*head)->command->next;
            temp_pat = Temp_Com->pattern;
            while (temp_pat) {
                Temp_Com->pattern = Temp_Com->pattern->next;
                free(temp_pat->bytes);
                free(temp_pat);
                temp_pat = Temp_Com->pattern;
            }
            free(Temp_Com->name);
            free(Temp_Com);
            Temp_Com = (*head)->command;
        }
        (*head) = (*head)->next;
        free(Temp_Rem->name);
        free(Temp_Rem);
    }
    *head = ((void *)0);
}

canonical_original_code:
void FreeRemotes(struct remote **head) {
    _log(7, "FreeRemotes");;
    struct command *Temp_Com;
    struct remote *Temp_Rem;
    struct pattern *temp_pat;
    while (*head) {
        Temp_Rem = *head;
        Temp_Com = (*head)->command;
        while (Temp_Com) {
            (*head)->command = (*head)->command->next;
            temp_pat = Temp_Com->pattern;
            while (temp_pat) {
                Temp_Com->pattern = Temp_Com->pattern->next;
                free(temp_pat->bytes);
                free(temp_pat);
                temp_pat = Temp_Com->pattern;
            }
            free(Temp_Com->name);
            free(Temp_Com);
            Temp_Com = (*head)->command;
        }
        (*head) = (*head)->next;
        free(Temp_Rem->name);
        free(Temp_Rem);
    }
    *head = ((void *)0);
}

variable_types: struct remote { unsigned char *name; unsigned long carrier_freq; unsigned int bit_time; struct command { unsigned char *name; struct pattern { unsigned int bit_length; unsigned int length; char r_flag; unsigned char *bytes; struct pattern *next; } *pattern; struct command *next; } *command; struct remote *next; } **


DumpRemotes

decompiled_code:
int __fastcall DumpRemotes(__int64 a1)
{
__int64 v1; // r12
__int64 i; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
printf("RemoteName: %s\n", *(const char **)v1);
for ( i = *(_QWORD *)(v1 + 24); i; i = *(_QWORD *)(i + 16) )
printf("CmdKey: %s\n", *(const char **)i);
result = putchar(10);
v1 = *(_QWORD *)(v1 + 32);
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func17(__int64 a1)
{
__int64 v1; // r12
__int64 i; // rbx
int result; // eax

if ( a1 )
{
v1 = a1;
do
{
printf("RemoteName: %s\n", *(const char **)v1);
for ( i = *(_QWORD *)(v1 + 24); i; i = *(_QWORD *)(i + 16) )
printf("CmdKey: %s\n", *(const char **)i);
result = putchar(10);
v1 = *(_QWORD *)(v1 + 32);
}
while ( v1 );
}
return result;
}

original_code:
void DumpRemotes(remote *head) {
    command *chead = ((void *)0);
    while (head) {
        printf("RemoteName: %s\n", head->name);
        chead = head->command;
        while (chead) {
            printf("CmdKey: %s\n", chead->name);
            chead=chead->next;
        }
        printf("\n");
        head = head->next;
    }
}

canonical_original_code:
void DumpRemotes(struct remote *head) {
    struct command *chead = ((void *)0);
    while (head) {
        printf("RemoteName: %s\n", head->name);
        chead = head->command;
        while (chead) {
            printf("CmdKey: %s\n", chead->name);
            chead=chead->next;
        }
        printf("\n");
        head = head->next;
    }
}


MacroTune

decompiled_code:
double __fastcall MacroTune(double a1, __int64 a2, unsigned int a3)
{
double v3; // xmm0_8
double v4; // xmm0_8
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s TUNE %s %d", "/opt/sagetv/server/gentuner", loadedDevName, a3);
v3 = log(a1);
v4 = log(v3);
system(savedregs);
return log(v4);
}

canonical_decompiled_code:
double __fastcall func19(double a1, __int64 a2, unsigned int a3)
{
double v3; // xmm0_8
double v4; // xmm0_8
_BYTE savedregs[1048]; // [rsp+0h] [rbp+0h] BYREF

snprintf(savedregs, 0x400uLL, "%s TUNE %s %d", "/opt/sagetv/server/gentuner", loadedDevName, a3);
v3 = func0(a1);
v4 = func0(v3);
system(savedregs);
return func0(v4);
}

original_code:
void MacroTune(int devHandle, int channel) {
    char cmd[1024];
    snprintf(cmd, sizeof(cmd), "%s TUNE %s %d", "/opt/sagetv/server/gentuner", loadedDevName, channel);
    _log(7, "MacroTune: Using command: %s", cmd);;
    _log(6, "MacroTune: Remote: %s, Channel: %d", loadedDevName, channel);;
    if ( system(cmd) != 0 ) {
        _log(3, "MacroTune: Failed to execute TUNE command: %s", cmd);;
    } else {
        _log(7, "MacroTune: Executed TUNE command without error: %s", cmd);;
    }
}

variable_types: channel int


SetRemoteName

decompiled_code:
char *__fastcall SetRemoteName(char *src)
{
return strncpy(loadedDevName, src, 0x100uLL);
}

canonical_decompiled_code:
char *__fastcall func20(char *src)
{
return strncpy(loadedDevName, src, 0x100uLL);
}

original_code:
void SetRemoteName(char *name) {
    strncpy(loadedDevName, name, sizeof(loadedDevName));
}

variable_types:
name
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx

puts("Test Generic Tuner Plugin");
puts("Open Device");
OpenDevice(1LL, argv);
puts("Creating Test Remote");
v3 = (void *)CreateRemote("testremote");
SetRemoteName("testremote");
if ( (unsigned int)CanMacroTune() )
{
puts("Test Macro Tune");
MacroTune(1LL, 256LL);
}
puts("Playing Command");
PlayCommand(1LL, v3, "ENTER", 1LL);
puts("Freeing Test Remote");
free(v3);
puts("Close Device");
CloseDevice(1LL);
return 0;
}

original_code:
int main(int argc, char *argv[]) {
    printf("Test Generic Tuner Plugin\n");
    printf("Open Device\n");
    OpenDevice(1);
    printf("Creating Test Remote\n");
    remote *rem = CreateRemote((unsigned char *)"testremote");
    SetRemoteName("testremote");
    if (CanMacroTune()) {
        printf("Test Macro Tune\n");
        MacroTune(1, 256);
    }
    printf("Playing Command\n");
    PlayCommand((unsigned int)1, rem, (unsigned char *)"ENTER", 1);
    printf("Freeing Test Remote\n");
    free(rem);
    printf("Close Device\n");
    CloseDevice(1);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
    printf("Test Generic Tuner Plugin\n");
    printf("Open Device\n");
    OpenDevice(1);
    printf("Creating Test Remote\n");
    struct remote *rem = CreateRemote((unsigned char *)"testremote");
    SetRemoteName("testremote");
    if (CanMacroTune()) {
        printf("Test Macro Tune\n");
        MacroTune(1, 256);
    }
    printf("Playing Command\n");
    PlayCommand((unsigned int)1, rem, (unsigned char *)"ENTER", 1);
    printf("Freeing Test Remote\n");
    free(rem);
    printf("Close Device\n");
    CloseDevice(1);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


repo: jwm-art-net/MDZ

decompiled_code:
void __fastcall set_last_used(char *s)
{
char *v1; // rbp
char *v2; // rbp
char *v3; // rax

if ( s )
{
v1 = last_used_dir;
if ( last_used_dir )
{
if ( !strcmp(last_used_dir, s) )
goto LABEL_4;
free(v1);
}
v3 = strdup(s);
last_used_dir = dirname(v3);
LABEL_4:
v2 = last_used_filename;
if ( last_used_filename )
{
if ( !strcmp(last_used_filename, s) )
return;
free(v2);
}
last_used_filename_path = strdup(s);
last_used_filename = _xpg_basename((char *)last_used_filename_path);
}
}

canonical_decompiled_code:
void __fastcall func0(char *s)
{
char *v1; // rbp
char *v2; // rbp
char *v3; // rax

if ( s )
{
v1 = last_used_dir;
if ( last_used_dir )
{
if ( !strcmp(last_used_dir, s) )
goto LABEL_4;
free(v1);
}
v3 = strdup(s);
last_used_dir = dirname(v3);
LABEL_4:
v2 = last_used_filename;
if ( last_used_filename )
{
if ( !strcmp(last_used_filename, s) )
return;
free(v2);
}
last_used_filename_path = strdup(s);
last_used_filename = _xpg_basename((char *)last_used_filename_path);
}
}

original_code:
static void set_last_used(const char* path)
{
    if (!path)
        return;
    if (last_used_dir && strcmp(last_used_dir, path) != 0) {
        free(last_used_dir);
        last_used_dir = 0;
    }
    if (!last_used_dir) {
        last_used_dir = strdup(path);
        last_used_dir = dirname(last_used_dir);
    }
    if (last_used_filename && strcmp(last_used_filename, path) != 0) {
        free(last_used_filename);
        last_used_filename = 0;
    }
    if (!last_used_filename) {
        last_used_filename_path = strdup(path);
        last_used_filename = __xpg_basename(last_used_filename_path);
    }
}

canonical_original_code:
static void set_last_used(char *path)
{
    if (!path)
        return;
    if (last_used_dir && strcmp(last_used_dir, path) != 0) {
        free(last_used_dir);
        last_used_dir = 0;
    }
    if (!last_used_dir) {
        last_used_dir = strdup(path);
        last_used_dir = dirname(last_used_dir);
    }
    if (last_used_filename && strcmp(last_used_filename, path) != 0) {
        free(last_used_filename);
        last_used_filename = 0;
    }
    if (!last_used_filename) {
        last_used_filename_path = strdup(path);
        last_used_filename = __xpg_basename(last_used_filename_path);
    }
}

variable_types:
path
char *


decompiled_code:
char *my_png_get_last_used_dir()
{
return last_used_dir;
}

canonical_decompiled_code:
char *func2()
{
return last_used_dir;
}

original_code:
const char* my_png_get_last_used_dir(void)
{
    return last_used_dir;
}


decompiled_code:
char *my_png_get_last_used_filename()
{
return last_used_filename;
}

canonical_decompiled_code:
char *func3()
{
return last_used_filename;
}

original_code:
const char* my_png_get_last_used_filename(void)
{
    return last_used_filename;
}


decompiled_code:
void my_png_reset_last_used_filename()
{
if ( last_used_filename_path )
{
free(last_used_filename_path);
last_used_filename_path = 0LL;
last_used_filename = 0LL;
}
}

canonical_decompiled_code:
void func5()
{
if ( last_used_filename_path )
{
free(last_used_filename_path);
last_used_filename_path = 0LL;
last_used_filename = 0LL;
}
}

original_code:
void my_png_reset_last_used_filename(void)
{
    if (last_used_filename_path) {
        free(last_used_filename_path);
        last_used_filename_path = 0;
        last_used_filename = 0;
    }
}

canonical_original_code:
void my_png_reset_last_used_filename()
{
    if (last_used_filename_path) {
        free(last_used_filename_path);
        last_used_filename_path = 0;
        last_used_filename = 0;
    }
}


decompiled_code:
void my_png_cleanup()
{
if ( last_used_dir )
{
free(last_used_dir);
last_used_dir = 0LL;
}
my_png_reset_last_used_filename();
}

canonical_decompiled_code:
void func6()
{
if ( last_used_dir )
{
free(last_used_dir);
last_used_dir = 0LL;
}
func5();
}

original_code:
void my_png_cleanup(void)
{
    if (last_used_dir) {
        free(last_used_dir);
        last_used_dir = 0;
    }
    my_png_reset_last_used_filename();
}

canonical_original_code:
void my_png_cleanup()
{
    if (last_used_dir) {
        free(last_used_dir);
        last_used_dir = 0;
    }
    my_png_reset_last_used_filename();
}


original_code:
void init_misc(void)
{
    if (!opts.width && !opts.height)
    {
        opts.width = img->user_width;
        if (opts.aspect)
            opts.height = img->user_width / opts.aspect;
        else
            opts.height = img->user_height;
    }
    else if (!opts.width)
    {
        if (opts.aspect)
            opts.width = opts.height * opts.aspect;
        else
            opts.width = opts.height * img->aspect;
    }
    else if (!opts.height)
    {
        if (opts.aspect)
            opts.height = opts.width / opts.aspect;
        else
            opts.height = opts.width / img->aspect;
    }
    if (!opts.antialias)
        opts.antialias = 1;
    if (!opts.threads)
    {
        if (!(opts.threads = cpu_count()))
            opts.threads = 2;
    }
    img->thread_count = opts.threads;
    image_info_set(img, opts.width, opts.height, opts.antialias);
    fun_palette.offset = 0;
    fun_palette.stripe = 1;
    fun_palette.spread = 1;
}

canonical_original_code:
void init_misc()
{
    if (!opts.width && !opts.height)
    {
        opts.width = img->user_width;
        if (opts.aspect)
            opts.height = img->user_width / opts.aspect;
        else
            opts.height = img->user_height;
    }
    else if (!opts.width)
    {
        if (opts.aspect)
            opts.width = opts.height * opts.aspect;
        else
            opts.width = opts.height * img->aspect;
    }
    else if (!opts.height)
    {
        if (opts.aspect)
            opts.height = opts.width / opts.aspect;
        else
            opts.height = opts.width / img->aspect;
    }
    if (!opts.antialias)
        opts.antialias = 1;
    if (!opts.threads)
    {
        if (!(opts.threads = cpu_count()))
            opts.threads = 2;
    }
    img->thread_count = opts.threads;
    image_info_set(img, opts.width, opts.height, opts.antialias);
    fun_palette.offset = 0;
    fun_palette.stripe = 1;
    fun_palette.spread = 1;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
unsigned int v4; // edi
__int64 v5; // rdi
const char *v6; // rbp
char *v8; // rax
const char **v9; // [rsp+0h] [rbp-28h] BYREF
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = argc;
v9 = argv;
program_name = (char *)*argv;
setting_init(argc, argv, envp);
v3 = process_args((unsigned int)argc, argv);
if ( v3 >= 0 )
{
v4 = time(0LL);
srand(v4);
rnd_palette = LC18;
*(&rnd_palette + 1) = LC18;
*(&rnd_palette + 2) = LC18;
*(&rnd_palette + 3) = LC19;
*(&rnd_palette + 4) = LC20;
*(&rnd_palette + 5) = LC21;
*((_DWORD *)&rnd_palette + 12) = 0;
*((_DWORD *)&rnd_palette + 13) = 1;
*((_DWORD *)&rnd_palette + 14) = 1;
if ( !(unsigned int)palette_init() )
palette_randomize(&rnd_palette);
v5 = image_info_create(0LL, 0LL);
img = v5;
*(_QWORD *)(v5 + 376) = &rnd_palette;
if ( *(&opts + 4) )
{
if ( !(unsigned int)image_info_load_all(v5, 3LL) )
{
perror("Failed to load dump file\n");
v3 = -1;
goto LABEL_13;
}
}
else if ( *(&opts + 1) && !(unsigned int)image_info_load_all(v5, 3LL) )
{
fprintf(stderr, "Failed to load %s\n", *(&opts + 1));
v3 = -1;
goto LABEL_13;
}
init_misc();
if ( *(&opts + 2) && !(unsigned int)palette_load() )
{
fprintf(stderr, "could not read palette file %s\n", *(&opts + 2));
v3 = -1;
}
else
{
v6 = opts;
if ( !opts )
goto LABEL_11;
if ( !strcmp("-", opts) )
{
*(&opts + 5) = (char *)stdout;
goto LABEL_11;
}
v8 = (char *)fopen(v6, "w");
*(&opts + 5) = v8;
if ( v8 )
{
LABEL_11:
if ( *(&opts + 9) )
render_to_file(img);
else
gui_init(v10, &v9, img);
goto LABEL_13;
}
fprintf(stderr, "could not open logfile %s for writing\n", opts);
v3 = -1;
}
LABEL_13:
image_info_destroy(img);
image_info_cleanup();
palette_free();
my_png_cleanup();
}
cleanup_opts();
return v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
unsigned int v4; // edi
__int64 v5; // rdi
const char *v6; // rbp
char *v8; // rax
const char **v9; // [rsp+0h] [rbp-28h] BYREF
int v10[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v10[0] = argc;
v9 = argv;
program_name = (char *)*argv;
setting_init(argc, argv, envp);
v3 = process_args((unsigned int)argc, argv);
if ( v3 >= 0 )
{
v4 = time(0LL);
srand(v4);
rnd_palette = LC18;
*(&rnd_palette + 1) = LC18;
*(&rnd_palette + 2) = LC18;
*(&rnd_palette + 3) = LC19;
*(&rnd_palette + 4) = LC20;
*(&rnd_palette + 5) = LC21;
*((_DWORD *)&rnd_palette + 12) = 0;
*((_DWORD *)&rnd_palette + 13) = 1;
*((_DWORD *)&rnd_palette + 14) = 1;
if ( !(unsigned int)palette_init() )
palette_randomize(&rnd_palette);
v5 = image_info_create(0LL, 0LL);
img = v5;
*(_QWORD *)(v5 + 376) = &rnd_palette;
if ( *(&opts + 4) )
{
if ( !(unsigned int)image_info_load_all(v5, 3LL) )
{
perror("Failed to load dump file\n");
v3 = -1;
goto LABEL_13;
}
}
else if ( *(&opts + 1) && !(unsigned int)image_info_load_all(v5, 3LL) )
{
fprintf(stderr, "Failed to load %s\n", *(&opts + 1));
v3 = -1;
goto LABEL_13;
}
func2();
if ( *(&opts + 2) && !(unsigned int)palette_load() )
{
fprintf(stderr, "could not read palette file %s\n", *(&opts + 2));
v3 = -1;
}
else
{
v6 = opts;
if ( !opts )
goto LABEL_11;
if ( !strcmp("-", opts) )
{
*(&opts + 5) = (char *)stdout;
goto LABEL_11;
}
v8 = (char *)fopen(v6, "w");
*(&opts + 5) = v8;
if ( v8 )
{
LABEL_11:
if ( *(&opts + 9) )
render_to_file(img);
else
gui_init(v10, &v9, img);
goto LABEL_13;
}
fprintf(stderr, "could not open logfile %s for writing\n", opts);
v3 = -1;
}
LABEL_13:
image_info_destroy(img);
image_info_cleanup();
palette_free();
my_png_cleanup();
}
cleanup_opts();
return v3;
}

original_code:
int main(int argc, char** argv)
{
    program_name = argv[0];
    setting_init();
    int ret = process_args(argc, argv);
    if (ret < 0)
        goto quit2;
    srand(time(0));
    rnd_palette.r_strength = 1.0;
    rnd_palette.g_strength = 1.0;
    rnd_palette.b_strength = 1.0;
    rnd_palette.r_bands = 0.05;
    rnd_palette.g_bands = 0.08;
    rnd_palette.b_bands = 0.2;
    rnd_palette.offset = 0.0;
    rnd_palette.stripe = 1.0;
    rnd_palette.spread = 1.0;
    if (!palette_init())
        palette_randomize(&rnd_palette);
    img = image_info_create(FAMILY_MANDEL, MANDELBROT);
    img->rnd_pal = &rnd_palette;
    if (opts.dumpfile)
    {
        if (!image_info_load_all(img,
                                MDZ_FRACTAL_SETTINGS | MDZ_PALETTE_DATA,
                                opts.dumpfile))
        {
            perror("Failed to load dump file\n");
            ret = -1;
            goto quit1;
        }
        if (0 && remove(opts.dumpfile) == -1)
        {
            perror("Can't delete temp file");
        }
    }
    else if (opts.settingsfile)
    {
        if (!image_info_load_all(img,
                                MDZ_FRACTAL_SETTINGS | MDZ_PALETTE_DATA,
                                opts.settingsfile))
        {
            fprintf(stderr, "Failed to load %s\n", opts.settingsfile);
            ret = -1;
            goto quit1;
        }
    }
    init_misc();
    if (opts.palettefile)
    {
        if (!palette_load(opts.palettefile))
        {
            fprintf(stderr, "could not read palette file %s\n",
                            opts.palettefile);
            ret = -1;
            goto quit1;
        }
    }
    if (opts.logfile)
    {
        if (strcmp("-", opts.logfile) == 0)
            opts.logfd = stdout;
        else if (!(opts.logfd = fopen(opts.logfile, "w")))
        {
            fprintf(stderr, "could not open logfile %s for writing\n",
                            opts.logfile);
            ret = -1;
            goto quit1;
        }
    }
    if (opts.renderfile)
        render_to_file(img);
    else
        gui_init(&argc, &argv, img);
quit1:
    image_info_destroy(img);
    image_info_cleanup();
    palette_free();
    my_png_cleanup();
quit2:
    cleanup_opts();
    return ret;
}

canonical_original_code:
int main(int argc, char **argv)
{
    program_name = argv[0];
    setting_init();
    int ret = process_args(argc, argv);
    if (ret < 0)
        goto quit2;
    srand(time(0));
    rnd_palette.r_strength = 1.0;
    rnd_palette.g_strength = 1.0;
    rnd_palette.b_strength = 1.0;
    rnd_palette.r_bands = 0.05;
    rnd_palette.g_bands = 0.08;
    rnd_palette.b_bands = 0.2;
    rnd_palette.offset = 0.0;
    rnd_palette.stripe = 1.0;
    rnd_palette.spread = 1.0;
    if (!palette_init())
        palette_randomize(&rnd_palette);
    img = image_info_create(FAMILY_MANDEL, MANDELBROT);
    img->rnd_pal = &rnd_palette;
    if (opts.dumpfile)
    {
        if (!image_info_load_all(img,
                                MDZ_FRACTAL_SETTINGS | MDZ_PALETTE_DATA,
                                opts.dumpfile))
        {
            perror("Failed to load dump file\n");
            ret = -1;
            goto quit1;
        }
        if (0 && remove(opts.dumpfile) == -1)
        {
            perror("Can't delete temp file");
        }
    }
    else if (opts.settingsfile)
    {
        if (!image_info_load_all(img,
                                MDZ_FRACTAL_SETTINGS | MDZ_PALETTE_DATA,
                                opts.settingsfile))
        {
            fprintf(stderr, "Failed to load %s\n", opts.settingsfile);
            ret = -1;
            goto quit1;
        }
    }
    init_misc();
    if (opts.palettefile)
    {
        if (!palette_load(opts.palettefile))
        {
            fprintf(stderr, "could not read palette file %s\n",
                            opts.palettefile);
            ret = -1;
            goto quit1;
        }
    }
    if (opts.logfile)
    {
        if (strcmp("-", opts.logfile) == 0)
            opts.logfd = stdout;
        else if (!(opts.logfd = fopen(opts.logfile, "w")))
        {
            fprintf(stderr, "could not open logfile %s for writing\n",
                            opts.logfile);
            ret = -1;
            goto quit1;
        }
    }
    if (opts.renderfile)
        render_to_file(img);
    else
        gui_init(&argc, &argv, img);
quit1:
    image_info_destroy(img);
    image_info_cleanup();
    palette_free();
    my_png_cleanup();
quit2:
    cleanup_opts();
    return ret;
}

variable_types:
argv
char **

variable_types: ret int


decompiled_code:
__int64 __fastcall zoom_resize(int a1)
{
int v1; // eax
__int64 result; // rax

v1 = *((_DWORD *)&stat + 4) + 4 * a1;
*((_DWORD *)&stat + 4) = v1;
result = (unsigned int)(int)((double)v1 / *(double *)(img + 400LL));
*((_DWORD *)&stat + 5) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
int v1; // eax
__int64 result; // rax

v1 = *((_DWORD *)&stat + 4) + 4 * a1;
*((_DWORD *)&stat + 4) = v1;
result = (unsigned int)(int)((double)v1 / *(double *)(img + 400LL));
*((_DWORD *)&stat + 5) = result;
return result;
}

original_code:
void zoom_resize(int arg)
{
    stat.z_width += arg * 4;
    stat.z_height = stat.z_width / img->aspect;
}

variable_types: arg int


decompiled_code:
_BOOL8 zoom_is_valid_size()
{
int v0; // edx
_BOOL8 result; // rax
int v2; // edx

v0 = *((_DWORD *)&stat + 4);
result = 0LL;
if ( v0 > 3 )
{
result = 0LL;
if ( v0 < *(_DWORD *)(img + 392LL) - 15 )
{
v2 = *((_DWORD *)&stat + 5);
if ( v2 > 3 )
result = v2 < *(_DWORD *)(img + 396LL) - 15;
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 func1()
{
int v0; // edx
_BOOL8 result; // rax
int v2; // edx

v0 = *((_DWORD *)&stat + 4);
result = 0LL;
if ( v0 > 3 )
{
result = 0LL;
if ( v0 < *(_DWORD *)(img + 392LL) - 15 )
{
v2 = *((_DWORD *)&stat + 5);
if ( v2 > 3 )
result = v2 < *(_DWORD *)(img + 396LL) - 15;
}
}
return result;
}

original_code:
int zoom_is_valid_size(void)
{
    if ((stat.z_width < 4) || (stat.z_width > (img->user_width - 16))
    || (stat.z_height < 4) || (stat.z_height > (img->user_height - 16)))
        return (0);
    else
        return (!(0));
}

canonical_original_code:
int zoom_is_valid_size()
{
    if ((stat.z_width < 4) || (stat.z_width > (img->user_width - 16))
    || (stat.z_height < 4) || (stat.z_height > (img->user_height - 16)))
        return (0);
    else
        return (!(0));
}


decompiled_code:
__int64 __fastcall zoom_gui_sensitive_zoom_in_button(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_in_button, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_in_button, a1);
}

original_code:
void zoom_gui_sensitive_zoom_in_button(gboolean t)
    { gtk_widget_set_sensitive(zoom_in_button, t); }

canonical_original_code:
void zoom_gui_sensitive_zoom_in_button(int t)
    { gtk_widget_set_sensitive(zoom_in_button, t); }

variable_types: t int


decompiled_code:
__int64 start_zoom_1click()
{
LODWORD(stat) = 3;
*((_DWORD *)&stat + 4) = 16;
*((_DWORD *)&stat + 5) = (int)(16.0 / *(double *)(img + 400LL));
HIDWORD(stat) = 0;
zoom_gui_sensitive_zoom_in_button(0);
gui_sensitive_switch_menu(0LL);
return repos_gui_sensitive_reposition_button(0LL);
}

canonical_decompiled_code:
__int64 func4()
{
LODWORD(stat) = 3;
*((_DWORD *)&stat + 4) = 16;
*((_DWORD *)&stat + 5) = (int)(16.0 / *(double *)(img + 400LL));
HIDWORD(stat) = 0;
func3(0);
gui_sensitive_switch_menu(0LL);
return repos_gui_sensitive_reposition_button(0LL);
}

original_code:
void start_zoom_1click(void)
{
    stat.action = STAT_ZOOMING_1CLICK;
    stat.z_width = 16;
    stat.z_height = stat.z_width / img->aspect;
    stat.reposition_p2 = (0);
    zoom_gui_sensitive_zoom_in_button((0));
    gui_sensitive_switch_menu((0));
    repos_gui_sensitive_reposition_button((0));
}

canonical_original_code:
void start_zoom_1click()
{
    stat.action = STAT_ZOOMING_1CLICK;
    stat.z_width = 16;
    stat.z_height = stat.z_width / img->aspect;
    stat.reposition_p2 = (0);
    zoom_gui_sensitive_zoom_in_button((0));
    gui_sensitive_switch_menu((0));
    repos_gui_sensitive_reposition_button((0));
}


decompiled_code:
__int64 __fastcall zoom_gui_sensitive_zoom_out_button(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_out_button, a1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_out_button, a1);
}

original_code:
void zoom_gui_sensitive_zoom_out_button(gboolean t)
    { gtk_widget_set_sensitive(zoom_out_button, t); }

canonical_original_code:
void zoom_gui_sensitive_zoom_out_button(int t)
    { gtk_widget_set_sensitive(zoom_out_button, t); }


decompiled_code:
__int64 __fastcall zoom_gui_sensitive_zoom_in_1click_button(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_in_1click_button, a1);
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1)
{
return gtk_widget_set_sensitive(zoom_in_1click_button, a1);
}

original_code:
void zoom_gui_sensitive_zoom_in_1click_button(gboolean t)
    { gtk_widget_set_sensitive(zoom_in_1click_button, t); }

canonical_original_code:
void zoom_gui_sensitive_zoom_in_1click_button(int t)
    { gtk_widget_set_sensitive(zoom_in_1click_button, t); }


decompiled_code:
__int64 start_zooming()
{
__int64 v0; // rax
int v1; // edx

LODWORD(stat) = 2;
*((_DWORD *)&stat + 2) = 0;
*((_DWORD *)&stat + 3) = 0;
v0 = img;
v1 = (int)((double)*(int *)(img + 392LL) * 0.35);
*((_DWORD *)&stat + 4) = v1;
*((_DWORD *)&stat + 5) = (int)((double)v1 / *(double *)(v0 + 400));
zoom_gui_sensitive_zoom_in_1click_button(0);
gui_sensitive_switch_menu(0LL);
repos_gui_sensitive_reposition_button(0LL);
return gdk_gc_set_line_attributes(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 1LL, 0LL, 1LL, 0LL);
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rax
int v1; // edx

LODWORD(stat) = 2;
*((_DWORD *)&stat + 2) = 0;
*((_DWORD *)&stat + 3) = 0;
v0 = img;
v1 = (int)((double)*(int *)(img + 392LL) * 0.35);
*((_DWORD *)&stat + 4) = v1;
*((_DWORD *)&stat + 5) = (int)((double)v1 / *(double *)(v0 + 400));
func8(0);
gui_sensitive_switch_menu(0LL);
repos_gui_sensitive_reposition_button(0LL);
return gdk_gc_set_line_attributes(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 1LL, 0LL, 1LL, 0LL);
}

original_code:
void start_zooming(void)
{
    stat.action = STAT_ZOOMING;
    stat.z_x = 0;
    stat.z_y = 0;
    stat.z_width = .35 * img->user_width;
    stat.z_height = stat.z_width / img->aspect;
    zoom_gui_sensitive_zoom_in_1click_button((0));
    gui_sensitive_switch_menu((0));
    repos_gui_sensitive_reposition_button((0));
    gdk_gc_set_line_attributes(drawing_area->style->white_gc,
            1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
}

canonical_original_code:
void start_zooming()
{
    stat.action = STAT_ZOOMING;
    stat.z_x = 0;
    stat.z_y = 0;
    stat.z_width = .35 * img->user_width;
    stat.z_height = stat.z_width / img->aspect;
    zoom_gui_sensitive_zoom_in_1click_button((0));
    gui_sensitive_switch_menu((0));
    repos_gui_sensitive_reposition_button((0));
    gdk_gc_set_line_attributes(drawing_area->style->white_gc,
            1, GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
}


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

if ( *((_DWORD *)&stat + 6) != -1 )
result = g_source_remove();
*((_DWORD *)&stat + 6) = -1;
return result;
}

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

if ( *((_DWORD *)&stat + 6) != -1 )
result = g_source_remove();
*((_DWORD *)&stat + 6) = -1;
return result;
}

original_code:
void zoom_gui_kill_timers(void)
{
    if (stat.zoom_timer_id != -1)
        g_source_remove(stat.zoom_timer_id);
    stat.zoom_timer_id = -1;
}

canonical_original_code:
void zoom_gui_kill_timers()
{
    if (stat.zoom_timer_id != -1)
        g_source_remove(stat.zoom_timer_id);
    stat.zoom_timer_id = -1;
}


decompiled_code:
__int64 stop_zooming()
{
LODWORD(stat) = 0;
zoom_gui_kill_timers();
zoom_gui_sensitive_zoom_in_1click_button(1u);
gui_sensitive_switch_menu(1LL);
return repos_gui_sensitive_reposition_button(1LL);
}

canonical_decompiled_code:
__int64 func12()
{
LODWORD(stat) = 0;
func11();
func8(1u);
gui_sensitive_switch_menu(1LL);
return repos_gui_sensitive_reposition_button(1LL);
}

original_code:
void stop_zooming(void)
{
    stat.action = STAT_NORMAL;
    zoom_gui_kill_timers();
    zoom_gui_sensitive_zoom_in_1click_button((!(0)));
    gui_sensitive_switch_menu((!(0)));
    repos_gui_sensitive_reposition_button((!(0)));
}

canonical_original_code:
void stop_zooming()
{
    stat.action = STAT_NORMAL;
    zoom_gui_kill_timers();
    zoom_gui_sensitive_zoom_in_1click_button((!(0)));
    gui_sensitive_switch_menu((!(0)));
    repos_gui_sensitive_reposition_button((!(0)));
}


decompiled_code:
__int64 zoom_gui_draw_zoom_box()
{
gdk_gc_set_function(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 2LL);
gdk_draw_rectangle(
*(_QWORD *)(drawing_area + 80LL),
*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL),
0LL,
(unsigned int)(*((_DWORD *)&stat + 2) - (*((int *)&stat + 4) >> 1)),
(unsigned int)(*((_DWORD *)&stat + 3) - (*((int *)&stat + 5) >> 1)));
return gdk_gc_set_function(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 0LL);
}

canonical_decompiled_code:
__int64 func14()
{
gdk_gc_set_function(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 2LL);
gdk_draw_rectangle(
*(_QWORD *)(drawing_area + 80LL),
*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL),
0LL,
(unsigned int)(*((_DWORD *)&stat + 2) - (*((int *)&stat + 4) >> 1)),
(unsigned int)(*((_DWORD *)&stat + 3) - (*((int *)&stat + 5) >> 1)));
return gdk_gc_set_function(*(_QWORD *)(*(_QWORD *)(drawing_area + 48LL) + 872LL), 0LL);
}

original_code:
void zoom_gui_draw_zoom_box(void)
{
    gdk_gc_set_function(drawing_area->style->white_gc, GDK_XOR);
    gdk_draw_rectangle(
        drawing_area->window, drawing_area->style->white_gc,
        (0), stat.z_x - (stat.z_width >> 1),
                stat.z_y - (stat.z_height >> 1),
                stat.z_width, stat.z_height);
    gdk_gc_set_function(drawing_area->style->white_gc, GDK_COPY);
}

canonical_original_code:
void zoom_gui_draw_zoom_box()
{
    gdk_gc_set_function(drawing_area->style->white_gc, GDK_XOR);
    gdk_draw_rectangle(
        drawing_area->window, drawing_area->style->white_gc,
        (0), stat.z_x - (stat.z_width >> 1),
                stat.z_y - (stat.z_height >> 1),
                stat.z_width, stat.z_height);
    gdk_gc_set_function(drawing_area->style->white_gc, GDK_COPY);
}


decompiled_code:
__int64 __fastcall zoom_callback(int a1)
{
zoom_gui_draw_zoom_box();
zoom_resize(a1);
if ( !zoom_is_valid_size() )
zoom_resize(-a1);
zoom_gui_draw_zoom_box();
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(int a1)
{
func14();
func0(a1);
if ( !func1() )
func0(-a1);
func14();
return 1LL;
}

original_code:
gint zoom_callback(int arg)
{
    zoom_gui_draw_zoom_box();
    zoom_resize(arg);
    if (!zoom_is_valid_size())
        zoom_resize(-1*arg);
    zoom_gui_draw_zoom_box();
    return (!(0));
}