// File: /workspace/github_c_makefile_star2_O3/JulStrat[P]bams/test_bams_ptr.c
// Function: main
int
main(int argc, char *argv[])
{
    BAMS *bas;
    char **keys;
    char **lt_keys = NULL, **eq_keys = NULL, **gt_keys = NULL;
    size_t bas_sz = 0;
    int i;
    FILE *shuff;
    char bf[1024];
    char *key;
    size_t lt_num = 0, eq_num = 0, gt_num = 0;

    shuff = fopen(argv[1], "r");
    bas = bams_create(0, cmp_str);

    while (fgets(bf, 1024, shuff)) {
        key = malloc(strlen(bf) + 1);
        strcpy(key, bf);
        bams_insert(bas, key);
    }
    fclose(shuff);

    lt_keys = bams_less(bas, "obelisk", &lt_num);
    assert(lt_num == bams_count_less(bas, "obelisk"));

    eq_keys = bams_equal(bas, "obelisk", &eq_num);
    assert(eq_num == bams_count_equal(bas, "obelisk"));

    gt_keys = bams_great(bas, "obelisk", &gt_num);
    assert(gt_num == bams_count_great(bas, "obelisk"));

    assert(bams_size(bas) == (lt_num + eq_num + gt_num));

    for (i = 0; i < lt_num; i++) {
        printf("%s", lt_keys[i]);
        free(lt_keys[i]);
    }

    for (i = 0; i < eq_num; i++) {
        printf("%s", eq_keys[i]);
        free(eq_keys[i]);
    }

    for (i = 0; i < gt_num; i++) {
        printf("%s", gt_keys[i]);
        free(gt_keys[i]);
    }

    free(lt_keys);
    free(eq_keys);
    free(gt_keys);

    /*
     * keys = bams_array(bas, &bas_sz); 
     */

    /*
     * keys = bams_less(bas, "b", &bas_sz); 
     */

    /*
     * for (i = 0; i < bas_sz; i++) { printf("%s", keys[i]); free(keys[i]); }
     * 
     * free(keys); 
     */

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

    bams_free(bas);
    /*
     * qsort(&argv[1], argc-1, sizeof (char *), cmp_str); for (i = 1; i <
     * argc; i++) { printf("%s\n", argv[i]); } 
     */
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rax, 0x8(%rsp)
movq 0x8(%rsi), %rdi
leaq 0x22e0(%rip), %rsi      # 0x3504
callq 0x10e0
movq %rax, %r14
leaq -0x47(%rip), %rsi       # 0x11ec
xorl %edi, %edi
callq 0x18eb
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x1090
testq %rax, %rax
je 0x1298
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x1060
leaq 0x1(%rax), %rdi
callq 0x10c0
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x1040
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1952
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x1090
testq %rax, %rax
jne 0x1259
movq %r14, %rdi
callq 0x1050
leaq 0x1d5d(%rip), %r15      # 0x3004
leaq 0x18(%rsp), %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1f0d
movq %rax, %r14
movq (%r12), %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c46
cmpq %rax, %r12
jne 0x142c
leaq 0x1d28(%rip), %r12      # 0x3004
leaq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2068
movq %rax, %r15
movq (%r13), %r13
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1d2a
cmpq %rax, %r13
jne 0x144b
leaq 0x1cf3(%rip), %r13      # 0x3004
leaq 0x8(%rsp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2231
movq %rax, %r12
movq (%rbp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1e21
cmpq %rax, %rbp
jne 0x146a
movq %rbx, %rdi
callq 0x2431
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
leaq (%rcx,%rdx), %rsi
addq 0x8(%rsp), %rsi
cmpq %rsi, %rax
jne 0x1489
testq %rdx, %rdx
je 0x1397
leaq 0x1d71(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
movq (%r14,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r14,%rbp,8), %rdi
callq 0x1030
incq %rbp
cmpq %rbp, 0x18(%rsp)
ja 0x1371
movq 0x10(%rsp), %rcx
testq %rcx, %rcx
je 0x13c6
leaq 0x1d3d(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
movq (%r15,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r15,%rbp,8), %rdi
callq 0x1030
incq %rbp
cmpq %rbp, 0x10(%rsp)
ja 0x13a5
cmpq $0x0, 0x8(%rsp)
je 0x13f8
leaq 0x1d0b(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
movq (%r12,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r12,%rbp,8), %rdi
callq 0x1030
incq %rbp
cmpq %rbp, 0x8(%rsp)
ja 0x13d7
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x24bc
xorl %eax, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1bd9(%rip), %rdi      # 0x300c
leaq 0x1bfc(%rip), %rsi      # 0x3036
leaq 0x1c05(%rip), %rcx      # 0x3046
movl $0x28, %edx
callq 0x1080
leaq 0x1c0b(%rip), %rdi      # 0x305d
leaq 0x1bdd(%rip), %rsi      # 0x3036
leaq 0x1be6(%rip), %rcx      # 0x3046
movl $0x2b, %edx
callq 0x1080
leaq 0x1c17(%rip), %rdi      # 0x3088
leaq 0x1bbe(%rip), %rsi      # 0x3036
leaq 0x1bc7(%rip), %rcx      # 0x3046
movl $0x2e, %edx
callq 0x1080
leaq 0x1c23(%rip), %rdi      # 0x30b3
leaq 0x1b9f(%rip), %rsi      # 0x3036
leaq 0x1ba8(%rip), %rcx      # 0x3046
movl $0x30, %edx
callq 0x1080