runtimeTests

decompiled_code:
__int64 runtimeTests()
{
unsigned int v0; // ebx
char *v1; // rax
int v3; // ecx
__int64 v4; // rax
char v5; // si
int v6; // edx
unsigned int v7; // eax
unsigned int v8; // eax
int v9; // er12
unsigned __int64 v10; // rbp
_BYTE v11[32]; // [rsp+0h] [rbp-F8h] BYREF
char v12[16]; // [rsp+20h] [rbp-D8h] BYREF
char v13[3]; // [rsp+30h] [rbp-C8h] BYREF
char v14; // [rsp+33h] [rbp-C5h]
unsigned __int8 v15; // [rsp+AFh] [rbp-49h]
__int64 v16; // [rsp+B8h] [rbp-40h] BYREF
char ptr[16]; // [rsp+C0h] [rbp-38h] BYREF
char v18; // [rsp+D0h] [rbp-28h] BYREF

memset_s(ptr, 0LL, 16LL);
v0 = getRandom(ptr, 0x10uLL);
if ( v0 )
{
v1 = ptr;
while ( !*v1 )
{
if ( ++v1 == &v18 )
return 0;
}
v16 = 0LL;
v0 = getRandomUnsignedLong(&v16);
if ( v0 )
{
v0 = 0;
if ( v16 )
{
v10 = getLeastCoveringMask(0LL);
if ( !v10
&& getLeastCoveringMask(1uLL) == 1
&& getLeastCoveringMask(2uLL) == 3
&& getLeastCoveringMask(3uLL) == 3
&& getLeastCoveringMask(4uLL) == 7
&& getLeastCoveringMask(5uLL) == 7
&& getLeastCoveringMask(6uLL) == 7
&& getLeastCoveringMask(7uLL) == 7
&& getLeastCoveringMask(8uLL) == 15
&& getLeastCoveringMask(0xFFuLL) == 255
&& getLeastCoveringMask(0xFFFFFFFFFFFFFFFFLL) == -1LL
&& getLeastCoveringMask(0xFFFFFFFFFFFFFFFELL) == -1LL )
{
getPassword((__int64)"AB", 2uLL, (__int64)v13, 0x80uLL);
v4 = 0LL;
v6 = 0;
v3 = 0;
do
{
v5 = v13[v4];
if ( v5 == 65 )
{
++v3;
}
else
{
if ( v5 != 66 )
return 0;
++v6;
}
++v4;
}
while ( v4 != 128 );
if ( v3 && v6 )
{
v13[0] = -1;
v14 = -1;
v15 = -1;
memset_s(v13, 0LL, 128LL);
v0 = 0;
if ( !(v15 | (unsigned __int8)(v14 | v13[0]))
&& (unsigned int)ct_eq_u32(0LL, 0LL) == 1
&& (unsigned int)ct_eq_u32(5LL, 5LL) == 1
&& (unsigned int)ct_eq_u32(0x80000000LL, 0x80000000LL) == 1 )
{
v0 = ct_eq_u32(0LL, 1LL);
if ( v0 )
{
v0 = 0;
}
else if ( !(unsigned int)ct_eq_u32(1LL, 0LL) )
{
v0 = ct_eq_u32(2LL, 0LL);
if ( v0 )
{
v0 = 0;
}
else if ( !(unsigned int)ct_eq_u32(3LL, 0LL) )
{
v0 = 0;
if ( !(unsigned int)ct_eq_u32(1LL, 2LL) )
{
v0 = ct_eq_u32(0x80000000LL, 0LL);
if ( v0 )
{
v0 = 0;
}
else
{
v7 = ct_eq_u32(1LL, 1LL);
if ( (unsigned int)ct_mask_u32(v7) == -1 )
{
v8 = ct_eq_u32(1LL, 0LL);
if ( !(unsigned int)ct_mask_u32(v8) )
{
while ( 1 )
{
v9 = byte_F20[v10];
if ( v9 != (unsigned __int8)invariant_time_lookup(byte_F20, 94LL, (unsigned int)v10) )
break;
if ( ++v10 == 94 )
{
ct_string_init(v12);
ct_string_concat(v12, "ABCDEF", 6LL, 3LL);
ct_string_concat(v12, "GHIJKL", 6LL, 3LL);
ct_string_concat(v12, "12345", 5LL, 5LL);
if ( (unsigned int)ct_string_allocated_length(v12) == 17 )
{
ct_string_finalize(v12, v11, 90LL);
if ( !memcmp(v11, "ABCGHI12345ZZZZZZ", 0x11uLL) )
{
ct_string_deinit(v12);
v0 = 1;
}
}
return v0;
}
}
}
}
}
}
}
}
}
}
else
{
v0 = 0;
}
}
}
}
}
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
unsigned int v0; // ebx
char *v1; // rax
int v3; // ecx
__int64 v4; // rax
char v5; // si
int v6; // edx
unsigned int v7; // eax
unsigned int v8; // eax
int v9; // er12
unsigned __int64 v10; // rbp
_BYTE v11[32]; // [rsp+0h] [rbp-F8h] BYREF
char v12[16]; // [rsp+20h] [rbp-D8h] BYREF
char v13[3]; // [rsp+30h] [rbp-C8h] BYREF
char v14; // [rsp+33h] [rbp-C5h]
unsigned __int8 v15; // [rsp+AFh] [rbp-49h]
__int64 v16; // [rsp+B8h] [rbp-40h] BYREF
char ptr[16]; // [rsp+C0h] [rbp-38h] BYREF
char v18; // [rsp+D0h] [rbp-28h] BYREF

memset_s(ptr, 0LL, 16LL);
v0 = func3(ptr, 0x10uLL);
if ( v0 )
{
v1 = ptr;
while ( !*v1 )
{
if ( ++v1 == &v18 )
return 0;
}
v16 = 0LL;
v0 = func5(&v16);
if ( v0 )
{
v0 = 0;
if ( v16 )
{
v10 = func2(0LL);
if ( !v10
&& func2(1uLL) == 1
&& func2(2uLL) == 3
&& func2(3uLL) == 3
&& func2(4uLL) == 7
&& func2(5uLL) == 7
&& func2(6uLL) == 7
&& func2(7uLL) == 7
&& func2(8uLL) == 15
&& func2(0xFFuLL) == 255
&& func2(0xFFFFFFFFFFFFFFFFLL) == -1LL
&& func2(0xFFFFFFFFFFFFFFFELL) == -1LL )
{
func4((__int64)"AB", 2uLL, (__int64)v13, 0x80uLL);
v4 = 0LL;
v6 = 0;
v3 = 0;
do
{
v5 = v13[v4];
if ( v5 == 65 )
{
++v3;
}
else
{
if ( v5 != 66 )
return 0;
++v6;
}
++v4;
}
while ( v4 != 128 );
if ( v3 && v6 )
{
v13[0] = -1;
v14 = -1;
v15 = -1;
memset_s(v13, 0LL, 128LL);
v0 = 0;
if ( !(v15 | (unsigned __int8)(v14 | v13[0]))
&& (unsigned int)ct_eq_u32(0LL, 0LL) == 1
&& (unsigned int)ct_eq_u32(5LL, 5LL) == 1
&& (unsigned int)ct_eq_u32(0x80000000LL, 0x80000000LL) == 1 )
{
v0 = ct_eq_u32(0LL, 1LL);
if ( v0 )
{
v0 = 0;
}
else if ( !(unsigned int)ct_eq_u32(1LL, 0LL) )
{
v0 = ct_eq_u32(2LL, 0LL);
if ( v0 )
{
v0 = 0;
}
else if ( !(unsigned int)ct_eq_u32(3LL, 0LL) )
{
v0 = 0;
if ( !(unsigned int)ct_eq_u32(1LL, 2LL) )
{
v0 = ct_eq_u32(0x80000000LL, 0LL);
if ( v0 )
{
v0 = 0;
}
else
{
v7 = ct_eq_u32(1LL, 1LL);
if ( (unsigned int)ct_mask_u32(v7) == -1 )
{
v8 = ct_eq_u32(1LL, 0LL);
if ( !(unsigned int)ct_mask_u32(v8) )
{
while ( 1 )
{
v9 = byte_F20[v10];
if ( v9 != (unsigned __int8)invariant_time_lookup(byte_F20, 94LL, (unsigned int)v10) )
break;
if ( ++v10 == 94 )
{
ct_string_init(v12);
ct_string_concat(v12, "ABCDEF", 6LL, 3LL);
ct_string_concat(v12, "GHIJKL", 6LL, 3LL);
ct_string_concat(v12, "12345", 5LL, 5LL);
if ( (unsigned int)ct_string_allocated_length(v12) == 17 )
{
ct_string_finalize(v12, v11, 90LL);
if ( !memcmp(v11, "ABCGHI12345ZZZZZZ", 0x11uLL) )
{
ct_string_deinit(v12);
v0 = 1;
}
}
return v0;
}
}
}
}
}
}
}
}
}
}
else
{
v0 = 0;
}
}
}
}
}
return v0;
}

original_code:
int runtimeTests(void)
{
    unsigned char buffer[16];
    memset_s(buffer, 0, sizeof(buffer));
    if (!getRandom(buffer, sizeof(buffer))) {
        return 0;
    }
    int all_zero = 1;
    for (size_t i = 0; i < sizeof(buffer); i++) {
        if (buffer[i] != 0) {
            all_zero = 0;
            break;
        }
    }
    if (all_zero) {
        return 0;
    }
    unsigned long test = 0;
    if (!getRandomUnsignedLong(&test)) {
        return 0;
    }
    if (test == 0) {
        return 0;
    }
    if (getLeastCoveringMask(0) != 0) { return 0; }
    if (getLeastCoveringMask(1) != 1) { return 0; }
    if (getLeastCoveringMask(2) != 3) { return 0; }
    if (getLeastCoveringMask(3) != 3) { return 0; }
    if (getLeastCoveringMask(4) != 7) { return 0; }
    if (getLeastCoveringMask(5) != 7) { return 0; }
    if (getLeastCoveringMask(6) != 7) { return 0; }
    if (getLeastCoveringMask(7) != 7) { return 0; }
    if (getLeastCoveringMask(8) != 15) { return 0; }
    if (getLeastCoveringMask(255) != 255) { return 0; }
    if (getLeastCoveringMask((0x7fffffffffffffffL * 2UL + 1UL)) != (0x7fffffffffffffffL * 2UL + 1UL)) { return 0; }
    if (getLeastCoveringMask((0x7fffffffffffffffL * 2UL + 1UL) - 1) != (0x7fffffffffffffffL * 2UL + 1UL)) { return 0; }
    unsigned char buffer2[128];
    getPassword("AB", 2, buffer2, sizeof(buffer2));
    unsigned int a_count = 0, b_count = 0;
    for (size_t i = 0; i < sizeof(buffer2); i++) {
        if (buffer2[i] == 'A') { a_count++; }
        else if (buffer2[i] == 'B') { b_count++; }
        else { return 0; }
    }
    if (a_count == 0 || b_count == 0) {
        return 0;
    }
    buffer2[0] = -1;
    buffer2[3] = -1;
    buffer2[127] = -1;
    memset_s(buffer2, 0, sizeof(buffer2));
    if (buffer2[0] != 0 || buffer2[3] != 0 || buffer2[127] != 0) {
        return 0;
    }
    if (ct_eq_u32(0, 0) != 1) { return 0; }
    if (ct_eq_u32(5, 5) != 1) { return 0; }
    if (ct_eq_u32(0x80000000u, 0x80000000u) != 1) { return 0; }
    if (ct_eq_u32(0, 1) != 0) { return 0; }
    if (ct_eq_u32(1, 0) != 0) { return 0; }
    if (ct_eq_u32(2, 0) != 0) { return 0; }
    if (ct_eq_u32(3, 0) != 0) { return 0; }
    if (ct_eq_u32(1, 2) != 0) { return 0; }
    if (ct_eq_u32(0x80000000u, 0) != 0) { return 0; }
    if (ct_mask_u32(ct_eq_u32(1, 1)) != (4294967295U)) { return 0; }
    if (ct_mask_u32(ct_eq_u32(1, 0)) != 0) { return 0; }
    const char *set = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    for (size_t i = 0; i < strlen(set); i++) {
        if (set[i] != invariant_time_lookup((const unsigned char*)set, strlen(set), i)) {
            return 0;
        }
    }
    ct_string str;
    ct_string_init(&str);
    ct_string_concat(&str, (const unsigned char *)"ABCDEF", 6, 3);
    ct_string_concat(&str, (const unsigned char *)"GHIJKL", 6, 3);
    ct_string_concat(&str, (const unsigned char *)"12345", 5, 5);
    if (ct_string_allocated_length(&str) != 17) { return 0; }
    unsigned char str_result[17];
    ct_string_finalize(&str, str_result, 'Z');
    if (memcmp(str_result, "ABCGHI12345ZZZZZZ", 17) != 0) {
        return 0;
    }
    ct_string_deinit(&str);
    return 1;
}

canonical_original_code:
int runtimeTests()
{
    unsigned char buffer[16];
    memset_s(buffer, 0, sizeof(buffer));
    if (!getRandom(buffer, sizeof(buffer))) {
        return 0;
    }
    int all_zero = 1;
    for (unsigned long i = 0; i < sizeof(buffer); i++) {
        if (buffer[i] != 0) {
            all_zero = 0;
            break;
        }
    }
    if (all_zero) {
        return 0;
    }
    unsigned long test = 0;
    if (!getRandomUnsignedLong(&test)) {
        return 0;
    }
    if (test == 0) {
        return 0;
    }
    if (getLeastCoveringMask(0) != 0) { return 0; }
    if (getLeastCoveringMask(1) != 1) { return 0; }
    if (getLeastCoveringMask(2) != 3) { return 0; }
    if (getLeastCoveringMask(3) != 3) { return 0; }
    if (getLeastCoveringMask(4) != 7) { return 0; }
    if (getLeastCoveringMask(5) != 7) { return 0; }
    if (getLeastCoveringMask(6) != 7) { return 0; }
    if (getLeastCoveringMask(7) != 7) { return 0; }
    if (getLeastCoveringMask(8) != 15) { return 0; }
    if (getLeastCoveringMask(255) != 255) { return 0; }
    if (getLeastCoveringMask((0x7fffffffffffffffL * 2UL + 1UL)) != (0x7fffffffffffffffL * 2UL + 1UL)) { return 0; }
    if (getLeastCoveringMask((0x7fffffffffffffffL * 2UL + 1UL) - 1) != (0x7fffffffffffffffL * 2UL + 1UL)) { return 0; }
    unsigned char buffer2[128];
    getPassword("AB", 2, buffer2, sizeof(buffer2));
    unsigned int a_count = 0; unsigned int b_count = 0;
    for (unsigned long i = 0; i < sizeof(buffer2); i++) {
        if (buffer2[i] == 'A') { a_count++; }
        else if (buffer2[i] == 'B') { b_count++; }
        else { return 0; }
    }
    if (a_count == 0 || b_count == 0) {
        return 0;
    }
    buffer2[0] = -1;
    buffer2[3] = -1;
    buffer2[127] = -1;
    memset_s(buffer2, 0, sizeof(buffer2));
    if (buffer2[0] != 0 || buffer2[3] != 0 || buffer2[127] != 0) {
        return 0;
    }
    if (ct_eq_u32(0, 0) != 1) { return 0; }
    if (ct_eq_u32(5, 5) != 1) { return 0; }
    if (ct_eq_u32(0x80000000u, 0x80000000u) != 1) { return 0; }
    if (ct_eq_u32(0, 1) != 0) { return 0; }
    if (ct_eq_u32(1, 0) != 0) { return 0; }
    if (ct_eq_u32(2, 0) != 0) { return 0; }
    if (ct_eq_u32(3, 0) != 0) { return 0; }
    if (ct_eq_u32(1, 2) != 0) { return 0; }
    if (ct_eq_u32(0x80000000u, 0) != 0) { return 0; }
    if (ct_mask_u32(ct_eq_u32(1, 1)) != (4294967295U)) { return 0; }
    if (ct_mask_u32(ct_eq_u32(1, 0)) != 0) { return 0; }
    char *set = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
    for (unsigned long i = 0; i < strlen(set); i++) {
        if (set[i] != invariant_time_lookup((unsigned char *)set, strlen(set), i)) {
            return 0;
        }
    }
    struct ConstantTimeString str;
    ct_string_init(&str);
    ct_string_concat(&str, (unsigned char *)"ABCDEF", 6, 3);
    ct_string_concat(&str, (unsigned char *)"GHIJKL", 6, 3);
    ct_string_concat(&str, (unsigned char *)"12345", 5, 5);
    if (ct_string_allocated_length(&str) != 17) { return 0; }
    unsigned char str_result[17];
    ct_string_finalize(&str, str_result, 'Z');
    if (memcmp(str_result, "ABCGHI12345ZZZZZZ", 17) != 0) {
        return 0;
    }
    ct_string_deinit(&str);
    return 1;
}

variable_types:
buffer
unsigned char [16]

variable_types:
test
unsigned long


main

canonical_name: main

repo: defuse/passgen

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r15
int v4; // er14
int v5; // ebx
int v6; // eax
int v8; // ebp
int i; // ebx
unsigned __int64 v10; // rax
int v11; // [rsp+8h] [rbp-90h]
int v12; // [rsp+Ch] [rbp-8Ch]
char ptr[76]; // [rsp+10h] [rbp-88h] BYREF
int v14; // [rsp+5Ch] [rbp-3Ch] BYREF

v14 = 1;
v4 = 0;
v5 = 0;
v12 = 0;
v11 = 0;
while ( 1 )
{
v6 = getopt_long(argc, (char *const *)argv, "hzxndlwap:", &long_options, 0LL);
if ( v6 == -1 )
break;
switch ( v6 )
{
case 'a':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = byte_F20;
continue;
case 'd':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "0123456789";
continue;
case 'h':
showHelp();
return 0;
case 'l':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "abcdefghijklmnopqrstuvwxyz";
continue;
case 'n':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
continue;
case 'p':
if ( v4 )
goto LABEL_27;
v4 = _isoc99_sscanf(optarg, "%10d", &v14);
if ( v4 != 1 )
goto LABEL_38;
if ( v14 > 0 )
continue;
LABEL_27:
showHelp();
return v4;
case 'w':
if ( v5 )
goto LABEL_23;
v5 = 1;
v11 = 1;
continue;
case 'x':
if ( v5 )
{
LABEL_23:
showHelp();
return v5;
}
v5 = 1;
v3 = "0123456789ABCDEF";
break;
case 'z':
v12 = 1;
continue;
default:
goto LABEL_38;
}
}
if ( v5 )
{
if ( v12 || (unsigned int)runtimeTests() )
{
v8 = v11;
if ( v11 )
{
for ( i = 0; v14 > i; ++i )
{
if ( !(unsigned int)showRandomWords() )
{
fwrite("Error getting random data.\n", 1uLL, 0x1BuLL, stderr);
return v11;
}
}
v5 = 0;
}
else
{
while ( v14 > v8 )
{
v10 = strlen(v3);
if ( !getPassword((__int64)v3, v10, (__int64)ptr, 0x40uLL) )
{
memset_s(ptr, 0LL, 64LL);
fwrite("Error getting random data or allocating memory.\n", 1uLL, 0x30uLL, stderr);
return v5;
}
fwrite(ptr, 1uLL, 0x40uLL, stdout);
putchar(10);
memset_s(ptr, 0LL, 64LL);
++v8;
}
v5 = v11;
}
}
else
{
fwrite("ERROR: Runtime self-tests failed. SOMETHING IS WRONG\n", 1uLL, 0x35uLL, stderr);
}
}
else
{
LABEL_38:
showHelp();
v5 = 1;
}
return v5;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r15
int v4; // er14
int v5; // ebx
int v6; // eax
int v8; // ebp
int i; // ebx
unsigned __int64 v10; // rax
int v11; // [rsp+8h] [rbp-90h]
int v12; // [rsp+Ch] [rbp-8Ch]
char ptr[76]; // [rsp+10h] [rbp-88h] BYREF
int v14; // [rsp+5Ch] [rbp-3Ch] BYREF

v14 = 1;
v4 = 0;
v5 = 0;
v12 = 0;
v11 = 0;
while ( 1 )
{
v6 = getopt_long(argc, (char *const *)argv, "hzxndlwap:", &long_options, 0LL);
if ( v6 == -1 )
break;
switch ( v6 )
{
case 'a':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = byte_F20;
continue;
case 'd':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "0123456789";
continue;
case 'h':
func0();
return 0;
case 'l':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "abcdefghijklmnopqrstuvwxyz";
continue;
case 'n':
if ( v5 )
goto LABEL_23;
v5 = 1;
v3 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
continue;
case 'p':
if ( v4 )
goto LABEL_27;
v4 = _isoc99_sscanf(optarg, "%10d", &v14);
if ( v4 != 1 )
goto LABEL_38;
if ( v14 > 0 )
continue;
LABEL_27:
func0();
return v4;
case 'w':
if ( v5 )
goto LABEL_23;
v5 = 1;
v11 = 1;
continue;
case 'x':
if ( v5 )
{
LABEL_23:
func0();
return v5;
}
v5 = 1;
v3 = "0123456789ABCDEF";
break;
case 'z':
v12 = 1;
continue;
default:
goto LABEL_38;
}
}
if ( v5 )
{
if ( v12 || (unsigned int)func7() )
{
v8 = v11;
if ( v11 )
{
for ( i = 0; v14 > i; ++i )
{
if ( !(unsigned int)func6() )
{
fwrite("Error getting random data.\n", 1uLL, 0x1BuLL, stderr);
return v11;
}
}
v5 = 0;
}
else
{
while ( v14 > v8 )
{
v10 = strlen(v3);
if ( !func4((__int64)v3, v10, (__int64)ptr, 0x40uLL) )
{
memset_s(ptr, 0LL, 64LL);
fwrite("Error getting random data or allocating memory.\n", 1uLL, 0x30uLL, stderr);
return v5;
}
fwrite(ptr, 1uLL, 0x40uLL, stdout);
putchar(10);
memset_s(ptr, 0LL, 64LL);
++v8;
}
v5 = v11;
}
}
else
{
fwrite("ERROR: Runtime self-tests failed. SOMETHING IS WRONG\n", 1uLL, 0x35uLL, stderr);
}
}
else
{
LABEL_38:
func0();
v5 = 1;
}
return v5;
}

original_code:
int main(int argc, char* argv[])
{
    const char *set;
    int numberOfPasswords = 1;
    int generateWordPassword = 0;
    int skipSelfTest = 0;
    int optionCharacter = 0;
    int isPasswordTypeSet = 0;
    int isPasswordCountSet = 0;
    while((optionCharacter = getopt_long(argc, argv, "hzxndlwap:", long_options, ((void *)0))) != -1) {
            switch(optionCharacter)
            {
                case 'h':
                    showHelp();
                    return 0;
                case 'x':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "0123456789ABCDEF";
                    isPasswordTypeSet = 1;
                    break;
                case 'n':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                    isPasswordTypeSet = 1;
                    break;
                case 'a':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
                    isPasswordTypeSet = 1;
                    break;
                case 'd':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "0123456789";
                    isPasswordTypeSet = 1;
                    break;
                case 'l':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "abcdefghijklmnopqrstuvwxyz";
                    isPasswordTypeSet = 1;
                    break;
                case 'w':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    generateWordPassword = 1;
                    isPasswordTypeSet = 1;
                    break;
                case 'p':
                    if (isPasswordCountSet) {
                        showHelp();
                        return 1;
                    }
                    if(sscanf(optarg, "%10d", &numberOfPasswords) == 1) {
                        if (numberOfPasswords <= 0) {
                            showHelp();
                            return 1;
                        }
                        isPasswordCountSet = 1;
                    } else {
                        showHelp();
                        return 1;
                    }
                    break;
                case 'z':
                    skipSelfTest = 1;
                    break;
                default:
                    showHelp();
                    return 1;
            }
    }
    if(!isPasswordTypeSet) {
        showHelp();
        return 1;
    }
    if (!skipSelfTest && !runtimeTests()) {
        fprintf(stderr, "ERROR: Runtime self-tests failed. SOMETHING IS WRONG\n");
        return 1;
    }
    if (generateWordPassword) {
        for (int i = 0; i < numberOfPasswords; i++) {
            if (!showRandomWords()) {
                fprintf(stderr, "Error getting random data.\n");
                return 1;
            }
        }
    } else {
        unsigned char result[64];
        for(int i = 0; i < numberOfPasswords; i++) {
            if(getPassword(set, strlen(set), result, 64)) {
                fwrite(result, sizeof(unsigned char), 64, stdout);
                printf("\n");
            } else {
                memset_s(result, 0, 64);
                fprintf(stderr, "Error getting random data or allocating memory.\n");
                return 1;
            }
            memset_s(result, 0, 64);
        }
    }
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    char *set;
    int numberOfPasswords = 1;
    int generateWordPassword = 0;
    int skipSelfTest = 0;
    int optionCharacter = 0;
    int isPasswordTypeSet = 0;
    int isPasswordCountSet = 0;
    while((optionCharacter = getopt_long(argc, argv, "hzxndlwap:", long_options, ((void *)0))) != -1) {
            switch(optionCharacter)
            {
                case 'h':
                    showHelp();
                    return 0;
                case 'x':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "0123456789ABCDEF";
                    isPasswordTypeSet = 1;
                    break;
                case 'n':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                    isPasswordTypeSet = 1;
                    break;
                case 'a':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
                    isPasswordTypeSet = 1;
                    break;
                case 'd':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "0123456789";
                    isPasswordTypeSet = 1;
                    break;
                case 'l':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    set = "abcdefghijklmnopqrstuvwxyz";
                    isPasswordTypeSet = 1;
                    break;
                case 'w':
                    if (isPasswordTypeSet) {
                        showHelp();
                        return 1;
                    }
                    generateWordPassword = 1;
                    isPasswordTypeSet = 1;
                    break;
                case 'p':
                    if (isPasswordCountSet) {
                        showHelp();
                        return 1;
                    }
                    if(sscanf(optarg, "%10d", &numberOfPasswords) == 1) {
                        if (numberOfPasswords <= 0) {
                            showHelp();
                            return 1;
                        }
                        isPasswordCountSet = 1;
                    } else {
                        showHelp();
                        return 1;
                    }
                    break;
                case 'z':
                    skipSelfTest = 1;
                    break;
                default:
                    showHelp();
                    return 1;
            }
    }
    if(!isPasswordTypeSet) {
        showHelp();
        return 1;
    }
    if (!skipSelfTest && !runtimeTests()) {
        fprintf(stderr, "ERROR: Runtime self-tests failed. SOMETHING IS WRONG\n");
        return 1;
    }
    if (generateWordPassword) {
        for (int i = 0; i < numberOfPasswords; i++) {
            if (!showRandomWords()) {
                fprintf(stderr, "Error getting random data.\n");
                return 1;
            }
        }
    } else {
        unsigned char result[64];
        for(int i = 0; i < numberOfPasswords; i++) {
            if(getPassword(set, strlen(set), result, 64)) {
                fwrite(result, sizeof(unsigned char), 64, stdout);
                printf("\n");
            } else {
                memset_s(result, 0, 64);
                fprintf(stderr, "Error getting random data or allocating memory.\n");
                return 1;
            }
            memset_s(result, 0, 64);
        }
    }
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
set
char *

variable_types: numberOfPasswords int

variable_types: generateWordPassword int

variable_types: skipSelfTest int

variable_types: optionCharacter int

variable_types: isPasswordTypeSet int

variable_types: isPasswordCountSet int

variable_types: i int

variable_types:
result
unsigned char [64]

return_type: int


human

repo: delan/guardbuffer

decompiled_code:
char *__fastcall human(unsigned __int64 a1)
{
unsigned __int64 v1; // rdx
int v2; // ecx
unsigned __int64 v3; // rsi

v1 = a1;
if ( a1 <= 0x3E7 )
{
v2 = 0;
}
else
{
v2 = 0;
do
{
v3 = v1;
v1 /= 0x3E8uLL;
++v2;
}
while ( v3 > 0xF423F );
}
snprintf(out_3, 7uLL, "%llu %cB", v1, (unsigned int)byte_402004[v2]);
return out_3;
}

canonical_decompiled_code:
char *__fastcall func7(unsigned __int64 a1)
{
unsigned __int64 v1; // rdx
int v2; // ecx
unsigned __int64 v3; // rsi

v1 = a1;
if ( a1 <= 0x3E7 )
{
v2 = 0;
}
else
{
v2 = 0;
do
{
v3 = v1;
v1 /= 0x3E8uLL;
++v2;
}
while ( v3 > 0xF423F );
}
snprintf(out_3, 7uLL, "%llu %cB", v1, (unsigned int)byte_402004[v2]);
return out_3;
}

original_code:
char *human(uint64_t bytes) {
 static const char *prefix = " kMGTPEZY";
 static char out[] = "999 YB";
 int i = 0;
 while (bytes >= 1000) {
  bytes /= 1000;
  i++;
 }
 snprintf(out, sizeof(out), "%" "ll" "u %cB",
  bytes, prefix[i]);
 return out;
}

canonical_original_code:
char *human(unsigned long bytes) {
 static char *prefix = " kMGTPEZY";
 static char out[] = "999 YB";
 int i = 0;
 while (bytes >= 1000) {
  bytes /= 1000;
  i++;
 }
 snprintf(out, sizeof(out), "%" "ll" "u %cB",
  bytes, prefix[i]);
 return out;
}

variable_types:
bytes
unsigned long

variable_types:
prefix
char *

variable_types:
out
char []

return_type: char *


progress

decompiled_code:
time_t progress()
{
time_t result; // rax
__int64 v1; // rbx
char *v2; // rax
char *v3; // rax

result = time(0LL);
v1 = result;
if ( (int)last_time_2 < (int)result )
{
v2 = human(bytes);
fprintf(stderr, "\r%jd s: %s @ ", ++elapsed_1, v2);
v3 = human(bytes - last_bytes_0);
fprintf(stderr, "%s/s ", v3);
result = bytes;
last_bytes_0 = bytes;
}
last_time_2 = v1;
return result;
}

canonical_decompiled_code:
time_t func8()
{
time_t result; // rax
__int64 v1; // rbx
char *v2; // rax
char *v3; // rax

result = time(0LL);
v1 = result;
if ( (int)last_time_2 < (int)result )
{
v2 = func7(bytes);
fprintf(stderr, "\r%jd s: %s @ ", ++elapsed_1, v2);
v3 = func7(bytes - last_bytes_0);
fprintf(stderr, "%s/s ", v3);
result = bytes;
last_bytes_0 = bytes;
}
last_time_2 = v1;
return result;
}

original_code:
void progress(void) {
 static time_t last_time;
 static intmax_t last_bytes;
 static intmax_t elapsed;
 time_t now = time(((void *)0));
 if ((int) now > (int) last_time) {
  fprintf(stderr, "\r%jd s: %s @ ", ++elapsed, human(bytes));
  fprintf(stderr, "%s/s    ", human(bytes - last_bytes));
  last_bytes = bytes;
 }
 last_time = now;
}

canonical_original_code:
void progress() {
 static long last_time;
 static long last_bytes;
 static long elapsed;
 long now = time(((void *)0));
 if ((int) now > (int) last_time) {
  fprintf(stderr, "\r%jd s: %s @ ", ++elapsed, human(bytes));
  fprintf(stderr, "%s/s    ", human(bytes - last_bytes));
  last_bytes = bytes;
 }
 last_time = now;
}

variable_types: elapsed long

variable_types: now long

return_type: void


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
fputc(10, stderr);
while ( !feof(stdin) )
{
used += fread((void *)(used + 4210912), 1uLL, 0x10000 - used, stdin);
if ( used == 0x10000 )
{
fwrite(&buffer, 0x10000uLL, 1uLL, stdout);
bytes += used;
used = 0LL;
++blocks;
}
progress();
}
if ( used )
{
fwrite(&buffer, 1uLL, used, stdout);
bytes += used;
progress();
}
fflush(stdout);
fprintf(stderr, "\n%jd = %jd x %zu + %zu", bytes, blocks, 0x10000uLL, used);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
fputc(10, stderr);
while ( !feof(stdin) )
{
used += fread((void *)(used + 4210912), 1uLL, 0x10000 - used, stdin);
if ( used == 0x10000 )
{
fwrite(&buffer, 0x10000uLL, 1uLL, stdout);
bytes += used;
used = 0LL;
++blocks;
}
func8();
}
if ( used )
{
fwrite(&buffer, 1uLL, used, stdout);
bytes += used;
func8();
}
fflush(stdout);
fprintf(stderr, "\n%jd = %jd x %zu + %zu", bytes, blocks, 0x10000uLL, used);
return 0;
}

original_code:
int main(void) {
 fprintf(stderr, "\n");
 while (!feof(stdin)) {
  used += fread(buffer + used, 1, ((size_t) 65536) - used, stdin);
  if (used == ((size_t) 65536)) {
   fwrite(buffer, ((size_t) 65536), 1, stdout);
   bytes += used;
   used = 0;
   blocks++;
  }
  progress();
 }
 if (used) {
  fwrite(buffer, 1, used, stdout);
  bytes += used;
  progress();
 }
 fflush(stdout);
 fprintf(stderr, "\n%jd = %jd x %zu + %zu",
  bytes, blocks, ((size_t) 65536), used);
 return 0;
}

canonical_original_code:
int main() {
 fprintf(stderr, "\n");
 while (!feof(stdin)) {
  used += fread(buffer + used, 1, ((unsigned long) 65536) - used, stdin);
  if (used == ((unsigned long) 65536)) {
   fwrite(buffer, ((unsigned long) 65536), 1, stdout);
   bytes += used;
   used = 0;
   blocks++;
  }
  progress();
 }
 if (used) {
  fwrite(buffer, 1, used, stdout);
  bytes += used;
  progress();
 }
 fflush(stdout);
 fprintf(stderr, "\n%jd = %jd x %zu + %zu",
  bytes, blocks, ((unsigned long) 65536), used);
 return 0;
}


repo: delan/hdid

decompiled_code:
int __fastcall hdid_print(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, unsigned int a12)
{
printf("Manufacturer: %s\n", *((const char **)&hdid_man_list + (unsigned int)a7));
printf("Product family: %s\n", *((const char **)&hdid_family_list + a12));
printf("Spindle speed: %d rpm\n", HIDWORD(a7));
printf("Nominal capacity: %f GB\n", (float)((float)(int)a8 / 1000.0));
printf("Interface: %s\n", *((const char **)&hdid_interface_list + (unsigned int)a9));
printf("Form factor: %s\n", *((const char **)&hdid_form_list + HIDWORD(a9)));
printf("Sector size: %d B\n", (unsigned int)a10);
printf("Cache size: %ld MiB\n", a11 >> 20);
return printf("Platters: %d\n", HIDWORD(a10));
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, unsigned int a12)
{
printf("Manufacturer: %s\n", *((const char **)&hdid_man_list + (unsigned int)a7));
printf("Product family: %s\n", *((const char **)&hdid_family_list + a12));
printf("Spindle speed: %d rpm\n", HIDWORD(a7));
printf("Nominal capacity: %f GB\n", (float)((float)(int)a8 / 1000.0));
printf("Interface: %s\n", *((const char **)&hdid_interface_list + (unsigned int)a9));
printf("Form factor: %s\n", *((const char **)&hdid_form_list + HIDWORD(a9)));
printf("Sector size: %d B\n", (unsigned int)a10);
printf("Cache size: %ld MiB\n", a11 >> 20);
return printf("Platters: %d\n", HIDWORD(a10));
}

original_code:
void hdid_print(struct hdid_info info) {
 printf(
  "Manufacturer:           %s\n",
  hdid_man_list[info.manufacturer]
 );
 printf(
  "Product family:         %s\n",
  hdid_family_list[info.family]
 );
 printf(
  "Spindle speed:          %d rpm\n",
  info.spindle_rpm
 );
 printf(
  "Nominal capacity:       %f GB\n",
  (float) info.nominal_megabytes / 1000
 );
 printf(
  "Interface:              %s\n",
  hdid_interface_list[info.interface]
 );
 printf(
  "Form factor:            %s\n",
  hdid_form_list[info.form]
 );
 printf(
  "Sector size:            %d B\n",
  info.sector_bytes
 );
 printf(
  "Cache size:             %ld MiB\n",
  info.cache_bytes >> 20
 );
 printf(
  "Platters:               %d\n",
  info.platters
 );
}

variable_types: struct hdid_info { enum hdid_man_t { HDID_MAN_UNKNOWN=0, HDID_MAN_WD=1, HDID_MAN_SEAGATE=2, HDID_MAN_MAXTOR=3, HDID_MAN_SAMSUNG=4, HDID_MAN_HITACHI=5, HDID_MAN_TOSHIBA=6, HDID_MAN_CONNER=7, HDID_MAN_QUANTUM=8, HDID_MAN_IBM=9 } manufacturer; int spindle_rpm; long nominal_megabytes; enum hdid_interface_t { HDID_INTERFACE_UNKNOWN=0, HDID_INTERFACE_ATA33=1, HDID_INTERFACE_ATA66=2, HDID_INTERFACE_ATA100=3, HDID_INTERFACE_ATA133=4, HDID_INTERFACE_SATA1=5, HDID_INTERFACE_SATA2=6, HDID_INTERFACE_SATA3=7, HDID_INTERFACE_FIREWIRE=8, HDID_INTERFACE_CFPLUS2=9, HDID_INTERFACE_SAS10=10, HDID_INTERFACE_SAS11=11, HDID_INTERFACE_SAS20=12, HDID_INTERFACE_SAS30=13, HDID_INTERFACE_ZIF33=14 } interface; enum hdid_form_t { HDID_FORM_UNKNOWN=0, HDID_FORM_100=1, HDID_FORM_180=2, HDID_FORM_180_50=3, HDID_FORM_180_80=4, HDID_FORM_250=5, HDID_FORM_250_50=6, HDID_FORM_250_70=7, HDID_FORM_250_95=8, HDID_FORM_250_125=9, HDID_FORM_250_150=10, HDID_FORM_350=11, HDID_FORM_350_190=12, HDID_FORM_350_254=13, HDID_FORM_525=14, HDID_FORM_525_414=15, HDID_FORM_525_826=16, HDID_FORM_800=17, HDID_FORM_800_1175=18, HDID_FORM_CF_33=19, HDID_FORM_CF_50=20, HDID_FORM_250_350_INCORRECT=21, HDID_FORM_250_350_CORRECT=22 } form; int sector_bytes; int platters; long cache_bytes; enum hdid_family_t { HDID_FAMILY_UNKNOWN=0, HDID_FAMILY_WD_DESKTOP=1, HDID_FAMILY_WD_RE=2, HDID_FAMILY_WD_RAPTOR=3, HDID_FAMILY_WD_RAPTORX=4, HDID_FAMILY_WD_MOBILE=5, HDID_FAMILY_WD_NAS=6, HDID_FAMILY_WD_VR=7, HDID_FAMILY_WD_XE=8, HDID_FAMILY_WD_S25=9, HDID_FAMILY_WD_BRAND=10, HDID_FAMILY_WD_AV=11, HDID_FAMILY_WD_SERVER=12, HDID_FAMILY_WD_PROTEGE=13 } family; }

user_defined_types: struct hdid_info { enum hdid_man_t manufacturer; int spindle_rpm; long nominal_megabytes; enum hdid_interface_t interface; enum hdid_form_t form; int sector_bytes; int platters; long cache_bytes; enum hdid_family_t family; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // rcx
__int64 *v5; // rdi
_DWORD *v6; // rsi
__int64 v7; // [rsp-30h] [rbp-68h] BYREF
_BYTE v8[56]; // [rsp+0h] [rbp-38h] BYREF

if ( argc == 2 )
{
hdid_identify(v8, argv[1], envp);
v4 = 12LL;
v5 = &v7;
v6 = v8;
while ( v4 )
{
*(_DWORD *)v5 = *v6++;
v5 = (__int64 *)((char *)v5 + 4);
--v4;
}
hdid_print(v5, v6);
result = 0;
}
else
{
fprintf(stderr, "Usage: %s [HDD model]\n", *argv);
result = 1;
}
return result;
}

original_code:
int main(int argc, char **argv) {
 if (argc != 2) {
  fprintf(stderr, "Usage: %s [HDD model]\n", argv[0]);
  return 1;
 }
 hdid_print(hdid_identify(argv[1]));
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


original_code:
void hdid_wd_2005_oem_internal(struct hdid_info *info, const char *model) {
 const char *suffix = hdid_wd_suffix(model);
 info->nominal_megabytes = atoi(model + 2) * 100;
 info->sector_bytes = 512;
 switch (suffix[0]) {
 case 'A':
  info->spindle_rpm = 5400;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 10000;
  break;
 case 'D':
  info->spindle_rpm = 4500;
  break;
 case 'E':
  info->spindle_rpm = 5400;
  info->platters = 1;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 2097152;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 4194304;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  info->family = HDID_FAMILY_WD_DESKTOP;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  break;
 case 'M':
  info->spindle_rpm = 5400;
  break;
 case 'N':
  info->spindle_rpm = 5400;
  info->family = HDID_FAMILY_WD_PROTEGE;
  break;
 case 'P':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'R':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'S':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'T':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'U':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'W':
  info->spindle_rpm = 3600;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'X':
  info->spindle_rpm = 4200;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'Z':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  info->form = HDID_FORM_350_254;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_FIREWIRE;
  info->form = HDID_FORM_350_254;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  info->form = HDID_FORM_350_254;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  info->form = HDID_FORM_350_254;
  break;
 case 'P':
  info->interface = HDID_INTERFACE_CFPLUS2;
  info->form = HDID_FORM_CF_50;
  break;
 case 'R':
 case 'S':
  info->interface = HDID_INTERFACE_SATA2;
  info->form = HDID_FORM_350_254;
  break;
 case 'W':
  info->form = HDID_FORM_350_254;
  break;
 }
}

canonical_original_code:
void hdid_wd_2005_oem_internal(struct hdid_info *info, char *model) {
 char *suffix = hdid_wd_suffix(model);
 info->nominal_megabytes = atoi(model + 2) * 100;
 info->sector_bytes = 512;
 switch (suffix[0]) {
 case 'A':
  info->spindle_rpm = 5400;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 10000;
  break;
 case 'D':
  info->spindle_rpm = 4500;
  break;
 case 'E':
  info->spindle_rpm = 5400;
  info->platters = 1;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 2097152;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 4194304;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  info->family = HDID_FAMILY_WD_DESKTOP;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  break;
 case 'M':
  info->spindle_rpm = 5400;
  break;
 case 'N':
  info->spindle_rpm = 5400;
  info->family = HDID_FAMILY_WD_PROTEGE;
  break;
 case 'P':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'R':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'S':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'T':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'U':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'W':
  info->spindle_rpm = 3600;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'X':
  info->spindle_rpm = 4200;
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  info->family = HDID_FAMILY_WD_SERVER;
  break;
 case 'Z':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  info->form = HDID_FORM_350_254;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_FIREWIRE;
  info->form = HDID_FORM_350_254;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  info->form = HDID_FORM_350_254;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  info->form = HDID_FORM_350_254;
  break;
 case 'P':
  info->interface = HDID_INTERFACE_CFPLUS2;
  info->form = HDID_FORM_CF_50;
  break;
 case 'R':
 case 'S':
  info->interface = HDID_INTERFACE_SATA2;
  info->form = HDID_FORM_350_254;
  break;
 case 'W':
  info->form = HDID_FORM_350_254;
  break;
 }
}

variable_types: struct hdid_info { enum hdid_man_t { HDID_MAN_UNKNOWN=0, HDID_MAN_WD=1, HDID_MAN_SEAGATE=2, HDID_MAN_MAXTOR=3, HDID_MAN_SAMSUNG=4, HDID_MAN_HITACHI=5, HDID_MAN_TOSHIBA=6, HDID_MAN_CONNER=7, HDID_MAN_QUANTUM=8, HDID_MAN_IBM=9 } manufacturer; int spindle_rpm; long nominal_megabytes; enum hdid_interface_t { HDID_INTERFACE_UNKNOWN=0, HDID_INTERFACE_ATA33=1, HDID_INTERFACE_ATA66=2, HDID_INTERFACE_ATA100=3, HDID_INTERFACE_ATA133=4, HDID_INTERFACE_SATA1=5, HDID_INTERFACE_SATA2=6, HDID_INTERFACE_SATA3=7, HDID_INTERFACE_FIREWIRE=8, HDID_INTERFACE_CFPLUS2=9, HDID_INTERFACE_SAS10=10, HDID_INTERFACE_SAS11=11, HDID_INTERFACE_SAS20=12, HDID_INTERFACE_SAS30=13, HDID_INTERFACE_ZIF33=14 } interface; enum hdid_form_t { HDID_FORM_UNKNOWN=0, HDID_FORM_100=1, HDID_FORM_180=2, HDID_FORM_180_50=3, HDID_FORM_180_80=4, HDID_FORM_250=5, HDID_FORM_250_50=6, HDID_FORM_250_70=7, HDID_FORM_250_95=8, HDID_FORM_250_125=9, HDID_FORM_250_150=10, HDID_FORM_350=11, HDID_FORM_350_190=12, HDID_FORM_350_254=13, HDID_FORM_525=14, HDID_FORM_525_414=15, HDID_FORM_525_826=16, HDID_FORM_800=17, HDID_FORM_800_1175=18, HDID_FORM_CF_33=19, HDID_FORM_CF_50=20, HDID_FORM_250_350_INCORRECT=21, HDID_FORM_250_350_CORRECT=22 } form; int sector_bytes; int platters; long cache_bytes; enum hdid_family_t { HDID_FAMILY_UNKNOWN=0, HDID_FAMILY_WD_DESKTOP=1, HDID_FAMILY_WD_RE=2, HDID_FAMILY_WD_RAPTOR=3, HDID_FAMILY_WD_RAPTORX=4, HDID_FAMILY_WD_MOBILE=5, HDID_FAMILY_WD_NAS=6, HDID_FAMILY_WD_VR=7, HDID_FAMILY_WD_XE=8, HDID_FAMILY_WD_S25=9, HDID_FAMILY_WD_BRAND=10, HDID_FAMILY_WD_AV=11, HDID_FAMILY_WD_SERVER=12, HDID_FAMILY_WD_PROTEGE=13 } family; } *

variable_types:
model
char *

variable_types:
suffix
char *


original_code:
void hdid_wd_new_oem_internal(struct hdid_info *info, const char *model) {
 int raw_capacity = atoi(model + 2);
 const char *suffix = hdid_wd_suffix(model);
 if (raw_capacity >= 1000)
  raw_capacity = raw_capacity / 10 * 10;
 switch (suffix[0]) {
 case 'A':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250;
  break;
 case 'C':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 case 'D':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'E':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_350_254;
  break;
 case 'F':
  info->nominal_megabytes = raw_capacity * 1000;
  info->form = HDID_FORM_350_254;
  break;
 case 'G':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_INCORRECT;
  break;
 case 'H':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'J':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 case 'K':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_125;
  break;
 case 'L':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_70;
  break;
 case 'N':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_150;
  break;
 case 'S':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_70;
  break;
 case 'T':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_125;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->family = HDID_FAMILY_WD_DESKTOP;
  info->sector_bytes = 512;
  break;
 case 'B':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 512;
  info->platters = 3;
  break;
 case 'D':
  info->family = HDID_FAMILY_WD_RAPTOR;
  info->sector_bytes = 512;
  break;
 case 'E':
  info->family = HDID_FAMILY_WD_MOBILE;
  info->sector_bytes = 512;
  break;
 case 'F':
  info->family = HDID_FAMILY_WD_NAS;
  info->sector_bytes = 4096;
  break;
 case 'H':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 512;
  break;
 case 'K':
  info->family = HDID_FAMILY_WD_XE;
  info->sector_bytes = 512;
  break;
 case 'L':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 512;
  break;
 case 'M':
  info->family = HDID_FAMILY_WD_BRAND;
  info->sector_bytes = 512;
  break;
 case 'N':
  info->family = HDID_FAMILY_WD_BRAND;
  info->sector_bytes = 4096;
  break;
 case 'P':
  info->family = HDID_FAMILY_WD_MOBILE;
  info->sector_bytes = 4096;
  break;
 case 'R':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 4096;
  break;
 case 'U':
  info->family = HDID_FAMILY_WD_AV;
  info->sector_bytes = 4096;
  break;
 case 'V':
  info->family = HDID_FAMILY_WD_AV;
  info->sector_bytes = 512;
  break;
 case 'W':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 4096;
  break;
 case 'Y':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 512;
  info->platters = 4;
  break;
 case 'Z':
  info->family = HDID_FAMILY_WD_DESKTOP;
  info->sector_bytes = 4096;
  break;
 }
 switch (suffix[2]) {
 case 'A':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 5400;
  info->cache_bytes = 16777216;
  break;
 case 'D':
  info->spindle_rpm = 5400;
  info->cache_bytes = 33554432;
  break;
 case 'E':
  info->spindle_rpm = 7200;
  info->cache_bytes = 67108864;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 16777216;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 33554432;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  info->cache_bytes = 33554432;
  break;
 case 'P':
  info->spindle_rpm = 5400;
  break;
 case 'R':
  info->spindle_rpm = 5400;
  info->cache_bytes = 67108864;
  break;
 case 'S':
  info->spindle_rpm = 7200;
  info->cache_bytes = 67108864;
  break;
 case 'T':
  info->spindle_rpm = 10000;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  break;
 }
 switch (suffix[3]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_ZIF33;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  break;
 case 'F':
  info->interface = HDID_INTERFACE_SAS11;
  break;
 case 'G':
  info->interface = HDID_INTERFACE_SAS20;
  break;
 case 'S':
  if (info->family == HDID_FAMILY_WD_MOBILE)
   info->interface = HDID_INTERFACE_SATA1;
  else
   info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'T':
  info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'X':
  info->interface = HDID_INTERFACE_SATA3;
  break;
 case 'Z':
  info->interface = HDID_INTERFACE_SATA3;
  break;
 }
}

canonical_original_code:
void hdid_wd_new_oem_internal(struct hdid_info *info, char *model) {
 int raw_capacity = atoi(model + 2);
 char *suffix = hdid_wd_suffix(model);
 if (raw_capacity >= 1000)
  raw_capacity = raw_capacity / 10 * 10;
 switch (suffix[0]) {
 case 'A':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250;
  break;
 case 'C':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 case 'D':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'E':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_350_254;
  break;
 case 'F':
  info->nominal_megabytes = raw_capacity * 1000;
  info->form = HDID_FORM_350_254;
  break;
 case 'G':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_INCORRECT;
  break;
 case 'H':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'J':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 case 'K':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_125;
  break;
 case 'L':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_70;
  break;
 case 'N':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_150;
  break;
 case 'S':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_70;
  break;
 case 'T':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250_125;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->family = HDID_FAMILY_WD_DESKTOP;
  info->sector_bytes = 512;
  break;
 case 'B':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 512;
  info->platters = 3;
  break;
 case 'D':
  info->family = HDID_FAMILY_WD_RAPTOR;
  info->sector_bytes = 512;
  break;
 case 'E':
  info->family = HDID_FAMILY_WD_MOBILE;
  info->sector_bytes = 512;
  break;
 case 'F':
  info->family = HDID_FAMILY_WD_NAS;
  info->sector_bytes = 4096;
  break;
 case 'H':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 512;
  break;
 case 'K':
  info->family = HDID_FAMILY_WD_XE;
  info->sector_bytes = 512;
  break;
 case 'L':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 512;
  break;
 case 'M':
  info->family = HDID_FAMILY_WD_BRAND;
  info->sector_bytes = 512;
  break;
 case 'N':
  info->family = HDID_FAMILY_WD_BRAND;
  info->sector_bytes = 4096;
  break;
 case 'P':
  info->family = HDID_FAMILY_WD_MOBILE;
  info->sector_bytes = 4096;
  break;
 case 'R':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 4096;
  break;
 case 'U':
  info->family = HDID_FAMILY_WD_AV;
  info->sector_bytes = 4096;
  break;
 case 'V':
  info->family = HDID_FAMILY_WD_AV;
  info->sector_bytes = 512;
  break;
 case 'W':
  info->family = HDID_FAMILY_WD_VR;
  info->sector_bytes = 4096;
  break;
 case 'Y':
  info->family = HDID_FAMILY_WD_RE;
  info->sector_bytes = 512;
  info->platters = 4;
  break;
 case 'Z':
  info->family = HDID_FAMILY_WD_DESKTOP;
  info->sector_bytes = 4096;
  break;
 }
 switch (suffix[2]) {
 case 'A':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 5400;
  info->cache_bytes = 16777216;
  break;
 case 'D':
  info->spindle_rpm = 5400;
  info->cache_bytes = 33554432;
  break;
 case 'E':
  info->spindle_rpm = 7200;
  info->cache_bytes = 67108864;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 16777216;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 33554432;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  info->cache_bytes = 33554432;
  break;
 case 'P':
  info->spindle_rpm = 5400;
  break;
 case 'R':
  info->spindle_rpm = 5400;
  info->cache_bytes = 67108864;
  break;
 case 'S':
  info->spindle_rpm = 7200;
  info->cache_bytes = 67108864;
  break;
 case 'T':
  info->spindle_rpm = 10000;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  break;
 }
 switch (suffix[3]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_ZIF33;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  break;
 case 'F':
  info->interface = HDID_INTERFACE_SAS11;
  break;
 case 'G':
  info->interface = HDID_INTERFACE_SAS20;
  break;
 case 'S':
  if (info->family == HDID_FAMILY_WD_MOBILE)
   info->interface = HDID_INTERFACE_SATA1;
  else
   info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'T':
  info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'X':
  info->interface = HDID_INTERFACE_SATA3;
  break;
 case 'Z':
  info->interface = HDID_INTERFACE_SATA3;
  break;
 }
}

user_defined_types: enum hdid_man_t { HDID_MAN_UNKNOWN=0, HDID_MAN_WD=1, HDID_MAN_SEAGATE=2, HDID_MAN_MAXTOR=3, HDID_MAN_SAMSUNG=4, HDID_MAN_HITACHI=5, HDID_MAN_TOSHIBA=6, HDID_MAN_CONNER=7, HDID_MAN_QUANTUM=8, HDID_MAN_IBM=9 }

user_defined_types: enum hdid_interface_t { HDID_INTERFACE_UNKNOWN=0, HDID_INTERFACE_ATA33=1, HDID_INTERFACE_ATA66=2, HDID_INTERFACE_ATA100=3, HDID_INTERFACE_ATA133=4, HDID_INTERFACE_SATA1=5, HDID_INTERFACE_SATA2=6, HDID_INTERFACE_SATA3=7, HDID_INTERFACE_FIREWIRE=8, HDID_INTERFACE_CFPLUS2=9, HDID_INTERFACE_SAS10=10, HDID_INTERFACE_SAS11=11, HDID_INTERFACE_SAS20=12, HDID_INTERFACE_SAS30=13, HDID_INTERFACE_ZIF33=14 }

user_defined_types: enum hdid_family_t { HDID_FAMILY_UNKNOWN=0, HDID_FAMILY_WD_DESKTOP=1, HDID_FAMILY_WD_RE=2, HDID_FAMILY_WD_RAPTOR=3, HDID_FAMILY_WD_RAPTORX=4, HDID_FAMILY_WD_MOBILE=5, HDID_FAMILY_WD_NAS=6, HDID_FAMILY_WD_VR=7, HDID_FAMILY_WD_XE=8, HDID_FAMILY_WD_S25=9, HDID_FAMILY_WD_BRAND=10, HDID_FAMILY_WD_AV=11, HDID_FAMILY_WD_SERVER=12, HDID_FAMILY_WD_PROTEGE=13 }


original_code:
void hdid_wd_2009_retail_internal(struct hdid_info *info, const char *model) {
 int raw_capacity = atoi(model + 2);
 const char *suffix = hdid_wd_suffix(model);
 if (raw_capacity >= 1000)
  raw_capacity = raw_capacity / 10 * 10;
 switch (suffix[0]) {
 case 'A':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250;
  break;
 case 'C':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_100;
  break;
 case 'E':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_350_254;
  break;
 case 'F':
  info->nominal_megabytes = raw_capacity * 1000;
  info->form = HDID_FORM_350_254;
  break;
 case 'G':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_INCORRECT;
  break;
 case 'H':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'J':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->family = HDID_FAMILY_WD_DESKTOP;
  break;
 case 'B':
  info->family = HDID_FAMILY_WD_RE;
  info->platters = 3;
  break;
 case 'C':
  info->family = HDID_FAMILY_WD_PROTEGE;
  break;
 case 'D':
  info->family = HDID_FAMILY_WD_RAPTOR;
  break;
 case 'E':
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'H':
  info->family = HDID_FAMILY_WD_RAPTORX;
  break;
 case 'J':
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'K':
  info->family = HDID_FAMILY_WD_S25;
  break;
 case 'L':
  info->family = HDID_FAMILY_WD_VR;
  break;
 case 'M':
  info->family = HDID_FAMILY_WD_BRAND;
  break;
 case 'V':
  info->family = HDID_FAMILY_WD_AV;
  break;
 case 'Y':
  info->family = HDID_FAMILY_WD_RE;
  info->platters = 4;
  break;
 }
 switch (suffix[2]) {
 case 'A':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 5400;
  info->cache_bytes = 16777216;
  break;
 case 'D':
  info->spindle_rpm = 5400;
  info->cache_bytes = 33554432;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 16777216;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 33554432;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  info->cache_bytes = 33554432;
  break;
 case 'P':
  info->spindle_rpm = 5400;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  break;
 }
 switch (suffix[3]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_ZIF33;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  break;
 case 'F':
  info->interface = HDID_INTERFACE_SAS11;
  break;
 case 'G':
  info->interface = HDID_INTERFACE_SAS20;
  break;
 case 'S':
  if (info->family == HDID_FAMILY_WD_MOBILE)
   info->interface = HDID_INTERFACE_SATA1;
  else
   info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'T':
  info->interface = HDID_INTERFACE_SATA2;
  break;
 }
}

canonical_original_code:
void hdid_wd_2009_retail_internal(struct hdid_info *info, char *model) {
 int raw_capacity = atoi(model + 2);
 char *suffix = hdid_wd_suffix(model);
 if (raw_capacity >= 1000)
  raw_capacity = raw_capacity / 10 * 10;
 switch (suffix[0]) {
 case 'A':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_350_254;
  break;
 case 'B':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250;
  break;
 case 'C':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_100;
  break;
 case 'E':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_350_254;
  break;
 case 'F':
  info->nominal_megabytes = raw_capacity * 1000;
  info->form = HDID_FORM_350_254;
  break;
 case 'G':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_INCORRECT;
  break;
 case 'H':
  info->nominal_megabytes = raw_capacity * 100;
  info->form = HDID_FORM_250_350_CORRECT;
  break;
 case 'J':
  info->nominal_megabytes = raw_capacity * 100000;
  info->form = HDID_FORM_250;
  break;
 }
 switch (suffix[1]) {
 case 'A':
  info->family = HDID_FAMILY_WD_DESKTOP;
  break;
 case 'B':
  info->family = HDID_FAMILY_WD_RE;
  info->platters = 3;
  break;
 case 'C':
  info->family = HDID_FAMILY_WD_PROTEGE;
  break;
 case 'D':
  info->family = HDID_FAMILY_WD_RAPTOR;
  break;
 case 'E':
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'H':
  info->family = HDID_FAMILY_WD_RAPTORX;
  break;
 case 'J':
  info->family = HDID_FAMILY_WD_MOBILE;
  break;
 case 'K':
  info->family = HDID_FAMILY_WD_S25;
  break;
 case 'L':
  info->family = HDID_FAMILY_WD_VR;
  break;
 case 'M':
  info->family = HDID_FAMILY_WD_BRAND;
  break;
 case 'V':
  info->family = HDID_FAMILY_WD_AV;
  break;
 case 'Y':
  info->family = HDID_FAMILY_WD_RE;
  info->platters = 4;
  break;
 }
 switch (suffix[2]) {
 case 'A':
  info->spindle_rpm = 5400;
  info->cache_bytes = 2097152;
  break;
 case 'B':
  info->spindle_rpm = 7200;
  info->cache_bytes = 2097152;
  break;
 case 'C':
  info->spindle_rpm = 5400;
  info->cache_bytes = 16777216;
  break;
 case 'D':
  info->spindle_rpm = 5400;
  info->cache_bytes = 33554432;
  break;
 case 'F':
  info->spindle_rpm = 10000;
  info->cache_bytes = 16777216;
  break;
 case 'G':
  info->spindle_rpm = 10000;
  info->cache_bytes = 8388608;
  break;
 case 'H':
  info->spindle_rpm = 10000;
  info->cache_bytes = 33554432;
  break;
 case 'J':
  info->spindle_rpm = 7200;
  info->cache_bytes = 8388608;
  break;
 case 'K':
  info->spindle_rpm = 7200;
  info->cache_bytes = 16777216;
  break;
 case 'L':
  info->spindle_rpm = 7200;
  info->cache_bytes = 33554432;
  break;
 case 'P':
  info->spindle_rpm = 5400;
  break;
 case 'V':
  info->spindle_rpm = 5400;
  info->cache_bytes = 8388608;
  break;
 case 'Y':
  info->spindle_rpm = 7200;
  break;
 }
 switch (suffix[3]) {
 case 'A':
  info->interface = HDID_INTERFACE_ATA66;
  break;
 case 'B':
  info->interface = HDID_INTERFACE_ATA100;
  break;
 case 'C':
  info->interface = HDID_INTERFACE_ZIF33;
  break;
 case 'D':
  info->interface = HDID_INTERFACE_SATA1;
  break;
 case 'E':
  info->interface = HDID_INTERFACE_ATA133;
  break;
 case 'F':
  info->interface = HDID_INTERFACE_SAS11;
  break;
 case 'G':
  info->interface = HDID_INTERFACE_SAS20;
  break;
 case 'S':
  if (info->family == HDID_FAMILY_WD_MOBILE)
   info->interface = HDID_INTERFACE_SATA1;
  else
   info->interface = HDID_INTERFACE_SATA2;
  break;
 case 'T':
  info->interface = HDID_INTERFACE_SATA2;
  break;
 }
}


decompiled_code:
size_t __fastcall hdid_identify_wd(_DWORD *a1, __int64 a2)
{
size_t result; // rax
const char *v3; // rax
bool v4; // cf

*a1 = 1;
result = (unsigned int)(*(char *)(a2 + 2) - 49);
if ( (unsigned int)result <= 8 )
{
v3 = hdid_wd_suffix(a2);
result = strlen(v3);
if ( result == 4 )
{
result = hdid_wd_new_oem_internal((__int64)a1, a2);
}
else if ( result > 4 )
{
v4 = result == 8;
result -= 8LL;
if ( v4 || result == 1 )
result = hdid_wd_2009_retail_internal((__int64)a1, a2);
}
else if ( result == 2 )
{
result = hdid_wd_2005_oem_internal((__int64)a1, a2);
}
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func3(_DWORD *a1, __int64 a2)
{
size_t result; // rax
const char *v3; // rax
bool v4; // cf

*a1 = 1;
result = (unsigned int)(*(char *)(a2 + 2) - 49);
if ( (unsigned int)result <= 8 )
{
v3 = hdid_wd_suffix(a2);
result = strlen(v3);
if ( result == 4 )
{
result = func1((__int64)a1, a2);
}
else if ( result > 4 )
{
v4 = result == 8;
result -= 8LL;
if ( v4 || result == 1 )
result = func2((__int64)a1, a2);
}
else if ( result == 2 )
{
result = func0((__int64)a1, a2);
}
}
return result;
}

original_code:
void hdid_identify_wd(struct hdid_info *info, const char *model) {
 const char *suffix;
 info->manufacturer = HDID_MAN_WD;
 switch (model[2]) {
 case '1':
 case '2':
 case '3':
 case '4':
 case '5':
 case '6':
 case '7':
 case '8':
 case '9':
  suffix = hdid_wd_suffix(model);
  switch (strlen(suffix)) {
  case 2:
   hdid_wd_2005_oem_internal(info, model);
   break;
  case 4:
   hdid_wd_new_oem_internal(info, model);
   break;
  case 8:
  case 9:
   hdid_wd_2009_retail_internal(info, model);
   break;
  }
 case 'A':
 case 'B':
 case 'C':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'M':
 case 'P':
 case 'Q':
 case 'S':
 case 'T':
 case 'U':
 case 'X':
  break;
 }
}

canonical_original_code:
void hdid_identify_wd(struct hdid_info *info, char *model) {
 char *suffix;
 info->manufacturer = HDID_MAN_WD;
 switch (model[2]) {
 case '1':
 case '2':
 case '3':
 case '4':
 case '5':
 case '6':
 case '7':
 case '8':
 case '9':
  suffix = hdid_wd_suffix(model);
  switch (strlen(suffix)) {
  case 2:
   hdid_wd_2005_oem_internal(info, model);
   break;
  case 4:
   hdid_wd_new_oem_internal(info, model);
   break;
  case 8:
  case 9:
   hdid_wd_2009_retail_internal(info, model);
   break;
  }
 case 'A':
 case 'B':
 case 'C':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'M':
 case 'P':
 case 'Q':
 case 'S':
 case 'T':
 case 'U':
 case 'X':
  break;
 }
}


decompiled_code:
char *__fastcall hdid_minstr(char *src, size_t a2)
{
size_t v2; // rbx
size_t v3; // rbp
char *v4; // rax

v2 = a2;
v3 = strlen(src);
if ( v3 >= a2 )
v2 = v3 + 1;
v4 = (char *)calloc(v2, 1uLL);
return strncpy(v4, src, v3);
}

canonical_decompiled_code:
char *__fastcall func0(char *src, size_t a2)
{
size_t v2; // rbx
size_t v3; // rbp
char *v4; // rax

v2 = a2;
v3 = strlen(src);
if ( v3 >= a2 )
v2 = v3 + 1;
v4 = (char *)calloc(v2, 1uLL);
return strncpy(v4, src, v3);
}

original_code:
char *hdid_minstr(const char *in, size_t min) {
 size_t len = strlen(in);
 char *out = calloc(
  len < min ? min : len + 1,
  sizeof(char)
 );
 strncpy(out, in, len);
 return out;
}

canonical_original_code:
char *hdid_minstr(char *in, unsigned long min) {
 unsigned long len = strlen(in);
 char *out = calloc(
  len < min ? min : len + 1,
  sizeof(char)
 );
 strncpy(out, in, len);
 return out;
}

variable_types:
in
char *

variable_types:
min
unsigned long

variable_types:
len
unsigned long

variable_types:
out
char *


repo: delan/ucpcal

decompiled_code:
void *ucpcal_event_new()
{
return calloc(0x30uLL, 1uLL);
}

canonical_decompiled_code:
void *func0()
{
return calloc(0x30uLL, 1uLL);
}

original_code:
ucpcal_event *ucpcal_event_new(void) {
 ucpcal_event *event = (ucpcal_event *) calloc(sizeof(ucpcal_event), 1);
 event->name = ((void *)0);
 event->location = ((void *)0);
 return event;
}

canonical_original_code:
struct ucpcal_event *ucpcal_event_new() {
 struct ucpcal_event *event = (ucpcal_event *) calloc(sizeof(ucpcal_event), 1);
 event->name = ((void *)0);
 event->location = ((void *)0);
 return event;
}

variable_types: struct ucpcal_event { struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; } date; unsigned int duration; char *name; char *location; } *

user_defined_types: struct ucpcal_event { struct ucpcal_date date; unsigned int duration; char *name; char *location; }


decompiled_code:
void __fastcall ucpcal_event_free(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(ptr);
}
}

original_code:
void ucpcal_event_free(ucpcal_event *event) {
 if (event) {
  free(event->name);
  free(event->location);
  free(event);
 }
}

canonical_original_code:
void ucpcal_event_free(struct ucpcal_event *event) {
 if (event) {
  free(event->name);
  free(event->location);
  free(event);
 }
}

user_defined_types: struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; }


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

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

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

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

original_code:
ucpcal_node *ucpcal_node_new(void) {
 ucpcal_node *node = (ucpcal_node *) malloc(sizeof(ucpcal_node));
 node->event = ((void *)0);
 node->next = ((void *)0);
 return node;
}

canonical_original_code:
struct ucpcal_node *ucpcal_node_new() {
 struct ucpcal_node *node = (ucpcal_node *) malloc(sizeof(ucpcal_node));
 node->event = ((void *)0);
 node->next = ((void *)0);
 return node;
}

variable_types: struct ucpcal_node { struct ucpcal_event { struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; } date; unsigned int duration; char *name; char *location; } *event; struct ucpcal_node *next; } *

user_defined_types: struct ucpcal_node { struct ucpcal_event *event; struct ucpcal_node *next; }


decompiled_code:
void __fastcall ucpcal_node_free(void *ptr)
{
ucpcal_event_free(*(_QWORD *)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
ucpcal_event_free(*(_QWORD *)ptr);
free(ptr);
}

original_code:
void ucpcal_node_free(ucpcal_node *node) {
 ucpcal_event_free(node->event);
 free(node);
}

canonical_original_code:
void ucpcal_node_free(struct ucpcal_node *node) {
 ucpcal_event_free(node->event);
 free(node);
}


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

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

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

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

original_code:
ucpcal_list *ucpcal_list_new(void) {
 ucpcal_list *list = (ucpcal_list *) malloc(sizeof(ucpcal_list));
 list->head = ((void *)0);
 list->tail = ((void *)0);
 return list;
}

canonical_original_code:
struct ucpcal_list *ucpcal_list_new() {
 struct ucpcal_list *list = (ucpcal_list *) malloc(sizeof(ucpcal_list));
 list->head = ((void *)0);
 list->tail = ((void *)0);
 return list;
}

variable_types: struct ucpcal_list { struct ucpcal_node { struct ucpcal_event { struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; } date; unsigned int duration; char *name; char *location; } *event; struct ucpcal_node *next; } *head; struct ucpcal_node *tail; } *

user_defined_types: struct ucpcal_list { struct ucpcal_node *head; struct ucpcal_node *tail; }


decompiled_code:
void __fastcall ucpcal_list_delete(__int64 a1, const char *a2)
{
_QWORD *v2; // rbx
_QWORD *v3; // rbp

v2 = *(_QWORD **)a1;
if ( *(_QWORD *)a1 )
{
v3 = 0LL;
while ( strcmp(*(const char **)(*v2 + 32LL), a2) )
{
v3 = v2;
if ( !v2[1] )
return;
v2 = (_QWORD *)v2[1];
}
if ( v3 )
v3[1] = v2[1];
else
*(_QWORD *)a1 = v2[1];
if ( *(_QWORD **)(a1 + 8) == v2 )
*(_QWORD *)(a1 + 8) = v3;
ucpcal_node_free(v2);
}
}

original_code:
void ucpcal_list_delete(ucpcal_list *list, const char *name) {
 ucpcal_node *cur = list->head, *prev = ((void *)0);
 int done = 0;
 while (cur && !done) {
  if (!strcmp(cur->event->name, name)) {
   if (prev)
    prev->next = cur->next;
   else
    list->head = cur->next;
   if (cur == list->tail)
    list->tail = prev;
   ucpcal_node_free(cur);
   done = 1;
  }
  if (!done) {
   prev = cur;
   cur = cur->next;
  }
 }
}

canonical_original_code:
void ucpcal_list_delete(struct ucpcal_list *list, char *name) {
 struct ucpcal_node *cur = list->head; struct ucpcal_node *prev = ((void *)0);
 int done = 0;
 while (cur && !done) {
  if (!strcmp(cur->event->name, name)) {
   if (prev)
    prev->next = cur->next;
   else
    list->head = cur->next;
   if (cur == list->tail)
    list->tail = prev;
   ucpcal_node_free(cur);
   done = 1;
  }
  if (!done) {
   prev = cur;
   cur = cur->next;
  }
 }
}

variable_types:
name
char *

variable_types: done int


decompiled_code:
__int64 __fastcall ucpcal_list_find(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rbx
__int64 v3; // rbp

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( !strcmp(*(const char **)(*v2 + 32LL), a2) )
break;
v2 = (_QWORD *)v2[1];
if ( !v2 )
return 0LL;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD **a1, const char *a2)
{
_QWORD *v2; // rbx
__int64 v3; // rbp

v2 = *a1;
if ( !*a1 )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( !strcmp(*(const char **)(*v2 + 32LL), a2) )
break;
v2 = (_QWORD *)v2[1];
if ( !v2 )
return 0LL;
}
return v3;
}

original_code:
ucpcal_event *ucpcal_list_find(ucpcal_list *list, const char *name) {
 ucpcal_node *cur = list->head;
 ucpcal_event *result = ((void *)0);
 int done = 0;
 while (cur && !done) {
  if (!strcmp(cur->event->name, name)) {
   result = cur->event;
   done = 1;
  }
  cur = cur->next;
 }
 return result;
}

canonical_original_code:
struct ucpcal_event *ucpcal_list_find(struct ucpcal_list *list, char *name) {
 struct ucpcal_node *cur = list->head;
 struct ucpcal_event *result = ((void *)0);
 int done = 0;
 while (cur && !done) {
  if (!strcmp(cur->event->name, name)) {
   result = cur->event;
   done = 1;
  }
  cur = cur->next;
 }
 return result;
}

variable_types: struct ucpcal_list { struct ucpcal_node { struct ucpcal_event *event; struct ucpcal_node *next; } *head; struct ucpcal_node *tail; } *

return_type: struct ucpcal_event { struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; } date; unsigned int duration; char *name; char *location; } *


decompiled_code:
void __fastcall ucpcal_list_free(void *ptr)
{
ucpcal_list_empty(ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
func5(ptr);
free(ptr);
}

original_code:
void ucpcal_list_free(ucpcal_list *list) {
 ucpcal_list_empty(list);
 free(list);
}

canonical_original_code:
void ucpcal_list_free(struct ucpcal_list *list) {
 ucpcal_list_empty(list);
 free(list);
}


freeCallback

decompiled_code:
void __fastcall freeCallback(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(void *a1)
{
free(a1);
}

original_code:
static void freeCallback(gpointer data, GClosure *closure)
{
    free(data);
}

canonical_original_code:
static void freeCallback(void *data, struct _GClosure *closure)
{
    free(data);
}

variable_types:
data
void *

variable_types: struct _GClosure { unsigned int ref_count; unsigned int meta_marshal_nouse; unsigned int n_guards; unsigned int n_fnotifiers; unsigned int n_inotifiers; unsigned int in_inotify; unsigned int floating; unsigned int derivative_flag; unsigned int in_marshal; unsigned int is_invalid; void (*marshal)(struct _GClosure *closure, struct _GValue { unsigned long g_type; union { int v_int; unsigned int v_uint; long v_long; unsigned long v_ulong; long v_int64; unsigned long v_uint64; float v_float; double v_double; void *v_pointer; } data[2]; } *return_value, unsigned int n_param_values, struct _GValue *param_values, void *invocation_hint, void *marshal_data); void *data; struct _GClosureNotifyData { void *data; void (*notify)(void *data, struct _GClosure *closure); } *notifiers; } *

user_defined_types: struct _GClosure { unsigned int ref_count; unsigned int meta_marshal_nouse; unsigned int n_guards; unsigned int n_fnotifiers; unsigned int n_inotifiers; unsigned int in_inotify; unsigned int floating; unsigned int derivative_flag; unsigned int in_marshal; unsigned int is_invalid; void (*marshal)(struct _GClosure *closure, struct _GValue *return_value, unsigned int n_param_values, struct _GValue *param_values, void *invocation_hint, void *marshal_data); void *data; struct _GClosureNotifyData *notifiers; }


freeWindow

decompiled_code:
void __fastcall freeWindow(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func5(void *a1)
{
free(a1);
}

original_code:
void freeWindow(Window *window)
{
    free(window);
}

canonical_original_code:
void freeWindow(struct Window *window)
{
    free(window);
}

variable_types: struct Window { void *gtkWindow; void *buttonBox; void *textBuffer; } *


decompiled_code:
char *__fastcall ucpcal_duration_friendly(unsigned int a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // r8
const char *v3; // r9
const char *v4; // rcx
const char *v6; // rcx
const char *v7; // rcx

v1 = a1 / 0x3CuLL;
v2 = a1 % 0x3C;
if ( (_DWORD)v1 && (_DWORD)v2 )
{
v3 = (const char *)&unk_30F;
if ( (_DWORD)v2 != 1 )
v3 = "s";
v4 = (const char *)&unk_30F;
if ( (_DWORD)v1 != 1 )
v4 = "s";
sprintf(result_2, "%u hour%s, %u minute%s", v1, v4, v2, v3);
}
else if ( (_DWORD)v1 )
{
v6 = (const char *)&unk_30F;
if ( (_DWORD)v1 != 1 )
v6 = "s";
sprintf(result_2, "%u hour%s", v1, v6);
}
else
{
v7 = (const char *)&unk_30F;
if ( (_DWORD)v2 != 1 )
v7 = "s";
sprintf(result_2, "%u minute%s", (unsigned int)v2, v7);
}
return result_2;
}

canonical_decompiled_code:
char *__fastcall func0(unsigned int a1)
{
unsigned __int64 v1; // rdx
__int64 v2; // r8
const char *v3; // r9
const char *v4; // rcx
const char *v6; // rcx
const char *v7; // rcx

v1 = a1 / 0x3CuLL;
v2 = a1 % 0x3C;
if ( (_DWORD)v1 && (_DWORD)v2 )
{
v3 = (const char *)&unk_30F;
if ( (_DWORD)v2 != 1 )
v3 = "s";
v4 = (const char *)&unk_30F;
if ( (_DWORD)v1 != 1 )
v4 = "s";
sprintf(result_2, "%u hour%s, %u minute%s", v1, v4, v2, v3);
}
else if ( (_DWORD)v1 )
{
v6 = (const char *)&unk_30F;
if ( (_DWORD)v1 != 1 )
v6 = "s";
sprintf(result_2, "%u hour%s", v1, v6);
}
else
{
v7 = (const char *)&unk_30F;
if ( (_DWORD)v2 != 1 )
v7 = "s";
sprintf(result_2, "%u minute%s", (unsigned int)v2, v7);
}
return result_2;
}

original_code:
const char *ucpcal_duration_friendly(unsigned int minutes) {
 static char result[64] = "";
 int output_hours = minutes / 60;
 int output_minutes = minutes % 60;
 if (output_hours != 0 && output_minutes != 0)
  sprintf(
   result,
   "%u hour%s, %u minute%s",
   output_hours,
   output_hours == 1 ? "" : "s",
   output_minutes,
   output_minutes == 1 ? "" : "s"
  );
 else if (output_hours != 0)
  sprintf(
   result,
   "%u hour%s",
   output_hours,
   output_hours == 1 ? "" : "s"
  );
 else
  sprintf(
   result,
   "%u minute%s",
   output_minutes,
   output_minutes == 1 ? "" : "s"
  );
 return result;
}

variable_types:
minutes
unsigned int

variable_types:
result
char [64]


decompiled_code:
char *__fastcall ucpcal_date_friendly(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v10; // r9
__int64 v11; // rax
__int64 v12; // rax

if ( (unsigned int)a9 <= 0x17
&& (unsigned int)(HIDWORD(a8) - 1) <= 0x1E
&& a7 >= 0
&& (unsigned int)(a8 - 1) <= 0xB
&& HIDWORD(a9) <= 0x3B
&& (_DWORD)a7 )
{
v10 = (unsigned int)((int)a9 % 12);
if ( !((int)a9 % 12) )
v10 = 12LL;
if ( HIDWORD(a9) )
{
v11 = 112LL;
if ( (int)a9 <= 11 )
v11 = 97LL;
sprintf(
result_0,
"%d %s %d, %d:%02d %cm",
HIDWORD(a8),
(const char *)months_1[(int)a8],
HIDWORD(a7),
v10,
HIDWORD(a9),
v11);
}
else
{
v12 = 112LL;
if ( (int)a9 <= 11 )
v12 = 97LL;
sprintf(result_0, "%d %s %d, %d %cm", HIDWORD(a8), (const char *)months_1[(int)a8], HIDWORD(a7), v10, v12);
}
}
else
{
strcpy(result_0, "invalid date and/or time");
}
return result_0;
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v10; // r9
__int64 v11; // rax
__int64 v12; // rax

if ( (unsigned int)a9 <= 0x17
&& (unsigned int)(HIDWORD(a8) - 1) <= 0x1E
&& a7 >= 0
&& (unsigned int)(a8 - 1) <= 0xB
&& HIDWORD(a9) <= 0x3B
&& (_DWORD)a7 )
{
v10 = (unsigned int)((int)a9 % 12);
if ( !((int)a9 % 12) )
v10 = 12LL;
if ( HIDWORD(a9) )
{
v11 = 112LL;
if ( (int)a9 <= 11 )
v11 = 97LL;
sprintf(
result_0,
"%d %s %d, %d:%02d %cm",
HIDWORD(a8),
(const char *)months_1[(int)a8],
HIDWORD(a7),
v10,
HIDWORD(a9),
v11);
}
else
{
v12 = 112LL;
if ( (int)a9 <= 11 )
v12 = 97LL;
sprintf(result_0, "%d %s %d, %d %cm", HIDWORD(a8), (const char *)months_1[(int)a8], HIDWORD(a7), v10, v12);
}
}
else
{
strcpy(result_0, "invalid date and/or time");
}
return result_0;
}

original_code:
const char *ucpcal_date_friendly(ucpcal_date date) {
 static char result[64] = "";
 static const char *months[] = {
  ((void *)0), "January", "February", "March", "April",
  "May", "June", "July", "August",
  "September", "October", "November", "December"
 };
 if (
  date.year >= 0 &&
  date.month >= 1 && date.month <= 12 &&
  date.day >= 1 && date.day <= 31 &&
  date.hour >= 0 && date.hour <= 23 &&
  date.minute >= 0 && date.minute <= 59 &&
  date.good
 ) {
  int hour = date.hour % 12;
  if (hour == 0)
   hour = 12;
  if (date.minute)
   sprintf(
    result,
    "%d %s %d, %d:%02d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.minute,
    date.hour > 11 ? 'p' : 'a'
   );
  else
   sprintf(
    result,
    "%d %s %d, %d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.hour > 11 ? 'p' : 'a'
   );
 } else {
  strcpy(result, "invalid date and/or time");
 }
 return result;
}

canonical_original_code:
char *ucpcal_date_friendly(struct ucpcal_date date) {
 static char result[64] = "";
 static char *months[] = {
  ((void *)0), "January", "February", "March", "April",
  "May", "June", "July", "August",
  "September", "October", "November", "December"
 };
 if (
  date.year >= 0 &&
  date.month >= 1 && date.month <= 12 &&
  date.day >= 1 && date.day <= 31 &&
  date.hour >= 0 && date.hour <= 23 &&
  date.minute >= 0 && date.minute <= 59 &&
  date.good
 ) {
  int hour = date.hour % 12;
  if (hour == 0)
   hour = 12;
  if (date.minute)
   sprintf(
    result,
    "%d %s %d, %d:%02d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.minute,
    date.hour > 11 ? 'p' : 'a'
   );
  else
   sprintf(
    result,
    "%d %s %d, %d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.hour > 11 ? 'p' : 'a'
   );
 } else {
  strcpy(result, "invalid date and/or time");
 }
 return result;
}

variable_types: struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; }

variable_types:
months
char *[]

variable_types: hour int


main

repo: dellelce/usleep

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // edi

v4 = 100;
if ( argc > 1 )
{
v4 = atoi(argv[1]);
if ( !v4 )
v4 = 100;
}
usleep(v4);
return 0;
}

original_code:
int
main (int argc, char **argv)
{
  unsigned int secs;
  if (argc < 2)
  {
    secs = 100;
  }
  else
  {
    secs = atoi(argv[1]);
  }
  if (secs == 0) secs = 100;
  usleep((useconds_t)secs);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  unsigned int secs;
  if (argc < 2)
  {
    secs = 100;
  }
  else
  {
    secs = atoi(argv[1]);
  }
  if (secs == 0) secs = 100;
  usleep((unsigned int)secs);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
secs
unsigned int


printUsage

repo: deloschang/search-engine

decompiled_code:
int printUsage()
{
puts("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]");
return puts("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]");
}

canonical_decompiled_code:
int func0()
{
puts("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]");
return puts("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]");
}

original_code:
void printUsage(){
    printf("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]\n");
    printf("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]\n");
}


validateArgs

decompiled_code:
void __fastcall validateArgs(unsigned int a1, __int64 a2)
{
const char *v2; // r13
size_t v3; // r12
char *v4; // rbx
struct stat v5; // [rsp+0h] [rbp-148h] BYREF
struct stat v6; // [rsp+90h] [rbp-B8h] BYREF

if ( ((a1 - 3) & 0xFFFFFFFD) != 0 )
{
fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", a1);
printUsage();
exit(1);
}
if ( stat(*(const char **)(a2 + 8), &v6) )
{
fprintf(
stderr,
"Error: The dir argument %s was not found. Please enter a readable and valid directory. \n",
*(const char **)(a2 + 8));
printUsage();
exit(1);
}
if ( !stat(*(const char **)(a2 + 16), &v5) )
fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", *(const char **)(a2 + 16));
v2 = *(const char **)(a2 + 8);
v3 = strlen(v2);
v4 = (char *)malloc(v3 + 43);
if ( !v4 )
{
fwrite("Out of memory! \n ", 1uLL, 0x11uLL, stderr);
exit(1);
}
*(_QWORD *)v4 = 0x722D205B5B206669LL;
v4[8] = 32;
memcpy(v4 + 9, v2, v3);
strcat(v4, " ]]; then exit 0; else exit 1; fi");
if ( system(v4) )
{
fprintf(
stderr,
"Error: The dir argument %s was not readable. Please enter readable and valid directory. \n",
*(const char **)(a2 + 8));
printUsage();
free(v4);
exit(1);
}
free(v4);
}

canonical_decompiled_code:
void __fastcall func1(unsigned int a1, __int64 a2)
{
const char *v2; // r13
size_t v3; // r12
char *v4; // rbx
struct stat v5; // [rsp+0h] [rbp-148h] BYREF
struct stat v6; // [rsp+90h] [rbp-B8h] BYREF

if ( ((a1 - 3) & 0xFFFFFFFD) != 0 )
{
fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", a1);
func0();
exit(1);
}
if ( stat(*(const char **)(a2 + 8), &v6) )
{
fprintf(
stderr,
"Error: The dir argument %s was not found. Please enter a readable and valid directory. \n",
*(const char **)(a2 + 8));
func0();
exit(1);
}
if ( !stat(*(const char **)(a2 + 16), &v5) )
fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", *(const char **)(a2 + 16));
v2 = *(const char **)(a2 + 8);
v3 = strlen(v2);
v4 = (char *)malloc(v3 + 43);
if ( !v4 )
{
fwrite("Out of memory! \n ", 1uLL, 0x11uLL, stderr);
exit(1);
}
*(_QWORD *)v4 = 0x722D205B5B206669LL;
v4[8] = 32;
memcpy(v4 + 9, v2, v3);
strcat(v4, " ]]; then exit 0; else exit 1; fi");
if ( system(v4) )
{
fprintf(
stderr,
"Error: The dir argument %s was not readable. Please enter readable and valid directory. \n",
*(const char **)(a2 + 8));
func0();
free(v4);
exit(1);
}
free(v4);
}

original_code:
void validateArgs(int argc, char* argv[]){
  struct stat s;
  struct stat checkDest;
  int readableResult = 0;
  char* readableTest = ((void *)0);
  if ( (argc != 3) && (argc != 5) ){
    fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", argc);
    printUsage();
    exit(1);
  }
  if ( stat(argv[1], &s) != 0){
    fprintf(stderr, "Error: The dir argument %s was not found.  Please     enter a readable and valid directory. \n", argv[1]);
    printUsage();
    exit(1);
  }
  if ( stat(argv[2], &checkDest) == 0){
    fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", argv[2]);
  }
  size_t len1 = strlen("if [[ -r "), len2 = strlen(argv[1]), len3 = strlen(" ]]; then exit 0; else exit 1; fi");
  readableTest = (char*) malloc(len1 + len2 + len3 + 1);
  if (readableTest == ((void *)0)){
    fprintf(stderr, "Out of memory! \n ");
    exit(1);
  }
  memcpy(readableTest, "if [[ -r ", len1);
  memcpy(readableTest+len1, argv[1], len2);
  strcat(readableTest, " ]]; then exit 0; else exit 1; fi");
  readableResult = system(readableTest);
  if ( readableResult != 0){
    fprintf(stderr, "Error: The dir argument %s was not readable.     Please enter readable and valid directory. \n", argv[1]);
    printUsage();
    free(readableTest);
    exit(1);
  }
  free(readableTest);
}

canonical_original_code:
void validateArgs(int argc, char *argv[]){
  struct stat s;
  struct stat checkDest;
  int readableResult = 0;
  char *readableTest = ((void *)0);
  if ( (argc != 3) && (argc != 5) ){
    fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", argc);
    printUsage();
    exit(1);
  }
  if ( stat(argv[1], &s) != 0){
    fprintf(stderr, "Error: The dir argument %s was not found.  Please     enter a readable and valid directory. \n", argv[1]);
    printUsage();
    exit(1);
  }
  if ( stat(argv[2], &checkDest) == 0){
    fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", argv[2]);
  }
  unsigned long len1 = strlen("if [[ -r "); unsigned long len2 = strlen(argv[1]); unsigned long len3 = strlen(" ]]; then exit 0; else exit 1; fi");
  readableTest = (char *) malloc(len1 + len2 + len3 + 1);
  if (readableTest == ((void *)0)){
    fprintf(stderr, "Out of memory! \n ");
    exit(1);
  }
  memcpy(readableTest, "if [[ -r ", len1);
  memcpy(readableTest+len1, argv[1], len2);
  strcat(readableTest, " ]]; then exit 0; else exit 1; fi");
  readableResult = system(readableTest);
  if ( readableResult != 0){
    fprintf(stderr, "Error: The dir argument %s was not readable.     Please enter readable and valid directory. \n", argv[1]);
    printUsage();
    free(readableTest);
    exit(1);
  }
  free(readableTest);
}

variable_types:
argv
char *[]

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types: readableResult int

variable_types:
readableTest
char *


validateDebugArgs

decompiled_code:
int __fastcall validateDebugArgs(const char *a1, const char *a2)
{
int result; // eax
struct stat v3; // [rsp+0h] [rbp-138h] BYREF
struct stat v4; // [rsp+90h] [rbp-A8h] BYREF

if ( stat(a1, &v4) )
{
fprintf(stderr, "Error: The target file argument %s was not found \n", a1);
printUsage();
exit(1);
}
result = stat(a2, &v3);
if ( !result )
result = fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", a2);
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1, const char *a2)
{
int result; // eax
struct stat v3; // [rsp+0h] [rbp-138h] BYREF
struct stat v4; // [rsp+90h] [rbp-A8h] BYREF

if ( stat(a1, &v4) )
{
fprintf(stderr, "Error: The target file argument %s was not found \n", a1);
func0();
exit(1);
}
result = stat(a2, &v3);
if ( !result )
result = fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", a2);
return result;
}

original_code:
void validateDebugArgs(char* loadFile, char* writeReload){
  struct stat checkLoadFile;
  struct stat checkWriteReload;
  if ( stat(loadFile, &checkLoadFile) != 0){
    fprintf(stderr, "Error: The target file argument %s was not found \n", loadFile);
    printUsage();
    exit(1);
  }
  if ( stat(writeReload, &checkWriteReload) == 0){
    fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", writeReload);
  }
}

canonical_original_code:
void validateDebugArgs(char *loadFile, char *writeReload){
  struct stat checkLoadFile;
  struct stat checkWriteReload;
  if ( stat(loadFile, &checkLoadFile) != 0){
    fprintf(stderr, "Error: The target file argument %s was not found \n", loadFile);
    printUsage();
    exit(1);
  }
  if ( stat(writeReload, &checkWriteReload) == 0){
    fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", writeReload);
  }
}

variable_types:
loadFile
char *

variable_types:
writeReload
char *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }


updateIndex

decompiled_code:
__int64 __fastcall updateIndex(__int64 a1, const char *a2, unsigned int a3)
{
unsigned __int64 v4; // rcx
__int64 v5; // rbx
__int64 v6; // r13
__int64 *i; // rbx
int v8; // er14
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v4 = hash1(a2) % 0x2710uLL;
v5 = *(_QWORD *)(a1 + 8LL * (int)v4 + 16);
if ( v5 )
{
if ( !strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
{
LABEL_5:
for ( i = *(__int64 **)(v5 + 1016); i; i = (__int64 *)*i )
{
if ( *((_DWORD *)i + 2) == a3 )
{
++*((_DWORD *)i + 3);
return 1LL;
}
if ( !*i )
{
*i = newDocNode(0LL, a3, 1LL);
return 1LL;
}
}
}
else
{
while ( 1 )
{
v6 = v5;
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
break;
if ( !strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
goto LABEL_5;
}
v11 = newDocNode(0LL, a3, 1LL);
*(_QWORD *)(v6 + 8) = newWordNode(0LL, v11, a2);
}
}
else
{
v8 = v4;
v9 = newDocNode(0LL, a3, 1LL);
v10 = newWordNode(0LL, v9, a2);
*(_QWORD *)(a1 + 8LL * v8 + 16) = v10;
*(_QWORD *)(a1 + 8) = v10;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2, unsigned int a3)
{
unsigned __int64 v4; // rcx
__int64 v5; // rbx
__int64 v6; // r13
__int64 *i; // rbx
int v8; // er14
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v4 = hash1(a2) % 0x2710uLL;
v5 = *(_QWORD *)(a1 + 8LL * (int)v4 + 16);
if ( v5 )
{
if ( !strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
{
LABEL_5:
for ( i = *(__int64 **)(v5 + 1016); i; i = (__int64 *)*i )
{
if ( *((_DWORD *)i + 2) == a3 )
{
++*((_DWORD *)i + 3);
return 1LL;
}
if ( !*i )
{
*i = newDocNode(0LL, a3, 1LL);
return 1LL;
}
}
}
else
{
while ( 1 )
{
v6 = v5;
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
break;
if ( !strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
goto LABEL_5;
}
v11 = newDocNode(0LL, a3, 1LL);
*(_QWORD *)(v6 + 8) = newWordNode(0LL, v11, a2);
}
}
else
{
v8 = v4;
v9 = newDocNode(0LL, a3, 1LL);
v10 = newWordNode(0LL, v9, a2);
*(_QWORD *)(a1 + 8LL * v8 + 16) = v10;
*(_QWORD *)(a1 + 8) = v10;
}
return 1LL;
}

original_code:
int updateIndex(INVERTED_INDEX* index, char* word, int documentId){
  int wordHash = hash1(word) % 10000;
  DocumentNode* docNode = ((void *)0);
  WordNode* wordNode = ((void *)0);
  if (index->hash[wordHash] == ((void *)0)){
    docNode = ((void *)0);
    docNode = newDocNode(docNode, documentId, 1);
    wordNode = ((void *)0);
    wordNode = newWordNode(wordNode, docNode, word);
    index->hash[wordHash] = wordNode;
    index->end = wordNode;
    return 1;
  } else {
    WordNode* checkWordNode = index->hash[wordHash];
    WordNode* matchedWordNode;
    WordNode* endWordNode = ((void *)0);
    if (!strncmp(checkWordNode->word, word, 1000)){
      matchedWordNode = checkWordNode;
    } else {
      while (checkWordNode != ((void *)0)){
        if ( (checkWordNode->next == ((void *)0)) ){
          endWordNode = checkWordNode;
          break;
        }
        checkWordNode = checkWordNode->next;
        if (!strncmp(checkWordNode->word, word, 1000)){
          matchedWordNode = checkWordNode;
          break;
        }
      }
    }
    if (matchedWordNode != ((void *)0)){
      DocumentNode* matchDocNode = matchedWordNode->page;
      DocumentNode* endDocNode;
      while (matchDocNode != ((void *)0)){
        if (matchDocNode->document_id == documentId){
          matchDocNode->page_word_frequency++;
          break;
        }
        if ( (matchDocNode->next == ((void *)0)) ){
          endDocNode = matchDocNode;
          docNode = ((void *)0);
          docNode = newDocNode(docNode, documentId, 1);
          endDocNode->next = docNode;
          break;
        }
        matchDocNode = matchDocNode->next;
      }
    } else {
      docNode = ((void *)0);
      docNode = newDocNode(docNode, documentId, 1);
      wordNode = ((void *)0);
      wordNode = newWordNode(wordNode, docNode, word);
      endWordNode->next = wordNode;
    }
    return 1;
  }
  return 1;
}

canonical_original_code:
int updateIndex(struct _INVERTED_INDEX *index, char *word, int documentId){
  int wordHash = hash1(word) % 10000;
  struct _DocumentNode *docNode = ((void *)0);
  struct _WordNode *wordNode = ((void *)0);
  if (index->hash[wordHash] == ((void *)0)){
    docNode = ((void *)0);
    docNode = newDocNode(docNode, documentId, 1);
    wordNode = ((void *)0);
    wordNode = newWordNode(wordNode, docNode, word);
    index->hash[wordHash] = wordNode;
    index->end = wordNode;
    return 1;
  } else {
    struct _WordNode *checkWordNode = index->hash[wordHash];
    struct _WordNode *matchedWordNode;
    struct _WordNode *endWordNode = ((void *)0);
    if (!strncmp(checkWordNode->word, word, 1000)){
      matchedWordNode = checkWordNode;
    } else {
      while (checkWordNode != ((void *)0)){
        if ( (checkWordNode->next == ((void *)0)) ){
          endWordNode = checkWordNode;
          break;
        }
        checkWordNode = checkWordNode->next;
        if (!strncmp(checkWordNode->word, word, 1000)){
          matchedWordNode = checkWordNode;
          break;
        }
      }
    }
    if (matchedWordNode != ((void *)0)){
      struct _DocumentNode *matchDocNode = matchedWordNode->page;
      struct _DocumentNode *endDocNode;
      while (matchDocNode != ((void *)0)){
        if (matchDocNode->document_id == documentId){
          matchDocNode->page_word_frequency++;
          break;
        }
        if ( (matchDocNode->next == ((void *)0)) ){
          endDocNode = matchDocNode;
          docNode = ((void *)0);
          docNode = newDocNode(docNode, documentId, 1);
          endDocNode->next = docNode;
          break;
        }
        matchDocNode = matchDocNode->next;
      }
    } else {
      docNode = ((void *)0);
      docNode = newDocNode(docNode, documentId, 1);
      wordNode = ((void *)0);
      wordNode = newWordNode(wordNode, docNode, word);
      endWordNode->next = wordNode;
    }
    return 1;
  }
  return 1;
}

variable_types: struct _INVERTED_INDEX { struct _WordNode { struct _WordNode *prev; struct _WordNode *next; char word[1000]; struct _DocumentNode { struct _DocumentNode *next; int document_id; int page_word_frequency; } *page; } *start; struct _WordNode *end; struct _WordNode *hash[10000]; } *

variable_types:
word
char *

variable_types: documentId int

variable_types: wordHash int

user_defined_types: struct _INVERTED_INDEX { struct _WordNode *start; struct _WordNode *end; struct _WordNode *hash[10000]; }

user_defined_types: struct _WordNode { struct _WordNode *prev; struct _WordNode *next; char word[1000]; struct _DocumentNode *page; }