// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/test-regidx.c
// Function: test_random
void test_random(int nregs, uint32_t min, uint32_t max)
{
    min--;
    max--;

    // Init index with no file name, we will insert the regions manually
    regidx_t *idx = regidx_init(NULL,custom_parse,custom_free,sizeof(char*),NULL);
    if ( !idx ) error("init failed\n");

    // Test region
    uint32_t beg,end;
    get_random_region(min,max,&beg,&end);

    // Insert regions
    int i, nexp = 0;
    kstring_t str = {0,0,0};
    for (i=0; i<nregs; i++)
    {
        uint32_t b,e;
        get_random_region(min,max,&b,&e);
        str.l = 0;
        ksprintf(&str,"1\t%"PRIu32"\t%"PRIu32"\t1:%"PRIu32"-%"PRIu32"",b+1,e+1,b+1,e+1);
        if ( regidx_insert(idx,str.s)!=0 ) error("insert failed: %s\n", str.s);
        if ( e>=beg && b<=end ) nexp++;
    }

    // Test
    regitr_t *itr = regitr_init(idx);
    int nhit = 0, ret = regidx_overlap(idx,"1",beg,end,itr);
    if ( nexp && !ret ) error("query failed, expected %d overlap(s), found none: %d-%d\n", nexp,beg+1,end+1);
    if ( !nexp && ret ) error("query failed, expected no overlaps, found some: %d-%d\n", beg+1,end+1);
    while ( ret && regitr_overlap(itr) )
    {
        str.l = 0;
        ksprintf(&str,"1:%"PRIhts_pos"-%"PRIhts_pos"",itr->beg+1,itr->end+1);
        if ( strcmp(str.s,regitr_payload(itr,char*)) )
            error("query failed, incorrect payload: %s vs %s (%d-%d)\n",str.s,regitr_payload(itr,char*),beg+1,end+1);
        if ( itr->beg > end || itr->end < beg )
            error("query failed, incorrect hit: %d-%d vs %"PRIhts_pos"-%"PRIhts_pos", payload %s\n", beg+1,end+1,itr->beg+1,itr->end+1,regitr_payload(itr,char*));
        nhit++;
    }
    if ( nexp!=nhit ) error("query failed, expected %d overlap(s), found %d: %d-%d\n",nexp,nhit,beg+1,end+1);
    debug("ok: found %d overlaps\n", nexp);

    // Clean up
    regitr_destroy(itr);
    regidx_destroy(idx);
    free(str.s);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
xorl %eax, %eax
movl %eax, %r8d
leaq -0xb0f(%rip), %rsi      # 0x5ac0
leaq -0x8c6(%rip), %rdx      # 0x5d10
movl $0x8, %ecx
movq %r8, %rdi
callq 0xa300
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x65fc
leaq 0xe4a0f(%rip), %rdi     # 0xeb004
movb $0x0, %al
callq 0x5f40
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
leaq -0x1c(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x6500
movl $0x0, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4250
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x66cf
movl -0x8(%rbp), %edi
movl -0xc(%rbp), %esi
leaq -0x44(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x6500
movq $0x0, -0x40(%rbp)
movl -0x44(%rbp), %edx
addl $0x1, %edx
movl -0x48(%rbp), %ecx
addl $0x1, %ecx
movl -0x44(%rbp), %r8d
addl $0x1, %r8d
movl -0x48(%rbp), %r9d
addl $0x1, %r9d
leaq -0x40(%rbp), %rdi
leaq 0xe4b73(%rip), %rsi     # 0xeb1ee
movb $0x0, %al
callq 0x8460
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x9630
cmpl $0x0, %eax
je 0x66a6
movq -0x30(%rbp), %rsi
leaq 0xe497d(%rip), %rdi     # 0xeb01c
movb $0x0, %al
callq 0x5f40
movl -0x48(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jb 0x66bf
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
ja 0x66bf
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x66c1
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x662d
movq -0x18(%rbp), %rdi
callq 0xb300
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
movl -0x20(%rbp), %eax
movl %eax, %ecx
movq -0x50(%rbp), %r8
leaq 0xe7cb9(%rip), %rsi     # 0xee3b5
callq 0xa910
movl %eax, -0x58(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x672d
cmpl $0x0, -0x58(%rbp)
jne 0x672d
movl -0x28(%rbp), %esi
movl -0x1c(%rbp), %edx
addl $0x1, %edx
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
leaq 0xe4ad8(%rip), %rdi     # 0xeb1fe
movb $0x0, %al
callq 0x5f40
cmpl $0x0, -0x28(%rbp)
jne 0x6753
cmpl $0x0, -0x58(%rbp)
je 0x6753
movl -0x1c(%rbp), %esi
addl $0x1, %esi
movl -0x20(%rbp), %edx
addl $0x1, %edx
leaq 0xe4aeb(%rip), %rdi     # 0xeb237
movb $0x0, %al
callq 0x5f40
jmp 0x6755
xorl %eax, %eax
cmpl $0x0, -0x58(%rbp)
movb %al, -0x59(%rbp)
je 0x6772
movq -0x50(%rbp), %rdi
callq 0xb410
cmpl $0x0, %eax
setne %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x677e
jmp 0x685c
movq $0x0, -0x40(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rdx
addq $0x1, %rdx
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
leaq -0x40(%rbp), %rdi
leaq 0xe4ac6(%rip), %rsi     # 0xeb26e
movb $0x0, %al
callq 0x8460
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rsi
callq 0x46a0
cmpl $0x0, %eax
je 0x67f3
movq -0x30(%rbp), %rsi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdx
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl -0x20(%rbp), %r8d
addl $0x1, %r8d
leaq 0xe4a8c(%rip), %rdi     # 0xeb278
movb $0x0, %al
callq 0x5f40
movq -0x50(%rbp), %rax
movq (%rax), %rax
movl -0x20(%rbp), %ecx
cmpq %rcx, %rax
jg 0x6812
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
jge 0x684e
movl -0x1c(%rbp), %esi
addl $0x1, %esi
movl -0x20(%rbp), %edx
addl $0x1, %edx
movq -0x50(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq -0x50(%rbp), %rax
movq 0x8(%rax), %r8
addq $0x1, %r8
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq (%rax), %r9
leaq 0xe4a64(%rip), %rdi     # 0xeb2ab
movb $0x0, %al
callq 0x5f40
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x6755
movl -0x28(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x6886
movl -0x28(%rbp), %esi
movl -0x54(%rbp), %edx
movl -0x1c(%rbp), %ecx
addl $0x1, %ecx
movl -0x20(%rbp), %r8d
addl $0x1, %r8d
leaq 0xe4a67(%rip), %rdi     # 0xeb2e6
movb $0x0, %al
callq 0x5f40
movl -0x28(%rbp), %esi
leaq 0xe4a8d(%rip), %rdi     # 0xeb31d
movb $0x0, %al
callq 0x5ff0
movq -0x50(%rbp), %rdi
callq 0xb3e0
movq -0x18(%rbp), %rdi
callq 0xa1e0
movq -0x30(%rbp), %rdi
callq 0x45b0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)