// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x1, -0x8(%rbp)
jle 0x63f1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xdfe6b(%rip), %rsi     # 0xe61d1
callq 0x4690
cmpl $0x0, %eax
jne 0x6390
movl -0x24(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x634d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xdfe35(%rip), %rsi     # 0xe61d4
callq 0x4690
cmpl $0x0, %eax
jne 0x63c9
movl -0x24(%rbp), %eax
orl $0x2, %eax
movl %eax, -0x24(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
jmp 0x634d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xdfdff(%rip), %rsi     # 0xe61d7
callq 0x4690
cmpl $0x0, %eax
jne 0x63ef
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x5c70
jmp 0x63f1
cmpl $0x3, -0x8(%rbp)
je 0x6419
movq 0xfdbe2(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfdd2(%rip), %rsi     # 0xe61da
movb $0x0, %al
callq 0x46d0
movl $0x1, %edi
callq 0x45c0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe2f2a(%rip), %rsi     # 0xe9352
callq 0xa310
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x644e
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x43c0
movl $0x1, %edi
callq 0x45c0
movq -0x20(%rbp), %rdi
callq 0x239f0
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x6483
movq 0xfdb78(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfd9c(%rip), %rsi     # 0xe620e
movb $0x0, %al
callq 0x46d0
movl $0x1, %edi
callq 0x45c0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x652c
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %r9d
leaq -0x34(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x1ee50
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x64e6
movq 0xfdb15(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfd4f(%rip), %rsi     # 0xe6224
movb $0x0, %al
callq 0x46d0
movl $0x1, %edi
callq 0x45c0
cmpl $-0x1, -0x34(%rbp)
jne 0x64f9
leaq 0xe3031(%rip), %rax     # 0xe9524
movq %rax, -0x50(%rbp)
jmp 0x650d
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0xdfd1c(%rip), %rdi     # 0xe623c
movb $0x0, %al
callq 0x4060
jmp 0x648f
movq -0x18(%rbp), %rdi
callq 0x1df90
movq -0x20(%rbp), %rdi
callq 0xc430
xorl %eax, %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)