decompiled_code:
__int64 mbt_toolbar_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtToolBar");
v1 = gtk_toolbar_get_type();
return g_type_register_static_simple(v1, v0, 872LL, mbt_toolbar_class_intern_init, 208LL, mbt_toolbar_init, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtToolBar");
v1 = gtk_toolbar_get_type();
return g_type_register_static_simple(v1, v0, 872LL, mbt_toolbar_class_intern_init, 208LL, mbt_toolbar_init, 0LL);
}

original_code: __attribute__((noinline)) static GType mbt_toolbar_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_toolbar_get_type ()), g_intern_static_string ("MbtToolBar"), sizeof (MbtToolBarClass), (GClassInitFunc)(void (*)(void)) mbt_toolbar_class_intern_init, sizeof (MbtToolBar), (GInstanceInitFunc)(void (*)(void)) mbt_toolbar_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_toolbar_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_toolbar_get_type ()), g_intern_static_string ("MbtToolBar"), sizeof (MbtToolBarClass), (GClassInitFunc)(void (*)(void)) mbt_toolbar_class_intern_init, sizeof (MbtToolBar), (GInstanceInitFunc)(void (*)(void)) mbt_toolbar_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

return_type: unsigned long


repo: moyeah/mbt

decompiled_code:
__int64 mbt_toolbar_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = mbt_toolbar_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

original_code: GType mbt_toolbar_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_toolbar_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_toolbar_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_toolbar_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_window_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtWindow");
v1 = gtk_window_get_type();
return g_type_register_static_simple(v1, v0, 904LL, mbt_window_class_intern_init, 272LL, mbt_window_init, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtWindow");
v1 = gtk_window_get_type();
return g_type_register_static_simple(v1, v0, 904LL, mbt_window_class_intern_init, 272LL, mbt_window_init, 0LL);
}

original_code: __attribute__((noinline)) static GType mbt_window_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_window_get_type ()), g_intern_static_string ("MbtWindow"), sizeof (MbtWindowClass), (GClassInitFunc)(void (*)(void)) mbt_window_class_intern_init, sizeof (MbtWindow), (GInstanceInitFunc)(void (*)(void)) mbt_window_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_window_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_window_get_type ()), g_intern_static_string ("MbtWindow"), sizeof (MbtWindowClass), (GClassInitFunc)(void (*)(void)) mbt_window_class_intern_init, sizeof (MbtWindow), (GInstanceInitFunc)(void (*)(void)) mbt_window_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_window_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_2 )
return g_define_type_id__volatile_2;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_2) )
{
v1 = mbt_window_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_2, v1);
}
return g_define_type_id__volatile_2;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_2 )
return g_define_type_id__volatile_2;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_2) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_2, v1);
}
return g_define_type_id__volatile_2;
}

original_code: GType mbt_window_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_window_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_window_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_window_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_connection_dialog_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtConnectionDialog");
v1 = gtk_dialog_get_type();
return g_type_register_static_simple(
v1,
v0,
952LL,
mbt_connection_dialog_class_intern_init,
264LL,
mbt_connection_dialog_init,
0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtConnectionDialog");
v1 = gtk_dialog_get_type();
return g_type_register_static_simple(
v1,
v0,
952LL,
mbt_connection_dialog_class_intern_init,
264LL,
mbt_connection_dialog_init,
0LL);
}

original_code: __attribute__((noinline)) static GType mbt_connection_dialog_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_dialog_get_type ()), g_intern_static_string ("MbtConnectionDialog"), sizeof (MbtConnectionDialogClass), (GClassInitFunc)(void (*)(void)) mbt_connection_dialog_class_intern_init, sizeof (MbtConnectionDialog), (GInstanceInitFunc)(void (*)(void)) mbt_connection_dialog_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_connection_dialog_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_dialog_get_type ()), g_intern_static_string ("MbtConnectionDialog"), sizeof (MbtConnectionDialogClass), (GClassInitFunc)(void (*)(void)) mbt_connection_dialog_class_intern_init, sizeof (MbtConnectionDialog), (GInstanceInitFunc)(void (*)(void)) mbt_connection_dialog_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_connection_dialog_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_2 )
return g_define_type_id__volatile_2;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_2) )
{
v1 = mbt_connection_dialog_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_2, v1);
}
return g_define_type_id__volatile_2;
}

original_code: GType mbt_connection_dialog_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_connection_dialog_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_connection_dialog_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_connection_dialog_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_mb_get_type_once()
{
__int64 v0; // rax

v0 = g_intern_static_string("MbtMB");
return g_type_register_static_simple(80LL, v0, 136LL, mbt_mb_class_intern_init, 32LL, mbt_mb_init, 0LL);
}

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

v0 = g_intern_static_string("MbtMB");
return g_type_register_static_simple(80LL, v0, 136LL, mbt_mb_class_intern_init, 32LL, mbt_mb_init, 0LL);
}

original_code: __attribute__((noinline)) static GType mbt_mb_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("MbtMB"), sizeof (MbtMBClass), (GClassInitFunc)(void (*)(void)) mbt_mb_class_intern_init, sizeof (MbtMB), (GInstanceInitFunc)(void (*)(void)) mbt_mb_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_mb_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple (((GType) ((20) << (2))), g_intern_static_string ("MbtMB"), sizeof (MbtMBClass), (GClassInitFunc)(void (*)(void)) mbt_mb_class_intern_init, sizeof (MbtMB), (GInstanceInitFunc)(void (*)(void)) mbt_mb_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_mb_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_2 )
return g_define_type_id__volatile_2;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_2) )
{
v1 = mbt_mb_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_2, v1);
}
return g_define_type_id__volatile_2;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_2 )
return g_define_type_id__volatile_2;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_2) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_2, v1);
}
return g_define_type_id__volatile_2;
}

original_code: GType mbt_mb_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_mb_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_mb_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_mb_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_mb_data_item_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMBDataItem");
v1 = mbt_mb_get_type();
return g_type_register_static_simple(
v1,
v0,
136LL,
mbt_mb_data_item_class_intern_init,
40LL,
mbt_mb_data_item_init,
0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMBDataItem");
v1 = mbt_mb_get_type();
return g_type_register_static_simple(
v1,
v0,
136LL,
mbt_mb_data_item_class_intern_init,
40LL,
mbt_mb_data_item_init,
0LL);
}

original_code: __attribute__((noinline)) static GType mbt_mb_data_item_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((mbt_mb_get_type ()), g_intern_static_string ("MbtMBDataItem"), sizeof (MbtMBDataItemClass), (GClassInitFunc)(void (*)(void)) mbt_mb_data_item_class_intern_init, sizeof (MbtMBDataItem), (GInstanceInitFunc)(void (*)(void)) mbt_mb_data_item_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_mb_data_item_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((mbt_mb_get_type ()), g_intern_static_string ("MbtMBDataItem"), sizeof (MbtMBDataItemClass), (GClassInitFunc)(void (*)(void)) mbt_mb_data_item_class_intern_init, sizeof (MbtMBDataItem), (GInstanceInitFunc)(void (*)(void)) mbt_mb_data_item_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_mb_data_item_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_3 )
return g_define_type_id__volatile_3;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_3) )
{
v1 = mbt_mb_data_item_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_3, v1);
}
return g_define_type_id__volatile_3;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_3 )
return g_define_type_id__volatile_3;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_3) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_3, v1);
}
return g_define_type_id__volatile_3;
}

original_code: GType mbt_mb_data_item_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_mb_data_item_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_mb_data_item_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_mb_data_item_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_menubar_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMenuBar");
v1 = gtk_menu_bar_get_type();
return g_type_register_static_simple(v1, v0, 952LL, mbt_menubar_class_intern_init, 216LL, mbt_menubar_init, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMenuBar");
v1 = gtk_menu_bar_get_type();
return g_type_register_static_simple(v1, v0, 952LL, mbt_menubar_class_intern_init, 216LL, mbt_menubar_init, 0LL);
}

original_code: __attribute__((noinline)) static GType mbt_menubar_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((gtk_menu_bar_get_type ()), g_intern_static_string ("MbtMenuBar"), sizeof (MbtMenuBarClass), (GClassInitFunc)(void (*)(void)) mbt_menubar_class_intern_init, sizeof (MbtMenuBar), (GInstanceInitFunc)(void (*)(void)) mbt_menubar_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_menubar_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((gtk_menu_bar_get_type ()), g_intern_static_string ("MbtMenuBar"), sizeof (MbtMenuBarClass), (GClassInitFunc)(void (*)(void)) mbt_menubar_class_intern_init, sizeof (MbtMenuBar), (GInstanceInitFunc)(void (*)(void)) mbt_menubar_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_menubar_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = mbt_menubar_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_0 )
return g_define_type_id__volatile_0;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_0) )
{
v1 = func0();
g_once_init_leave(&g_define_type_id__volatile_0, v1);
}
return g_define_type_id__volatile_0;
}

original_code: GType mbt_menubar_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_menubar_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_menubar_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_menubar_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_mb_device_get_type_once()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMBDevice");
v1 = mbt_mb_get_type();
return g_type_register_static_simple(v1, v0, 136LL, mbt_mb_device_class_intern_init, 40LL, mbt_mb_device_init, 0LL);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rbp
__int64 v1; // rax

v0 = g_intern_static_string("MbtMBDevice");
v1 = mbt_mb_get_type();
return g_type_register_static_simple(v1, v0, 136LL, mbt_mb_device_class_intern_init, 40LL, mbt_mb_device_init, 0LL);
}

original_code: __attribute__((noinline)) static GType mbt_mb_device_get_type_once (void) { GType g_define_type_id = g_type_register_static_simple ((mbt_mb_get_type ()), g_intern_static_string ("MbtMBDevice"), sizeof (MbtMBDeviceClass), (GClassInitFunc)(void (*)(void)) mbt_mb_device_class_intern_init, sizeof (MbtMBDevice), (GInstanceInitFunc)(void (*)(void)) mbt_mb_device_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }

canonical_original_code: static unsigned long mbt_mb_device_get_type_once() { unsigned long g_define_type_id = g_type_register_static_simple ((mbt_mb_get_type ()), g_intern_static_string ("MbtMBDevice"), sizeof (MbtMBDeviceClass), (GClassInitFunc)(void (*)(void)) mbt_mb_device_class_intern_init, sizeof (MbtMBDevice), (GInstanceInitFunc)(void (*)(void)) mbt_mb_device_init, (GTypeFlags) 0); { {{};} } return g_define_type_id; }


decompiled_code:
__int64 mbt_mb_device_get_type()
{
__int64 v1; // rax

if ( g_define_type_id__volatile_3 )
return g_define_type_id__volatile_3;
if ( (unsigned int)g_once_init_enter(&g_define_type_id__volatile_3) )
{
v1 = mbt_mb_device_get_type_once();
g_once_init_leave(&g_define_type_id__volatile_3, v1);
}
return g_define_type_id__volatile_3;
}

original_code: GType mbt_mb_device_get_type (void) { static volatile gsize g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); guint64 gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (gpointer) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { GType g_define_type_id = mbt_mb_device_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }

canonical_original_code: unsigned long mbt_mb_device_get_type() { static unsigned long g_define_type_id__volatile = 0; if ((__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? (gpointer) *(&g_define_type_id__volatile) : 0); (!(__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_2[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); unsigned long gapg_temp = __atomic_load_8 ((&g_define_type_id__volatile), 5); (void *) gapg_temp; })) && g_once_init_enter (&g_define_type_id__volatile)); }))) { unsigned long g_define_type_id = mbt_mb_device_get_type_once (); (__extension__ ({ typedef char _GStaticAssertCompileTimeAssertion_3[(sizeof *(&g_define_type_id__volatile) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__)); (void) (0 ? *(&g_define_type_id__volatile) = (g_define_type_id) : 0); g_once_init_leave ((&g_define_type_id__volatile), (gsize) (g_define_type_id)); })); } return g_define_type_id__volatile; }


decompiled_code:
__int64 mbt_mb_mode_get_type()
{
__int64 result; // rax
__int64 v1; // rax

result = etype_1;
if ( !etype_1 )
{
v1 = g_intern_static_string("MbtMBMode");
result = g_enum_register_static(v1, &values_0);
etype_1 = result;
}
return result;
}

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

result = etype_1;
if ( !etype_1 )
{
v1 = g_intern_static_string("MbtMBMode");
result = g_enum_register_static(v1, &values_0);
etype_1 = result;
}
return result;
}

original_code:
GType
mbt_mb_mode_get_type (void)
{
  static GType etype = 0;
  if ((etype == 0))
    {
      static const GEnumValue values[] = {
        { MBT_MB_RTU, "MBT_MB_RTU", "rtu" },
        { MBT_MB_ASCII, "MBT_MB_ASCII", "ascii" },
        { MBT_MB_TCPIP, "MBT_MB_TCPIP", "tcpip" },
        { 0, ((void *)0), ((void *)0) }
      };
      etype = g_enum_register_static (g_intern_static_string ("MbtMBMode"),
                                                                values);
    }
  return etype;
}

canonical_original_code:
unsigned long mbt_mb_mode_get_type()
{
  static unsigned long etype = 0;
  if ((etype == 0))
    {
      static struct _GEnumValue values[] = {
        { MBT_MB_RTU, "MBT_MB_RTU", "rtu" },
        { MBT_MB_ASCII, "MBT_MB_ASCII", "ascii" },
        { MBT_MB_TCPIP, "MBT_MB_TCPIP", "tcpip" },
        { 0, ((void *)0), ((void *)0) }
      };
      etype = g_enum_register_static (g_intern_static_string ("MbtMBMode"),
                                                                values);
    }
  return etype;
}

variable_types:
etype
unsigned long

variable_types: struct _GEnumValue { int value; char *value_name; char *value_nick; } []


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er8
int v4; // eax
int v5; // ebp
int v6; // er12
char *v7; // r14
char *v8; // rbx
__int64 v9; // rsi
unsigned int v10; // er15
int v12; // [rsp+4h] [rbp-2054h]
int v13; // [rsp+8h] [rbp-2050h]
int fd; // [rsp+Ch] [rbp-204Ch]
char *ptr; // [rsp+18h] [rbp-2040h]
char buf[8248]; // [rsp+20h] [rbp-2038h] BYREF

if ( argc <= 1 )
{
v6 = -1;
fprintf(stderr, "Usage: %s binary_file > output_file\n", *argv);
return v6;
}
fd = open(argv[1], 0, envp);
if ( fd == -1 )
{
v6 = -1;
fprintf(stderr, "%s: can't open %s for reading\n", *argv, argv[1]);
return v6;
}
ptr = (char *)make_ident(argv[1]);
printf("static const unsigned char %s[] = {", ptr);
v13 = 0;
v3 = 0;
LABEL_4:
while ( 2 )
{
v12 = v3;
v4 = read(fd, buf, 0x2000uLL);
v3 = v12;
v5 = v4;
v6 = v4;
if ( !v4 )
{
puts("\n};");
close(fd);
free(ptr);
return v6;
}
if ( v4 != -1 )
{
if ( v4 <= 0 )
continue;
v7 = buf;
v8 = &buf[v4 - 1 + 1];
while ( 1 )
{
v10 = v13 - (unsigned int)buf + (_DWORD)v7;
if ( v3 )
{
printf(", ");
if ( -1171354717 * v10 <= 0x1745D174 )
{
LABEL_12:
printf("\n\t");
goto LABEL_9;
}
}
else if ( -1171354717 * v10 <= 0x1745D174 )
{
goto LABEL_12;
}
LABEL_9:
v9 = (unsigned __int8)*v7++;
printf("0x%.2x", v9);
v3 = 1;
if ( v7 == v8 )
{
v13 += v5;
goto LABEL_4;
}
}
}
break;
}
fprintf(stderr, "%s: file read error\n", *argv);
return v6;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er8
int v4; // eax
int v5; // ebp
int v6; // er12
char *v7; // r14
char *v8; // rbx
__int64 v9; // rsi
unsigned int v10; // er15
int v12; // [rsp+4h] [rbp-2054h]
int v13; // [rsp+8h] [rbp-2050h]
int fd; // [rsp+Ch] [rbp-204Ch]
char *ptr; // [rsp+18h] [rbp-2040h]
char buf[8248]; // [rsp+20h] [rbp-2038h] BYREF

if ( argc <= 1 )
{
v6 = -1;
fprintf(stderr, "Usage: %s binary_file > output_file\n", *argv);
return v6;
}
fd = open(argv[1], 0, envp);
if ( fd == -1 )
{
v6 = -1;
fprintf(stderr, "%s: can't open %s for reading\n", *argv, argv[1]);
return v6;
}
ptr = (char *)func7(argv[1]);
printf("static const unsigned char %s[] = {", ptr);
v13 = 0;
v3 = 0;
LABEL_4:
while ( 2 )
{
v12 = v3;
v4 = read(fd, buf, 0x2000uLL);
v3 = v12;
v5 = v4;
v6 = v4;
if ( !v4 )
{
puts("\n};");
close(fd);
free(ptr);
return v6;
}
if ( v4 != -1 )
{
if ( v4 <= 0 )
continue;
v7 = buf;
v8 = &buf[v4 - 1 + 1];
while ( 1 )
{
v10 = v13 - (unsigned int)buf + (_DWORD)v7;
if ( v3 )
{
printf(", ");
if ( -1171354717 * v10 <= 0x1745D174 )
{
LABEL_12:
printf("\n\t");
goto LABEL_9;
}
}
else if ( -1171354717 * v10 <= 0x1745D174 )
{
goto LABEL_12;
}
LABEL_9:
v9 = (unsigned __int8)*v7++;
printf("0x%.2x", v9);
v3 = 1;
if ( v7 == v8 )
{
v13 += v5;
goto LABEL_4;
}
}
}
break;
}
fprintf(stderr, "%s: file read error\n", *argv);
return v6;
}

original_code:
int
main ( int argc, char* argv[] )
{
  unsigned char buf[8192];
  char* ident;
  int fd, i, total, rd, need_comma;
  if ( argc < 2 )
  {
    fprintf ( stderr, "Usage: %s binary_file > output_file\n", argv[0] );
    return -1;
  }
  fd = open ( argv[1], 00 );
  if ( fd == -1 )
  {
    fprintf ( stderr, "%s: can't open %s for reading\n", argv[0], argv[1] );
    return -1;
  }
  ident = make_ident ( argv[1] );
  printf ( "static const unsigned char %s[] = {", ident );
  for ( total = 0, need_comma = 0; ( rd = read ( fd, buf, 8192 ) ) != 0; )
  {
    if ( rd == -1 )
    {
      fprintf ( stderr, "%s: file read error\n", argv[0] );
      return -1;
    }
    for ( i = 0; i < rd; i++ )
    {
      if ( need_comma ) printf ( ", " );
      else need_comma = 1;
      if ( ( total % 11 ) == 0 ) printf ( "\n\t" );
      printf ( "0x%.2x", buf[i] );
      total++;
    }
  }
  printf ( "\n};\n" );
  close ( fd );
  free ( ident );
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
  unsigned char buf[8192];
  char *ident;
  int fd; int i; int total; int rd; int need_comma;
  if ( argc < 2 )
  {
    fprintf ( stderr, "Usage: %s binary_file > output_file\n", argv[0] );
    return -1;
  }
  fd = open ( argv[1], 00 );
  if ( fd == -1 )
  {
    fprintf ( stderr, "%s: can't open %s for reading\n", argv[0], argv[1] );
    return -1;
  }
  ident = make_ident ( argv[1] );
  printf ( "static const unsigned char %s[] = {", ident );
  for ( total = 0, need_comma = 0; ( rd = read ( fd, buf, 8192 ) ) != 0; )
  {
    if ( rd == -1 )
    {
      fprintf ( stderr, "%s: file read error\n", argv[0] );
      return -1;
    }
    for ( i = 0; i < rd; i++ )
    {
      if ( need_comma ) printf ( ", " );
      else need_comma = 1;
      if ( ( total % 11 ) == 0 ) printf ( "\n\t" );
      printf ( "0x%.2x", buf[i] );
      total++;
    }
  }
  printf ( "\n};\n" );
  close ( fd );
  free ( ident );
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
buf
unsigned char [8192]

variable_types:
ident
char *

variable_types: fd int

variable_types: i int

variable_types: total int

variable_types: rd int

return_type: int


decompiled_code:
char *__fastcall make_ident(const char *a1)
{
char *v1; // rax
__int64 v2; // rbx
char *v3; // r12
const unsigned __int16 *v4; // rdx
char *v5; // rax

v1 = strdup(a1);
v2 = *v1;
v3 = v1;
if ( (_BYTE)v2 )
{
v4 = *__ctype_b_loc();
v5 = v3;
do
{
if ( (v4[v2] & 8) == 0 )
*v5 = 95;
v2 = *++v5;
}
while ( (_BYTE)v2 );
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func7(const char *a1)
{
char *v1; // rax
__int64 v2; // rbx
char *v3; // r12
const unsigned __int16 *v4; // rdx
char *v5; // rax

v1 = strdup(a1);
v2 = *v1;
v3 = v1;
if ( (_BYTE)v2 )
{
v4 = *__ctype_b_loc();
v5 = v3;
do
{
if ( (v4[v2] & 8) == 0 )
*v5 = 95;
v2 = *++v5;
}
while ( (_BYTE)v2 );
}
return v3;
}

original_code:
char*
make_ident ( char* name )
{
  char* ret;
  char* p;
  ret = strdup ( name );
  for ( p = ret; p[0]; p++ )
  {
    if ( !((*__ctype_b_loc ())[(int) ((p[0]))] & (unsigned short int) _ISalnum) ) p[0] = '_';
  }
  return ret;
}

canonical_original_code:
char *make_ident(char *name)
{
  char *ret;
  char *p;
  ret = strdup ( name );
  for ( p = ret; p[0]; p++ )
  {
    if ( !((*__ctype_b_loc ())[(int) ((p[0]))] & (unsigned short) _ISalnum) ) p[0] = '_';
  }
  return ret;
}

variable_types:
name
char *

variable_types:
ret
char *

variable_types:
p
char *

return_type: char *


screenOff

repo: mozzwald/bldaemon-zipit

decompiled_code:
int screenOff()
{
int result; // eax

result = system("echo 1 >/sys/class/graphics/fb0/blank");
bScreenOff = 1;
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax

result = system("echo 1 >/sys/class/graphics/fb0/blank");
bScreenOff = 1;
return result;
}

original_code:
static inline void screenOff(){
 system("echo 1 >/sys/class/graphics/fb0/blank");
 bScreenOff = 1;
}

return_type: void


onTimer

decompiled_code:
int __fastcall onTimer(__int64 a1, __int64 a2)
{
int result; // eax

result = *(_DWORD *)(a2 + 24);
switch ( result )
{
case 201:
return screenOff();
case 301:
return system("/usr/local/sbin/onPowerDown");
case 101:
result = keysOff();
break;
}
return result;
}

canonical_decompiled_code:
int __fastcall func6(__int64 a1, __int64 a2)
{
int result; // eax

result = *(_DWORD *)(a2 + 24);
switch ( result )
{
case 201:
return func5();
case 301:
return system("/usr/local/sbin/onPowerDown");
case 101:
result = func3();
break;
}
return result;
}

original_code:
static void onTimer(int sig, siginfo_t *si, void *uc)
{
 switch(si->_sifields._rt.si_sigval.sival_int){
  case 101:
   keysOff();
   break;
  case 201:
   screenOff();
   break;
  case 301:
   system("/usr/local/sbin/onPowerDown");
   break;
  default:
   break;
 }
}

canonical_original_code:
static void onTimer(int sig, struct siginfo_t *si, void *uc)
{
 switch(si->_sifields._rt.si_sigval.sival_int){
  case 101:
   keysOff();
   break;
  case 201:
   screenOff();
   break;
  case 301:
   system("/usr/local/sbin/onPowerDown");
   break;
  default:
   break;
 }
}

variable_types: sig int

variable_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *

variable_types:
uc
void *

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


screenOn

decompiled_code:
void screenOn()
{
sigset_t v0; // [rsp+0h] [rbp-88h] BYREF

sigemptyset(&v0);
sigaddset(&v0, 14);
if ( sigprocmask(2, &v0, 0LL) == -1 )
perror("sigprocmask");
if ( bScreenOff )
{
system("echo 0 >/sys/class/graphics/fb0/blank");
bScreenOff = 0;
}
if ( sigprocmask(1, &v0, 0LL) == -1 )
perror("sigprocmask");
}

canonical_decompiled_code:
void func7()
{
sigset_t v0; // [rsp+0h] [rbp-88h] BYREF

sigemptyset(&v0);
sigaddset(&v0, 14);
if ( sigprocmask(2, &v0, 0LL) == -1 )
perror("sigprocmask");
if ( bScreenOff )
{
system("echo 0 >/sys/class/graphics/fb0/blank");
bScreenOff = 0;
}
if ( sigprocmask(1, &v0, 0LL) == -1 )
perror("sigprocmask");
}

original_code:
static inline void screenOn(){
 sigset_t mask;
 sigemptyset(&mask);
 sigaddset(&mask, 14);
 if (sigprocmask(2, &mask, ((void *)0)) == -1)
    perror("sigprocmask");
 if(bScreenOff){
  system("echo 0 >/sys/class/graphics/fb0/blank");
  bScreenOff = 0;
 }
   if (sigprocmask(1, &mask, ((void *)0)) == -1)
    perror("sigprocmask");
}

canonical_original_code:
static inline void screenOn(){
 struct __sigset_t mask;
 sigemptyset(&mask);
 sigaddset(&mask, 14);
 if (sigprocmask(2, &mask, ((void *)0)) == -1)
    perror("sigprocmask");
 if(bScreenOff){
  system("echo 0 >/sys/class/graphics/fb0/blank");
  bScreenOff = 0;
 }
   if (sigprocmask(1, &mask, ((void *)0)) == -1)
    perror("sigprocmask");
}

variable_types: struct __sigset_t { unsigned long __val[-1]; }


regoffset

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

result = 0LL;
if ( a1 > 31 )
{
result = 4LL;
if ( a1 > 63 )
{
result = 256LL;
if ( a1 <= 95 )
result = 8LL;
}
}
return result;
}

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

result = 0LL;
if ( a1 > 31 )
{
result = 4LL;
if ( a1 > 63 )
{
result = 256LL;
if ( a1 <= 95 )
result = 8LL;
}
}
return result;
}

original_code:
int regoffset(int gpio) {
 if (gpio < 32) return 0;
 if (gpio < 64) return 4;
 if (gpio < 96) return 8;
 return 0x100;
}

variable_types: gpio int


decompiled_code:
__int64 __fastcall gpio_read(__int64 a1, int a2)
{
int v2; // eax
char v3; // cl
__int64 v4; // r8

v2 = regoffset(a2);
return (*(_QWORD *)(v2 + v4) >> (v3 & 0x1F)) & 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
int v2; // eax
char v3; // cl
__int64 v4; // r8

v2 = func9(a2);
return (*(_QWORD *)(v2 + v4) >> (v3 & 0x1F)) & 1LL;
}

original_code:
int gpio_read(void *map_base, int gpio) {
 volatile u32 *reg = (u32*)((u32)map_base + regoffset(gpio));
 return (*reg >> (gpio&31)) & 1;
}

canonical_original_code:
int gpio_read(void *map_base, int gpio) {
 unsigned long *reg = (u32*)((u32)map_base + regoffset(gpio));
 return (*reg >> (gpio&31)) & 1;
}

variable_types:
reg
unsigned long *


lidstate

decompiled_code:
__int64 lidstate()
{
int v0; // eax
int v1; // ebp
void *v2; // rax
unsigned int v3; // eax
void *v4; // r9
unsigned int v5; // er12

v0 = open("/dev/mem", 1052672);
if ( v0 < 0 )
{
printf("Please run as root");
exit(1);
}
v1 = v0;
v2 = mmap(0LL, 0x1000uLL, 1, 1, v0, 1088421888LL);
if ( v2 == (void *)-1LL )
goto LABEL_8;
v3 = gpio_read((__int64)v2, 98);
v5 = v3;
if ( v3 && v3 != 1 )
v5 = 255;
if ( munmap(v4, 0x1000uLL) == -1 )
LABEL_8:
exit(255);
close(v1);
return v5;
}

canonical_decompiled_code:
__int64 func11()
{
int v0; // eax
int v1; // ebp
void *v2; // rax
unsigned int v3; // eax
void *v4; // r9
unsigned int v5; // er12

v0 = open("/dev/mem", 1052672);
if ( v0 < 0 )
{
printf("Please run as root");
exit(1);
}
v1 = v0;
v2 = mmap(0LL, 0x1000uLL, 1, 1, v0, 1088421888LL);
if ( v2 == (void *)-1LL )
goto LABEL_8;
v3 = func10((__int64)v2, 98);
v5 = v3;
if ( v3 && v3 != 1 )
v5 = 255;
if ( munmap(v4, 0x1000uLL) == -1 )
LABEL_8:
exit(255);
close(v1);
return v5;
}

original_code:
int lidstate() {
 int fd;
 int retval;
 void *map_base;
 fd = open("/dev/mem", 00 | 04010000);
    if (fd < 0) {printf("Please run as root"); exit(1);}
     map_base = mmap(0, 4096UL, 0x1, 0x01, fd, 0x40E00000);
 if(map_base == (void *) -1) exit(255);
 switch(gpio_read(map_base,98))
 {
  case 0:
   retval = 0;
   break;
  case 1:
   retval = 1;
   break;
  default:
   retval = 255;
 }
 if(munmap(map_base, 4096UL) == -1) exit(255) ;
 close(fd);
 return retval;
}

variable_types: retval int


powerstate

decompiled_code:
__int64 powerstate()
{
int v0; // eax
int v1; // ebp
void *v2; // rax
unsigned int v3; // eax
void *v4; // r9
unsigned int v5; // er12

v0 = open("/dev/mem", 1052672);
if ( v0 < 0 )
{
printf("Please run as root");
exit(1);
}
v1 = v0;
v2 = mmap(0LL, 0x1000uLL, 1, 1, v0, 1088421888LL);
if ( v2 == (void *)-1LL )
goto LABEL_8;
v3 = gpio_read((__int64)v2, 0);
v5 = v3;
if ( v3 && v3 != 1 )
v5 = 255;
if ( munmap(v4, 0x1000uLL) == -1 )
LABEL_8:
exit(255);
close(v1);
return v5;
}

canonical_decompiled_code:
__int64 func12()
{
int v0; // eax
int v1; // ebp
void *v2; // rax
unsigned int v3; // eax
void *v4; // r9
unsigned int v5; // er12

v0 = open("/dev/mem", 1052672);
if ( v0 < 0 )
{
printf("Please run as root");
exit(1);
}
v1 = v0;
v2 = mmap(0LL, 0x1000uLL, 1, 1, v0, 1088421888LL);
if ( v2 == (void *)-1LL )
goto LABEL_8;
v3 = func10((__int64)v2, 0);
v5 = v3;
if ( v3 && v3 != 1 )
v5 = 255;
if ( munmap(v4, 0x1000uLL) == -1 )
LABEL_8:
exit(255);
close(v1);
return v5;
}

original_code:
int powerstate() {
        int fd;
        int retval;
        void *map_base;
        fd = open("/dev/mem", 00 | 04010000);
        if (fd < 0) {printf("Please run as root"); exit(1);}
        map_base = mmap(0, 4096UL, 0x1, 0x01, fd, 0x40E00000);
        if(map_base == (void *) -1) exit(255);
        switch(gpio_read(map_base,0))
        {
                case 0:
                        retval = 0;
   break;
                case 1:
                        retval = 1;
                        break;
                default:
   retval = 255;
        }
        if(munmap(map_base, 4096UL) == -1) exit(255) ;
        close(fd);
        return retval;
}


decompiled_code:
timer_t __fastcall create_timer(int a1, unsigned int a2)
{
int v2; // er8
timer_t result; // rax
timer_t timerid; // [rsp+8h] [rbp-110h] BYREF
struct itimerspec value; // [rsp+10h] [rbp-108h] BYREF
struct sigevent evp; // [rsp+30h] [rbp-E8h] BYREF
struct sigaction v7; // [rsp+70h] [rbp-A8h] BYREF

evp.sigev_value.sival_int = a1;
value.it_value.tv_nsec = 0LL;
value.it_interval.tv_sec = 0LL;
value.it_interval.tv_nsec = 0LL;
*(_QWORD *)&evp.sigev_signo = 14LL;
value.it_value.tv_sec = a2 / 0x64;
v7.sa_flags = 4;
v7.sa_handler = (__sighandler_t)onTimer;
timerid = 0LL;
sigemptyset(&v7.sa_mask);
if ( sigaction(14, &v7, 0LL) == -1 )
{
perror("sigaction");
result = 0LL;
}
else if ( timer_create(1, &evp, &timerid) == -1 )
{
perror("timer_create");
result = 0LL;
}
else
{
v2 = timer_settime(timerid, 0, &value, 0LL);
result = timerid;
if ( v2 == -1 )
{
perror("timer_settime");
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
timer_t __fastcall func20(int a1, unsigned int a2)
{
int v2; // er8
timer_t result; // rax
timer_t timerid; // [rsp+8h] [rbp-110h] BYREF
struct itimerspec value; // [rsp+10h] [rbp-108h] BYREF
struct sigevent evp; // [rsp+30h] [rbp-E8h] BYREF
struct sigaction v7; // [rsp+70h] [rbp-A8h] BYREF

evp.sigev_value.sival_int = a1;
value.it_value.tv_nsec = 0LL;
value.it_interval.tv_sec = 0LL;
value.it_interval.tv_nsec = 0LL;
*(_QWORD *)&evp.sigev_signo = 14LL;
value.it_value.tv_sec = a2 / 0x64;
v7.sa_flags = 4;
v7.sa_handler = (__sighandler_t)onTimer;
timerid = 0LL;
sigemptyset(&v7.sa_mask);
if ( sigaction(14, &v7, 0LL) == -1 )
{
perror("sigaction");
result = 0LL;
}
else if ( timer_create(1, &evp, &timerid) == -1 )
{
perror("timer_create");
result = 0LL;
}
else
{
v2 = timer_settime(timerid, 0, &value, 0LL);
result = timerid;
if ( v2 == -1 )
{
perror("timer_settime");
result = 0LL;
}
}
return result;
}

original_code:
timer_t create_timer(int timerName, unsigned int freq_msecs)
{
    struct itimerspec its;
      its.it_value.tv_sec = freq_msecs / 100;
      its.it_value.tv_nsec = 0;
      its.it_interval.tv_sec = 0;
      its.it_interval.tv_nsec = 0;
 struct sigevent sev;
      sev.sigev_notify = SIGEV_SIGNAL;
      sev.sigev_signo = 14;
      sev.sigev_value.sival_int = timerName;
 struct sigaction sa;
      sa.sa_flags = 4;
      sa.__sigaction_handler.sa_sigaction = onTimer;
 timer_t timerid=0;
 sigemptyset(&sa.sa_mask);
 if (sigaction(14, &sa, ((void *)0)) == -1)
  do { perror("sigaction"); return 0; } while (0);
 if (timer_create(1, &sev, &timerid) == -1)
  do { perror("timer_create"); return 0; } while (0);
   if (timer_settime(timerid, 0, &its, ((void *)0)) == -1)
         do { perror("timer_settime"); return 0; } while (0);
   return timerid;
}

canonical_original_code:
void *create_timer(int timerName, unsigned int freq_msecs)
{
    struct itimerspec its;
      its.it_value.tv_sec = freq_msecs / 100;
      its.it_value.tv_nsec = 0;
      its.it_interval.tv_sec = 0;
      its.it_interval.tv_nsec = 0;
 struct sigevent sev;
      sev.sigev_notify = SIGEV_SIGNAL;
      sev.sigev_signo = 14;
      sev.sigev_value.sival_int = timerName;
 struct sigaction sa;
      sa.sa_flags = 4;
      sa.__sigaction_handler.sa_sigaction = onTimer;
 void *timerid = 0;
 sigemptyset(&sa.sa_mask);
 if (sigaction(14, &sa, ((void *)0)) == -1)
  do { perror("sigaction"); return 0; } while (0);
 if (timer_create(1, &sev, &timerid) == -1)
  do { perror("timer_create"); return 0; } while (0);
   if (timer_settime(timerid, 0, &its, ((void *)0)) == -1)
         do { perror("timer_settime"); return 0; } while (0);
   return timerid;
}

variable_types: timerName int

variable_types: struct itimerspec { struct timespec { long tv_sec; long tv_nsec; } it_interval; struct timespec it_value; }

variable_types: struct sigevent { union sigval { int sival_int; void *sival_ptr; } sigev_value; int sigev_signo; int sigev_notify; union { int _pad[-1]; int _tid; struct { void (*_function)(union sigval); union pthread_attr_t { char __size[56]; long __align; } *_attribute; } _sigev_thread; } _sigev_un; }

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

variable_types:
timerid
void *

return_type: void *

user_defined_types: struct itimerspec { struct timespec it_interval; struct timespec it_value; }

user_defined_types: struct sigevent { union sigval sigev_value; int sigev_signo; int sigev_notify; union { int _pad[-1]; int _tid; struct { void (*_function)(union sigval); union pthread_attr_t *_attribute; } _sigev_thread; } _sigev_un; }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // edi
unsigned int v4; // er15
unsigned int v5; // er14
__int64 v6; // rsi
__int64 v7; // rdi
unsigned int v8; // er13
unsigned int v9; // er12
int v10; // ebp
int v11; // ebx
int *v12; // rax
char *v13; // rax

system("echo -ne \"\\033[9;0]\" >/dev/tty0");
v3 = 512;
if ( (unsigned int)powerstate("echo -ne \"\\033[9;0]\" >/dev/tty0", argv) != 1 )
v3 = 300;
keyb(v3);
keys_timerid = (__int64)create_timer(101, 0x1F4u);
lcd_timerid = (__int64)create_timer(201, 0x1770u);
power_timerid = (__int64)create_timer(301, 0);
signal(3, (__sighandler_t)powerDown);
signal(2, (__sighandler_t)suspend);
signal(10, (__sighandler_t)newMsg);
evfd = open("/dev/input/event0", 0);
if ( evfd != -1 )
{
v4 = 300;
v5 = 512;
pthread_mutex_init(&lock, 0LL);
v6 = 0LL;
v7 = (unsigned int)((_DWORD)&get_keypressed + 8);
v8 = 512;
v9 = 1023;
v10 = 255;
pthread_create((pthread_t *)v7, 0LL, GetKeyPressed, 0LL);
v11 = 255;
while ( 1 )
{
if ( v10 )
{
if ( !newMsg || wasKeyPressed != 1 )
goto LABEL_10;
}
else
{
if ( wasKeyPressed != 1 )
goto LABEL_10;
set_timer_isra_0((void *)keys_timerid, 0x1F4u);
v7 = lcd_timerid;
v6 = 6000LL;
set_timer_isra_0((void *)lcd_timerid, 0x1770u);
wasKeyPressed = 0;
screenOn();
}
if ( newMsg && valkeyb )
{
keyb(valkeyb);
v7 = 0LL;
toggleLED(0);
valkeyb = 0;
newMsg = 0;
}
LABEL_10:
if ( newMsg )
{
if ( !valkeyb )
valkeyb = getkeyb();
toggleLED(flashKeyBrd);
if ( flashKeyBrd )
{
v7 = (unsigned int)valkeyb;
keyb(valkeyb);
flashKeyBrd = 0;
}
else
{
v7 = 0LL;
keyb(0);
flashKeyBrd = 1;
}
}
if ( powerDown && !suspend )
{
v7 = power_timerid;
v6 = 300LL;
set_timer_isra_0((void *)power_timerid, 0x12Cu);
powerDown = 0;
}
if ( suspend )
{
v7 = power_timerid;
v6 = 0LL;
set_timer_isra_0((void *)power_timerid, 0);
suspend = 0;
powerDown = 0;
}
if ( (unsigned int)powerstate(v7, v6) != v10 )
{
v10 = powerstate(v7, v6);
if ( v10 )
{
screenOn();
set_timer_isra_0((void *)keys_timerid, 0);
v6 = 0LL;
set_timer_isra_0((void *)lcd_timerid, 0);
v5 = getscr();
v4 = getkeyb();
keysOn();
lcdb(v9);
keyb(v8);
}
else
{
set_timer_isra_0((void *)keys_timerid, 0x1F4u);
v6 = 6000LL;
set_timer_isra_0((void *)lcd_timerid, 0x1770u);
v9 = getscr();
v8 = getkeyb();
lcdb(v5);
keyb(v4);
}
}
if ( (unsigned int)lidstate() != v11 )
{
v11 = lidstate();
lightswitch(v11);
}
v7 = 1LL;
sleep(1u);
}
}
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "Cannot open %s: %s.\n", "/dev/input/event0", v13);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // edi
unsigned int v4; // er15
unsigned int v5; // er14
__int64 v6; // rsi
__int64 v7; // rdi
unsigned int v8; // er13
unsigned int v9; // er12
int v10; // ebp
int v11; // ebx
int *v12; // rax
char *v13; // rax

system("echo -ne \"\\033[9;0]\" >/dev/tty0");
v3 = 512;
if ( (unsigned int)func12("echo -ne \"\\033[9;0]\" >/dev/tty0", argv) != 1 )
v3 = 300;
func15(v3);
keys_timerid = (__int64)func20(101, 0x1F4u);
lcd_timerid = (__int64)func20(201, 0x1770u);
power_timerid = (__int64)func20(301, 0);
signal(3, (__sighandler_t)powerDown);
signal(2, (__sighandler_t)suspend);
signal(10, (__sighandler_t)newMsg);
evfd = open("/dev/input/event0", 0);
if ( evfd != -1 )
{
v4 = 300;
v5 = 512;
pthread_mutex_init(&lock, 0LL);
v6 = 0LL;
v7 = (unsigned int)((_DWORD)&get_keypressed + 8);
v8 = 512;
v9 = 1023;
v10 = 255;
pthread_create((pthread_t *)v7, 0LL, GetKeyPressed, 0LL);
v11 = 255;
while ( 1 )
{
if ( v10 )
{
if ( !newMsg || wasKeyPressed != 1 )
goto LABEL_10;
}
else
{
if ( wasKeyPressed != 1 )
goto LABEL_10;
func8((void *)keys_timerid, 0x1F4u);
v7 = lcd_timerid;
v6 = 6000LL;
func8((void *)lcd_timerid, 0x1770u);
wasKeyPressed = 0;
func7();
}
if ( newMsg && valkeyb )
{
func15(valkeyb);
v7 = 0LL;
func16(0);
valkeyb = 0;
newMsg = 0;
}
LABEL_10:
if ( newMsg )
{
if ( !valkeyb )
valkeyb = func18();
func16(flashKeyBrd);
if ( flashKeyBrd )
{
v7 = (unsigned int)valkeyb;
func15(valkeyb);
flashKeyBrd = 0;
}
else
{
v7 = 0LL;
func15(0);
flashKeyBrd = 1;
}
}
if ( powerDown && !suspend )
{
v7 = power_timerid;
v6 = 300LL;
func8((void *)power_timerid, 0x12Cu);
powerDown = 0;
}
if ( suspend )
{
v7 = power_timerid;
v6 = 0LL;
func8((void *)power_timerid, 0);
suspend = 0;
powerDown = 0;
}
if ( (unsigned int)func12(v7, v6) != v10 )
{
v10 = func12(v7, v6);
if ( v10 )
{
func7();
func8((void *)keys_timerid, 0);
v6 = 0LL;
func8((void *)lcd_timerid, 0);
v5 = func17();
v4 = func18();
func19();
func14(v9);
func15(v8);
}
else
{
func8((void *)keys_timerid, 0x1F4u);
v6 = 6000LL;
func8((void *)lcd_timerid, 0x1770u);
v9 = func17();
v8 = func18();
func14(v5);
func15(v4);
}
}
if ( (unsigned int)func11() != v11 )
{
v11 = func11();
func13(v11);
}
v7 = 1LL;
sleep(1u);
}
}
v12 = _errno_location();
v13 = strerror(*v12);
fprintf(stderr, "Cannot open %s: %s.\n", "/dev/input/event0", v13);
return 1;
}

original_code:
int main(int argc, char **argv) {
 int lid = 255;
 int power = 255;
 int brightscr=1023;
 int brightkeyb=512;
 int dimscr=512;
 int dimkeyb=300;
 int keyTimer = 0;
 system("echo -ne \"\\033[9;0]\" >/dev/tty0");
 keyb(powerstate() == 1?brightkeyb:dimkeyb);
 keys_timerid = create_timer(101, 500);
 lcd_timerid = create_timer(201, 6000);
 power_timerid = create_timer(301, 0);
 signal(3, _powerDown);
 signal(2, _suspend);
 signal(10, _newMsg);
 const char *evdev = "/dev/input/event0";
    evfd = open(evdev, 00);
    if (evfd == -1) {
        fprintf(stderr, "Cannot open %s: %s.\n", evdev, strerror((*__errno_location ())));
        return 1;
    }
 pthread_mutex_init(&lock, ((void *)0));
 pthread_create(&(get_keypressed[1]), ((void *)0), &GetKeyPressed, ((void *)0));
 while(1) {
  if( (!power || newMsg) && wasKeyPressed == 1)
  {
   if(!power){
    set_timer(keys_timerid, 500);
    set_timer(lcd_timerid, 6000);
    wasKeyPressed = 0;
    screenOn();
   }
   if(newMsg && valkeyb){
    keyb(valkeyb);
    toggleLED(0);
    valkeyb = 0;
    newMsg = 0;
   }
  }
  if(newMsg){
   if(!valkeyb)
    valkeyb = getkeyb();
   toggleLED(flashKeyBrd);
   if(flashKeyBrd){
    keyb(valkeyb);
    flashKeyBrd=0;
   }
   else{
    keyb(0);
    flashKeyBrd=1;
   }
  }
  if(powerDown && !suspend)
  {
   set_timer(power_timerid, 300);
   powerDown = 0;
  }
  if(suspend)
  {
   set_timer(power_timerid, 0);
   suspend = 0;
   powerDown = 0;
  }
  if(power != powerstate())
  {
   keyTimer = 0;
   power = powerstate();
   if (power) {
    screenOn();
    set_timer(keys_timerid, 0);
    set_timer(lcd_timerid, 0);
    dimscr = getscr();
    dimkeyb = getkeyb();
    keysOn();
    lcdb(brightscr);
    keyb(brightkeyb);
   }
   else{
    set_timer(keys_timerid, 500);
    set_timer(lcd_timerid, 6000);
    brightscr = getscr();
    brightkeyb = getkeyb();
    lcdb(dimscr);
    keyb(dimkeyb);
   }
  }
  if(lid != lidstate())
  {
   lid = lidstate();
   lightswitch(lid);
  }
  sleep(1);
 }
}

canonical_original_code:
int main(int argc, char **argv) {
 int lid = 255;
 int power = 255;
 int brightscr = 1023;
 int brightkeyb = 512;
 int dimscr = 512;
 int dimkeyb = 300;
 int keyTimer = 0;
 system("echo -ne \"\\033[9;0]\" >/dev/tty0");
 keyb(powerstate() == 1?brightkeyb:dimkeyb);
 keys_timerid = create_timer(101, 500);
 lcd_timerid = create_timer(201, 6000);
 power_timerid = create_timer(301, 0);
 signal(3, _powerDown);
 signal(2, _suspend);
 signal(10, _newMsg);
 char *evdev = "/dev/input/event0";
    evfd = open(evdev, 00);
    if (evfd == -1) {
        fprintf(stderr, "Cannot open %s: %s.\n", evdev, strerror((*__errno_location ())));
        return 1;
    }
 pthread_mutex_init(&lock, ((void *)0));
 pthread_create(&(get_keypressed[1]), ((void *)0), &GetKeyPressed, ((void *)0));
 while(1) {
  if( (!power || newMsg) && wasKeyPressed == 1)
  {
   if(!power){
    set_timer(keys_timerid, 500);
    set_timer(lcd_timerid, 6000);
    wasKeyPressed = 0;
    screenOn();
   }
   if(newMsg && valkeyb){
    keyb(valkeyb);
    toggleLED(0);
    valkeyb = 0;
    newMsg = 0;
   }
  }
  if(newMsg){
   if(!valkeyb)
    valkeyb = getkeyb();
   toggleLED(flashKeyBrd);
   if(flashKeyBrd){
    keyb(valkeyb);
    flashKeyBrd=0;
   }
   else{
    keyb(0);
    flashKeyBrd=1;
   }
  }
  if(powerDown && !suspend)
  {
   set_timer(power_timerid, 300);
   powerDown = 0;
  }
  if(suspend)
  {
   set_timer(power_timerid, 0);
   suspend = 0;
   powerDown = 0;
  }
  if(power != powerstate())
  {
   keyTimer = 0;
   power = powerstate();
   if (power) {
    screenOn();
    set_timer(keys_timerid, 0);
    set_timer(lcd_timerid, 0);
    dimscr = getscr();
    dimkeyb = getkeyb();
    keysOn();
    lcdb(brightscr);
    keyb(brightkeyb);
   }
   else{
    set_timer(keys_timerid, 500);
    set_timer(lcd_timerid, 6000);
    brightscr = getscr();
    brightkeyb = getkeyb();
    lcdb(dimscr);
    keyb(dimkeyb);
   }
  }
  if(lid != lidstate())
  {
   lid = lidstate();
   lightswitch(lid);
  }
  sleep(1);
 }
}

variable_types: argc int

variable_types:
argv
char **

variable_types: lid int

variable_types: power int

variable_types: brightscr int

variable_types: brightkeyb int

variable_types: dimscr int

variable_types: dimkeyb int

variable_types: keyTimer int

variable_types:
evdev
char *


repo: mph-/mmculib

decompiled_code:
__int64 __fastcall fat_search(__int64 a1, _BYTE *a2, unsigned int *a3)
{
char *v4; // rbx
char v5; // al
char *v6; // rdx
unsigned int v7; // er12
char v9[72]; // [rsp+0h] [rbp-48h] BYREF

if ( a2 && *a2 )
{
v4 = &a2[*a2 == 47];
*a3 = *(_DWORD *)(a1 + 52);
v5 = *v4;
while ( 1 )
{
if ( !v5 )
return 1;
v6 = v9;
do
{
if ( v5 == 47 )
break;
++v4;
*v6++ = v5;
v5 = *v4;
}
while ( *v4 );
*v6 = 0;
if ( !v9[0] )
return 0LL;
v7 = fat_de_find(a1, *a3, v9, a3);
if ( !v7 )
break;
v5 = *v4;
if ( *v4 == 47 )
{
v7 = a3[72];
if ( !v7 )
{
fprintf(stderr, "FAT:%s not a dir\n", v9);
return v7;
}
if ( !v4[1] )
return 1;
*a3 = a3[1];
v5 = *++v4;
}
}
fprintf(stderr, "FAT:%s not found\n", v9);
if ( *v4 == 47 )
{
*a3 = 0;
return v7;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _BYTE *a2, unsigned int *a3)
{
char *v4; // rbx
char v5; // al
char *v6; // rdx
unsigned int v7; // er12
char v9[72]; // [rsp+0h] [rbp-48h] BYREF

if ( a2 && *a2 )
{
v4 = &a2[*a2 == 47];
*a3 = *(_DWORD *)(a1 + 52);
v5 = *v4;
while ( 1 )
{
if ( !v5 )
return 1;
v6 = v9;
do
{
if ( v5 == 47 )
break;
++v4;
*v6++ = v5;
v5 = *v4;
}
while ( *v4 );
*v6 = 0;
if ( !v9[0] )
return 0LL;
v7 = fat_de_find(a1, *a3, v9, a3);
if ( !v7 )
break;
v5 = *v4;
if ( *v4 == 47 )
{
v7 = a3[72];
if ( !v7 )
{
fprintf(stderr, "FAT:%s not a dir\n", v9);
return v7;
}
if ( !v4[1] )
return 1;
*a3 = a3[1];
v5 = *++v4;
}
}
fprintf(stderr, "FAT:%s not found\n", v9);
if ( *v4 == 47 )
{
*a3 = 0;
return v7;
}
}
return 0LL;
}

original_code:
bool
fat_search (fat_t *fat, const char *pathname, fat_ff_t *ff)
{
    const char *p;
    char *q;
    char tmp[32];
    if (pathname == ((void *)0) || !*pathname)
        return 0;
    p = pathname;
    if (*p == '/')
        p++;
    ff->parent_dir_cluster = fat->root_dir_cluster;
    while (*p)
    {
        q = tmp;
        while (*p && *p != '/')
            *q++ = *p++;
        *q = 0;
        if (!*tmp)
            return 0;
        if (!fat_de_find (fat, ff->parent_dir_cluster, tmp, ff))
        {
            fprintf (stderr, "FAT:%s not found\n", tmp);
            if (*p == '/')
                ff->parent_dir_cluster = 0;
            return 0;
        }
        if (*p == '/')
        {
            p++;
            if (!ff->isdir)
            {
                fprintf (stderr, "FAT:%s not a dir\n", tmp);
                return 0;
            }
            if (*p)
                ff->parent_dir_cluster = ff->cluster;
        }
    }
    return 1;
}

canonical_original_code:
int fat_search(struct fat_struct *fat, char *pathname, struct fat_ff_struct *ff)
{
    char *p;
    char *q;
    char tmp[32];
    if (pathname == ((void *)0) || !*pathname)
        return 0;
    p = pathname;
    if (*p == '/')
        p++;
    ff->parent_dir_cluster = fat->root_dir_cluster;
    while (*p)
    {
        q = tmp;
        while (*p && *p != '/')
            *q++ = *p++;
        *q = 0;
        if (!*tmp)
            return 0;
        if (!fat_de_find (fat, ff->parent_dir_cluster, tmp, ff))
        {
            fprintf (stderr, "FAT:%s not found\n", tmp);
            if (*p == '/')
                ff->parent_dir_cluster = 0;
            return 0;
        }
        if (*p == '/')
        {
            p++;
            if (!ff->isdir)
            {
                fprintf (stderr, "FAT:%s not a dir\n", tmp);
                return 0;
            }
            if (*p)
                ff->parent_dir_cluster = ff->cluster;
        }
    }
    return 1;
}

variable_types: struct fat_struct { void *dev; unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size); unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size); enum fat_fs_type_t { FAT_UNKNOWN=0, FAT_FAT12=1, FAT_FAT16=2, FAT_FAT32=3 } type; unsigned int first_sector; unsigned int fsinfo_sector; unsigned int first_fat_sector; unsigned int first_data_sector; unsigned int num_fat_sectors; unsigned int first_dir_sector; unsigned int root_dir_cluster; unsigned int num_clusters; unsigned int free_clusters; unsigned int prev_free_cluster; unsigned short root_dir_sectors; unsigned short bytes_per_sector; unsigned short bytes_per_cluster; unsigned short sectors_per_cluster; struct fat_io_cache_struct { unsigned int sector; unsigned char buffer[512]; int dirty; } cache; int fsinfo_dirty; } *

variable_types:
pathname
char *

variable_types: struct fat_ff_struct { unsigned int parent_dir_cluster; unsigned int cluster; unsigned int size; struct fat_dir_struct { unsigned int sector; unsigned short offset; } dir; unsigned char short_name[12]; char name[256]; int isdir; } *

variable_types:
p
char *

variable_types:
q
char *

variable_types:
tmp
char [32]

user_defined_types: struct fat_struct { void *dev; unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size); unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size); enum fat_fs_type_t type; unsigned int first_sector; unsigned int fsinfo_sector; unsigned int first_fat_sector; unsigned int first_data_sector; unsigned int num_fat_sectors; unsigned int first_dir_sector; unsigned int root_dir_cluster; unsigned int num_clusters; unsigned int free_clusters; unsigned int prev_free_cluster; unsigned short root_dir_sectors; unsigned short bytes_per_sector; unsigned short bytes_per_cluster; unsigned short sectors_per_cluster; struct fat_io_cache_struct cache; int fsinfo_dirty; }

user_defined_types: struct fat_ff_struct { unsigned int parent_dir_cluster; unsigned int cluster; unsigned int size; struct fat_dir_struct dir; unsigned char short_name[12]; char name[256]; int isdir; }


decompiled_code:
__int64 __fastcall fat_unlink(__int64 a1, char *a2)
{
unsigned int v2; // er12
unsigned int v4[3]; // [rsp+0h] [rbp-148h] BYREF
char v5[276]; // [rsp+Ch] [rbp-13Ch] BYREF
unsigned int v6; // [rsp+120h] [rbp-28h]

fprintf(stderr, "FAT:Unlink %s\n", a2);
if ( (unsigned int)fat_search(a1, a2, v4) )
{
v2 = v6;
if ( v6 )
{
v2 = -1;
*_errno_location() = 21;
}
else
{
fat_cluster_chain_free(a1, v4[1]);
fat_de_slot_delete(a1, v5, v4[0]);
fwrite("FAT:Unlink lost dir entry\n", 1uLL, 0x1AuLL, stderr);
}
}
else
{
v2 = -1;
*_errno_location() = 2;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2)
{
unsigned int v2; // er12
unsigned int v4[3]; // [rsp+0h] [rbp-148h] BYREF
char v5[276]; // [rsp+Ch] [rbp-13Ch] BYREF
unsigned int v6; // [rsp+120h] [rbp-28h]

fprintf(stderr, "FAT:Unlink %s\n", a2);
if ( (unsigned int)func0(a1, a2, v4) )
{
v2 = v6;
if ( v6 )
{
v2 = -1;
*_errno_location() = 21;
}
else
{
fat_cluster_chain_free(a1, v4[1]);
fat_de_slot_delete(a1, v5, v4[0]);
fwrite("FAT:Unlink lost dir entry\n", 1uLL, 0x1AuLL, stderr);
}
}
else
{
v2 = -1;
*_errno_location() = 2;
}
return v2;
}

original_code:
int
fat_unlink (fat_t *fat, const char *pathname)
{
    fat_ff_t ff;
    fprintf (stderr, "FAT:Unlink %s\n", pathname);
    if (!fat_search (fat, pathname, &ff))
    {
        (*__errno_location ()) = 2;
        return -1;
    }
    if (ff.isdir)
    {
        (*__errno_location ()) = 21;
        return -1;
    }
    fat_cluster_chain_free (fat, ff.cluster);
    fat_de_slot_delete (fat, &ff.dir, ff.parent_dir_cluster);
    fprintf (stderr, "FAT:Unlink lost dir entry\n");
    return 0;
}

canonical_original_code:
int fat_unlink(struct fat_struct *fat, char *pathname)
{
    struct fat_ff_struct ff;
    fprintf (stderr, "FAT:Unlink %s\n", pathname);
    if (!fat_search (fat, pathname, &ff))
    {
        (*__errno_location ()) = 2;
        return -1;
    }
    if (ff.isdir)
    {
        (*__errno_location ()) = 21;
        return -1;
    }
    fat_cluster_chain_free (fat, ff.cluster);
    fat_de_slot_delete (fat, &ff.dir, ff.parent_dir_cluster);
    fprintf (stderr, "FAT:Unlink lost dir entry\n");
    return 0;
}

variable_types: struct fat_ff_struct { unsigned int parent_dir_cluster; unsigned int cluster; unsigned int size; struct fat_dir_struct { unsigned int sector; unsigned short offset; } dir; unsigned char short_name[12]; char name[256]; int isdir; }

user_defined_types: enum fat_fs_type_t { FAT_UNKNOWN=0, FAT_FAT12=1, FAT_FAT16=2, FAT_FAT32=3 }

user_defined_types: struct fat_io_cache_struct { unsigned int sector; unsigned char buffer[512]; int dirty; }


decompiled_code:
__int64 __fastcall fat_write(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 v5; // rdi
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rax
unsigned __int16 v8; // bp
unsigned __int16 v9; // cx
unsigned int v10; // ebx
unsigned int v11; // eax
int v12; // er11
unsigned int v13; // eax
int v14; // er12
unsigned int v15; // er8
unsigned int v16; // eax
FILE *v17; // rdi
unsigned __int64 v19; // r14
unsigned int v20; // eax
unsigned int v21; // edx
unsigned int v22; // [rsp+0h] [rbp-58h]
__int64 v23; // [rsp+8h] [rbp-50h]
unsigned int *v24; // [rsp+10h] [rbp-48h]
unsigned int v25; // [rsp+18h] [rbp-40h]
int v26; // [rsp+1Ch] [rbp-3Ch]

v23 = a3;
v25 = a3;
fprintf(stderr, "FAT:Writing %u\n", a3);
if ( (a1[2] & 3) != 0 )
{
v5 = *(_QWORD *)a1;
v6 = a1[5];
v24 = a1 + 8;
v7 = v23 + a1[4];
v8 = v23;
v9 = *(_WORD *)(*(_QWORD *)a1 + 72LL);
v10 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
if ( v6 < v7 )
{
LOWORD(v22) = *(_WORD *)(*(_QWORD *)a1 + 72LL);
v19 = (v9 + v7 - v6 - 1) / v9;
v20 = fat_cluster_chain_extend(v5, a1[7], (unsigned int)v19);
v9 = v22;
v21 = a1[6];
v22 = (unsigned __int16)v22;
a1[5] += (unsigned __int16)v22 * (_DWORD)v19;
if ( !v21 )
{
a1[6] = v20;
if ( !(_WORD)v23 )
{
fat_de_size_set(*(_QWORD *)a1, v24, a1[4]);
goto LABEL_22;
}
v26 = 1;
LABEL_5:
v11 = a1[3];
while ( 1 )
{
if ( !(v11 % v22) )
{
if ( a1[7] )
{
v16 = fat_cluster_next();
a1[7] = v16;
if ( (unsigned int)fat_cluster_last_p(v16) )
{
fwrite("Trying to write past allocated clusters\n", 1uLL, 0x28uLL, stderr);
v15 = a1[4];
v25 -= v8;
v23 -= v8;
LABEL_16:
fat_de_size_set(*(_QWORD *)a1, v24, v15);
if ( !v26 )
{
LABEL_17:
fat_io_cache_flush(*(_QWORD *)a1);
v17 = stderr;
*(_DWORD *)(*(_QWORD *)a1 + 596LL) = 0;
fprintf(v17, "FAT:Wrote %u\n", v25);
return v23;
}
LABEL_22:
fat_de_cluster_set(*(_QWORD *)a1, v24, a1[6]);
goto LABEL_17;
}
}
else
{
a1[7] = a1[6];
}
}
v12 = fat_cluster_to_sector();
v13 = a1[3];
v14 = v10 - v13 % v10;
if ( v14 > v8 )
LOWORD(v14) = v8;
if ( (unsigned __int16)fat_io_write(*(_QWORD *)a1, v12 + v13 % v22 / v10, v13 % v10, a2) != (_WORD)v14 )
{
v25 -= v8;
v15 = a1[4];
v23 -= v8;
goto LABEL_16;
}
a2 += (unsigned __int16)v14;
v11 = (unsigned __int16)v14 + a1[3];
v15 = a1[4] + (unsigned __int16)v14;
a1[3] = v11;
a1[4] = v15;
v8 -= v14;
if ( !v8 )
goto LABEL_16;
}
}
v5 = *(_QWORD *)a1;
}
if ( !(_WORD)v23 )
{
fat_de_size_set(v5, v24, a1[4]);
goto LABEL_17;
}
v26 = 0;
v22 = v9;
goto LABEL_5;
}
*_errno_location() = 22;
return -1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1, __int64 a2, __int64 a3)
{
__int64 v5; // rdi
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rax
unsigned __int16 v8; // bp
unsigned __int16 v9; // cx
unsigned int v10; // ebx
unsigned int v11; // eax
int v12; // er11
unsigned int v13; // eax
int v14; // er12
unsigned int v15; // er8
unsigned int v16; // eax
FILE *v17; // rdi
unsigned __int64 v19; // r14
unsigned int v20; // eax
unsigned int v21; // edx
unsigned int v22; // [rsp+0h] [rbp-58h]
__int64 v23; // [rsp+8h] [rbp-50h]
unsigned int *v24; // [rsp+10h] [rbp-48h]
unsigned int v25; // [rsp+18h] [rbp-40h]
int v26; // [rsp+1Ch] [rbp-3Ch]

v23 = a3;
v25 = a3;
fprintf(stderr, "FAT:Writing %u\n", a3);
if ( (a1[2] & 3) != 0 )
{
v5 = *(_QWORD *)a1;
v6 = a1[5];
v24 = a1 + 8;
v7 = v23 + a1[4];
v8 = v23;
v9 = *(_WORD *)(*(_QWORD *)a1 + 72LL);
v10 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
if ( v6 < v7 )
{
LOWORD(v22) = *(_WORD *)(*(_QWORD *)a1 + 72LL);
v19 = (v9 + v7 - v6 - 1) / v9;
v20 = fat_cluster_chain_extend(v5, a1[7], (unsigned int)v19);
v9 = v22;
v21 = a1[6];
v22 = (unsigned __int16)v22;
a1[5] += (unsigned __int16)v22 * (_DWORD)v19;
if ( !v21 )
{
a1[6] = v20;
if ( !(_WORD)v23 )
{
fat_de_size_set(*(_QWORD *)a1, v24, a1[4]);
goto LABEL_22;
}
v26 = 1;
LABEL_5:
v11 = a1[3];
while ( 1 )
{
if ( !(v11 % v22) )
{
if ( a1[7] )
{
v16 = fat_cluster_next();
a1[7] = v16;
if ( (unsigned int)fat_cluster_last_p(v16) )
{
fwrite("Trying to write past allocated clusters\n", 1uLL, 0x28uLL, stderr);
v15 = a1[4];
v25 -= v8;
v23 -= v8;
LABEL_16:
fat_de_size_set(*(_QWORD *)a1, v24, v15);
if ( !v26 )
{
LABEL_17:
fat_io_cache_flush(*(_QWORD *)a1);
v17 = stderr;
*(_DWORD *)(*(_QWORD *)a1 + 596LL) = 0;
fprintf(v17, "FAT:Wrote %u\n", v25);
return v23;
}
LABEL_22:
fat_de_cluster_set(*(_QWORD *)a1, v24, a1[6]);
goto LABEL_17;
}
}
else
{
a1[7] = a1[6];
}
}
v12 = fat_cluster_to_sector();
v13 = a1[3];
v14 = v10 - v13 % v10;
if ( v14 > v8 )
LOWORD(v14) = v8;
if ( (unsigned __int16)fat_io_write(*(_QWORD *)a1, v12 + v13 % v22 / v10, v13 % v10, a2) != (_WORD)v14 )
{
v25 -= v8;
v15 = a1[4];
v23 -= v8;
goto LABEL_16;
}
a2 += (unsigned __int16)v14;
v11 = (unsigned __int16)v14 + a1[3];
v15 = a1[4] + (unsigned __int16)v14;
a1[3] = v11;
a1[4] = v15;
v8 -= v14;
if ( !v8 )
goto LABEL_16;
}
}
v5 = *(_QWORD *)a1;
}
if ( !(_WORD)v23 )
{
fat_de_size_set(v5, v24, a1[4]);
goto LABEL_17;
}
v26 = 0;
v22 = v9;
goto LABEL_5;
}
*_errno_location() = 22;
return -1LL;
}

original_code:
ssize_t
fat_write (fat_file_t *file, const void *buffer, size_t len)
{
    uint32_t sector;
    uint16_t ret;
    uint16_t nbytes;
    uint16_t bytes_left;
    uint16_t offset;
    uint16_t bytes_per_cluster;
    uint16_t bytes_per_sector;
    const uint8_t *data;
    bool newfile;
    fprintf (stderr, "FAT:Writing %u\n", (unsigned int)len);
    if (! ((file->mode & 02) || (file->mode & 01)))
    {
        (*__errno_location ()) = 22;
        return -1;
    }
    bytes_per_cluster = file->fat->bytes_per_cluster;
    bytes_per_sector = file->fat->bytes_per_sector;
    newfile = 0;
    if (file->alloc < len + file->size)
    {
        uint32_t cluster;
        uint32_t num_clusters;
        num_clusters = (len + file->size - file->alloc
                        + bytes_per_cluster - 1) / bytes_per_cluster;
        cluster = fat_cluster_chain_extend (file->fat, file->cluster, num_clusters);
        file->alloc += num_clusters * bytes_per_cluster;
        if (!file->start_cluster)
        {
            file->start_cluster = cluster;
            newfile = 1;
        }
    }
    data = buffer;
    bytes_left = len;
    while (bytes_left)
    {
        if (file->offset % bytes_per_cluster == 0)
        {
            if (!file->cluster)
                file->cluster = file->start_cluster;
            else
            {
                file->cluster = fat_cluster_next (file->fat, file->cluster);
                if (fat_cluster_last_p (file->cluster))
                {
                    fprintf (stderr, "Trying to write past allocated clusters\n");
                    break;
                }
            }
        }
        sector = fat_cluster_to_sector (file->fat, file->cluster);
        sector += (file->offset % bytes_per_cluster) / bytes_per_sector;
        offset = file->offset % bytes_per_sector;
        nbytes = bytes_left < bytes_per_sector - offset
            ? bytes_left : bytes_per_sector - offset;
        ret = fat_io_write (file->fat, sector, offset, data, nbytes);
        if (ret != nbytes)
            break;
        data += nbytes;
        file->offset += nbytes;
        file->size += nbytes;
        bytes_left -= nbytes;
    }
    fat_de_size_set (file->fat, &file->dir, file->size);
    if (newfile)
        fat_de_cluster_set (file->fat, &file->dir, file->start_cluster);
    fat_io_cache_flush (file->fat);
    file->fat->fsinfo_dirty = 0;
    fprintf (stderr, "FAT:Wrote %u\n", (unsigned int)len - bytes_left);
    return len - bytes_left;
}

canonical_original_code:
long fat_write(struct fat_file_struct *file, void *buffer, unsigned long len)
{
    unsigned int sector;
    unsigned short ret;
    unsigned short nbytes;
    unsigned short bytes_left;
    unsigned short offset;
    unsigned short bytes_per_cluster;
    unsigned short bytes_per_sector;
    unsigned char *data;
    int newfile;
    fprintf (stderr, "FAT:Writing %u\n", (unsigned int)len);
    if (! ((file->mode & 02) || (file->mode & 01)))
    {
        (*__errno_location ()) = 22;
        return -1;
    }
    bytes_per_cluster = file->fat->bytes_per_cluster;
    bytes_per_sector = file->fat->bytes_per_sector;
    newfile = 0;
    if (file->alloc < len + file->size)
    {
        unsigned int cluster;
        unsigned int num_clusters;
        num_clusters = (len + file->size - file->alloc
                        + bytes_per_cluster - 1) / bytes_per_cluster;
        cluster = fat_cluster_chain_extend (file->fat, file->cluster, num_clusters);
        file->alloc += num_clusters * bytes_per_cluster;
        if (!file->start_cluster)
        {
            file->start_cluster = cluster;
            newfile = 1;
        }
    }
    data = buffer;
    bytes_left = len;
    while (bytes_left)
    {
        if (file->offset % bytes_per_cluster == 0)
        {
            if (!file->cluster)
                file->cluster = file->start_cluster;
            else
            {
                file->cluster = fat_cluster_next (file->fat, file->cluster);
                if (fat_cluster_last_p (file->cluster))
                {
                    fprintf (stderr, "Trying to write past allocated clusters\n");
                    break;
                }
            }
        }
        sector = fat_cluster_to_sector (file->fat, file->cluster);
        sector += (file->offset % bytes_per_cluster) / bytes_per_sector;
        offset = file->offset % bytes_per_sector;
        nbytes = bytes_left < bytes_per_sector - offset
            ? bytes_left : bytes_per_sector - offset;
        ret = fat_io_write (file->fat, sector, offset, data, nbytes);
        if (ret != nbytes)
            break;
        data += nbytes;
        file->offset += nbytes;
        file->size += nbytes;
        bytes_left -= nbytes;
    }
    fat_de_size_set (file->fat, &file->dir, file->size);
    if (newfile)
        fat_de_cluster_set (file->fat, &file->dir, file->start_cluster);
    fat_io_cache_flush (file->fat);
    file->fat->fsinfo_dirty = 0;
    fprintf (stderr, "FAT:Wrote %u\n", (unsigned int)len - bytes_left);
    return len - bytes_left;
}

variable_types: struct fat_file_struct { struct fat_struct { void *dev; unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size); unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size); enum fat_fs_type_t { FAT_UNKNOWN=0, FAT_FAT12=1, FAT_FAT16=2, FAT_FAT32=3 } type; unsigned int first_sector; unsigned int fsinfo_sector; unsigned int first_fat_sector; unsigned int first_data_sector; unsigned int num_fat_sectors; unsigned int first_dir_sector; unsigned int root_dir_cluster; unsigned int num_clusters; unsigned int free_clusters; unsigned int prev_free_cluster; unsigned short root_dir_sectors; unsigned short bytes_per_sector; unsigned short bytes_per_cluster; unsigned short sectors_per_cluster; struct fat_io_cache_struct { unsigned int sector; unsigned char buffer[512]; int dirty; } cache; int fsinfo_dirty; } *fat; int mode; unsigned int offset; unsigned int size; unsigned int alloc; unsigned int start_cluster; unsigned int cluster; struct fat_dir_struct { unsigned int sector; unsigned short offset; } dir; } *

variable_types:
buffer
void *

variable_types:
len
unsigned long

variable_types:
sector
unsigned int

variable_types:
ret
unsigned short

variable_types:
nbytes
unsigned short

variable_types:
offset
unsigned short

variable_types:
data
unsigned char *

variable_types: newfile int

variable_types:
cluster
unsigned int

return_type: long

user_defined_types: struct fat_file_struct { struct fat_struct *fat; int mode; unsigned int offset; unsigned int size; unsigned int alloc; unsigned int start_cluster; unsigned int cluster; struct fat_dir_struct dir; }


decompiled_code:
__int64 __fastcall fat_close(void *ptr)
{
fwrite("FAT:Close\n", 1uLL, 0xAuLL, stderr);
if ( !ptr )
return 0xFFFFFFFFLL;
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(void *ptr)
{
fwrite("FAT:Close\n", 1uLL, 0xAuLL, stderr);
if ( !ptr )
return 0xFFFFFFFFLL;
free(ptr);
return 0LL;
}

original_code:
int
fat_close (fat_file_t *file)
{
    fprintf (stderr, "FAT:Close\n");
    if (file == ((void *)0))
        return (uint32_t) -1;
    free (file);
    return 0;
}

canonical_original_code:
int fat_close(struct fat_file_struct *file)
{
    fprintf (stderr, "FAT:Close\n");
    if (file == ((void *)0))
        return (unsigned int) -1;
    free (file);
    return 0;
}

user_defined_types: struct fat_dir_struct { unsigned int sector; unsigned short offset; }


decompiled_code:
__int64 __fastcall fat_read(_DWORD *a1, __int64 a2, __int64 a3)
{
unsigned int v5; // ebx
unsigned int v6; // eax
unsigned int v7; // edx
unsigned int v8; // ebp
unsigned int v9; // er14
unsigned int v10; // er13
int v11; // er9
int v12; // ecx
unsigned int v13; // ebx
__int64 v14; // rdi
unsigned int v15; // ecx
unsigned int v16; // eax
unsigned int v17; // eax
__int64 v19; // [rsp+0h] [rbp-48h]
unsigned int v20; // [rsp+Ch] [rbp-3Ch]

v5 = a3;
v19 = a3;
v20 = a3;
fprintf(stderr, "FAT:Reading %u\n", a3);
v6 = a1[3];
v7 = a1[4] - v6;
if ( v5 > v7 )
{
v20 = a1[4] - v6;
v19 = v7;
}
v8 = v19;
if ( (_WORD)v19 )
{
while ( 1 )
{
v9 = v8;
v10 = v6 % *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
v11 = fat_cluster_to_sector(*(_QWORD *)a1, (unsigned int)a1[7]);
v12 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
if ( (unsigned __int16)v12 <= (unsigned __int16)v8 )
v9 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
v13 = (unsigned __int16)v9;
if ( (unsigned __int16)v9 > (int)(v12 - v10) )
{
v13 = (unsigned __int16)(*(_WORD *)(*(_QWORD *)a1 + 70LL) - v10);
v9 = v13;
}
if ( (_WORD)v9 != (unsigned __int16)fat_io_read(
*(_QWORD *)a1,
v11
+ a1[3] % (unsigned int)*(unsigned __int16 *)(*(_QWORD *)a1 + 72LL)
/ *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL),
v10,
a2,
v13) )
break;
v14 = *(_QWORD *)a1;
v8 -= v9;
a2 += (unsigned __int16)v9;
v15 = *(unsigned __int16 *)(*(_QWORD *)a1 + 72LL);
v16 = v13 + a1[3];
a1[3] = v16;
if ( !(v16 % v15) )
{
v17 = fat_cluster_next(v14, (unsigned int)a1[7]);
a1[7] = v17;
if ( (unsigned int)fat_cluster_last_p(v17) )
break;
}
if ( !(_WORD)v8 )
goto LABEL_15;
v6 = a1[3];
}
v20 -= (unsigned __int16)v8;
v19 -= (unsigned __int16)v8;
}
LABEL_15:
fprintf(stderr, "FAT:Read %u\n", v20);
return v19;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, __int64 a2, __int64 a3)
{
unsigned int v5; // ebx
unsigned int v6; // eax
unsigned int v7; // edx
unsigned int v8; // ebp
unsigned int v9; // er14
unsigned int v10; // er13
int v11; // er9
int v12; // ecx
unsigned int v13; // ebx
__int64 v14; // rdi
unsigned int v15; // ecx
unsigned int v16; // eax
unsigned int v17; // eax
__int64 v19; // [rsp+0h] [rbp-48h]
unsigned int v20; // [rsp+Ch] [rbp-3Ch]

v5 = a3;
v19 = a3;
v20 = a3;
fprintf(stderr, "FAT:Reading %u\n", a3);
v6 = a1[3];
v7 = a1[4] - v6;
if ( v5 > v7 )
{
v20 = a1[4] - v6;
v19 = v7;
}
v8 = v19;
if ( (_WORD)v19 )
{
while ( 1 )
{
v9 = v8;
v10 = v6 % *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
v11 = fat_cluster_to_sector(*(_QWORD *)a1, (unsigned int)a1[7]);
v12 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
if ( (unsigned __int16)v12 <= (unsigned __int16)v8 )
v9 = *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL);
v13 = (unsigned __int16)v9;
if ( (unsigned __int16)v9 > (int)(v12 - v10) )
{
v13 = (unsigned __int16)(*(_WORD *)(*(_QWORD *)a1 + 70LL) - v10);
v9 = v13;
}
if ( (_WORD)v9 != (unsigned __int16)fat_io_read(
*(_QWORD *)a1,
v11
+ a1[3] % (unsigned int)*(unsigned __int16 *)(*(_QWORD *)a1 + 72LL)
/ *(unsigned __int16 *)(*(_QWORD *)a1 + 70LL),
v10,
a2,
v13) )
break;
v14 = *(_QWORD *)a1;
v8 -= v9;
a2 += (unsigned __int16)v9;
v15 = *(unsigned __int16 *)(*(_QWORD *)a1 + 72LL);
v16 = v13 + a1[3];
a1[3] = v16;
if ( !(v16 % v15) )
{
v17 = fat_cluster_next(v14, (unsigned int)a1[7]);
a1[7] = v17;
if ( (unsigned int)fat_cluster_last_p(v17) )
break;
}
if ( !(_WORD)v8 )
goto LABEL_15;
v6 = a1[3];
}
v20 -= (unsigned __int16)v8;
v19 -= (unsigned __int16)v8;
}
LABEL_15:
fprintf(stderr, "FAT:Read %u\n", v20);
return v19;
}

original_code:
ssize_t
fat_read (fat_file_t *file, void *buffer, size_t len)
{
    uint16_t nbytes;
    uint16_t ret;
    uint32_t sector;
    uint16_t bytes_left;
    uint16_t offset;
    uint8_t *data;
    fprintf (stderr, "FAT:Reading %u\n", (unsigned int)len);
    if ((uint32_t)len > (file->size - file->offset))
        len = file->size - file->offset;
    data = buffer;
    bytes_left = len;
    while (bytes_left)
    {
        offset = file->offset % file->fat->bytes_per_sector;
        sector = fat_cluster_to_sector (file->fat, file->cluster);
        sector += (file->offset % file->fat->bytes_per_cluster)
            / file->fat->bytes_per_sector;
        nbytes = bytes_left < file->fat->bytes_per_sector
            ? bytes_left : file->fat->bytes_per_sector;
        if (nbytes > (file->fat->bytes_per_sector - offset))
            nbytes = file->fat->bytes_per_sector - offset;
        ret = fat_io_read (file->fat, sector, offset, data, nbytes);
        if (ret != nbytes)
            break;
        data += nbytes;
        file->offset += nbytes;
        bytes_left -= nbytes;
        if (file->offset % file->fat->bytes_per_cluster == 0)
        {
            file->cluster = fat_cluster_next (file->fat, file->cluster);
            if (fat_cluster_last_p (file->cluster))
                break;
        }
    }
    fprintf (stderr, "FAT:Read %u\n", (unsigned int)len - bytes_left);
    return len - bytes_left;
}

canonical_original_code:
long fat_read(struct fat_file_struct *file, void *buffer, unsigned long len)
{
    unsigned short nbytes;
    unsigned short ret;
    unsigned int sector;
    unsigned short bytes_left;
    unsigned short offset;
    unsigned char *data;
    fprintf (stderr, "FAT:Reading %u\n", (unsigned int)len);
    if ((unsigned int)len > (file->size - file->offset))
        len = file->size - file->offset;
    data = buffer;
    bytes_left = len;
    while (bytes_left)
    {
        offset = file->offset % file->fat->bytes_per_sector;
        sector = fat_cluster_to_sector (file->fat, file->cluster);
        sector += (file->offset % file->fat->bytes_per_cluster)
            / file->fat->bytes_per_sector;
        nbytes = bytes_left < file->fat->bytes_per_sector
            ? bytes_left : file->fat->bytes_per_sector;
        if (nbytes > (file->fat->bytes_per_sector - offset))
            nbytes = file->fat->bytes_per_sector - offset;
        ret = fat_io_read (file->fat, sector, offset, data, nbytes);
        if (ret != nbytes)
            break;
        data += nbytes;
        file->offset += nbytes;
        bytes_left -= nbytes;
        if (file->offset % file->fat->bytes_per_cluster == 0)
        {
            file->cluster = fat_cluster_next (file->fat, file->cluster);
            if (fat_cluster_last_p (file->cluster))
                break;
        }
    }
    fprintf (stderr, "FAT:Read %u\n", (unsigned int)len - bytes_left);
    return len - bytes_left;
}


decompiled_code:
__int64 __fastcall fat_lseek(__int64 *a1, __int64 a2, int a3)
{
unsigned int v4; // eax
int v5; // eax
__int64 v6; // r13
__int64 v8; // rdi
unsigned int v9; // ebp
__int64 v10; // rcx
int i; // ebx

v4 = *((_DWORD *)a1 + 4);
if ( a3 == 1 )
{
a2 += *((unsigned int *)a1 + 3);
}
else if ( a3 == 2 )
{
a2 += v4;
}
else if ( a3 )
{
v5 = *((_DWORD *)a1 + 6);
*((_DWORD *)a1 + 3) = 0;
v6 = 0LL;
*((_DWORD *)a1 + 7) = v5;
return v6;
}
v6 = 0LL;
if ( a2 >= 0 )
v6 = a2;
if ( (unsigned int)v6 <= v4 )
v4 = v6;
else
v6 = v4;
v8 = *a1;
v9 = *((_DWORD *)a1 + 6);
*((_DWORD *)a1 + 3) = v4;
v10 = *(unsigned __int16 *)(v8 + 72);
*((_DWORD *)a1 + 7) = v9;
if ( !(unsigned int)(v6 / v10) )
return v6;
for ( i = v6 / v10 - 2; ; --i )
{
v9 = fat_cluster_next(v8, v9);
if ( (unsigned int)fat_cluster_last_p(v9) )
break;
*((_DWORD *)a1 + 7) = v9;
if ( i == -1 )
return v6;
v8 = *a1;
}
return v6;
}

original_code:
off_t
fat_lseek (fat_file_t *file, off_t offset, int whence)
{
    off_t fpos = 0;
    unsigned int num;
    switch (whence)
    {
    case 0 : fpos = offset;
        break;
    case 1 : fpos = file->offset + offset;
        break;
    case 2 : fpos = file->size + offset;
        break;
    }
    if (fpos < 0)
        fpos = 0;
    if ((uint32_t)fpos > file->size)
        fpos = file->size;
    file->offset = fpos;
    num = fpos / file->fat->bytes_per_cluster;
    file->cluster = file->start_cluster;
    while (num--)
    {
        uint32_t cluster_new;
        cluster_new = fat_cluster_next (file->fat, file->cluster);
        if (!fat_cluster_last_p (cluster_new))
            file->cluster = cluster_new;
        else
            break;
    }
    return fpos;
}

canonical_original_code:
long fat_lseek(struct fat_file_struct *file, long offset, int whence)
{
    long fpos = 0;
    unsigned int num;
    switch (whence)
    {
    case 0 : fpos = offset;
        break;
    case 1 : fpos = file->offset + offset;
        break;
    case 2 : fpos = file->size + offset;
        break;
    }
    if (fpos < 0)
        fpos = 0;
    if ((unsigned int)fpos > file->size)
        fpos = file->size;
    file->offset = fpos;
    num = fpos / file->fat->bytes_per_cluster;
    file->cluster = file->start_cluster;
    while (num--)
    {
        unsigned int cluster_new;
        cluster_new = fat_cluster_next (file->fat, file->cluster);
        if (!fat_cluster_last_p (cluster_new))
            file->cluster = cluster_new;
        else
            break;
    }
    return fpos;
}

variable_types: offset long

variable_types: whence int

variable_types: fpos long

variable_types:
num
unsigned int


original_code:
int
fat_mkdir (fat_t *fat, const char *pathname, mode_t mode)
{
    return -13;
}

canonical_original_code:
int fat_mkdir(struct fat_struct *fat, char *pathname, unsigned int mode)
{
    return -13;
}

variable_types: struct fat_struct { void *dev; unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size); unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size); enum fat_fs_type_t { FAT_UNKNOWN=0, FAT_FAT12=1, FAT_FAT16=2, FAT_FAT32=3 } type; unsigned int first_sector; unsigned int fsinfo_sector; unsigned int first_fat_sector; unsigned int first_data_sector; unsigned int num_fat_sectors; unsigned int first_dir_sector; unsigned int root_dir_cluster; unsigned int num_clusters; unsigned int free_clusters; unsigned int prev_free_cluster; unsigned short root_dir_sectors; unsigned short bytes_per_sector; unsigned short bytes_per_cluster; unsigned short sectors_per_cluster; struct fat_io_cache_struct { unsigned int sector; unsigned char buffer[512]; int dirty; } cache; int fsinfo_dirty; } *

variable_types:
pathname
char *

variable_types:
mode
unsigned int


decompiled_code:
__int64 __fastcall fat_file_debug(__int64 a1)
{
fprintf(stderr, "Offset %lu\n", *(unsigned int *)(a1 + 12));
fprintf(stderr, "Size %lu\n", *(unsigned int *)(a1 + 16));
fprintf(stderr, "Alloc %lu\n", *(unsigned int *)(a1 + 20));
fprintf(stderr, "DE sector %lu\n", *(unsigned int *)(a1 + 32));
fprintf(stderr, "DE offset %u\n", *(unsigned __int16 *)(a1 + 36));
fwrite("Clusters ", 1uLL, 9uLL, stderr);
return fat_cluster_chain_dump(*(_QWORD *)a1, *(unsigned int *)(a1 + 24));
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
fprintf(stderr, "Offset %lu\n", *(unsigned int *)(a1 + 12));
fprintf(stderr, "Size %lu\n", *(unsigned int *)(a1 + 16));
fprintf(stderr, "Alloc %lu\n", *(unsigned int *)(a1 + 20));
fprintf(stderr, "DE sector %lu\n", *(unsigned int *)(a1 + 32));
fprintf(stderr, "DE offset %u\n", *(unsigned __int16 *)(a1 + 36));
fwrite("Clusters ", 1uLL, 9uLL, stderr);
return fat_cluster_chain_dump(*(_QWORD *)a1, *(unsigned int *)(a1 + 24));
}

original_code:
void
fat_file_debug (fat_file_t *file)
{
    fprintf (stderr, "Offset %lu\n", file->offset);
    fprintf (stderr, "Size %lu\n", file->size);
    fprintf (stderr, "Alloc %lu\n", file->alloc);
    fprintf (stderr, "DE sector %lu\n", file->dir.sector);
    fprintf (stderr, "DE offset %u\n", file->dir.offset);
    fprintf (stderr, "Clusters ");
    fat_cluster_chain_dump (file->fat, file->start_cluster);
}

canonical_original_code:
void fat_file_debug(struct fat_file_struct *file)
{
    fprintf (stderr, "Offset %lu\n", file->offset);
    fprintf (stderr, "Size %lu\n", file->size);
    fprintf (stderr, "Alloc %lu\n", file->alloc);
    fprintf (stderr, "DE sector %lu\n", file->dir.sector);
    fprintf (stderr, "DE offset %u\n", file->dir.offset);
    fprintf (stderr, "Clusters ");
    fat_cluster_chain_dump (file->fat, file->start_cluster);
}

variable_types: struct fat_file_struct { struct fat_struct { void *dev; unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size); unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size); enum fat_fs_type_t { FAT_UNKNOWN=0, FAT_FAT12=1, FAT_FAT16=2, FAT_FAT32=3 } type; unsigned int first_sector; unsigned int fsinfo_sector; unsigned int first_fat_sector; unsigned int first_data_sector; unsigned int num_fat_sectors; unsigned int first_dir_sector; unsigned int root_dir_cluster; unsigned int num_clusters; unsigned int free_clusters; unsigned int prev_free_cluster; unsigned short root_dir_sectors; unsigned short bytes_per_sector; unsigned short bytes_per_cluster; unsigned short sectors_per_cluster; struct fat_io_cache_struct { unsigned int sector; unsigned char buffer[512]; int dirty; } cache; int fsinfo_dirty; } *fat; int mode; unsigned int offset; unsigned int size; unsigned int alloc; unsigned int start_cluster; unsigned int cluster; struct fat_dir_struct { unsigned int sector; unsigned short offset; } dir; } *


decompiled_code:
_BOOL8 __fastcall fat_init(__int64 a1)
{
fat_io_init();
return (unsigned int)fat_partition_read(a1) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(__int64 a1)
{
fat_io_init();
return (unsigned int)fat_partition_read(a1) != 0;
}

original_code:
bool
fat_init (fat_t *fat, void *dev, fat_dev_read_t dev_read,
          fat_dev_write_t dev_write)
{
    fat_io_init (fat, dev, dev_read, dev_write);
    if (!fat_partition_read (fat))
        return 0;
    return 1;
}

canonical_original_code:
int fat_init(struct fat_struct *fat, void *dev, unsigned short (*dev_read)(void *dev, unsigned int addr, void *buffer, unsigned short size), unsigned short (*dev_write)(void *dev, unsigned int addr, void *buffer, unsigned short size))
{
    fat_io_init (fat, dev, dev_read, dev_write);
    if (!fat_partition_read (fat))
        return 0;
    return 1;
}

variable_types:
dev
void *

variable_types: unsigned short (*)(void *dev, unsigned int addr, void *buffer, unsigned short size)


decompiled_code:
__int64 __fastcall chaser_pixel_set(__int64 a1, __int64 a2, unsigned __int8 a3, unsigned __int8 a4, char a5)
{
__int64 v6; // rsi

v6 = *(_QWORD *)(a1 + 48);
if ( (unsigned int)(*(_DWORD *)(a1 + 36) - 2) <= 1 != a5 )
v6 = *(_QWORD *)(a1 + 40);
return flasher_pattern_set(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * (a3 + a4 * *(unsigned __int8 *)(a2 + 1))), v6);
}

original_code:
static void
chaser_pixel_set (void *data, font_t *font, uint8_t col, uint8_t row, bool val)
{
    chaser_obj_t *dev = data;
    bool invert;
    invert = dev->mode == CHASER_MODE_INVERT
        || dev->mode == CHASER_MODE_CYCLE_INVERT;
    flasher_pattern_set (dev->flashers[row * font->width + col], val ^ invert
                         ? dev->on_pattern : dev->off_pattern);
}

canonical_original_code:
static void chaser_pixel_set(void *data, struct font_t *font, unsigned char col, unsigned char row, unsigned char val)
{
    struct chaser_private_t *dev = data;
    unsigned char invert;
    invert = dev->mode == CHASER_MODE_INVERT
        || dev->mode == CHASER_MODE_CYCLE_INVERT;
    flasher_pattern_set (dev->flashers[row * font->width + col], val ^ invert
                         ? dev->on_pattern : dev->off_pattern);
}

variable_types:
data
void *

variable_types:
col
unsigned char

variable_types:
row
unsigned char

variable_types:
val
unsigned char

variable_types: struct chaser_private_t { unsigned char flasher_num; struct flasher_obj_t { char dummy[-1]; } **flashers; char *seq; struct font_t { unsigned char flags; unsigned char width; unsigned char height; unsigned char offset; unsigned char size; unsigned char data[]; } *font; unsigned char step; char dir; enum chaser_mode_t { CHASER_MODE_NORMAL=0, CHASER_MODE_CYCLE=1, CHASER_MODE_INVERT=2, CHASER_MODE_CYCLE_INVERT=3, CHASER_MODE_NUM=4 } mode; struct flasher_pattern_t { unsigned char mod_period; unsigned char mod_duty; unsigned char flasher_period; unsigned char flasher_duty; unsigned char flashes; unsigned char period; } *on_pattern; struct flasher_pattern_t *off_pattern; } *

variable_types:
invert
unsigned char

user_defined_types: struct chaser_private_t { unsigned char flasher_num; struct flasher_obj_t **flashers; char *seq; struct font_t *font; unsigned char step; char dir; enum chaser_mode_t mode; struct flasher_pattern_t *on_pattern; struct flasher_pattern_t *off_pattern; }