// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x30(%rsp)
andq $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
andq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1080
movl %eax, %edi
callq 0x1060
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl $0x80000000, %ebp       # imm = 0x80000000
leaq 0x4e6b(%rip), %rbx      # 0x6080
cmpq $0x3ffffc, %r14         # imm = 0x3FFFFC
je 0x1239
callq 0x10b0
movl %eax, (%r14,%rbx)
cmpl %r12d, %eax
cmovll %eax, %r12d
cmpl %ebp, %eax
cmovgl %eax, %ebp
addq $0x4, %r14
jmp 0x1215
leaq -0x84(%rip), %rsi       # 0x11bc
pushq $0x4
popq %rdi
callq 0x1a7e
movq %rax, %r15
xorl %r14d, %r14d
cmpq $0x3ffffc, %r14         # imm = 0x3FFFFC
je 0x1269
leaq (%rbx,%r14), %rsi
movq %r15, %rdi
callq 0x1adf
addq $0x4, %r14
jmp 0x124e
movq %r15, 0x10(%rsp)
movl 0x4e0c(%rip), %eax      # 0x6080
movl %eax, 0x8(%rsp)
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq $0x3ffffc, %rcx         # imm = 0x3FFFFC
je 0x12a6
cmpl %eax, (%rcx,%rbx)
jge 0x1296
incq %r13
jmp 0x12a0
jle 0x129d
incq %r14
jmp 0x12a0
incq %r15
addq $0x4, %rcx
jmp 0x1283
leaq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x1db5
cmpq %rax, %r13
jne 0x1599
leaq 0x8(%rsp), %rsi
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x1db5
leaq 0x1d6c(%rip), %rdi      # 0x3047
movl 0xc(%rsp), %esi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x1e99
cmpq %rax, %r15
jne 0x15b5
leaq 0x8(%rsp), %rsi
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x1e99
leaq 0x1d6f(%rip), %rdi      # 0x308b
movl 0xc(%rsp), %esi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x1f90
cmpq %rax, %r14
jne 0x15d1
leaq 0x8(%rsp), %rsi
movl (%rsi), %eax
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x1f90
leaq 0x1d71(%rip), %rdi      # 0x30ce
movl 0xc(%rsp), %esi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x1c17
cmpl %r12d, (%rax)
jne 0x15ed
movq %rbx, %rdi
callq 0x1c17
movl (%rax), %esi
leaq 0x1d82(%rip), %rdi      # 0x3112
movl %r12d, %edx
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x1ccb
cmpl %ebp, (%rax)
jne 0x1609
movq %rbx, %rdi
callq 0x1ccb
movl (%rax), %esi
leaq 0x1d94(%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 0x207c
cmpq (%r12), %r13
jne 0x1625
movl 0x8(%rsp), %ecx
xorl %edx, %edx
cmpq %rdx, %r13
je 0x1416
leaq 0x1(%rdx), %rsi
cmpl %ecx, (%rax,%rdx,4)
movq %rsi, %rdx
jl 0x13e9
leaq 0x1d78(%rip), %rdi      # 0x3179
leaq 0x1c1d(%rip), %rsi      # 0x3025
leaq 0x1c21(%rip), %rcx      # 0x3030
pushq $0x6b
jmp 0x14e1
movq %rax, %rdi
callq 0x1030
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %r13
movq 0x10(%rsp), %rdi
movq %r13, %rdx
callq 0x21c7
movq %rax, %r12
movq (%r13), %rdx
leaq 0x1d47(%rip), %rdi      # 0x318a
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
cmpq (%r13), %r15
jne 0x1641
movl 0x8(%rsp), %eax
xorl %ecx, %ecx
movq 0x10(%rsp), %rbx
cmpq %rcx, %r15
je 0x148d
leaq 0x1(%rcx), %rdx
cmpl %eax, (%r12,%rcx,4)
movq %rdx, %rcx
je 0x1462
leaq 0x1d31(%rip), %rdi      # 0x31ac
leaq 0x1ba3(%rip), %rsi      # 0x3025
leaq 0x1ba7(%rip), %rcx      # 0x3030
pushq $0x73
jmp 0x14e1
movq %r12, %rdi
callq 0x1030
leaq 0x8(%rsp), %rsi
leaq 0x20(%rsp), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x2387
cmpq (%r15), %r14
jne 0x165d
movl 0x8(%rsp), %ecx
xorl %edx, %edx
cmpq %rdx, %r14
je 0x14e7
leaq 0x1(%rdx), %rsi
cmpl %ecx, (%rax,%rdx,4)
movq %rsi, %rdx
jg 0x14b9
leaq 0x1cff(%rip), %rdi      # 0x31d0
leaq 0x1b4d(%rip), %rsi      # 0x3025
leaq 0x1b51(%rip), %rcx      # 0x3030
pushq $0x7a
popq %rdx
callq 0x1050
movq %rax, %rdi
callq 0x1030
leaq 0x18(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24dd
cmpq $0xfffff, (%r14)        # imm = 0xFFFFF
jne 0x1679
pushq $0x1
popq %rcx
cmpq $0xfffff, %rcx          # imm = 0xFFFFF
je 0x1547
movl (%rax,%rcx,4), %edx
leaq 0x1(%rcx), %rsi
cmpl -0x4(%rax,%rcx,4), %edx
movq %rsi, %rcx
jge 0x150f
leaq 0x1cc3(%rip), %rdi      # 0x31f2
leaq 0x1aef(%rip), %rsi      # 0x3025
leaq 0x1af3(%rip), %rcx      # 0x3030
movl $0x81, %edx
callq 0x1050
movq %rax, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x256d
leaq 0x1cb3(%rip), %rdi      # 0x3211
movq %rax, %rsi
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x2650
leaq 0x1ca9(%rip), %rdi      # 0x3220
movl %eax, %esi
xorl %eax, %eax
callq 0x1040
movq %rbx, %rdi
callq 0x25f5
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a64(%rip), %rdi      # 0x3004
leaq 0x1a7e(%rip), %rsi      # 0x3025
leaq 0x1a82(%rip), %rcx      # 0x3030
pushq $0x56
jmp 0x14e1
leaq 0x1aac(%rip), %rdi      # 0x3068
leaq 0x1a62(%rip), %rsi      # 0x3025
leaq 0x1a66(%rip), %rcx      # 0x3030
pushq $0x5a
jmp 0x14e1
leaq 0x1ad3(%rip), %rdi      # 0x30ab
leaq 0x1a46(%rip), %rsi      # 0x3025
leaq 0x1a4a(%rip), %rcx      # 0x3030
pushq $0x5e
jmp 0x14e1
leaq 0x1afc(%rip), %rdi      # 0x30f0
leaq 0x1a2a(%rip), %rsi      # 0x3025
leaq 0x1a2e(%rip), %rcx      # 0x3030
pushq $0x62
jmp 0x14e1
leaq 0x1b1d(%rip), %rdi      # 0x312d
leaq 0x1a0e(%rip), %rsi      # 0x3025
leaq 0x1a12(%rip), %rcx      # 0x3030
pushq $0x65
jmp 0x14e1
leaq 0x1b3e(%rip), %rdi      # 0x316a
leaq 0x19f2(%rip), %rsi      # 0x3025
leaq 0x19f6(%rip), %rcx      # 0x3030
pushq $0x69
jmp 0x14e1
leaq 0x1b53(%rip), %rdi      # 0x319b
leaq 0x19d6(%rip), %rsi      # 0x3025
leaq 0x19da(%rip), %rcx      # 0x3030
pushq $0x71
jmp 0x14e1
leaq 0x1b5b(%rip), %rdi      # 0x31bf
leaq 0x19ba(%rip), %rsi      # 0x3025
leaq 0x19be(%rip), %rcx      # 0x3030
pushq $0x78
jmp 0x14e1
leaq 0x1b62(%rip), %rdi      # 0x31e2
leaq 0x199e(%rip), %rsi      # 0x3025
leaq 0x19a2(%rip), %rcx      # 0x3030
pushq $0x7f
jmp 0x14e1
nopl (%rax)