// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xe36cb(%rip), %rsi     # 0xe9352
callq 0xa310
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x5ca2
movl $0x1, -0x4(%rbp)
jmp 0x6327
movq -0x18(%rbp), %rdi
callq 0x239f0
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x5cc1
movl $0x1, -0x4(%rbp)
jmp 0x6327
movq -0x20(%rbp), %rdi
leaq 0xe04be(%rip), %rsi     # 0xe618a
xorl %r8d, %r8d
leaq 0xe0c24(%rip), %rcx     # 0xe68fa
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movl %r8d, %edx
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0358(%rip), %rsi     # 0xe6054
xorl %r8d, %r8d
leaq 0xe0bf4(%rip), %rcx     # 0xe68fa
movl $0x31, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movl %r8d, %edx
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0327(%rip), %rsi     # 0xe6054
movl $0x2, %edx
leaq 0xe0bc1(%rip), %rcx     # 0xe68fa
xorl %r8d, %r8d
movl $0x31, %r9d
movq $0x32, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0302(%rip), %rsi     # 0xe605c
xorl %r8d, %r8d
leaq 0xe0b96(%rip), %rcx     # 0xe68fa
movl $0x31, %r9d
movl %r8d, %edx
movq $0x64, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe02e3(%rip), %rsi     # 0xe6068
xorl %r8d, %r8d
leaq 0xe0b6b(%rip), %rcx     # 0xe68fa
movl $0x31, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movl %r8d, %edx
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe02bb(%rip), %rsi     # 0xe6071
xorl %r8d, %r8d
leaq 0xe0b3a(%rip), %rcx     # 0xe68fa
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq $0x32, (%rsp)
callq 0x5aa0
movq 0xfe204(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xe0294(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xe0293(%rip), %rsi     # 0xe608b
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe027a(%rip), %rsi     # 0xe6098
xorl %r8d, %r8d
leaq 0xe0ad2(%rip), %rcx     # 0xe68fa
movl $0x63, %r9d
movl %r8d, %edx
movq $0xc8, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe025e(%rip), %rsi     # 0xe60a7
xorl %edx, %edx
leaq 0xe0aa8(%rip), %rcx     # 0xe68fa
movl $0x2, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe023b(%rip), %rsi     # 0xe60b6
xorl %edx, %edx
leaq 0xe0a76(%rip), %rcx     # 0xe68fa
movl $0x2, %r8d
movl $0x63, %r9d
movq $0xc8, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0225(%rip), %rsi     # 0xe60cd
xorl %edx, %edx
leaq 0xe0a49(%rip), %rcx     # 0xe68fa
movl $0x3, %r8d
movl $0x63, %r9d
movq $0xc8, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe020f(%rip), %rsi     # 0xe60e4
xorl %edx, %edx
leaq 0xe0a1c(%rip), %rcx     # 0xe68fa
movl $0x3, %r8d
movl $0x63, %r9d
movq $0xc8, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe01f7(%rip), %rsi     # 0xe60f9
xorl %edx, %edx
leaq 0xe09ef(%rip), %rcx     # 0xe68fa
movl $0x3, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0239(%rip), %rsi     # 0xe616d
xorl %edx, %edx
leaq 0xe09bd(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe01a0(%rip), %rsi     # 0xe6106
xorl %edx, %edx
leaq 0xe098b(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0174(%rip), %rsi     # 0xe610c
xorl %edx, %edx
leaq 0xe0959(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
movl $0x3e7, %r9d            # imm = 0x3E7
movq $0x5dc, (%rsp)          # imm = 0x5DC
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0156(%rip), %rsi     # 0xe611b
xorl %edx, %edx
leaq 0xe092c(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
movl $0x3e7, %r9d            # imm = 0x3E7
movq $0x5dc, (%rsp)          # imm = 0x5DC
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe013a(%rip), %rsi     # 0xe612c
xorl %edx, %edx
leaq 0xe08ff(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
movl $0x3e7, %r9d            # imm = 0x3E7
movq $0x5dc, (%rsp)          # imm = 0x5DC
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe011a(%rip), %rsi     # 0xe6139
xorl %edx, %edx
leaq 0xe08d2(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
movl $0x3e7, %r9d            # imm = 0x3E7
movq $0x5dc, (%rsp)          # imm = 0x5DC
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe00fc(%rip), %rsi     # 0xe6148
xorl %edx, %edx
leaq 0xe08a5(%rip), %rcx     # 0xe68fa
movl $0x4, %r8d
movl $0x3e7, %r9d            # imm = 0x3E7
movq $0x5dc, (%rsp)          # imm = 0x5DC
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe00dd(%rip), %rsi     # 0xe6156
movl $0x4, %edx
leaq 0xe00e8(%rip), %rcx     # 0xe616d
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq 0xfdf39(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdffc9(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xe009d(%rip), %rsi     # 0xe6160
movl $0x4, %edx
xorl %eax, %eax
movl %eax, %r9d
xorl %r8d, %r8d
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe0087(%rip), %rsi     # 0xe6172
movl $0x4, %edx
leaq 0xe0803(%rip), %rcx     # 0xe68fa
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe005e(%rip), %rsi     # 0xe617e
movl $0x4, %edx
leaq 0xe005e(%rip), %rcx     # 0xe618a
movl $0x5, %r8d
xorl %eax, %eax
movl %eax, %r9d
movabsq $0x7fffffff7fffffff, %rax # imm = 0x7FFFFFFF7FFFFFFF
movq %rax, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xdffc6(%rip), %rsi     # 0xe611b
movl $0x6, %edx
leaq 0xdffc1(%rip), %rcx     # 0xe6122
movl $0x4, %r8d
xorl %eax, %eax
movl %eax, %r9d
movq $0x1, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xe000b(%rip), %rsi     # 0xe618f
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xdffea(%rip), %rsi     # 0xe6194
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq 0xfde14(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfea4(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xdffb2(%rip), %rsi     # 0xe619a
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xdff92(%rip), %rsi     # 0xe61a0
xorl %r8d, %r8d
leaq 0xe06e2(%rip), %rcx     # 0xe68fa
movl $0x9, %r9d
movl %r8d, %edx
movq $0xa, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
leaq 0xdff72(%rip), %rsi     # 0xe61ab
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq 0xfdd85(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfe15(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xdff3e(%rip), %rsi     # 0xe61b5
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq 0xfdd47(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfdd7(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xdff07(%rip), %rsi     # 0xe61bc
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq 0xfdd09(%rip), %rax     # 0x103fe0
movq (%rax), %rdi
leaq 0xdfd99(%rip), %rsi     # 0xe607a
movb $0x0, %al
callq 0x46d0
movq -0x20(%rbp), %rdi
leaq 0xdfed2(%rip), %rsi     # 0xe61c5
xorl %r8d, %r8d
xorl %eax, %eax
movl %eax, %r9d
movl %r8d, %edx
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x5aa0
movq -0x20(%rbp), %rdi
callq 0x1df90
movq -0x18(%rbp), %rdi
callq 0xc430
xorl %edi, %edi
callq 0x45c0
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq