decompiled_code:
void *alarm_line_init()
{
return calloc(1uLL, 0x28uLL);
}

canonical_decompiled_code:
void *func4()
{
return calloc(1uLL, 0x28uLL);
}

original_code:
alarm_line_t* alarm_line_init()
{
    alarm_line_t* alarm_line = ((void *)0);
    alarm_line = (alarm_line_t*)calloc(1, sizeof(alarm_line_t));
    return alarm_line;
}

canonical_original_code:
struct alarm_line_t *alarm_line_init()
{
    struct alarm_line_t *alarm_line = ((void *)0);
    alarm_line = (struct alarm_line_t *)calloc(1, sizeof(alarm_line_t));
    return alarm_line;
}

variable_types: struct alarm_line_t { char *text; unsigned int hash; unsigned char sent; long timestamp; unsigned short channel; unsigned char event; char description[9]; } *


repo: joeledwards/asl-station-processor

decompiled_code:
__int64 __fastcall alarm_line_destroy(void *ptr)
{
void *v3; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
free(v3);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(void *ptr)
{
void *v3; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
free(v3);
free(ptr);
return 0LL;
}

original_code:
alarm_line_t* alarm_line_destroy( alarm_line_t* alarm_line )
{
    if (alarm_line) {
        if (alarm_line->text) {
            free(alarm_line->text);
        }
        free(alarm_line);
        alarm_line = ((void *)0);
    }
    return alarm_line;
}

canonical_original_code:
struct alarm_line_t *alarm_line_destroy(struct alarm_line_t *alarm_line)
{
    if (alarm_line) {
        if (alarm_line->text) {
            free(alarm_line->text);
        }
        free(alarm_line);
        alarm_line = ((void *)0);
    }
    return alarm_line;
}

return_type: struct alarm_line_t { char *text; unsigned int hash; unsigned char sent; long timestamp; unsigned short channel; unsigned char event; char description[9]; } *


decompiled_code:
void *alarm_context_init()
{
void *v0; // rax
void *v1; // rbx

v0 = calloc(1uLL, 0x78uLL);
v1 = v0;
if ( v0 )
{
if ( (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
else
{
list_attributes_comparator(v1, alarm_list_comparator);
list_attributes_seeker(v1, alarm_list_seeker);
}
}
return v1;
}

canonical_decompiled_code:
void *func6()
{
void *v0; // rax
void *v1; // rbx

v0 = calloc(1uLL, 0x78uLL);
v1 = v0;
if ( v0 )
{
if ( (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
else
{
list_attributes_comparator(v1, alarm_list_comparator);
list_attributes_seeker(v1, alarm_list_seeker);
}
}
return v1;
}

original_code:
alarm_context_t* alarm_context_init()
{
    alarm_context_t* alarm_list = ((void *)0);
    alarm_list = (alarm_context_t*)calloc(1, sizeof(alarm_context_t));
    if (alarm_list) {
        if (list_init(alarm_list) == -1) {
            free(alarm_list);
            alarm_list = ((void *)0);
        } else {
            list_attributes_comparator(alarm_list, _alarm_list_comparator);
            list_attributes_seeker(alarm_list, _alarm_list_seeker);
        }
    }
    return alarm_list;
}

canonical_original_code:
struct list_t *alarm_context_init()
{
    struct list_t *alarm_list = ((void *)0);
    alarm_list = (struct list_t *)calloc(1, sizeof(alarm_context_t));
    if (alarm_list) {
        if (list_init(alarm_list) == -1) {
            free(alarm_list);
            alarm_list = ((void *)0);
        } else {
            list_attributes_comparator(alarm_list, _alarm_list_comparator);
            list_attributes_seeker(alarm_list, _alarm_list_seeker);
        }
    }
    return alarm_list;
}

variable_types: struct list_t { struct list_entry_s { void *data; struct list_entry_s *next; struct list_entry_s *prev; } *head_sentinel; struct list_entry_s *tail_sentinel; struct list_entry_s *mid; unsigned int numels; struct list_entry_s **spareels; unsigned int spareelsnum; int iter_active; unsigned int iter_pos; struct list_entry_s *iter_curentry; struct list_attributes_s { int (*comparator)(void *a, void *b); int (*seeker)(void *el, void *indicator); unsigned long (*meter)(void *el); int copy_data; int (*hasher)(void *el); void *(*serializer)(void *el, unsigned int *serializ_len); void *(*unserializer)(void *data, unsigned int *data_len); } attrs; } *

user_defined_types: struct list_t { struct list_entry_s *head_sentinel; struct list_entry_s *tail_sentinel; struct list_entry_s *mid; unsigned int numels; struct list_entry_s **spareels; unsigned int spareelsnum; int iter_active; unsigned int iter_pos; struct list_entry_s *iter_curentry; struct list_attributes_s attrs; }


decompiled_code:
__int64 __fastcall alarm_context_destroy(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
alarm_line_destroy(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
func5(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

original_code:
alarm_context_t* alarm_context_destroy( alarm_context_t* alarm_list )
{
    alarm_line_t* line = ((void *)0);
    if (alarm_list) {
        while (!list_empty(alarm_list)) {
            line = (alarm_line_t*)list_fetch(alarm_list);
            alarm_line_destroy(line);
        }
        list_destroy(alarm_list);
        free(alarm_list);
        alarm_list = ((void *)0);
    }
    return alarm_list;
}

canonical_original_code:
struct list_t *alarm_context_destroy(struct list_t *alarm_list)
{
    struct alarm_line_t *line = ((void *)0);
    if (alarm_list) {
        while (!list_empty(alarm_list)) {
            line = (struct alarm_line_t *)list_fetch(alarm_list);
            alarm_line_destroy(line);
        }
        list_destroy(alarm_list);
        free(alarm_list);
        alarm_list = ((void *)0);
    }
    return alarm_list;
}

return_type: struct list_t { struct list_entry_s { void *data; struct list_entry_s *next; struct list_entry_s *prev; } *head_sentinel; struct list_entry_s *tail_sentinel; struct list_entry_s *mid; unsigned int numels; struct list_entry_s **spareels; unsigned int spareelsnum; int iter_active; unsigned int iter_pos; struct list_entry_s *iter_curentry; struct list_attributes_s { int (*comparator)(void *a, void *b); int (*seeker)(void *el, void *indicator); unsigned long (*meter)(void *el); int copy_data; int (*hasher)(void *el); void *(*serializer)(void *el, unsigned int *serializ_len); void *(*unserializer)(void *data, unsigned int *data_len); } attrs; } *

user_defined_types: struct alarm_line_t { char *text; unsigned int hash; unsigned char sent; long timestamp; unsigned short channel; unsigned char event; char description[9]; }


decompiled_code:
void *csv_context_init()
{
void *v0; // rax
void *v1; // rbx

v0 = malloc(0x78uLL);
v1 = v0;
if ( v0 )
{
if ( (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
else
{
list_attributes_seeker(v1, buffer_list_seeker);
list_attributes_comparator(v1, buffer_list_comparator);
}
}
return v1;
}

canonical_decompiled_code:
void *func8()
{
void *v0; // rax
void *v1; // rbx

v0 = malloc(0x78uLL);
v1 = v0;
if ( v0 )
{
if ( (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
else
{
list_attributes_seeker(v1, buffer_list_seeker);
list_attributes_comparator(v1, buffer_list_comparator);
}
}
return v1;
}

original_code:
csv_context_t* csv_context_init()
{
    csv_context_t* csv_buffer_list = ((void *)0);
    csv_buffer_list = (csv_context_t*)malloc(sizeof(csv_context_t));
    if (csv_buffer_list) {
        if (list_init(csv_buffer_list) == -1) {
            free(csv_buffer_list);
            csv_buffer_list = ((void *)0);
        } else {
            list_attributes_seeker( csv_buffer_list, _buffer_list_seeker );
            list_attributes_comparator( csv_buffer_list, _buffer_list_comparator );
        }
    }
    return csv_buffer_list;
}

canonical_original_code:
struct list_t *csv_context_init()
{
    struct list_t *csv_buffer_list = ((void *)0);
    csv_buffer_list = (struct list_t *)malloc(sizeof(csv_context_t));
    if (csv_buffer_list) {
        if (list_init(csv_buffer_list) == -1) {
            free(csv_buffer_list);
            csv_buffer_list = ((void *)0);
        } else {
            list_attributes_seeker( csv_buffer_list, _buffer_list_seeker );
            list_attributes_comparator( csv_buffer_list, _buffer_list_comparator );
        }
    }
    return csv_buffer_list;
}

user_defined_types: struct list_attributes_s { int (*comparator)(void *a, void *b); int (*seeker)(void *el, void *indicator); unsigned long (*meter)(void *el); int copy_data; int (*hasher)(void *el); void *(*serializer)(void *el, unsigned int *serializ_len); void *(*unserializer)(void *data, unsigned int *data_len); }

user_defined_types: struct list_entry_s { void *data; struct list_entry_s *next; struct list_entry_s *prev; }


decompiled_code:
void *csv_header_init()
{
return calloc(1uLL, 0x20uLL);
}

canonical_decompiled_code:
void *func9()
{
return calloc(1uLL, 0x20uLL);
}

original_code:
csv_header_t* csv_header_init()
{
    csv_header_t* csv_header = ((void *)0);
    csv_header = (csv_header_t*)calloc(1, sizeof(csv_header_t));
    return csv_header;
}

canonical_original_code:
struct csv_header_t *csv_header_init()
{
    struct csv_header_t *csv_header = ((void *)0);
    csv_header = (struct csv_header_t *)calloc(1, sizeof(csv_header_t));
    return csv_header;
}

variable_types: struct csv_header_t { char *name; char *description; char *unit_of_measure; unsigned short channel; } *


decompiled_code:
__int64 __fastcall csv_header_destroy(void *ptr)
{
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
free(v3);
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 2);
if ( v5 )
free(v5);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *ptr)
{
void *v3; // rdi
void *v4; // rdi
void *v5; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
free(v3);
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
free(v4);
v5 = (void *)*((_QWORD *)ptr + 2);
if ( v5 )
free(v5);
free(ptr);
return 0LL;
}

original_code:
csv_header_t* csv_header_destroy(csv_header_t* csv_header)
{
    if (csv_header) {
        if (csv_header->name) {
            free(csv_header->name);
            csv_header->name = ((void *)0);
        }
        if (csv_header->description) {
            free(csv_header->description);
            csv_header->description = ((void *)0);
        }
        if (csv_header->unit_of_measure) {
            free(csv_header->unit_of_measure);
            csv_header->unit_of_measure = ((void *)0);
        }
        free(csv_header);
        csv_header = ((void *)0);
    }
    return csv_header;
}

canonical_original_code:
struct csv_header_t *csv_header_destroy(struct csv_header_t *csv_header)
{
    if (csv_header) {
        if (csv_header->name) {
            free(csv_header->name);
            csv_header->name = ((void *)0);
        }
        if (csv_header->description) {
            free(csv_header->description);
            csv_header->description = ((void *)0);
        }
        if (csv_header->unit_of_measure) {
            free(csv_header->unit_of_measure);
            csv_header->unit_of_measure = ((void *)0);
        }
        free(csv_header);
        csv_header = ((void *)0);
    }
    return csv_header;
}

return_type: struct csv_header_t { char *name; char *description; char *unit_of_measure; unsigned short channel; } *


decompiled_code:
void *csv_list_init()
{
void *v0; // rax
void *v1; // rbx

v0 = calloc(1uLL, 0x78uLL);
v1 = v0;
if ( v0 && (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
return v1;
}

canonical_decompiled_code:
void *func11()
{
void *v0; // rax
void *v1; // rbx

v0 = calloc(1uLL, 0x78uLL);
v1 = v0;
if ( v0 && (unsigned int)list_init(v0) == -1 )
{
free(v1);
v1 = 0LL;
}
return v1;
}

original_code:
csv_list_t* csv_list_init()
{
    csv_list_t* csv_list = ((void *)0);
    csv_list = (csv_list_t*)calloc(1, sizeof(csv_list_t));
    if (csv_list && (list_init(csv_list) == -1)) {
        free(csv_list);
        csv_list = ((void *)0);
    }
    return csv_list;
}

canonical_original_code:
struct list_t *csv_list_init()
{
    struct list_t *csv_list = ((void *)0);
    csv_list = (struct list_t *)calloc(1, sizeof(csv_list_t));
    if (csv_list && (list_init(csv_list) == -1)) {
        free(csv_list);
        csv_list = ((void *)0);
    }
    return csv_list;
}


decompiled_code:
_QWORD *csv_buffer_init()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x30uLL);
if ( v0 )
{
v0[1] = csv_header_init();
v0[2] = csv_list_init();
}
return v0;
}

canonical_decompiled_code:
_QWORD *func12()
{
_QWORD *v0; // rbx

v0 = calloc(1uLL, 0x30uLL);
if ( v0 )
{
v0[1] = func9();
v0[2] = func11();
}
return v0;
}

original_code:
csv_buffer_t* csv_buffer_init()
{
    csv_buffer_t* csv_buffer = ((void *)0);
    csv_buffer = (csv_buffer_t*)calloc(1, sizeof(csv_buffer_t));
    if (csv_buffer) {
        csv_buffer->header = csv_header_init();
        csv_buffer->list = csv_list_init();
    }
    return csv_buffer;
}

canonical_original_code:
struct csv_buffer_t *csv_buffer_init()
{
    struct csv_buffer_t *csv_buffer = ((void *)0);
    csv_buffer = (struct csv_buffer_t *)calloc(1, sizeof(csv_buffer_t));
    if (csv_buffer) {
        csv_buffer->header = csv_header_init();
        csv_buffer->list = csv_list_init();
    }
    return csv_buffer;
}

variable_types: struct csv_buffer_t { char *file_name; struct csv_header_t { char *name; char *description; char *unit_of_measure; unsigned short channel; } *header; struct list_t { struct list_entry_s { void *data; struct list_entry_s *next; struct list_entry_s *prev; } *head_sentinel; struct list_entry_s *tail_sentinel; struct list_entry_s *mid; unsigned int numels; struct list_entry_s **spareels; unsigned int spareelsnum; int iter_active; unsigned int iter_pos; struct list_entry_s *iter_curentry; struct list_attributes_s { int (*comparator)(void *a, void *b); int (*seeker)(void *el, void *indicator); unsigned long (*meter)(void *el); int copy_data; int (*hasher)(void *el); void *(*serializer)(void *el, unsigned int *serializ_len); void *(*unserializer)(void *data, unsigned int *data_len); } attrs; } *list; long start_time; long end_time; long last_flush; } *

user_defined_types: struct csv_buffer_t { char *file_name; struct csv_header_t *header; struct list_t *list; long start_time; long end_time; long last_flush; }


decompiled_code:
void *csv_row_init()
{
return calloc(1uLL, 0x18uLL);
}

canonical_decompiled_code:
void *func13()
{
return calloc(1uLL, 0x18uLL);
}

original_code:
csv_row_t* csv_row_init()
{
    csv_row_t* csv_row = ((void *)0);
    csv_row = (csv_row_t*)calloc(1, sizeof(csv_row_t));
    return csv_row;
}

canonical_original_code:
struct csv_row_t *csv_row_init()
{
    struct csv_row_t *csv_row = ((void *)0);
    csv_row = (struct csv_row_t *)calloc(1, sizeof(csv_row_t));
    return csv_row;
}

variable_types: struct csv_row_t { long timestamp; int average; int high; int low; unsigned char empty; } *


decompiled_code:
__int64 __fastcall csv_row_destroy(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

original_code:
csv_row_t* csv_row_destroy(csv_row_t* csv_row)
{
    if (csv_row) {
        free(csv_row);
        csv_row = ((void *)0);
    }
    return csv_row;
}

canonical_original_code:
struct csv_row_t *csv_row_destroy(struct csv_row_t *csv_row)
{
    if (csv_row) {
        free(csv_row);
        csv_row = ((void *)0);
    }
    return csv_row;
}

return_type: struct csv_row_t { long timestamp; int average; int high; int low; unsigned char empty; } *


decompiled_code:
__int64 __fastcall csv_list_destroy(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
csv_row_destroy(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
func14(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

original_code:
csv_list_t* csv_list_destroy(csv_list_t* csv_list)
{
    csv_row_t* csv_row = ((void *)0);
    if (csv_list) {
        while(!list_empty(csv_list)) {
            csv_row = list_fetch(csv_list);
            csv_row = csv_row_destroy(csv_row);
        }
        list_destroy(csv_list);
        free(csv_list);
        csv_list = ((void *)0);
    }
    return csv_list;
}

canonical_original_code:
struct list_t *csv_list_destroy(struct list_t *csv_list)
{
    struct csv_row_t *csv_row = ((void *)0);
    if (csv_list) {
        while(!list_empty(csv_list)) {
            csv_row = list_fetch(csv_list);
            csv_row = csv_row_destroy(csv_row);
        }
        list_destroy(csv_list);
        free(csv_list);
        csv_list = ((void *)0);
    }
    return csv_list;
}

user_defined_types: struct csv_row_t { long timestamp; int average; int high; int low; unsigned char empty; }


decompiled_code:
__int64 __fastcall csv_buffer_destroy(void *ptr)
{
void *v3; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
{
free(v3);
*(_QWORD *)ptr = 0LL;
}
*((_QWORD *)ptr + 1) = csv_header_destroy(*((void **)ptr + 1));
csv_list_destroy(*((void **)ptr + 2));
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func16(void *ptr)
{
void *v3; // rdi

if ( !ptr )
return 0LL;
v3 = *(void **)ptr;
if ( v3 )
{
free(v3);
*(_QWORD *)ptr = 0LL;
}
*((_QWORD *)ptr + 1) = func10(*((void **)ptr + 1));
func15(*((void **)ptr + 2));
free(ptr);
return 0LL;
}

original_code:
csv_buffer_t* csv_buffer_destroy(csv_buffer_t* csv_buffer)
{
    if (csv_buffer) {
        if (csv_buffer->file_name) {
            free(csv_buffer->file_name);
            csv_buffer->file_name = ((void *)0);
        }
        csv_buffer->header = csv_header_destroy(csv_buffer->header);
        csv_buffer->list = csv_list_destroy(csv_buffer->list);
        free(csv_buffer);
        csv_buffer = ((void *)0);
    }
    return csv_buffer;
}

canonical_original_code:
struct csv_buffer_t *csv_buffer_destroy(struct csv_buffer_t *csv_buffer)
{
    if (csv_buffer) {
        if (csv_buffer->file_name) {
            free(csv_buffer->file_name);
            csv_buffer->file_name = ((void *)0);
        }
        csv_buffer->header = csv_header_destroy(csv_buffer->header);
        csv_buffer->list = csv_list_destroy(csv_buffer->list);
        free(csv_buffer);
        csv_buffer = ((void *)0);
    }
    return csv_buffer;
}

return_type: struct csv_buffer_t { char *file_name; struct csv_header_t { char *name; char *description; char *unit_of_measure; unsigned short channel; } *header; struct list_t { struct list_entry_s { void *data; struct list_entry_s *next; struct list_entry_s *prev; } *head_sentinel; struct list_entry_s *tail_sentinel; struct list_entry_s *mid; unsigned int numels; struct list_entry_s **spareels; unsigned int spareelsnum; int iter_active; unsigned int iter_pos; struct list_entry_s *iter_curentry; struct list_attributes_s { int (*comparator)(void *a, void *b); int (*seeker)(void *el, void *indicator); unsigned long (*meter)(void *el); int copy_data; int (*hasher)(void *el); void *(*serializer)(void *el, unsigned int *serializ_len); void *(*unserializer)(void *data, unsigned int *data_len); } attrs; } *list; long start_time; long end_time; long last_flush; } *


decompiled_code:
__int64 __fastcall csv_context_destroy(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
csv_buffer_destroy(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(void *ptr)
{
void *v2; // rax

if ( !ptr )
return 0LL;
while ( !(unsigned int)list_empty(ptr) )
{
v2 = (void *)list_fetch(ptr);
func16(v2);
}
list_destroy(ptr);
free(ptr);
return 0LL;
}

original_code:
csv_context_t* csv_context_destroy( csv_context_t* csv_buffer_list )
{
    csv_buffer_t* csv_buffer = ((void *)0);
    if (csv_buffer_list) {
        while (!list_empty(csv_buffer_list)) {
            csv_buffer = list_fetch(csv_buffer_list);
            csv_buffer = csv_buffer_destroy(csv_buffer);
        }
        list_destroy(csv_buffer_list);
        free(csv_buffer_list);
        csv_buffer_list = ((void *)0);
    }
    return csv_buffer_list;
}

canonical_original_code:
struct list_t *csv_context_destroy(struct list_t *csv_buffer_list)
{
    struct csv_buffer_t *csv_buffer = ((void *)0);
    if (csv_buffer_list) {
        while (!list_empty(csv_buffer_list)) {
            csv_buffer = list_fetch(csv_buffer_list);
            csv_buffer = csv_buffer_destroy(csv_buffer);
        }
        list_destroy(csv_buffer_list);
        free(csv_buffer_list);
        csv_buffer_list = ((void *)0);
    }
    return csv_buffer_list;
}

user_defined_types: struct csv_header_t { char *name; char *description; char *unit_of_measure; unsigned short channel; }


decompiled_code:
__int64 __fastcall int32_to_varint(int a1)
{
if ( (unsigned int)(a1 + 16) <= 0x1F )
return 1LL;
if ( (unsigned int)(a1 + 2048) <= 0xFFF )
return 2LL;
if ( (unsigned int)(a1 + 0x40000) <= 0x7FFFF )
return 3LL;
if ( (unsigned int)(a1 + 0x1FFFFFF) > 0x3FFFFFE )
return 5LL;
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(int a1)
{
if ( (unsigned int)(a1 + 16) <= 0x1F )
return 1LL;
if ( (unsigned int)(a1 + 2048) <= 0xFFF )
return 2LL;
if ( (unsigned int)(a1 + 0x40000) <= 0x7FFFF )
return 3LL;
if ( (unsigned int)(a1 + 0x1FFFFFF) > 0x3FFFFFE )
return 5LL;
return 4LL;
}

canonical_original_code:
struct varint int32_to_varint(int integer)
{
    unsigned int *p_integer = ((void *)0);
    struct varint result;
    memset(&result, 0, sizeof(varint));
    p_integer = (unsigned int *)&integer;
    if ((integer < 16) && (integer > -17)) {
        result.num[0] = (*p_integer & 0x0000001f) << 2;
        result.bytes = 1;
    }
    else if ((integer < 2048) && (integer > -2049)) {
        result.num[0] = ((*p_integer & 0x0000001f) << 2) | 0x80;
        result.num[1] = ((*p_integer >> 5) & 0x0000007f);
        result.bytes = 2;
    }
    else if ((integer < 262144) && (integer > -262145)) {
        result.num[0] = ((*p_integer & 0x0000001f) << 2) | 0x80;
        result.num[1] = ((*p_integer >> 5) & 0x0000007f) | 0x80;
        result.num[2] = ((*p_integer >> 12) & 0x0000007f);
        result.bytes = 3;
    }
    else if ((integer < 33554432) && (integer > -33554432)) {
        result.num[0] = ((*p_integer & 0x0000001f) << 2) | 0x80;
        result.num[1] = ((*p_integer >> 5) & 0x0000007f) | 0x80;
        result.num[2] = ((*p_integer >> 12) & 0x0000007f) | 0x80;
        result.num[3] = ((*p_integer >> 19) & 0x0000007f);
        result.bytes = 4;
    }
    else {
        result.num[0] = ((*p_integer & 0x0000001f) << 2) | 0x80;
        result.num[1] = ((*p_integer >> 5) & 0x0000007f) | 0x80;
        result.num[2] = ((*p_integer >> 12) & 0x0000007f) | 0x80;
        result.num[3] = ((*p_integer >> 19) & 0x0000007f) | 0x80;
        result.num[4] = ((*p_integer >> 26) & 0x0000003f);
        result.bytes = 5;
    }
    return result;
}

variable_types: integer int

variable_types: struct varint { unsigned long bytes; unsigned char num[5]; }


decompiled_code:
__int64 __fastcall varint_to_int32(char *a1, _QWORD *a2)
{
unsigned int v2; // ecx
__int64 result; // rax
char v4; // cl
unsigned int v5; // ecx
char v6; // al
char v7; // dl
bool v8; // zf

*a2 = 0LL;
LOBYTE(v2) = ((unsigned __int8)*a1 >> 2) & 0x1F;
*a2 = 1LL;
if ( *a1 >= 0 )
{
v2 = (unsigned __int8)v2;
result = (unsigned __int8)v2 | 0xFFFFFFE0;
if ( (*a1 & 0x40) == 0 )
result = v2;
}
else
{
result = (32 * (unsigned __int8)a1[1]) & 0xFE0 | (unsigned int)(unsigned __int8)v2;
*a2 = 2LL;
v4 = a1[1];
if ( v4 >= 0 )
{
if ( (v4 & 0x40) != 0 )
result = (unsigned __int16)result | 0xFFFFF000;
}
else
{
v5 = result | ((unsigned __int8)a1[2] << 12) & 0x7F000;
*a2 = 3LL;
v6 = a1[2];
if ( v6 >= 0 )
{
v8 = (v6 & 0x40) == 0;
result = v5;
if ( !v8 )
result = v5 | 0xFFF80000;
}
else
{
result = v5 | ((unsigned __int8)a1[3] << 19) & 0x3F80000;
*a2 = 4LL;
v7 = a1[3];
if ( v7 >= 0 )
{
if ( (v7 & 0x40) != 0 )
result = (unsigned int)result | 0xFC000000;
}
else
{
result = ((unsigned __int8)a1[4] << 26) | (unsigned int)result;
*a2 = 5LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(char *a1, _QWORD *a2)
{
unsigned int v2; // ecx
__int64 result; // rax
char v4; // cl
unsigned int v5; // ecx
char v6; // al
char v7; // dl
bool v8; // zf

*a2 = 0LL;
LOBYTE(v2) = ((unsigned __int8)*a1 >> 2) & 0x1F;
*a2 = 1LL;
if ( *a1 >= 0 )
{
v2 = (unsigned __int8)v2;
result = (unsigned __int8)v2 | 0xFFFFFFE0;
if ( (*a1 & 0x40) == 0 )
result = v2;
}
else
{
result = (32 * (unsigned __int8)a1[1]) & 0xFE0 | (unsigned int)(unsigned __int8)v2;
*a2 = 2LL;
v4 = a1[1];
if ( v4 >= 0 )
{
if ( (v4 & 0x40) != 0 )
result = (unsigned __int16)result | 0xFFFFF000;
}
else
{
v5 = result | ((unsigned __int8)a1[2] << 12) & 0x7F000;
*a2 = 3LL;
v6 = a1[2];
if ( v6 >= 0 )
{
v8 = (v6 & 0x40) == 0;
result = v5;
if ( !v8 )
result = v5 | 0xFFF80000;
}
else
{
result = v5 | ((unsigned __int8)a1[3] << 19) & 0x3F80000;
*a2 = 4LL;
v7 = a1[3];
if ( v7 >= 0 )
{
if ( (v7 & 0x40) != 0 )
result = (unsigned int)result | 0xFC000000;
}
else
{
result = ((unsigned __int8)a1[4] << 26) | (unsigned int)result;
*a2 = 5LL;
}
}
}
}
return result;
}

original_code:
int32_t varint_to_int32( uint8_t* integer, size_t* bytes )
{
    int32_t result = 0;
    uint32_t* p_result = ((void *)0);
    uint8_t* p_num = ((void *)0);
    p_num = integer;
    p_result = (uint32_t*)(&result);
    *bytes = 0;
    *p_result |= (*p_num >> 2) & 0x0000001f;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xffffffe0;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 5;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfffff000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 12;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfff80000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 19;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfc000000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x3f) << 26;
    *bytes += 1;
 complete:
    return result;
}

canonical_original_code:
int varint_to_int32(unsigned char *integer, unsigned long *bytes)
{
    int result = 0;
    unsigned int *p_result = ((void *)0);
    unsigned char *p_num = ((void *)0);
    p_num = integer;
    p_result = (unsigned int *)(&result);
    *bytes = 0;
    *p_result |= (*p_num >> 2) & 0x0000001f;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xffffffe0;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 5;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfffff000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 12;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfff80000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x0000007f) << 19;
    *bytes += 1;
    if (!(*p_num & 0x80)) {
        if (*p_num & 0x40) {
            *p_result |= 0xfc000000;
        }
        goto complete;
    } p_num++;
    *p_result |= (*p_num & 0x3f) << 26;
    *bytes += 1;
 complete:
    return result;
}

variable_types:
integer
unsigned char *

variable_types:
bytes
unsigned long *

variable_types: result int

return_type: int


decompiled_code:
__int64 __fastcall map_4_get(__int64 a1, int a2)
{
_BYTE *v2; // rdi
__int64 result; // rax

v2 = (_BYTE *)(a2 / 2 + a1);
if ( (a2 & 1) != 0 )
result = (*v2 >> 4) & 8;
else
result = *v2 & 8;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, int a2)
{
_BYTE *v2; // rdi
__int64 result; // rax

v2 = (_BYTE *)(a2 / 2 + a1);
if ( (a2 & 1) != 0 )
result = (*v2 >> 4) & 8;
else
result = *v2 & 8;
return result;
}

original_code:
uint8_t map_4_get( const uint8_t* map, int index )
{
    map += index / 2;
    if (index % 2)
        return ((*(map) >> 4) & 0x08);
    else
        return (*(map) & 0x08);
}

canonical_original_code:
unsigned char map_4_get(unsigned char *map, int index)
{
    map += index / 2;
    if (index % 2)
        return ((*(map) >> 4) & 0x08);
    else
        return (*(map) & 0x08);
}

variable_types:
map
unsigned char *

variable_types: index int

return_type: unsigned char


decompiled_code:
unsigned __int64 __fastcall map_3_set(__int64 a1, int a2, unsigned __int8 a3)
{
unsigned __int64 result; // rax
_BYTE *v4; // rdi
_BYTE *v5; // rdi
_BYTE *v6; // rdi
_BYTE *v7; // rdi
_BYTE *v8; // rdi

result = (unsigned int)(3 * (a2 / 8));
switch ( a2 % 8 )
{
case 0:
result = (int)result;
*(_BYTE *)((int)result + a1) = *(_BYTE *)((int)result + a1) & 0xF8 | a3 & 7;
break;
case 1:
result = (int)result;
*(_BYTE *)((int)result + a1) = *(_BYTE *)((int)result + a1) & 0xC7 | (8 * a3) & 0x38;
break;
case 2:
*(_BYTE *)(a1 + (int)result) = (a3 << 6) | *(_BYTE *)(a1 + (int)result) & 0x3F;
v4 = (_BYTE *)((int)result + 1 + a1);
result = *v4 & 0xFE;
*v4 = *v4 & 0xFE | ((int)a3 >> 2) & 1;
break;
case 3:
v5 = (_BYTE *)((int)result + 1 + a1);
result = *v5 & 0xF1;
*v5 = *v5 & 0xF1 | (2 * a3) & 0xE;
break;
case 4:
v6 = (_BYTE *)((int)result + 1 + a1);
result = *v6 & 0x8F;
*v6 = *v6 & 0x8F | (16 * a3) & 0x70;
break;
case 5:
*(_BYTE *)(a1 + (int)result + 1) = (a3 << 7) | *(_BYTE *)(a1 + (int)result + 1) & 0x7F;
v7 = (_BYTE *)((int)result + 2 + a1);
result = *v7 & 0xFC;
*v7 = *v7 & 0xFC | ((int)a3 >> 1) & 3;
break;
case 6:
v8 = (_BYTE *)((int)result + 2 + a1);
result = *v8 & 0xE3;
*v8 = *v8 & 0xE3 | (4 * a3) & 0x1C;
break;
case 7:
result = a1 + (int)result + 2;
*(_BYTE *)result = *(_BYTE *)result & 0x1F | (32 * a3);
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func21(__int64 a1, int a2, unsigned __int8 a3)
{
unsigned __int64 result; // rax
_BYTE *v4; // rdi
_BYTE *v5; // rdi
_BYTE *v6; // rdi
_BYTE *v7; // rdi
_BYTE *v8; // rdi

result = (unsigned int)(3 * (a2 / 8));
switch ( a2 % 8 )
{
case 0:
result = (int)result;
*(_BYTE *)((int)result + a1) = *(_BYTE *)((int)result + a1) & 0xF8 | a3 & 7;
break;
case 1:
result = (int)result;
*(_BYTE *)((int)result + a1) = *(_BYTE *)((int)result + a1) & 0xC7 | (8 * a3) & 0x38;
break;
case 2:
*(_BYTE *)(a1 + (int)result) = (a3 << 6) | *(_BYTE *)(a1 + (int)result) & 0x3F;
v4 = (_BYTE *)((int)result + 1 + a1);
result = *v4 & 0xFE;
*v4 = *v4 & 0xFE | ((int)a3 >> 2) & 1;
break;
case 3:
v5 = (_BYTE *)((int)result + 1 + a1);
result = *v5 & 0xF1;
*v5 = *v5 & 0xF1 | (2 * a3) & 0xE;
break;
case 4:
v6 = (_BYTE *)((int)result + 1 + a1);
result = *v6 & 0x8F;
*v6 = *v6 & 0x8F | (16 * a3) & 0x70;
break;
case 5:
*(_BYTE *)(a1 + (int)result + 1) = (a3 << 7) | *(_BYTE *)(a1 + (int)result + 1) & 0x7F;
v7 = (_BYTE *)((int)result + 2 + a1);
result = *v7 & 0xFC;
*v7 = *v7 & 0xFC | ((int)a3 >> 1) & 3;
break;
case 6:
v8 = (_BYTE *)((int)result + 2 + a1);
result = *v8 & 0xE3;
*v8 = *v8 & 0xE3 | (4 * a3) & 0x1C;
break;
case 7:
result = a1 + (int)result + 2;
*(_BYTE *)result = *(_BYTE *)result & 0x1F | (32 * a3);
break;
default:
return result;
}
return result;
}

canonical_original_code:
void map_3_set(unsigned char *map, int index, unsigned char value)
{
    int pos = 0;
    pos = (index / 8) * 3;
    switch (index % 8) {
        case 0 :
            *(map+pos) = (*(map+pos) & 0xf8) | ((value & 0x07) ); break;
        case 1 :
            *(map+pos) = (*(map+pos) & 0xc7) | ((value & 0x07) << 3); break;
        case 2 :
            *(map+pos) = (*(map+pos) & 0x3f) | ((value & 0x03) << 6);
            *(map+pos+1) = (*(map+pos+1) & 0xfe) | ((value & 0x04) >> 2); break;
        case 3 :
            *(map+pos+1) = (*(map+pos+1) & 0xf1) | ((value & 0x07) << 1); break;
        case 4 :
            *(map+pos+1) = (*(map+pos+1) & 0x8f) | ((value & 0x07) << 4); break;
        case 5 :
            *(map+pos+1) = (*(map+pos+1) & 0x7f) | ((value & 0x01) << 7);
            *(map+pos+2) = (*(map+pos+2) & 0xfc) | ((value & 0x06) >> 1); break;
        case 6 :
            *(map+pos+2) = (*(map+pos+2) & 0xe3) | ((value & 0x07) << 2); break;
        case 7 :
            *(map+pos+2) = (*(map+pos+2) & 0x1f) | ((value & 0x07) << 5); break;
    }
}

variable_types:
value
unsigned char

variable_types: pos int

return_type: void


decompiled_code:
char __fastcall map_3_get(__int64 a1, int a2)
{
int v2; // edx
char result; // al

v2 = 3 * (a2 / 8);
switch ( a2 % 8 )
{
case 0:
result = *(_BYTE *)(a1 + v2) & 7;
break;
case 1:
result = (*(_BYTE *)(a1 + v2) >> 3) & 7;
break;
case 2:
result = (*(_BYTE *)(a1 + v2) >> 6) | (4 * *(_BYTE *)(a1 + v2 + 1)) & 4;
break;
case 3:
result = (*(_BYTE *)(a1 + v2 + 1) >> 1) & 7;
break;
case 4:
result = (*(_BYTE *)(a1 + v2 + 1) >> 4) & 7;
break;
case 5:
result = (*(_BYTE *)(a1 + v2 + 1) >> 7) | (2 * *(_BYTE *)(a1 + v2 + 2)) & 6;
break;
case 6:
result = (*(_BYTE *)(a1 + v2 + 2) >> 2) & 7;
break;
case 7:
result = *(_BYTE *)(a1 + v2 + 2) >> 5;
break;
default:
result = 0;
break;
}
return result;
}

canonical_decompiled_code:
char __fastcall func22(__int64 a1, int a2)
{
int v2; // edx
char result; // al

v2 = 3 * (a2 / 8);
switch ( a2 % 8 )
{
case 0:
result = *(_BYTE *)(a1 + v2) & 7;
break;
case 1:
result = (*(_BYTE *)(a1 + v2) >> 3) & 7;
break;
case 2:
result = (*(_BYTE *)(a1 + v2) >> 6) | (4 * *(_BYTE *)(a1 + v2 + 1)) & 4;
break;
case 3:
result = (*(_BYTE *)(a1 + v2 + 1) >> 1) & 7;
break;
case 4:
result = (*(_BYTE *)(a1 + v2 + 1) >> 4) & 7;
break;
case 5:
result = (*(_BYTE *)(a1 + v2 + 1) >> 7) | (2 * *(_BYTE *)(a1 + v2 + 2)) & 6;
break;
case 6:
result = (*(_BYTE *)(a1 + v2 + 2) >> 2) & 7;
break;
case 7:
result = *(_BYTE *)(a1 + v2 + 2) >> 5;
break;
default:
result = 0;
break;
}
return result;
}

original_code:
uint8_t map_3_get( const uint8_t* map, int index )
{
    int pos = 0;
    pos = (index / 8) * 3;
    switch (index % 8) {
        case 0 :
            return ((*(map+pos) ) & 0x07); break;
        case 1 :
            return ((*(map+pos) >> 3) & 0x07); break;
        case 2 :
            return ((*(map+pos) >> 6) & 0x03) |
                   ((*(map+pos+1) << 2) & 0x04); break;
        case 3 :
            return ((*(map+pos+1) >> 1) & 0x07); break;
        case 4 :
            return ((*(map+pos+1) >> 4) & 0x07); break;
        case 5 :
            return ((*(map+pos+1) >> 7) & 0x01) |
                   ((*(map+pos+2) << 1) & 0x06); break;
        case 6 :
            return ((*(map+pos+2) >> 2) & 0x07); break;
        case 7 :
            return ((*(map+pos+2) >> 5) & 0x07); break;
        default:
            return 0;
    };
}

canonical_original_code:
unsigned char map_3_get(unsigned char *map, int index)
{
    int pos = 0;
    pos = (index / 8) * 3;
    switch (index % 8) {
        case 0 :
            return ((*(map+pos) ) & 0x07); break;
        case 1 :
            return ((*(map+pos) >> 3) & 0x07); break;
        case 2 :
            return ((*(map+pos) >> 6) & 0x03) |
                   ((*(map+pos+1) << 2) & 0x04); break;
        case 3 :
            return ((*(map+pos+1) >> 1) & 0x07); break;
        case 4 :
            return ((*(map+pos+1) >> 4) & 0x07); break;
        case 5 :
            return ((*(map+pos+1) >> 7) & 0x01) |
                   ((*(map+pos+2) << 1) & 0x06); break;
        case 6 :
            return ((*(map+pos+2) >> 2) & 0x07); break;
        case 7 :
            return ((*(map+pos+2) >> 5) & 0x07); break;
        default:
            return 0;
    };
}


decompiled_code:
int __fastcall print_seed_time(const char *a1, unsigned __int16 *a2, const char *a3)
{
int result; // eax

if ( a2 )
result = printf(
"%s[%04d-%03d %02d:%02d:%02d.%04d]%s",
a1,
*a2,
a2[1],
*((unsigned __int8 *)a2 + 4),
*((unsigned __int8 *)a2 + 5),
*((unsigned __int8 *)a2 + 6),
a2[4],
a3);
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, unsigned __int16 *a2, const char *a3)
{
int result; // eax

if ( a2 )
result = printf(
"%s[%04d-%03d %02d:%02d:%02d.%04d]%s",
a1,
*a2,
a2[1],
*((unsigned __int8 *)a2 + 4),
*((unsigned __int8 *)a2 + 5),
*((unsigned __int8 *)a2 + 6),
a2[4],
a3);
return result;
}

original_code:
void print_seed_time( const char* prefix_msg, tseed_time* time,
                      const char* postfix_msg ) {
    if ( time ) {
        printf( "%s[%04d-%03d %02d:%02d:%02d.%04d]%s",
                prefix_msg,
                time->STUNION.STGREG.yr,
                time->STUNION.STGREG.jday,
                time->STUNION.STGREG.hr,
                time->STUNION.STGREG.minute,
                time->STUNION.STGREG.seconds,
                time->STUNION.STGREG.tenth_millisec,
                postfix_msg );
    }
}

canonical_original_code:
void print_seed_time(char *prefix_msg, struct tseed_time *time, char *postfix_msg) {
    if ( time ) {
        printf( "%s[%04d-%03d %02d:%02d:%02d.%04d]%s",
                prefix_msg,
                time->STUNION.STGREG.yr,
                time->STUNION.STGREG.jday,
                time->STUNION.STGREG.hr,
                time->STUNION.STGREG.minute,
                time->STUNION.STGREG.seconds,
                time->STUNION.STGREG.tenth_millisec,
                postfix_msg );
    }
}

variable_types: struct tseed_time { union { struct { unsigned short yr; unsigned short jday; unsigned char hr; unsigned char minute; unsigned char seconds; unsigned char unused; unsigned short tenth_millisec; } STGREG; double fpt; } STUNION; } *


decompiled_code:
int __fastcall print_seed_header(__int64 a1)
{
printf("SEED Record:");
printf(
" %c%c_%c%c%c%c%c %c%c-%c%c%c",
(unsigned int)*(char *)(a1 + 20),
(unsigned int)*(char *)(a1 + 21),
(unsigned int)*(char *)(a1 + 10),
(unsigned int)*(char *)(a1 + 11),
(unsigned int)*(char *)(a1 + 12),
(unsigned int)*(char *)(a1 + 13),
(unsigned int)*(char *)(a1 + 14),
(unsigned int)*(char *)(a1 + 15),
(unsigned int)*(char *)(a1 + 16),
(unsigned int)*(char *)(a1 + 17),
(unsigned int)*(char *)(a1 + 18),
(unsigned int)*(char *)(a1 + 19));
return print_seed_time(" ", (unsigned __int16 *)(a1 + 24), "\n");
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
printf("SEED Record:");
printf(
" %c%c_%c%c%c%c%c %c%c-%c%c%c",
(unsigned int)*(char *)(a1 + 20),
(unsigned int)*(char *)(a1 + 21),
(unsigned int)*(char *)(a1 + 10),
(unsigned int)*(char *)(a1 + 11),
(unsigned int)*(char *)(a1 + 12),
(unsigned int)*(char *)(a1 + 13),
(unsigned int)*(char *)(a1 + 14),
(unsigned int)*(char *)(a1 + 15),
(unsigned int)*(char *)(a1 + 16),
(unsigned int)*(char *)(a1 + 17),
(unsigned int)*(char *)(a1 + 18),
(unsigned int)*(char *)(a1 + 19));
return func1(" ", (unsigned __int16 *)(a1 + 24), "\n");
}

original_code:
void print_seed_header( seed_header* header ) {
    printf( "SEED Record:" );
    printf( " %c%c_%c%c%c%c%c %c%c-%c%c%c",
            header->seednet[0],
            header->seednet[1],
            header->station_id_call_letters[0],
            header->station_id_call_letters[1],
            header->station_id_call_letters[2],
            header->station_id_call_letters[3],
            header->station_id_call_letters[4],
            header->location_id[0],
            header->location_id[1],
            header->channel_id[0],
            header->channel_id[1],
            header->channel_id[2] );
    print_seed_time( " ", &header->starting_time, "\n" );
}

canonical_original_code:
void print_seed_header(struct seed_header *header) {
    printf( "SEED Record:" );
    printf( " %c%c_%c%c%c%c%c %c%c-%c%c%c",
            header->seednet[0],
            header->seednet[1],
            header->station_id_call_letters[0],
            header->station_id_call_letters[1],
            header->station_id_call_letters[2],
            header->station_id_call_letters[3],
            header->station_id_call_letters[4],
            header->location_id[0],
            header->location_id[1],
            header->channel_id[0],
            header->channel_id[1],
            header->channel_id[2] );
    print_seed_time( " ", &header->starting_time, "\n" );
}

variable_types: struct seed_header { struct tseed_sequence { union { char ch[6]; unsigned int num; } SSUNION; } sequence; char seed_record_type; char continuation_record; char station_id_call_letters[5]; char location_id[2]; char channel_id[3]; char seednet[2]; struct tseed_time { union { struct { unsigned short yr; unsigned short jday; unsigned char hr; unsigned char minute; unsigned char seconds; unsigned char unused; unsigned short tenth_millisec; } STGREG; double fpt; } STUNION; } starting_time; unsigned short samples_in_record; short sample_rate_factor; short sample_rate_multiplier; unsigned char activity_flags; unsigned char io_flags; unsigned char data_quality_flags; unsigned char number_of_following_blockettes; int tenth_msec_correction; unsigned short first_data_byte; unsigned short first_blockette_byte; struct data_only_blockette { unsigned short blockette_type; unsigned short next_blockette; unsigned char encoding_format; unsigned char word_order; unsigned char rec_length; unsigned char dob_reserved; } dob; struct data_extension_blockette { unsigned short blockette_type; unsigned short next_blockette; unsigned char qual; unsigned char usec99; unsigned char deb_flags; unsigned char frame_count; } deb; } *

user_defined_types: struct seed_header { struct tseed_sequence sequence; char seed_record_type; char continuation_record; char station_id_call_letters[5]; char location_id[2]; char channel_id[3]; char seednet[2]; struct tseed_time starting_time; unsigned short samples_in_record; short sample_rate_factor; short sample_rate_multiplier; unsigned char activity_flags; unsigned char io_flags; unsigned char data_quality_flags; unsigned char number_of_following_blockettes; int tenth_msec_correction; unsigned short first_data_byte; unsigned short first_blockette_byte; struct data_only_blockette dob; struct data_extension_blockette deb; }


original_code:
uint32_t murmur_32 ( const void *key, size_t length, uint32_t seed )
{
    const uint32_t m = 0x5bd1e995;
    const int r = 24;
    uint32_t h;
    uint32_t k;
    const unsigned char* data;
    h = seed ^ length;
    data = (const unsigned char*)key;
    while (length >= 4)
    {
        k = *(uint32_t*)data;
        k *= m;
        k ^= k >> r;
        k *= m;
        h *= m;
        h ^= k;
        data += 4;
        length -= 4;
    }
    switch (length)
    {
        case 3: h ^= data[2] << 16;
        case 2: h ^= data[1] << 8;
        case 1: h ^= data[0];
                h *= m;
    };
    h ^= h >> 13;
    h *= m;
    h ^= h >> 15;
    return h;
}

canonical_original_code:
unsigned int murmur_32(void *key, unsigned long length, unsigned int seed)
{
    unsigned int m = 0x5bd1e995;
    int r = 24;
    unsigned int h;
    unsigned int k;
    unsigned char *data;
    h = seed ^ length;
    data = (unsigned char *)key;
    while (length >= 4)
    {
        k = *(unsigned int *)data;
        k *= m;
        k ^= k >> r;
        k *= m;
        h *= m;
        h ^= k;
        data += 4;
        length -= 4;
    }
    switch (length)
    {
        case 3: h ^= data[2] << 16;
        case 2: h ^= data[1] << 8;
        case 1: h ^= data[0];
                h *= m;
    };
    h ^= h >> 13;
    h *= m;
    h ^= h >> 15;
    return h;
}

variable_types:
key
void *

variable_types:
length
unsigned long

variable_types:
seed
unsigned int

variable_types:
m
unsigned int

variable_types: r int

variable_types:
h
unsigned int

variable_types:
k
unsigned int

variable_types:
data
unsigned char *

return_type: unsigned int


original_code:
uint64_t murmur_64_a ( const void *key, size_t length, uint64_t seed )
{
    const uint64_t m = 0xc6a4a7935bd1e995LL;
    const int r = 47;
    uint64_t h;
    uint64_t k;
    const uint64_t* data;
    const uint64_t* end;
    const unsigned char* data2;
    h = seed ^ length;
    data = (const uint64_t*)key;
    end = data + (length / 8);
    while (data != end)
    {
        k = *data++;
        k *= m;
        k ^= k >> r;
        k *= m;
        h ^= k;
        h *= m;
    }
    data2 = (const unsigned char*)data;
    switch (length & 7)
    {
        case 7: h ^= (uint64_t)(data[6]) << 48;
        case 6: h ^= (uint64_t)(data[5]) << 40;
        case 5: h ^= (uint64_t)(data[4]) << 32;
        case 4: h ^= (uint64_t)(data[3]) << 24;
        case 3: h ^= (uint64_t)(data[2]) << 16;
        case 2: h ^= (uint64_t)(data[1]) << 8;
        case 1: h ^= (uint64_t)(data[0]);
                h *= m;
    };
    h ^= h >> r;
    h *= m;
    h ^= h >> r;
    return h;
}

canonical_original_code:
unsigned long murmur_64_a(void *key, unsigned long length, unsigned long seed)
{
    unsigned long m = 0xc6a4a7935bd1e995LL;
    int r = 47;
    unsigned long h;
    unsigned long k;
    unsigned long *data;
    unsigned long *end;
    unsigned char *data2;
    h = seed ^ length;
    data = (unsigned long *)key;
    end = data + (length / 8);
    while (data != end)
    {
        k = *data++;
        k *= m;
        k ^= k >> r;
        k *= m;
        h ^= k;
        h *= m;
    }
    data2 = (unsigned char *)data;
    switch (length & 7)
    {
        case 7: h ^= (unsigned long)(data[6]) << 48;
        case 6: h ^= (unsigned long)(data[5]) << 40;
        case 5: h ^= (unsigned long)(data[4]) << 32;
        case 4: h ^= (unsigned long)(data[3]) << 24;
        case 3: h ^= (unsigned long)(data[2]) << 16;
        case 2: h ^= (unsigned long)(data[1]) << 8;
        case 1: h ^= (unsigned long)(data[0]);
                h *= m;
    };
    h ^= h >> r;
    h *= m;
    h ^= h >> r;
    return h;
}

variable_types:
seed
unsigned long

variable_types:
m
unsigned long

variable_types:
h
unsigned long

variable_types:
k
unsigned long

variable_types:
data
unsigned long *

variable_types:
end
unsigned long *

return_type: unsigned long


original_code:
uint64_t murmur_64_b ( const void *key, size_t length, uint64_t seed )
{
    const uint32_t m = 0x5bd1e995;
    const int r = 24;
    uint64_t h;
    uint32_t h1;
    uint32_t h2;
    uint32_t k1;
    uint32_t k2;
    const uint32_t* data;
    h1 = seed ^ length;
    h2 = 0;
    data = (const uint32_t*)key;
    while (length >= 8)
    {
        k1 = *data++;
        k1 *= m;
        k1 ^= k1 >> r;
        k1 *= m;
        h1 *= m;
        h1 ^= k1;
        length -= 4;
        k2 = *data++;
        k2 *= m;
        k2 ^= k2 >> r;
        k2 *= m;
        h2 *= m;
        h2 ^= k2;
        length -= 4;
    }
    if (length >= 4)
    {
        k1 = *data++;
        k1 *= m;
        k1 ^= k1 >> r;
        k1 *= m;
        h1 *= m;
        h1 ^= k1;
        length -= 4;
    }
    switch (length)
    {
        case 3: h ^= ((unsigned char*)data)[2] << 16;
        case 2: h ^= ((unsigned char*)data)[1] << 8;
        case 1: h ^= ((unsigned char*)data)[0];
                h *= m;
    };
    h1 ^= h2 >> 18; h1 *=m;
    h2 ^= h1 >> 22; h2 *=m;
    h1 ^= h2 >> 17; h1 *=m;
    h2 ^= h1 >> 19; h2 *=m;
    h = h1;
    h = (h << 32) | h2;
    return h;
}

canonical_original_code:
unsigned long murmur_64_b(void *key, unsigned long length, unsigned long seed)
{
    unsigned int m = 0x5bd1e995;
    int r = 24;
    unsigned long h;
    unsigned int h1;
    unsigned int h2;
    unsigned int k1;
    unsigned int k2;
    unsigned int *data;
    h1 = seed ^ length;
    h2 = 0;
    data = (unsigned int *)key;
    while (length >= 8)
    {
        k1 = *data++;
        k1 *= m;
        k1 ^= k1 >> r;
        k1 *= m;
        h1 *= m;
        h1 ^= k1;
        length -= 4;
        k2 = *data++;
        k2 *= m;
        k2 ^= k2 >> r;
        k2 *= m;
        h2 *= m;
        h2 ^= k2;
        length -= 4;
    }
    if (length >= 4)
    {
        k1 = *data++;
        k1 *= m;
        k1 ^= k1 >> r;
        k1 *= m;
        h1 *= m;
        h1 ^= k1;
        length -= 4;
    }
    switch (length)
    {
        case 3: h ^= ((unsigned char *)data)[2] << 16;
        case 2: h ^= ((unsigned char *)data)[1] << 8;
        case 1: h ^= ((unsigned char *)data)[0];
                h *= m;
    };
    h1 ^= h2 >> 18; h1 *=m;
    h2 ^= h1 >> 22; h2 *=m;
    h1 ^= h2 >> 17; h1 *=m;
    h2 ^= h1 >> 19; h2 *=m;
    h = h1;
    h = (h << 32) | h2;
    return h;
}

variable_types:
data
unsigned int *


decompiled_code:
__int64 __fastcall ST_TimeComp2(unsigned __int64 a1, __int16 a2, unsigned __int64 a3, __int16 a4)
{
__int16 v6; // bp
unsigned int v7; // esi
unsigned __int64 v8; // r9
unsigned __int64 v9; // r10
unsigned __int64 v10; // rdi
__int16 v11; // r12
unsigned int v12; // ecx
unsigned __int64 v13; // r8
char v14; // r13
unsigned __int64 v15; // rdx
__int64 result; // rax

v6 = a1;
v7 = WORD1(a1);
v8 = HIDWORD(a1);
v9 = a1 >> 40;
v10 = HIWORD(a1);
v11 = a3;
v12 = WORD1(a3);
v13 = HIDWORD(a3);
v14 = BYTE5(a3);
v15 = HIWORD(a3);
result = 1LL;
if ( v6 <= v11 )
{
result = 0xFFFFFFFFLL;
if ( v6 >= v11 )
{
result = 1LL;
if ( (__int16)v7 <= (__int16)v12 )
{
result = 0xFFFFFFFFLL;
if ( (__int16)v7 >= (__int16)v12 )
{
result = 1LL;
if ( (char)v8 <= (char)v13 )
{
result = 0xFFFFFFFFLL;
if ( (char)v8 >= (char)v13 )
{
result = 1LL;
if ( (char)v9 <= v14 )
{
result = 0xFFFFFFFFLL;
if ( (char)v9 >= v14 )
{
result = 1LL;
if ( (char)v10 <= (char)v15 )
{
result = 0xFFFFFFFFLL;
if ( (char)v10 >= (char)v15 )
{
result = 1LL;
if ( a2 <= a4 )
result = (unsigned int)-(a2 < a4);
}
}
}
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1, __int16 a2, unsigned __int64 a3, __int16 a4)
{
__int16 v6; // bp
unsigned int v7; // esi
unsigned __int64 v8; // r9
unsigned __int64 v9; // r10
unsigned __int64 v10; // rdi
__int16 v11; // r12
unsigned int v12; // ecx
unsigned __int64 v13; // r8
char v14; // r13
unsigned __int64 v15; // rdx
__int64 result; // rax

v6 = a1;
v7 = WORD1(a1);
v8 = HIDWORD(a1);
v9 = a1 >> 40;
v10 = HIWORD(a1);
v11 = a3;
v12 = WORD1(a3);
v13 = HIDWORD(a3);
v14 = BYTE5(a3);
v15 = HIWORD(a3);
result = 1LL;
if ( v6 <= v11 )
{
result = 0xFFFFFFFFLL;
if ( v6 >= v11 )
{
result = 1LL;
if ( (__int16)v7 <= (__int16)v12 )
{
result = 0xFFFFFFFFLL;
if ( (__int16)v7 >= (__int16)v12 )
{
result = 1LL;
if ( (char)v8 <= (char)v13 )
{
result = 0xFFFFFFFFLL;
if ( (char)v8 >= (char)v13 )
{
result = 1LL;
if ( (char)v9 <= v14 )
{
result = 0xFFFFFFFFLL;
if ( (char)v9 >= v14 )
{
result = 1LL;
if ( (char)v10 <= (char)v15 )
{
result = 0xFFFFFFFFLL;
if ( (char)v10 >= (char)v15 )
{
result = 1LL;
if ( a2 <= a4 )
result = (unsigned int)-(a2 < a4);
}
}
}
}
}
}
}
}
}
}
return result;
}

original_code:
int ST_TimeComp2(STDTIME2 time_arg1, STDTIME2 time_arg2) {
  if (time_arg1.year > time_arg2.year)
    return(1);
  if (time_arg1.year < time_arg2.year)
    return(-1);
  if (time_arg1.day > time_arg2.day)
    return(1);
  if (time_arg1.day < time_arg2.day)
    return(-1);
  if (time_arg1.hour > time_arg2.hour)
    return(1);
  if (time_arg1.hour < time_arg2.hour)
    return(-1);
  if (time_arg1.minute > time_arg2.minute)
    return(1);
  if (time_arg1.minute < time_arg2.minute)
    return(-1);
  if (time_arg1.second > time_arg2.second)
    return(1);
  if (time_arg1.second < time_arg2.second)
    return(-1);
  if (time_arg1.tenth_msec > time_arg2.tenth_msec)
    return(1);
  if (time_arg1.tenth_msec < time_arg2.tenth_msec)
    return(-1);
  return(0);
}

canonical_original_code:
int ST_TimeComp2(struct __sjtim2 time_arg1, struct __sjtim2 time_arg2) {
  if (time_arg1.year > time_arg2.year)
    return(1);
  if (time_arg1.year < time_arg2.year)
    return(-1);
  if (time_arg1.day > time_arg2.day)
    return(1);
  if (time_arg1.day < time_arg2.day)
    return(-1);
  if (time_arg1.hour > time_arg2.hour)
    return(1);
  if (time_arg1.hour < time_arg2.hour)
    return(-1);
  if (time_arg1.minute > time_arg2.minute)
    return(1);
  if (time_arg1.minute < time_arg2.minute)
    return(-1);
  if (time_arg1.second > time_arg2.second)
    return(1);
  if (time_arg1.second < time_arg2.second)
    return(-1);
  if (time_arg1.tenth_msec > time_arg2.tenth_msec)
    return(1);
  if (time_arg1.tenth_msec < time_arg2.tenth_msec)
    return(-1);
  return(0);
}

variable_types: struct __sjtim2 { short year; short day; char hour; char minute; char second; short tenth_msec; }


decompiled_code:
_QWORD *list_new()
{
_QWORD *result; // rax

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

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

result = malloc(0x10uLL);
*result = 0LL;
result[1] = 0LL;
return result;
}

original_code:
List *
list_new(void)
{
  List *new_list;
  new_list = (List*)malloc(sizeof(List));
  new_list->data = ((void *)0);
  new_list->next = ((void *)0);
  return new_list;
}

canonical_original_code:
struct _List *list_new()
{
  struct _List *new_list;
  new_list = (struct _List *)malloc(sizeof(List));
  new_list->data = ((void *)0);
  new_list->next = ((void *)0);
  return new_list;
}

variable_types: struct _List { void *data; struct _List *next; } *


optiontrue

decompiled_code:
__int64 __fastcall optiontrue(char a1, int a2, char **a3)
{
char **v3; // rbp
__int64 v4; // r13
char *v5; // rbx

if ( a2 <= 1 )
return 0LL;
v3 = a3;
v4 = (__int64)&a3[(unsigned int)(a2 - 2) + 1];
do
{
v5 = *++v3;
if ( **v3 == 45 )
{
while ( *++v5 )
{
if ( toupper(*v5) == a1 )
return 1LL;
}
}
}
while ( v3 != (char **)v4 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, int a2, char **a3)
{
char **v3; // rbp
__int64 v4; // r13
char *v5; // rbx

if ( a2 <= 1 )
return 0LL;
v3 = a3;
v4 = (__int64)&a3[(unsigned int)(a2 - 2) + 1];
do
{
v5 = *++v3;
if ( **v3 == 45 )
{
while ( *++v5 )
{
if ( toupper(*v5) == a1 )
return 1LL;
}
}
}
while ( v3 != (char **)v4 );
return 0LL;
}

original_code:
int optiontrue (char op, int argc, char *argv[])
  {
    char *p;
    while (--argc>0)
      if(*(p=*++argv)=='-')
        while(*++p)
          if (toupper(*p) == op)
            return(1);
    return(0);
  }

canonical_original_code:
int optiontrue(char op, int argc, char *argv[])
  {
    char *p;
    while (--argc>0)
      if(*(p=*++argv)=='-')
        while(*++p)
          if (toupper(*p) == op)
            return(1);
    return(0);
  }

variable_types: op char

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
p
char *


decompiled_code:
__int64 __fastcall decode_SEED_micro_header(__int64 a1, _WORD *a2, _WORD *a3, _WORD *a4, _WORD *a5)
{
__int64 v5; // r14
__int16 v6; // bp
__int16 v7; // r12
__int16 v8; // ax
__int16 v9; // r15
char v10; // dl
char v11; // dl

*a4 = 1;
v5 = (__int16)swapb((unsigned int)*(__int16 *)(a1 + 30));
v6 = swapb((unsigned int)*(__int16 *)(a1 + 48));
v7 = swapb((unsigned int)*(__int16 *)(a1 + 50));
v8 = swapb((unsigned int)*(__int16 *)(a1 + 52));
if ( (v6 & 0x7F) != 0 )
{
fwrite("first data does not begin on frame boundary!\n", 1uLL, 0x2DuLL, stderr);
exit(0);
}
v9 = v8;
*a2 = ((unsigned __int64)v6 >> 7) - 1;
if ( (__int16)(((unsigned __int64)v6 >> 7) - 1) < 0 )
fprintf(stderr, "Firstframe came out negative! - hfirstdata = %d\n", (unsigned int)v6);
if ( v7 == 48 && v9 == 1000 )
{
v10 = *(_BYTE *)(a1 + 56);
switch ( v10 )
{
case 11:
*a3 = 2;
break;
case 20:
*a3 = 3;
break;
case 10:
*a3 = 1;
break;
default:
fprintf(stderr, "unknown encoding format %d\n", (unsigned int)v10);
exit(0);
}
v11 = *(_BYTE *)(a1 + 58);
switch ( v11 )
{
case 7:
*a5 = 1;
break;
case 8:
*a5 = 3;
break;
case 9:
*a5 = 7;
break;
case 10:
*a5 = 15;
break;
case 11:
*a5 = 31;
break;
case 12:
*a5 = 63;
break;
default:
fprintf(stderr, "unknown record length code %d\n", (unsigned int)v11);
exit(0);
}
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, _WORD *a2, _WORD *a3, _WORD *a4, _WORD *a5)
{
__int64 v5; // r14
__int16 v6; // bp
__int16 v7; // r12
__int16 v8; // ax
__int16 v9; // r15
char v10; // dl
char v11; // dl

*a4 = 1;
v5 = (__int16)swapb((unsigned int)*(__int16 *)(a1 + 30));
v6 = swapb((unsigned int)*(__int16 *)(a1 + 48));
v7 = swapb((unsigned int)*(__int16 *)(a1 + 50));
v8 = swapb((unsigned int)*(__int16 *)(a1 + 52));
if ( (v6 & 0x7F) != 0 )
{
fwrite("first data does not begin on frame boundary!\n", 1uLL, 0x2DuLL, stderr);
exit(0);
}
v9 = v8;
*a2 = ((unsigned __int64)v6 >> 7) - 1;
if ( (__int16)(((unsigned __int64)v6 >> 7) - 1) < 0 )
fprintf(stderr, "Firstframe came out negative! - hfirstdata = %d\n", (unsigned int)v6);
if ( v7 == 48 && v9 == 1000 )
{
v10 = *(_BYTE *)(a1 + 56);
switch ( v10 )
{
case 11:
*a3 = 2;
break;
case 20:
*a3 = 3;
break;
case 10:
*a3 = 1;
break;
default:
fprintf(stderr, "unknown encoding format %d\n", (unsigned int)v10);
exit(0);
}
v11 = *(_BYTE *)(a1 + 58);
switch ( v11 )
{
case 7:
*a5 = 1;
break;
case 8:
*a5 = 3;
break;
case 9:
*a5 = 7;
break;
case 10:
*a5 = 15;
break;
case 11:
*a5 = 31;
break;
case 12:
*a5 = 63;
break;
default:
fprintf(stderr, "unknown record length code %d\n", (unsigned int)v11);
exit(0);
}
}
return v5;
}

original_code:
long decode_SEED_micro_header (SEED_data_record *sdr, short *firstframe, short *level, short *flip, short *dframes)
{
  COMPWORD ftest;
  short hfirstdata, hfirstblockette, h1000 ;
  long headertotal ;
  ftest.b[0] = 0x12 ;
  ftest.b[1] = 0x34 ;
  ftest.b[2] = 0x56 ;
  ftest.b[3] = 0x78 ;
  if (ftest.l == 0x78563412)
    *flip = 1 ;
  else
    if (ftest.l == 0x12345678)
      *flip = 0 ;
    else
      {
 fprintf (stderr, "CPU word order cannot be processed\n") ;
 exit (0) ;
      }
  if (*flip)
    {
      headertotal = swapb (sdr->Head.samples_in_record) ;
      hfirstdata = swapb (sdr->Head.first_data_byte) ;
      hfirstblockette = swapb (sdr->Head.first_blockette_byte) ;
      h1000 = swapb (sdr->Head.DOB.blockette_type) ;
    }
  else
    {
      headertotal = sdr->Head.samples_in_record ;
      hfirstdata = sdr->Head.first_data_byte ;
      hfirstblockette = sdr->Head.first_blockette_byte ;
      h1000 = sdr->Head.DOB.blockette_type ;
    }
  if ((hfirstdata % sizeof(compressed_frame)) != 0)
    {
      fprintf (stderr, "first data does not begin on frame boundary!\n") ;
      exit(0);
    }
  *firstframe = hfirstdata/sizeof(compressed_frame) - 1 ;
  if (*firstframe<0) {
    fprintf(stderr, "Firstframe came out negative! - hfirstdata = %d\n",hfirstdata);
  }
  if ((hfirstblockette == 48) && (h1000 == 1000))
    {
      switch (sdr->Head.DOB.encoding_format)
 {
 case 10 :
   *level = 1 ;
   break ;
 case 11 :
   *level = 2 ;
   break ;
 case 20 :
   *level = 3 ;
   break ;
 default :
   fprintf (stderr, "unknown encoding format %d\n",(int)sdr->Head.DOB.encoding_format) ;
   exit (0) ;
   break ;
 }
      switch (sdr->Head.DOB.rec_length)
 {
 case 12 :
   *dframes = 63 ;
   break ;
 case 11 :
   *dframes = 31 ;
   break ;
 case 10 :
   *dframes = 15 ;
   break ;
 case 9 :
   *dframes = 7 ;
   break ;
 case 8 :
   *dframes = 3 ;
   break ;
 case 7 :
   *dframes = 1 ;
   break ;
 default :
   fprintf (stderr, "unknown record length code %d\n",(int)sdr->Head.DOB.rec_length) ;
   exit (0) ;
   break ;
 }
    }
  return (headertotal) ;
}

canonical_original_code:
long decode_SEED_micro_header(struct SEED_data_record *sdr, short *firstframe, short *level, short *flip, short *dframes)
{
  union COMPWORD ftest;
  short hfirstdata; short hfirstblockette; short h1000;
  long headertotal;
  ftest.b[0] = 0x12 ;
  ftest.b[1] = 0x34 ;
  ftest.b[2] = 0x56 ;
  ftest.b[3] = 0x78 ;
  if (ftest.l == 0x78563412)
    *flip = 1 ;
  else
    if (ftest.l == 0x12345678)
      *flip = 0 ;
    else
      {
 fprintf (stderr, "CPU word order cannot be processed\n") ;
 exit (0) ;
      }
  if (*flip)
    {
      headertotal = swapb (sdr->Head.samples_in_record) ;
      hfirstdata = swapb (sdr->Head.first_data_byte) ;
      hfirstblockette = swapb (sdr->Head.first_blockette_byte) ;
      h1000 = swapb (sdr->Head.DOB.blockette_type) ;
    }
  else
    {
      headertotal = sdr->Head.samples_in_record ;
      hfirstdata = sdr->Head.first_data_byte ;
      hfirstblockette = sdr->Head.first_blockette_byte ;
      h1000 = sdr->Head.DOB.blockette_type ;
    }
  if ((hfirstdata % sizeof(compressed_frame)) != 0)
    {
      fprintf (stderr, "first data does not begin on frame boundary!\n") ;
      exit(0);
    }
  *firstframe = hfirstdata/sizeof(compressed_frame) - 1 ;
  if (*firstframe<0) {
    fprintf(stderr, "Firstframe came out negative! - hfirstdata = %d\n",hfirstdata);
  }
  if ((hfirstblockette == 48) && (h1000 == 1000))
    {
      switch (sdr->Head.DOB.encoding_format)
 {
 case 10 :
   *level = 1 ;
   break ;
 case 11 :
   *level = 2 ;
   break ;
 case 20 :
   *level = 3 ;
   break ;
 default :
   fprintf (stderr, "unknown encoding format %d\n",(int)sdr->Head.DOB.encoding_format) ;
   exit (0) ;
   break ;
 }
      switch (sdr->Head.DOB.rec_length)
 {
 case 12 :
   *dframes = 63 ;
   break ;
 case 11 :
   *dframes = 31 ;
   break ;
 case 10 :
   *dframes = 15 ;
   break ;
 case 9 :
   *dframes = 7 ;
   break ;
 case 8 :
   *dframes = 3 ;
   break ;
 case 7 :
   *dframes = 1 ;
   break ;
 default :
   fprintf (stderr, "unknown record length code %d\n",(int)sdr->Head.DOB.rec_length) ;
   exit (0) ;
   break ;
 }
    }
  return (headertotal) ;
}

variable_types: struct SEED_data_record { struct SEED_fixed_data_record_header { char sequence[6]; char seed_record_type; char continuation_record; char station_ID_call_letters[5]; char location_id[2]; char channel_ID[3]; char seednet[2]; struct SEED_time_struc { short yr; short jday; char hr; char minute; char seconds; char unused; short tenth_millisec; } starting_time; short samples_in_record; short sample_rate_factor; short sample_rate_multiplier; char activity_flags; char IO_flags; char data_quality_flags; char number_of_following_blockettes; long tenth_msec_correction; short first_data_byte; short first_blockette_byte; struct data_only_blockette { short blockette_type; short next_offset; char encoding_format; char word_order; char rec_length; char dob_reserved; } DOB; struct data_extension_blockette { short blockette_type; short next_offset; char qual; char usec99; char state_of_health; char frame_count; } DEB; } Head; union COMPWORD { char b[4]; short s[2]; long l; } Frames[-1][16]; } *

variable_types:
firstframe
short *

variable_types:
level
short *

variable_types:
flip
short *

variable_types:
dframes
short *

variable_types: hfirstdata short

variable_types: hfirstblockette short

variable_types: headertotal long

return_type: long

user_defined_types: struct SEED_data_record { struct SEED_fixed_data_record_header Head; union COMPWORD Frames[-1][16]; }

user_defined_types: struct SEED_fixed_data_record_header { char sequence[6]; char seed_record_type; char continuation_record; char station_ID_call_letters[5]; char location_id[2]; char channel_ID[3]; char seednet[2]; struct SEED_time_struc starting_time; short samples_in_record; short sample_rate_factor; short sample_rate_multiplier; char activity_flags; char IO_flags; char data_quality_flags; char number_of_following_blockettes; long tenth_msec_correction; short first_data_byte; short first_blockette_byte; struct data_only_blockette DOB; struct data_extension_blockette DEB; }


decompiled_code:
__int64 __fastcall validate_frames(__int16 a1, __int16 a2, int a3)
{
__int64 result; // rax

result = (unsigned int)(a3 - 1);
if ( (unsigned __int16)(a3 - 1) > 0x3Eu )
{
puts("illegal number of data frames specified!");
exit(0);
}
if ( a1 < 0 || (__int16)a3 < a1 )
{
printf("illegal first data frame! (firstframe=%d, dframes=%d)\n", (unsigned int)a1, (unsigned int)(__int16)a3);
exit(0);
}
if ( (unsigned __int16)(a2 - 1) > 2u )
{
puts("illegal compression level!");
exit(0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 a1, __int16 a2, int a3)
{
__int64 result; // rax

result = (unsigned int)(a3 - 1);
if ( (unsigned __int16)(a3 - 1) > 0x3Eu )
{
puts("illegal number of data frames specified!");
exit(0);
}
if ( a1 < 0 || (__int16)a3 < a1 )
{
printf("illegal first data frame! (firstframe=%d, dframes=%d)\n", (unsigned int)a1, (unsigned int)(__int16)a3);
exit(0);
}
if ( (unsigned __int16)(a2 - 1) > 2u )
{
puts("illegal compression level!");
exit(0);
}
return result;
}

original_code:
void validate_frames (short firstframe, short level, short dframes)
{
  if ((dframes < 1) || (dframes >= 64))
    {
      printf("illegal number of data frames specified!\n");
      exit(0);
    }
  if ((firstframe < 0) || (firstframe > dframes))
    {
      printf("illegal first data frame! (firstframe=%d, dframes=%d)\n",
      firstframe,dframes);
      exit(0);
    }
  if ((level < 1) || (level > 3))
    {
      printf("illegal compression level!\n");
      exit(0);
    }
}

canonical_original_code:
void validate_frames(short firstframe, short level, short dframes)
{
  if ((dframes < 1) || (dframes >= 64))
    {
      printf("illegal number of data frames specified!\n");
      exit(0);
    }
  if ((firstframe < 0) || (firstframe > dframes))
    {
      printf("illegal first data frame! (firstframe=%d, dframes=%d)\n",
      firstframe,dframes);
      exit(0);
    }
  if ((level < 1) || (level > 3))
    {
      printf("illegal compression level!\n");
      exit(0);
    }
}

variable_types: firstframe short

variable_types: level short

variable_types: dframes short


decompiled_code:
__int64 __fastcall STEIM_Decode(char *a1, __int64 a2, __int64 a3, __int16 a4, _DWORD *a5)
{
__int64 v8; // rax
__int64 v9; // rbp
__int64 v10; // r14
__int16 v11; // si
__int64 v12; // rbp
__int16 v14; // [rsp+6h] [rbp-32h] BYREF
__int16 v15; // [rsp+8h] [rbp-30h] BYREF
__int16 v16; // [rsp+Ah] [rbp-2Eh] BYREF
__int16 v17; // [rsp+Ch] [rbp-2Ch] BYREF
__int16 v18[21]; // [rsp+Eh] [rbp-2Ah] BYREF

v8 = init_generic_decompression();
if ( !v8 )
exit(12);
v9 = v8;
v15 = a4;
v14 = 63;
v10 = decode_SEED_micro_header((__int64)a1, &v17, &v15, &v16, &v14);
v11 = v15;
*a5 = v15;
validate_frames(v17, v11, v14);
v12 = decompress_generic_record(
a1,
a2,
v18,
v9,
(unsigned int)v17,
v10,
(unsigned int)v15,
(unsigned int)v16,
(unsigned int)v14);
if ( (unsigned int)dferrorfatal((unsigned int)v18[0], stdout) )
{
printf("\n%c%c%c = %ld\n", (unsigned int)a1[15], (unsigned int)a1[16], (unsigned int)a1[17], v12);
puts("decompress: decompress_SEED_record reports errors!");
exit(3);
}
return v12;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *a1, __int64 a2, __int64 a3, __int16 a4, _DWORD *a5)
{
__int64 v8; // rax
__int64 v9; // rbp
__int64 v10; // r14
__int16 v11; // si
__int64 v12; // rbp
__int16 v14; // [rsp+6h] [rbp-32h] BYREF
__int16 v15; // [rsp+8h] [rbp-30h] BYREF
__int16 v16; // [rsp+Ah] [rbp-2Eh] BYREF
__int16 v17; // [rsp+Ch] [rbp-2Ch] BYREF
__int16 v18[21]; // [rsp+Eh] [rbp-2Ah] BYREF

v8 = init_generic_decompression();
if ( !v8 )
exit(12);
v9 = v8;
v15 = a4;
v14 = 63;
v10 = func1((__int64)a1, &v17, &v15, &v16, &v14);
v11 = v15;
*a5 = v15;
func2(v17, v11, v14);
v12 = decompress_generic_record(
a1,
a2,
v18,
v9,
(unsigned int)v17,
v10,
(unsigned int)v15,
(unsigned int)v16,
(unsigned int)v14);
if ( (unsigned int)dferrorfatal((unsigned int)v18[0], stdout) )
{
printf("\n%c%c%c = %ld\n", (unsigned int)a1[15], (unsigned int)a1[16], (unsigned int)a1[17], v12);
puts("decompress: decompress_SEED_record reports errors!");
exit(3);
}
return v12;
}

original_code:
long STEIM_Decode(SEED_data_record *sdr, long *udata, int numsams, int steimlevel, int *actuallevel)
{
  long rectotal, headertotal ;
  short dstat ;
  short firstframe, flip, level ;
  dcptype dcp;
  short dframes ;
  if ((dcp = init_generic_decompression ()) == ((void *)0) )
      exit (12) ;
  level = steimlevel ;
  dframes = 63 ;
  headertotal = decode_SEED_micro_header (sdr, &firstframe, &level, &flip, &dframes) ;
  *actuallevel = level;
  validate_frames (firstframe, level, dframes) ;
  rectotal = decompress_generic_record ((generic_data_record *)sdr, udata, &dstat, dcp,
     firstframe, headertotal, level, flip, dframes) ;
  if (dferrorfatal(dstat, stdout))
    {
      printf ("\n%c%c%c = %ld\n",sdr->Head.channel_ID[0],sdr->Head.channel_ID[1],sdr->Head.channel_ID[2],rectotal);
      printf ("decompress: decompress_SEED_record reports errors!\n") ;
      exit(3) ;
    } ;
  return(rectotal);
}

canonical_original_code:
long STEIM_Decode(struct SEED_data_record *sdr, long *udata, int numsams, int steimlevel, int *actuallevel)
{
  long rectotal; long headertotal;
  short dstat;
  short firstframe; short flip; short level;
  struct decompression_continuity *dcp;
  short dframes;
  if ((dcp = init_generic_decompression ()) == ((void *)0) )
      exit (12) ;
  level = steimlevel ;
  dframes = 63 ;
  headertotal = decode_SEED_micro_header (sdr, &firstframe, &level, &flip, &dframes) ;
  *actuallevel = level;
  validate_frames (firstframe, level, dframes) ;
  rectotal = decompress_generic_record ((struct generic_data_record *)sdr, udata, &dstat, dcp,
     firstframe, headertotal, level, flip, dframes) ;
  if (dferrorfatal(dstat, stdout))
    {
      printf ("\n%c%c%c = %ld\n",sdr->Head.channel_ID[0],sdr->Head.channel_ID[1],sdr->Head.channel_ID[2],rectotal);
      printf ("decompress: decompress_SEED_record reports errors!\n") ;
      exit(3) ;
    } ;
  return(rectotal);
}

variable_types:
udata
long *

variable_types: numsams int

variable_types: steimlevel int

variable_types:
actuallevel
int *

variable_types: rectotal long

variable_types: dstat short

variable_types: flip short

variable_types: struct decompression_continuity { long samp_1; long samp_2; short numdecomp; } *

user_defined_types: struct generic_data_record { char head[64]; union COMPWORD frames[-1][16]; }

user_defined_types: struct SEED_time_struc { short yr; short jday; char hr; char minute; char seconds; char unused; short tenth_millisec; }

user_defined_types: struct data_only_blockette { short blockette_type; short next_offset; char encoding_format; char word_order; char rec_length; char dob_reserved; }

user_defined_types: struct data_extension_blockette { short blockette_type; short next_offset; char qual; char usec99; char state_of_health; char frame_count; }

user_defined_types: union COMPWORD { char b[4]; short s[2]; long l; }


decompiled_code:
__int64 __fastcall STEIM_Decode_Small(char *a1, __int64 a2, __int64 a3, __int16 a4, _DWORD *a5, __int16 a6)
{
__int64 v10; // rax
__int64 v11; // r12
__int64 v12; // rbx
__int16 v13; // si
__int64 v14; // rbx
__int16 v16; // [rsp+6h] [rbp-42h] BYREF
__int16 v17; // [rsp+8h] [rbp-40h] BYREF
__int16 v18; // [rsp+Ah] [rbp-3Eh] BYREF
__int16 v19; // [rsp+Ch] [rbp-3Ch] BYREF
__int16 v20[29]; // [rsp+Eh] [rbp-3Ah] BYREF

v10 = init_generic_decompression();
if ( !v10 )
exit(12);
v11 = v10;
v17 = a4;
if ( a6 <= 0 )
a6 = 63;
v16 = a6;
v12 = decode_SEED_micro_header((__int64)a1, &v19, &v17, &v18, &v16);
v13 = v17;
*a5 = v17;
validate_frames(v19, v13, v16);
v14 = decompress_generic_record(
a1,
a2,
v20,
v11,
(unsigned int)v19,
v12,
(unsigned int)v17,
(unsigned int)v18,
(unsigned int)v16);
if ( (unsigned int)dferrorfatal((unsigned int)v20[0], stdout) )
{
printf("\n%c%c%c = %ld\n", (unsigned int)a1[15], (unsigned int)a1[16], (unsigned int)a1[17], v14);
puts("decompress: decompress_SEED_record reports errors!");
exit(3);
}
return v14;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *a1, __int64 a2, __int64 a3, __int16 a4, _DWORD *a5, __int16 a6)
{
__int64 v10; // rax
__int64 v11; // r12
__int64 v12; // rbx
__int16 v13; // si
__int64 v14; // rbx
__int16 v16; // [rsp+6h] [rbp-42h] BYREF
__int16 v17; // [rsp+8h] [rbp-40h] BYREF
__int16 v18; // [rsp+Ah] [rbp-3Eh] BYREF
__int16 v19; // [rsp+Ch] [rbp-3Ch] BYREF
__int16 v20[29]; // [rsp+Eh] [rbp-3Ah] BYREF

v10 = init_generic_decompression();
if ( !v10 )
exit(12);
v11 = v10;
v17 = a4;
if ( a6 <= 0 )
a6 = 63;
v16 = a6;
v12 = func1((__int64)a1, &v19, &v17, &v18, &v16);
v13 = v17;
*a5 = v17;
func2(v19, v13, v16);
v14 = decompress_generic_record(
a1,
a2,
v20,
v11,
(unsigned int)v19,
v12,
(unsigned int)v17,
(unsigned int)v18,
(unsigned int)v16);
if ( (unsigned int)dferrorfatal((unsigned int)v20[0], stdout) )
{
printf("\n%c%c%c = %ld\n", (unsigned int)a1[15], (unsigned int)a1[16], (unsigned int)a1[17], v14);
puts("decompress: decompress_SEED_record reports errors!");
exit(3);
}
return v14;
}

original_code:
long STEIM_Decode_Small(SEED_data_record *sdr, long *udata, int numsams, int steimlevel, int *actuallevel, int frames)
{
  long rectotal, headertotal ;
  short dstat ;
  short firstframe, flip, level ;
  dcptype dcp;
  short dframes ;
  if ((dcp = init_generic_decompression ()) == ((void *)0) )
      exit (12) ;
  level = steimlevel ;
  dframes = frames;
  if (dframes<=0) dframes = 63 ;
  headertotal = decode_SEED_micro_header (sdr, &firstframe, &level, &flip, &dframes) ;
  *actuallevel = level;
  validate_frames (firstframe, level, dframes) ;
  rectotal = decompress_generic_record ((generic_data_record *)sdr, udata, &dstat, dcp,
     firstframe, headertotal, level, flip, dframes) ;
  if (dferrorfatal(dstat, stdout))
    {
      printf ("\n%c%c%c = %ld\n",sdr->Head.channel_ID[0],sdr->Head.channel_ID[1],sdr->Head.channel_ID[2],rectotal);
      printf ("decompress: decompress_SEED_record reports errors!\n") ;
      exit(3) ;
    } ;
  return(rectotal);
}

canonical_original_code:
long STEIM_Decode_Small(struct SEED_data_record *sdr, long *udata, int numsams, int steimlevel, int *actuallevel, int frames)
{
  long rectotal; long headertotal;
  short dstat;
  short firstframe; short flip; short level;
  struct decompression_continuity *dcp;
  short dframes;
  if ((dcp = init_generic_decompression ()) == ((void *)0) )
      exit (12) ;
  level = steimlevel ;
  dframes = frames;
  if (dframes<=0) dframes = 63 ;
  headertotal = decode_SEED_micro_header (sdr, &firstframe, &level, &flip, &dframes) ;
  *actuallevel = level;
  validate_frames (firstframe, level, dframes) ;
  rectotal = decompress_generic_record ((struct generic_data_record *)sdr, udata, &dstat, dcp,
     firstframe, headertotal, level, flip, dframes) ;
  if (dferrorfatal(dstat, stdout))
    {
      printf ("\n%c%c%c = %ld\n",sdr->Head.channel_ID[0],sdr->Head.channel_ID[1],sdr->Head.channel_ID[2],rectotal);
      printf ("decompress: decompress_SEED_record reports errors!\n") ;
      exit(3) ;
    } ;
  return(rectotal);
}

variable_types: struct SEED_data_record { struct SEED_fixed_data_record_header { char sequence[6]; char seed_record_type; char continuation_record; char station_ID_call_letters[5]; char location_id[2]; char channel_ID[3]; char seednet[2]; struct SEED_time_struc { short yr; short jday; char hr; char minute; char seconds; char unused; short tenth_millisec; } starting_time; short samples_in_record; short sample_rate_factor; short sample_rate_multiplier; char activity_flags; char IO_flags; char data_quality_flags; char number_of_following_blockettes; long tenth_msec_correction; short first_data_byte; short first_blockette_byte; struct data_only_blockette { short blockette_type; short next_offset; char encoding_format; char word_order; char rec_length; char dob_reserved; } DOB; struct data_extension_blockette { short blockette_type; short next_offset; char qual; char usec99; char state_of_health; char frame_count; } DEB; } Head; union COMPWORD { char b[4]; short s[2]; long l; } Frames[-1][16]; } *

variable_types: frames int

user_defined_types: struct decompression_continuity { long samp_1; long samp_2; short numdecomp; }


decompiled_code:
const char *get_modules()
{
return "Globals";
}

canonical_decompiled_code:
const char *func0()
{
return "Globals";
}

original_code:
pmodules get_modules (void)
{
  return &(sen_modules) ;
}

canonical_original_code:
struct tmodule (*get_modules())[31]
{
  return &(sen_modules) ;
}

return_type: struct tmodule { char name[16]; long ver; } (*)[31]


decompiled_code:
char __fastcall ms_samplesize(char a1)
{
char result; // al

result = 8;
if ( a1 != 100 )
{
if ( a1 > 100 )
{
result = 4;
if ( a1 != 102 )
result = 4 * (a1 == 105);
}
else
{
result = a1 == 97;
}
}
return result;
}

canonical_decompiled_code:
char __fastcall func0(char a1)
{
char result; // al

result = 8;
if ( a1 != 100 )
{
if ( a1 > 100 )
{
result = 4;
if ( a1 != 102 )
result = 4 * (a1 == 105);
}
else
{
result = a1 == 97;
}
}
return result;
}

original_code:
uint8_t
ms_samplesize (const char sampletype)
{
  switch (sampletype)
    {
    case 'a':
      return 1;
    case 'i':
    case 'f':
      return 4;
    case 'd':
      return 8;
    default:
      return 0;
    }
}

canonical_original_code:
unsigned char ms_samplesize(char sampletype)
{
  switch (sampletype)
    {
    case 'a':
      return 1;
    case 'i':
    case 'f':
      return 4;
    case 'd':
      return 8;
    default:
      return 0;
    }
}

variable_types: sampletype char


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

switch ( a1 )
{
case 0:
result = "ASCII text";
break;
case 1:
result = "16 bit integers";
break;
case 2:
result = "24 bit integers";
break;
case 3:
result = "32 bit integers";
break;
case 4:
result = "IEEE floating point";
break;
case 5:
result = "IEEE double precision float";
break;
case 10:
result = "STEIM 1 Compression";
break;
case 11:
result = "STEIM 2 Compression";
break;
case 12:
result = "GEOSCOPE Muxed 24 bit int";
break;
case 13:
result = "GEOSCOPE Muxed 16/3 bit gain/exp";
break;
case 14:
result = "GEOSCOPE Muxed 16/4 bit gain/exp";
break;
case 15:
result = "US National Network compression";
break;
case 16:
result = "CDSN 16 bit gain ranged";
break;
case 17:
result = "Graefenberg 16 bit gain ranged";
break;
case 18:
result = "IPG - Strasbourg 16 bit gain";
break;
case 19:
result = "STEIM 3 Compression";
break;
case 30:
result = "SRO Gain Ranged Format";
break;
case 31:
result = "HGLP Format";
break;
case 32:
result = "DWWSSN Format";
break;
case 33:
result = "RSTN 16 bit gain ranged";
break;
default:
result = "Unknown format code";
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = "ASCII text";
break;
case 1:
result = "16 bit integers";
break;
case 2:
result = "24 bit integers";
break;
case 3:
result = "32 bit integers";
break;
case 4:
result = "IEEE floating point";
break;
case 5:
result = "IEEE double precision float";
break;
case 10:
result = "STEIM 1 Compression";
break;
case 11:
result = "STEIM 2 Compression";
break;
case 12:
result = "GEOSCOPE Muxed 24 bit int";
break;
case 13:
result = "GEOSCOPE Muxed 16/3 bit gain/exp";
break;
case 14:
result = "GEOSCOPE Muxed 16/4 bit gain/exp";
break;
case 15:
result = "US National Network compression";
break;
case 16:
result = "CDSN 16 bit gain ranged";
break;
case 17:
result = "Graefenberg 16 bit gain ranged";
break;
case 18:
result = "IPG - Strasbourg 16 bit gain";
break;
case 19:
result = "STEIM 3 Compression";
break;
case 30:
result = "SRO Gain Ranged Format";
break;
case 31:
result = "HGLP Format";
break;
case 32:
result = "DWWSSN Format";
break;
case 33:
result = "RSTN 16 bit gain ranged";
break;
default:
result = "Unknown format code";
break;
}
return result;
}

original_code:
char *
ms_encodingstr (const char encoding)
{
  switch (encoding)
    {
    case 0:
      return "ASCII text";
    case 1:
      return "16 bit integers";
    case 2:
      return "24 bit integers";
    case 3:
      return "32 bit integers";
    case 4:
      return "IEEE floating point";
    case 5:
      return "IEEE double precision float";
    case 10:
      return "STEIM 1 Compression";
    case 11:
      return "STEIM 2 Compression";
    case 12:
      return "GEOSCOPE Muxed 24 bit int";
    case 13:
      return "GEOSCOPE Muxed 16/3 bit gain/exp";
    case 14:
      return "GEOSCOPE Muxed 16/4 bit gain/exp";
    case 15:
      return "US National Network compression";
    case 16:
      return "CDSN 16 bit gain ranged";
    case 17:
      return "Graefenberg 16 bit gain ranged";
    case 18:
      return "IPG - Strasbourg 16 bit gain";
    case 19:
      return "STEIM 3 Compression";
    case 30:
      return "SRO Gain Ranged Format";
    case 31:
      return "HGLP Format";
    case 32:
      return "DWWSSN Format";
    case 33:
      return "RSTN 16 bit gain ranged";
    default:
      return "Unknown format code";
    }
}

canonical_original_code:
char *ms_encodingstr(char encoding)
{
  switch (encoding)
    {
    case 0:
      return "ASCII text";
    case 1:
      return "16 bit integers";
    case 2:
      return "24 bit integers";
    case 3:
      return "32 bit integers";
    case 4:
      return "IEEE floating point";
    case 5:
      return "IEEE double precision float";
    case 10:
      return "STEIM 1 Compression";
    case 11:
      return "STEIM 2 Compression";
    case 12:
      return "GEOSCOPE Muxed 24 bit int";
    case 13:
      return "GEOSCOPE Muxed 16/3 bit gain/exp";
    case 14:
      return "GEOSCOPE Muxed 16/4 bit gain/exp";
    case 15:
      return "US National Network compression";
    case 16:
      return "CDSN 16 bit gain ranged";
    case 17:
      return "Graefenberg 16 bit gain ranged";
    case 18:
      return "IPG - Strasbourg 16 bit gain";
    case 19:
      return "STEIM 3 Compression";
    case 30:
      return "SRO Gain Ranged Format";
    case 31:
      return "HGLP Format";
    case 32:
      return "DWWSSN Format";
    case 33:
      return "RSTN 16 bit gain ranged";
    default:
      return "Unknown format code";
    }
}

variable_types: encoding char

return_type: char *


decompiled_code:
const char *__fastcall ms_blktdesc(unsigned __int16 a1)
{
const char *result; // rax

if ( a1 == 390 )
return "Generic Calibration";
if ( a1 <= 0x186u )
{
if ( a1 == 300 )
{
result = "Step Calibration";
}
else if ( a1 <= 0x12Cu )
{
result = "Generic Event Detection";
if ( a1 != 200 )
{
if ( a1 == 201 )
{
result = "Murdock Event Detection";
}
else
{
result = "Sample Rate";
if ( a1 != 100 )
result = 0LL;
}
}
}
else
{
result = "Sine Calibration";
if ( a1 != 310 )
{
result = "Pseudo-random Calibration";
if ( a1 != 320 )
result = 0LL;
}
}
}
else if ( a1 == 1000 )
{
result = "Data Only SEED";
}
else if ( a1 <= 0x3E8u )
{
result = "Beam";
if ( a1 != 400 )
{
if ( a1 == 500 )
{
result = "Timing";
}
else
{
result = "Calibration Abort";
if ( a1 != 395 )
result = 0LL;
}
}
}
else
{
result = "Data Extension";
if ( a1 != 1001 )
{
result = "Opaque Data";
if ( a1 != 2000 )
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func2(unsigned __int16 a1)
{
const char *result; // rax

if ( a1 == 390 )
return "Generic Calibration";
if ( a1 <= 0x186u )
{
if ( a1 == 300 )
{
result = "Step Calibration";
}
else if ( a1 <= 0x12Cu )
{
result = "Generic Event Detection";
if ( a1 != 200 )
{
if ( a1 == 201 )
{
result = "Murdock Event Detection";
}
else
{
result = "Sample Rate";
if ( a1 != 100 )
result = 0LL;
}
}
}
else
{
result = "Sine Calibration";
if ( a1 != 310 )
{
result = "Pseudo-random Calibration";
if ( a1 != 320 )
result = 0LL;
}
}
}
else if ( a1 == 1000 )
{
result = "Data Only SEED";
}
else if ( a1 <= 0x3E8u )
{
result = "Beam";
if ( a1 != 400 )
{
if ( a1 == 500 )
{
result = "Timing";
}
else
{
result = "Calibration Abort";
if ( a1 != 395 )
result = 0LL;
}
}
}
else
{
result = "Data Extension";
if ( a1 != 1001 )
{
result = "Opaque Data";
if ( a1 != 2000 )
result = 0LL;
}
}
return result;
}

original_code:
char *
ms_blktdesc (uint16_t blkttype)
{
  switch (blkttype)
    {
    case 100:
      return "Sample Rate";
    case 200:
      return "Generic Event Detection";
    case 201:
      return "Murdock Event Detection";
    case 300:
      return "Step Calibration";
    case 310:
      return "Sine Calibration";
    case 320:
      return "Pseudo-random Calibration";
    case 390:
      return "Generic Calibration";
    case 395:
      return "Calibration Abort";
    case 400:
      return "Beam";
    case 500:
      return "Timing";
    case 1000:
      return "Data Only SEED";
    case 1001:
      return "Data Extension";
    case 2000:
      return "Opaque Data";
    }
  return ((void *)0);
}

canonical_original_code:
char *ms_blktdesc(unsigned short blkttype)
{
  switch (blkttype)
    {
    case 100:
      return "Sample Rate";
    case 200:
      return "Generic Event Detection";
    case 201:
      return "Murdock Event Detection";
    case 300:
      return "Step Calibration";
    case 310:
      return "Sine Calibration";
    case 320:
      return "Pseudo-random Calibration";
    case 390:
      return "Generic Calibration";
    case 395:
      return "Calibration Abort";
    case 400:
      return "Beam";
    case 500:
      return "Timing";
    case 1000:
      return "Data Only SEED";
    case 1001:
      return "Data Extension";
    case 2000:
      return "Opaque Data";
    }
  return ((void *)0);
}

variable_types:
blkttype
unsigned short


original_code:
uint16_t
ms_blktlen (uint16_t blkttype, const char *blkt, flag swapflag)
{
  uint16_t blktlen = 0;
  switch (blkttype)
    {
    case 100:
      blktlen = 12;
      break;
    case 200:
      blktlen = 28;
      break;
    case 201:
      blktlen = 36;
      break;
    case 300:
      blktlen = 32;
      break;
    case 310:
      blktlen = 32;
      break;
    case 320:
      blktlen = 28;
      break;
    case 390:
      blktlen = 28;
      break;
    case 395:
      blktlen = 16;
      break;
    case 400:
      blktlen = 16;
      break;
    case 500:
      blktlen = 8;
      break;
    case 1000:
      blktlen = 8;
      break;
    case 1001:
      blktlen = 8;
      break;
    case 2000:
      if ( blkt )
 {
   memcpy ((void *) &blktlen, blkt+4, sizeof (int16_t));
   if ( swapflag ) ms_gswap2 (&blktlen);
 }
      break;
    }
  return blktlen;
}

canonical_original_code:
unsigned short ms_blktlen(unsigned short blkttype, char *blkt, char swapflag)
{
  unsigned short blktlen = 0;
  switch (blkttype)
    {
    case 100:
      blktlen = 12;
      break;
    case 200:
      blktlen = 28;
      break;
    case 201:
      blktlen = 36;
      break;
    case 300:
      blktlen = 32;
      break;
    case 310:
      blktlen = 32;
      break;
    case 320:
      blktlen = 28;
      break;
    case 390:
      blktlen = 28;
      break;
    case 395:
      blktlen = 16;
      break;
    case 400:
      blktlen = 16;
      break;
    case 500:
      blktlen = 8;
      break;
    case 1000:
      blktlen = 8;
      break;
    case 1001:
      blktlen = 8;
      break;
    case 2000:
      if ( blkt )
 {
   memcpy ((void *) &blktlen, blkt+4, sizeof (short));
   if ( swapflag ) ms_gswap2 (&blktlen);
 }
      break;
    }
  return blktlen;
}

variable_types:
blkt
char *

variable_types: swapflag char

variable_types:
blktlen
unsigned short

return_type: unsigned short


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

switch ( a1 )
{
case -6:
result = "Bad Steim compression flag(s) detected";
break;
case -5:
result = "Unknown data encoding format";
break;
case -4:
result = "SEED record length out of range";
break;
case -3:
result = "Length of data read does not match record length";
break;
case -2:
result = "No SEED data detected";
break;
case -1:
result = "Generic error";
break;
case 0:
result = "No error";
break;
case 1:
result = "End of file reached";
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case -6:
result = "Bad Steim compression flag(s) detected";
break;
case -5:
result = "Unknown data encoding format";
break;
case -4:
result = "SEED record length out of range";
break;
case -3:
result = "Length of data read does not match record length";
break;
case -2:
result = "No SEED data detected";
break;
case -1:
result = "Generic error";
break;
case 0:
result = "No error";
break;
case 1:
result = "End of file reached";
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
char *
ms_errorstr (int errorcode)
{
  switch (errorcode)
    {
    case 1:
      return "End of file reached";
    case 0:
      return "No error";
    case -1:
      return "Generic error";
    case -2:
      return "No SEED data detected";
    case -3:
      return "Length of data read does not match record length";
    case -4:
      return "SEED record length out of range";
    case -5:
      return "Unknown data encoding format";
    case -6:
      return "Bad Steim compression flag(s) detected";
    }
  return ((void *)0);
}

canonical_original_code:
char *ms_errorstr(int errorcode)
{
  switch (errorcode)
    {
    case 1:
      return "End of file reached";
    case 0:
      return "No error";
    case -1:
      return "Generic error";
    case -2:
      return "No SEED data detected";
    case -3:
      return "Length of data read does not match record length";
    case -4:
      return "SEED record length out of range";
    case -5:
      return "Unknown data encoding format";
    case -6:
      return "Bad Steim compression flag(s) detected";
    }
  return ((void *)0);
}

variable_types: errorcode int


decompiled_code:
__int64 __fastcall ST_TimeMin2(__int64 a1, __int64 a2, __int64 a3, unsigned __int16 a4)
{
__int64 v6; // [rsp+36h] [rbp-12h]

if ( (int)ST_TimeComp2(a1, a2, a3, a4) <= 0 )
v6 = a1;
else
v6 = a3;
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, unsigned __int16 a4)
{
__int64 v6; // [rsp+36h] [rbp-12h]

if ( (int)ST_TimeComp2(a1, a2, a3, a4) <= 0 )
v6 = a1;
else
v6 = a3;
return v6;
}

original_code:
STDTIME2 ST_TimeMin2(STDTIME2 time_arg1, STDTIME2 time_arg2) {
  if (ST_TimeComp2(time_arg1, time_arg2) <= 0)
    return(time_arg1);
  else
    return(time_arg2);
}

canonical_original_code:
struct __sjtim2 ST_TimeMin2(struct __sjtim2 time_arg1, struct __sjtim2 time_arg2) {
  if (ST_TimeComp2(time_arg1, time_arg2) <= 0)
    return(time_arg1);
  else
    return(time_arg2);
}

return_type: struct __sjtim2 { short year; short day; char hour; char minute; char second; short tenth_msec; }


decompiled_code:
__int64 __fastcall ST_TimeMax2(__int64 a1, __int64 a2, __int64 a3, unsigned __int16 a4)
{
__int64 v6; // [rsp+36h] [rbp-12h]

if ( (int)ST_TimeComp2(a1, a2, a3, a4) < 0 )
v6 = a3;
else
v6 = a1;
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, unsigned __int16 a4)
{
__int64 v6; // [rsp+36h] [rbp-12h]

if ( (int)ST_TimeComp2(a1, a2, a3, a4) < 0 )
v6 = a3;
else
v6 = a1;
return v6;
}

original_code:
STDTIME2 ST_TimeMax2(STDTIME2 time_arg1, STDTIME2 time_arg2) {
  if (ST_TimeComp2(time_arg1, time_arg2) >= 0)
    return(time_arg1);
  else
    return(time_arg2);
}

canonical_original_code:
struct __sjtim2 ST_TimeMax2(struct __sjtim2 time_arg1, struct __sjtim2 time_arg2) {
  if (ST_TimeComp2(time_arg1, time_arg2) >= 0)
    return(time_arg1);
  else
    return(time_arg2);
}

user_defined_types: struct __sjtim2 { short year; short day; char hour; char minute; char second; short tenth_msec; }


decompiled_code:
__int64 __fastcall ST_GetJulian2(int a1)
{
return julday2((__int16)a1, 1LL, SHIWORD(a1));
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return julday2((__int16)a1, 1LL, SHIWORD(a1));
}

original_code:
long ST_GetJulian2(STDTIME2 intime) {
  long jul1;
  jul1 = _julday2(intime.year, 1, intime.day);
  return(jul1);
}

canonical_original_code:
long ST_GetJulian2(struct __sjtim2 intime) {
  long jul1;
  jul1 = _julday2(intime.year, 1, intime.day);
  return(jul1);
}

variable_types: struct __sjtim2 { short year; short day; char hour; char minute; char second; short tenth_msec; }


MapStatusMem

decompiled_code:
char *__fastcall MapStatusMem(_QWORD *a1)
{
char *v2; // rbx
int v3; // edi
void *v4; // rax
int *v6; // rbx
char *v7; // rax
int *v8; // rbx
char *v9; // rax

v2 = (char *)unixadr_2;
if ( unixadr_2 )
{
*a1 = unixadr_2;
v2 = 0LL;
}
else
{
v3 = shmget(11, 0x5A80uLL, 944);
if ( v3 == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
sprintf(errbuf_1, "shmget SHMKEY_STATUS failure, error %d: %s.", (unsigned int)*v6, v7);
fprintf(stderr, "%s\n", errbuf_1);
v2 = errbuf_1;
}
else
{
v4 = shmat(v3, 0LL, 48);
unixadr_2 = (__int64)v4;
if ( (_DWORD)v4 == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
sprintf(errbuf_1, "%s: shmat LOG330 failure, error %d: %s.", "statusutil", (unsigned int)*v8, v9);
fprintf(stderr, "%s\n", errbuf_1);
v2 = errbuf_1;
}
else
{
*a1 = v4;
}
}
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(_QWORD *a1)
{
char *v2; // rbx
int v3; // edi
void *v4; // rax
int *v6; // rbx
char *v7; // rax
int *v8; // rbx
char *v9; // rax

v2 = (char *)unixadr_2;
if ( unixadr_2 )
{
*a1 = unixadr_2;
v2 = 0LL;
}
else
{
v3 = shmget(11, 0x5A80uLL, 944);
if ( v3 == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
sprintf(errbuf_1, "shmget SHMKEY_STATUS failure, error %d: %s.", (unsigned int)*v6, v7);
fprintf(stderr, "%s\n", errbuf_1);
v2 = errbuf_1;
}
else
{
v4 = shmat(v3, 0LL, 48);
unixadr_2 = (__int64)v4;
if ( (_DWORD)v4 == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
sprintf(errbuf_1, "%s: shmat LOG330 failure, error %d: %s.", "statusutil", (unsigned int)*v8, v9);
fprintf(stderr, "%s\n", errbuf_1);
v2 = errbuf_1;
}
else
{
*a1 = v4;
}
}
}
return v2;
}

original_code:
char *MapStatusMem(void **mapstatus)
{
   int shmid;
   static char *unixadr = ((void *)0);
   static char errbuf[1024];
   if (unixadr != ((void *)0) && unixadr != 0)
   {
     *mapstatus = unixadr;
     return ((void *)0);
   }
   if ((shmid = shmget(11, sizeof (struct s_mapstatus),
         01000 | 00660))==-1)
   {
      sprintf(errbuf, "shmget SHMKEY_STATUS failure, error %d: %s.",
            (*__errno_location ()), strerror((*__errno_location ())));
      fprintf(stderr, "%s\n", errbuf);
      return errbuf;
   }
   if ((int)(unixadr = (char *)shmat(shmid,0,060))==-1)
   {
      sprintf(errbuf, "%s: shmat LOG330 failure, error %d: %s.",
            "statusutil", (*__errno_location ()), strerror((*__errno_location ())));
      fprintf(stderr, "%s\n", errbuf);
      return errbuf;
   }
  *mapstatus = unixadr;
  return ((void *)0);
}

variable_types:
mapstatus
void **

variable_types: shmid int

variable_types:
unixadr
char *

variable_types:
errbuf
char [1024]

user_defined_types: struct s_mapstatus { int iNumDlg; enum tlibstate libstate[8]; int ixWriteData[8]; int ixReadData[8]; int ixWriteStatus[8]; int ixReadStatus[8]; struct s_dlgstatus dlg[3][8]; int ixWriteArch; int ixReadArch; struct __sjtim2 archWatchdog[3]; int ixWriteServ[8]; int ixReadServ[8]; struct __sjtim2 servWatchdog[3][8]; }

user_defined_types: enum tlibstate { LIBSTATE_IDLE=0, LIBSTATE_TERM=1, LIBSTATE_PING=2, LIBSTATE_CONN=3, LIBSTATE_ANNC=4, LIBSTATE_REG=5, LIBSTATE_READCFG=6, LIBSTATE_READTOK=7, LIBSTATE_DECTOK=8, LIBSTATE_RUNWAIT=9, LIBSTATE_RUN=10, LIBSTATE_DEALLOC=11, LIBSTATE_DEREG=12, LIBSTATE_WAIT=13 }

user_defined_types: struct s_dlgstatus { struct __sjtim2 timeLastData; unsigned long property_tag; int sys_temp; float analog_voltage; float input_voltage; int main_cur; int boom_pos[6]; struct tstat_gps stat_gps; int pll_state; float pll_time_error; int clock_quality; long vacuum[3]; long pressure; long dummyl[94]; }

user_defined_types: struct tstat_gps { unsigned short gpstime; unsigned short gpson; unsigned short sat_used; unsigned short sat_view; char time[10]; char date[12]; char fix[6]; char height[12]; char lat[14]; char longt[14]; unsigned int last_good; unsigned int check_err; }


GetDlgIndex

original_code:
int GetDlgIndex(const char *configstr)
{
  int iDig;
  int i;
  static int rememberdig=-2;
  if (rememberdig > -2)
    return rememberdig;
  iDig = 0;
  rememberdig = 0;
  for (i=0; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "etc", 3) != 0)
    rememberdig;
  i += 3;
  if (configstr[i] != '/') return rememberdig;
  for (; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "q330", 4) != 0)
    return rememberdig;
  i += 4;
  if (configstr[i] != '/') return rememberdig;
  for (; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "DLG", 3) != 0)
    return rememberdig;
  i += 3;
  if (!((*__ctype_b_loc ())[(int) ((configstr[i]))] & (unsigned short int) _ISdigit))
    return rememberdig;
  iDig = configstr[i] - '0';
  iDig = iDig-1;
  if (iDig < 0) iDig = 0;
  rememberdig = iDig;
  return rememberdig;
}

canonical_original_code:
int GetDlgIndex(char *configstr)
{
  int iDig;
  int i;
  static int rememberdig = -2;
  if (rememberdig > -2)
    return rememberdig;
  iDig = 0;
  rememberdig = 0;
  for (i=0; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "etc", 3) != 0)
    rememberdig;
  i += 3;
  if (configstr[i] != '/') return rememberdig;
  for (; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "q330", 4) != 0)
    return rememberdig;
  i += 4;
  if (configstr[i] != '/') return rememberdig;
  for (; configstr[i] == '/'; i++)
    ;
  if (strncmp(&configstr[i], "DLG", 3) != 0)
    return rememberdig;
  i += 3;
  if (!((*__ctype_b_loc ())[(int) ((configstr[i]))] & (unsigned short) _ISdigit))
    return rememberdig;
  iDig = configstr[i] - '0';
  iDig = iDig-1;
  if (iDig < 0) iDig = 0;
  rememberdig = iDig;
  return rememberdig;
}

variable_types:
configstr
char *

variable_types: iDig int

variable_types: i int

variable_types: rememberdig int