decompiled_code:
__int64 q_pop()
{
void *v0; // rbx
__int64 *v1; // rdi
__int64 v2; // rax
__int64 v3; // rbp

pthread_mutex_lock(*((pthread_mutex_t **)events + 2));
v0 = events;
v1 = *(__int64 **)events;
if ( *(_QWORD *)events )
{
v2 = v1[2];
*(_QWORD *)events = v2;
if ( v2 )
*(_QWORD *)(v2 + 8) = 0LL;
else
*((_QWORD *)v0 + 1) = 0LL;
--*((_DWORD *)v0 + 6);
v3 = *v1;
free(v1);
}
else
{
v3 = 0LL;
}
pthread_mutex_unlock(*((pthread_mutex_t **)v0 + 2));
return v3;
}

canonical_decompiled_code:
__int64 func7()
{
void *v0; // rbx
__int64 *v1; // rdi
__int64 v2; // rax
__int64 v3; // rbp

pthread_mutex_lock(*((pthread_mutex_t **)events + 2));
v0 = events;
v1 = *(__int64 **)events;
if ( *(_QWORD *)events )
{
v2 = v1[2];
*(_QWORD *)events = v2;
if ( v2 )
*(_QWORD *)(v2 + 8) = 0LL;
else
*((_QWORD *)v0 + 1) = 0LL;
--*((_DWORD *)v0 + 6);
v3 = *v1;
free(v1);
}
else
{
v3 = 0LL;
}
pthread_mutex_unlock(*((pthread_mutex_t **)v0 + 2));
return v3;
}

original_code:
struct raw_event* q_pop() {
    struct raw_event* event = ((void *)0);
    pthread_mutex_lock(events->lock);
    if (events->top != ((void *)0)) {
        struct q_node* node;
        node = events->top;
        events->top = node->next;
        if (events->top == ((void *)0)) {
            events->bottom = ((void *)0);
        } else {
            events->top->prev = ((void *)0);
        }
        events->size--;
        event = node->event;
        free(node);
        (void)0;
        (void)0;
    }
    pthread_mutex_unlock(events->lock);
    return event;
}

canonical_original_code:
struct raw_event *q_pop() {
    struct raw_event *event = ((void *)0);
    pthread_mutex_lock(events->lock);
    if (events->top != ((void *)0)) {
        struct q_node *node;
        node = events->top;
        events->top = node->next;
        if (events->top == ((void *)0)) {
            events->bottom = ((void *)0);
        } else {
            events->top->prev = ((void *)0);
        }
        events->size--;
        event = node->event;
        free(node);
        (void)0;
        (void)0;
    }
    pthread_mutex_unlock(events->lock);
    return event;
}

variable_types: struct raw_event { struct timeval { long tv_sec; long tv_usec; } timestamp; char *__buffer; char *type; char *prefix; int num_params; char *params[15]; } *


repo: nacx/circus

decompiled_code:
void __fastcall __noreturn event_consumer(void *a1)
{
__int64 v1; // rbx

pthread_mutex_lock(*((pthread_mutex_t **)consumer + 1));
while ( !*((_DWORD *)consumer + 6) )
{
if ( !*((_DWORD *)events + 6) )
{
pthread_cond_wait(*((pthread_cond_t **)consumer + 2), *((pthread_mutex_t **)consumer + 1));
if ( *((_DWORD *)consumer + 6) )
continue;
}
v1 = q_pop();
fire_event(v1);
evt_raw_destroy(v1);
}
pthread_mutex_unlock(*((pthread_mutex_t **)consumer + 1));
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
__int64 v1; // rbx

pthread_mutex_lock(*((pthread_mutex_t **)consumer + 1));
while ( !*((_DWORD *)consumer + 6) )
{
if ( !*((_DWORD *)events + 6) )
{
pthread_cond_wait(*((pthread_cond_t **)consumer + 2), *((pthread_mutex_t **)consumer + 1));
if ( *((_DWORD *)consumer + 6) )
continue;
}
v1 = func7();
fire_event(v1);
evt_raw_destroy(v1);
}
pthread_mutex_unlock(*((pthread_mutex_t **)consumer + 1));
pthread_exit(0LL);
}

original_code:
static void* event_consumer(void* arg) {
    pthread_mutex_lock(consumer->lock);
    while (consumer->terminate == 0) {
        if (events->size == 0) {
            (void)0;
            pthread_cond_wait(consumer->ready, consumer->lock);
            (void)0;
        }
        if (consumer->terminate == 0) {
            struct raw_event* event = q_pop();
            _fire_event(event);
            evt_raw_destroy(event);
        }
    }
    (void)0;
    pthread_mutex_unlock(consumer->lock);
    pthread_exit(((void *)0));
}

canonical_original_code:
static void *event_consumer(void *arg) {
    pthread_mutex_lock(consumer->lock);
    while (consumer->terminate == 0) {
        if (events->size == 0) {
            (void)0;
            pthread_cond_wait(consumer->ready, consumer->lock);
            (void)0;
        }
        if (consumer->terminate == 0) {
            struct raw_event *event = q_pop();
            _fire_event(event);
            evt_raw_destroy(event);
        }
    }
    (void)0;
    pthread_mutex_unlock(consumer->lock);
    pthread_exit(((void *)0));
}

variable_types:
arg
void *

return_type: void *

user_defined_types: struct raw_event { struct timeval timestamp; char *__buffer; char *type; char *prefix; int num_params; char *params[15]; }

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


decompiled_code:
int dsp_start()
{
q_create();
return consumer_create();
}

canonical_decompiled_code:
int func9()
{
func0();
return func1();
}

original_code:
void dsp_start() {
    q_create();
    consumer_create();
}

return_type: void


decompiled_code:
void dsp_shutdown()
{
consumer_destroy();
q_destroy();
}

canonical_decompiled_code:
void func10()
{
func6();
func5();
}


decompiled_code:
int __fastcall dsp_dispatch(__int64 a1)
{
return q_push(a1);
}

canonical_decompiled_code:
int __fastcall func11(__int64 a1)
{
return func4(a1);
}

original_code:
void dsp_dispatch(struct raw_event* event) {
    q_push(event);
}

canonical_original_code:
void dsp_dispatch(struct raw_event *event) {
    q_push(event);
}


original_code:
struct raw_event* lst_parse(char* msg) {
    int i = 0, is_last_parameter = 0;
    size_t msg_len;
    struct raw_event* raw = evt_raw_create();
    char* token, *token_end = ((void *)0);
    if (msg != ((void *)0) && (msg_len = strlen(msg)) > 0) {
        if ((raw->__buffer = malloc((msg_len + 1) * sizeof(char))) == 0) {
            perror("Out of memory (parse)");
            exit(1);
        }
        memset(raw->__buffer, '\0', msg_len + 1);
        strncpy(raw->__buffer, msg, msg_len);
        token = strtok_r(raw->__buffer, " ", &token_end);
        while(token != ((void *)0))
        {
            if (raw->type == ((void *)0)) {
                if (token[0] == ':') {
                    raw->prefix = token + 1;
                } else {
                    raw->type = token;
                }
            } else {
                if (is_last_parameter == 0 && token[0] == ':') {
                    raw->params[i] = token + 1;
                    is_last_parameter = 1;
                } else {
                    if (is_last_parameter == 0) {
                        raw->params[i++] = token;
                    } else {
                        sprintf(raw->params[i], "%s %s", raw->params[i], token);
                    }
                }
            }
            token = strtok_r(((void *)0), " ", &token_end);
        }
        raw->num_params = (is_last_parameter == 0)? i : i + 1;
    }
    return raw;
}

canonical_original_code:
struct raw_event *lst_parse(char *msg) {
    int i = 0; int is_last_parameter = 0;
    unsigned long msg_len;
    struct raw_event *raw = evt_raw_create();
    char *token; char *token_end = ((void *)0);
    if (msg != ((void *)0) && (msg_len = strlen(msg)) > 0) {
        if ((raw->__buffer = malloc((msg_len + 1) * sizeof(char))) == 0) {
            perror("Out of memory (parse)");
            exit(1);
        }
        memset(raw->__buffer, '\0', msg_len + 1);
        strncpy(raw->__buffer, msg, msg_len);
        token = strtok_r(raw->__buffer, " ", &token_end);
        while(token != ((void *)0))
        {
            if (raw->type == ((void *)0)) {
                if (token[0] == ':') {
                    raw->prefix = token + 1;
                } else {
                    raw->type = token;
                }
            } else {
                if (is_last_parameter == 0 && token[0] == ':') {
                    raw->params[i] = token + 1;
                    is_last_parameter = 1;
                } else {
                    if (is_last_parameter == 0) {
                        raw->params[i++] = token;
                    } else {
                        sprintf(raw->params[i], "%s %s", raw->params[i], token);
                    }
                }
            }
            token = strtok_r(((void *)0), " ", &token_end);
        }
        raw->num_params = (is_last_parameter == 0)? i : i + 1;
    }
    return raw;
}

variable_types:
msg
char *

variable_types: i int

variable_types:
token
char *

return_type: struct raw_event { struct timeval { long tv_sec; long tv_usec; } timestamp; char *__buffer; char *type; char *prefix; int num_params; char *params[15]; } *


decompiled_code:
__int64 __fastcall lst_handle(char *src)
{
__int64 v1; // rax

src[strlen(src) - 2] = 0;
v1 = lst_parse(src);
return dsp_dispatch(v1);
}

canonical_decompiled_code:
__int64 __fastcall func1(char *src)
{
__int64 v1; // rax

src[strlen(src) - 2] = 0;
v1 = func0(src);
return dsp_dispatch(v1);
}

original_code:
void lst_handle(char* msg) {
    struct raw_event* raw;
    msg[strlen(msg) - 2] = '\0';
    raw = lst_parse(msg);
    dsp_dispatch(raw);
}

canonical_original_code:
void lst_handle(char *msg) {
    struct raw_event *raw;
    msg[strlen(msg) - 2] = '\0';
    raw = lst_parse(msg);
    dsp_dispatch(raw);
}


decompiled_code:
__int64 test_parse_empty_message()
{
__int64 v0; // rax
__int64 v1; // rax

v0 = lst_parse(0LL);
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_empty_message: prefix should be NULL");
if ( *(_QWORD *)(v0 + 24) )
return mu_fail("test_parse_empty_message: type should be NULL");
if ( !*(_DWORD *)(v0 + 40) )
{
evt_raw_destroy(v0);
v1 = lst_parse((char *)&src);
if ( !*(_QWORD *)(v1 + 32) )
{
if ( !*(_QWORD *)(v1 + 24) )
{
if ( !*(_DWORD *)(v1 + 40) )
return evt_raw_destroy(v1);
return mu_fail("test_parse_empty_message: there should be 0 parameters");
}
return mu_fail("test_parse_empty_message: type should be NULL");
}
return mu_fail("test_parse_empty_message: prefix should be NULL");
}
return mu_fail("test_parse_empty_message: there should be 0 parameters");
}

canonical_decompiled_code:
__int64 func2()
{
__int64 v0; // rax
__int64 v1; // rax

v0 = func0(0LL);
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_empty_message: prefix should be NULL");
if ( *(_QWORD *)(v0 + 24) )
return mu_fail("test_parse_empty_message: type should be NULL");
if ( !*(_DWORD *)(v0 + 40) )
{
evt_raw_destroy(v0);
v1 = func0((char *)&src);
if ( !*(_QWORD *)(v1 + 32) )
{
if ( !*(_QWORD *)(v1 + 24) )
{
if ( !*(_DWORD *)(v1 + 40) )
return evt_raw_destroy(v1);
return mu_fail("test_parse_empty_message: there should be 0 parameters");
}
return mu_fail("test_parse_empty_message: type should be NULL");
}
return mu_fail("test_parse_empty_message: prefix should be NULL");
}
return mu_fail("test_parse_empty_message: there should be 0 parameters");
}

original_code:
void test_parse_empty_message() {
    struct raw_event* raw;
    raw = lst_parse(((void *)0));
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_empty_message: prefix should be NULL"); return; } } while (0);
    do { if (!(raw->type == ((void *)0))) { mu_fail("test_parse_empty_message: type should be NULL"); return; } } while (0);
    do { if (!(raw->num_params == 0)) { mu_fail("test_parse_empty_message: there should be 0 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
    raw = lst_parse("");
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_empty_message: prefix should be NULL"); return; } } while (0);
    do { if (!(raw->type == ((void *)0))) { mu_fail("test_parse_empty_message: type should be NULL"); return; } } while (0);
    do { if (!(raw->num_params == 0)) { mu_fail("test_parse_empty_message: there should be 0 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_empty_message() {
    struct raw_event *raw;
    raw = lst_parse(((void *)0));
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_empty_message: prefix should be NULL"); return; } } while (0);
    do { if (!(raw->type == ((void *)0))) { mu_fail("test_parse_empty_message: type should be NULL"); return; } } while (0);
    do { if (!(raw->num_params == 0)) { mu_fail("test_parse_empty_message: there should be 0 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
    raw = lst_parse("");
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_empty_message: prefix should be NULL"); return; } } while (0);
    do { if (!(raw->type == ((void *)0))) { mu_fail("test_parse_empty_message: type should be NULL"); return; } } while (0);
    do { if (!(raw->num_params == 0)) { mu_fail("test_parse_empty_message: there should be 0 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse("TEST This is a message test without prefix");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse: type should be TEST");
if ( *(_DWORD *)(v0 + 40) == 7 )
return evt_raw_destroy(v0);
return mu_fail("test_parse: there should be 7 parameters");
}

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

v0 = func0("TEST This is a message test without prefix");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse: type should be TEST");
if ( *(_DWORD *)(v0 + 40) == 7 )
return evt_raw_destroy(v0);
return mu_fail("test_parse: there should be 7 parameters");
}

original_code:
void test_parse() {
    struct raw_event* raw;
    raw = lst_parse("TEST This is a message test without prefix");
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse: type should be TEST"); return; } } while (0);
    do { if (!(raw->num_params == 7)) { mu_fail("test_parse: there should be 7 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse() {
    struct raw_event *raw;
    raw = lst_parse("TEST This is a message test without prefix");
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse: type should be TEST"); return; } } while (0);
    do { if (!(raw->num_params == 7)) { mu_fail("test_parse: there should be 7 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse(":prefix TEST This is a message test with prefix");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) == 7 )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix: there should be 7 parameters");
}

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

v0 = func0(":prefix TEST This is a message test with prefix");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) == 7 )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix: there should be 7 parameters");
}

original_code:
void test_parse_with_prefix() {
    struct raw_event* raw;
    raw = lst_parse(":prefix TEST This is a message test with prefix");
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 7)) { mu_fail("test_parse_with_prefix: there should be 7 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_with_prefix() {
    struct raw_event *raw;
    raw = lst_parse(":prefix TEST This is a message test with prefix");
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 7)) { mu_fail("test_parse_with_prefix: there should be 7 parameters"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse("TEST This is a message test with a :last parameter");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_with_last_param: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 8 )
return mu_fail("test_parse_with_last_param: there should be 8 parameters");
if ( !strcmp(*(const char **)(v0 + 104), "last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_last_param: last parameter should be 'last parameter'");
}

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

v0 = func0("TEST This is a message test with a :last parameter");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_with_last_param: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 8 )
return mu_fail("test_parse_with_last_param: there should be 8 parameters");
if ( !strcmp(*(const char **)(v0 + 104), "last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_last_param: last parameter should be 'last parameter'");
}

original_code:
void test_parse_with_last_param() {
    char* last_param;
    struct raw_event* raw;
    raw = lst_parse("TEST This is a message test with a :last parameter");
    last_param = raw->params[raw->num_params -1];
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_with_last_param: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 8)) { mu_fail("test_parse_with_last_param: there should be 8 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"last parameter") == 0))) { mu_fail("test_parse_with_last_param: last parameter should be 'last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_with_last_param() {
    char *last_param;
    struct raw_event *raw;
    raw = lst_parse("TEST This is a message test with a :last parameter");
    last_param = raw->params[raw->num_params -1];
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_with_last_param: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 8)) { mu_fail("test_parse_with_last_param: there should be 8 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"last parameter") == 0))) { mu_fail("test_parse_with_last_param: last parameter should be 'last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse(":prefix TEST This is a message test with a :last parameter");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix_and_last_param: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix_and_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 8 )
return mu_fail("test_parse_with_prefix_and_last_param: there should be 8 parameters");
if ( !strcmp(*(const char **)(v0 + 104), "last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix_and_last_param: last parameter should be 'last parameter'");
}

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

v0 = func0(":prefix TEST This is a message test with a :last parameter");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix_and_last_param: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix_and_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 8 )
return mu_fail("test_parse_with_prefix_and_last_param: there should be 8 parameters");
if ( !strcmp(*(const char **)(v0 + 104), "last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix_and_last_param: last parameter should be 'last parameter'");
}

original_code:
void test_parse_with_prefix_and_last_param() {
    char* last_param;
    struct raw_event* raw;
    raw = lst_parse(":prefix TEST This is a message test with a :last parameter");
    last_param = raw->params[raw->num_params - 1];
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 8)) { mu_fail("test_parse_with_prefix_and_last_param: there should be 8 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"last parameter") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: last parameter should be 'last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_with_prefix_and_last_param() {
    char *last_param;
    struct raw_event *raw;
    raw = lst_parse(":prefix TEST This is a message test with a :last parameter");
    last_param = raw->params[raw->num_params - 1];
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 8)) { mu_fail("test_parse_with_prefix_and_last_param: there should be 8 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"last parameter") == 0))) { mu_fail("test_parse_with_prefix_and_last_param: last parameter should be 'last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse("TEST :only last parameter");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_only_last_param: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_only_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 1 )
return mu_fail("test_parse_only_last_param: there should be 1 parameters");
if ( !strcmp(*(const char **)(v0 + 48), "only last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_only_last_param: last parameter should be 'only last parameter'");
}

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

v0 = func0("TEST :only last parameter");
if ( *(_QWORD *)(v0 + 32) )
return mu_fail("test_parse_only_last_param: prefix should be NULL");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_only_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 1 )
return mu_fail("test_parse_only_last_param: there should be 1 parameters");
if ( !strcmp(*(const char **)(v0 + 48), "only last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_only_last_param: last parameter should be 'only last parameter'");
}

original_code:
void test_parse_only_last_param() {
    char* last_param;
    struct raw_event* raw;
    raw = lst_parse("TEST :only last parameter");
    last_param = raw->params[raw->num_params -1];
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_only_last_param: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_only_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 1)) { mu_fail("test_parse_only_last_param: there should be 1 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"only last parameter") == 0))) { mu_fail("test_parse_only_last_param: last parameter should be 'only last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_only_last_param() {
    char *last_param;
    struct raw_event *raw;
    raw = lst_parse("TEST :only last parameter");
    last_param = raw->params[raw->num_params -1];
    do { if (!(raw->prefix == ((void *)0))) { mu_fail("test_parse_only_last_param: prefix should be NULL"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_only_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 1)) { mu_fail("test_parse_only_last_param: there should be 1 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"only last parameter") == 0))) { mu_fail("test_parse_only_last_param: last parameter should be 'only last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

v0 = lst_parse(":prefix TEST :only last parameter");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix_only_last_param: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix_only_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 1 )
return mu_fail("test_parse_with_prefix_only_last_param: there should be 1 parameters");
if ( !strcmp(*(const char **)(v0 + 48), "only last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix_only_last_param: last parameter should be 'only last parameter'");
}

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

v0 = func0(":prefix TEST :only last parameter");
if ( strcmp(*(const char **)(v0 + 32), "prefix") )
return mu_fail("test_parse_with_prefix_only_last_param: prefix should be 'prefix'");
if ( strcmp(*(const char **)(v0 + 24), "TEST") )
return mu_fail("test_parse_with_prefix_only_last_param: type should be 'TEST'");
if ( *(_DWORD *)(v0 + 40) != 1 )
return mu_fail("test_parse_with_prefix_only_last_param: there should be 1 parameters");
if ( !strcmp(*(const char **)(v0 + 48), "only last parameter") )
return evt_raw_destroy(v0);
return mu_fail("test_parse_with_prefix_only_last_param: last parameter should be 'only last parameter'");
}

original_code:
void test_parse_with_prefix_only_last_param() {
    char* last_param;
    struct raw_event* raw;
    raw = lst_parse(":prefix TEST :only last parameter");
    last_param = raw->params[raw->num_params - 1];
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 1)) { mu_fail("test_parse_with_prefix_only_last_param: there should be 1 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"only last parameter") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: last parameter should be 'only last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}

canonical_original_code:
void test_parse_with_prefix_only_last_param() {
    char *last_param;
    struct raw_event *raw;
    raw = lst_parse(":prefix TEST :only last parameter");
    last_param = raw->params[raw->num_params - 1];
    do { if (!((strcmp(raw->prefix,"prefix") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: prefix should be 'prefix'"); return; } } while (0);
    do { if (!((strcmp(raw->type,"TEST") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: type should be 'TEST'"); return; } } while (0);
    do { if (!(raw->num_params == 1)) { mu_fail("test_parse_with_prefix_only_last_param: there should be 1 parameters"); return; } } while (0);
    do { if (!((strcmp(last_param,"only last parameter") == 0))) { mu_fail("test_parse_with_prefix_only_last_param: last parameter should be 'only last parameter'"); return; } } while (0);
    evt_raw_destroy(raw);
}


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

test_parse_empty_message();
++tests_run;
test_parse();
++tests_run;
test_parse_with_prefix();
++tests_run;
test_parse_with_last_param();
++tests_run;
test_parse_with_prefix_and_last_param();
++tests_run;
test_parse_only_last_param();
++tests_run;
result = test_parse_with_prefix_only_last_param();
++tests_run;
return result;
}

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

func2();
++tests_run;
func3();
++tests_run;
func4();
++tests_run;
func5();
++tests_run;
func6();
++tests_run;
func7();
++tests_run;
result = func8();
++tests_run;
return result;
}

original_code:
void test_listener() {
    do { (void)0; test_parse_empty_message(); tests_run++; } while (0);
    do { (void)0; test_parse(); tests_run++; } while (0);
    do { (void)0; test_parse_with_prefix(); tests_run++; } while (0);
    do { (void)0; test_parse_with_last_param(); tests_run++; } while (0);
    do { (void)0; test_parse_with_prefix_and_last_param(); tests_run++; } while (0);
    do { (void)0; test_parse_only_last_param(); tests_run++; } while (0);
    do { (void)0; test_parse_with_prefix_only_last_param(); tests_run++; } while (0);
}


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

if ( !(unsigned int)is_error(&unk_173) )
return mu_fail("test_is_error: 400 should be a valid error");
if ( !(unsigned int)is_error(&unk_177) )
return mu_fail("test_is_error: 427 should be a valid error");
if ( !(unsigned int)is_error(&unk_17B) )
return mu_fail("test_is_error: 599 should be a valid error");
if ( (unsigned int)is_error(&unk_17F) )
return mu_fail("test_is_error: 200 should not be a valid error");
if ( (unsigned int)is_error(&unk_183) )
return mu_fail("test_is_error: 299 should not be a valid error");
result = is_error(&unk_187);
if ( (_DWORD)result )
result = mu_fail("test_is_error: 600 should not be a valid error");
return result;
}

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

if ( !(unsigned int)is_error(&unk_173) )
return mu_fail("test_is_error: 400 should be a valid error");
if ( !(unsigned int)is_error(&unk_177) )
return mu_fail("test_is_error: 427 should be a valid error");
if ( !(unsigned int)is_error(&unk_17B) )
return mu_fail("test_is_error: 599 should be a valid error");
if ( (unsigned int)is_error(&unk_17F) )
return mu_fail("test_is_error: 200 should not be a valid error");
if ( (unsigned int)is_error(&unk_183) )
return mu_fail("test_is_error: 299 should not be a valid error");
result = is_error(&unk_187);
if ( (_DWORD)result )
result = mu_fail("test_is_error: 600 should not be a valid error");
return result;
}

original_code:
void test_is_error() {
    do { if (!(is_error("400"))) { mu_fail("test_is_error: 400 should be a valid error"); return; } } while (0);
    do { if (!(is_error("427"))) { mu_fail("test_is_error: 427 should be a valid error"); return; } } while (0);
    do { if (!(is_error("599"))) { mu_fail("test_is_error: 599 should be a valid error"); return; } } while (0);
    do { if (!(!is_error("200"))) { mu_fail("test_is_error: 200 should not be a valid error"); return; } } while (0);
    do { if (!(!is_error("399"))) { mu_fail("test_is_error: 299 should not be a valid error"); return; } } while (0);
    do { if (!(!is_error("600"))) { mu_fail("test_is_error: 600 should not be a valid error"); return; } } while (0);
}


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

if ( !(unsigned int)is_numeric_response(&unk_17F) )
return mu_fail("test_is_numeric_response: 200 should be a valid response");
if ( !(unsigned int)is_numeric_response(&unk_183) )
return mu_fail("test_is_numeric_response: 399 should be a valid response");
if ( !(unsigned int)is_numeric_response(&unk_18B) )
return mu_fail("test_is_numeric_response: 250 should be a valid response");
if ( (unsigned int)is_numeric_response(&unk_18F) )
return mu_fail("test_is_numeric_response: 199 should not be a valid response");
if ( (unsigned int)is_numeric_response(&unk_173) )
return mu_fail("test_is_numeric_response: 400 should not be a valid response");
result = is_numeric_response(&unk_193);
if ( (_DWORD)result )
result = mu_fail("test_is_numeric_response: 403 should not be a valid response");
return result;
}

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

if ( !(unsigned int)is_numeric_response(&unk_17F) )
return mu_fail("test_is_numeric_response: 200 should be a valid response");
if ( !(unsigned int)is_numeric_response(&unk_183) )
return mu_fail("test_is_numeric_response: 399 should be a valid response");
if ( !(unsigned int)is_numeric_response(&unk_18B) )
return mu_fail("test_is_numeric_response: 250 should be a valid response");
if ( (unsigned int)is_numeric_response(&unk_18F) )
return mu_fail("test_is_numeric_response: 199 should not be a valid response");
if ( (unsigned int)is_numeric_response(&unk_173) )
return mu_fail("test_is_numeric_response: 400 should not be a valid response");
result = is_numeric_response(&unk_193);
if ( (_DWORD)result )
result = mu_fail("test_is_numeric_response: 403 should not be a valid response");
return result;
}

original_code:
void test_is_numeric_response() {
    do { if (!(is_numeric_response("200"))) { mu_fail("test_is_numeric_response: 200 should be a valid response"); return; } } while (0);
    do { if (!(is_numeric_response("399"))) { mu_fail("test_is_numeric_response: 399 should be a valid response"); return; } } while (0);
    do { if (!(is_numeric_response("250"))) { mu_fail("test_is_numeric_response: 250 should be a valid response"); return; } } while (0);
    do { if (!(!is_numeric_response("199"))) { mu_fail("test_is_numeric_response: 199 should not be a valid response"); return; } } while (0);
    do { if (!(!is_numeric_response("400"))) { mu_fail("test_is_numeric_response: 400 should not be a valid response"); return; } } while (0);
    do { if (!(!is_numeric_response("403"))) { mu_fail("test_is_numeric_response: 403 should not be a valid response"); return; } } while (0);
}


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

test_is_error();
++tests_run;
result = test_is_numeric_response();
++tests_run;
return result;
}

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

func0();
++tests_run;
result = func1();
++tests_run;
return result;
}

original_code:
void test_codes() {
    do { (void)0; test_is_error(); tests_run++; } while (0);
    do { (void)0; test_is_numeric_response(); tests_run++; } while (0);
}


decompiled_code:
void __fastcall shutdown_handler(int a1, int a2)
{
if ( a1 <= 2 )
{
if ( a1 <= 0 )
return;
LABEL_5:
shutdown(a1, a2);
return;
}
if ( a1 == 15 )
goto LABEL_5;
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2)
{
if ( a1 <= 2 )
{
if ( a1 <= 0 )
return;
LABEL_5:
func0(a1, a2);
return;
}
if ( a1 == 15 )
goto LABEL_5;
}

original_code:
void shutdown_handler(int signal) {
    switch (signal) {
        case 1:
        case 15:
        case 2:
            _shutdown();
            break;
        default:
            break;
    }
}

variable_types: signal int


decompiled_code:
__int64 irc_bind_event()
{
return bnd_bind();
}

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

original_code:
void irc_bind_event(char* event, Callback callback) {
    bnd_bind(event, callback);
}

canonical_original_code:
void irc_bind_event(char *event, void (*callback)()) {
    bnd_bind(event, callback);
}

variable_types:
event
char *

variable_types:
callback
void (*)()


decompiled_code:
__int64 irc_unbind_event()
{
return bnd_unbind();
}

canonical_decompiled_code:
__int64 func3()
{
return bnd_unbind();
}

original_code:
void irc_unbind_event(char* event) {
    bnd_unbind(event);
}

canonical_original_code:
void irc_unbind_event(char *event) {
    bnd_unbind(event);
}


original_code:
void irc_bind_command(char* command, Callback callback) {
    char key[50];
    memset(key, '\0', 50);
    build_command_key(key, command);
    bnd_bind(key, callback);
}

canonical_original_code:
void irc_bind_command(char *command, void (*callback)()) {
    char key[50];
    memset(key, '\0', 50);
    build_command_key(key, command);
    bnd_bind(key, callback);
}

variable_types:
command
char *

variable_types:
key
char [50]


original_code:
void irc_unbind_command(char* command) {
    char key[50];
    memset(key, '\0', 50);
    build_command_key(key, command);
    bnd_unbind(key);
}

canonical_original_code:
void irc_unbind_command(char *command) {
    char key[50];
    memset(key, '\0', 50);
    build_command_key(key, command);
    bnd_unbind(key);
}


decompiled_code:
__int64 irc_connect()
{
return net_connect();
}

canonical_decompiled_code:
__int64 func6()
{
return net_connect();
}

original_code:
void irc_connect(char* address, char* port) {
    net_connect(address, port);
}

canonical_original_code:
void irc_connect(char *address, char *port) {
    net_connect(address, port);
}

variable_types:
address
char *

variable_types:
port
char *


decompiled_code:
__int64 irc_disconnect()
{
return net_disconnect();
}

canonical_decompiled_code:
__int64 func7()
{
return net_disconnect();
}

original_code:
void irc_disconnect() {
    net_disconnect();
}


decompiled_code:
int irc_listen()
{
int v0; // esi
const char *v1; // rdi
int result; // eax
_BYTE v3[536]; // [rsp+0h] [rbp-218h] BYREF

_sysv_signal(1, (__sighandler_t)shutdown_handler);
_sysv_signal(15, (__sighandler_t)shutdown_handler);
_sysv_signal(2, (__sighandler_t)shutdown_handler);
v0 = lib_name;
v1 = "Starting %s %s...\n Git: %s\n Build: %s\n Platform: %s\n";
printf(
"Starting %s %s...\n Git: %s\n Build: %s\n Platform: %s\n",
*(const char **)&lib_name,
lib_version,
git_revision,
build_date,
build_platform);
result = dsp_start();
while ( !shutdown_requested )
{
result = net_listen();
switch ( result )
{
case 1:
perror("Error listening for messages");
exit(1);
case 2:
result = shutdown((int)v1, v0);
break;
case 0:
net_recv(v3);
v1 = v3;
result = lst_handle(v3);
break;
}
}
return result;
}

canonical_decompiled_code:
int func8()
{
int v0; // esi
const char *v1; // rdi
int result; // eax
_BYTE v3[536]; // [rsp+0h] [rbp-218h] BYREF

_sysv_signal(1, (__sighandler_t)shutdown_handler);
_sysv_signal(15, (__sighandler_t)shutdown_handler);
_sysv_signal(2, (__sighandler_t)shutdown_handler);
v0 = lib_name;
v1 = "Starting %s %s...\n Git: %s\n Build: %s\n Platform: %s\n";
printf(
"Starting %s %s...\n Git: %s\n Build: %s\n Platform: %s\n",
*(const char **)&lib_name,
lib_version,
git_revision,
build_date,
build_platform);
result = dsp_start();
while ( !shutdown_requested )
{
result = net_listen();
switch ( result )
{
case 1:
perror("Error listening for messages");
exit(1);
case 2:
result = func0((int)v1, v0);
break;
case 0:
net_recv(v3);
v1 = v3;
result = lst_handle(v3);
break;
}
}
return result;
}

original_code:
void irc_listen() {
    enum net_status status;
    char msg[(512 + 1)];
    signal(1, shutdown_handler);
    signal(15, shutdown_handler);
    signal(2, shutdown_handler);
    printf("Starting %s %s...\n  Git: %s\n  Build: %s\n  Platform: %s\n",
        lib_name, lib_version, git_revision, build_date, build_platform);
    dsp_start();
    while (shutdown_requested == 0) {
        status = net_listen();
        switch(status) {
            case NET_ERROR:
                perror("Error listening for messages");
                exit(1);
                break;
            case NET_CLOSE:
                (void)0;
                _shutdown();
                break;
            case NET_READY:
                net_recv(msg);
                lst_handle(msg);
                break;
            case NET_TIMEOUT:
                (void)0;
                break;
            default:
                break;
        }
    }
    (void)0;
}

canonical_original_code:
void irc_listen() {
    enum net_status status;
    char msg[-1];
    signal(1, shutdown_handler);
    signal(15, shutdown_handler);
    signal(2, shutdown_handler);
    printf("Starting %s %s...\n  Git: %s\n  Build: %s\n  Platform: %s\n",
        lib_name, lib_version, git_revision, build_date, build_platform);
    dsp_start();
    while (shutdown_requested == 0) {
        status = net_listen();
        switch(status) {
            case NET_ERROR:
                perror("Error listening for messages");
                exit(1);
                break;
            case NET_CLOSE:
                (void)0;
                _shutdown();
                break;
            case NET_READY:
                net_recv(msg);
                lst_handle(msg);
                break;
            case NET_TIMEOUT:
                (void)0;
                break;
            default:
                break;
        }
    }
    (void)0;
}

variable_types: enum net_status { NET_READY=0, NET_ERROR=1, NET_CLOSE=2, NET_TIMEOUT=3 }

variable_types:
msg
char [-1]


decompiled_code:
__int64 __fastcall irc_nick(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "NICK", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func9(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "NICK", a1);
return net_send(v2);
}

original_code:
void irc_nick(char* nick) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s", "NICK", nick);
    net_send(msg);
}

canonical_original_code:
void irc_nick(char *nick) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s", "NICK", nick);
    net_send(msg);
}

variable_types:
nick
char *


decompiled_code:
__int64 __fastcall irc_user(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s hostname server :%s", "USER", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func10(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s hostname server :%s", "USER", a1, a2);
return net_send(v3);
}

original_code:
void irc_user(char* user_name, char* real_name) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s hostname server :%s", "USER", user_name, real_name);
    net_send(msg);
}

canonical_original_code:
void irc_user(char *user_name, char *real_name) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s hostname server :%s", "USER", user_name, real_name);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_login(const char *a1, const char *a2, const char *a3)
{
irc_nick(a1);
return irc_user(a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1, const char *a2, const char *a3)
{
func9(a1);
return func10(a2, a3);
}

original_code:
void irc_login(char* nick, char* user_name, char* real_name) {
    irc_nick(nick);
    irc_user(user_name, real_name);
}

canonical_original_code:
void irc_login(char *nick, char *user_name, char *real_name) {
    irc_nick(nick);
    irc_user(user_name, real_name);
}


decompiled_code:
__int64 __fastcall irc_quit(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s :%s", "QUIT", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s :%s", "QUIT", a1);
return net_send(v2);
}

original_code:
void irc_quit(char* message) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s :%s", "QUIT", message);
    net_send(msg);
}

canonical_original_code:
void irc_quit(char *message) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s :%s", "QUIT", message);
    net_send(msg);
}

variable_types:
message
char *


decompiled_code:
__int64 __fastcall irc_join(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "JOIN", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func13(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "JOIN", a1);
return net_send(v2);
}

original_code:
void irc_join(char* channel) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s", "JOIN", channel);
    net_send(msg);
}

canonical_original_code:
void irc_join(char *channel) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s", "JOIN", channel);
    net_send(msg);
}

variable_types:
channel
char *


decompiled_code:
__int64 __fastcall irc_join_pass(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s %s", "JOIN", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func14(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s %s", "JOIN", a1, a2);
return net_send(v3);
}

original_code:
void irc_join_pass(char* channel, char* pass) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s %s", "JOIN", channel, pass);
    net_send(msg);
}

canonical_original_code:
void irc_join_pass(char *channel, char *pass) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s %s", "JOIN", channel, pass);
    net_send(msg);
}

variable_types:
pass
char *


decompiled_code:
__int64 __fastcall irc_part(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "PART", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func15(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "PART", a1);
return net_send(v2);
}

original_code:
void irc_part(char* channel) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s", "PART", channel);
    net_send(msg);
}

canonical_original_code:
void irc_part(char *channel) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s", "PART", channel);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_topic(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s :%s", "TOPIC", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func16(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s :%s", "TOPIC", a1, a2);
return net_send(v3);
}

original_code:
void irc_topic(char* channel, char* topic) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s :%s", "TOPIC", channel, topic);
    net_send(msg);
}

canonical_original_code:
void irc_topic(char *channel, char *topic) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s :%s", "TOPIC", channel, topic);
    net_send(msg);
}

variable_types:
topic
char *


decompiled_code:
__int64 __fastcall irc_names(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "NAMES", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func17(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "NAMES", a1);
return net_send(v2);
}

original_code:
void irc_names(char* channel) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s", "NAMES", channel);
    net_send(msg);
}

canonical_original_code:
void irc_names(char *channel) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s", "NAMES", channel);
    net_send(msg);
}


decompiled_code:
__int64 irc_list()
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v1, 0x1FDuLL, "%s", "LIST");
return net_send(v1);
}

canonical_decompiled_code:
__int64 func18()
{
char v1[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v1, 0x1FDuLL, "%s", "LIST");
return net_send(v1);
}

original_code:
void irc_list() {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s", "LIST");
    net_send(msg);
}

canonical_original_code:
void irc_list() {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s", "LIST");
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_invite(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s %s", "INVITE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func19(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s %s", "INVITE", a1, a2);
return net_send(v3);
}

original_code:
void irc_invite(char* nick, char* channel) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s %s", "INVITE", nick, channel);
    net_send(msg);
}

canonical_original_code:
void irc_invite(char *nick, char *channel) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s %s", "INVITE", nick, channel);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_message(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s :%s", "PRIVMSG", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func20(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s :%s", "PRIVMSG", a1, a2);
return net_send(v3);
}

original_code:
void irc_message(char* target, char* message) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s :%s", "PRIVMSG", target, message);
    net_send(msg);
}

canonical_original_code:
void irc_message(char *target, char *message) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s :%s", "PRIVMSG", target, message);
    net_send(msg);
}

variable_types:
target
char *


decompiled_code:
__int64 __fastcall irc_op(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +o %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func21(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +o %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_op(char* channel, char* nick) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +o %s", "MODE", channel, nick);
    net_send(msg);
}

canonical_original_code:
void irc_op(char *channel, char *nick) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +o %s", "MODE", channel, nick);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_deop(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -o %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func22(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -o %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_deop(char* channel, char* nick) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s -o %s", "MODE", channel, nick);
    net_send(msg);
}

canonical_original_code:
void irc_deop(char *channel, char *nick) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s -o %s", "MODE", channel, nick);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_voice(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +v %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func23(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +v %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_voice(char* channel, char* nick) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +v %s", "MODE", channel, nick);
    net_send(msg);
}

canonical_original_code:
void irc_voice(char *channel, char *nick) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +v %s", "MODE", channel, nick);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_devoice(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -v %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func24(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -v %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_devoice(char* channel, char* nick) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s -v %s", "MODE", channel, nick);
    net_send(msg);
}

canonical_original_code:
void irc_devoice(char *channel, char *nick) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s -v %s", "MODE", channel, nick);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_kick(const char *a1, const char *a2, const char *a3)
{
char s[520]; // [rsp+8h] [rbp-208h] BYREF

snprintf(s, 0x1FDuLL, "%s %s %s :%s", "KICK", a1, a2, a3);
return net_send(s);
}

canonical_decompiled_code:
__int64 __fastcall func25(const char *a1, const char *a2, const char *a3)
{
char s[520]; // [rsp+8h] [rbp-208h] BYREF

snprintf(s, 0x1FDuLL, "%s %s %s :%s", "KICK", a1, a2, a3);
return net_send(s);
}

original_code:
void irc_kick(char* channel, char* nick, char* message) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s %s :%s", "KICK", channel, nick, message);
    net_send(msg);
}

canonical_original_code:
void irc_kick(char *channel, char *nick, char *message) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s %s :%s", "KICK", channel, nick, message);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_ban(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +b %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func26(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +b %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_ban(char* channel, char* mask) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +b %s", "MODE", channel, mask);
    net_send(msg);
}

canonical_original_code:
void irc_ban(char *channel, char *mask) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +b %s", "MODE", channel, mask);
    net_send(msg);
}

variable_types:
mask
char *


decompiled_code:
__int64 __fastcall irc_unban(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -b %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func27(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -b %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_unban(char* channel, char* mask) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s -b %s", "MODE", channel, mask);
    net_send(msg);
}

canonical_original_code:
void irc_unban(char *channel, char *mask) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s -b %s", "MODE", channel, mask);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_ban_list(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s +b", "MODE", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func28(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s +b", "MODE", a1);
return net_send(v2);
}

original_code:
void irc_ban_list(char* channel) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +b", "MODE", channel);
    net_send(msg);
}

canonical_original_code:
void irc_ban_list(char *channel) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +b", "MODE", channel);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_limit(const char *a1, unsigned int a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +l %d", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func29(const char *a1, unsigned int a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +l %d", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_limit(char* channel, int limit) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +l %d", "MODE", channel, limit);
    net_send(msg);
}

canonical_original_code:
void irc_limit(char *channel, int limit) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +l %d", "MODE", channel, limit);
    net_send(msg);
}

variable_types: limit int


decompiled_code:
__int64 __fastcall irc_channel_key(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +k %s", "MODE", a1, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func30(const char *a1, const char *a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +k %s", "MODE", a1, a2);
return net_send(v3);
}

original_code:
void irc_channel_key(char* channel, char* key) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +k %s", "MODE", channel, key);
    net_send(msg);
}

canonical_original_code:
void irc_channel_key(char *channel, char *key) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +k %s", "MODE", channel, key);
    net_send(msg);
}

variable_types:
key
char *


decompiled_code:
__int64 __fastcall irc_channel_set(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +", "MODE", a1);
append_channel_flags(v3, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func31(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +", "MODE", a1);
append_channel_flags(v3, a2);
return net_send(v3);
}

original_code:
void irc_channel_set(char* channel, unsigned short int flags) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +", "MODE", channel);
    append_channel_flags(msg, flags);
    net_send(msg);
}

canonical_original_code:
void irc_channel_set(char *channel, unsigned short flags) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +", "MODE", channel);
    append_channel_flags(msg, flags);
    net_send(msg);
}

variable_types:
flags
unsigned short


decompiled_code:
__int64 __fastcall irc_channel_unset(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -", "MODE", a1);
append_channel_flags(v3, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func32(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -", "MODE", a1);
append_channel_flags(v3, a2);
return net_send(v3);
}

original_code:
void irc_channel_unset(char* channel, unsigned short int flags) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s -", "MODE", channel);
    append_channel_flags(msg, flags);
    net_send(msg);
}

canonical_original_code:
void irc_channel_unset(char *channel, unsigned short flags) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s -", "MODE", channel);
    append_channel_flags(msg, flags);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_user_set(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +", "MODE", a1);
append_user_flags(v3, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func33(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s +", "MODE", a1);
append_user_flags(v3, a2);
return net_send(v3);
}

original_code:
void irc_user_set(char* user, unsigned short int flags) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s +", "MODE", user);
    append_user_flags(msg, flags);
    net_send(msg);
}

canonical_original_code:
void irc_user_set(char *user, unsigned short flags) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s +", "MODE", user);
    append_user_flags(msg, flags);
    net_send(msg);
}

variable_types:
user
char *


decompiled_code:
__int64 __fastcall irc_user_unset(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -", "MODE", a1);
append_user_flags(v3, a2);
return net_send(v3);
}

canonical_decompiled_code:
__int64 __fastcall func34(const char *a1, unsigned __int16 a2)
{
char v3[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v3, 0x1FDuLL, "%s %s -", "MODE", a1);
append_user_flags(v3, a2);
return net_send(v3);
}

original_code:
void irc_user_unset(char* user, unsigned short int flags) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s -", "MODE", user);
    append_user_flags(msg, flags);
    net_send(msg);
}

canonical_original_code:
void irc_user_unset(char *user, unsigned short flags) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s -", "MODE", user);
    append_user_flags(msg, flags);
    net_send(msg);
}


decompiled_code:
__int64 __fastcall irc_pong(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "PONG", a1);
return net_send(v2);
}

canonical_decompiled_code:
__int64 __fastcall func35(const char *a1)
{
char v2[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v2, 0x1FDuLL, "%s %s", "PONG", a1);
return net_send(v2);
}

original_code:
void irc_pong(char* server) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), "%s %s", "PONG", server);
    net_send(msg);
}

canonical_original_code:
void irc_pong(char *server) {
    char msg[-1];
    snprintf(msg, (512 - 3), "%s %s", "PONG", server);
    net_send(msg);
}

variable_types:
server
char *


decompiled_code:
__int64 __fastcall irc_raw(const char *a1, const char *a2, const char *a3)
{
char v4[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v4, 0x1FDuLL, ":%s %s %s", a1, a2, a3);
return net_send(v4);
}

canonical_decompiled_code:
__int64 __fastcall func36(const char *a1, const char *a2, const char *a3)
{
char v4[520]; // [rsp+0h] [rbp-208h] BYREF

snprintf(v4, 0x1FDuLL, ":%s %s %s", a1, a2, a3);
return net_send(v4);
}

original_code:
void irc_raw(char* prefix, char* type, char* message) {
    char msg[(512 - 3)];
    snprintf(msg, (512 - 3), ":%s %s %s", prefix, type, message);
    net_send(msg);
}

canonical_original_code:
void irc_raw(char *prefix, char *type, char *message) {
    char msg[-1];
    snprintf(msg, (512 - 3), ":%s %s %s", prefix, type, message);
    net_send(msg);
}

variable_types:
prefix
char *

variable_types:
type
char *


decompiled_code:
__int64 __fastcall give_op(__int64 a1)
{
return irc_op(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return irc_op(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

original_code:
void give_op(MessageEvent* event) {
    irc_op(event->to, event->user.nick);
}

canonical_original_code:
void give_op(struct MessageEvent *event) {
    irc_op(event->to, event->user.nick);
}

variable_types: struct MessageEvent { struct timeval { long tv_sec; long tv_usec; } *timestamp; struct UserInfo { char *nick; char *user; char *server; } user; int is_channel; char *to; char *message; } *

user_defined_types: struct MessageEvent { struct timeval *timestamp; struct UserInfo user; int is_channel; char *to; char *message; }


decompiled_code:
__int64 __fastcall take_op(__int64 a1)
{
return irc_deop(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return irc_deop(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

original_code:
void take_op(MessageEvent* event) {
    irc_deop(event->to, event->user.nick);
}

canonical_original_code:
void take_op(struct MessageEvent *event) {
    irc_deop(event->to, event->user.nick);
}

user_defined_types: struct UserInfo { char *nick; char *user; char *server; }


decompiled_code:
__int64 __fastcall give_voice(__int64 a1)
{
return irc_voice(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return irc_voice(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

original_code:
void give_voice(MessageEvent* event) {
    irc_voice(event->to, event->user.nick);
}

canonical_original_code:
void give_voice(struct MessageEvent *event) {
    irc_voice(event->to, event->user.nick);
}


decompiled_code:
__int64 __fastcall take_voice(__int64 a1)
{
return irc_devoice(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return irc_devoice(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

original_code:
void take_voice(MessageEvent* event) {
    irc_devoice(event->to, event->user.nick);
}

canonical_original_code:
void take_voice(struct MessageEvent *event) {
    irc_devoice(event->to, event->user.nick);
}


upper

decompiled_code:
void __fastcall upper(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( strlen(s) > v1 )
{
s[v1] = (*_ctype_toupper_loc())[s[v1]];
++v1;
}
}
}

canonical_decompiled_code:
void __fastcall func0(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( strlen(s) > v1 )
{
s[v1] = (*_ctype_toupper_loc())[s[v1]];
++v1;
}
}
}

original_code:
void upper(char* str) {
    int i;
    if (str != ((void *)0)) {
        for (i = 0; i < strlen(str); i++) {
            str[i] = toupper(str[i]);
        }
    }
}

canonical_original_code:
void upper(char *str) {
    int i;
    if (str != ((void *)0)) {
        for (i = 0; i < strlen(str); i++) {
            str[i] = toupper(str[i]);
        }
    }
}

variable_types:
str
char *

variable_types: i int


lower

decompiled_code:
void __fastcall lower(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( strlen(s) > v1 )
{
s[v1] = (*_ctype_tolower_loc())[s[v1]];
++v1;
}
}
}

canonical_decompiled_code:
void __fastcall func1(char *s)
{
size_t v1; // rbx

v1 = 0LL;
if ( s )
{
while ( strlen(s) > v1 )
{
s[v1] = (*_ctype_tolower_loc())[s[v1]];
++v1;
}
}
}

original_code:
void lower(char* str) {
    int i;
    if (str != ((void *)0)) {
        for (i = 0; i < strlen(str); i++) {
            str[i] = tolower(str[i]);
        }
    }
}

canonical_original_code:
void lower(char *str) {
    int i;
    if (str != ((void *)0)) {
        for (i = 0; i < strlen(str); i++) {
            str[i] = tolower(str[i]);
        }
    }
}


decompiled_code:
int __fastcall build_command_key(char *a1, const char *a2)
{
return snprintf(a1, 0x32uLL, "%s#%s", "PRIVMSG", a2);
}

canonical_decompiled_code:
int __fastcall func2(char *a1, const char *a2)
{
return snprintf(a1, 0x32uLL, "%s#%s", "PRIVMSG", a2);
}

original_code:
void build_command_key(char* key, char* command) {
    snprintf(key, 50, "%s#%s", "PRIVMSG", command);
}

canonical_original_code:
void build_command_key(char *key, char *command) {
    snprintf(key, 50, "%s#%s", "PRIVMSG", command);
}

variable_types:
command
char *


original_code:
void append_channel_flags(char* str, unsigned short int flags) {
    if (flags & CH_PRIVATE) strcat(str, "p");
    if (flags & CH_SECRET) strcat(str, "s");
    if (flags & CH_INVITEONLY) strcat(str, "i");
    if (flags & CH_TOPICLOCK) strcat(str, "t");
    if (flags & CH_NOEXTMSGS) strcat(str, "n");
    if (flags & CH_MODERATED) strcat(str, "m");
}

canonical_original_code:
void append_channel_flags(char *str, unsigned short flags) {
    if (flags & CH_PRIVATE) strcat(str, "p");
    if (flags & CH_SECRET) strcat(str, "s");
    if (flags & CH_INVITEONLY) strcat(str, "i");
    if (flags & CH_TOPICLOCK) strcat(str, "t");
    if (flags & CH_NOEXTMSGS) strcat(str, "n");
    if (flags & CH_MODERATED) strcat(str, "m");
}


original_code:
void append_user_flags(char* str, unsigned short int flags) {
    if (flags & USR_INVISIBLE) strcat(str, "i");
    if (flags & USR_WALLOPS) strcat(str, "w");
    if (flags & USR_OPERATOR) strcat(str, "o");
}

canonical_original_code:
void append_user_flags(char *str, unsigned short flags) {
    if (flags & USR_INVISIBLE) strcat(str, "i");
    if (flags & USR_WALLOPS) strcat(str, "w");
    if (flags & USR_OPERATOR) strcat(str, "o");
}


decompiled_code:
_BOOL8 __fastcall is_error(const char *a1)
{
return (unsigned int)(atoi(a1) - 400) <= 0xC7;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(const char *a1)
{
return (unsigned int)(atoi(a1) - 400) <= 0xC7;
}

original_code:
int is_error(char* code) {
    int num_code = atoi(code);
    return num_code >= 400 && num_code <= 599;
}

canonical_original_code:
int is_error(char *code) {
    int num_code = atoi(code);
    return num_code >= 400 && num_code <= 599;
}

variable_types:
code
char *

return_type: int


decompiled_code:
_BOOL8 __fastcall is_numeric_response(const char *a1)
{
return (unsigned int)(atoi(a1) - 200) <= 0xC7;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(const char *a1)
{
return (unsigned int)(atoi(a1) - 200) <= 0xC7;
}

original_code:
int is_numeric_response(char* code) {
    int num_code = atoi(code);
    return num_code >= 200 && num_code <= 399;
}

canonical_original_code:
int is_numeric_response(char *code) {
    int num_code = atoi(code);
    return num_code >= 200 && num_code <= 399;
}


decompiled_code:
void __fastcall __noreturn on_nick_in_use(__int64 a1)
{
printf("Nick %s is already in use\n", *(const char **)(a1 + 32));
irc_quit("Bye");
irc_disconnect();
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1)
{
printf("Nick %s is already in use\n", *(const char **)(a1 + 32));
irc_quit("Bye");
irc_disconnect();
exit(1);
}

original_code:
void on_nick_in_use(ErrorEvent* event) {
    printf("Nick %s is already in use\n", event->params[1]);
    irc_quit("Bye");
    irc_disconnect();
    exit(1);
}

canonical_original_code:
void on_nick_in_use(struct ErrorEvent *event) {
    printf("Nick %s is already in use\n", event->params[1]);
    irc_quit("Bye");
    irc_disconnect();
    exit(1);
}

variable_types: struct ErrorEvent { struct timeval { long tv_sec; long tv_usec; } *timestamp; char *code; int num_params; char *params[15]; char *message; } *

user_defined_types: struct ErrorEvent { struct timeval *timestamp; char *code; int num_params; char *params[15]; char *message; }


decompiled_code:
int __fastcall on_error(__int64 a1)
{
return printf("Incoming error message: [%s] %s\n", *(const char **)(a1 + 8), *(const char **)(a1 + 144));
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
return printf("Incoming error message: [%s] %s\n", *(const char **)(a1 + 8), *(const char **)(a1 + 144));
}

original_code:
void on_error(ErrorEvent* event) {
    printf("Incoming error message: [%s] %s\n", event->code, event->message);
}

canonical_original_code:
void on_error(struct ErrorEvent *event) {
    printf("Incoming error message: [%s] %s\n", event->code, event->message);
}


decompiled_code:
int __fastcall on_message(__int64 a1)
{
return printf("Incoming message: [%s] %s\n", *(const char **)(a1 + 8), *(const char **)(a1 + 144));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
return printf("Incoming message: [%s] %s\n", *(const char **)(a1 + 8), *(const char **)(a1 + 144));
}

original_code:
void on_message(GenericEvent* event) {
    printf("Incoming message: [%s] %s\n", event->code, event->message);
}

canonical_original_code:
void on_message(struct GenericEvent *event) {
    printf("Incoming message: [%s] %s\n", event->code, event->message);
}

variable_types: struct GenericEvent { struct timeval { long tv_sec; long tv_usec; } *timestamp; char *code; int num_params; char *params[15]; char *message; } *

user_defined_types: struct GenericEvent { struct timeval *timestamp; char *code; int num_params; char *params[15]; char *message; }


decompiled_code:
char __fastcall on_join(__int64 a1)
{
const char *v1; // rdx
bool v2; // zf
char result; // al
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = *(const char **)(a1 + 8);
v2 = strcmp(v1, "circus-bot") == 0;
result = !v2;
if ( !v2 )
{
snprintf(v4, 0x1EuLL, "Welcome %s", v1);
result = irc_message(*(_QWORD *)(a1 + 32), v4);
}
return result;
}

canonical_decompiled_code:
char __fastcall func3(__int64 a1)
{
const char *v1; // rdx
bool v2; // zf
char result; // al
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = *(const char **)(a1 + 8);
v2 = strcmp(v1, "circus-bot") == 0;
result = !v2;
if ( !v2 )
{
snprintf(v4, 0x1EuLL, "Welcome %s", v1);
result = irc_message(*(_QWORD *)(a1 + 32), v4);
}
return result;
}

original_code:
void on_join(JoinEvent* event) {
    char msg[30];
    if ((strcmp(event->user.nick,"circus-bot") != 0)) {
        snprintf(msg, 30, "Welcome %s", event->user.nick);
        irc_message(event->channel, msg);
    }
}

canonical_original_code:
void on_join(struct JoinEvent *event) {
    char msg[30];
    if ((strcmp(event->user.nick,"circus-bot") != 0)) {
        snprintf(msg, 30, "Welcome %s", event->user.nick);
        irc_message(event->channel, msg);
    }
}

variable_types: struct JoinEvent { struct timeval { long tv_sec; long tv_usec; } *timestamp; struct UserInfo { char *nick; char *user; char *server; } user; char *channel; } *

variable_types:
msg
char [30]

user_defined_types: struct JoinEvent { struct timeval *timestamp; struct UserInfo user; char *channel; }


decompiled_code:
int mu_results()
{
int result; // eax
const char **v1; // rbx

printf(" Tests run: %d\n", (unsigned int)tests_run);
if ( !test_fails )
return puts(" Test result: Ok");
result = printf(" Test result: %d Failures\n", (unsigned int)test_fails);
v1 = (const char **)fails;
if ( fails )
{
do
{
result = printf(" %s\n", v1[1]);
v1 = (const char **)*v1;
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int func0()
{
int result; // eax
const char **v1; // rbx

printf(" Tests run: %d\n", (unsigned int)tests_run);
if ( !test_fails )
return puts(" Test result: Ok");
result = printf(" Test result: %d Failures\n", (unsigned int)test_fails);
v1 = (const char **)fails;
if ( fails )
{
do
{
result = printf(" %s\n", v1[1]);
v1 = (const char **)*v1;
}
while ( v1 );
}
return result;
}

original_code:
void mu_results() {
    struct failure *f;
    printf("  Tests run: %d\n", tests_run);
    if (test_fails == 0) {
        printf("  Test result: Ok\n");
    } else {
        printf("  Test result: %d Failures\n", test_fails);
        for (f = fails; f; f = f->next) {
            printf("    %s\n", f->msg);
        }
    }
}

variable_types: struct failure { struct failure *next; char *msg; } *


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

v0 = fails;
if ( fails )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
free(v1);
}
while ( v0 );
}
}

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

v0 = fails;
if ( fails )
{
do
{
v1 = v0;
v0 = (_QWORD *)*v0;
free(v1);
}
while ( v0 );
}
}

original_code:
void mu_free() {
    struct failure *old, *current;
    old = current = fails;
    while (current) {
        old = current;
        current = current->next;
        free(old);
    }
}

canonical_original_code:
void mu_free() {
    struct failure *old; struct failure *current;
    old = current = fails;
    while (current) {
        old = current;
        current = current->next;
        free(old);
    }
}

user_defined_types: struct failure { struct failure *next; char *msg; }


decompiled_code:
__int64 run_all_tests()
{
test_version();
test_hashtable();
test_binding();
test_utils();
test_codes();
test_events();
test_network();
test_listener();
test_irc();
return test_dispatcher();
}

canonical_decompiled_code:
__int64 func0()
{
test_version();
test_hashtable();
test_binding();
test_utils();
test_codes();
test_events();
test_network();
test_listener();
test_irc();
return test_dispatcher();
}

original_code:
void run_all_tests() {
    do { (void)0; test_version(); } while (0);
    do { (void)0; test_hashtable(); } while (0);
    do { (void)0; test_binding(); } while (0);
    do { (void)0; test_utils(); } while (0);
    do { (void)0; test_codes(); } while (0);
    do { (void)0; test_events(); } while (0);
    do { (void)0; test_network(); } while (0);
    do { (void)0; test_listener(); } while (0);
    do { (void)0; test_irc(); } while (0);
    do { (void)0; test_dispatcher(); } while (0);
}


decompiled_code:
__int64 disable_stdout()
{
unsigned int v0; // ebp
int v1; // ebx

fflush(stdout);
v0 = dup(1);
v1 = open("/dev/null", 1);
dup2(v1, 1);
close(v1);
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // ebp
int v1; // ebx

fflush(stdout);
v0 = dup(1);
v1 = open("/dev/null", 1);
dup2(v1, 1);
close(v1);
return v0;
}

original_code:
int disable_stdout() {
    int original, quiet;
    fflush(stdout);
    original = dup(1);
    quiet = open("/dev/null", 01);
    dup2(quiet, 1);
    close(quiet);
    return original;
}

canonical_original_code:
int disable_stdout() {
    int original; int quiet;
    fflush(stdout);
    original = dup(1);
    quiet = open("/dev/null", 01);
    dup2(quiet, 1);
    close(quiet);
    return original;
}

variable_types: original int

variable_types: quiet int


decompiled_code:
int __fastcall enable_stdout(int fd)
{
fflush(stdout);
dup2(fd, 1);
return close(fd);
}

canonical_decompiled_code:
int __fastcall func2(int fd)
{
fflush(stdout);
dup2(fd, 1);
return close(fd);
}

original_code:
void enable_stdout(int original) {
    fflush(stdout);
    dup2(original, 1);
    close(original);
}


welcome

decompiled_code:
char __fastcall welcome(__int64 a1)
{
const char *v1; // rdx
bool v2; // zf
char result; // al
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = *(const char **)(a1 + 8);
v2 = strcmp(v1, "circus-bot") == 0;
result = !v2;
if ( !v2 )
{
snprintf(v4, 0x1EuLL, "Welcome %s", v1);
result = irc_message(*(_QWORD *)(a1 + 32), v4);
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(__int64 a1)
{
const char *v1; // rdx
bool v2; // zf
char result; // al
char v4[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = *(const char **)(a1 + 8);
v2 = strcmp(v1, "circus-bot") == 0;
result = !v2;
if ( !v2 )
{
snprintf(v4, 0x1EuLL, "Welcome %s", v1);
result = irc_message(*(_QWORD *)(a1 + 32), v4);
}
return result;
}

original_code:
void welcome(JoinEvent* event) {
    char msg[30];
    if ((strcmp(event->user.nick,"circus-bot") != 0)) {
        snprintf(msg, 30, "Welcome %s", event->user.nick);
        irc_message(event->channel, msg);
    }
}

canonical_original_code:
void welcome(struct JoinEvent *event) {
    char msg[30];
    if ((strcmp(event->user.nick,"circus-bot") != 0)) {
        snprintf(msg, 30, "Welcome %s", event->user.nick);
        irc_message(event->channel, msg);
    }
}


decompiled_code:
__int64 __fastcall give_op(__int64 a1)
{
return irc_op(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return irc_op(*(_QWORD *)(a1 + 40), *(_QWORD *)(a1 + 8));
}

original_code:
void give_op(MessageEvent* event) {
    irc_op(event->to, event->user.nick);
}

canonical_original_code:
void give_op(struct MessageEvent *event) {
    irc_op(event->to, event->user.nick);
}


disable

decompiled_code:
__int64 disable()
{
irc_unbind_event("JOIN");
return irc_unbind_command("!op");
}

canonical_decompiled_code:
__int64 func2()
{
irc_unbind_event("JOIN");
return irc_unbind_command("!op");
}

original_code:
void disable(MessageEvent* event) {
    irc_unbind_event("JOIN");
    irc_unbind_command("!op");
}

canonical_original_code:
void disable(struct MessageEvent *event) {
    irc_unbind_event("JOIN");
    irc_unbind_command("!op");
}


enable

decompiled_code:
__int64 enable()
{
irc_bind_event("JOIN", welcome);
return irc_bind_command("!op", give_op);
}

canonical_decompiled_code:
__int64 func3()
{
irc_bind_event("JOIN", welcome);
return irc_bind_command("!op", give_op);
}

original_code:
void enable(MessageEvent* event) {
    irc_bind_event("JOIN", (Callback) welcome);
    irc_bind_command("!op", (Callback) give_op);
}

canonical_original_code:
void enable(struct MessageEvent *event) {
    irc_bind_event("JOIN", (void (*)()) welcome);
    irc_bind_command("!op", (void (*)()) give_op);
}


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

if ( !*lib_name )
return mu_fail("test_version_values: lib_name is not set");
if ( !*lib_version )
return mu_fail("test_version_values: lib_version is not set");
if ( !*git_revision )
return mu_fail("test_version_values: git_revision is not set");
if ( !*build_platform )
return mu_fail("test_version_values: build_platform is not set");
result = build_date;
if ( !*build_date )
result = mu_fail("test_version_values: build_date is not set");
return result;
}

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

if ( !*lib_name )
return mu_fail("test_version_values: lib_name is not set");
if ( !*lib_version )
return mu_fail("test_version_values: lib_version is not set");
if ( !*git_revision )
return mu_fail("test_version_values: git_revision is not set");
if ( !*build_platform )
return mu_fail("test_version_values: build_platform is not set");
result = build_date;
if ( !*build_date )
result = mu_fail("test_version_values: build_date is not set");
return result;
}

original_code:
void test_version_values() {
    do { if (!(strlen(lib_name) > 0)) { mu_fail("test_version_values: lib_name is not set"); return; } } while (0);
    do { if (!(strlen(lib_version) > 0)) { mu_fail("test_version_values: lib_version is not set"); return; } } while (0);
    do { if (!(strlen(git_revision) > 0)) { mu_fail("test_version_values: git_revision is not set"); return; } } while (0);
    do { if (!(strlen(build_platform) > 0)) { mu_fail("test_version_values: build_platform is not set"); return; } } while (0);
    do { if (!(strlen(build_date) > 0)) { mu_fail("test_version_values: build_date is not set"); return; } } while (0);
}


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

result = test_version_values();
++tests_run;
return result;
}

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

result = func0();
++tests_run;
return result;
}

original_code:
void test_version() {
    do { (void)0; test_version_values(); tests_run++; } while (0);
}


decompiled_code:
__time_t __fastcall on_event(__int64 a1)
{
__time_t result; // rax
double v2; // xmm0_8
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v3, 0LL);
result = 1000000 * (v3.tv_sec - **(_QWORD **)a1) + LODWORD(v3.tv_usec) - *(_DWORD *)(*(_QWORD *)a1 + 8LL);
if ( *(double *)&avg_sec <= 0.0 )
v2 = (double)(int)result;
else
v2 = (*(double *)&avg_sec + (double)(int)result) * 0.5;
*(double *)&avg_sec = v2 / 1000000.0;
++evt_total;
return result;
}

canonical_decompiled_code:
__time_t __fastcall func0(__int64 a1)
{
__time_t result; // rax
double v2; // xmm0_8
struct timeval v3; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v3, 0LL);
result = 1000000 * (v3.tv_sec - **(_QWORD **)a1) + LODWORD(v3.tv_usec) - *(_DWORD *)(*(_QWORD *)a1 + 8LL);
if ( *(double *)&avg_sec <= 0.0 )
v2 = (double)(int)result;
else
v2 = (*(double *)&avg_sec + (double)(int)result) * 0.5;
*(double *)&avg_sec = v2 / 1000000.0;
++evt_total;
return result;
}

original_code:
void on_event(GenericEvent* event) {
    struct timeval current_time;
    long int avg;
    gettimeofday(&current_time, ((void *)0));
    avg = (current_time.tv_sec - event->timestamp->tv_sec) * 1000000 + ((int) current_time.tv_usec - (int) event->timestamp->tv_usec);
    avg_sec = (avg_sec > 0 ? (avg_sec + avg) / (double) 2 : avg) / 1000000;
    evt_total++;
}

canonical_original_code:
void on_event(struct GenericEvent *event) {
    struct timeval current_time;
    long avg;
    gettimeofday(&current_time, ((void *)0));
    avg = (current_time.tv_sec - event->timestamp->tv_sec) * 1000000 + ((int) current_time.tv_usec - (int) event->timestamp->tv_usec);
    avg_sec = (avg_sec > 0 ? (avg_sec + avg) / (double) 2 : avg) / 1000000;
    evt_total++;
}

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

variable_types: avg long


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 i; // rbx
int v5; // ebx
char v7[40]; // [rsp+0h] [rbp-C8h] BYREF
__int64 v8; // [rsp+28h] [rbp-A0h]
__int64 v9; // [rsp+30h] [rbp-98h]
__int64 v10; // [rsp+38h] [rbp-90h]
__int64 v11; // [rsp+40h] [rbp-88h]
__int64 v12; // [rsp+48h] [rbp-80h]
__int64 v13; // [rsp+50h] [rbp-78h]
__int64 v14; // [rsp+58h] [rbp-70h]
int v15; // [rsp+60h] [rbp-68h]
struct timeval v16; // [rsp+70h] [rbp-58h] BYREF
struct timeval tv; // [rsp+80h] [rbp-48h] BYREF

if ( argc != 2 )
{
printf("Usage: %s <num_events>\n", *argv);
exit(1);
}
v3 = strtol(argv[1], 0LL, 0);
bnd_bind("ALL", on_event);
dsp_start();
printf("Starting benchmark with %ld events\n", v3);
gettimeofday(&tv, 0LL);
if ( v3 > 0 )
{
for ( i = 0LL; i != v3; ++i )
{
strcpy(v7, ":nick!~user@server MODE #test +inm\r\n");
v8 = 0LL;
v9 = 0LL;
v10 = 0LL;
v11 = 0LL;
v12 = 0LL;
v13 = 0LL;
v14 = 0LL;
v15 = 0;
lst_handle(v7);
}
}
while ( evt_total < v3 )
poll(0LL, 0LL, 10);
gettimeofday(&v16, 0LL);
v5 = 1000000 * (LODWORD(v16.tv_sec) - LODWORD(tv.tv_sec)) + LODWORD(v16.tv_usec) - LODWORD(tv.tv_usec);
dsp_shutdown();
bnd_destroy();
printf(" Run time (secs): %f\n", (double)v5 / 1000000.0);
printf(" Processed events: %ld\n", evt_total);
printf(" Process time per event (secs): %f\n", *(double *)&avg_sec);
return 0;
}

original_code:
int main(int argc, char **argv) {
    long int i, evt_max, el_usec;
    struct timeval start, end;
    if (argc != 2) {
        printf("Usage: %s <num_events>\n", argv[0]);
        exit(1);
    }
    evt_max = strtol(argv[1], ((void *)0), 0);
    bnd_bind("ALL", (Callback) on_event);
    dsp_start();
    printf("Starting benchmark with %ld events\n", evt_max);
    gettimeofday(&start, ((void *)0));
    for (i = 0; i < evt_max; i++) {
        char event[100] = ":nick!~user@server MODE #test +inm\r\n";
        lst_handle(event);
    }
    while (evt_total < evt_max) {
        poll(0, 0, 10);
    }
    gettimeofday(&end, ((void *)0));
    el_usec = (end.tv_sec - start.tv_sec) * 1000000 + ((int) end.tv_usec - (int) start.tv_usec);
    dsp_shutdown();
    bnd_destroy();
    printf("  Run time (secs): %f\n", el_usec / (double) 1000000);
    printf("  Processed events: %ld\n", evt_total);
    printf("  Process time per event (secs): %f\n", avg_sec);
    return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
    long i; long evt_max; long el_usec;
    struct timeval start; struct timeval end;
    if (argc != 2) {
        printf("Usage: %s <num_events>\n", argv[0]);
        exit(1);
    }
    evt_max = strtol(argv[1], ((void *)0), 0);
    bnd_bind("ALL", (void (*)()) on_event);
    dsp_start();
    printf("Starting benchmark with %ld events\n", evt_max);
    gettimeofday(&start, ((void *)0));
    for (i = 0; i < evt_max; i++) {
        char event[100] = ":nick!~user@server MODE #test +inm\r\n";
        lst_handle(event);
    }
    while (evt_total < evt_max) {
        poll(0, 0, 10);
    }
    gettimeofday(&end, ((void *)0));
    el_usec = (end.tv_sec - start.tv_sec) * 1000000 + ((int) end.tv_usec - (int) start.tv_usec);
    dsp_shutdown();
    bnd_destroy();
    printf("  Run time (secs): %f\n", el_usec / (double) 1000000);
    printf("  Processed events: %ld\n", evt_total);
    printf("  Process time per event (secs): %f\n", avg_sec);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i long

variable_types:
event
char [100]


decompiled_code:
int debug_printf(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func0(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
return vfprintf(stderr, format, arg);
}

original_code:
void debug_printf(char *fmt, ...) {
    va_list ap;
    __builtin_va_start(ap,fmt);
    vfprintf(stderr, fmt, ap);
    __builtin_va_end(ap);
}

canonical_original_code:
void debug_printf(char *fmt, ...) {
    __builtin_va_list ap;
    __builtin_va_start(ap,fmt);
    vfprintf(stderr, fmt, ap);
    __builtin_va_end(ap);
}

variable_types:
fmt
char *


decompiled_code:
void __fastcall __noreturn on_nick_in_use(__int64 a1)
{
printf("Nick %s is already in use\n", *(const char **)(a1 + 32));
irc_quit("Bye");
irc_disconnect();
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(__int64 a1)
{
printf("Nick %s is already in use\n", *(const char **)(a1 + 32));
irc_quit("Bye");
irc_disconnect();
exit(1);
}

original_code:
void on_nick_in_use(ErrorEvent* event) {
    printf("Nick %s is already in use\n", event->params[1]);
    irc_quit("Bye");
    irc_disconnect();
    exit(1);
}


logtwo

repo: naegelejd/duneOS

decompiled_code:
__int64 __fastcall logtwo(unsigned int a1)
{
__int64 result; // rax
unsigned int v2; // edx

if ( a1 <= 1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
v2 = a1;
a1 >>= 1;
}
while ( v2 > 3 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
__int64 result; // rax
unsigned int v2; // edx

if ( a1 <= 1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
v2 = a1;
a1 >>= 1;
}
while ( v2 > 3 );
return result;
}

original_code:
static unsigned int logtwo(unsigned int num)
{
    unsigned int p = 0;
    while (num > 1) {
        p++;
        num /= 2;
    }
    return p;
}

variable_types:
num
unsigned int

variable_types:
p
unsigned int

return_type: unsigned int


original_code:
static void populate_superblock(struct ext2_superblock *sb,
        long image_size, long block_size)
{
    unsigned int usable_blocks = (unsigned int)(image_size / block_size);
    sb->s_blocks_count = usable_blocks;
    sb->s_r_blocks_count = usable_blocks / 32;
    sb->s_first_data_block = block_size / EXT2_SUPERBLOCK_LOCATION;
    sb->s_log_block_size = logtwo(block_size / 1024);
    sb->s_log_frag_size = sb->s_log_block_size;
    sb->s_blocks_per_group = 8 * block_size;
    sb->s_frags_per_group = 0;
    sb->s_inodes_per_group = 8 * block_size;
    unsigned int num_block_groups = sb->s_blocks_count / sb->s_blocks_per_group;
    unsigned int block_group_descr_table_size = num_block_groups *
            sizeof(struct ext2_block_group_descr);
    unsigned int block_group_size = sb->s_blocks_per_group * block_size;
    do { printf("Number of blocks: %u\n", sb->s_blocks_count); } while (0);
    do { printf("Number of block groups: %u\n", num_block_groups); } while (0);
    do { printf("Size of block group descriptor table: %u\n", block_group_descr_table_size); } while (0);
    do { printf("Size of block group: %u\n", block_group_size); } while (0);
    sb->s_inodes_count = sb->s_inodes_per_group * num_block_groups;
    sb->s_free_blocks_count = sb->s_blocks_count;
    sb->s_free_inodes_count = sb->s_inodes_count - (
            EXT2_GOOD_OLD_FIRST_INO * num_block_groups);
    sb->s_mtime = 0;
    sb->s_wtime = 0;
    sb->s_mnt_count = 0;
    sb->s_max_mnt_count = 32;
    sb->s_magic = EXT2_SUPER_MAGIC;
    sb->s_state = EXT2_VALID_FS;
    sb->s_errors = EXT2_ERRORS_PANIC;
    sb->s_minor_rev_level = 0;
    sb->s_lastcheck = 0;
    sb->s_checkinterval = 60 * 60 * 24 * 64;
    sb->s_creator_os = EXT2_OS_LINUX;
    sb->s_rev_level = 0;
    sb->s_def_resuid = EXT2_DEF_RESUID;
    sb->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
    sb->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
    sb->s_block_group_nr = sb->s_first_data_block;
    sb->s_feature_compat = 0;
    sb->s_feature_incompat = 0;
    sb->s_feature_ro_compat = 0;
    uint32_t *s_uuid = &sb->s_uuid[0];
    *s_uuid++ = (uint32_t)random();
    *s_uuid++ = (uint32_t)random();
    *s_uuid++ = (uint32_t)random();
    *s_uuid = (uint32_t)random();
    memset(sb->s_volume_name, 0, 16);
    memset(sb->s_last_mounted, 0, 64);
    sb->s_algo_bitmap = EXT2_GZIP_ALG;
    sb->s_prealloc_blocks = 0;
    sb->s_prealloc_dir_blocks = 0;
    memset(sb->s_journal_uuid, 0, sizeof(sb->s_journal_uuid));
    sb->s_journal_inum = 0;
    sb->s_journal_dev = 0;
    sb->s_last_orphan = 0;
    uint32_t *s_hash_seed = &sb->s_hash_seed[0];
    *s_hash_seed++ = (uint32_t)random();
    *s_hash_seed++ = (uint32_t)random();
    *s_hash_seed++ = (uint32_t)random();
    *s_hash_seed = (uint32_t)random();
    sb->s_def_hash_version = 0;
    sb->s_default_mount_options = 0;
    sb->s_first_meta_bg = 0;
}

canonical_original_code:
static void populate_superblock(struct ext2_superblock *sb, long image_size, long block_size)
{
    unsigned int usable_blocks = (unsigned int)(image_size / block_size);
    sb->s_blocks_count = usable_blocks;
    sb->s_r_blocks_count = usable_blocks / 32;
    sb->s_first_data_block = block_size / EXT2_SUPERBLOCK_LOCATION;
    sb->s_log_block_size = logtwo(block_size / 1024);
    sb->s_log_frag_size = sb->s_log_block_size;
    sb->s_blocks_per_group = 8 * block_size;
    sb->s_frags_per_group = 0;
    sb->s_inodes_per_group = 8 * block_size;
    unsigned int num_block_groups = sb->s_blocks_count / sb->s_blocks_per_group;
    unsigned int block_group_descr_table_size = num_block_groups *
            sizeof(struct ext2_block_group_descr);
    unsigned int block_group_size = sb->s_blocks_per_group * block_size;
    do { printf("Number of blocks: %u\n", sb->s_blocks_count); } while (0);
    do { printf("Number of block groups: %u\n", num_block_groups); } while (0);
    do { printf("Size of block group descriptor table: %u\n", block_group_descr_table_size); } while (0);
    do { printf("Size of block group: %u\n", block_group_size); } while (0);
    sb->s_inodes_count = sb->s_inodes_per_group * num_block_groups;
    sb->s_free_blocks_count = sb->s_blocks_count;
    sb->s_free_inodes_count = sb->s_inodes_count - (
            EXT2_GOOD_OLD_FIRST_INO * num_block_groups);
    sb->s_mtime = 0;
    sb->s_wtime = 0;
    sb->s_mnt_count = 0;
    sb->s_max_mnt_count = 32;
    sb->s_magic = EXT2_SUPER_MAGIC;
    sb->s_state = EXT2_VALID_FS;
    sb->s_errors = EXT2_ERRORS_PANIC;
    sb->s_minor_rev_level = 0;
    sb->s_lastcheck = 0;
    sb->s_checkinterval = 60 * 60 * 24 * 64;
    sb->s_creator_os = EXT2_OS_LINUX;
    sb->s_rev_level = 0;
    sb->s_def_resuid = EXT2_DEF_RESUID;
    sb->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
    sb->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
    sb->s_block_group_nr = sb->s_first_data_block;
    sb->s_feature_compat = 0;
    sb->s_feature_incompat = 0;
    sb->s_feature_ro_compat = 0;
    unsigned int *s_uuid = &sb->s_uuid[0];
    *s_uuid++ = (unsigned int)random();
    *s_uuid++ = (unsigned int)random();
    *s_uuid++ = (unsigned int)random();
    *s_uuid = (unsigned int)random();
    memset(sb->s_volume_name, 0, 16);
    memset(sb->s_last_mounted, 0, 64);
    sb->s_algo_bitmap = EXT2_GZIP_ALG;
    sb->s_prealloc_blocks = 0;
    sb->s_prealloc_dir_blocks = 0;
    memset(sb->s_journal_uuid, 0, sizeof(sb->s_journal_uuid));
    sb->s_journal_inum = 0;
    sb->s_journal_dev = 0;
    sb->s_last_orphan = 0;
    unsigned int *s_hash_seed = &sb->s_hash_seed[0];
    *s_hash_seed++ = (unsigned int)random();
    *s_hash_seed++ = (unsigned int)random();
    *s_hash_seed++ = (unsigned int)random();
    *s_hash_seed = (unsigned int)random();
    sb->s_def_hash_version = 0;
    sb->s_default_mount_options = 0;
    sb->s_first_meta_bg = 0;
}

variable_types: struct ext2_superblock { unsigned int s_inodes_count; unsigned int s_blocks_count; unsigned int s_r_blocks_count; unsigned int s_free_blocks_count; unsigned int s_free_inodes_count; unsigned int s_first_data_block; unsigned int s_log_block_size; int s_log_frag_size; unsigned int s_blocks_per_group; unsigned int s_frags_per_group; unsigned int s_inodes_per_group; unsigned int s_mtime; unsigned int s_wtime; unsigned short s_mnt_count; unsigned short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_errors; unsigned short s_minor_rev_level; unsigned int s_lastcheck; unsigned int s_checkinterval; unsigned int s_creator_os; unsigned int s_rev_level; unsigned short s_def_resuid; unsigned short s_def_resgid; unsigned int s_first_ino; unsigned short s_inode_size; unsigned short s_block_group_nr; unsigned int s_feature_compat; unsigned int s_feature_incompat; unsigned int s_feature_ro_compat; unsigned int s_uuid[4]; char s_volume_name[16]; char s_last_mounted[64]; unsigned int s_algo_bitmap; unsigned char s_prealloc_blocks; unsigned char s_prealloc_dir_blocks; unsigned char alignment[2]; unsigned int s_journal_uuid[4]; unsigned int s_journal_inum; unsigned int s_journal_dev; unsigned int s_last_orphan; unsigned int s_hash_seed[4]; unsigned char s_def_hash_version; unsigned char reserved[3]; unsigned int s_default_mount_options; unsigned int s_first_meta_bg; unsigned char unused[760]; } *


repo: naftaliharris/markovian

decompiled_code:
__int64 random64()
{
__int64 v0; // rbx

v0 = random() << 32;
return v0 | random();
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rbx

v0 = random() << 32;
return v0 | random();
}

original_code:
uint64_t random64(void)
{
    uint64_t result = random();
    result = result << 32;
    result |= random();
    return (result);
}

canonical_original_code:
unsigned long random64()
{
    unsigned long result = random();
    result = result << 32;
    result |= random();
    return (result);
}

variable_types:
result
unsigned long

return_type: unsigned long