// File: /workspace/github_c_makefile_star2_O2/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 0x88ba
testq %rax, %rax
je 0x6d72
movq %rax, 0x18(%rsp)
movl $0x55f0, %ecx           # imm = 0x55F0
pushq $0xb
popq %rbx
leaq 0x30(%rsp), %rbp
leaq 0x6dbe9(%rip), %r13     # 0x74428
movq 0x28(%rsp), %r14
movq 0x18(%rsp), %r12
leal 0x4e20(%rcx), %eax
cmpl $0x36330, %eax          # imm = 0x36330
je 0x691d
movq %rcx, 0x20(%rsp)
movl %eax, 0xc(%rsp)
leal -0x1(%rbx), %ecx
movl $0xfa, %esi
movq %rbp, %rdi
leaq 0x707ad(%rip), %r15     # 0x77022
movq %r15, %rdx
movl %ecx, %r8d
callq *%r14
movq %r13, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x5de0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7f92
testl %eax, %eax
jne 0x690a
movl $0xfa, %esi
movq %rbp, %rdi
movq %r15, %rdx
movl %ebx, %ecx
movl %ebx, %r8d
callq *%r14
movq %r13, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x5de0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7f92
testl %eax, %eax
jne 0x690a
addl $0xa, %ebx
movq 0x20(%rsp), %r8
leal -0x7d0(%r8), %ecx
movl $0xfa, %esi
movq %rbp, %rdi
movq %r15, %rdx
callq *%r14
movq %r13, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x5de0
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7f92
movl 0xc(%rsp), %ecx
testl %eax, %eax
je 0x6849
leaq 0x6d70b(%rip), %rdi     # 0x7401c
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x5d48
movq 0x18(%rsp), %rdi
callq 0x918c
movq %rax, %r15
pushq $0x1
popq %r12
leaq 0x706ed(%rip), %rax     # 0x77022
leaq 0x6dbcf(%rip), %r13     # 0x7450b
cmpq $0xa, %r12
je 0x6c33
imulq $0xa, %r12, %rbp
leaq -0x1(%rbp), %rbx
leaq -0x2(%rbp), %rcx
movq 0x18(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
movq %rcx, %rdx
movq %r15, %r8
callq 0x8c4c
testl %eax, %eax
jne 0x6cbe
leaq 0x6daec(%rip), %rdi     # 0x74463
leaq 0x706a4(%rip), %rsi     # 0x77022
movl %ebx, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x5de0
movq %r14, %rdi
leaq 0x7068f(%rip), %rsi     # 0x77022
movq %rbx, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x8c4c
testl %eax, %eax
je 0x6ca7
movq %r12, 0x20(%rsp)
imull $0xa, %r12d, %eax
movl %eax, 0xc(%rsp)
xorl %r12d, %r12d
leaq 0x6daf5(%rip), %rdi     # 0x744b5
leaq 0x7065b(%rip), %rsi     # 0x77022
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x5de0
movq %r15, %rdi
callq 0x9202
testl %eax, %eax
je 0x6a0e
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jge 0x6c57
cmpq %rbx, %rax
jl 0x6c57
movq %r13, %rdi
xorl %eax, %eax
callq 0x5de0
incl %r12d
jmp 0x69d2
cmpl $0x1, %r12d
movq 0x18(%rsp), %rdi
jne 0x6cd5
leaq 0x705fe(%rip), %r12     # 0x77022
movq %r12, %rsi
movq %rbp, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x8c4c
movl %ebp, %ecx
orl $0x1, %ecx
testl %eax, %eax
je 0x6ced
orl $0x1, 0xc(%rsp)
xorl %r14d, %r14d
leaq 0x6da64(%rip), %rdi     # 0x744b5
movq %r12, %rsi
movl %ecx, %edx
movl %ecx, 0x10(%rsp)
xorl %eax, %eax
callq 0x5de0
movq %r15, %rdi
callq 0x9202
testl %eax, %eax
je 0x6a9d
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jg 0x6c65
cmpq %rbp, %rax
jl 0x6c65
movq %r13, %rdi
xorl %eax, %eax
callq 0x5de0
incl %r14d
jmp 0x6a61
cmpl $0x1, %r14d
jne 0x6cff
movq 0x18(%rsp), %rdi
leaq 0x7056f(%rip), %r12     # 0x77022
movq %r12, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x8c4c
testl %eax, %eax
je 0x6d19
xorl %r14d, %r14d
leaq 0x6d9df(%rip), %rdi     # 0x744b5
movq %r12, %rsi
movl %ebp, %edx
movl 0xc(%rsp), %ecx
xorl %eax, %eax
callq 0x5de0
movq %r15, %rdi
callq 0x9202
testl %eax, %eax
je 0x6b22
movq (%r15), %rcx
movq 0x8(%r15), %rax
leaq 0x1(%rcx), %rsi
leaq 0x1(%rax), %rdx
cmpq %rbp, %rcx
jg 0x6c75
cmpq %rbx, %rax
jl 0x6c75
movq %r13, %rdi
xorl %eax, %eax
callq 0x5de0
incl %r14d
jmp 0x6ae6
cmpl $0x2, %r14d
jne 0x6d2f
movq 0x20(%rsp), %rax
imulq $0x4e20, %rax, %r14     # imm = 0x4E20
imull $0x4e20, %eax, %ebx     # imm = 0x4E20
addl $0xffffec78, %ebx       # imm = 0xFFFFEC78
leal 0xbb8(%r14), %r8d
movl $0xfa, %esi
leaq 0x30(%rsp), %rdi
leaq 0x704c6(%rip), %rdx     # 0x77022
movl %ebx, %ecx
movl %r8d, 0xc(%rsp)
callq *0x28(%rsp)
leaq -0x1389(%r14), %r12
movq %r14, 0x10(%rsp)
leaq 0xbb7(%r14), %rbp
movq 0x18(%rsp), %rdi
leaq 0x7049c(%rip), %rsi     # 0x77022
movq %r12, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x8c4c
testl %eax, %eax
je 0x6d4e
xorl %r14d, %r14d
leaq 0x6d90f(%rip), %rdi     # 0x744b5
leaq 0x70475(%rip), %rsi     # 0x77022
movl %ebx, %edx
movl 0xc(%rsp), %ebx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x5de0
movq %r15, %rdi
callq 0x9202
testl %eax, %eax
je 0x6bf6
movq (%r15), %rsi
movq 0x8(%r15), %rdx
cmpq %rbp, %rsi
jg 0x6c85
cmpq %r12, %rdx
jl 0x6c85
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x5de0
incl %r14d
jmp 0x6bbc
movq 0x20(%rsp), %r12
incq %r12
cmpl $0x1, %r14d
leaq 0x70419(%rip), %rax     # 0x77022
je 0x693c
movq 0x10(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
leaq 0x6d8f5(%rip), %rdi     # 0x74516
leaq 0x703fa(%rip), %rdx     # 0x77022
movl %r14d, %esi
movl %ebx, %r8d
jmp 0x6d47
movq %r15, %rdi
callq 0x91ec
movq 0x18(%rsp), %rdi
callq 0x87b0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6d87a(%rip), %rdi     # 0x744d8
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x6ca0
leaq 0x6d86c(%rip), %rdi     # 0x744d8
movl 0x10(%rsp), %ecx
movl %ecx, %r8d
jmp 0x6ca0
leaq 0x6d85c(%rip), %rdi     # 0x744d8
movl %ebp, %ecx
movl 0x10(%rsp), %r8d
jmp 0x6ca0
movq 0x10(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
incq %rsi
incq %rdx
leaq 0x6d83b(%rip), %rdi     # 0x744d8
movl %ebx, %r8d
xorl %eax, %eax
callq 0x5d48
leaq 0x6d7d8(%rip), %rdi     # 0x74486
leaq 0x7036d(%rip), %rsi     # 0x77022
movl %ebp, %edx
movl %ebp, %ecx
jmp 0x6d6b
leaq 0x6d76e(%rip), %rdi     # 0x74433
leaq 0x70356(%rip), %rsi     # 0x77022
movl %ebx, %edx
movl %ebx, %ecx
jmp 0x6d6b
leaq 0x6d83a(%rip), %rdi     # 0x74516
leaq 0x7033f(%rip), %rdx     # 0x77022
movl %r12d, %esi
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x6d47
leaq 0x6d792(%rip), %rdi     # 0x74486
leaq 0x70327(%rip), %rsi     # 0x77022
movl %ecx, %edx
jmp 0x6d6b
leaq 0x6d810(%rip), %rdi     # 0x74516
leaq 0x70315(%rip), %rdx     # 0x77022
movl %r14d, %esi
movl 0x10(%rsp), %ecx
movl %ecx, %r8d
jmp 0x6d47
leaq 0x6d766(%rip), %rdi     # 0x74486
leaq 0x702fb(%rip), %rsi     # 0x77022
movl %ebp, %edx
movl 0x10(%rsp), %ecx
jmp 0x6d6b
leaq 0x6d814(%rip), %rdi     # 0x7454a
leaq 0x702e5(%rip), %rdx     # 0x77022
movl %r14d, %esi
movl %ebp, %ecx
movl 0x10(%rsp), %r8d
xorl %eax, %eax
callq 0x5d48
movq 0x10(%rsp), %rdx
addl $0xffffec78, %edx       # imm = 0xFFFFEC78
leaq 0x6d726(%rip), %rdi     # 0x74486
leaq 0x702bb(%rip), %rsi     # 0x77022
movl 0xc(%rsp), %ecx
xorl %eax, %eax
callq 0x5d48
leaq 0x6d28b(%rip), %rdi     # 0x74004
xorl %eax, %eax
callq 0x5d48