// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/test-parse-reg.c
// Function: main
int main(int argc, char **argv) {
    sam_hdr_t *hdr;
    samFile *fp;
    int flags = 0;

    while (argc > 1) {
        if (strcmp(argv[1], "-m") == 0) {
            flags |= HTS_PARSE_LIST;
            argc--; argv++;
            continue;
        }

        if (strcmp(argv[1], "-c") == 0) {
            flags |= HTS_PARSE_ONE_COORD;
            argc--; argv++;
            continue;
        }

        // Automatic mode for test harness
        if (strcmp(argv[1], "-t") == 0)
            reg_test(argv[2]);

        break;
    }

    // Interactive mode for debugging
    if (argc != 3) {
        fprintf(stderr, "Usage: test-parse-reg [-m] [-c] region[,region]...\n");
        exit(1);
    }

    if (!(fp = sam_open(argv[1], "r"))) {
        perror(argv[1]);
        exit(1);
    }

    if (!(hdr = sam_hdr_read(fp))) {
        fprintf(stderr, "Couldn't read header\n");
        exit(1);
    }

    const char *reg = argv[2];
    while (*reg) {
        int tid;
        hts_pos_t beg, end;
        reg = sam_parse_region(hdr, reg, &tid, &beg, &end, flags);
        if (!reg) {
            fprintf(stderr, "Failed to parse region\n");
            exit(1);
        }
        printf("%-20s %12"PRIhts_pos" %12"PRIhts_pos"\n",
               tid == -1 ? "*" : hdr->target_name[tid],
               beg, end);
    }

    sam_hdr_destroy(hdr);
    sam_close(fp);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
movl %edi, %ebp
addq $0x8, %r14
xorl %ebx, %ebx
pushq $0x4
popq %rax
pushq $0x2
popq %rcx
cmpl $0x2, %ebp
jl 0x623c
movq (%r14), %rdx
cmpb $0x2d, (%rdx)
jne 0x615d
cmpb $0x6d, 0x1(%rdx)
jne 0x6130
cmpb $0x0, 0x2(%rdx)
movl %eax, %esi
je 0x613e
cmpb $0x63, 0x1(%rdx)
jne 0x6148
cmpb $0x0, 0x2(%rdx)
movl %ecx, %esi
jne 0x6148
orl %esi, %ebx
decl %ebp
addq $0x8, %r14
jmp 0x6111
cmpb $0x74, 0x1(%rdx)
jne 0x615d
cmpb $0x0, 0x2(%rdx)
jne 0x615d
movq 0x8(%r14), %rdi
callq 0x5b9d
cmpl $0x3, %ebp
jne 0x623c
movq (%r14), %rdi
leaq 0x6df17(%rip), %rsi     # 0x74087
callq 0x84c7
testq %rax, %rax
je 0x6260
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x1600e
testq %rax, %rax
je 0x626a
movq %rax, %r12
movq 0x8(%r14), %r14
leaq 0x18(%rsp), %rbp
leaq 0x6e0b2(%rip), %r13     # 0x74259
leaq 0x6b085(%rip), %r15     # 0x71233
cmpb $0x0, (%r14)
je 0x6204
movq %r12, %rdi
movq %r14, %rsi
leaq 0xc(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq %rbp, %r8
movl %ebx, %r9d
callq 0x13857
testq %rax, %rax
je 0x6227
movq %rax, %r14
movslq 0xc(%rsp), %rax
movq %r13, %rsi
cmpq $-0x1, %rax
je 0x61ee
movq 0x20(%r12), %rcx
movq (%rcx,%rax,8), %rsi
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq %r15, %rdi
xorl %eax, %eax
callq 0x4060
jmp 0x61ae
movq %r12, %rdi
callq 0x12fde
movq 0x10(%rsp), %rdi
callq 0x969d
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x90db2(%rip), %rax     # 0x96fe0
movq (%rax), %rcx
leaq 0x6afe3(%rip), %rdi     # 0x7121b
pushq $0x17
jmp 0x624f
movq 0x90d9d(%rip), %rax     # 0x96fe0
movq (%rax), %rcx
leaq 0x6af84(%rip), %rdi     # 0x711d1
pushq $0x33
popq %rsi
pushq $0x1
popq %rdx
callq 0x4990
pushq $0x1
popq %rdi
callq 0x45e0
movq (%r14), %rdi
callq 0x43d0
jmp 0x6258
movq 0x90d6f(%rip), %rax     # 0x96fe0
movq (%rax), %rcx
leaq 0x6af8a(%rip), %rdi     # 0x71205
pushq $0x15
jmp 0x624f
nop