// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x18(%rsp)
andq $0x0, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
movq 0x8(%rsi), %rdi
leaq 0x22df(%rip), %rsi      # 0x3504
callq 0x10e0
movq %rax, %r14
leaq -0x48(%rip), %rsi       # 0x11ec
xorl %edi, %edi
callq 0x185a
movq %rax, %rbx
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdx
callq 0x1090
testq %rax, %rax
je 0x1284
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 0x18bb
jmp 0x1243
movq %r14, %rdi
callq 0x1050
leaq 0x1d71(%rip), %r15      # 0x3004
leaq 0x18(%rsp), %r12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1e58
movq %rax, %r14
movq (%r12), %r12
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1b91
cmpq %rax, %r12
jne 0x1409
leaq 0x1d3c(%rip), %r12      # 0x3004
leaq 0x10(%rsp), %r13
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1fa3
movq %rax, %r15
movq (%r13), %r13
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1c75
cmpq %rax, %r13
jne 0x1422
leaq 0x1d07(%rip), %r13      # 0x3004
leaq 0x8(%rsp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0x2163
movq %rax, %r12
movq (%rbp), %rbp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1d6c
cmpq %rax, %rbp
jne 0x143b
movq %rbx, %rdi
callq 0x2349
movq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rdx
addq %rcx, %rdx
addq 0x8(%rsp), %rdx
cmpq %rdx, %rax
jne 0x1454
leaq 0x1d8b(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
cmpq %rbp, %rcx
jbe 0x137d
movq (%r14,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r14,%rbp,8), %rdi
callq 0x1030
incq %rbp
movq 0x18(%rsp), %rcx
jmp 0x1357
leaq 0x1d5c(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
cmpq %rbp, 0x10(%rsp)
jbe 0x13a9
movq (%r15,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r15,%rbp,8), %rdi
callq 0x1030
incq %rbp
jmp 0x1386
leaq 0x1d30(%rip), %r13      # 0x30e0
xorl %ebp, %ebp
cmpq %rbp, 0x8(%rsp)
jbe 0x13d5
movq (%r12,%rbp,8), %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1070
movq (%r12,%rbp,8), %rdi
callq 0x1030
incq %rbp
jmp 0x13b2
movq %r14, %rdi
callq 0x1030
movq %r15, %rdi
callq 0x1030
movq %r12, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x23d1
xorl %eax, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1bfc(%rip), %rdi      # 0x300c
leaq 0x1c1f(%rip), %rsi      # 0x3036
leaq 0x1c28(%rip), %rcx      # 0x3046
pushq $0x28
jmp 0x146b
leaq 0x1c34(%rip), %rdi      # 0x305d
leaq 0x1c06(%rip), %rsi      # 0x3036
leaq 0x1c0f(%rip), %rcx      # 0x3046
pushq $0x2b
jmp 0x146b
leaq 0x1c46(%rip), %rdi      # 0x3088
leaq 0x1bed(%rip), %rsi      # 0x3036
leaq 0x1bf6(%rip), %rcx      # 0x3046
pushq $0x2e
jmp 0x146b
leaq 0x1c58(%rip), %rdi      # 0x30b3
leaq 0x1bd4(%rip), %rsi      # 0x3036
leaq 0x1bdd(%rip), %rcx      # 0x3046
pushq $0x30
popq %rdx
callq 0x1080
nopl (%rax)