// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/test-parse-reg.c
// Function: reg_test
int reg_test(char *fn) {
    samFile *fp;
    sam_hdr_t *hdr;

    if (!(fp = sam_open(fn, "r")))
        return 1;

    if (!(hdr = sam_hdr_read(fp)))
        return 1;

    // 0 chr1
    // 1 chr1:100
    // 2 chr1:100-200
    // 3 chr2:100-200
    // 4 chr3
    // 5 chr1,chr3

    // Check range extensions.
    reg_expected(hdr, "chr1", 0, "",  0, 0, HTS_POS_MAX);
    reg_expected(hdr, "chr1:50", 0, "",  0, 49, HTS_POS_MAX);
    reg_expected(hdr, "chr1:50", HTS_PARSE_ONE_COORD, "",  0, 49, 50);
    reg_expected(hdr, "chr1:50-100", 0, "",  0, 49, 100);
    reg_expected(hdr, "chr1:50-", 0, "",  0, 49, HTS_POS_MAX);
    reg_expected(hdr, "chr1:-50", 0, "",  0, 0, 50);

    // Check quoting
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "chr1:100-200", 0, NULL,  0, 0, 0); // ambiguous
    reg_expected(hdr, "{chr1}:100-200", 0, "",  0, 99, 200);
    reg_expected(hdr, "{chr1:100-200}", 0, "",  2, 0, HTS_POS_MAX);
    reg_expected(hdr, "{chr1:100-200}:100-200", 0, "",  2, 99, 200);
    reg_expected(hdr, "{chr2:100-200}:100-200", 0, "",  3, 99, 200);
    reg_expected(hdr, "chr2:100-200:100-200", 0, "",  3, 99, 200);
    reg_expected(hdr, "chr2:100-200", 0, "",  3, 0, HTS_POS_MAX);

    // Check numerics
    reg_expected(hdr, "chr3", 0, "",  4, 0, HTS_POS_MAX);
    reg_expected(hdr, "chr3:", 0, "",  4, 0, HTS_POS_MAX);
    reg_expected(hdr, "chr3:1000-1500", 0, "",  4, 999, 1500);
    reg_expected(hdr, "chr3:1,000-1,500", 0, "",  4, 999, 1500);
    reg_expected(hdr, "chr3:1k-1.5K", 0, "",  4, 999, 1500);
    reg_expected(hdr, "chr3:1e3-1.5e3", 0, "",  4, 999, 1500);
    reg_expected(hdr, "chr3:1e3-15e2", 0, "",  4, 999, 1500);

    // Check list mode
    reg_expected(hdr, "chr1,chr3", HTS_PARSE_LIST, "chr3", 0, 0, HTS_POS_MAX);
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "chr1:100-200,chr3", HTS_PARSE_LIST, NULL,  0, 0, 0); // ambiguous
    reg_expected(hdr, "{chr1,chr3}", HTS_PARSE_LIST, "", 5, 0, HTS_POS_MAX);
    reg_expected(hdr, "{chr1,chr3},chr1", HTS_PARSE_LIST, "chr1", 5, 0, HTS_POS_MAX);
    // incorrect usage; first reg is valid (but not what user expects).
    reg_expected(hdr, "chr3:1,000-1,500", HTS_PARSE_LIST | HTS_PARSE_ONE_COORD, "000-1,500",  4, 0, 1);

    // More expected failures
    reg_expected(hdr, "chr2", 0, NULL, 0, 0, 0);
    reg_expected(hdr, "chr1,", 0, NULL, 0, 0, 0);
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "{chr1", 0, NULL, 0, 0, 0);
    reg_expected(hdr, "chr1:10-10", 0, "", 0, 9, 10); // OK
    reg_expected(hdr, "chr1:10-9", 0, NULL, 0, 0, 0); // Issue#353
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "chr1:x", 0, NULL, 0, 0, 0);
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "chr1:1-y", 0, NULL, 0, 0, 0);
    fprintf(stderr, "Expected error: ");
    reg_expected(hdr, "chr1:1,chr3", 0, NULL, 0, 0, 0);

    sam_hdr_destroy(hdr);
    sam_close(fp);

    exit(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x6e4d8(%rip), %rsi     # 0x74087
callq 0x84c7
testq %rax, %rax
je 0x5bc9
movq %rax, %rbx
movq %rax, %rdi
callq 0x1600e
testq %rax, %rax
jne 0x5bdb
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
movq %rax, %r12
leaq 0x6b594(%rip), %rsi     # 0x7118a
leaq 0x6bcf9(%rip), %r15     # 0x718f6
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b439(%rip), %r13     # 0x71054
pushq $0x31
popq %r12
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x5a9c
pushq $0x32
popq %rbp
movq %rbp, (%rsp)
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x5a9c
movq $0x64, (%rsp)
leaq 0x6b3fa(%rip), %rsi     # 0x7105c
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x5a9c
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
leaq 0x6b3de(%rip), %rsi     # 0x71068
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x5a9c
movq %rbp, (%rsp)
leaq 0x6b3c9(%rip), %rsi     # 0x71071
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq 0x9131e(%rip), %rax     # 0x96fe0
movq (%rax), %rcx
leaq 0x6b3ae(%rip), %rdi     # 0x7107a
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b3a8(%rip), %rsi     # 0x7108b
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movl $0xc8, %r13d
movq %r13, (%rsp)
leaq 0x6b392(%rip), %rsi     # 0x71098
pushq $0x63
popq %r12
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
xorl %r8d, %r8d
movq %r12, %r9
callq 0x5a9c
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
leaq 0x6b375(%rip), %rsi     # 0x710a7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
pushq $0x2
popq %rbp
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r13, (%rsp)
leaq 0x6b363(%rip), %rsi     # 0x710b6
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
movq %r12, %r9
callq 0x5a9c
movq %r13, (%rsp)
leaq 0x6b35c(%rip), %rsi     # 0x710cd
pushq $0x3
popq %rbp
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
movq %r12, %r9
callq 0x5a9c
movq %r13, (%rsp)
leaq 0x6b352(%rip), %rsi     # 0x710e4
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
movq %r12, %r9
callq 0x5a9c
movabsq $0x7fffffff7fffffff, %r12 # imm = 0x7FFFFFFF7FFFFFFF
movq %r12, (%rsp)
leaq 0x6b33f(%rip), %rsi     # 0x710f9
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b395(%rip), %r13     # 0x7116d
pushq $0x4
popq %rbp
movq %r14, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b30a(%rip), %rsi     # 0x71106
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movl $0x5dc, %r12d           # imm = 0x5DC
movq %r12, (%rsp)
leaq 0x6b2ec(%rip), %rsi     # 0x7110c
movl $0x3e7, %r9d            # imm = 0x3E7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b2da(%rip), %rsi     # 0x7111b
movl $0x3e7, %r9d            # imm = 0x3E7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b2ca(%rip), %rsi     # 0x7112c
movl $0x3e7, %r9d            # imm = 0x3E7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b2b6(%rip), %rsi     # 0x71139
movl $0x3e7, %r9d            # imm = 0x3E7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x5a9c
movq %r12, (%rsp)
leaq 0x6b2a4(%rip), %rsi     # 0x71148
movl $0x3e7, %r9d            # imm = 0x3E7
movq %r14, %rdi
xorl %edx, %edx
movq %r15, %rcx
movl %ebp, %r8d
callq 0x5a9c
movabsq $0x7fffffff7fffffff, %r15 # imm = 0x7FFFFFFF7FFFFFFF
movq %r15, (%rsp)
leaq 0x6b287(%rip), %rsi     # 0x71156
movq %r14, %rdi
movl %ebp, %edx
movq %r13, %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq 0x910f7(%rip), %r12     # 0x96fe0
movq (%r12), %rcx
leaq 0x6b186(%rip), %rdi     # 0x7107a
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b255(%rip), %rsi     # 0x71160
movq %r14, %rdi
movl %ebp, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r15, (%rsp)
leaq 0x6b24a(%rip), %rsi     # 0x71172
pushq $0x5
popq %r13
movq %r14, %rdi
movl %ebp, %edx
leaq 0x6b9be(%rip), %rcx     # 0x718f6
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r15, (%rsp)
leaq 0x6b230(%rip), %rsi     # 0x7117e
movq %r14, %rdi
movl %ebp, %edx
leaq 0x6b230(%rip), %rcx     # 0x7118a
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq $0x1, (%rsp)
leaq 0x6b1ae(%rip), %rcx     # 0x71122
pushq $0x6
popq %rdx
movq %r14, %rdi
leaq 0x6b19a(%rip), %rsi     # 0x7111b
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x5a9c
andq $0x0, (%rsp)
leaq 0x6b1f7(%rip), %rsi     # 0x7118f
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
andq $0x0, (%rsp)
leaq 0x6b1de(%rip), %rsi     # 0x71194
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq (%r12), %rcx
leaq 0x6b0a7(%rip), %r13     # 0x7107a
movq %r13, %rdi
pushq $0x10
popq %rbp
movq %rbp, %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b1a6(%rip), %rsi     # 0x7119a
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq $0xa, (%rsp)
leaq 0x6b18b(%rip), %rsi     # 0x711a0
pushq $0x9
popq %r9
movq %r14, %rdi
xorl %edx, %edx
leaq 0x6b8d1(%rip), %rcx     # 0x718f6
xorl %r8d, %r8d
callq 0x5a9c
andq $0x0, (%rsp)
leaq 0x6b172(%rip), %rsi     # 0x711ab
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq (%r12), %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b14c(%rip), %rsi     # 0x711b5
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq (%r12), %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b123(%rip), %rsi     # 0x711bc
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq (%r12), %rcx
movq %r13, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x4990
andq $0x0, (%rsp)
leaq 0x6b0fc(%rip), %rsi     # 0x711c5
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x5a9c
movq %r14, %rdi
callq 0x12fde
movq %rbx, %rdi
callq 0x969d
xorl %edi, %edi
callq 0x45e0