// File: /workspace/github_c_makefile_star2_O1/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 0x92c7
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x734a
movl $0xb, %ebx
movl $0x55f0, %r12d          # imm = 0x55F0
leaq 0x902f1(%rip), %r14     # 0x970a4
leaq 0x30(%rsp), %r15
leaq 0x8d669(%rip), %r13     # 0x94428
leal -0x1(%rbx), %ecx
movl $0xfa, %esi
movq %r15, %rdi
movq %r14, %rbp
movq %r14, %rdx
movl %ecx, %r8d
movq 0x28(%rsp), %r14
callq *%r14
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x61db
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8743
testl %eax, %eax
jne 0x7248
movl $0xfa, %esi
movq %r15, %rdi
movq %rbp, %rdx
movl %ebx, %ecx
movl %ebx, %r8d
callq *%r14
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x61db
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8743
testl %eax, %eax
jne 0x7248
movq %r14, %rax
leal -0x7d0(%r12), %ecx
movl $0xfa, %esi
movq %r15, %rdi
movq %rbp, %r14
movq %rbp, %rdx
movl %r12d, %r8d
callq *%rax
movq %r13, %rbp
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x61db
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8743
testl %eax, %eax
jne 0x7248
addl $0xa, %ebx
addl $0x4e20, %r12d          # imm = 0x4E20
cmpl $0x65, %ebx
movq %rbp, %r13
jne 0x6dbf
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x9df9
movq %rax, %r15
movl $0x1, %eax
leaq 0x8d664(%rip), %r13     # 0x9450b
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 0x901de(%rip), %rsi     # 0x970a4
movq %rcx, %rdx
movq %r15, %r8
callq 0x96b7
testl %eax, %eax
jne 0x7272
leaq (%r14,%r14,4), %rbp
leaq 0x8d57f(%rip), %rdi     # 0x94463
leaq 0x901b9(%rip), %r14     # 0x970a4
movq %r14, %rsi
movl %ebx, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x61db
movq %r12, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rbx, %rcx
movq %r15, %r8
callq 0x96b7
testl %eax, %eax
je 0x725b
movq %r14, %rsi
xorl %r14d, %r14d
leaq 0x8d593(%rip), %rdi     # 0x944b5
movl %ebp, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x61db
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
je 0x6f74
xorl %r14d, %r14d
movq (%r15), %rsi
cmpq %rbp, %rsi
jge 0x71dc
movq 0x8(%r15), %rdx
cmpq %rbx, %rdx
jl 0x71dc
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x61db
incl %r14d
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
jne 0x6f3c
cmpl $0x1, %r14d
jne 0x7289
movq %rbp, %r13
orq $0x1, %r13
movq 0x8(%rsp), %rdi
leaq 0x90113(%rip), %r12     # 0x970a4
movq %r12, %rsi
movq %rbp, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x96b7
testl %eax, %eax
je 0x72a4
xorl %r14d, %r14d
leaq 0x8d501(%rip), %rdi     # 0x944b5
movq %r12, %rsi
movl %r13d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x61db
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
movq %r13, %r12
leaq 0x8d533(%rip), %r13     # 0x9450b
je 0x7015
xorl %r14d, %r14d
movq (%r15), %rsi
cmpq %rbp, %rsi
jg 0x71f4
movq 0x8(%r15), %rdx
cmpq %rbp, %rdx
jl 0x71f4
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x61db
incl %r14d
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
jne 0x6fdd
movq %r12, 0x10(%rsp)
cmpl $0x1, %r14d
jne 0x72ba
movq 0x8(%rsp), %rdi
leaq 0x90074(%rip), %r12     # 0x970a4
movq %r12, %rsi
movq %rbx, %rdx
movq %rbp, %rcx
movq %r15, %r8
callq 0x96b7
testl %eax, %eax
je 0x72d5
movq 0x20(%rsp), %rax
addl %eax, %eax
leal (%rax,%rax,4), %ecx
orl $0x1, %ecx
xorl %r14d, %r14d
leaq 0x8d455(%rip), %rdi     # 0x944b5
movq %r12, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x61db
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
movq 0x10(%rsp), %r12
je 0x70b8
xorl %r14d, %r14d
movq (%r15), %rsi
cmpq %rbp, %rsi
jg 0x720a
movq 0x8(%r15), %rdx
cmpq %rbx, %rdx
jl 0x720a
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x61db
incl %r14d
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
jne 0x7080
cmpl $0x2, %r14d
jne 0x72e7
movq 0x20(%rsp), %rax
imulq $0x4e20, %rax, %r14     # imm = 0x4E20
imull $0x4e20, %eax, %ebx     # imm = 0x4E20
addl $0xffffec78, %ebx       # imm = 0xFFFFEC78
leaq 0xbb8(%r14), %r8
movl $0xfa, %esi
leaq 0x30(%rsp), %rdi
leaq 0x8ffb2(%rip), %r12     # 0x970a4
movq %r12, %rdx
movl %ebx, %ecx
movq %r8, 0x10(%rsp)
callq *0x28(%rsp)
leaq -0x1389(%r14), %rbp
movq %r14, 0x18(%rsp)
addq $0xbb7, %r14            # imm = 0xBB7
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %r14, %rcx
movq %r15, %r8
callq 0x96b7
testl %eax, %eax
je 0x72ff
xorl %r12d, %r12d
leaq 0x8d37a(%rip), %rdi     # 0x944b5
leaq 0x8ff62(%rip), %rsi     # 0x970a4
movl %ebx, %edx
movq 0x10(%rsp), %rbx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x61db
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
je 0x7199
xorl %r12d, %r12d
movq (%r15), %rsi
cmpq %r14, %rsi
jg 0x7222
movq 0x8(%r15), %rdx
cmpq %rbp, %rdx
jl 0x7222
incq %rsi
incq %rdx
movq %r13, %rdi
xorl %eax, %eax
callq 0x61db
incl %r12d
movq %r15, %rdi
callq 0x9e7f
testl %eax, %eax
jne 0x7161
cmpl $0x1, %r12d
jne 0x7324
movq 0x20(%rsp), %rax
incq %rax
cmpq $0xa, %rax
movq 0x8(%rsp), %r12
jne 0x6ea7
movq %r15, %rdi
callq 0x9e69
movq %r12, %rdi
callq 0x91ad
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incq %rsi
movq 0x8(%r15), %rdx
incq %rdx
leaq 0x8d2eb(%rip), %rdi     # 0x944d8
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x7241
incq %rsi
movq 0x8(%r15), %rdx
incq %rdx
leaq 0x8d2d3(%rip), %rdi     # 0x944d8
movl %r12d, %ecx
jmp 0x721d
incq %rsi
movq 0x8(%r15), %rdx
incq %rdx
leaq 0x8d2bd(%rip), %rdi     # 0x944d8
movl %ebp, %ecx
movl %r12d, %r8d
jmp 0x7241
movq 0x18(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
incq %rsi
movq 0x8(%r15), %rdx
incq %rdx
leaq 0x8d29a(%rip), %rdi     # 0x944d8
movl %ebx, %r8d
xorl %eax, %eax
callq 0x6141
leaq 0x8cdcd(%rip), %rdi     # 0x9401c
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
callq 0x6141
leaq 0x8d224(%rip), %rdi     # 0x94486
leaq 0x8fe3b(%rip), %rsi     # 0x970a4
movl %ebp, %edx
movl %ebp, %ecx
jmp 0x731d
leaq 0x8d1ba(%rip), %rdi     # 0x94433
leaq 0x8fe24(%rip), %rsi     # 0x970a4
movl %ebx, %edx
movl %ebx, %ecx
jmp 0x731d
leaq 0x8d286(%rip), %rdi     # 0x94516
leaq 0x8fe0d(%rip), %rdx     # 0x970a4
movl %r14d, %esi
movl %ebp, %ecx
movl %ebp, %r8d
jmp 0x7343
leaq 0x8d1db(%rip), %rdi     # 0x94486
leaq 0x8fdf2(%rip), %rsi     # 0x970a4
movl %r13d, %edx
movl %r13d, %ecx
jmp 0x731d
leaq 0x8d255(%rip), %rdi     # 0x94516
leaq 0x8fddc(%rip), %rdx     # 0x970a4
movl %r14d, %esi
movq 0x10(%rsp), %rcx
movl %ecx, %r8d
jmp 0x7343
leaq 0x8d1aa(%rip), %rdi     # 0x94486
leaq 0x8fdc1(%rip), %rsi     # 0x970a4
movl %ebp, %edx
jmp 0x7318
leaq 0x8d25c(%rip), %rdi     # 0x9454a
leaq 0x8fdaf(%rip), %rdx     # 0x970a4
movl %r14d, %esi
movl %ebp, %ecx
movl %r12d, %r8d
jmp 0x7343
movq 0x18(%rsp), %rdx
addl $0xffffec78, %edx       # imm = 0xFFFFEC78
leaq 0x8d175(%rip), %rdi     # 0x94486
leaq 0x8fd8c(%rip), %rsi     # 0x970a4
movq 0x10(%rsp), %rcx
xorl %eax, %eax
callq 0x6141
movq 0x18(%rsp), %rcx
addl $0xffffec78, %ecx       # imm = 0xFFFFEC78
leaq 0x8d1e0(%rip), %rdi     # 0x94516
leaq 0x8fd67(%rip), %rdx     # 0x970a4
movl %r12d, %esi
movl %ebx, %r8d
xorl %eax, %eax
callq 0x6141
leaq 0x8ccb3(%rip), %rdi     # 0x94004
xorl %eax, %eax
callq 0x6141