decompiled_code:
char *__fastcall ojt_fullname(char a1, char *a2, int a3)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x37u, "ojt_fullname");
if ( !a2 || !a3 )
_assert_fail("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 0x38u, "ojt_fullname");
*a2 = 0;
if ( a1 == 54 )
strncat(a2, "red joker", a3 - 1);
else
snprintf(a2, a3, "%s of %ss", ranknames[(char)(a1 - 1) >> 2], suitnames[(a1 - 1) & 3]);
return a2;
}

canonical_decompiled_code:
char *__fastcall func4(char a1, char *a2, int a3)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x37u, "ojt_fullname");
if ( !a2 || !a3 )
_assert_fail("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 0x38u, "ojt_fullname");
*a2 = 0;
if ( a1 == 54 )
strncat(a2, "red joker", a3 - 1);
else
snprintf(a2, a3, "%s of %ss", ranknames[(char)(a1 - 1) >> 2], suitnames[(a1 - 1) & 3]);
return a2;
}

original_code:
char *ojt_fullname(oj_card c, char *buf, int size) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((0 != buf && 0 != size) ? (void) (0) : __assert_fail ("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 56, __extension__ __PRETTY_FUNCTION__));
    *buf = '\0';
    if (54 == c) {
        strncat(buf, "red joker", size - 1);
    } else if (53 == 3) {
        strncat(buf, "joker", size - 1);
    } else {
        snprintf(buf, size, "%s of %ss",
            _ranknames[((oj_rank)(((c) - 1) >> 2))], _suitnames[((oj_suit)(((c) - 1) & 3))]);
    }
    return buf;
}

canonical_original_code:
char *ojt_fullname(char c, char *buf, int size) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((0 != buf && 0 != size) ? (void) (0) : __assert_fail ("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 56, __extension__ __PRETTY_FUNCTION__));
    *buf = '\0';
    if (54 == c) {
        strncat(buf, "red joker", size - 1);
    } else if (53 == 3) {
        strncat(buf, "joker", size - 1);
    } else {
        snprintf(buf, size, "%s of %ss",
            _ranknames[((oj_rank)(((c) - 1) >> 2))], _suitnames[((oj_suit)(((c) - 1) & 3))]);
    }
    return buf;
}


repo: lcrocker/ojcardlib

decompiled_code:
__int64 __fastcall ojt_val(unsigned __int8 *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

return parse_card(a1, &v2);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int8 *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

return func0(a1, &v2);
}

original_code:
oj_card ojt_val(char *str) {
    char *next;
    return _parse_card(str, &next);
}

canonical_original_code:
char ojt_val(char *str) {
    char *next;
    return _parse_card(str, &next);
}

variable_types:
str
char *

variable_types:
next
char *

return_type: char


decompiled_code:
__int64 __fastcall ojt_vals(unsigned __int8 *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // r15
unsigned int v5; // er12
char v6; // al
unsigned __int8 *v8; // [rsp+8h] [rbp-40h] BYREF

if ( a3 == 0 || a2 == 0 || !a1 )
_assert_fail("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 0x87u, "ojt_vals");
v4 = 0LL;
while ( 1 )
{
v5 = v4;
v6 = parse_card(a1, &v8);
if ( !v6 )
break;
*(_BYTE *)(a2 + v4++) = v6;
if ( v4 == a3 )
return a3;
a1 = v8;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 *a1, __int64 a2, unsigned int a3)
{
__int64 v4; // r15
unsigned int v5; // er12
char v6; // al
unsigned __int8 *v8; // [rsp+8h] [rbp-40h] BYREF

if ( a3 == 0 || a2 == 0 || !a1 )
_assert_fail("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 0x87u, "ojt_vals");
v4 = 0LL;
while ( 1 )
{
v5 = v4;
v6 = func0(a1, &v8);
if ( !v6 )
break;
*(_BYTE *)(a2 + v4++) = v6;
if ( v4 == a3 )
return a3;
a1 = v8;
}
return v5;
}

original_code:
int ojt_vals(char *str, oj_card *arr, int size) {
    int v, i = 0;
    char *next;
    ((0 != str && 0 != arr && 0 != size) ? (void) (0) : __assert_fail ("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 135, __extension__ __PRETTY_FUNCTION__));
    while ((v = _parse_card(str, &next))) {
        arr[i] = v;
        if (++i == size) return i;
        str = next;
    }
    return i;
}

canonical_original_code:
int ojt_vals(char *str, char *arr, int size) {
    int v; int i = 0;
    char *next;
    ((0 != str && 0 != arr && 0 != size) ? (void) (0) : __assert_fail ("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 135, __extension__ __PRETTY_FUNCTION__));
    while ((v = _parse_card(str, &next))) {
        arr[i] = v;
        if (++i == size) return i;
        str = next;
    }
    return i;
}

variable_types:
arr
char *

variable_types: size int

variable_types: v int

variable_types: i int

return_type: int


original_code:
int ojb_total(oj_cardlist *p) {
    int total = 0, ace = 0, soft = 0;
    ((0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/blackjack.c", 19, __extension__ __PRETTY_FUNCTION__));
    for (int i = 0; i < p->length; ++i) {
        int c = p->cards[i];
        if (c >= ((oj_card)((((int)(OJR_ACE) << 2) | (int)(OJS_CLUB)) + 1))) {
            ace = 1;
            total += 1;
        } else if (c >= ((oj_card)((((int)(OJR_TEN) << 2) | (int)(OJS_CLUB)) + 1))) {
            total += 10;
        } else {
            total += ((oj_rank)(((c) - 1) >> 2)) + 2;
        }
    }
    if (ace && total < 12) {
        total += 10;
        soft = 1;
    }
    return soft ? -total : total;
}

canonical_original_code:
int ojb_total(struct _oj_cardlist *p) {
    int total = 0; int ace = 0; int soft = 0;
    ((0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/blackjack.c", 19, __extension__ __PRETTY_FUNCTION__));
    for (int i = 0; i < p->length; ++i) {
        int c = p->cards[i];
        if (c >= ((oj_card)((((int)(OJR_ACE) << 2) | (int)(OJS_CLUB)) + 1))) {
            ace = 1;
            total += 1;
        } else if (c >= ((oj_card)((((int)(OJR_TEN) << 2) | (int)(OJS_CLUB)) + 1))) {
            total += 10;
        } else {
            total += ((oj_rank)(((c) - 1) >> 2)) + 2;
        }
    }
    if (ace && total < 12) {
        total += 10;
        soft = 1;
    }
    return soft ? -total : total;
}

variable_types: struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; } *

variable_types: total int

variable_types: ace int

variable_types: soft int

variable_types: c int


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

result = ojr_seed();
if ( !(_DWORD)result )
oj_johnnymoss = 279765247;
return result;
}

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

result = ojr_seed();
if ( !(_DWORD)result )
oj_johnnymoss = 279765247;
return result;
}

original_code:
int oj_init_library(int seed) {
    int r;
    r = ojr_seed(seed);
    if (r) return r;
    _oj_johnnymoss = 0x10ACE0FF;
    return 0;
}

variable_types: seed int

variable_types: r int


repo: lcrocker/ojrandlib

decompiled_code:
__int64 ojr_structure_size()
{
return 96LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 96LL;
}

original_code: int ojr_structure_size(void) { return sizeof(ojr_generator); }

canonical_original_code: int ojr_structure_size() { return sizeof(ojr_generator); }


decompiled_code:
__int64 __fastcall ojr_get_seeded(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x22u, "ojr_get_seeded");
return a1[2] & 1;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x22u, "ojr_get_seeded");
return a1[2] & 1;
}

original_code:
int ojr_get_seeded(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 34, __extension__ __PRETTY_FUNCTION__));
    return 0 != (g->flags & 0x01);
}

canonical_original_code:
int ojr_get_seeded(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 34, __extension__ __PRETTY_FUNCTION__));
    return 0 != (g->flags & 0x01);
}

variable_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *


decompiled_code:
__int64 __fastcall ojr_get_algorithm(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x2Du, "ojr_get_algorithm");
return (unsigned int)a1[3];
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x2Du, "ojr_get_algorithm");
return (unsigned int)a1[3];
}

original_code:
int ojr_get_algorithm(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 45, __extension__ __PRETTY_FUNCTION__));
    return g->algorithm;
}

canonical_original_code:
int ojr_get_algorithm(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 45, __extension__ __PRETTY_FUNCTION__));
    return g->algorithm;
}

user_defined_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; }


decompiled_code:
__int64 __fastcall ojr_get_statesize(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x38u, "ojr_get_statesize");
return (unsigned int)a1[4];
}

canonical_decompiled_code:
__int64 __fastcall func6(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x38u, "ojr_get_statesize");
return (unsigned int)a1[4];
}

original_code:
int ojr_get_statesize(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 56, __extension__ __PRETTY_FUNCTION__));
    return g->statesize;
}

canonical_original_code:
int ojr_get_statesize(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 56, __extension__ __PRETTY_FUNCTION__));
    return g->statesize;
}


decompiled_code:
__int64 __fastcall ojr_get_state(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x3Du, "ojr_get_state");
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x3Du, "ojr_get_state");
return *(_QWORD *)(a1 + 24);
}

original_code:
uint32_t *ojr_get_state(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 61, __extension__ __PRETTY_FUNCTION__));
    return g->state;
}

canonical_original_code:
unsigned int *ojr_get_state(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 61, __extension__ __PRETTY_FUNCTION__));
    return g->state;
}

return_type: unsigned int *


decompiled_code:
void __fastcall ojr_set_state(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x42u, "ojr_set_state");
if ( !a2 || !a3 )
_assert_fail("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 0x43u, "ojr_set_state");
*(_DWORD *)(a1 + 16) = a3;
*(_QWORD *)(a1 + 24) = a2;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x42u, "ojr_set_state");
if ( !a2 || !a3 )
_assert_fail("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 0x43u, "ojr_set_state");
*(_DWORD *)(a1 + 16) = a3;
*(_QWORD *)(a1 + 24) = a2;
}

original_code:
void ojr_set_state(ojr_generator *g, uint32_t *state, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 66, __extension__ __PRETTY_FUNCTION__));
    ((0 != state && 0 != size) ? (void) (0) : __assert_fail ("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 67, __extension__ __PRETTY_FUNCTION__));
    g->statesize = size;
    g->state = state;
}

canonical_original_code:
void ojr_set_state(struct _ojr_generator *g, unsigned int *state, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 66, __extension__ __PRETTY_FUNCTION__));
    ((0 != state && 0 != size) ? (void) (0) : __assert_fail ("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 67, __extension__ __PRETTY_FUNCTION__));
    g->statesize = size;
    g->state = state;
}

variable_types:
state
unsigned int *

return_type: void


decompiled_code:
__int64 __fastcall ojr_get_bufsize(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x49u, "ojr_get_bufsize");
return (unsigned int)a1[5];
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x49u, "ojr_get_bufsize");
return (unsigned int)a1[5];
}

original_code:
int ojr_get_bufsize(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 73, __extension__ __PRETTY_FUNCTION__));
    return g->bufsize;
}

canonical_original_code:
int ojr_get_bufsize(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 73, __extension__ __PRETTY_FUNCTION__));
    return g->bufsize;
}


decompiled_code:
__int64 __fastcall ojr_get_buffer(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x4Eu, "ojr_get_buffer");
return *(_QWORD *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x4Eu, "ojr_get_buffer");
return *(_QWORD *)(a1 + 32);
}

original_code:
uint32_t *ojr_get_buffer(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 78, __extension__ __PRETTY_FUNCTION__));
    return g->buf;
}

canonical_original_code:
unsigned int *ojr_get_buffer(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 78, __extension__ __PRETTY_FUNCTION__));
    return g->buf;
}


decompiled_code:
__int64 __fastcall ojr_get_buffer_ptr(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x53u, "ojr_get_buffer_ptr");
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x53u, "ojr_get_buffer_ptr");
return *(_QWORD *)(a1 + 40);
}

original_code:
uint32_t *ojr_get_buffer_ptr(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 83, __extension__ __PRETTY_FUNCTION__));
    return g->bptr;
}

canonical_original_code:
unsigned int *ojr_get_buffer_ptr(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 83, __extension__ __PRETTY_FUNCTION__));
    return g->bptr;
}


decompiled_code:
void __fastcall ojr_set_buffer(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x58u, "ojr_set_buffer");
*(_DWORD *)(a1 + 20) = a3;
*(_QWORD *)(a1 + 40) = a2;
*(_QWORD *)(a1 + 32) = a2;
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x58u, "ojr_set_buffer");
*(_DWORD *)(a1 + 20) = a3;
*(_QWORD *)(a1 + 40) = a2;
*(_QWORD *)(a1 + 32) = a2;
}

original_code:
void ojr_set_buffer(ojr_generator *g, uint32_t *buf, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 88, __extension__ __PRETTY_FUNCTION__));
    g->bufsize = size;
    g->buf = g->bptr = buf;
}

canonical_original_code:
void ojr_set_buffer(struct _ojr_generator *g, unsigned int *buf, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 88, __extension__ __PRETTY_FUNCTION__));
    g->bufsize = size;
    g->buf = g->bptr = buf;
}

variable_types:
buf
unsigned int *


decompiled_code:
__int64 __fastcall ojr_set_buffer_ptr(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x5Eu, "ojr_set_buffer_ptr");
if ( !a2 || (result = (a2 - *(_QWORD *)(a1 + 32)) >> 2, result > *(int *)(a1 + 20)) )
_assert_fail(
"0 != bptr && (bptr - g->buf) <= g->bufsize",
"/usr/src/repo/source/library/generator.c",
0x5Fu,
"ojr_set_buffer_ptr");
*(_QWORD *)(a1 + 40) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x5Eu, "ojr_set_buffer_ptr");
if ( !a2 || (result = (a2 - *(_QWORD *)(a1 + 32)) >> 2, result > *(int *)(a1 + 20)) )
_assert_fail(
"0 != bptr && (bptr - g->buf) <= g->bufsize",
"/usr/src/repo/source/library/generator.c",
0x5Fu,
"ojr_set_buffer_ptr");
*(_QWORD *)(a1 + 40) = a2;
return result;
}

original_code:
void ojr_set_buffer_ptr(ojr_generator *g, uint32_t *bptr) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 94, __extension__ __PRETTY_FUNCTION__));
    ((0 != bptr && (bptr - g->buf) <= g->bufsize) ? (void) (0) : __assert_fail ("0 != bptr && (bptr - g->buf) <= g->bufsize", "/usr/src/repo/source/library/generator.c", 95, __extension__ __PRETTY_FUNCTION__));
    g->bptr = bptr;
}

canonical_original_code:
void ojr_set_buffer_ptr(struct _ojr_generator *g, unsigned int *bptr) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 94, __extension__ __PRETTY_FUNCTION__));
    ((0 != bptr && (bptr - g->buf) <= g->bufsize) ? (void) (0) : __assert_fail ("0 != bptr && (bptr - g->buf) <= g->bufsize", "/usr/src/repo/source/library/generator.c", 95, __extension__ __PRETTY_FUNCTION__));
    g->bptr = bptr;
}

variable_types:
bptr
unsigned int *


decompiled_code:
__int64 __fastcall ojr_get_extra(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x64u, "ojr_get_extra");
return *(_QWORD *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x64u, "ojr_get_extra");
return *(_QWORD *)(a1 + 56);
}

original_code:
void *ojr_get_extra(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 100, __extension__ __PRETTY_FUNCTION__));
    return g->extra;
}

canonical_original_code:
void *ojr_get_extra(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 100, __extension__ __PRETTY_FUNCTION__));
    return g->extra;
}

return_type: void *


decompiled_code:
void __fastcall ojr_set_extra(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x69u, "ojr_set_extra");
*(_QWORD *)(a1 + 56) = a2;
}

canonical_decompiled_code:
void __fastcall func15(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x69u, "ojr_set_extra");
*(_QWORD *)(a1 + 56) = a2;
}

original_code:
void ojr_set_extra(ojr_generator *g, void *extra) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 105, __extension__ __PRETTY_FUNCTION__));
    g->extra = extra;
}

canonical_original_code:
void ojr_set_extra(struct _ojr_generator *g, void *extra) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 105, __extension__ __PRETTY_FUNCTION__));
    g->extra = extra;
}

variable_types:
extra
void *


decompiled_code:
__int64 __fastcall ojr_default_reseed(__int64 a1, __int64 a2, int a3)
{
__int64 result; // rax
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rsi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > 0 )
{
v6 = *(_QWORD *)(a1 + 24);
v7 = 0LL;
LODWORD(result) = 0;
do
{
v8 = (int)result;
result = (unsigned int)(result + 1);
*(_DWORD *)(v6 + 4 * v7) ^= *(_DWORD *)(a2 + 4 * v8);
if ( (int)result >= a3 )
result = 0LL;
++v7;
}
while ( *(_DWORD *)(a1 + 16) > (int)v7 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2, int a3)
{
__int64 result; // rax
__int64 v6; // rcx
__int64 v7; // rdx
__int64 v8; // rsi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > 0 )
{
v6 = *(_QWORD *)(a1 + 24);
v7 = 0LL;
LODWORD(result) = 0;
do
{
v8 = (int)result;
result = (unsigned int)(result + 1);
*(_DWORD *)(v6 + 4 * v7) ^= *(_DWORD *)(a2 + 4 * v8);
if ( (int)result >= a3 )
result = 0LL;
++v7;
}
while ( *(_DWORD *)(a1 + 16) > (int)v7 );
}
return result;
}

original_code:
void ojr_default_reseed(ojr_generator *g, uint32_t *seed, int size) {
    int i, j = 0;
    for (i = 0; i < g->statesize; ++i) {
        g->state[i] ^= seed[j];
        if (++j >= size) j = 0;
    }
}

canonical_original_code:
void ojr_default_reseed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int i; int j = 0;
    for (i = 0; i < g->statesize; ++i) {
        g->state[i] ^= seed[j];
        if (++j >= size) j = 0;
    }
}

variable_types:
seed
unsigned int *

variable_types: j int


decompiled_code:
__int64 __fastcall ojr_call_reseed(__int64 a1, __int64 a2, int a3)
{
__int64 (*v3)(void); // rax
__int64 result; // rax

v3 = *(__int64 (**)(void))(ojr_algorithms[(*(_DWORD *)(a1 + 12) == 0) - 1 + *(_DWORD *)(a1 + 12)] + 48LL);
if ( v3 )
result = v3();
else
result = ojr_default_reseed(a1, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, int a3)
{
__int64 (*v3)(void); // rax
__int64 result; // rax

v3 = *(__int64 (**)(void))(ojr_algorithms[(*(_DWORD *)(a1 + 12) == 0) - 1 + *(_DWORD *)(a1 + 12)] + 48LL);
if ( v3 )
result = v3();
else
result = func16(a1, a2, a3);
return result;
}

original_code:
void ojr_call_reseed(ojr_generator *g, uint32_t *seed, int size) {
    int id = g->algorithm;
    void (*f)(ojr_generator *, uint32_t *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->reseed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_reseed(g, seed, size);
}

canonical_original_code:
void ojr_call_reseed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int id = g->algorithm;
    void (*f)(struct _ojr_generator *, unsigned int *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->reseed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_reseed(g, seed, size);
}

variable_types: size int

variable_types: id int

variable_types: void (*)(struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *, unsigned int *, int)


decompiled_code:
__int64 __fastcall ojr_default_seed(__int64 a1, __int64 a2, int a3)
{
__int64 result; // rax
__int64 v6; // r11
__int64 v7; // rcx
int v8; // edx
int v9; // edx
__int64 v10; // rsi
int v11; // esi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > 0 )
{
v6 = *(_QWORD *)(a1 + 24);
v7 = 0LL;
LODWORD(result) = 0;
v8 = 232497429;
do
{
v9 = 69069 * v8;
v10 = (int)result;
result = (unsigned int)(result + 1);
v11 = *(_DWORD *)(a2 + 4 * v10);
if ( (int)result >= a3 )
result = 0LL;
v8 = v9 + v11 + 764385;
*(_DWORD *)(v6 + 4 * v7++) = v8;
}
while ( *(_DWORD *)(a1 + 16) > (int)v7 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1, __int64 a2, int a3)
{
__int64 result; // rax
__int64 v6; // r11
__int64 v7; // rcx
int v8; // edx
int v9; // edx
__int64 v10; // rsi
int v11; // esi

result = *(unsigned int *)(a1 + 16);
if ( (int)result > 0 )
{
v6 = *(_QWORD *)(a1 + 24);
v7 = 0LL;
LODWORD(result) = 0;
v8 = 232497429;
do
{
v9 = 69069 * v8;
v10 = (int)result;
result = (unsigned int)(result + 1);
v11 = *(_DWORD *)(a2 + 4 * v10);
if ( (int)result >= a3 )
result = 0LL;
v8 = v9 + v11 + 764385;
*(_DWORD *)(v6 + 4 * v7++) = v8;
}
while ( *(_DWORD *)(a1 + 16) > (int)v7 );
}
return result;
}

original_code:
void ojr_default_seed(ojr_generator *g, uint32_t *seed, int size) {
    int i, x, j = 0;
    x = 232497429;
    for (i = 0; i < g->statesize; ++i) {
        x = (69069 * x) + 764385 + seed[j];
        g->state[i] = x;
        if (++j >= size) j = 0;
    }
}

canonical_original_code:
void ojr_default_seed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int i; int x; int j = 0;
    x = 232497429;
    for (i = 0; i < g->statesize; ++i) {
        x = (69069 * x) + 764385 + seed[j];
        g->state[i] = x;
        if (++j >= size) j = 0;
    }
}

variable_types: i int

variable_types: x int


decompiled_code:
__int64 __fastcall ojr_call_seed(__int64 a1, __int64 a2, int a3)
{
__int64 (*v3)(void); // rax
__int64 result; // rax

v3 = *(__int64 (**)(void))(ojr_algorithms[(*(_DWORD *)(a1 + 12) == 0) - 1 + *(_DWORD *)(a1 + 12)] + 40LL);
if ( v3 )
result = v3();
else
result = ojr_default_seed(a1, a2, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2, int a3)
{
__int64 (*v3)(void); // rax
__int64 result; // rax

v3 = *(__int64 (**)(void))(ojr_algorithms[(*(_DWORD *)(a1 + 12) == 0) - 1 + *(_DWORD *)(a1 + 12)] + 40LL);
if ( v3 )
result = v3();
else
result = func18(a1, a2, a3);
return result;
}

original_code:
void ojr_call_seed(ojr_generator *g, uint32_t *seed, int size) {
    int id = g->algorithm;
    void (*f)(ojr_generator *, uint32_t *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->seed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_seed(g, seed, size);
}

canonical_original_code:
void ojr_call_seed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int id = g->algorithm;
    void (*f)(struct _ojr_generator *, unsigned int *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->seed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_seed(g, seed, size);
}


original_code:
void ojr_shuffle_int_array(
ojr_generator *g, int *array, int size, int count) {
    int i, r, t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

canonical_original_code:
void ojr_shuffle_int_array(struct _ojr_generator *g, int *array, int size, int count) {
    int i; int r; int t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

variable_types:
array
int *

variable_types: count int

variable_types: t int


original_code:
void ojr_shuffle_pointer_array(
ojr_generator *g, void **array, int size, int count) {
    int i, r;
    void *t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

canonical_original_code:
void ojr_shuffle_pointer_array(struct _ojr_generator *g, void **array, int size, int count) {
    int i; int r;
    void *t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

variable_types:
array
void **

variable_types:
t
void *


decompiled_code:
__int64 ojr_library_startup()
{
if ( (_DWORD *)ojr_algorithms != ojr_algorithm_mwc8222 )
_assert_fail(
"&ojr_algorithm_mwc8222 == ojr_algorithms[0]",
"/usr/src/repo/source/library/init.c",
0x1Eu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[3] != 1 )
_assert_fail(
"1 == ojr_algorithm_mwc8222.statesize",
"/usr/src/repo/source/library/init.c",
0x1Fu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[4] != 256 )
_assert_fail(
"256 == ojr_algorithm_mwc8222.bufsize",
"/usr/src/repo/source/library/init.c",
0x20u,
"ojr_library_startup");
ojr_init(&ojr_default_generator);
ojr_set_algorithm(&ojr_default_generator, 1LL);
ojr_set_state(&ojr_default_generator, &ojr_default_buffer, 1LL);
ojr_set_buffer(&ojr_default_generator, (char *)&ojr_default_buffer + 4, 256LL);
ojr_call_open(&ojr_default_generator);
ojr_system_seed(&ojr_default_generator);
ojr_library_initialized = 1592598101;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
if ( (_DWORD *)ojr_algorithms != ojr_algorithm_mwc8222 )
_assert_fail(
"&ojr_algorithm_mwc8222 == ojr_algorithms[0]",
"/usr/src/repo/source/library/init.c",
0x1Eu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[3] != 1 )
_assert_fail(
"1 == ojr_algorithm_mwc8222.statesize",
"/usr/src/repo/source/library/init.c",
0x1Fu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[4] != 256 )
_assert_fail(
"256 == ojr_algorithm_mwc8222.bufsize",
"/usr/src/repo/source/library/init.c",
0x20u,
"ojr_library_startup");
ojr_init(&ojr_default_generator);
ojr_set_algorithm(&ojr_default_generator, 1LL);
ojr_set_state(&ojr_default_generator, &ojr_default_buffer, 1LL);
ojr_set_buffer(&ojr_default_generator, (char *)&ojr_default_buffer + 4, 256LL);
ojr_call_open(&ojr_default_generator);
ojr_system_seed(&ojr_default_generator);
ojr_library_initialized = 1592598101;
return 0LL;
}

original_code:
int ojr_library_startup(void) {
    ((&ojr_algorithm_mwc8222 == ojr_algorithms[0]) ? (void) (0) : __assert_fail ("&ojr_algorithm_mwc8222 == ojr_algorithms[0]", "/usr/src/repo/source/library/init.c", 30, __extension__ __PRETTY_FUNCTION__));
    ((1 == ojr_algorithm_mwc8222.statesize) ? (void) (0) : __assert_fail ("1 == ojr_algorithm_mwc8222.statesize", "/usr/src/repo/source/library/init.c", 31, __extension__ __PRETTY_FUNCTION__));
    ((256 == ojr_algorithm_mwc8222.bufsize) ? (void) (0) : __assert_fail ("256 == ojr_algorithm_mwc8222.bufsize", "/usr/src/repo/source/library/init.c", 32, __extension__ __PRETTY_FUNCTION__));
    ojr_init(&ojr_default_generator);
    ojr_set_algorithm(&ojr_default_generator, 1);
    ojr_set_state(&ojr_default_generator, ojr_default_buffer, 1);
    ojr_set_buffer(&ojr_default_generator, ojr_default_buffer + 1, 256);
    ojr_call_open(&ojr_default_generator);
    ojr_system_seed(&ojr_default_generator);
    _ojr_library_initialized = 0x5eed1e55;
    return 0;
}

canonical_original_code:
int ojr_library_startup() {
    ((&ojr_algorithm_mwc8222 == ojr_algorithms[0]) ? (void) (0) : __assert_fail ("&ojr_algorithm_mwc8222 == ojr_algorithms[0]", "/usr/src/repo/source/library/init.c", 30, __extension__ __PRETTY_FUNCTION__));
    ((1 == ojr_algorithm_mwc8222.statesize) ? (void) (0) : __assert_fail ("1 == ojr_algorithm_mwc8222.statesize", "/usr/src/repo/source/library/init.c", 31, __extension__ __PRETTY_FUNCTION__));
    ((256 == ojr_algorithm_mwc8222.bufsize) ? (void) (0) : __assert_fail ("256 == ojr_algorithm_mwc8222.bufsize", "/usr/src/repo/source/library/init.c", 32, __extension__ __PRETTY_FUNCTION__));
    ojr_init(&ojr_default_generator);
    ojr_set_algorithm(&ojr_default_generator, 1);
    ojr_set_state(&ojr_default_generator, ojr_default_buffer, 1);
    ojr_set_buffer(&ojr_default_generator, ojr_default_buffer + 1, 256);
    ojr_call_open(&ojr_default_generator);
    ojr_system_seed(&ojr_default_generator);
    _ojr_library_initialized = 0x5eed1e55;
    return 0;
}


decompiled_code:
__int64 ojr_close_all()
{
unsigned int v0; // er12
_QWORD *i; // rbp
void *v2; // rdi
void *v3; // rdi

v0 = 0;
for ( i = (_QWORD *)ojr_genlist_head; ojr_genlist_head; i = (_QWORD *)ojr_genlist_head )
{
v2 = (void *)i[3];
ojr_genlist_head = i[6];
if ( v2 )
free(v2);
v3 = (void *)i[4];
if ( v3 )
free(v3);
++v0;
free(i);
}
return v0;
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // er12
_QWORD *i; // rbp
void *v2; // rdi
void *v3; // rdi

v0 = 0;
for ( i = (_QWORD *)ojr_genlist_head; ojr_genlist_head; i = (_QWORD *)ojr_genlist_head )
{
v2 = (void *)i[3];
ojr_genlist_head = i[6];
if ( v2 )
free(v2);
v3 = (void *)i[4];
if ( v3 )
free(v3);
++v0;
free(i);
}
return v0;
}

original_code:
int ojr_close_all(void) {
    int c = 0;
    ojr_generator *g = ojr_genlist_head;
    while (g) {
        ojr_genlist_head = g->next;
        if (g->state) free(g->state);
        if (g->buf) free(g->buf);
        free(g);
        g = ojr_genlist_head;
        ++c;
    }
    return c;
}

canonical_original_code:
int ojr_close_all() {
    int c = 0;
    struct _ojr_generator *g = ojr_genlist_head;
    while (g) {
        ojr_genlist_head = g->next;
        if (g->state) free(g->state);
        if (g->buf) free(g->buf);
        free(g);
        g = ojr_genlist_head;
        ++c;
    }
    return c;
}

variable_types: c int

variable_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *


decompiled_code:
__int64 ojr_library_shutdown()
{
int v0; // eax
const char *v1; // rcx

if ( ojr_library_initialized != 1592598101 )
_assert_fail(
"0x5eed1e55 == _ojr_library_initialized",
"/usr/src/repo/source/library/init.c",
0x3Du,
"ojr_library_shutdown");
v0 = ojr_close_all();
if ( v0 )
{
v1 = "s";
if ( v0 <= 1 )
v1 = (const char *)&LC5;
fprintf(stderr, "ojrandlib: %d generator object%s not freed.\n", (unsigned int)v0, v1);
}
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // eax
const char *v1; // rcx

if ( ojr_library_initialized != 1592598101 )
_assert_fail(
"0x5eed1e55 == _ojr_library_initialized",
"/usr/src/repo/source/library/init.c",
0x3Du,
"ojr_library_shutdown");
v0 = func1();
if ( v0 )
{
v1 = "s";
if ( v0 <= 1 )
v1 = (const char *)&LC5;
fprintf(stderr, "ojrandlib: %d generator object%s not freed.\n", (unsigned int)v0, v1);
}
return 0LL;
}

original_code:
int ojr_library_shutdown(void) {
    ((0x5eed1e55 == _ojr_library_initialized) ? (void) (0) : __assert_fail ("0x5eed1e55 == _ojr_library_initialized", "/usr/src/repo/source/library/init.c", 61, __extension__ __PRETTY_FUNCTION__));
    int c = ojr_close_all();
    if (c) {
        fprintf(stderr, "ojrandlib: %d generator object%s not freed.\n",
            c, (c > 1) ? "s" : "");
    }
    return 0;
}

canonical_original_code:
int ojr_library_shutdown() {
    ((0x5eed1e55 == _ojr_library_initialized) ? (void) (0) : __assert_fail ("0x5eed1e55 == _ojr_library_initialized", "/usr/src/repo/source/library/init.c", 61, __extension__ __PRETTY_FUNCTION__));
    int c = ojr_close_all();
    if (c) {
        fprintf(stderr, "ojrandlib: %d generator object%s not freed.\n",
            c, (c > 1) ? "s" : "");
    }
    return 0;
}


compare

decompiled_code:
__int64 __fastcall compare(const void *a1, const void *a2)
{
return (unsigned int)(*(_DWORD *)a1 - *(_DWORD *)a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
return (unsigned int)(*(_DWORD *)a1 - *(_DWORD *)a2);
}

original_code:
static int compare(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

canonical_original_code:
static int compare(void *a, void *b) {
    return *(int *)a - *(int *)b;
}

variable_types:
a
void *

variable_types:
b
void *


decompiled_code:
void __fastcall ojr_close(void *ptr)
{
_QWORD *v2; // rax
_QWORD *v3; // rdx
_QWORD *v4; // rdx
__int64 v5; // rax
void *v6; // rdi

if ( *(_DWORD *)ptr != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x37u, "ojr_close");
if ( !*((_QWORD *)ptr + 3) || !*((_QWORD *)ptr + 4) )
_assert_fail("g->state && g->buf", "/usr/src/repo/source/library/capi.c", 0x38u, "ojr_close");
if ( !ojr_genlist_head )
_assert_fail("NULL != ojr_genlist_head", "/usr/src/repo/source/library/capi.c", 0x39u, "ojr_close");
ojr_call_close();
v2 = (_QWORD *)ojr_genlist_head;
if ( ptr == (void *)ojr_genlist_head )
{
v4 = &ojr_genlist_head;
}
else
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[6];
}
while ( ptr != v2 );
v4 = v3 + 6;
}
v5 = *((_QWORD *)ptr + 6);
v6 = (void *)*((_QWORD *)ptr + 4);
*v4 = v5;
free(v6);
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
_QWORD *v2; // rax
_QWORD *v3; // rdx
_QWORD *v4; // rdx
__int64 v5; // rax
void *v6; // rdi

if ( *(_DWORD *)ptr != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x37u, "ojr_close");
if ( !*((_QWORD *)ptr + 3) || !*((_QWORD *)ptr + 4) )
_assert_fail("g->state && g->buf", "/usr/src/repo/source/library/capi.c", 0x38u, "ojr_close");
if ( !ojr_genlist_head )
_assert_fail("NULL != ojr_genlist_head", "/usr/src/repo/source/library/capi.c", 0x39u, "ojr_close");
ojr_call_close();
v2 = (_QWORD *)ojr_genlist_head;
if ( ptr == (void *)ojr_genlist_head )
{
v4 = &ojr_genlist_head;
}
else
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[6];
}
while ( ptr != v2 );
v4 = v3 + 6;
}
v5 = *((_QWORD *)ptr + 6);
v6 = (void *)*((_QWORD *)ptr + 4);
*v4 = v5;
free(v6);
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void ojr_close(ojr_generator *g) {
    ojr_generator **p;
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((g->state && g->buf) ? (void) (0) : __assert_fail ("g->state && g->buf", "/usr/src/repo/source/library/capi.c", 56, __extension__ __PRETTY_FUNCTION__));
    ((((void *)0) != ojr_genlist_head) ? (void) (0) : __assert_fail ("NULL != ojr_genlist_head", "/usr/src/repo/source/library/capi.c", 57, __extension__ __PRETTY_FUNCTION__));
    ojr_call_close(g);
    p = &ojr_genlist_head;
    while (*p != g) p = &((*p)->next);
    *p = g->next;
    free(g->buf);
    free(g->state);
    free(g);
}

canonical_original_code:
void ojr_close(struct _ojr_generator *g) {
    struct _ojr_generator **p;
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((g->state && g->buf) ? (void) (0) : __assert_fail ("g->state && g->buf", "/usr/src/repo/source/library/capi.c", 56, __extension__ __PRETTY_FUNCTION__));
    ((((void *)0) != ojr_genlist_head) ? (void) (0) : __assert_fail ("NULL != ojr_genlist_head", "/usr/src/repo/source/library/capi.c", 57, __extension__ __PRETTY_FUNCTION__));
    ojr_call_close(g);
    p = &ojr_genlist_head;
    while (*p != g) p = &((*p)->next);
    *p = g->next;
    free(g->buf);
    free(g->state);
    free(g);
}

variable_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } **


decompiled_code:
__int64 __fastcall ojr_array_seed(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x47u, "ojr_array_seed");
*(_QWORD *)(a1 + 40) = *(_QWORD *)(a1 + 32);
ojr_call_seed();
return ojr_set_seeded(a1, 1LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x47u, "ojr_array_seed");
*(_QWORD *)(a1 + 40) = *(_QWORD *)(a1 + 32);
ojr_call_seed();
return ojr_set_seeded(a1, 1LL);
}

original_code:
void ojr_array_seed(ojr_generator *g, uint32_t *seed, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 71, __extension__ __PRETTY_FUNCTION__));
    g->bptr = g->buf;
    ojr_call_seed(g, seed, size);
    ojr_set_seeded(g, 1);
}

canonical_original_code:
void ojr_array_seed(struct _ojr_generator *g, unsigned int *seed, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 71, __extension__ __PRETTY_FUNCTION__));
    g->bptr = g->buf;
    ojr_call_seed(g, seed, size);
    ojr_set_seeded(g, 1);
}

variable_types:
seed
unsigned int *


decompiled_code:
__int64 __fastcall ojr_int_seed(__int64 a1)
{
return ojr_array_seed(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return func2(a1);
}

original_code:
void ojr_int_seed(ojr_generator *g, int value) {
    ojr_array_seed(g, (uint32_t *)(&value), 1);
}

canonical_original_code:
void ojr_int_seed(struct _ojr_generator *g, int value) {
    ojr_array_seed(g, (unsigned int *)(&value), 1);
}

variable_types: value int


decompiled_code:
void __fastcall ojr_system_seed(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // er12
void *v3; // rax
void *v4; // rbp

v1 = ojr_get_algorithm();
v2 = ojr_algorithm_seedsize(v1);
v3 = malloc((int)(4 * v2));
if ( v3 )
{
v4 = v3;
ojr_get_system_entropy(v3, v2);
ojr_array_seed(a1);
free(v4);
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // er12
void *v3; // rax
void *v4; // rbp

v1 = ojr_get_algorithm();
v2 = ojr_algorithm_seedsize(v1);
v3 = malloc((int)(4 * v2));
if ( v3 )
{
v4 = v3;
ojr_get_system_entropy(v3, v2);
func2(a1);
free(v4);
}
}

original_code:
void ojr_system_seed(ojr_generator *g) {
    uint32_t *seed;
    int id = ojr_get_algorithm(g);
    int size = ojr_algorithm_seedsize(id);
    if (! (seed = malloc(4 * size))) return;
    ojr_get_system_entropy(seed, size);
    ojr_array_seed(g, seed, size);
    free(seed);
}

canonical_original_code:
void ojr_system_seed(struct _ojr_generator *g) {
    unsigned int *seed;
    int id = ojr_get_algorithm(g);
    int size = ojr_algorithm_seedsize(id);
    if (! (seed = malloc(4 * size))) return;
    ojr_get_system_entropy(seed, size);
    ojr_array_seed(g, seed, size);
    free(seed);
}

variable_types: size int


decompiled_code:
void __fastcall ojr_network_seed(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // er12
void *v3; // rax
void *v4; // rbp

v1 = ojr_get_algorithm();
v2 = ojr_algorithm_seedsize(v1);
v3 = malloc((int)(4 * v2));
if ( v3 )
{
v4 = v3;
ojr_get_random_org(v3, v2);
ojr_array_seed(a1);
free(v4);
}
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
unsigned int v1; // eax
unsigned int v2; // er12
void *v3; // rax
void *v4; // rbp

v1 = ojr_get_algorithm();
v2 = ojr_algorithm_seedsize(v1);
v3 = malloc((int)(4 * v2));
if ( v3 )
{
v4 = v3;
ojr_get_random_org(v3, v2);
func2(a1);
free(v4);
}
}

original_code:
void ojr_network_seed(ojr_generator *g) {
    uint32_t *seed;
    int id = ojr_get_algorithm(g);
    int size = ojr_algorithm_seedsize(id);
    if (! (seed = malloc(4 * size))) return;
    ojr_get_random_org(seed, size);
    ojr_array_seed(g, seed, size);
    free(seed);
}

canonical_original_code:
void ojr_network_seed(struct _ojr_generator *g) {
    unsigned int *seed;
    int id = ojr_get_algorithm(g);
    int size = ojr_algorithm_seedsize(id);
    if (! (seed = malloc(4 * size))) return;
    ojr_get_random_org(seed, size);
    ojr_array_seed(g, seed, size);
    free(seed);
}

variable_types: id int


decompiled_code:
__int64 __fastcall ojr_reseed(_DWORD *a1, __int64 a2, unsigned int a3)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x6Bu, "ojr_reseed");
if ( !(unsigned int)ojr_get_seeded() )
_assert_fail("ojr_get_seeded(g)", "/usr/src/repo/source/library/capi.c", 0x6Cu, "ojr_reseed");
return ojr_call_reseed(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, __int64 a2, unsigned int a3)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0x6Bu, "ojr_reseed");
if ( !(unsigned int)ojr_get_seeded() )
_assert_fail("ojr_get_seeded(g)", "/usr/src/repo/source/library/capi.c", 0x6Cu, "ojr_reseed");
return ojr_call_reseed(a1, a2, a3);
}

original_code:
void ojr_reseed(ojr_generator *g, uint32_t *seed, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 107, __extension__ __PRETTY_FUNCTION__));
    ((ojr_get_seeded(g)) ? (void) (0) : __assert_fail ("ojr_get_seeded(g)", "/usr/src/repo/source/library/capi.c", 108, __extension__ __PRETTY_FUNCTION__));
    ojr_call_reseed(g, seed, size);
}

canonical_original_code:
void ojr_reseed(struct _ojr_generator *g, unsigned int *seed, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 107, __extension__ __PRETTY_FUNCTION__));
    ((ojr_get_seeded(g)) ? (void) (0) : __assert_fail ("ojr_get_seeded(g)", "/usr/src/repo/source/library/capi.c", 108, __extension__ __PRETTY_FUNCTION__));
    ojr_call_reseed(g, seed, size);
}


decompiled_code:
__int64 __fastcall ojr_next32(__int64 a1)
{
__int64 v1; // rax
unsigned int *v2; // rdx
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 || (*(_BYTE *)(a1 + 8) & 1) == 0 )
_assert_fail(
"0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)",
"/usr/src/repo/source/library/capi.c",
0x75u,
"ojr_next32");
v1 = *(_QWORD *)(a1 + 40);
if ( v1 == *(_QWORD *)(a1 + 32) )
{
ojr_call_refill();
v2 = (unsigned int *)(*(_QWORD *)(a1 + 32) + 4LL * *(int *)(a1 + 20) - 4);
result = *v2;
}
else
{
v2 = (unsigned int *)(v1 - 4);
result = *(unsigned int *)(v1 - 4);
}
*(_QWORD *)(a1 + 40) = v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 v1; // rax
unsigned int *v2; // rdx
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 || (*(_BYTE *)(a1 + 8) & 1) == 0 )
_assert_fail(
"0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)",
"/usr/src/repo/source/library/capi.c",
0x75u,
"ojr_next32");
v1 = *(_QWORD *)(a1 + 40);
if ( v1 == *(_QWORD *)(a1 + 32) )
{
ojr_call_refill();
v2 = (unsigned int *)(*(_QWORD *)(a1 + 32) + 4LL * *(int *)(a1 + 20) - 4);
result = *v2;
}
else
{
v2 = (unsigned int *)(v1 - 4);
result = *(unsigned int *)(v1 - 4);
}
*(_QWORD *)(a1 + 40) = v2;
return result;
}

original_code:
uint32_t ojr_next32(ojr_generator *g) {
    ((0x5eed1e55 == g->init && (g->flags & 0x01)) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)", "/usr/src/repo/source/library/capi.c", 117, __extension__ __PRETTY_FUNCTION__));
    if (g->bptr == g->buf) {
        ojr_call_refill(g);
        g->bptr = g->buf + g->bufsize;
    }
    return *--g->bptr;
}

canonical_original_code:
unsigned int ojr_next32(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init && (g->flags & 0x01)) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)", "/usr/src/repo/source/library/capi.c", 117, __extension__ __PRETTY_FUNCTION__));
    if (g->bptr == g->buf) {
        ojr_call_refill(g);
        g->bptr = g->buf + g->bufsize;
    }
    return *--g->bptr;
}

return_type: unsigned int


original_code:
uint16_t ojr_next16(ojr_generator *g) {
    uint16_t r16;
    ((0x5eed1e55 == g->init && (g->flags & 0x01)) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)", "/usr/src/repo/source/library/capi.c", 128, __extension__ __PRETTY_FUNCTION__));
    if (g->leftover) {
        r16 = g->leftover & 0xFFFF;
        g->leftover = 0;
        return r16;
    }
    if (g->bptr == g->buf) {
        ojr_call_refill(g);
        g->bptr = g->buf + g->bufsize;
    }
    --g->bptr;
    g->leftover = 0x10000 | *((uint16_t *)(g->bptr) + 1);
    return *((uint16_t *)(g->bptr));
}

canonical_original_code:
unsigned short ojr_next16(struct _ojr_generator *g) {
    unsigned short r16;
    ((0x5eed1e55 == g->init && (g->flags & 0x01)) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init && (g->flags & OJRF_SEEDED)", "/usr/src/repo/source/library/capi.c", 128, __extension__ __PRETTY_FUNCTION__));
    if (g->leftover) {
        r16 = g->leftover & 0xFFFF;
        g->leftover = 0;
        return r16;
    }
    if (g->bptr == g->buf) {
        ojr_call_refill(g);
        g->bptr = g->buf + g->bufsize;
    }
    --g->bptr;
    g->leftover = 0x10000 | *((unsigned short *)(g->bptr) + 1);
    return *((unsigned short *)(g->bptr));
}

return_type: unsigned short


original_code:
uint64_t ojr_next64(ojr_generator *g) {
    uint64_t r;
    if ((g->bptr - g->buf) >= 2) {
        g->bptr -= 2;
        return *(uint64_t *)(g->bptr);
    }
    r = (uint64_t)(((((g)->bptr == (g)->buf) ? ( ojr_call_refill(g), (g)->bptr = (g)->buf + (g)->bufsize ) : 0), *--(g)->bptr));
    return (r << 32) | ((((g)->bptr == (g)->buf) ? ( ojr_call_refill(g), (g)->bptr = (g)->buf + (g)->bufsize ) : 0), *--(g)->bptr);
}

canonical_original_code:
unsigned long ojr_next64(struct _ojr_generator *g) {
    unsigned long r;
    if ((g->bptr - g->buf) >= 2) {
        g->bptr -= 2;
        return *(unsigned long *)(g->bptr);
    }
    r = (unsigned long)(((((g)->bptr == (g)->buf) ? ( ojr_call_refill(g), (g)->bptr = (g)->buf + (g)->bufsize ) : 0), *--(g)->bptr));
    return (r << 32) | ((((g)->bptr == (g)->buf) ? ( ojr_call_refill(g), (g)->bptr = (g)->buf + (g)->bufsize ) : 0), *--(g)->bptr);
}

variable_types:
r
unsigned long

return_type: unsigned long


decompiled_code:
double __fastcall ojr_next_double(__int64 a1)
{
__int64 v1; // rdx
double result; // xmm0_8
__int64 v3; // rbx

v1 = *(_QWORD *)(a1 + 40);
if ( v1 - *(_QWORD *)(a1 + 32) <= 4 )
{
v3 = (unsigned int)ojr_next32(a1);
result = COERCE_DOUBLE(((unsigned int)ojr_next32(a1) | (unsigned __int64)(v3 << 32)) & 0xFFFFFFFFFFFFFLL | 0x3FF0000000000000LL)
- 1.0;
}
else
{
*(_QWORD *)(a1 + 40) = v1 - 8;
result = COERCE_DOUBLE(*(_QWORD *)(v1 - 8) & 0xFFFFFFFFFFFFFLL | 0x3FF0000000000000LL) - 1.0;
}
return result;
}

canonical_decompiled_code:
double __fastcall func11(__int64 a1)
{
__int64 v1; // rdx
double result; // xmm0_8
__int64 v3; // rbx

v1 = *(_QWORD *)(a1 + 40);
if ( v1 - *(_QWORD *)(a1 + 32) <= 4 )
{
v3 = (unsigned int)func8(a1);
result = COERCE_DOUBLE(((unsigned int)ojr_next32(a1) | (unsigned __int64)(v3 << 32)) & 0xFFFFFFFFFFFFFLL | 0x3FF0000000000000LL)
- 1.0;
}
else
{
*(_QWORD *)(a1 + 40) = v1 - 8;
result = COERCE_DOUBLE(*(_QWORD *)(v1 - 8) & 0xFFFFFFFFFFFFFLL | 0x3FF0000000000000LL) - 1.0;
}
return result;
}

original_code:
double ojr_next_double(ojr_generator *g) {
    uint64_t r = (((((g)->bptr - (g)->buf) >= 2) ? ((g)->bptr -= 2, *(uint64_t *)((g)->bptr)) : (((uint64_t)(ojr_next32(g)) << 32) | ojr_next32(g))) & 0xFFFFFFFFFFFFFull) | 0x3FF0000000000000ull;
    return *(double *)(&r) - 1.0;
}

canonical_original_code:
double ojr_next_double(struct _ojr_generator *g) {
    unsigned long r = (((((g)->bptr - (g)->buf) >= 2) ? ((g)->bptr -= 2, *(uint64_t *)((g)->bptr)) : (((uint64_t)(ojr_next32(g)) << 32) | ojr_next32(g))) & 0xFFFFFFFFFFFFFull) | 0x3FF0000000000000ull;
    return *(double *)(&r) - 1.0;
}

return_type: double


decompiled_code:
double __fastcall ojr_next_signed_double(__int64 a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rax
unsigned __int64 v3; // rdx
__int64 v4; // rax
__int64 v5; // rbx
__int64 v6; // rdx
double result; // xmm0_8

do
{
v4 = *(_QWORD *)(a1 + 40);
if ( v4 - *(_QWORD *)(a1 + 32) > 4 )
{
v1 = v4 - 8;
v2 = *(_QWORD *)(v4 - 8);
*(_QWORD *)(a1 + 40) = v1;
v3 = v2 >> 12;
if ( v2 >> 12 )
break;
continue;
}
v5 = (unsigned int)ojr_next32(a1);
v2 = (unsigned int)ojr_next32(a1) | (unsigned __int64)(v5 << 32);
v3 = v2 >> 12;
if ( v2 >> 12 )
break;
}
while ( (v2 & 1) != 0 );
v6 = v3 | 0x3FF0000000000000LL;
if ( (v2 & 1) != 0 )
result = 1.0 - *(double *)&v6;
else
result = *(double *)&v6 - 1.0;
return result;
}

canonical_original_code:
double ojr_next_signed_double(struct _ojr_generator *g) {
    int sign;
    unsigned long r64;
    do {
        r64 = ((((g)->bptr - (g)->buf) >= 2) ? ((g)->bptr -= 2, *(unsigned long *)((g)->bptr)) : (((unsigned long)(ojr_next32(g)) << 32) | ojr_next32(g)));
        sign = (int)r64 & 1;
        r64 >>= 12;
    } while (sign && 0LL == r64);
    r64 |= 0x3FF0000000000000;
    if (sign) return 1.0 - *(double *)(&r64);
    else return *(double *)(&r64) - 1.0;
}

variable_types: sign int


original_code:
int ojr_rand(ojr_generator *g, int limit) {
    int v, m = limit - 1;
    ((limit > 0 && limit <= 0x80000) ? (void) (0) : __assert_fail ("limit > 0 && limit <= 0x80000", "/usr/src/repo/source/library/capi.c", 185, __extension__ __PRETTY_FUNCTION__));
    m |= m >> 1;
    m |= m >> 2;
    m |= m >> 4;
    m |= m >> 8;
    do {
        if (g->leftover) {
            v = g->leftover & m;
            g->leftover = 0;
        } else {
            if (g->bptr == g->buf) {
                ojr_call_refill(g);
                g->bptr = g->buf + g->bufsize;
            }
            --g->bptr;
            v = *((uint16_t *)(g->bptr)) & m;
            g->leftover = 0x10000 | *((uint16_t *)(g->bptr) + 1);
        }
    } while (v >= limit);
    return v;
}

canonical_original_code:
int ojr_rand(struct _ojr_generator *g, int limit) {
    int v; int m = limit - 1;
    ((limit > 0 && limit <= 0x80000) ? (void) (0) : __assert_fail ("limit > 0 && limit <= 0x80000", "/usr/src/repo/source/library/capi.c", 185, __extension__ __PRETTY_FUNCTION__));
    m |= m >> 1;
    m |= m >> 2;
    m |= m >> 4;
    m |= m >> 8;
    do {
        if (g->leftover) {
            v = g->leftover & m;
            g->leftover = 0;
        } else {
            if (g->bptr == g->buf) {
                ojr_call_refill(g);
                g->bptr = g->buf + g->bufsize;
            }
            --g->bptr;
            v = *((unsigned short *)(g->bptr)) & m;
            g->leftover = 0x10000 | *((unsigned short *)(g->bptr) + 1);
        }
    } while (v >= limit);
    return v;
}

variable_types: limit int

variable_types: v int

variable_types: m int


decompiled_code:
__int64 __fastcall ojr_discard(__int64 a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 result; // rax
int v5; // ebx

v2 = *(_QWORD *)(a1 + 40);
v3 = *(_QWORD *)(a1 + 32);
result = (v2 - v3) >> 2;
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0xD8u, "ojr_discard");
*(_DWORD *)(a1 + 4) = 0;
if ( (int)result >= a2 )
{
*(_QWORD *)(a1 + 40) = v2 - 4LL * a2;
}
else
{
v5 = a2 - result;
*(_QWORD *)(a1 + 40) = v3 + 4LL * *(int *)(a1 + 20);
while ( 1 )
{
ojr_call_refill(a1);
result = *(unsigned int *)(a1 + 20);
if ( (int)result >= v5 )
break;
v5 -= result;
}
*(_QWORD *)(a1 + 40) -= 4LL * v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 result; // rax
int v5; // ebx

v2 = *(_QWORD *)(a1 + 40);
v3 = *(_QWORD *)(a1 + 32);
result = (v2 - v3) >> 2;
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 0xD8u, "ojr_discard");
*(_DWORD *)(a1 + 4) = 0;
if ( (int)result >= a2 )
{
*(_QWORD *)(a1 + 40) = v2 - 4LL * a2;
}
else
{
v5 = a2 - result;
*(_QWORD *)(a1 + 40) = v3 + 4LL * *(int *)(a1 + 20);
while ( 1 )
{
ojr_call_refill(a1);
result = *(unsigned int *)(a1 + 20);
if ( (int)result >= v5 )
break;
v5 -= result;
}
*(_QWORD *)(a1 + 40) -= 4LL * v5;
}
return result;
}

original_code:
void ojr_discard(ojr_generator *g, int count) {
    int inbuf = g->bptr - g->buf;
    if (((void *)0) == g) g = &ojr_default_generator;
    else { ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 216, __extension__ __PRETTY_FUNCTION__)); }
    g->leftover = 0;
    if (count <= inbuf) {
        g->bptr -= count;
        return;
    }
    count -= inbuf;
    g->bptr = g->buf + g->bufsize;
    do {
        ojr_call_refill(g);
        if (count <= g->bufsize) {
            g->bptr -= count;
            count = 0;
        } else {
            count -= g->bufsize;
        }
    } while (count);
}

canonical_original_code:
void ojr_discard(struct _ojr_generator *g, int count) {
    int inbuf = g->bptr - g->buf;
    if (((void *)0) == g) g = &ojr_default_generator;
    else { ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/capi.c", 216, __extension__ __PRETTY_FUNCTION__)); }
    g->leftover = 0;
    if (count <= inbuf) {
        g->bptr -= count;
        return;
    }
    count -= inbuf;
    g->bptr = g->buf + g->bufsize;
    do {
        ojr_call_refill(g);
        if (count <= g->bufsize) {
            g->bptr -= count;
            count = 0;
        } else {
            count -= g->bufsize;
        }
    } while (count);
}

variable_types: count int

variable_types: inbuf int


decompiled_code:
char *__fastcall ojr_array_with_sum(__int64 a1, char *a2, int a3, int a4)
{
size_t v4; // r14
int v6; // esi
char *v7; // r15
__int64 v8; // r14
char *result; // rax
char *v10; // [rsp+8h] [rbp-50h]
__int64 v12; // [rsp+18h] [rbp-40h]

v4 = a3 - 1;
v6 = a4;
v10 = &a2[4 * a3 - 4];
if ( a3 - 1 <= 0 )
{
qsort(a2, a3 - 1, 4uLL, (__compar_fn_t)compare);
result = v10;
*(_DWORD *)v10 = a4;
}
else
{
v7 = a2;
v12 = 4LL * (unsigned int)(a3 - 2);
do
{
v7 += 4;
*((_DWORD *)v7 - 1) = ojr_rand(a1, v6 + 1);
}
while ( &a2[v12 + 4] != v7 );
qsort(a2, v4, 4uLL, (__compar_fn_t)compare);
v8 = 4 * v4;
*(_DWORD *)v10 = a4;
result = &a2[v8];
do
{
*(_DWORD *)result -= *((_DWORD *)result - 1);
result -= 4;
}
while ( result != &a2[v8 - 4 - v12] );
}
return result;
}

canonical_decompiled_code:
char *__fastcall func15(__int64 a1, char *a2, int a3, int a4)
{
size_t v4; // r14
int v6; // esi
char *v7; // r15
__int64 v8; // r14
char *result; // rax
char *v10; // [rsp+8h] [rbp-50h]
__int64 v12; // [rsp+18h] [rbp-40h]

v4 = a3 - 1;
v6 = a4;
v10 = &a2[4 * a3 - 4];
if ( a3 - 1 <= 0 )
{
qsort(a2, a3 - 1, 4uLL, (__compar_fn_t)compare);
result = v10;
*(_DWORD *)v10 = a4;
}
else
{
v7 = a2;
v12 = 4LL * (unsigned int)(a3 - 2);
do
{
v7 += 4;
*((_DWORD *)v7 - 1) = func13(a1, v6 + 1);
}
while ( &a2[v12 + 4] != v7 );
qsort(a2, v4, 4uLL, (__compar_fn_t)compare);
v8 = 4 * v4;
*(_DWORD *)v10 = a4;
result = &a2[v8];
do
{
*(_DWORD *)result -= *((_DWORD *)result - 1);
result -= 4;
}
while ( result != &a2[v8 - 4 - v12] );
}
return result;
}

original_code:
void ojr_array_with_sum(ojr_generator *g, int *a, int count, int sum) {
    int i;
    for (i = 0; i < count-1; ++i) { a[i] = ojr_rand(g, sum+1); }
    qsort(a, count-1, sizeof(int), compare);
    a[count-1] = sum;
    for (i = count-1; i > 0; --i) { a[i] -= a[i-1]; }
}

canonical_original_code:
void ojr_array_with_sum(struct _ojr_generator *g, int *a, int count, int sum) {
    int i;
    for (i = 0; i < count-1; ++i) { a[i] = ojr_rand(g, sum+1); }
    qsort(a, count-1, sizeof(int), compare);
    a[count-1] = sum;
    for (i = count-1; i > 0; --i) { a[i] -= a[i-1]; }
}

variable_types:
a
int *

variable_types: sum int

variable_types: i int


refill

variable_types: r int

variable_types: c int

variable_types:
buf
char [4096]

variable_types:
a
unsigned int [32]

variable_types: j int


decompiled_code:
__int64 __fastcall ojr_get_random_org(__int64 a1, int a2)
{
unsigned int v2; // er13
unsigned int v4; // ebp
char *v5; // rdx
int v6; // eax
char *v7; // rax

if ( a2 <= 0 )
return 0;
v2 = a2;
v4 = 0;
v5 = (char *)bptr;
while ( 1 )
{
v7 = v5;
if ( v5 == (char *)&buffer )
break;
LABEL_3:
v5 = v7 - 4;
v6 = *((_DWORD *)v7 - 1);
++v4;
a1 += 4LL;
bptr = v5;
*(_DWORD *)(a1 - 4) = v6;
if ( a2 == v4 )
return v2;
}
if ( (unsigned int)refill() == 400 )
{
v7 = (char *)&buffer + 1600;
goto LABEL_3;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2)
{
unsigned int v2; // er13
unsigned int v4; // ebp
char *v5; // rdx
int v6; // eax
char *v7; // rax

if ( a2 <= 0 )
return 0;
v2 = a2;
v4 = 0;
v5 = (char *)bptr;
while ( 1 )
{
v7 = v5;
if ( v5 == (char *)&buffer )
break;
LABEL_3:
v5 = v7 - 4;
v6 = *((_DWORD *)v7 - 1);
++v4;
a1 += 4LL;
bptr = v5;
*(_DWORD *)(a1 - 4) = v6;
if ( a2 == v4 )
return v2;
}
if ( (unsigned int)func2() == 400 )
{
v7 = (char *)&buffer + 1600;
goto LABEL_3;
}
return v4;
}

original_code:
int ojr_get_random_org(uint32_t *buf, int size) {
    int c = 0;
    for (int i = 0; i < size; ++i) {
        if (bptr == buffer) {
            if (400 != refill()) return c;
            bptr = buffer + 400;
        }
        buf[i] = *--bptr;
        ++c;
    }
    return c;
}

canonical_original_code:
int ojr_get_random_org(unsigned int *buf, int size) {
    int c = 0;
    for (int i = 0; i < size; ++i) {
        if (bptr == buffer) {
            if (400 != refill()) return c;
            bptr = buffer + 400;
        }
        buf[i] = *--bptr;
        ++c;
    }
    return c;
}

variable_types:
buf
unsigned int *

variable_types: size int


decompiled_code:
__int64 ojr_algorithm_count()
{
unsigned int v0; // er8
void **v1; // rax
int v2; // edx

v0 = ojr_algorithm_count;
if ( !ojr_algorithm_count )
{
v1 = &ojr_algorithms;
if ( ojr_algorithms )
{
v2 = 1;
do
{
++v1;
v0 = v2++;
}
while ( *v1 );
ojr_algorithm_count = v0;
}
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er8
void **v1; // rax
int v2; // edx

v0 = ojr_algorithm_count;
if ( !ojr_algorithm_count )
{
v1 = &ojr_algorithms;
if ( ojr_algorithms )
{
v2 = 1;
do
{
++v1;
v0 = v2++;
}
while ( *v1 );
ojr_algorithm_count = v0;
}
}
return v0;
}

original_code:
int ojr_algorithm_count(void) {
    if (0 == _ojr_algorithm_count) {
        ojr_algorithm **aap = ojr_algorithms;
        while (((void *)0) != *aap) { ++aap; ++_ojr_algorithm_count; }
    }
    return _ojr_algorithm_count;
}

canonical_original_code:
int ojr_algorithm_count() {
    if (0 == _ojr_algorithm_count) {
        struct _ojr_algorithm **aap = ojr_algorithms;
        while (((void *)0) != *aap) { ++aap; ++_ojr_algorithm_count; }
    }
    return _ojr_algorithm_count;
}

variable_types: struct _ojr_algorithm { char *name; int seedsize; int statesize; int bufsize; void (*open)(struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *); void (*close)(struct _ojr_generator *); void (*seed)(struct _ojr_generator *, unsigned int *, int); void (*reseed)(struct _ojr_generator *, unsigned int *, int); void (*refill)(struct _ojr_generator *); void *extra; void *padding[4]; } **

user_defined_types: struct _ojr_algorithm { char *name; int seedsize; int statesize; int bufsize; void (*open)(struct _ojr_generator *); void (*close)(struct _ojr_generator *); void (*seed)(struct _ojr_generator *, unsigned int *, int); void (*reseed)(struct _ojr_generator *, unsigned int *, int); void (*refill)(struct _ojr_generator *); void *extra; void *padding[4]; }


decompiled_code:
__int64 __fastcall ojr_algorithm_name(int a1)
{
if ( a1 < 0 )
return 0LL;
if ( (int)ojr_algorithm_count() < a1 )
return 0LL;
return *(_QWORD *)*(&ojr_algorithms + (a1 == 0) + a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
if ( a1 < 0 )
return 0LL;
if ( (int)func0() < a1 )
return 0LL;
return *(_QWORD *)*(&ojr_algorithms + (a1 == 0) + a1 - 1);
}

original_code:
char *ojr_algorithm_name(int id) {
    if (id < 0 || id > ojr_algorithm_count()) return ((void *)0);
    if (0 == id) id = 1;
    return (ojr_algorithms[id - 1])->name;
}

variable_types: id int

return_type: char *


decompiled_code:
__int64 __fastcall ojr_algorithm_id(char *s1)
{
int v1; // eax
__int64 v2; // r13
__int64 v3; // rbx

v1 = ojr_algorithm_count();
if ( !s1 || v1 <= 0 )
return 0LL;
v2 = (unsigned int)(v1 + 1);
v3 = 1LL;
while ( strcmp(s1, *(const char **)*(&ojr_algorithms + v3 - 1)) )
{
if ( ++v3 == v2 )
return 0LL;
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s1)
{
int v1; // eax
__int64 v2; // r13
__int64 v3; // rbx

v1 = func0();
if ( !s1 || v1 <= 0 )
return 0LL;
v2 = (unsigned int)(v1 + 1);
v3 = 1LL;
while ( strcmp(s1, *(const char **)*(&ojr_algorithms + v3 - 1)) )
{
if ( ++v3 == v2 )
return 0LL;
}
return (unsigned int)v3;
}

original_code:
int ojr_algorithm_id(const char *name) {
    int i, c = ojr_algorithm_count();
    if (((void *)0) == name) return 0;
    for (i = 0; i < c; ++i) {
        if (0 == strcmp(name, (ojr_algorithms[i])->name)) {
            return i + 1;
        }
    }
    return 0;
}

canonical_original_code:
int ojr_algorithm_id(char *name) {
    int i; int c = ojr_algorithm_count();
    if (((void *)0) == name) return 0;
    for (i = 0; i < c; ++i) {
        if (0 == strcmp(name, (ojr_algorithms[i])->name)) {
            return i + 1;
        }
    }
    return 0;
}

variable_types:
name
char *


decompiled_code:
__int64 __fastcall ojr_algorithm_seedsize(int a1)
{
if ( a1 < 0 || (int)ojr_algorithm_count() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x3Eu,
"ojr_algorithm_seedsize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 2);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
if ( a1 < 0 || (int)func0() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x3Eu,
"ojr_algorithm_seedsize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 2);
}

original_code:
int ojr_algorithm_seedsize(int id) {
    ((id >= 0 && id <= ojr_algorithm_count()) ? (void) (0) : __assert_fail ("id >= 0 && id <= ojr_algorithm_count()", "/usr/src/repo/source/library/algorithms.c", 62, __extension__ __PRETTY_FUNCTION__));
    if (0 == id) id = 1;
    return (ojr_algorithms[id - 1])->seedsize;
}


decompiled_code:
__int64 __fastcall ojr_algorithm_statesize(int a1)
{
if ( a1 < 0 || (int)ojr_algorithm_count() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x44u,
"ojr_algorithm_statesize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 3);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
if ( a1 < 0 || (int)func0() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x44u,
"ojr_algorithm_statesize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 3);
}

original_code:
int ojr_algorithm_statesize(int id) {
    ((id >= 0 && id <= ojr_algorithm_count()) ? (void) (0) : __assert_fail ("id >= 0 && id <= ojr_algorithm_count()", "/usr/src/repo/source/library/algorithms.c", 68, __extension__ __PRETTY_FUNCTION__));
    if (0 == id) id = 1;
    return (ojr_algorithms[id - 1])->statesize;
}


decompiled_code:
__int64 __fastcall ojr_algorithm_bufsize(int a1)
{
if ( a1 < 0 || (int)ojr_algorithm_count() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x4Au,
"ojr_algorithm_bufsize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 4);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
if ( a1 < 0 || (int)func0() < a1 )
_assert_fail(
"id >= 0 && id <= ojr_algorithm_count()",
"/usr/src/repo/source/library/algorithms.c",
0x4Au,
"ojr_algorithm_bufsize");
return *((unsigned int *)*(&ojr_algorithms + (a1 == 0) + a1 - 1) + 4);
}

original_code:
int ojr_algorithm_bufsize(int id) {
    ((id >= 0 && id <= ojr_algorithm_count()) ? (void) (0) : __assert_fail ("id >= 0 && id <= ojr_algorithm_count()", "/usr/src/repo/source/library/algorithms.c", 74, __extension__ __PRETTY_FUNCTION__));
    if (0 == id) id = 1;
    return (ojr_algorithms[id - 1])->bufsize;
}


decompiled_code:
int __fastcall ojr_get_system_entropy(void *buf, int a2)
{
int v2; // eax
int v3; // ebx
int v4; // ebp

v2 = open("/dev/urandom", 0);
if ( v2 == -1 )
{
fwrite("ojrandlib: Can't open /dev/urandom.\n", 1uLL, 0x24uLL, stderr);
exit(1);
}
v3 = 4 * a2;
v4 = v2;
if ( v3 != read(v2, buf, v3) )
{
fprintf(stderr, "ojrandlib: Failed to read %d bytes from /dev/urandom.\n", (unsigned int)v3);
exit(1);
}
return close(v4);
}

canonical_decompiled_code:
int __fastcall func0(void *buf, int a2)
{
int v2; // eax
int v3; // ebx
int v4; // ebp

v2 = open("/dev/urandom", 0);
if ( v2 == -1 )
{
fwrite("ojrandlib: Can't open /dev/urandom.\n", 1uLL, 0x24uLL, stderr);
exit(1);
}
v3 = 4 * a2;
v4 = v2;
if ( v3 != read(v2, buf, v3) )
{
fprintf(stderr, "ojrandlib: Failed to read %d bytes from /dev/urandom.\n", (unsigned int)v3);
exit(1);
}
return close(v4);
}

original_code:
extern void ojr_get_system_entropy(uint32_t *dest, int dsize) {
    int fn;
    fn = open("/dev/urandom", 00);
    if (-1 == fn) {
        fprintf(stderr, "ojrandlib: Can't open /dev/urandom.\n");
        exit(1);
    }
    if (4 * dsize != read(fn, (char *)dest, 4 * dsize)) {
        fprintf(stderr,
            "ojrandlib: Failed to read %d bytes from /dev/urandom.\n",
            4 * dsize);
        exit(1);
    }
    close(fn);
    return;
}

canonical_original_code:
extern void ojr_get_system_entropy(unsigned int *dest, int dsize) {
    int fn;
    fn = open("/dev/urandom", 00);
    if (-1 == fn) {
        fprintf(stderr, "ojrandlib: Can't open /dev/urandom.\n");
        exit(1);
    }
    if (4 * dsize != read(fn, (char *)dest, 4 * dsize)) {
        fprintf(stderr,
            "ojrandlib: Failed to read %d bytes from /dev/urandom.\n",
            4 * dsize);
        exit(1);
    }
    close(fn);
    return;
}

variable_types:
dest
unsigned int *

variable_types: dsize int

variable_types: fn int


decompiled_code:
double __fastcall ojr_next_exponential(__int64 a1)
{
unsigned __int64 v1; // rdx
int v2; // er15
unsigned __int64 v3; // rax
double v4; // xmm1_8
__int64 v5; // rax
__int64 v6; // r15
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-50h]
double v10; // [rsp+10h] [rbp-48h]
double v11; // [rsp+18h] [rbp-40h]

while ( 1 )
{
v5 = *(_QWORD *)(a1 + 40);
if ( v5 - *(_QWORD *)(a1 + 32) > 4 )
{
*(_QWORD *)(a1 + 40) = v5 - 8;
v1 = *(_QWORD *)(v5 - 8);
}
else
{
v6 = (unsigned int)ojr_next32(a1);
v1 = (v6 << 32) | (unsigned int)ojr_next32(a1);
}
v2 = (unsigned __int8)v1;
v3 = (v1 >> 8) & 0xFFFFFFFFFFFFFLL;
if ( v3 < zeri[(unsigned __int8)v1] )
return (COERCE_DOUBLE(v3 | 0x3FF0000000000000LL) - 1.0) * zex[(unsigned __int8)v1];
if ( !(_BYTE)v1 )
break;
v4 = zex[(unsigned __int8)v1];
v9 = (COERCE_DOUBLE(v3 | 0x3FF0000000000000LL) - 1.0) * v4;
v11 = exp(v9 - v4);
v10 = exp(v9 - zex[v2 + 1]);
if ( (v11 - v10) * ojr_next_double(a1) + v10 < 1.0 )
return v9;
}
v8 = ojr_next_double(a1);
return 7.69711747013105 - log(v8);
}

canonical_decompiled_code:
double __fastcall func0(__int64 a1)
{
unsigned __int64 v1; // rdx
int v2; // er15
unsigned __int64 v3; // rax
double v4; // xmm1_8
__int64 v5; // rax
__int64 v6; // r15
double v8; // xmm0_8
double v9; // [rsp+8h] [rbp-50h]
double v10; // [rsp+10h] [rbp-48h]
double v11; // [rsp+18h] [rbp-40h]

while ( 1 )
{
v5 = *(_QWORD *)(a1 + 40);
if ( v5 - *(_QWORD *)(a1 + 32) > 4 )
{
*(_QWORD *)(a1 + 40) = v5 - 8;
v1 = *(_QWORD *)(v5 - 8);
}
else
{
v6 = (unsigned int)ojr_next32(a1);
v1 = (v6 << 32) | (unsigned int)ojr_next32(a1);
}
v2 = (unsigned __int8)v1;
v3 = (v1 >> 8) & 0xFFFFFFFFFFFFFLL;
if ( v3 < zeri[(unsigned __int8)v1] )
return (COERCE_DOUBLE(v3 | 0x3FF0000000000000LL) - 1.0) * zex[(unsigned __int8)v1];
if ( !(_BYTE)v1 )
break;
v4 = zex[(unsigned __int8)v1];
v9 = (COERCE_DOUBLE(v3 | 0x3FF0000000000000LL) - 1.0) * v4;
v11 = exp(v9 - v4);
v10 = exp(v9 - zex[v2 + 1]);
if ( (v11 - v10) * ojr_next_double(a1) + v10 < 1.0 )
return v9;
}
v8 = ojr_next_double(a1);
return 7.69711747013105 - log(v8);
}

canonical_original_code:
double ojr_next_exponential(struct _ojr_generator *g) {
    unsigned long r;
    int i;
    double x; double u0; double f0; double f1;
    while (1) {
        r = ((((g)->bptr - (g)->buf) >= 2) ? ((g)->bptr -= 2, *(unsigned long *)((g)->bptr)) : (((unsigned long)(ojr_next32(g)) << 32) | ojr_next32(g)));
        i = r & 0xFF;
        r = (r >> 8) & 0xFFFFFFFFFFFFFULL;
        if (r < zeri[i]) {
            r |= 0x3FF0000000000000ULL;
            u0 = *(double *)(&r) - 1.0;
            return u0 * zex[i];
        }
        if (0 == i) return 7.6971174701310497140 - log(ojr_next_double(g));
        r |= 0x3FF0000000000000ULL;
        u0 = *(double *)(&r) - 1.0;
        x = u0 * zex[i];
        f0 = exp(x - zex[i]);
        f1 = exp(x - zex[i+1]);
        if (f1 + ojr_next_double(g) * (f0 - f1) < 1.0) return x;
    }
}

variable_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *

variable_types:
r
unsigned long

variable_types: x double


canonical_original_code:
double ojr_next_normal(struct _ojr_generator *g) {
    unsigned long r;
    int i; int sign;
    double x; double y; double a; double u0; double f0; double f1;
    while (1) {
        do {
            r = ((((g)->bptr - (g)->buf) >= 2) ? ((g)->bptr -= 2, *(unsigned long *)((g)->bptr)) : (((unsigned long)(ojr_next32(g)) << 32) | ojr_next32(g)));
            sign = (int)r & 1;
            i = (r >> 1) & 0x7F;
            r >>= 12;
        } while (sign && 0LL == r);
        if (r < znri[i]) {
            r |= 0x3FF0000000000000ULL;
            a = *(double *)(&r) - 1.0;
            return znx[i] * (sign ? -a : a);
        }
        if (0 == i) {
            do {
                x = log(ojr_next_double(g)) / 3.4426198558966521214;
                y = log(ojr_next_double(g));
            } while (-2.0 * y < x * x);
            return sign ? x - 3.4426198558966521214 : 3.4426198558966521214 - x;
        }
        r |= 0x3FF0000000000000ULL;
        a = *(double *)(&r) - 1.0;
        x = znx[i] * (sign ? -a : a);
        f0 = exp(-0.5 * (znx[i] * znx[i] - x * x));
        f1 = exp(-0.5 * (znx[i+1] * znx[i+1] - x * x));
        if (f1 + ojr_next_double(g) * (f0 - f1) < 1.0) return x;
    }
}

variable_types: i int

variable_types: sign int

variable_types: y double

variable_types: a double


repo: ldipenti/GNOME-War-Pad

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

result = sdl_type_6;
if ( !sdl_type_6 )
{
v1 = gtk_widget_get_type();
result = gtk_type_unique(v1, &sdl_info_5);
sdl_type_6 = result;
}
return result;
}

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

result = sdl_type_6;
if ( !sdl_type_6 )
{
v1 = gtk_widget_get_type();
result = gtk_type_unique(v1, &sdl_info_5);
sdl_type_6 = result;
}
return result;
}

original_code:
GtkType gtk_sdl_get_type (void)
{
  static GtkType sdl_type = 0;
 if (!sdl_type)
 {
  static const GtkTypeInfo sdl_info =
  {
   "GtkSDL",
   sizeof (GtkSDL),
   sizeof (GtkSDLClass),
   (GtkClassInitFunc) gtk_sdl_class_init,
   (GtkObjectInitFunc) gtk_sdl_init,
                    ((void *)0),
                    ((void *)0),
   (GtkClassInitFunc) ((void *)0),
  };
  sdl_type = gtk_type_unique ((gtk_widget_get_type ()), &sdl_info);
 }
 return sdl_type;
}

canonical_original_code:
unsigned long gtk_sdl_get_type()
{
  static unsigned long sdl_type = 0;
 if (!sdl_type)
 {
  static struct _GtkTypeInfo sdl_info = {
   "GtkSDL",
   sizeof (GtkSDL),
   sizeof (GtkSDLClass),
   (GtkClassInitFunc) gtk_sdl_class_init,
   (GtkObjectInitFunc) gtk_sdl_init,
                    ((void *)0),
                    ((void *)0),
   (GtkClassInitFunc) ((void *)0),
  };
  sdl_type = gtk_type_unique ((gtk_widget_get_type ()), &sdl_info);
 }
 return sdl_type;
}

variable_types: struct _GtkTypeInfo { char *type_name; unsigned int object_size; unsigned int class_size; void (*class_init_func)(void *g_class); void (*object_init_func)(struct _GTypeInstance { struct _GTypeClass { unsigned long g_type; } *g_class; } *instance, void *g_class); void *reserved_1; void *reserved_2; void (*base_class_init_func)(void *g_class); }

user_defined_types: struct _GtkTypeInfo { char *type_name; unsigned int object_size; unsigned int class_size; void (*class_init_func)(void *g_class); void (*object_init_func)(struct _GTypeInstance *instance, void *g_class); void *reserved_1; void *reserved_2; void (*base_class_init_func)(void *g_class); }

user_defined_types: struct _GTypeInstance { struct _GTypeClass *g_class; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
const char *v4; // rdi
unsigned int v5; // ebp
int v6; // ebx
_QWORD *v7; // rax
void *v8; // r12
unsigned int v9; // ebx
unsigned int v10; // er13
int v11; // ebp
float v12; // xmm0_4
double v14; // [rsp+18h] [rbp-40h] BYREF
char v15[56]; // [rsp+20h] [rbp-38h] BYREF

if ( argc <= 2 )
{
puts("./dla seed number_of_particles");
}
else
{
v3 = atoi(argv[1]);
v4 = argv[2];
v5 = v3;
seed = v3;
n_of_particles = atoi(v4);
grid_size = global_grid_size;
radius = global_radius;
srand(v5);
dtimer(&v14, v15, 0xFFFFFFFFLL);
v6 = n_of_particles;
v7 = malloc(4LL * n_of_particles * dimensions);
*v7 = 0LL;
v8 = v7;
if ( v6 <= 1 )
{
v10 = 0;
}
else
{
v9 = 1;
v10 = 0;
do
{
v11 = 0;
initialize_particle(v8, v9);
do
{
++v11;
move_particle(v8, v9);
}
while ( !(unsigned int)check_for_collision(v8, v9) );
v10 += v11;
++v9;
}
while ( n_of_particles > (int)v9 );
}
dtimer(&v14, v15, 1LL);
v12 = v14;
free(v8);
printf("TOTAL NUMBER OF STEPS: %i : %f\n", v10, v12);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
const char *v4; // rdi
unsigned int v5; // ebp
int v6; // ebx
_QWORD *v7; // rax
void *v8; // r12
unsigned int v9; // ebx
unsigned int v10; // er13
int v11; // ebp
float v12; // xmm0_4
double v14; // [rsp+18h] [rbp-40h] BYREF
char v15[56]; // [rsp+20h] [rbp-38h] BYREF

if ( argc <= 2 )
{
puts("./dla seed number_of_particles");
}
else
{
v3 = atoi(argv[1]);
v4 = argv[2];
v5 = v3;
seed = v3;
n_of_particles = atoi(v4);
grid_size = global_grid_size;
radius = global_radius;
srand(v5);
func11(&v14, v15, 0xFFFFFFFFLL);
v6 = n_of_particles;
v7 = malloc(4LL * n_of_particles * dimensions);
*v7 = 0LL;
v8 = v7;
if ( v6 <= 1 )
{
v10 = 0;
}
else
{
v9 = 1;
v10 = 0;
do
{
v11 = 0;
func8(v8, v9);
do
{
++v11;
func9(v8, v9);
}
while ( !(unsigned int)func10(v8, v9) );
v10 += v11;
++v9;
}
while ( n_of_particles > (int)v9 );
}
func11(&v14, v15, 1LL);
v12 = v14;
free(v8);
printf("TOTAL NUMBER OF STEPS: %i : %f\n", v10, v12);
}
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 if (argc < 3)
 {
  printf("./dla seed number_of_particles\n");
  return 0;
 }
 seed = atoi(argv[1]);
 n_of_particles = atoi(argv[2]);
 grid_size = global_grid_size;
 radius = global_radius;
 srand(seed);
 float time;
 struct timeval itime;
 double dtime;
 dtimer(&dtime,&itime,-1);
 float* particles = (float*) malloc (dimensions * n_of_particles * sizeof(float));
 particles[0] = 0.00;
 particles[1] = 0.00;
 int total_step =0;
 int particle_index;
 for (particle_index = 1; particle_index < n_of_particles; particle_index++)
 {
  initialize_particle(particles, particle_index);
  int collision = 0;
  int step_ctr=0;
  while (!collision)
  {
   move_particle(particles, particle_index);
   collision = check_for_collision(particles, particle_index);
   step_ctr++;
  }
  total_step += step_ctr;
 }
 dtimer(&dtime,&itime,1);
 time = (float) dtime;
 free(particles);
 printf("TOTAL NUMBER OF STEPS: %i : %f\n",total_step,time);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 if (argc < 3)
 {
  printf("./dla seed number_of_particles\n");
  return 0;
 }
 seed = atoi(argv[1]);
 n_of_particles = atoi(argv[2]);
 grid_size = global_grid_size;
 radius = global_radius;
 srand(seed);
 float time;
 struct timeval itime;
 double dtime;
 dtimer(&dtime,&itime,-1);
 float *particles = (float*) malloc (dimensions * n_of_particles * sizeof(float));
 particles[0] = 0.00;
 particles[1] = 0.00;
 int total_step = 0;
 int particle_index;
 for (particle_index = 1; particle_index < n_of_particles; particle_index++)
 {
  initialize_particle(particles, particle_index);
  int collision = 0;
  int step_ctr = 0;
  while (!collision)
  {
   move_particle(particles, particle_index);
   collision = check_for_collision(particles, particle_index);
   step_ctr++;
  }
  total_step += step_ctr;
 }
 dtimer(&dtime,&itime,1);
 time = (float) dtime;
 free(particles);
 printf("TOTAL NUMBER OF STEPS: %i : %f\n",total_step,time);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: time float

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

variable_types: dtime double

variable_types:
particles
float *

variable_types: collision int


distance

decompiled_code:
void __fastcall distance(float a1, float a2, float a3, float a4)
{
float v4; // xmm0_4

v4 = (float)((float)(a1 - a2) * (float)(a1 - a2)) + (float)((float)(a3 - a4) * (float)(a3 - a4));
if ( v4 < 0.0 )
sqrtf(v4);
}

canonical_decompiled_code:
void __fastcall func7(float a1, float a2, float a3, float a4)
{
float v4; // xmm0_4

v4 = (float)((float)(a1 - a2) * (float)(a1 - a2)) + (float)((float)(a3 - a4) * (float)(a3 - a4));
if ( v4 < 0.0 )
sqrtf(v4);
}

original_code:
float distance (float x1, float x2, float y1, float y2)
{
 x1 = x1-x2;
 x1 = x1*x1;
 y1 = y1-y2;
 y1 = y1*y1;
 float result = sqrt(x1+y1);
 return result;
}

canonical_original_code:
float distance(float x1, float x2, float y1, float y2)
{
 x1 = x1-x2;
 x1 = x1*x1;
 y1 = y1-y2;
 y1 = y1*y1;
 float result = sqrt(x1+y1);
 return result;
}

variable_types: result float

return_type: float


decompiled_code:
__int64 __fastcall initialize_particle(__int64 a1, int a2)
{
__m128i v2; // xmm0
int v3; // er14
int v4; // eax
char v5; // dl
__int64 result; // rax
int v7; // xmm0_4
__int64 v8; // rbx
__int64 v9; // rbx
float v10; // xmm0_4
__int64 v11; // rbx
__int64 v12; // rbx

v2 = 0LL;
*(float *)v2.m128i_i32 = (float)((float)(2 * rand()) * 4.6566129e-10) * *(float *)&grid_size;
v3 = _mm_cvtsi128_si32(v2);
v4 = rand();
v5 = v4;
result = (unsigned int)(v4 % 4);
if ( (_DWORD)result == 2 )
{
v9 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v9) = v3;
*(float *)(a1 + 4 * v9 + 4) = -*(float *)&grid_size;
}
else if ( (_DWORD)result == 3 )
{
v12 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v12) = v3;
*(_DWORD *)(a1 + 4 * v12 + 4) = grid_size;
}
else if ( (v5 & 3) != 0 )
{
if ( (_DWORD)result == 1 )
{
v7 = grid_size;
v8 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v8 + 4) = v3;
*(_DWORD *)(a1 + 4 * v8) = v7;
}
}
else
{
v10 = -*(float *)&grid_size;
v11 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v11 + 4) = v3;
*(float *)(a1 + 4 * v11) = v10;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2)
{
__m128i v2; // xmm0
int v3; // er14
int v4; // eax
char v5; // dl
__int64 result; // rax
int v7; // xmm0_4
__int64 v8; // rbx
__int64 v9; // rbx
float v10; // xmm0_4
__int64 v11; // rbx
__int64 v12; // rbx

v2 = 0LL;
*(float *)v2.m128i_i32 = (float)((float)(2 * rand()) * 4.6566129e-10) * *(float *)&grid_size;
v3 = _mm_cvtsi128_si32(v2);
v4 = rand();
v5 = v4;
result = (unsigned int)(v4 % 4);
if ( (_DWORD)result == 2 )
{
v9 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v9) = v3;
*(float *)(a1 + 4 * v9 + 4) = -*(float *)&grid_size;
}
else if ( (_DWORD)result == 3 )
{
v12 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v12) = v3;
*(_DWORD *)(a1 + 4 * v12 + 4) = grid_size;
}
else if ( (v5 & 3) != 0 )
{
if ( (_DWORD)result == 1 )
{
v7 = grid_size;
v8 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v8 + 4) = v3;
*(_DWORD *)(a1 + 4 * v8) = v7;
}
}
else
{
v10 = -*(float *)&grid_size;
v11 = dimensions * a2;
*(_DWORD *)(a1 + 4 * v11 + 4) = v3;
*(float *)(a1 + 4 * v11) = v10;
}
return result;
}

original_code:
void initialize_particle(float* particles, int i)
{
 float random_position = grid_size*(2*rand()/(float)2147483647);
 switch( rand() % 4)
 {
  case 0:
   particles[dimensions*i] = -grid_size;
   particles[dimensions*i+1] = random_position;
   break;
  case 1:
   particles[dimensions*i] = grid_size;
   particles[dimensions*i+1] = random_position;
   break;
  case 2:
   particles[dimensions*i] = random_position;
   particles[dimensions*i+1] = -grid_size;
   break;
  case 3:
   particles[dimensions*i] = random_position;
   particles[dimensions*i+1] = grid_size;
   break;
 }
}

canonical_original_code:
void initialize_particle(float *particles, int i)
{
 float random_position = grid_size*(2*rand()/(float)2147483647);
 switch( rand() % 4)
 {
  case 0:
   particles[dimensions*i] = -grid_size;
   particles[dimensions*i+1] = random_position;
   break;
  case 1:
   particles[dimensions*i] = grid_size;
   particles[dimensions*i+1] = random_position;
   break;
  case 2:
   particles[dimensions*i] = random_position;
   particles[dimensions*i+1] = -grid_size;
   break;
  case 3:
   particles[dimensions*i] = random_position;
   particles[dimensions*i+1] = grid_size;
   break;
 }
}


decompiled_code:
__int64 __fastcall move_particle(__int64 a1, int a2)
{
int v2; // eax
float v3; // xmm1_4
float v4; // xmm0_4
bool v5; // zf
__int64 result; // rax
float *v7; // rdx
float v8; // xmm0_4
float v9; // xmm1_4
float v10; // xmm1_4
float v11; // [rsp+8h] [rbp-20h]
float v12; // [rsp+8h] [rbp-20h]

v11 = (float)((float)rand() * *(float *)&radius) * 4.6566129e-10;
v2 = rand();
v3 = (float)((float)v2 * v11) * 4.6566129e-10;
v4 = (float)(v11 * v11) - (float)(v3 * v3);
if ( v4 < 0.0 )
{
v3 = (float)((float)v2 * v11) * 4.6566129e-10;
v12 = sqrtf(v4);
}
else
{
v12 = fsqrt(v4);
}
if ( rand() % 2 == 1 )
*(float *)(a1 + 4LL * dimensions * a2) = v3 + *(float *)(a1 + 4LL * dimensions * a2);
else
*(float *)(a1 + 4LL * dimensions * a2) = *(float *)(a1 + 4LL * dimensions * a2) - v3;
v5 = rand() % 2 == 1;
result = dimensions * a2;
v7 = (float *)(a1 + 4 * result + 4);
if ( v5 )
v8 = v12 + *v7;
else
v8 = *v7 - v12;
*v7 = v8;
v9 = *(float *)(a1 + 4 * result);
if ( v9 > *(float *)&grid_size
|| (float)-*(float *)&grid_size > v9
|| (v10 = *(float *)(a1 + 4 * result + 4), v10 > *(float *)&grid_size)
|| (float)-*(float *)&grid_size > v10 )
{
result = initialize_particle(a1, a2);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2)
{
int v2; // eax
float v3; // xmm1_4
float v4; // xmm0_4
bool v5; // zf
__int64 result; // rax
float *v7; // rdx
float v8; // xmm0_4
float v9; // xmm1_4
float v10; // xmm1_4
float v11; // [rsp+8h] [rbp-20h]
float v12; // [rsp+8h] [rbp-20h]

v11 = (float)((float)rand() * *(float *)&radius) * 4.6566129e-10;
v2 = rand();
v3 = (float)((float)v2 * v11) * 4.6566129e-10;
v4 = (float)(v11 * v11) - (float)(v3 * v3);
if ( v4 < 0.0 )
{
v3 = (float)((float)v2 * v11) * 4.6566129e-10;
v12 = sqrtf(v4);
}
else
{
v12 = fsqrt(v4);
}
if ( rand() % 2 == 1 )
*(float *)(a1 + 4LL * dimensions * a2) = v3 + *(float *)(a1 + 4LL * dimensions * a2);
else
*(float *)(a1 + 4LL * dimensions * a2) = *(float *)(a1 + 4LL * dimensions * a2) - v3;
v5 = rand() % 2 == 1;
result = dimensions * a2;
v7 = (float *)(a1 + 4 * result + 4);
if ( v5 )
v8 = v12 + *v7;
else
v8 = *v7 - v12;
*v7 = v8;
v9 = *(float *)(a1 + 4 * result);
if ( v9 > *(float *)&grid_size
|| (float)-*(float *)&grid_size > v9
|| (v10 = *(float *)(a1 + 4 * result + 4), v10 > *(float *)&grid_size)
|| (float)-*(float *)&grid_size > v10 )
{
result = func8(a1, a2);
}
return result;
}

original_code:
void move_particle(float* particles, int i)
{
 float velocity = radius*rand()/(float)2147483647;
 float x_value = velocity*rand()/(float)2147483647;
 float y_squared = velocity*velocity-x_value*x_value;
 float y_value = sqrt(y_squared);
 if ((rand()%2) < 1)
  particles[dimensions*i] = particles[dimensions*i]-x_value;
 else
  particles[dimensions*i] = particles[dimensions*i]+x_value;
 if ((rand()%2) < 1)
  particles[dimensions*i+1] = particles[dimensions*i+1]-y_value;
 else
  particles[dimensions*i+1] = particles[dimensions*i+1]+y_value;
 if (particles[dimensions*i] > grid_size || particles[dimensions*i] < -grid_size || particles[dimensions*i+1] > grid_size || particles[dimensions*i+1] < -grid_size)
  initialize_particle(particles, i);
}

canonical_original_code:
void move_particle(float *particles, int i)
{
 float velocity = radius*rand()/(float)2147483647;
 float x_value = velocity*rand()/(float)2147483647;
 float y_squared = velocity*velocity-x_value*x_value;
 float y_value = sqrt(y_squared);
 if ((rand()%2) < 1)
  particles[dimensions*i] = particles[dimensions*i]-x_value;
 else
  particles[dimensions*i] = particles[dimensions*i]+x_value;
 if ((rand()%2) < 1)
  particles[dimensions*i+1] = particles[dimensions*i+1]-y_value;
 else
  particles[dimensions*i+1] = particles[dimensions*i+1]+y_value;
 if (particles[dimensions*i] > grid_size || particles[dimensions*i] < -grid_size || particles[dimensions*i+1] > grid_size || particles[dimensions*i+1] < -grid_size)
  initialize_particle(particles, i);
}

variable_types: velocity float


decompiled_code:
__int64 __fastcall check_for_collision(__int64 a1, int a2)
{
int i; // er12
__int64 v3; // rax
float v4; // xmm0_4

if ( a2 <= 0 )
return 0LL;
for ( i = 0; i != a2; ++i )
{
v3 = a2 * dimensions + 1LL;
v4 = *(float *)(a1 + 4 * v3 - 4);
distance(
v4,
*(float *)(a1 + 4 * (i * dimensions + 1LL) - 4),
*(float *)(a1 + 4 * v3),
*(float *)(a1 + 4 * (i * dimensions + 1LL)));
if ( (float)(*(float *)&radius + *(float *)&radius) > v4 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2)
{
int i; // er12
__int64 v3; // rax
float v4; // xmm0_4

if ( a2 <= 0 )
return 0LL;
for ( i = 0; i != a2; ++i )
{
v3 = a2 * dimensions + 1LL;
v4 = *(float *)(a1 + 4 * v3 - 4);
func7(
v4,
*(float *)(a1 + 4 * (i * dimensions + 1LL) - 4),
*(float *)(a1 + 4 * v3),
*(float *)(a1 + 4 * (i * dimensions + 1LL)));
if ( (float)(*(float *)&radius + *(float *)&radius) > v4 )
return 1LL;
}
return 0LL;
}

original_code:
int check_for_collision(float* particles, int i)
{
 int ctr;
 for (ctr = 0; ctr < i; ctr++)
 {
  float distance_to_particle = distance(particles[dimensions*i],particles[dimensions*ctr],particles[dimensions*i+1],particles[dimensions*ctr+1]);
  if (distance_to_particle< (2*radius))
  {
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
int check_for_collision(float *particles, int i)
{
 int ctr;
 for (ctr = 0; ctr < i; ctr++)
 {
  float distance_to_particle = distance(particles[dimensions*i],particles[dimensions*ctr],particles[dimensions*i+1],particles[dimensions*ctr+1]);
  if (distance_to_particle< (2*radius))
  {
   return 1;
  }
 }
 return 0;
}

variable_types: ctr int


dtimer

decompiled_code:
int __fastcall dtimer(double *a1, __m128i *a2, int a3)
{
int result; // eax
__m128i v4; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

if ( a3 )
{
if ( a3 == 1 )
{
gettimeofday(&tv, 0LL);
v4 = _mm_loadu_si128(a2);
result = LODWORD(tv.tv_sec) - v4.m128i_i32[0];
*a1 = (double)(LODWORD(tv.tv_usec) - v4.m128i_i32[2]) * 0.000001 + (double)(LODWORD(tv.tv_sec) - v4.m128i_i32[0]);
}
else
{
result = gettimeofday((struct timeval *)&v4, 0LL);
*a2 = _mm_loadu_si128(&v4);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func11(double *a1, __m128i *a2, int a3)
{
int result; // eax
__m128i v4; // [rsp+0h] [rbp-38h] BYREF
struct timeval tv; // [rsp+10h] [rbp-28h] BYREF

if ( a3 )
{
if ( a3 == 1 )
{
gettimeofday(&tv, 0LL);
v4 = _mm_loadu_si128(a2);
result = LODWORD(tv.tv_sec) - v4.m128i_i32[0];
*a1 = (double)(LODWORD(tv.tv_usec) - v4.m128i_i32[2]) * 0.000001 + (double)(LODWORD(tv.tv_sec) - v4.m128i_i32[0]);
}
else
{
result = gettimeofday((struct timeval *)&v4, 0LL);
*a2 = _mm_loadu_si128(&v4);
}
}
return result;
}

original_code:
void dtimer(double *time, struct timeval *itime, int icntrl) {
   long oss, usec;
   const double tick = 1.0/1000000.0;
   struct timeval jclock, nclock;
   if (!(icntrl))
      return;
   if (icntrl==1)
      goto L10;
   oss = gettimeofday(&jclock,((void *)0));
   *itime = jclock;
   return;
L10: oss = gettimeofday(&nclock,((void *)0));
   jclock = *itime;
   usec = nclock.tv_usec - jclock.tv_usec;
   *time = (nclock.tv_sec - jclock.tv_sec) + usec*tick;
   return;
}

canonical_original_code:
void dtimer(double *time, struct timeval *itime, int icntrl) {
   long oss; long usec;
   double tick = 1.0/1000000.0;
   struct timeval jclock; struct timeval nclock;
   if (!(icntrl))
      return;
   if (icntrl==1)
      goto L10;
   oss = gettimeofday(&jclock,((void *)0));
   *itime = jclock;
   return;
L10: oss = gettimeofday(&nclock,((void *)0));
   jclock = *itime;
   usec = nclock.tv_usec - jclock.tv_usec;
   *time = (nclock.tv_sec - jclock.tv_sec) + usec*tick;
   return;
}

variable_types:
time
double *

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

variable_types: icntrl int

variable_types: oss long

variable_types: usec long

variable_types: tick double


decompiled_code:
int __fastcall dtimer_(double *a1, __m128i *a2, int *a3)
{
return dtimer(a1, a2, *a3);
}

canonical_decompiled_code:
int __fastcall func12(double *a1, __m128i *a2, int *a3)
{
return func11(a1, a2, *a3);
}

original_code:
void dtimer_(double *time, unsigned long *itime, int *icntrl) {
   dtimer(time,(struct timeval *)itime,*icntrl);
   return;
}

variable_types:
itime
unsigned long *

variable_types:
icntrl
int *

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


repo: leasim/scramble

decompiled_code:
void *__fastcall clean_keys(void *s, void **a2)
{
int v2; // ebx

v2 = strlen((const char *)s);
memset(s, 0, v2);
return memset(*a2, 0, v2 / 2);
}

canonical_decompiled_code:
void *__fastcall func7(void *s, void **a2)
{
int v2; // ebx

v2 = strlen((const char *)s);
memset(s, 0, v2);
return memset(*a2, 0, v2 / 2);
}

original_code:
void clean_keys(char usrKey[], unsigned char ** keys)
{
 unsigned char * k;
 int i, size;
 size = strlen(usrKey);
 memset((void *)usrKey, '\0', size);
 memset((void *)*keys, '\0', size / 2);
}

canonical_original_code:
void clean_keys(char usrKey[], unsigned char **keys)
{
 unsigned char *k;
 int i; int size;
 size = strlen(usrKey);
 memset((void *)usrKey, '\0', size);
 memset((void *)*keys, '\0', size / 2);
}

variable_types:
usrKey
char []

variable_types:
keys
unsigned char **

variable_types:
k
unsigned char *

variable_types: i int

variable_types: size int