// File: /workspace/github_c_makefile_star2_O1/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 0x1956
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 0x1f18
movq %rax, %r14
movq (%r12), %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1c51
cmpq %rax, %r12
jne 0x1429
leaq 0x1d28(%rip), %r12      # 0x3004
leaq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2073
movq %rax, %r15
movq (%r13), %r13
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1d35
cmpq %rax, %r13
jne 0x1448
leaq 0x1cf3(%rip), %r13      # 0x3004
leaq 0x8(%rsp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x223c
movq %rax, %r12
movq (%rbp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1e2c
cmpq %rax, %rbp
jne 0x1467
movq %rbx, %rdi
callq 0x2433
movq 0x10(%rsp), %rcx
addq 0x18(%rsp), %rcx
addq 0x8(%rsp), %rcx
cmpq %rcx, %rax
jne 0x1486
cmpq $0x0, 0x18(%rsp)
je 0x1391
leaq 0x1d72(%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 0x1370
cmpq $0x0, 0x10(%rsp)
je 0x13c3
leaq 0x1d40(%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 0x13a2
cmpq $0x0, 0x8(%rsp)
je 0x13f5
leaq 0x1d0e(%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 0x13d4
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x24be
xorl %eax, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1bdc(%rip), %rdi      # 0x300c
leaq 0x1bff(%rip), %rsi      # 0x3036
leaq 0x1c08(%rip), %rcx      # 0x3046
movl $0x28, %edx
callq 0x1080
leaq 0x1c0e(%rip), %rdi      # 0x305d
leaq 0x1be0(%rip), %rsi      # 0x3036
leaq 0x1be9(%rip), %rcx      # 0x3046
movl $0x2b, %edx
callq 0x1080
leaq 0x1c1a(%rip), %rdi      # 0x3088
leaq 0x1bc1(%rip), %rsi      # 0x3036
leaq 0x1bca(%rip), %rcx      # 0x3046
movl $0x2e, %edx
callq 0x1080
leaq 0x1c26(%rip), %rdi      # 0x30b3
leaq 0x1ba2(%rip), %rsi      # 0x3036
leaq 0x1bab(%rip), %rcx      # 0x3046
movl $0x30, %edx
callq 0x1080
nopl (%rax)