// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test-regidx.c
// Function: test
void test(set_line_f set_line, regidx_parse_f parse)
{
    regidx_t *idx = regidx_init(NULL,parse,NULL,0,NULL);
    if ( !idx ) error("init failed\n");

    char line[250], *chr = "1";
    int i, n = 10, start, end, nhit;
    for (i=1; i<n; i++)
    {
        start = end = 10*i;
        set_line(line,sizeof(line),chr,start,end);
        debug("insert: %s", line);
        if ( regidx_insert(idx,line)!=0 ) error("insert failed: %s\n", line);

        start = end = 10*i + 1;
        set_line(line,sizeof(line),chr,start,end);
        debug("insert: %s", line);
        if ( regidx_insert(idx,line)!=0 ) error("insert failed: %s\n", line);

        start = 20000*i; end = start + 2000;
        set_line(line,sizeof(line),chr,start,end);
        debug("insert: %s", line);
        if ( regidx_insert(idx,line)!=0 ) error("insert failed: %s\n", line);
    }

    regitr_t *itr = regitr_init(idx);
    for (i=1; i<n; i++)
    {
        // no hit
        start = end = 10*i - 1;
        if ( regidx_overlap(idx,chr,start-1,end-1,itr) ) error("query failed, there should be no hit: %s:%d-%d\n",chr,start,end);
        debug("ok: no overlap found for %s:%d-%d\n",chr,start,end);


        // one hit
        start = end = 10*i;
        if ( !regidx_overlap(idx,chr,start-1,end-1,itr) ) error("query failed, there should be a hit: %s:%d-%d\n",chr,start,end);
        debug("ok: overlap(s) found for %s:%d-%d\n",chr,start,end);
        nhit = 0;
        while ( regitr_overlap(itr) )
        {
            if ( itr->beg > end-1 || itr->end < start-1 ) error("query failed, incorrect region: %"PRIhts_pos"-%"PRIhts_pos" for %d-%d\n",itr->beg+1,itr->end+1,start,end);
            debug("\t %"PRIhts_pos"-%"PRIhts_pos"\n",itr->beg+1,itr->end+1);
            nhit++;
        }
        if ( nhit!=1 ) error("query failed, expected one hit, found %d: %s:%d-%d\n",nhit,chr,start,end);


        // one hit
        start = end = 10*i+1;
        if ( !regidx_overlap(idx,chr,start-1,end-1,itr) ) error("query failed, there should be a hit: %s:%d-%d\n",chr,start,end);
        debug("ok: overlap(s) found for %s:%d-%d\n",chr,start,end);
        nhit = 0;
        while ( regitr_overlap(itr) )
        {
            if ( itr->beg > end-1 || itr->end < start-1 ) error("query failed, incorrect region: %"PRIhts_pos"-%"PRIhts_pos" for %d-%d\n",itr->beg+1,itr->end+1,start,end);
            debug("\t %"PRIhts_pos"-%"PRIhts_pos"\n",itr->beg+1,itr->end+1);
            nhit++;
        }
        if ( nhit!=1 ) error("query failed, expected one hit, found %d: %s:%d-%d\n",nhit,chr,start,end);


        // two hits
        start = 10*i; end = start+1;
        if ( !regidx_overlap(idx,chr,start-1,end-1,itr) ) error("query failed, there should be a hit: %s:%d-%d\n",chr,start,end);
        debug("ok: overlap(s) found for %s:%d-%d\n",chr,start,end);
        nhit = 0;
        while ( regitr_overlap(itr) )
        {
            if ( itr->beg > end-1 || itr->end < start-1 ) error("query failed, incorrect region: %"PRIhts_pos"-%"PRIhts_pos" for %d-%d\n",itr->beg+1,itr->end+1,start,end);
            debug("\t %"PRIhts_pos"-%"PRIhts_pos"\n",itr->beg+1,itr->end+1);
            nhit++;
        }
        if ( nhit!=2 ) error("query failed, expected two hits, found %d: %s:%d-%d\n",nhit,chr,start,end);

        // fully contained interval, one hit
        start = 20000*i - 5000; end = 20000*i + 3000;
        set_line(line,sizeof(line),chr,start,end);
        if ( !regidx_overlap(idx,chr,start-1,end-1,itr) ) error("query failed, there should be a hit: %s:%d-%d\n",chr,start,end);
        debug("ok: overlap(s) found for %s:%d-%d\n",chr,start,end);
        nhit = 0;
        while ( regitr_overlap(itr) )
        {
            if ( itr->beg > end-1 || itr->end < start-1 ) error("query failed, incorrect region: %"PRIhts_pos"-%"PRIhts_pos" for %d-%d\n",itr->beg+1,itr->end+1,start,end);
            debug("\t %"PRIhts_pos"-%"PRIhts_pos"\n",itr->beg+1,itr->end+1);
            nhit++;
        }
        if ( nhit!=1 ) error("query failed, expected one hit, found %d: %s:%d-%d\n",nhit,chr,start,end);
    }
    regitr_destroy(itr);
    regidx_destroy(idx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x28(%rsp)
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x92d3
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x7335
movl $0xb, %ebx
movl $0x55f0, %r15d          # imm = 0x55F0
leaq 0x8e2e9(%rip), %rbp     # 0x950a7
leaq 0x30(%rsp), %r14
leaq 0x8b65e(%rip), %r12     # 0x92428
leal -0x1(%rbx), %ecx
movl $0xfa, %esi
movq %r14, %rdi
movq %rbp, %r13
movq %rbp, %rdx
movl %ecx, %r8d
movq 0x28(%rsp), %rbp
callq *%rbp
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x61e2
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x87cd
testl %eax, %eax
jne 0x723d
movl $0xfa, %esi
movq %r14, %rdi
movq %r13, %rdx
movl %ebx, %ecx
movl %ebx, %r8d
callq *%rbp
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x61e2
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x87cd
testl %eax, %eax
jne 0x723d
movq %rbp, %rax
leal -0x7d0(%r15), %ecx
movl $0xfa, %esi
movq %r14, %rdi
movq %r13, %rbp
movq %r13, %rdx
movl %r15d, %r8d
callq *%rax
movq %r12, %r13
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x61e2
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x87cd
testl %eax, %eax
jne 0x723d
addl $0xa, %ebx
addl $0x4e20, %r15d          # imm = 0x4E20
cmpl $0x65, %ebx
movq %r13, %r12
jne 0x6dca
movq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x9def
movq %rax, %r15
movl $0x1, %eax
leaq 0x8b65c(%rip), %r13     # 0x9250b
movq %rax, 0x20(%rsp)
leaq (%rax,%rax), %r14
leaq (%r14,%r14,4), %rbx
decq %rbx
leaq -0x2(%r14,%r14,4), %rcx
movq %r12, %rdi
leaq 0x8e1d9(%rip), %rsi     # 0x950a7
movq %rcx, %rdx
movq %r15, %r8
callq 0x9698
testl %eax, %eax
jne 0x72c1
leaq (%r14,%r14,4), %rbp
leaq 0x8b577(%rip), %rdi     # 0x92463
leaq 0x8e1b4(%rip), %r14     # 0x950a7
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x61e2
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x9698
testl %eax, %eax
je 0x72d5
xorl %r12d, %r12d
leaq 0x8b58e(%rip), %rdi     # 0x924b5
movq %r14, %rsi
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x61e2
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
movq 0x20(%rsp), %rax
je 0x7250
addl %eax, %eax
leal (%rax,%rax,4), %eax
movl %eax, 0xc(%rsp)
xorl %r12d, %r12d
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jge 0x71ed
cmpq %rbx, %rax
jl 0x71ed
movq %r13, %rdi
xorl %eax, %eax
callq 0x61e2
incl %r12d
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
jne 0x6f56
cmpl $0x1, %r12d
jne 0x7250
movq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x9698
movl %ebp, %edx
orl $0x1, %edx
testl %eax, %eax
je 0x72e9
movq %r14, %rsi
xorl %r14d, %r14d
leaq 0x8b4eb(%rip), %rdi     # 0x924b5
movl %edx, 0x10(%rsp)
movl %edx, %ecx
xorl %eax, %eax
callq 0x61e2
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
movl 0xc(%rsp), %r12d
je 0x7268
orl $0x1, %r12d
xorl %r14d, %r14d
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jg 0x71fb
cmpq %rbp, %rax
jl 0x71fb
movq %r13, %rdi
xorl %eax, %eax
callq 0x61e2
incl %r14d
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
jne 0x6ff3
cmpl $0x1, %r14d
jne 0x7268
movl %r12d, 0xc(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x8e05f(%rip), %r12     # 0x950a7
movq %r12, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x9698
testl %eax, %eax
je 0x72fb
xorl %r14d, %r14d
leaq 0x8b44a(%rip), %rdi     # 0x924b5
movq %r12, %rsi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
xorl %eax, %eax
callq 0x61e2
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
je 0x7282
xorl %r14d, %r14d
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jg 0x720b
cmpq %rbx, %rax
jl 0x720b
movq %r13, %rdi
xorl %eax, %eax
callq 0x61e2
incl %r14d
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
jne 0x708e
cmpl $0x2, %r14d
jne 0x7282
movq 0x20(%rsp), %rax
imulq $0x4e20, %rax, %r12     # imm = 0x4E20
imull $0x4e20, %eax, %ebx     # imm = 0x4E20
addl $0xffffec78, %ebx       # imm = 0xFFFFEC78
leal 0xbb8(%r12), %r8d
movl $0xfa, %esi
leaq 0x30(%rsp), %rdi
leaq 0x8dfa4(%rip), %rbp     # 0x950a7
movq %rbp, %rdx
movl %ebx, %ecx
movl %r8d, 0xc(%rsp)
callq *0x28(%rsp)
leaq -0x1389(%r12), %r14
movq %r12, 0x10(%rsp)
addq $0xbb7, %r12            # imm = 0xBB7
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x9698
testl %eax, %eax
je 0x7311
xorl %ebp, %ebp
leaq 0x8b369(%rip), %rdi     # 0x924b5
leaq 0x8df54(%rip), %rsi     # 0x950a7
movl %ebx, %edx
movl 0xc(%rsp), %ebx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x61e2
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
je 0x729c
xorl %ebp, %ebp
movq (%r15), %rsi
movq 0x8(%r15), %rdx
cmpq %r12, %rsi
jg 0x721b
cmpq %r14, %rdx
jl 0x721b
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x61e2
incl %ebp
movq %r15, %rdi
callq 0x9e6d
testl %eax, %eax
jne 0x7174
cmpl $0x1, %ebp
jne 0x729c
movq 0x20(%rsp), %rax
incq %rax
cmpq $0xa, %rax
movq 0x18(%rsp), %r12
jne 0x6eaf
movq %r15, %rdi
callq 0x9e57
movq %r12, %rdi
callq 0x91b4
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8b2e4(%rip), %rdi     # 0x924d8
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x7236
leaq 0x8b2d6(%rip), %rdi     # 0x924d8
movl 0x10(%rsp), %ecx
movl %ecx, %r8d
jmp 0x7236
leaq 0x8b2c6(%rip), %rdi     # 0x924d8
movl %ebp, %ecx
movl 0x10(%rsp), %r8d
jmp 0x7236
movq 0x10(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
incq %rsi
incq %rdx
leaq 0x8b2a5(%rip), %rdi     # 0x924d8
movl %ebx, %r8d
xorl %eax, %eax
callq 0x6148
leaq 0x8add8(%rip), %rdi     # 0x9201c
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x6148
leaq 0x8b2bf(%rip), %rdi     # 0x92516
leaq 0x8de49(%rip), %rdx     # 0x950a7
movl %r12d, %esi
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x72ba
leaq 0x8b2a7(%rip), %rdi     # 0x92516
leaq 0x8de31(%rip), %rdx     # 0x950a7
movl %r14d, %esi
movl 0x10(%rsp), %ecx
movl %ecx, %r8d
jmp 0x72ba
leaq 0x8b2c1(%rip), %rdi     # 0x9254a
leaq 0x8de17(%rip), %rdx     # 0x950a7
movl %r14d, %esi
movl %ebp, %ecx
movl 0x10(%rsp), %r8d
jmp 0x72ba
movq 0x10(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
leaq 0x8b268(%rip), %rdi     # 0x92516
leaq 0x8ddf2(%rip), %rdx     # 0x950a7
movl %ebp, %esi
movl %ebx, %r8d
xorl %eax, %eax
callq 0x6148
leaq 0x8b16b(%rip), %rdi     # 0x92433
leaq 0x8ddd8(%rip), %rsi     # 0x950a7
movl %ebx, %edx
movl %ebx, %ecx
jmp 0x732e
leaq 0x8b1aa(%rip), %rdi     # 0x92486
leaq 0x8ddc4(%rip), %rsi     # 0x950a7
movl %ebp, %edx
movl %ebp, %ecx
jmp 0x732e
leaq 0x8b196(%rip), %rdi     # 0x92486
leaq 0x8ddb0(%rip), %rsi     # 0x950a7
movl %edx, %ecx
jmp 0x732e
leaq 0x8b184(%rip), %rdi     # 0x92486
leaq 0x8dd9e(%rip), %rsi     # 0x950a7
movl %ebp, %edx
movl 0x10(%rsp), %ecx
jmp 0x732e
movq 0x10(%rsp), %rdx
addl $0xffffec78, %edx       # imm = 0xFFFFEC78
leaq 0x8b163(%rip), %rdi     # 0x92486
leaq 0x8dd7d(%rip), %rsi     # 0x950a7
movl 0xc(%rsp), %ecx
xorl %eax, %eax
callq 0x6148
leaq 0x8acc8(%rip), %rdi     # 0x92004
xorl %eax, %eax
callq 0x6148