decompiled_code:
__int64 __fastcall zoom_gui_process_zooming_click(int a1)
{
zoom_gui_draw_zoom_box();
switch ( a1 )
{
case 1:
zoom_resize(1);
if ( zoom_is_valid_size() )
*((_DWORD *)&stat + 6) = g_timeout_add(25LL, zoom_callback, 2LL);
else
zoom_resize(-1);
break;
case 2:
zoom_in();
break;
case 3:
zoom_resize(-1);
if ( zoom_is_valid_size() )
*((_DWORD *)&stat + 6) = g_timeout_add(25LL, zoom_callback, -2LL);
else
zoom_resize(1);
break;
}
return zoom_gui_draw_zoom_box();
}

canonical_decompiled_code:
__int64 __fastcall func17(int a1)
{
func14();
switch ( a1 )
{
case 1:
func0(1);
if ( func1() )
*((_DWORD *)&stat + 6) = g_timeout_add(25LL, zoom_callback, 2LL);
else
func0(-1);
break;
case 2:
func15();
break;
case 3:
func0(-1);
if ( func1() )
*((_DWORD *)&stat + 6) = g_timeout_add(25LL, zoom_callback, -2LL);
else
func0(1);
break;
}
return func14();
}

original_code:
void zoom_gui_process_zooming_click(int button)
{
    zoom_gui_draw_zoom_box();
    if (button == 1)
    {
        zoom_resize(1);
        if (!zoom_is_valid_size())
            zoom_resize(-1);
        else
            stat.zoom_timer_id = g_timeout_add(25,
                                       (GtkFunction)zoom_callback,
                                       (gpointer)2);
    }
    else if (button == 2)
        zoom_in();
    else if (button == 3)
    {
        zoom_resize(-1);
        if (!zoom_is_valid_size())
            zoom_resize(1);
        else
            stat.zoom_timer_id = g_timeout_add(25,
                                       (GtkFunction)zoom_callback,
                                       (gpointer)-2);
    }
    zoom_gui_draw_zoom_box();
}

canonical_original_code:
void zoom_gui_process_zooming_click(int button)
{
    zoom_gui_draw_zoom_box();
    if (button == 1)
    {
        zoom_resize(1);
        if (!zoom_is_valid_size())
            zoom_resize(-1);
        else
            stat.zoom_timer_id = g_timeout_add(25,
                                       (int (*)(void *data))zoom_callback,
                                       (void *)2);
    }
    else if (button == 2)
        zoom_in();
    else if (button == 3)
    {
        zoom_resize(-1);
        if (!zoom_is_valid_size())
            zoom_resize(1);
        else
            stat.zoom_timer_id = g_timeout_add(25,
                                       (int (*)(void *data))zoom_callback,
                                       (gpointer)-2);
    }
    zoom_gui_draw_zoom_box();
}

variable_types: button int


repo: jwm-art-net/MDZ

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

if ( !*(_BYTE *)(img + 497LL) )
zoom_gui_draw_zoom_box();
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 1 )
return zoom_in();
if ( a1 == 3 )
result = stop_zoom_1click();
return result;
}

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

if ( !*(_BYTE *)(img + 497LL) )
func14();
result = (unsigned int)(a1 - 1);
if ( (unsigned int)result <= 1 )
return func15();
if ( a1 == 3 )
result = func5();
return result;
}

original_code:
void zoom_gui_process_zooming_1click_click(int button)
{
    if (!img->zoom_new_win)
        zoom_gui_draw_zoom_box();
    if (button == 1 || button == 2)
        zoom_in();
    else if (button == 3)
        stop_zoom_1click();
}

return_type: void


decompiled_code:
__int64 __fastcall frac_variant(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // rt1
long double v18; // fst3
long double v19; // fst6
long double v20; // rt0
long double v21; // fst3
long double v22; // fst7
long double v23; // fst3
long double v24; // rt1
long double v25; // fst3

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v20 = a6;
v21 = a2 * (a3 + a3);
v22 = v20;
v23 = v21 + a4;
if ( (result & 1) != 0 )
{
v24 = v23;
v25 = v22;
a2 = v24;
v19 = fabs(a7 - v25) + a5;
}
else
{
v17 = v23;
v18 = v22;
a2 = v17;
v19 = a7 - v18 + a5;
}
a6 = a2 * a2;
if ( a2 * a2 + v19 * v19 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
a3 = v19;
a7 = v19 * v19;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // rt1
long double v18; // fst3
long double v19; // fst6
long double v20; // rt0
long double v21; // fst3
long double v22; // fst7
long double v23; // fst3
long double v24; // rt1
long double v25; // fst3

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v20 = a6;
v21 = a2 * (a3 + a3);
v22 = v20;
v23 = v21 + a4;
if ( (result & 1) != 0 )
{
v24 = v23;
v25 = v22;
a2 = v24;
v19 = fabs(a7 - v25) + a5;
}
else
{
v17 = v23;
v18 = v22;
a2 = v17;
v19 = a7 - v18 + a5;
}
a6 = a2 * a2;
if ( a2 * a2 + v19 * v19 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
a3 = v19;
a7 = v19 * v19;
}
return result;
}

original_code:
depth_t frac_variant( depth_t depth,
                                long double wim, long double wre,
                                long double c_im, long double c_re,
                                long double wim2, long double wre2 )
{
    depth_t wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        if (wz % 2)
            wre = fabsl(wre2 - wim2) + c_re;
        else
            wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_variant(long depth, long double wim, long double wre, long double c_im, long double c_re, long double wim2, long double wre2)
{
    long wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        if (wz % 2)
            wre = fabsl(wre2 - wim2) + c_re;
        else
            wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

variable_types: depth long

variable_types:
wim
long double

variable_types:
wre
long double

variable_types: wz long

return_type: long


decompiled_code:
__int64 __fastcall frac_variant_mpfr(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r13

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
if ( (v11 & 1) != 0 )
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r13

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
if ( (v11 & 1) != 0 )
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_variant_mpfr(
                                depth_t depth,
                                mpfr_t bail,
                                mpfr_t wim, mpfr_t wre,
                                mpfr_t c_im, mpfr_t c_re,
                                mpfr_t wim2, mpfr_t wre2, mpfr_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        if (wz % 2)
            mpfr_set4(t1,t1,MPFR_RNDN,1);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_variant_mpfr(long depth, struct __mpfr_struct bail[1], struct __mpfr_struct wim[1], struct __mpfr_struct wre[1], struct __mpfr_struct c_im[1], struct __mpfr_struct c_re[1], struct __mpfr_struct wim2[1], struct __mpfr_struct wre2[1], struct __mpfr_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        if (wz % 2)
            mpfr_set4(t1,t1,MPFR_RNDN,1);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

variable_types: struct __mpfr_struct { long _mpfr_prec; int _mpfr_sign; long _mpfr_exp; unsigned long *_mpfr_d; } [1]

variable_types:
wim
struct __mpfr_struct [1]

variable_types:
wre
struct __mpfr_struct [1]


original_code:
depth_t frac_variant_gmp(
                                depth_t depth,
                                mpf_t bail,
                                mpf_t wim, mpf_t wre,
                                mpf_t c_im, mpf_t c_re,
                                mpf_t wim2, mpf_t wre2, mpf_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        if (wz % 2)
            __gmpf_abs(t1, t1);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_variant_gmp(long depth, struct __mpf_struct bail[1], struct __mpf_struct wim[1], struct __mpf_struct wre[1], struct __mpf_struct c_im[1], struct __mpf_struct c_re[1], struct __mpf_struct wim2[1], struct __mpf_struct wre2[1], struct __mpf_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        if (wz % 2)
            __gmpf_abs(t1, t1);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } [1]

variable_types:
wim
struct __mpf_struct [1]

variable_types:
wre
struct __mpf_struct [1]


decompiled_code:
int __fastcall show_usage(const char *a1)
{
printf("usage: %s [options]\n", a1);
puts("options:");
puts(" -l, --load-settings [FILE] saved settings file to load");
puts(" -P, --load-palette [FILE] .map palette file to load");
puts(" -p, --random-palette generate a random palette");
puts(" -L, --log-file [FILE] log settings to file");
puts(" -w, --width [n] set image width to n");
puts(" -h, --height [n] set image height to n");
puts(" -a --aspect [n.nnn] set aspect ration to n.nnn");
puts(" -R, --render [FILE] just render an image to file");
puts(" -A, --anti-alias [n] set anti-aliasing factor to n");
puts(" -t, --threads [n] set number of threads to n.");
puts(" -V, --version show version.");
putchar(10);
puts(
"NOTE: Not all combinations of width, height, aspect ratio, and\n"
" settings file make sense. The settings files only store\n"
" the aspect ratio of an image, not it's dimensions.\n"
" Author may have forgotten to update version number.");
putchar(10);
puts("mdz Mandelbrot Deep Zoom");
puts("(c) James W. Morris 2009-2010 http://jwm-art.net/mdz/");
return puts("This software is licensed using the GNU GPLv3\n");
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
printf("usage: %s [options]\n", a1);
puts("options:");
puts(" -l, --load-settings [FILE] saved settings file to load");
puts(" -P, --load-palette [FILE] .map palette file to load");
puts(" -p, --random-palette generate a random palette");
puts(" -L, --log-file [FILE] log settings to file");
puts(" -w, --width [n] set image width to n");
puts(" -h, --height [n] set image height to n");
puts(" -a --aspect [n.nnn] set aspect ration to n.nnn");
puts(" -R, --render [FILE] just render an image to file");
puts(" -A, --anti-alias [n] set anti-aliasing factor to n");
puts(" -t, --threads [n] set number of threads to n.");
puts(" -V, --version show version.");
putchar(10);
puts(
"NOTE: Not all combinations of width, height, aspect ratio, and\n"
" settings file make sense. The settings files only store\n"
" the aspect ratio of an image, not it's dimensions.\n"
" Author may have forgotten to update version number.");
putchar(10);
puts("mdz Mandelbrot Deep Zoom");
puts("(c) James W. Morris 2009-2010 http://jwm-art.net/mdz/");
return puts("This software is licensed using the GNU GPLv3\n");
}

original_code:
void show_usage(char* argvzero)
{
    printf("usage:  %s [options]\n", argvzero);
    printf("options:\n");
    printf("    -l, --load-settings [FILE]  saved settings file to load\n");
    printf("    -P, --load-palette [FILE]   .map palette file to load\n");
    printf("    -p, --random-palette        generate a random palette\n");
    printf("    -L, --log-file [FILE]       log settings to file\n");
    printf("    -w, --width [n]             set image width to n\n");
    printf("    -h, --height [n]            set image height to n\n");
    printf("    -a  --aspect [n.nnn]        set aspect ration to n.nnn\n");
    printf("    -R, --render [FILE]         just render an image to file\n");
    printf("    -A, --anti-alias [n]        set anti-aliasing factor to n\n");
    printf("    -t, --threads [n]           set number of threads to n.\n");
    printf("    -V, --version               show version.\n");
    printf("\n");
    printf("NOTE: Not all combinations of width, height, aspect ratio, and\n"
           "      settings file make sense. The settings files only store\n"
           "      the aspect ratio of an image, not it's dimensions.\n"
           "      Author may have forgotten to update version number.\n");
    printf("\n");
    printf("mdz Mandelbrot Deep Zoom\n");
    printf("(c) James W. Morris 2009-2010 http://jwm-art.net/mdz/\n");
    printf("This software is licensed using the GNU GPLv3\n\n");
}

canonical_original_code:
void show_usage(char *argvzero)
{
    printf("usage:  %s [options]\n", argvzero);
    printf("options:\n");
    printf("    -l, --load-settings [FILE]  saved settings file to load\n");
    printf("    -P, --load-palette [FILE]   .map palette file to load\n");
    printf("    -p, --random-palette        generate a random palette\n");
    printf("    -L, --log-file [FILE]       log settings to file\n");
    printf("    -w, --width [n]             set image width to n\n");
    printf("    -h, --height [n]            set image height to n\n");
    printf("    -a  --aspect [n.nnn]        set aspect ration to n.nnn\n");
    printf("    -R, --render [FILE]         just render an image to file\n");
    printf("    -A, --anti-alias [n]        set anti-aliasing factor to n\n");
    printf("    -t, --threads [n]           set number of threads to n.\n");
    printf("    -V, --version               show version.\n");
    printf("\n");
    printf("NOTE: Not all combinations of width, height, aspect ratio, and\n"
           "      settings file make sense. The settings files only store\n"
           "      the aspect ratio of an image, not it's dimensions.\n"
           "      Author may have forgotten to update version number.\n");
    printf("\n");
    printf("mdz Mandelbrot Deep Zoom\n");
    printf("(c) James W. Morris 2009-2010 http://jwm-art.net/mdz/\n");
    printf("This software is licensed using the GNU GPLv3\n\n");
}

variable_types:
argvzero
char *


oom

decompiled_code:
__int64 __fastcall oom(const char *a1, const char *a2)
{
fprintf(stderr, "out of memory processing %s=%s\naborting command line processing!", a1, a2);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1, const char *a2)
{
fprintf(stderr, "out of memory processing %s=%s\naborting command line processing!", a1, a2);
return 0xFFFFFFFFLL;
}

original_code:
int oom(const char* arg, const char* val)
{
    fprintf(stderr, "out of memory processing %s=%s\n"
                    "aborting command line processing!",
                    arg, val);
    return -1;
}

canonical_original_code:
int oom(char *arg, char *val)
{
    fprintf(stderr, "out of memory processing %s=%s\n"
                    "aborting command line processing!",
                    arg, val);
    return -1;
}

variable_types:
arg
char *

variable_types:
val
char *

return_type: int


decompiled_code:
__int64 __fastcall process_args(int argc, char **argv)
{
__int64 v2; // rax
int v3; // ecx
void *v4; // rsp
const char *v5; // r13
struct option *v6; // rcx
_BYTE *v7; // rdx
struct option *v8; // rax
char *v9; // r14
char *v10; // rax
char *v11; // rax
char *v12; // rax
int v13; // eax
int v14; // eax
__int64 result; // rax
int v16; // eax
double v17; // xmm0_8
int v18; // eax
char *v19; // rax
int v20; // eax
_BYTE v21[15]; // [rsp+0h] [rbp-30h] BYREF
char v22; // [rsp+Fh] [rbp-21h] BYREF

memset(&opts, 0, 0x58uLL);
if ( longopts.name )
{
v2 = 1LL;
do
v3 = v2++;
while ( *(_QWORD *)((char *)&loc_57D + 32 * v2 + 3) );
v4 = alloca(2 * v3 + 1);
v5 = v21;
v6 = &longopts + v3;
if ( v6 > &longopts )
{
v7 = v21;
v8 = &longopts;
do
{
*v7 = v8->val;
if ( v8->has_arg )
{
v7[1] = 58;
v7 += 2;
}
else
{
++v7;
}
++v8;
}
while ( v8 < v6 );
}
}
else
{
v5 = &v22;
}
while ( 2 )
{
v13 = getopt_long(argc, argv, v5, &longopts, 0LL);
if ( v13 == -1 )
{
result = *((unsigned int *)&opts + 12);
if ( (_DWORD)result )
{
result = *((unsigned int *)&opts + 13);
if ( (_DWORD)result )
{
result = 0LL;
if ( *((double *)&opts + 7) != 0.0 )
{
fwrite("Ignoring specified aspect-ratio\n", 1uLL, 0x20uLL, stderr);
result = 0LL;
}
}
}
}
else
{
switch ( v13 )
{
case 'A':
v18 = atoi(optarg);
*((_DWORD *)&opts + 16) = v18;
if ( (unsigned int)(v18 - 1) <= 7 )
continue;
fprintf(stderr, "anti-alias out of range 1 ~ %d", 8LL);
return 0xFFFFFFFFLL;
case 'L':
v9 = optarg;
opts = strdup(optarg);
if ( opts )
continue;
goto LABEL_30;
case 'P':
v9 = optarg;
v12 = strdup(optarg);
*(&opts + 2) = v12;
if ( v12 )
continue;
goto LABEL_30;
case 'R':
v9 = optarg;
v19 = strdup(optarg);
*(&opts + 9) = v19;
if ( v19 )
continue;
goto LABEL_30;
case 'V':
printf("mdz-%s\n", "0.1.2");
return 0xFFFFFFFFLL;
case 'a':
v17 = atof(optarg);
*((double *)&opts + 7) = v17;
if ( v17 > 0.0 )
continue;
fwrite("aspect-ratio must be above zero", 1uLL, 0x1FuLL, stderr);
return 0xFFFFFFFFLL;
case 'd':
v9 = optarg;
v10 = strdup(optarg);
*(&opts + 4) = v10;
if ( v10 )
continue;
goto LABEL_30;
case 'h':
v16 = atoi(optarg);
*((_DWORD *)&opts + 13) = v16;
if ( (unsigned int)(v16 - 2) <= 0x7FFD )
continue;
fprintf(stderr, "height out of range 1 ~ %d", 0x7FFFLL);
return 0xFFFFFFFFLL;
case 'l':
v9 = optarg;
v11 = strdup(optarg);
*(&opts + 1) = v11;
if ( v11 )
continue;
LABEL_30:
result = oom(*(&longopts.name + 4 * optind), v9);
break;
case 'p':
*((_DWORD *)&opts + 6) = 1;
continue;
case 't':
v20 = atoi(optarg);
*((_DWORD *)&opts + 20) = v20;
if ( (unsigned int)(v20 - 1) <= 0x1FF )
continue;
fprintf(stderr, "thread count out of range 1 ~ %d", 512LL);
result = 0xFFFFFFFFLL;
break;
case 'w':
v14 = atoi(optarg);
*((_DWORD *)&opts + 12) = v14;
if ( (unsigned int)(v14 - 2) <= 0x7FFD )
continue;
fprintf(stderr, "width out of range 1 ~ %d", 0x7FFFLL);
result = 0xFFFFFFFFLL;
break;
default:
show_usage(*argv);
result = 0xFFFFFFFFLL;
break;
}
}
return result;
}
}

canonical_decompiled_code:
__int64 __fastcall func2(int argc, char **argv)
{
__int64 v2; // rax
int v3; // ecx
void *v4; // rsp
const char *v5; // r13
struct option *v6; // rcx
_BYTE *v7; // rdx
struct option *v8; // rax
char *v9; // r14
char *v10; // rax
char *v11; // rax
char *v12; // rax
int v13; // eax
int v14; // eax
__int64 result; // rax
int v16; // eax
double v17; // xmm0_8
int v18; // eax
char *v19; // rax
int v20; // eax
_BYTE v21[15]; // [rsp+0h] [rbp-30h] BYREF
char v22; // [rsp+Fh] [rbp-21h] BYREF

memset(&opts, 0, 0x58uLL);
if ( longopts.name )
{
v2 = 1LL;
do
v3 = v2++;
while ( *(_QWORD *)((char *)&loc_57D + 32 * v2 + 3) );
v4 = alloca(2 * v3 + 1);
v5 = v21;
v6 = &longopts + v3;
if ( v6 > &longopts )
{
v7 = v21;
v8 = &longopts;
do
{
*v7 = v8->val;
if ( v8->has_arg )
{
v7[1] = 58;
v7 += 2;
}
else
{
++v7;
}
++v8;
}
while ( v8 < v6 );
}
}
else
{
v5 = &v22;
}
while ( 2 )
{
v13 = getopt_long(argc, argv, v5, &longopts, 0LL);
if ( v13 == -1 )
{
result = *((unsigned int *)&opts + 12);
if ( (_DWORD)result )
{
result = *((unsigned int *)&opts + 13);
if ( (_DWORD)result )
{
result = 0LL;
if ( *((double *)&opts + 7) != 0.0 )
{
fwrite("Ignoring specified aspect-ratio\n", 1uLL, 0x20uLL, stderr);
result = 0LL;
}
}
}
}
else
{
switch ( v13 )
{
case 'A':
v18 = atoi(optarg);
*((_DWORD *)&opts + 16) = v18;
if ( (unsigned int)(v18 - 1) <= 7 )
continue;
fprintf(stderr, "anti-alias out of range 1 ~ %d", 8LL);
return 0xFFFFFFFFLL;
case 'L':
v9 = optarg;
opts = strdup(optarg);
if ( opts )
continue;
goto LABEL_30;
case 'P':
v9 = optarg;
v12 = strdup(optarg);
*(&opts + 2) = v12;
if ( v12 )
continue;
goto LABEL_30;
case 'R':
v9 = optarg;
v19 = strdup(optarg);
*(&opts + 9) = v19;
if ( v19 )
continue;
goto LABEL_30;
case 'V':
printf("mdz-%s\n", "0.1.2");
return 0xFFFFFFFFLL;
case 'a':
v17 = atof(optarg);
*((double *)&opts + 7) = v17;
if ( v17 > 0.0 )
continue;
fwrite("aspect-ratio must be above zero", 1uLL, 0x1FuLL, stderr);
return 0xFFFFFFFFLL;
case 'd':
v9 = optarg;
v10 = strdup(optarg);
*(&opts + 4) = v10;
if ( v10 )
continue;
goto LABEL_30;
case 'h':
v16 = atoi(optarg);
*((_DWORD *)&opts + 13) = v16;
if ( (unsigned int)(v16 - 2) <= 0x7FFD )
continue;
fprintf(stderr, "height out of range 1 ~ %d", 0x7FFFLL);
return 0xFFFFFFFFLL;
case 'l':
v9 = optarg;
v11 = strdup(optarg);
*(&opts + 1) = v11;
if ( v11 )
continue;
LABEL_30:
result = func1(*(&longopts.name + 4 * optind), v9);
break;
case 'p':
*((_DWORD *)&opts + 6) = 1;
continue;
case 't':
v20 = atoi(optarg);
*((_DWORD *)&opts + 20) = v20;
if ( (unsigned int)(v20 - 1) <= 0x1FF )
continue;
fprintf(stderr, "thread count out of range 1 ~ %d", 512LL);
result = 0xFFFFFFFFLL;
break;
case 'w':
v14 = atoi(optarg);
*((_DWORD *)&opts + 12) = v14;
if ( (unsigned int)(v14 - 2) <= 0x7FFD )
continue;
fprintf(stderr, "width out of range 1 ~ %d", 0x7FFFLL);
result = 0xFFFFFFFFLL;
break;
default:
func0(*argv);
result = 0xFFFFFFFFLL;
break;
}
}
return result;
}
}

original_code:
int process_args(int argc, char** argv)
{
    memset(&opts, 0, sizeof(options));
    opts.width = 0;
    opts.height = 0;
    opts.aspect = 0;
    opts.antialias = 0;
    int optcount = 0;
    while (longopts[optcount].name)
        ++optcount;
    char shortopts[optcount * 2 + 1];
    char* sop = shortopts;
    struct option * lop = longopts;
    for (; lop < &longopts[optcount]; ++lop)
    {
        *sop++ = lop->val;
        if (lop->has_arg)
            *sop++ = ':';
    }
    for (;;)
    {
        int c = getopt_long(argc, argv, shortopts, longopts, 0);
        if (c == -1)
            break;
        switch(c)
        {
        case 'd':
            opts.dumpfile = strdup(optarg);
            if (!opts.dumpfile)
                return oom(longopts[optind].name, optarg);
            break;
        case 'l':
            if (!(opts.settingsfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'P':
            if (!(opts.palettefile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'p':
            opts.randompalette = 1;
            break;
        case 'L':
            if (!(opts.logfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'w':
            opts.width = atoi(optarg);
            if (opts.width < 2 || opts.width > 32767)
            {
                fprintf(stderr, "width out of range 1 ~ %d", 32767);
                return -1;
            }
            break;
        case 'h':
            opts.height = atoi(optarg);
            if (opts.height < 2 || opts.height > 32767)
            {
                fprintf(stderr, "height out of range 1 ~ %d", 32767);
                return -1;
            }
            break;
        case 'a':
            opts.aspect = atof(optarg);
            if (opts.aspect <= 0)
            {
                fprintf(stderr, "aspect-ratio must be above zero");
                return -1;
            }
            break;
        case 'A':
            opts.antialias = atoi(optarg);
            if (opts.antialias < 1 || opts.antialias > 8)
            {
                fprintf(stderr, "anti-alias out of range 1 ~ %d", 8);
                return -1;
            }
            break;
        case 'R':
            if (!(opts.renderfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 't':
            opts.threads = atoi(optarg);
            if (opts.threads < 1 || opts.threads > 512)
            {
                fprintf(stderr, "thread count out of range 1 ~ %d",
                                512);
                return -1;
            }
            break;
        case 'V':
            printf("mdz-%s\n", "0.1.2");
            return -1;
        default:
            show_usage(argv[0]);
            return -1;
        }
    }
    if (opts.width && opts.height && opts.aspect)
        fprintf(stderr, "Ignoring specified aspect-ratio\n");
    return 0;
}

canonical_original_code:
int process_args(int argc, char **argv)
{
    memset(&opts, 0, sizeof(options));
    opts.width = 0;
    opts.height = 0;
    opts.aspect = 0;
    opts.antialias = 0;
    int optcount = 0;
    while (longopts[optcount].name)
        ++optcount;
    char shortopts[-1];
    char *sop = shortopts;
    struct option *lop = longopts;
    for (; lop < &longopts[optcount]; ++lop)
    {
        *sop++ = lop->val;
        if (lop->has_arg)
            *sop++ = ':';
    }
    for (;;)
    {
        int c = getopt_long(argc, argv, shortopts, longopts, 0);
        if (c == -1)
            break;
        switch(c)
        {
        case 'd':
            opts.dumpfile = strdup(optarg);
            if (!opts.dumpfile)
                return oom(longopts[optind].name, optarg);
            break;
        case 'l':
            if (!(opts.settingsfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'P':
            if (!(opts.palettefile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'p':
            opts.randompalette = 1;
            break;
        case 'L':
            if (!(opts.logfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 'w':
            opts.width = atoi(optarg);
            if (opts.width < 2 || opts.width > 32767)
            {
                fprintf(stderr, "width out of range 1 ~ %d", 32767);
                return -1;
            }
            break;
        case 'h':
            opts.height = atoi(optarg);
            if (opts.height < 2 || opts.height > 32767)
            {
                fprintf(stderr, "height out of range 1 ~ %d", 32767);
                return -1;
            }
            break;
        case 'a':
            opts.aspect = atof(optarg);
            if (opts.aspect <= 0)
            {
                fprintf(stderr, "aspect-ratio must be above zero");
                return -1;
            }
            break;
        case 'A':
            opts.antialias = atoi(optarg);
            if (opts.antialias < 1 || opts.antialias > 8)
            {
                fprintf(stderr, "anti-alias out of range 1 ~ %d", 8);
                return -1;
            }
            break;
        case 'R':
            if (!(opts.renderfile = strdup(optarg)))
                return oom(longopts[optind].name, optarg);
            break;
        case 't':
            opts.threads = atoi(optarg);
            if (opts.threads < 1 || opts.threads > 512)
            {
                fprintf(stderr, "thread count out of range 1 ~ %d",
                                512);
                return -1;
            }
            break;
        case 'V':
            printf("mdz-%s\n", "0.1.2");
            return -1;
        default:
            show_usage(argv[0]);
            return -1;
        }
    }
    if (opts.width && opts.height && opts.aspect)
        fprintf(stderr, "Ignoring specified aspect-ratio\n");
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: optcount int

variable_types:
shortopts
char [-1]

variable_types:
sop
char *

variable_types: struct option { char *name; int has_arg; int *flag; int val; } *

variable_types: c int


decompiled_code:
void cleanup_opts()
{
FILE *v0; // rdi
void *v1; // rdi
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

if ( opts )
{
if ( strcmp("-", (const char *)opts) )
{
v0 = (FILE *)*(&opts + 5);
if ( v0 )
fclose(v0);
}
free(opts);
}
v1 = *(&opts + 1);
if ( v1 )
free(v1);
v2 = *(&opts + 2);
if ( v2 )
free(v2);
v3 = *(&opts + 4);
if ( v3 )
free(v3);
v4 = *(&opts + 9);
if ( v4 )
free(v4);
}

canonical_decompiled_code:
void func3()
{
FILE *v0; // rdi
void *v1; // rdi
void *v2; // rdi
void *v3; // rdi
void *v4; // rdi

if ( opts )
{
if ( strcmp("-", (const char *)opts) )
{
v0 = (FILE *)*(&opts + 5);
if ( v0 )
fclose(v0);
}
free(opts);
}
v1 = *(&opts + 1);
if ( v1 )
free(v1);
v2 = *(&opts + 2);
if ( v2 )
free(v2);
v3 = *(&opts + 4);
if ( v3 )
free(v3);
v4 = *(&opts + 9);
if ( v4 )
free(v4);
}

original_code:
void cleanup_opts()
{
    if (opts.logfile)
    {
        if (strcmp("-", opts.logfile) != 0)
        {
            if (opts.logfd)
                fclose(opts.logfd);
        }
        free(opts.logfile);
    }
    if (opts.settingsfile)
        free(opts.settingsfile);
    if (opts.palettefile)
        free(opts.palettefile);
    if (opts.dumpfile)
        free(opts.dumpfile);
    if (opts.renderfile)
        free(opts.renderfile);
}


decompiled_code:
char *__fastcall my_mpfr_to_str(__int64 a1)
{
mpfr_snprintf(d0_0, 4096LL, "%.Re", a1);
return strdup(d0_0);
}

canonical_decompiled_code:
char *__fastcall func0(__int64 a1)
{
mpfr_snprintf(d0_0, 4096LL, "%.Re", a1);
return strdup(d0_0);
}

original_code:
char* my_mpfr_to_str(mpfr_t n)
{
    static char d0[4096 + 1];
    mpfr_snprintf(d0, 4096, "%.Re", n);
    return strdup(d0);
}

canonical_original_code:
char *my_mpfr_to_str(struct __mpfr_struct n[1])
{
    static char d0[-1];
    mpfr_snprintf(d0, 4096, "%.Re", n);
    return strdup(d0);
}

return_type: char *

user_defined_types: struct __mpfr_struct { long _mpfr_prec; int _mpfr_sign; long _mpfr_exp; unsigned long *_mpfr_d; }


decompiled_code:
char *setting_init()
{
char *result; // rax

result = setlocale(1, 0LL);
sysloc = result;
return result;
}

canonical_decompiled_code:
char *func0()
{
char *result; // rax

result = setlocale(1, 0LL);
sysloc = result;
return result;
}

original_code:
void setting_init()
{
    sysloc = setlocale(1, 0);
}


decompiled_code:
char *__fastcall setting_get_str(char *s2, char *s1)
{
size_t v2; // r12
size_t v3; // r13
char *i; // rbx
size_t v5; // rax
char *v6; // rbp

if ( s1 )
{
v2 = strlen(s1);
v3 = v2;
if ( strlen(s2) < v2 + 2 )
return 0LL;
if ( strncmp(s1, s2, v2) )
return 0LL;
}
else
{
v3 = 0LL;
}
for ( i = &s2[v3]; *i == 32; ++i )
;
v5 = strlen(i);
v6 = (char *)malloc(v5 + 1);
strcpy(v6, i);
return v6;
}

canonical_decompiled_code:
char *__fastcall func1(char *s2, char *s1)
{
size_t v2; // r12
size_t v3; // r13
char *i; // rbx
size_t v5; // rax
char *v6; // rbp

if ( s1 )
{
v2 = strlen(s1);
v3 = v2;
if ( strlen(s2) < v2 + 2 )
return 0LL;
if ( strncmp(s1, s2, v2) )
return 0LL;
}
else
{
v3 = 0LL;
}
for ( i = &s2[v3]; *i == 32; ++i )
;
v5 = strlen(i);
v6 = (char *)malloc(v5 + 1);
strcpy(v6, i);
return v6;
}

original_code:
char* setting_get_str(const char* buf, const char* name)
{
    const char* opt;
    char* ret = 0;
    size_t nlen = 0;
    size_t olen;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 2 || strncmp(name, buf, nlen))
            return 0;
    }
    opt = buf + nlen;
    while (*opt == ' ')
        ++opt;
    olen = strlen(opt);
    ret = malloc(olen + 1);
    strcpy(ret, opt);
    return ret;
}

canonical_original_code:
char *setting_get_str(char *buf, char *name)
{
    char *opt;
    char *ret = 0;
    unsigned long nlen = 0;
    unsigned long olen;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 2 || strncmp(name, buf, nlen))
            return 0;
    }
    opt = buf + nlen;
    while (*opt == ' ')
        ++opt;
    olen = strlen(opt);
    ret = malloc(olen + 1);
    strcpy(ret, opt);
    return ret;
}

variable_types:
buf
char *

variable_types:
name
char *

variable_types:
opt
char *

variable_types:
ret
char *

variable_types:
nlen
unsigned long

variable_types:
olen
unsigned long


decompiled_code:
__int64 __fastcall setting_get_index(char *s2, char *s1, const char **a3)
{
size_t v5; // rbp
size_t v6; // rbx
const char *v7; // rsi
char *v8; // r13
char v9; // r14
__int64 v10; // rbp
const char *v11; // rbx
const char *v12; // rdx
const char **v13; // r12
unsigned int v15; // [rsp+Ch] [rbp-3Ch]

if ( s1 )
{
v5 = strlen(s1);
v6 = v5;
v15 = 0;
if ( strlen(s2) < v5 + 2 || strncmp(s1, s2, v5) )
return v15;
}
else
{
v6 = 0LL;
}
v7 = *a3;
if ( *a3 )
{
v8 = &s2[v6];
v9 = s2[v6];
v10 = 0LL;
while ( 1 )
{
v15 = v10;
if ( v9 == 32 )
{
v11 = v8;
do
++v11;
while ( *v11 == 32 );
}
else
{
v11 = v8;
}
if ( !strcmp(v11, v7) )
break;
v7 = a3[++v10];
if ( !v7 )
goto LABEL_15;
}
}
else
{
v11 = 0LL;
LABEL_15:
fprintf(stderr, "unknown option:%s for %s\n", v11, s1);
fwrite("available options:", 1uLL, 0x12uLL, stderr);
v12 = *a3;
if ( *a3 )
{
v13 = a3 + 1;
do
{
fprintf(stderr, "%s ", v12);
v12 = *v13++;
}
while ( v12 );
}
fputc(10, stderr);
v15 = -1;
}
return v15;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s2, char *s1, const char **a3)
{
size_t v5; // rbp
size_t v6; // rbx
const char *v7; // rsi
char *v8; // r13
char v9; // r14
__int64 v10; // rbp
const char *v11; // rbx
const char *v12; // rdx
const char **v13; // r12
unsigned int v15; // [rsp+Ch] [rbp-3Ch]

if ( s1 )
{
v5 = strlen(s1);
v6 = v5;
v15 = 0;
if ( strlen(s2) < v5 + 2 || strncmp(s1, s2, v5) )
return v15;
}
else
{
v6 = 0LL;
}
v7 = *a3;
if ( *a3 )
{
v8 = &s2[v6];
v9 = s2[v6];
v10 = 0LL;
while ( 1 )
{
v15 = v10;
if ( v9 == 32 )
{
v11 = v8;
do
++v11;
while ( *v11 == 32 );
}
else
{
v11 = v8;
}
if ( !strcmp(v11, v7) )
break;
v7 = a3[++v10];
if ( !v7 )
goto LABEL_15;
}
}
else
{
v11 = 0LL;
LABEL_15:
fprintf(stderr, "unknown option:%s for %s\n", v11, s1);
fwrite("available options:", 1uLL, 0x12uLL, stderr);
v12 = *a3;
if ( *a3 )
{
v13 = a3 + 1;
do
{
fprintf(stderr, "%s ", v12);
v12 = *v13++;
}
while ( v12 );
}
fputc(10, stderr);
v15 = -1;
}
return v15;
}

original_code:
int setting_get_index( const char* buf, const char* name,
                        const char** options)
{
    size_t nlen = 0;
    int i;
    const char* opt = 0;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 2 || strncmp(name, buf, nlen))
            return 0;
    }
    for (i = 0; options[i] != 0; ++i)
    {
        opt = buf + nlen;
        while (*opt == ' ')
            ++opt;
        if (strcmp(opt, options[i]) == 0)
            return i;
    }
    fprintf(stderr, "unknown option:%s for %s\n", opt, name);
    fprintf(stderr, "available options:");
    for (i = 0; options[i] != 0; ++i)
        fprintf(stderr, "%s ", options[i]);
    fprintf(stderr, "\n");
    return -1;
}

canonical_original_code:
int setting_get_index(char *buf, char *name, char **options)
{
    unsigned long nlen = 0;
    int i;
    char *opt = 0;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 2 || strncmp(name, buf, nlen))
            return 0;
    }
    for (i = 0; options[i] != 0; ++i)
    {
        opt = buf + nlen;
        while (*opt == ' ')
            ++opt;
        if (strcmp(opt, options[i]) == 0)
            return i;
    }
    fprintf(stderr, "unknown option:%s for %s\n", opt, name);
    fprintf(stderr, "available options:");
    for (i = 0; options[i] != 0; ++i)
        fprintf(stderr, "%s ", options[i]);
    fprintf(stderr, "\n");
    return -1;
}

variable_types:
options
char **

variable_types: i int


decompiled_code:
__int64 __fastcall setting_get_long(char *s2, char *s1, __int64 *a3, __int64 a4, __int64 a5)
{
size_t v8; // r12
size_t v9; // rcx
__int64 result; // rax
int v11; // edx
int v12; // ebx
__int64 v13; // rdx
size_t v14; // [rsp+8h] [rbp-40h]

if ( s1 )
{
v8 = strlen(s1);
v14 = v8;
v9 = strlen(s2);
result = 0LL;
if ( v9 < v8 + 1 )
return result;
v11 = strncmp(s1, s2, v8);
result = 0LL;
if ( v11 )
return result;
}
else
{
v14 = 0LL;
}
setlocale(1, "C");
v12 = _isoc99_sscanf(&s2[v14], "%ld", a3);
setlocale(1, sysloc);
result = 0LL;
if ( v12 == 1 )
{
result = 1LL;
if ( a5 | a4 )
{
v13 = *a3;
LOBYTE(result) = *a3 > a5;
LOBYTE(v13) = *a3 < a4;
result = ((unsigned int)v13 | (unsigned int)result) ^ 1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s2, char *s1, __int64 *a3, __int64 a4, __int64 a5)
{
size_t v8; // r12
size_t v9; // rcx
__int64 result; // rax
int v11; // edx
int v12; // ebx
__int64 v13; // rdx
size_t v14; // [rsp+8h] [rbp-40h]

if ( s1 )
{
v8 = strlen(s1);
v14 = v8;
v9 = strlen(s2);
result = 0LL;
if ( v9 < v8 + 1 )
return result;
v11 = strncmp(s1, s2, v8);
result = 0LL;
if ( v11 )
return result;
}
else
{
v14 = 0LL;
}
setlocale(1, "C");
v12 = _isoc99_sscanf(&s2[v14], "%ld", a3);
setlocale(1, sysloc);
result = 0LL;
if ( v12 == 1 )
{
result = 1LL;
if ( a5 | a4 )
{
v13 = *a3;
LOBYTE(result) = *a3 > a5;
LOBYTE(v13) = *a3 < a4;
result = ((unsigned int)v13 | (unsigned int)result) ^ 1;
}
}
return result;
}

original_code:
_Bool setting_get_long( const char* buf, const char* name,
                        long* val, long min, long max)
{
    size_t nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = sscanf(buf + nlen, "%ld", val);
    setlocale(1, sysloc);
    if (r != 1)
     return 0;
    if (!min && !max)
        return 1;
    if (*val < min || *val > max)
        return 0;
    return 1;
}

canonical_original_code:
_Bool setting_get_long(char *buf, char *name, long *val, long min, long max)
{
    unsigned long nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = sscanf(buf + nlen, "%ld", val);
    setlocale(1, sysloc);
    if (r != 1)
     return 0;
    if (!min && !max)
        return 1;
    if (*val < min || *val > max)
        return 0;
    return 1;
}

variable_types:
val
long *

variable_types: min long

variable_types: max long

variable_types: r int


decompiled_code:
__int64 __fastcall setting_get_version(__int64 a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
int v6; // ebx
__int64 result; // rax
int v8; // [rsp+4h] [rbp-34h] BYREF
int v9; // [rsp+8h] [rbp-30h] BYREF
int v10; // [rsp+Ch] [rbp-2Ch] BYREF

setlocale(1, "C");
v6 = _isoc99_sscanf(a1, "%d.%d.%d", &v10, &v9, &v8);
setlocale(1, sysloc);
result = 0LL;
if ( v6 == 3 )
{
*a2 = v10;
*a3 = v9;
*a4 = v8;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
int v6; // ebx
__int64 result; // rax
int v8; // [rsp+4h] [rbp-34h] BYREF
int v9; // [rsp+8h] [rbp-30h] BYREF
int v10; // [rsp+Ch] [rbp-2Ch] BYREF

setlocale(1, "C");
v6 = _isoc99_sscanf(a1, "%d.%d.%d", &v10, &v9, &v8);
setlocale(1, sysloc);
result = 0LL;
if ( v6 == 3 )
{
*a2 = v10;
*a3 = v9;
*a4 = v8;
result = 1LL;
}
return result;
}

original_code:
_Bool setting_get_version(const char* buf, int* major,
                                            int* minor,
                                            int* revision)
{
    int r, maj, min, rev;
    setlocale(1, "C");
    r = sscanf(buf, "%d.%d.%d", &maj, &min, &rev);
    setlocale(1, sysloc);
    if (r == 3)
    {
        *major = maj;
        *minor = min;
        *revision = rev;
        return 1;
    }
    return 0;
}

canonical_original_code:
_Bool setting_get_version(char *buf, int *major, int *minor, int *revision)
{
    int r; int maj; int min; int rev;
    setlocale(1, "C");
    r = sscanf(buf, "%d.%d.%d", &maj, &min, &rev);
    setlocale(1, sysloc);
    if (r == 3)
    {
        *major = maj;
        *minor = min;
        *revision = rev;
        return 1;
    }
    return 0;
}

variable_types:
major
int *

variable_types:
minor
int *

variable_types:
revision
int *

variable_types: maj int

variable_types: min int

variable_types: rev int


decompiled_code:
bool __fastcall setting_get_double(char *s2, char *s1, double *a3, double a4, double a5)
{
size_t v6; // r12
size_t v7; // r15
size_t v8; // rcx
bool result; // al
int v10; // edx
int v11; // ebx

if ( s1 )
{
v6 = strlen(s1);
v7 = v6;
v8 = strlen(s2);
result = 0;
if ( v8 < v6 + 1 )
return result;
v10 = strncmp(s1, s2, v6);
result = 0;
if ( v10 )
return result;
}
else
{
v7 = 0LL;
}
setlocale(1, "C");
v11 = _isoc99_sscanf(&s2[v7], "%lf", a3);
setlocale(1, sysloc);
result = 0;
if ( v11 == 1 )
{
result = a5 == 0.0 && a4 == 0.0;
if ( !result && a4 <= *a3 )
result = *a3 <= a5;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func5(char *s2, char *s1, double *a3, double a4, double a5)
{
size_t v6; // r12
size_t v7; // r15
size_t v8; // rcx
bool result; // al
int v10; // edx
int v11; // ebx

if ( s1 )
{
v6 = strlen(s1);
v7 = v6;
v8 = strlen(s2);
result = 0;
if ( v8 < v6 + 1 )
return result;
v10 = strncmp(s1, s2, v6);
result = 0;
if ( v10 )
return result;
}
else
{
v7 = 0LL;
}
setlocale(1, "C");
v11 = _isoc99_sscanf(&s2[v7], "%lf", a3);
setlocale(1, sysloc);
result = 0;
if ( v11 == 1 )
{
result = a5 == 0.0 && a4 == 0.0;
if ( !result && a4 <= *a3 )
result = *a3 <= a5;
}
return result;
}

original_code:
_Bool setting_get_double( const char* buf, const char* name,
                            double* val, double min, double max)
{
    size_t nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = sscanf(buf + nlen, "%lf", val);
    setlocale(1, sysloc);
    if (r != 1)
        return 0;
    if (!min && !max)
        return 1;
    if (*val < min || *val > max)
        return 0;
    return 1;
}

canonical_original_code:
_Bool setting_get_double(char *buf, char *name, double *val, double min, double max)
{
    unsigned long nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = sscanf(buf + nlen, "%lf", val);
    setlocale(1, sysloc);
    if (r != 1)
        return 0;
    if (!min && !max)
        return 1;
    if (*val < min || *val > max)
        return 0;
    return 1;
}

variable_types:
buf
char *

variable_types:
name
char *

variable_types:
val
double *

variable_types: min double

variable_types: max double


decompiled_code:
bool __fastcall setting_get_mpfr_t(char *s2, char *s1, __int64 a3)
{
size_t v4; // r12
size_t v5; // r14
size_t v6; // rcx
bool result; // al
int v8; // edx
int v9; // ebx

if ( !s1 )
{
v5 = 0LL;
LABEL_4:
setlocale(1, "C");
v9 = mpfr_set_str(a3, &s2[v5], 10LL, 0LL);
setlocale(1, sysloc);
return v9 == 0;
}
v4 = strlen(s1);
v5 = v4;
v6 = strlen(s2);
result = 0;
if ( v6 >= v4 + 1 )
{
v8 = strncmp(s1, s2, v4);
result = 0;
if ( !v8 )
goto LABEL_4;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func6(char *s2, char *s1, __int64 a3)
{
size_t v4; // r12
size_t v5; // r14
size_t v6; // rcx
bool result; // al
int v8; // edx
int v9; // ebx

if ( !s1 )
{
v5 = 0LL;
LABEL_4:
setlocale(1, "C");
v9 = mpfr_set_str(a3, &s2[v5], 10LL, 0LL);
setlocale(1, sysloc);
return v9 == 0;
}
v4 = strlen(s1);
v5 = v4;
v6 = strlen(s2);
result = 0;
if ( v6 >= v4 + 1 )
{
v8 = strncmp(s1, s2, v4);
result = 0;
if ( !v8 )
goto LABEL_4;
}
return result;
}

original_code:
_Bool setting_get_mpfr_t(const char* buf, const char* name, mpfr_t val)
{
    size_t nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = mpfr_set_str(val, buf + nlen, 10, MPFR_RNDN);
    setlocale(1, sysloc);
    if (r)
        return 0;
    return 1;
}

canonical_original_code:
_Bool setting_get_mpfr_t(char *buf, char *name, struct __mpfr_struct val[1])
{
    unsigned long nlen = 0;
    int r;
    if (name)
    {
        nlen = strlen(name);
        if (strlen(buf) < nlen + 1 || strncmp(name, buf, nlen))
            return 0;
    }
    setlocale(1, "C");
    r = mpfr_set_str(val, buf + nlen, 10, MPFR_RNDN);
    setlocale(1, sysloc);
    if (r)
        return 0;
    return 1;
}

variable_types: struct __mpfr_struct { long _mpfr_prec; int _mpfr_sign; long _mpfr_exp; unsigned long *_mpfr_d; } [1]

variable_types:
nlen
unsigned long


decompiled_code:
__int64 __fastcall frac_generalized_celtic(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v18; // fst2
long double v19; // rt2
long double v20; // fst2
long double v21; // rtt
long double v22; // rt0
long double v23; // fst3
long double v24; // fst6
long double v25; // fst7
long double v26; // fst4

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v22 = a6;
v23 = a7;
v24 = a2 * (a3 + a3) + a4;
v25 = a5;
v26 = fabs(v23 - v22) + a5;
a6 = v24 * v24;
if ( v24 * v24 + v26 * v26 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v18 = v24;
a7 = v26 * v26;
v19 = v18;
v20 = v25;
a2 = v19;
v21 = v20;
a3 = v26;
a5 = v21;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v18; // fst2
long double v19; // rt2
long double v20; // fst2
long double v21; // rtt
long double v22; // rt0
long double v23; // fst3
long double v24; // fst6
long double v25; // fst7
long double v26; // fst4

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v22 = a6;
v23 = a7;
v24 = a2 * (a3 + a3) + a4;
v25 = a5;
v26 = fabs(v23 - v22) + a5;
a6 = v24 * v24;
if ( v24 * v24 + v26 * v26 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v18 = v24;
a7 = v26 * v26;
v19 = v18;
v20 = v25;
a2 = v19;
v21 = v20;
a3 = v26;
a5 = v21;
}
return result;
}

original_code:
depth_t frac_generalized_celtic(depth_t depth,
                                long double wim, long double wre,
                                long double c_im, long double c_re,
                                long double wim2, long double wre2 )
{
    depth_t wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        wre = fabsl(wre2 - wim2) + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_generalized_celtic(long depth, long double wim, long double wre, long double c_im, long double c_re, long double wim2, long double wre2)
{
    long wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        wre = fabsl(wre2 - wim2) + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

variable_types: depth long

variable_types:
wim
long double

variable_types:
wre
long double

variable_types: wz long


decompiled_code:
__int64 __fastcall frac_generalized_celtic_mpfr(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_generalized_celtic_mpfr(
                                depth_t depth,
                                mpfr_t bail,
                                mpfr_t wim, mpfr_t wre,
                                mpfr_t c_im, mpfr_t c_re,
                                mpfr_t wim2, mpfr_t wre2, mpfr_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_set4(t1,t1,MPFR_RNDN,1);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_generalized_celtic_mpfr(long depth, struct __mpfr_struct bail[1], struct __mpfr_struct wim[1], struct __mpfr_struct wre[1], struct __mpfr_struct c_im[1], struct __mpfr_struct c_re[1], struct __mpfr_struct wim2[1], struct __mpfr_struct wre2[1], struct __mpfr_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_set4(t1,t1,MPFR_RNDN,1);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

variable_types:
wim
struct __mpfr_struct [1]

variable_types:
wre
struct __mpfr_struct [1]


decompiled_code:
__int64 __fastcall frac_generalized_celtic_gmp(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
_gmpf_mul(a9, a4, a3);
_gmpf_mul_ui(a9, a9, 2LL);
_gmpf_add(a3, a9, a5);
_gmpf_sub(a9, a8, a7);
_gmpf_abs(a9, a9);
_gmpf_add(a4, a9, a6);
_gmpf_mul(a7, a3, a3);
_gmpf_mul(a8, a4, a4);
_gmpf_add(a9, a7, a8);
if ( (int)_gmpf_cmp(a9, a2) > 0 )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_generalized_celtic_gmp(
                                depth_t depth,
                                mpf_t bail,
                                mpf_t wim, mpf_t wre,
                                mpf_t c_im, mpf_t c_re,
                                mpf_t wim2, mpf_t wre2, mpf_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_abs( t1, t1);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_generalized_celtic_gmp(long depth, struct __mpf_struct bail[1], struct __mpf_struct wim[1], struct __mpf_struct wre[1], struct __mpf_struct c_im[1], struct __mpf_struct c_re[1], struct __mpf_struct wim2[1], struct __mpf_struct wre2[1], struct __mpf_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_abs( t1, t1);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

variable_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; } [1]

variable_types:
wim
struct __mpf_struct [1]

variable_types:
wre
struct __mpf_struct [1]


decompiled_code:
__int64 __fastcall frac_burning_ship(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // fst2
long double v18; // rt2
long double v19; // rtt
long double v20; // fst3
long double v21; // rt0
long double v22; // fst3
long double v23; // fst6
long double v24; // fst7

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v19 = a6;
v20 = fabs(a2 * a3);
v21 = v20 + v20 + a4;
v22 = a7;
v23 = v21;
v24 = v22 - v19 + a5;
a6 = v21 * v21;
if ( v21 * v21 + v24 * v24 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v17 = v23;
a7 = v24 * v24;
v18 = v17;
a3 = v24;
a2 = v18;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // fst2
long double v18; // rt2
long double v19; // rtt
long double v20; // fst3
long double v21; // rt0
long double v22; // fst3
long double v23; // fst6
long double v24; // fst7

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v19 = a6;
v20 = fabs(a2 * a3);
v21 = v20 + v20 + a4;
v22 = a7;
v23 = v21;
v24 = v22 - v19 + a5;
a6 = v21 * v21;
if ( v21 * v21 + v24 * v24 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v17 = v23;
a7 = v24 * v24;
v18 = v17;
a3 = v24;
a2 = v18;
}
return result;
}

original_code:
depth_t frac_burning_ship( depth_t depth,
                                long double wim, long double wre,
                                long double c_im, long double c_re,
                                long double wim2, long double wre2 )
{
    depth_t wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * fabsl(wre * wim) + c_im;
        wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_burning_ship(long depth, long double wim, long double wre, long double c_im, long double c_re, long double wim2, long double wre2)
{
    long wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * fabsl(wre * wim) + c_im;
        wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall frac_burning_ship_mpfr(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_set4(a9, a9, 0LL, 1LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_burning_ship_mpfr(
                                depth_t depth,
                                mpfr_t bail,
                                mpfr_t wim, mpfr_t wre,
                                mpfr_t c_im, mpfr_t c_re,
                                mpfr_t wim2, mpfr_t wre2, mpfr_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        mpfr_set4(t1,t1,MPFR_RNDN,1);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_burning_ship_mpfr(long depth, struct __mpfr_struct bail[1], struct __mpfr_struct wim[1], struct __mpfr_struct wre[1], struct __mpfr_struct c_im[1], struct __mpfr_struct c_re[1], struct __mpfr_struct wim2[1], struct __mpfr_struct wre2[1], struct __mpfr_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        mpfr_set4(t1,t1,MPFR_RNDN,1);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall frac_burning_ship_gmp(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
_gmpf_mul(a9, a4, a3);
_gmpf_abs(a9, a9);
_gmpf_mul_ui(a9, a9, 2LL);
_gmpf_add(a3, a9, a5);
_gmpf_sub(a9, a8, a7);
_gmpf_add(a4, a9, a6);
_gmpf_mul(a7, a3, a3);
_gmpf_mul(a8, a4, a4);
_gmpf_add(a9, a7, a8);
if ( (int)_gmpf_cmp(a9, a2) > 0 )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_burning_ship_gmp(
                                depth_t depth,
                                mpf_t bail,
                                mpf_t wim, mpf_t wre,
                                mpf_t c_im, mpf_t c_re,
                                mpf_t wim2, mpf_t wre2, mpf_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_abs( t1, t1);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_burning_ship_gmp(long depth, struct __mpf_struct bail[1], struct __mpf_struct wim[1], struct __mpf_struct wre[1], struct __mpf_struct c_im[1], struct __mpf_struct c_re[1], struct __mpf_struct wim2[1], struct __mpf_struct wre2[1], struct __mpf_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_abs( t1, t1);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

user_defined_types: struct __mpf_struct { int _mp_prec; int _mp_size; long _mp_exp; unsigned long *_mp_d; }


decompiled_code:
__int64 start_reposition()
{
LODWORD(stat) = 4;
HIDWORD(stat) = 0;
gui_sensitive_switch_menu(0LL);
zoom_gui_sensitive_zoom_in_button(0LL);
zoom_gui_sensitive_zoom_out_button(0LL);
return zoom_gui_sensitive_zoom_in_1click_button(0LL);
}

canonical_decompiled_code:
__int64 func0()
{
LODWORD(stat) = 4;
HIDWORD(stat) = 0;
gui_sensitive_switch_menu(0LL);
zoom_gui_sensitive_zoom_in_button(0LL);
zoom_gui_sensitive_zoom_out_button(0LL);
return zoom_gui_sensitive_zoom_in_1click_button(0LL);
}

original_code:
void start_reposition(void)
{
    stat.action = STAT_REPOSITIONING;
    stat.reposition_p2 = (0);
    gui_sensitive_switch_menu((0));
    zoom_gui_sensitive_zoom_in_button((0));
    zoom_gui_sensitive_zoom_out_button((0));
    zoom_gui_sensitive_zoom_in_1click_button((0));
}

canonical_original_code:
void start_reposition()
{
    stat.action = STAT_REPOSITIONING;
    stat.reposition_p2 = (0);
    gui_sensitive_switch_menu((0));
    zoom_gui_sensitive_zoom_in_button((0));
    zoom_gui_sensitive_zoom_out_button((0));
    zoom_gui_sensitive_zoom_in_1click_button((0));
}


decompiled_code:
__int64 __fastcall repos_gui_sensitive_reposition_button(unsigned int a1)
{
return gtk_widget_set_sensitive(reposition_button, a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
return gtk_widget_set_sensitive(reposition_button, a1);
}

original_code:
void repos_gui_sensitive_reposition_button(gboolean t)
    { gtk_widget_set_sensitive(reposition_button, t); }

canonical_original_code:
void repos_gui_sensitive_reposition_button(int t)
    { gtk_widget_set_sensitive(reposition_button, t); }

variable_types: t int


decompiled_code:
__int64 __fastcall frac_mandel(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // fst2
long double v18; // rt2
long double v19; // rtt
long double v20; // fst3
long double v21; // fst6
long double v22; // fst7

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v19 = a6;
v20 = a7;
v21 = a2 * (a3 + a3) + a4;
v22 = v20 - v19 + a5;
a6 = v21 * v21;
if ( v21 * v21 + v22 * v22 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v17 = v21;
a7 = v22 * v22;
v18 = v17;
a3 = v22;
a2 = v18;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, long double a2, long double a3, long double a4, long double a5, long double a6, long double a7)
{
__int64 result; // rax
long double v17; // fst2
long double v18; // rt2
long double v19; // rtt
long double v20; // fst3
long double v21; // fst6
long double v22; // fst7

if ( a1 <= 0 )
return 0LL;
result = 1LL;
while ( 1 )
{
v19 = a6;
v20 = a7;
v21 = a2 * (a3 + a3) + a4;
v22 = v20 - v19 + a5;
a6 = v21 * v21;
if ( v21 * v21 + v22 * v22 > 4.0 )
break;
if ( a1 < ++result )
return 0LL;
v17 = v21;
a7 = v22 * v22;
v18 = v17;
a3 = v22;
a2 = v18;
}
return result;
}

original_code:
depth_t frac_mandel( depth_t depth,
                                long double wim, long double wre,
                                long double c_im, long double c_re,
                                long double wim2, long double wre2 )
{
    depth_t wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_mandel(long depth, long double wim, long double wre, long double c_im, long double c_re, long double wim2, long double wre2)
{
    long wz;
    for (wz = 1; wz <= depth; ++wz)
    {
        wim = 2.0 * wre * wim + c_im;
        wre = wre2 - wim2 + c_re;
        wim2 = wim * wim;
        wre2 = wre * wre;
        if (wim2 + wre2 > 4.0F)
            return wz;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall frac_mandel_mpfr(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
mpfr_mul(a9, a4, a3, 0LL);
mpfr_mul_2si(a9, a9, 1LL, 0LL);
mpfr_add(a3, a9, a5, 0LL);
mpfr_sub(a9, a8, a7, 0LL);
mpfr_add(a4, a9, a6, 0LL);
mpfr_mul(a7, a3, a3, 0LL);
mpfr_mul(a8, a4, a4, 0LL);
mpfr_add(a9, a7, a8, 0LL);
if ( (unsigned int)mpfr_greater_p(a9, a2) )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_mandel_mpfr(
                                depth_t depth,
                                mpfr_t bail,
                                mpfr_t wim, mpfr_t wre,
                                mpfr_t c_im, mpfr_t c_re,
                                mpfr_t wim2, mpfr_t wre2, mpfr_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_mandel_mpfr(long depth, struct __mpfr_struct bail[1], struct __mpfr_struct wim[1], struct __mpfr_struct wre[1], struct __mpfr_struct c_im[1], struct __mpfr_struct c_re[1], struct __mpfr_struct wim2[1], struct __mpfr_struct wre2[1], struct __mpfr_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
    {
        mpfr_mul( t1, wre, wim, MPFR_RNDN);
        (__builtin_constant_p (2) && (mpfr_long) (2) >= 0 ? (__builtin_constant_p ((mpfr_ulong) (mpfr_long) (2)) && (mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) >= 1 && ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) & ((mpfr_ulong) ((mpfr_ulong) (mpfr_long) (2)) - 1)) == 0 ? mpfr_mul_2si(((t1)), ((t1)), __builtin_ctzl ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN))) : mpfr_mul_ui (((t1)), ((t1)), ((mpfr_ulong) (mpfr_long) (2)), ((MPFR_RNDN)))) : mpfr_mul_si ((t1), (t1), (2), (MPFR_RNDN)));
        mpfr_add( wim, t1, c_im, MPFR_RNDN);
        mpfr_sub( t1, wre2, wim2, MPFR_RNDN);
        mpfr_add( wre, t1, c_re, MPFR_RNDN);
        mpfr_mul( wim2, wim, wim, MPFR_RNDN);
        mpfr_mul( wre2, wre, wre, MPFR_RNDN);
        mpfr_add( t1, wim2, wre2, MPFR_RNDN);
        if (mpfr_greater_p(t1, bail))
            return wz;
    }
    return 0;
}


decompiled_code:
__int64 __fastcall frac_mandel_gmp(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v11; // r15

if ( a1 <= 0 )
return 0LL;
v11 = 1LL;
while ( 1 )
{
_gmpf_mul(a9, a4, a3);
_gmpf_mul_ui(a9, a9, 2LL);
_gmpf_add(a3, a9, a5);
_gmpf_sub(a9, a8, a7);
_gmpf_add(a4, a9, a6);
_gmpf_mul(a7, a3, a3);
_gmpf_mul(a8, a4, a4);
_gmpf_add(a9, a7, a8);
if ( (int)_gmpf_cmp(a9, a2) > 0 )
break;
if ( a1 < ++v11 )
return 0LL;
}
return v11;
}

original_code:
depth_t frac_mandel_gmp(
                                depth_t depth,
                                mpf_t bail,
                                mpf_t wim, mpf_t wre,
                                mpf_t c_im, mpf_t c_re,
                                mpf_t wim2, mpf_t wre2, mpf_t t1)
{
    depth_t wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}

canonical_original_code:
long frac_mandel_gmp(long depth, struct __mpf_struct bail[1], struct __mpf_struct wim[1], struct __mpf_struct wre[1], struct __mpf_struct c_im[1], struct __mpf_struct c_re[1], struct __mpf_struct wim2[1], struct __mpf_struct wre2[1], struct __mpf_struct t1[1])
{
    long wz;
    for (wz = 1; wz <= depth; wz++)
        {
        __gmpf_mul( t1, wre, wim);
        __gmpf_mul_ui(t1, t1, 2);
        __gmpf_add( wim, t1, c_im);
        __gmpf_sub( t1, wre2, wim2);
        __gmpf_add( wre, t1, c_re);
        __gmpf_mul( wim2, wim, wim);
        __gmpf_mul( wre2, wre, wre);
        __gmpf_add( t1, wim2, wre2);
        if (__gmpf_cmp(t1, bail) > 0)
            return wz;
    }
    return 0;
}


decompiled_code:
int __fastcall timer_start(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

canonical_decompiled_code:
int __fastcall func0(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

original_code:
void timer_start(Timer* t)
{
    gettimeofday(&t->tv_start, 0);
}

canonical_original_code:
void timer_start(struct Timer *t)
{
    gettimeofday(&t->tv_start, 0);
}

variable_types: struct Timer { struct timeval { long tv_sec; long tv_usec; } tv_start; struct timeval tv_end; } *

user_defined_types: struct Timer { struct timeval tv_start; struct timeval tv_end; }


decompiled_code:
int __fastcall timer_stop(struct timeval *a1)
{
return gettimeofday(a1 + 1, 0LL);
}

canonical_decompiled_code:
int __fastcall func1(struct timeval *a1)
{
return gettimeofday(a1 + 1, 0LL);
}

original_code:
void timer_stop(Timer* t)
{
    gettimeofday(&t->tv_end, 0);
}

canonical_original_code:
void timer_stop(struct Timer *t)
{
    gettimeofday(&t->tv_end, 0);
}

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
__int64 __fastcall timer_get_elapsed(_QWORD *a1)
{
__int64 v1; // rax
__int64 result; // rax

v1 = a1[2];
if ( *a1 == v1 )
result = a1[3] - a1[1];
else
result = (unsigned int)(int)((double)(int)(v1 - *a1) * 1000000.0
+ (double)(*((_DWORD *)a1 + 6) - *((_DWORD *)a1 + 2)));
return result;
}

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

v1 = a1[2];
if ( *a1 == v1 )
result = a1[3] - a1[1];
else
result = (unsigned int)(int)((double)(int)(v1 - *a1) * 1000000.0
+ (double)(*((_DWORD *)a1 + 6) - *((_DWORD *)a1 + 2)));
return result;
}

original_code:
long timer_get_elapsed(Timer* t)
{
    if (t->tv_start.tv_sec == t->tv_end.tv_sec)
        return t->tv_end.tv_usec - t->tv_start.tv_usec;
    else
        return (t->tv_end.tv_sec - t->tv_start.tv_sec) *
            1e6 + (t->tv_end.tv_usec - t->tv_start.tv_usec);
}

canonical_original_code:
long timer_get_elapsed(struct Timer *t)
{
    if (t->tv_start.tv_sec == t->tv_end.tv_sec)
        return t->tv_end.tv_usec - t->tv_start.tv_usec;
    else
        return (t->tv_end.tv_sec - t->tv_start.tv_sec) *
            1e6 + (t->tv_end.tv_usec - t->tv_start.tv_usec);
}


decompiled_code:
char *__fastcall buf_tidy(char *src)
{
int v1; // ebp
char *v2; // rbx
char *v3; // rax

v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
v3 = strcpy(v2, src);
if ( v1 > 0 )
{
do
{
if ( *v3 == 9 )
{
*v3 = 32;
}
else if ( *v3 <= 31 )
{
*v3 = 0;
return v2;
}
++v3;
}
while ( v3 != &v2[v1 - 1 + 1] );
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(char *src)
{
int v1; // ebp
char *v2; // rbx
char *v3; // rax

v1 = strlen(src);
v2 = (char *)malloc(v1 + 1);
v3 = strcpy(v2, src);
if ( v1 > 0 )
{
do
{
if ( *v3 == 9 )
{
*v3 = 32;
}
else if ( *v3 <= 31 )
{
*v3 = 0;
return v2;
}
++v3;
}
while ( v3 != &v2[v1 - 1 + 1] );
}
return v2;
}

original_code:
static char* buf_tidy(const char* str)
{
    int i;
    int n = strlen(str);
    char* ret = malloc(n + 1);
    strcpy(ret, str);
    for (i = 0; i < n; ++i)
    {
        if (ret[i] == '\t')
            ret[i] = ' ';
        else if (ret[i] < ' ')
        {
            ret[i] = '\0';
            break;
        }
    }
    return ret;
}

canonical_original_code:
static char *buf_tidy(char *str)
{
    int i;
    int n = strlen(str);
    char *ret = malloc(n + 1);
    strcpy(ret, str);
    for (i = 0; i < n; ++i)
    {
        if (ret[i] == '\t')
            ret[i] = ' ';
        else if (ret[i] < ' ')
        {
            ret[i] = '\0';
            break;
        }
    }
    return ret;
}

variable_types:
str
char *

variable_types: i int

variable_types: n int

variable_types:
ret
char *


decompiled_code:
void trans_data_cleanup()
{
void *v0; // rbx
void *v1; // rdi

v0 = ptr;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 5);
free(v1);
}
}

canonical_decompiled_code:
void func1()
{
void *v0; // rbx
void *v1; // rdi

v0 = ptr;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 5);
free(v1);
}
}

original_code:
void trans_data_cleanup(void)
{
    xfer* xf = xfers.next;
    while(xf)
    {
        xfer* tmp = xf;
        xf = xf->next;
        free(tmp);
    }
}

canonical_original_code:
void trans_data_cleanup()
{
    struct xfer *xf = xfers.next;
    while(xf)
    {
        struct xfer *tmp = xf;
        xf = xf->next;
        free(tmp);
    }
}

variable_types: struct xfer { int type; char str[-1]; struct xfer *next; } *


decompiled_code:
__int64 __fastcall get_transaction_type(char *s1)
{
const char *v1; // rbx
size_t v2; // rax

v1 = (const char *)ptr;
if ( !s1 )
return 0xFFFFFFFFLL;
if ( !ptr )
return 0xFFFFFFFFLL;
while ( 1 )
{
v2 = strlen(v1 + 4);
if ( !strncasecmp(s1, v1 + 4, v2) )
break;
v1 = (const char *)*((_QWORD *)v1 + 5);
if ( !v1 )
return 0xFFFFFFFFLL;
}
return *(unsigned int *)v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1)
{
const char *v1; // rbx
size_t v2; // rax

v1 = (const char *)ptr;
if ( !s1 )
return 0xFFFFFFFFLL;
if ( !ptr )
return 0xFFFFFFFFLL;
while ( 1 )
{
v2 = strlen(v1 + 4);
if ( !strncasecmp(s1, v1 + 4, v2) )
break;
v1 = (const char *)*((_QWORD *)v1 + 5);
if ( !v1 )
return 0xFFFFFFFFLL;
}
return *(unsigned int *)v1;
}

original_code:
int get_transaction_type(const char* str)
{
    xfer* tr = xfers.next;
    if (!str)
        return TR_ERR;
    while (tr)
    {
        if (strncasecmp(str, tr->str, strlen(tr->str)) == 0)
            return tr->type;
        tr = tr->next;
    }
    return TR_ERR;
}

canonical_original_code:
int get_transaction_type(char *str)
{
    struct xfer *tr = xfers.next;
    if (!str)
        return TR_ERR;
    while (tr)
    {
        if (strncasecmp(str, tr->str, strlen(tr->str)) == 0)
            return tr->type;
        tr = tr->next;
    }
    return TR_ERR;
}

user_defined_types: struct xfer { int type; char str[-1]; struct xfer *next; }


decompiled_code:
int trans_data_init()
{
unsigned int i; // ebx
_QWORD *v1; // rax

xfers_add("Balance carried forward", 35);
xfers_add("Bal", 0);
xfers_add("Balance brought forward", 0);
xfers_add("BROUGHT FORWARD", 0);
xfers_add("ATM", 1);
xfers_add("CASH WITHDRAWAL", 1);
xfers_add("BAC", 2);
xfers_add("BGC", 3);
xfers_add("BSP", 4);
xfers_add("BP", 5);
xfers_add("CDM", 6);
xfers_add("CASH & DEP MACHINE", 6);
xfers_add("CHG", 7);
xfers_add("Charge", 7);
xfers_add("CHP", 8);
xfers_add("CHQ", 9);
xfers_add("CIR", 10);
xfers_add("CUI", 11);
xfers_add("CR", 12);
xfers_add("AUTOMATED CREDIT", 12);
xfers_add("CWP", 13);
xfers_add("DD", 14);
xfers_add("D/D", 14);
xfers_add("DIRECT DEBIT", 14);
xfers_add("DIV", 15);
xfers_add("DR", 16);
xfers_add("DWP", 17);
xfers_add("ERTF", 18);
xfers_add("IBP", 19);
xfers_add("INT", 20);
xfers_add("ITL", 21);
xfers_add("MAE", 22);
xfers_add("NDC", 23);
xfers_add("OTR", 24);
xfers_add("ONLINE TRANSACTION", 24);
xfers_add("POC", 25);
xfers_add("POS", 26);
xfers_add("DEBIT CARD TRANSACTION", 26);
xfers_add("DEBIT CARD", 26);
xfers_add("SO", 27);
xfers_add("S/O", 27);
xfers_add("STANDING ORDER", 27);
xfers_add("SBT", 28);
xfers_add("TEL", 29);
xfers_add("TFR", 30);
xfers_add("TLR", 31);
xfers_add("VIS", 32);
xfers_add("(((", 33);
for ( i = 0; i != 34; ++i )
{
v1 = get_transaction_str(i);
if ( !v1 )
LODWORD(v1) = fprintf(stderr, "ERROR: string not set for xfer id:%d\n", i);
}
return (int)v1;
}

canonical_decompiled_code:
int func3()
{
unsigned int i; // ebx
_QWORD *v1; // rax

func0("Balance carried forward", 35);
func0("Bal", 0);
func0("Balance brought forward", 0);
func0("BROUGHT FORWARD", 0);
func0("ATM", 1);
func0("CASH WITHDRAWAL", 1);
func0("BAC", 2);
func0("BGC", 3);
func0("BSP", 4);
func0("BP", 5);
func0("CDM", 6);
func0("CASH & DEP MACHINE", 6);
func0("CHG", 7);
func0("Charge", 7);
func0("CHP", 8);
func0("CHQ", 9);
func0("CIR", 10);
func0("CUI", 11);
func0("CR", 12);
func0("AUTOMATED CREDIT", 12);
func0("CWP", 13);
func0("DD", 14);
func0("D/D", 14);
func0("DIRECT DEBIT", 14);
func0("DIV", 15);
func0("DR", 16);
func0("DWP", 17);
func0("ERTF", 18);
func0("IBP", 19);
func0("INT", 20);
func0("ITL", 21);
func0("MAE", 22);
func0("NDC", 23);
func0("OTR", 24);
func0("ONLINE TRANSACTION", 24);
func0("POC", 25);
func0("POS", 26);
func0("DEBIT CARD TRANSACTION", 26);
func0("DEBIT CARD", 26);
func0("SO", 27);
func0("S/O", 27);
func0("STANDING ORDER", 27);
func0("SBT", 28);
func0("TEL", 29);
func0("TFR", 30);
func0("TLR", 31);
func0("VIS", 32);
func0("(((", 33);
for ( i = 0; i != 34; ++i )
{
v1 = get_transaction_str(i);
if ( !v1 )
LODWORD(v1) = fprintf(stderr, "ERROR: string not set for xfer id:%d\n", i);
}
return (int)v1;
}

original_code:
void trans_data_init(void)
{
    xfers_add("Balance carried forward",TR_CLOSING_BALANCE);
    xfers_add("Bal", TR_BALANCE);
    xfers_add("Balance brought forward",TR_BALANCE);
    xfers_add("BROUGHT FORWARD", TR_BALANCE);
    xfers_add("ATM", TR_ATM);
    xfers_add("CASH WITHDRAWAL", TR_ATM);
    xfers_add("BAC", TR_BAC);
    xfers_add("BGC", TR_BGC);
    xfers_add("BSP", TR_BSP);
    xfers_add("BP", TR_BP);
    xfers_add("CDM", TR_CDM);
    xfers_add("CASH & DEP MACHINE", TR_CDM);
    xfers_add("CHG", TR_CHARGE);
    xfers_add("Charge", TR_CHARGE);
    xfers_add("CHP", TR_CHP);
    xfers_add("CHQ", TR_CHQ);
    xfers_add("CIR", TR_CIR);
    xfers_add("CUI", TR_CUI);
    xfers_add("CR", TR_CR);
    xfers_add("AUTOMATED CREDIT", TR_CR);
    xfers_add("CWP", TR_CWP);
    xfers_add("DD", TR_DD);
    xfers_add("D/D", TR_DD);
    xfers_add("DIRECT DEBIT", TR_DD);
    xfers_add("DIV", TR_DIV);
    xfers_add("DR", TR_DR);
    xfers_add("DWP", TR_DWP);
    xfers_add("ERTF", TR_ERTF);
    xfers_add("IBP", TR_IBP);
    xfers_add("INT", TR_INT);
    xfers_add("ITL", TR_ITL);
    xfers_add("MAE", TR_MAE);
    xfers_add("NDC", TR_NDC);
    xfers_add("OTR", TR_OTR);
    xfers_add("ONLINE TRANSACTION", TR_OTR);
    xfers_add("POC", TR_POC);
    xfers_add("POS", TR_POS);
    xfers_add("DEBIT CARD TRANSACTION", TR_POS);
    xfers_add("DEBIT CARD", TR_POS);
    xfers_add("SO", TR_SO);
    xfers_add("S/O", TR_SO);
    xfers_add("STANDING ORDER", TR_SO);
    xfers_add("SBT", TR_SBT);
    xfers_add("TEL", TR_TEL);
    xfers_add("TFR", TR_TFR);
    xfers_add("TLR", TR_TLR);
    xfers_add("VIS", TR_VIS);
    xfers_add("(((", TR_CONTACTLESS);
    {
        int n;
        for (n = TR_BALANCE; n < TR_XXX_LAST_XXX; ++n)
        {
            if (!get_transaction_str(n))
                fprintf(stderr,"ERROR: string not set for xfer id:%d\n",n);
        }
    }
}

canonical_original_code:
void trans_data_init()
{
    xfers_add("Balance carried forward",TR_CLOSING_BALANCE);
    xfers_add("Bal", TR_BALANCE);
    xfers_add("Balance brought forward",TR_BALANCE);
    xfers_add("BROUGHT FORWARD", TR_BALANCE);
    xfers_add("ATM", TR_ATM);
    xfers_add("CASH WITHDRAWAL", TR_ATM);
    xfers_add("BAC", TR_BAC);
    xfers_add("BGC", TR_BGC);
    xfers_add("BSP", TR_BSP);
    xfers_add("BP", TR_BP);
    xfers_add("CDM", TR_CDM);
    xfers_add("CASH & DEP MACHINE", TR_CDM);
    xfers_add("CHG", TR_CHARGE);
    xfers_add("Charge", TR_CHARGE);
    xfers_add("CHP", TR_CHP);
    xfers_add("CHQ", TR_CHQ);
    xfers_add("CIR", TR_CIR);
    xfers_add("CUI", TR_CUI);
    xfers_add("CR", TR_CR);
    xfers_add("AUTOMATED CREDIT", TR_CR);
    xfers_add("CWP", TR_CWP);
    xfers_add("DD", TR_DD);
    xfers_add("D/D", TR_DD);
    xfers_add("DIRECT DEBIT", TR_DD);
    xfers_add("DIV", TR_DIV);
    xfers_add("DR", TR_DR);
    xfers_add("DWP", TR_DWP);
    xfers_add("ERTF", TR_ERTF);
    xfers_add("IBP", TR_IBP);
    xfers_add("INT", TR_INT);
    xfers_add("ITL", TR_ITL);
    xfers_add("MAE", TR_MAE);
    xfers_add("NDC", TR_NDC);
    xfers_add("OTR", TR_OTR);
    xfers_add("ONLINE TRANSACTION", TR_OTR);
    xfers_add("POC", TR_POC);
    xfers_add("POS", TR_POS);
    xfers_add("DEBIT CARD TRANSACTION", TR_POS);
    xfers_add("DEBIT CARD", TR_POS);
    xfers_add("SO", TR_SO);
    xfers_add("S/O", TR_SO);
    xfers_add("STANDING ORDER", TR_SO);
    xfers_add("SBT", TR_SBT);
    xfers_add("TEL", TR_TEL);
    xfers_add("TFR", TR_TFR);
    xfers_add("TLR", TR_TLR);
    xfers_add("VIS", TR_VIS);
    xfers_add("(((", TR_CONTACTLESS);
    {
        int n;
        for (n = TR_BALANCE; n < TR_XXX_LAST_XXX; ++n)
        {
            if (!get_transaction_str(n))
                fprintf(stderr,"ERROR: string not set for xfer id:%d\n",n);
        }
    }
}


original_code:
char* mon_val_brut(const char* str)
{
    char tmp[80];
    char* r = tmp;
    char* w = tmp;
    sscanf(str, "%[+-0123456789,. D]", tmp);
    while (*r != '\0')
    {
        if (*r != ',')
            *w++ = *r;
        ++r;
    }
    *w = *r;
    return strdup(tmp);
}

canonical_original_code:
char *mon_val_brut(char *str)
{
    char tmp[80];
    char *r = tmp;
    char *w = tmp;
    sscanf(str, "%[+-0123456789,. D]", tmp);
    while (*r != '\0')
    {
        if (*r != ',')
            *w++ = *r;
        ++r;
    }
    *w = *r;
    return strdup(tmp);
}

variable_types:
tmp
char [80]

variable_types:
r
char *

variable_types:
w
char *


decompiled_code:
__int64 __fastcall transaction_append(__int64 a1, __int64 a2, __int64 a3)
{
if ( a1 )
{
str_append_n(a1 + 16, a2, 40LL);
str_append_n(a1 + 56, a3, 80LL);
}
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, __int64 a3)
{
if ( a1 )
{
str_append_n(a1 + 16, a2, 40LL);
str_append_n(a1 + 56, a3, 80LL);
}
return a1;
}

original_code:
tran*
transaction_append(tran* tr, const char* type_str, const char* descr)
{
    if (!tr)
        return 0;
    str_append_n(tr->type_str, type_str, 40);
    str_append_n(tr->descr, descr, 80);
    return tr;
}

canonical_original_code:
struct transaction *transaction_append(struct transaction *tr, char *type_str, char *descr)
{
    if (!tr)
        return 0;
    str_append_n(tr->type_str, type_str, 40);
    str_append_n(tr->descr, descr, 80);
    return tr;
}

variable_types:
tr
struct transaction *

variable_types:
descr
char *

return_type: struct transaction { int day; int month; int year; int type; char type_str[40]; char descr[80]; int amt; int bal; struct transaction *next; } *


decompiled_code:
__int64 __fastcall month_to_int(char *s2)
{
__int64 v1; // rbx

if ( !s2 )
return 0xFFFFFFFFLL;
v1 = 0LL;
while ( strcasecmp(months[v1], s2) )
{
if ( ++v1 == 12 )
return 0xFFFFFFFFLL;
}
return (unsigned int)(v1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s2)
{
__int64 v1; // rbx

if ( !s2 )
return 0xFFFFFFFFLL;
v1 = 0LL;
while ( strcasecmp(months[v1], s2) )
{
if ( ++v1 == 12 )
return 0xFFFFFFFFLL;
}
return (unsigned int)(v1 + 1);
}

original_code:
int month_to_int(const char* str)
{
    int m;
    if (!str)
        return -1;
    for (m = 0; m < 12; ++m)
        if (strcasecmp(months[m], str) == 0)
            return m + 1;
    return -1;
}

canonical_original_code:
int month_to_int(char *str)
{
    int m;
    if (!str)
        return -1;
    for (m = 0; m < 12; ++m)
        if (strcasecmp(months[m], str) == 0)
            return m + 1;
    return -1;
}

variable_types: m int


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

if ( (unsigned int)(a1 - 1) > 0xB )
result = 0LL;
else
result = months[a1 - 1];
return result;
}

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

if ( (unsigned int)(a1 - 1) > 0xB )
result = 0LL;
else
result = months[a1 - 1];
return result;
}

original_code:
const char* int_to_month(int m)
{
    if (m < 1 || m > 12)
        return 0;
    return months[m - 1];
}

canonical_original_code:
char *int_to_month(int m)
{
    if (m < 1 || m > 12)
        return 0;
    return months[m - 1];
}


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

if ( (unsigned int)(a1 - 1) > 0xB )
result = 0LL;
else
result = months_full[a1 - 1];
return result;
}

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

if ( (unsigned int)(a1 - 1) > 0xB )
result = 0LL;
else
result = months_full[a1 - 1];
return result;
}

original_code:
const char* int_to_month_full(int m)
{
    if (m < 1 || m > 12)
        return 0;
    return months_full[m - 1];
}

canonical_original_code:
char *int_to_month_full(int m)
{
    if (m < 1 || m > 12)
        return 0;
    return months_full[m - 1];
}


decompiled_code:
size_t __fastcall str_append_n(const char *a1, const char *a2, int a3)
{
size_t v4; // rax
char *v5; // rbp
size_t v6; // r14
size_t result; // rax

v4 = strlen(a1);
v5 = (char *)&a1[v4];
if ( a1 < &a1[v4] )
*v5++ = 32;
v6 = strlen(a2);
strncpy(v5, a2, a3 - (v5 - a1));
a1[a3 - 1] = 0;
result = v6;
if ( a3 - (v5 - a1) <= v6 )
result = a3 - (v5 - a1);
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(const char *a1, const char *a2, int a3)
{
size_t v4; // rax
char *v5; // rbp
size_t v6; // r14
size_t result; // rax

v4 = strlen(a1);
v5 = (char *)&a1[v4];
if ( a1 < &a1[v4] )
*v5++ = 32;
v6 = strlen(a2);
strncpy(v5, a2, a3 - (v5 - a1));
a1[a3 - 1] = 0;
result = v6;
if ( a3 - (v5 - a1) <= v6 )
result = a3 - (v5 - a1);
return result;
}

original_code:
int str_append_n(char* buf, const char* src, int buf_len)
{
    size_t l1, l2;
    char* p = buf;
    p = buf + strlen(buf);
    if (p > buf)
        *p++ = ' ';
    l1 = buf_len - (p - buf);
    l2 = strlen(src);
    strncpy(p, src, l1);
    buf[buf_len - 1] = '\0';
    return (l2 < l1 ? l2 : l1);
}

canonical_original_code:
int str_append_n(char *buf, char *src, int buf_len)
{
    unsigned long l1; unsigned long l2;
    char *p = buf;
    p = buf + strlen(buf);
    if (p > buf)
        *p++ = ' ';
    l1 = buf_len - (p - buf);
    l2 = strlen(src);
    strncpy(p, src, l1);
    buf[buf_len - 1] = '\0';
    return (l2 < l1 ? l2 : l1);
}

variable_types:
buf
char *

variable_types:
src
char *

variable_types:
p
char *


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

result = strrchr(a1, 46);
if ( result )
{
if ( result[1] )
result = strdup(result + 1);
else
result = 0LL;
}
return result;
}

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

result = strrchr(a1, 46);
if ( result )
{
if ( result[1] )
result = strdup(result + 1);
else
result = 0LL;
}
return result;
}

original_code:
char* get_filename_ext(const char* fname)
{
    const char* d = strrchr(fname, '.');
    if (!d)
        return 0;
    ++d;
    if (*d == '\0')
        return 0;
    return strdup(d);
}

canonical_original_code:
char *get_filename_ext(char *fname)
{
    char *d = strrchr(fname, '.');
    if (!d)
        return 0;
    ++d;
    if (*d == '\0')
        return 0;
    return strdup(d);
}

variable_types:
fname
char *

variable_types:
d
char *


decompiled_code:
void __fastcall text_file_cleanup(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 64);
free(v2);
}
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

v1 = ptr;
while ( v1 )
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 64);
free(v2);
}
}

original_code:
void text_file_cleanup(txtline* tl)
{
    while(tl)
    {
        txtline* tmp = tl;
        tl = tl->next;
        free(tmp);
    }
}

canonical_original_code:
void text_file_cleanup(struct txtline *tl)
{
    while(tl)
    {
        struct txtline *tmp = tl;
        tl = tl->next;
        free(tmp);
    }
}

variable_types: struct txtline { char buf[512]; struct txtline *next; } *


terminate

decompiled_code:
void __noreturn terminate()
{
gpioTerminate();
fwrite("SIGHUP/SIGTERM received\n", 1uLL, 0x18uLL, errFifo);
fflush(0LL);
fclose(errFifo);
unlink("/dev/pigerr");
exit(0);
}

canonical_decompiled_code:
void __noreturn func0()
{
gpioTerminate();
fwrite("SIGHUP/SIGTERM received\n", 1uLL, 0x18uLL, errFifo);
fflush(0LL);
fclose(errFifo);
unlink("/dev/pigerr");
exit(0);
}

original_code:
void terminate(int signum)
{
   gpioTerminate();
   fprintf(errFifo, "SIGHUP/SIGTERM received\n");
   fflush(((void *)0));
   fclose(errFifo);
   unlink("/dev/pigerr");
   exit(0);
}

variable_types: signum int


usage

decompiled_code:
size_t usage()
{
return fwrite(
"\n"
"Usage: sudo pigpiod [OPTION] ...\n"
" -b value, gpio sample buffer in milliseconds, default 120\n"
" -d value, DMA channel, 0-14, default 14\n"
" -f, disable fifo interface, default enabled\n"
" -k, disable socket interface, default enabled\n"
" -p value, socket port, 1024-32000, default 8888\n"
" -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n"
" -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n"
" -u value, clock source, 0=OSC 1=PLLD, default PLLD\n"
"EXAMPLE\n"
"sudo pigpiod -s 2 -b 200 -f\n"
" Set a sample rate of 2 microseconds with a 200 millisecond\n"
" buffer. Disable the fifo interface.\n"
"\n",
1uLL,
0x29AuLL,
stderr);
}

canonical_decompiled_code:
size_t func1()
{
return fwrite(
"\n"
"Usage: sudo pigpiod [OPTION] ...\n"
" -b value, gpio sample buffer in milliseconds, default 120\n"
" -d value, DMA channel, 0-14, default 14\n"
" -f, disable fifo interface, default enabled\n"
" -k, disable socket interface, default enabled\n"
" -p value, socket port, 1024-32000, default 8888\n"
" -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n"
" -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n"
" -u value, clock source, 0=OSC 1=PLLD, default PLLD\n"
"EXAMPLE\n"
"sudo pigpiod -s 2 -b 200 -f\n"
" Set a sample rate of 2 microseconds with a 200 millisecond\n"
" buffer. Disable the fifo interface.\n"
"\n",
1uLL,
0x29AuLL,
stderr);
}

original_code:
void usage()
{
   fprintf(stderr, "\n" "Usage: sudo pigpiod [OPTION] ...\n" "   -b value, gpio sample buffer in milliseconds, default 120\n" "   -d value, DMA channel, 0-14,                  default 14\n" "   -f,       disable fifo interface,             default enabled\n" "   -k,       disable socket interface,           default enabled\n" "   -p value, socket port, 1024-32000,            default 8888\n" "   -s value, sample rate, 1, 2, 4, 5, 8, or 10,  default 5\n" "   -t value, clock peripheral, 0=PWM 1=PCM,      default PCM\n" "   -u value, clock source, 0=OSC 1=PLLD,         default PLLD\n" "EXAMPLE\n" "sudo pigpiod -s 2 -b 200 -f\n" "  Set a sample rate of 2 microseconds with a 200 millisecond\n" "  buffer.  Disable the fifo interface.\n" "\n");
}