// File: /workspace/github_c_makefile_star2_O1/JulStrat[P]bams/bams_app.c
// Function: main
int
main(int argc, char *argv[])
{
    int a, b;
    size_t i;
    int min_key = INT_MAX, max_key = INT_MIN;
    BAMS *bas;
    size_t less = 0;
    size_t equal = 0;
    size_t great = 0;

    size_t less_a = 0;
    size_t equal_a = 0;
    size_t great_a = 0;
    size_t all_a = 0;

    int *less_keys;
    int *equal_keys;
    int *great_keys;
    int *all_keys;

    srand(time(NULL));
    for (i = 0; i < ARR_SZ; i++) {
        arint[i] = rand();
        if (arint[i] < min_key) {
            min_key = arint[i];
        }
        if (arint[i] > max_key) {
            max_key = arint[i];
        }
    }

    bas = bams_create(sizeof (int), cmp_int);

    for (i = 0; i < ARR_SZ; i++) {
        bams_insert(bas, &arint[i]);
    }

#if 0
    for (i = 0; i < ARR_SZ; i++) {
        if (0 == bams_contains(bas, &arint[i])) {
            printf("Error: %d not in set.\n", arint[i]);
            break;
        };
    }
#endif

    a = arint[0];
    for (i = 0; i < ARR_SZ; i++) {
        if (arint[i] < a) {
            less++;
        } else if (arint[i] > a) {
            great++;
        } else {
            equal++;
        }
    }
    assert(less == bams_count_less(bas, &a));
    printf("Less than %d: Expected %lu, %lu\n", a, less,
           bams_count_less(bas, &a));

    assert(equal == bams_count_equal(bas, &a));
    printf("Equal to %d: Expected %lu, %lu\n", a, equal,
           bams_count_equal(bas, &a));

    assert(great == bams_count_great(bas, &a));
    printf("Great than %d: Expected %lu, %lu\n", a, great,
           bams_count_great(bas, &a));

    assert(*(int *) bams_min(bas) == min_key);
    printf("Min key: %d, expected: %d\n", *(int *) bams_min(bas), min_key);

    assert(*(int *) bams_max(bas) == max_key);
    printf("Max key: %d, expected: %d\n", *(int *) bams_max(bas), max_key);

    less_keys = bams_less(bas, &a, &less_a);
    assert(less == less_a);
    for (i = 0; i < less_a; i++) {
        assert(less_keys[i] < a);
    }
    free(less_keys);

    equal_keys = bams_equal(bas, &a, &equal_a);
    printf("Equal: %lu, %lu\n", equal, equal_a);
    assert(equal == equal_a);
    for (i = 0; i < equal_a; i++) {
        assert(equal_keys[i] == a);
    }
    free(equal_keys);

    great_keys = bams_great(bas, &a, &great_a);
    assert(great == great_a);
    for (i = 0; i < great_a; i++) {
        assert(great_keys[i] > a);
    }
    free(great_keys);

    all_keys = bams_array(bas, &all_a);
    assert(ARR_SZ == all_a);
    for (i = 1; i < all_a; i++) {
        assert(all_keys[i] >= all_keys[i - 1]);
    }
    free(all_keys);

    printf("Set size: %lu\n", bams_size(bas));
    printf("Check structure result: %d\n", bams_check_structure(bas));
    bams_free(bas);

    /*
     * big set 
     */
    /*
     * bas = bams_create(sizeof (int), cmp_int); for (i = 0; i < 1024 *
     * 1024 * 32; i++) { a = rand(); bams_insert(bas, &a); } printf("Set
     * size: %lu\n", bams_size(bas)); printf("Check structure result:
     * %d\n", bams_check_structure(bas)); bams_free(bas); 
     */
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
xorl %ebx, %ebx
movq %rbx, 0x30(%rsp)
movq %rbx, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movq %rbx, 0x18(%rsp)
xorl %edi, %edi
callq 0x1080
movl %eax, %edi
callq 0x1060
movl $0x80000000, %ebp       # imm = 0x80000000
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq 0x3e6e(%rip), %r14      # 0x5080
callq 0x10b0
movl %eax, (%rbx,%r14)
cmpl %r12d, %eax
cmovll %eax, %r12d
cmpl %ebp, %eax
cmovgl %eax, %ebp
addq $0x4, %rbx
cmpq $0x3ffffc, %rbx         # imm = 0x3FFFFC
jne 0x1212
leaq -0x7f(%rip), %rsi       # 0x11bc
movl $0x4, %edi
callq 0x1b0b
movq %rax, %rbx
xorl %r15d, %r15d
leaq (%r14,%r15), %rsi
movq %rbx, %rdi
callq 0x1b76
addq $0x4, %r15
cmpq $0x3ffffc, %r15         # imm = 0x3FFFFC
jne 0x124b
movl 0x3e16(%rip), %eax      # 0x5080
movl %eax, 0x8(%rsp)
xorl %ecx, %ecx
xorl %r13d, %r13d
xorl %edx, %edx
xorl %r15d, %r15d
cmpl %eax, (%rcx,%r14)
jge 0x1283
incq %r13
jmp 0x128d
jle 0x128a
incq %rdx
jmp 0x128d
incq %r15
addq $0x4, %rcx
cmpq $0x3ffffc, %rcx         # imm = 0x3FFFFC
jne 0x1278
movq %rdx, 0x10(%rsp)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x1e71
cmpq %rax, %r13
jne 0x15b1
leaq 0x8(%rsp), %r14
movl (%r14), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1e71
leaq 0x1d74(%rip), %rdi      # 0x3047
movl 0xc(%rsp), %esi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f55
cmpq %rax, %r15
jne 0x15d0
leaq 0x8(%rsp), %r14
movl (%r14), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f55
leaq 0x1d75(%rip), %rdi      # 0x308b
movl 0xc(%rsp), %esi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
movq %r14, %rsi
callq 0x204c
movq 0x10(%rsp), %r14
cmpq %rax, %r14
jne 0x15ef
leaq 0x8(%rsp), %rsi
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x204c
leaq 0x1d74(%rip), %rdi      # 0x30ce
movl 0xc(%rsp), %esi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x1cc3
cmpl %r12d, (%rax)
jne 0x160e
movq %rbx, %rdi
callq 0x1cc3
movl (%rax), %esi
leaq 0x1d85(%rip), %rdi      # 0x3112
movl %r12d, %edx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x1d7a
cmpl %ebp, (%rax)
jne 0x162d
movq %rbx, %rdi
callq 0x1d7a
movl (%rax), %esi
leaq 0x1d97(%rip), %rdi      # 0x314f
movl %ebp, %edx
xorl %eax, %eax
callq 0x1040
leaq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rdx
callq 0x2138
movq (%r12), %rcx
cmpq %rcx, %r13
jne 0x164c
testq %rcx, %rcx
je 0x13ff
movl 0x8(%rsp), %edx
xorl %esi, %esi
cmpl %edx, (%rax,%rsi,4)
jge 0x1554
incq %rsi
cmpq %rsi, %rcx
jne 0x13ee
movq %rax, %rdi
callq 0x1030
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
callq 0x2293
movq %rax, %r12
movq (%r13), %rdx
leaq 0x1d60(%rip), %rdi      # 0x318a
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movq (%r13), %rax
cmpq %rax, %r15
jne 0x166b
testq %rax, %rax
je 0x145e
movl 0x8(%rsp), %ecx
xorl %edx, %edx
cmpl %ecx, (%r12,%rdx,4)
jne 0x1573
incq %rdx
cmpq %rdx, %rax
jne 0x144c
movq %r12, %rdi
callq 0x1030
leaq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x245c
movq (%r15), %rcx
cmpq %rcx, 0x10(%rsp)
jne 0x168a
testq %rcx, %rcx
je 0x14a5
movl 0x8(%rsp), %edx
xorl %esi, %esi
cmpl %edx, (%rax,%rsi,4)
jle 0x1592
incq %rsi
cmpq %rsi, %rcx
jne 0x1494
movq %rax, %rdi
callq 0x1030
leaq 0x18(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x25c2
movq (%r14), %rcx
cmpq $0xfffff, %rcx          # imm = 0xFFFFF
jne 0x16a9
movl $0x1, %edx
movl (%rax,%rdx,4), %esi
cmpl -0x4(%rax,%rdx,4), %esi
jl 0x1535
incq %rdx
cmpq %rdx, %rcx
jne 0x14d2
movq %rax, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x2653
leaq 0x1d17(%rip), %rdi      # 0x3211
movq %rax, %rsi
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x273c
leaq 0x1d0d(%rip), %rdi      # 0x3220
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x26de
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1cb6(%rip), %rdi      # 0x31f2
leaq 0x1ae2(%rip), %rsi      # 0x3025
leaq 0x1ae6(%rip), %rcx      # 0x3030
movl $0x81, %edx
callq 0x1050
leaq 0x1c1e(%rip), %rdi      # 0x3179
leaq 0x1ac3(%rip), %rsi      # 0x3025
leaq 0x1ac7(%rip), %rcx      # 0x3030
movl $0x6b, %edx
callq 0x1050
leaq 0x1c32(%rip), %rdi      # 0x31ac
leaq 0x1aa4(%rip), %rsi      # 0x3025
leaq 0x1aa8(%rip), %rcx      # 0x3030
movl $0x73, %edx
callq 0x1050
leaq 0x1c37(%rip), %rdi      # 0x31d0
leaq 0x1a85(%rip), %rsi      # 0x3025
leaq 0x1a89(%rip), %rcx      # 0x3030
movl $0x7a, %edx
callq 0x1050
leaq 0x1a4c(%rip), %rdi      # 0x3004
leaq 0x1a66(%rip), %rsi      # 0x3025
leaq 0x1a6a(%rip), %rcx      # 0x3030
movl $0x56, %edx
callq 0x1050
leaq 0x1a91(%rip), %rdi      # 0x3068
leaq 0x1a47(%rip), %rsi      # 0x3025
leaq 0x1a4b(%rip), %rcx      # 0x3030
movl $0x5a, %edx
callq 0x1050
leaq 0x1ab5(%rip), %rdi      # 0x30ab
leaq 0x1a28(%rip), %rsi      # 0x3025
leaq 0x1a2c(%rip), %rcx      # 0x3030
movl $0x5e, %edx
callq 0x1050
leaq 0x1adb(%rip), %rdi      # 0x30f0
leaq 0x1a09(%rip), %rsi      # 0x3025
leaq 0x1a0d(%rip), %rcx      # 0x3030
movl $0x62, %edx
callq 0x1050
leaq 0x1af9(%rip), %rdi      # 0x312d
leaq 0x19ea(%rip), %rsi      # 0x3025
leaq 0x19ee(%rip), %rcx      # 0x3030
movl $0x65, %edx
callq 0x1050
leaq 0x1b17(%rip), %rdi      # 0x316a
leaq 0x19cb(%rip), %rsi      # 0x3025
leaq 0x19cf(%rip), %rcx      # 0x3030
movl $0x69, %edx
callq 0x1050
leaq 0x1b29(%rip), %rdi      # 0x319b
leaq 0x19ac(%rip), %rsi      # 0x3025
leaq 0x19b0(%rip), %rcx      # 0x3030
movl $0x71, %edx
callq 0x1050
leaq 0x1b2e(%rip), %rdi      # 0x31bf
leaq 0x198d(%rip), %rsi      # 0x3025
leaq 0x1991(%rip), %rcx      # 0x3030
movl $0x78, %edx
callq 0x1050
leaq 0x1b32(%rip), %rdi      # 0x31e2
leaq 0x196e(%rip), %rsi      # 0x3025
leaq 0x1972(%rip), %rcx      # 0x3030
movl $0x7f, %edx
callq 0x1050