// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x460(%rbp)
movq $0x0, -0x468(%rbp)
movq $0x0, -0x470(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x227b(%rip), %rsi      # 0x3504
callq 0x10e0
movq %rax, -0x50(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq -0xad(%rip), %rsi       # 0x11f0
callq 0x1c40
movq %rax, -0x18(%rbp)
leaq -0x450(%rbp), %rdi
movq -0x50(%rbp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x1090
cmpq $0x0, %rax
je 0x1305
leaq -0x450(%rbp), %rdi
callq 0x1060
movq %rax, %rdi
addq $0x1, %rdi
callq 0x10c0
movq %rax, -0x458(%rbp)
movq -0x458(%rbp), %rdi
leaq -0x450(%rbp), %rsi
callq 0x1040
movq -0x18(%rbp), %rdi
movq -0x458(%rbp), %rsi
callq 0x1d10
jmp 0x12a6
movq -0x50(%rbp), %rdi
callq 0x1050
movq -0x18(%rbp), %rdi
leaq 0x1ceb(%rip), %rsi      # 0x3004
leaq -0x460(%rbp), %rdx
callq 0x2600
movq %rax, -0x28(%rbp)
movq -0x460(%rbp), %rax
movq %rax, -0x478(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1cc2(%rip), %rsi      # 0x3004
callq 0x2210
movq %rax, %rcx
movq -0x478(%rbp), %rax
cmpq %rcx, %rax
jne 0x1358
jmp 0x1377
leaq 0x1cad(%rip), %rdi      # 0x300c
leaq 0x1cd0(%rip), %rsi      # 0x3036
movl $0x28, %edx
leaq 0x1cd4(%rip), %rcx      # 0x3046
callq 0x1080
movq -0x18(%rbp), %rdi
leaq 0x1c82(%rip), %rsi      # 0x3004
leaq -0x468(%rbp), %rdx
callq 0x27c0
movq %rax, -0x30(%rbp)
movq -0x468(%rbp), %rax
movq %rax, -0x480(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1c59(%rip), %rsi      # 0x3004
callq 0x2350
movq %rax, %rcx
movq -0x480(%rbp), %rax
cmpq %rcx, %rax
jne 0x13c1
jmp 0x13e0
leaq 0x1c95(%rip), %rdi      # 0x305d
leaq 0x1c67(%rip), %rsi      # 0x3036
movl $0x2b, %edx
leaq 0x1c6b(%rip), %rcx      # 0x3046
callq 0x1080
movq -0x18(%rbp), %rdi
leaq 0x1c19(%rip), %rsi      # 0x3004
leaq -0x470(%rbp), %rdx
callq 0x29e0
movq %rax, -0x38(%rbp)
movq -0x470(%rbp), %rax
movq %rax, -0x488(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1bf0(%rip), %rsi      # 0x3004
callq 0x24b0
movq %rax, %rcx
movq -0x488(%rbp), %rax
cmpq %rcx, %rax
jne 0x142a
jmp 0x1449
leaq 0x1c57(%rip), %rdi      # 0x3088
leaq 0x1bfe(%rip), %rsi      # 0x3036
movl $0x2e, %edx
leaq 0x1c02(%rip), %rcx      # 0x3046
callq 0x1080
movq -0x18(%rbp), %rdi
callq 0x2ca0
movq -0x460(%rbp), %rcx
addq -0x468(%rbp), %rcx
addq -0x470(%rbp), %rcx
cmpq %rcx, %rax
jne 0x146e
jmp 0x148d
leaq 0x1c3e(%rip), %rdi      # 0x30b3
leaq 0x1bba(%rip), %rsi      # 0x3036
movl $0x30, %edx
leaq 0x1bbe(%rip), %rcx      # 0x3046
callq 0x1080
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
cmpq -0x460(%rbp), %rax
jae 0x14d7
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1c2c(%rip), %rdi      # 0x30e0
movb $0x0, %al
callq 0x1070
movq -0x28(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1494
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
cmpq -0x468(%rbp), %rax
jae 0x1521
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1be2(%rip), %rdi      # 0x30e0
movb $0x0, %al
callq 0x1070
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x14de
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
cmpq -0x470(%rbp), %rax
jae 0x156b
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x1b98(%rip), %rdi      # 0x30e0
movb $0x0, %al
callq 0x1070
movq -0x38(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1528
movq -0x28(%rbp), %rdi
callq 0x1030
movq -0x30(%rbp), %rdi
callq 0x1030
movq -0x38(%rbp), %rdi
callq 0x1030
movq -0x18(%rbp), %rdi
callq 0x2d90
xorl %eax, %eax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
nopw (%rax,%rax)