// File: /workspace/github_c_makefile_star2_O0/zhou-lab[P]tbmate/htslib/regidx.c
// Function: regidx_build_index
int _regidx_build_index(regidx_t *idx)
{
    int iseq;
    for (iseq=0; iseq<idx->nseq; iseq++)
    {
        reglist_t *list = &idx->seq[iseq];
        int j,k, imax = 0;   // max index bin
        for (j=0; j<list->nregs; j++)
        {
            int ibeg = list->regs[j].start >> LIDX_SHIFT;
            int iend = list->regs[j].end >> LIDX_SHIFT;
            if ( imax < iend + 1 )
            {
                int old_imax = imax; 
                imax = iend + 1;
                kroundup32(imax);
                list->idx = (int*) realloc(list->idx, imax*sizeof(int));
                for (k=old_imax; k<imax; k++) list->idx[k] = -1;
            }
            if ( ibeg==iend )
            {
                if ( list->idx[ibeg]<0 ) list->idx[ibeg] = j;
            }
            else
            {
                for (k=ibeg; k<=iend; k++)
                    if ( list->idx[k]<0 ) list->idx[k] = j;
            }
            list->nidx = iend + 1;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x16540
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x16530
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,8), %eax
shrl $0xd, %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
shrl $0xd, %eax
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x164aa
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
sarl %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
sarl $0x2, %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
sarl $0x4, %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
sarl $0x8, %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
sarl $0x10, %eax
orl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movslq -0x24(%rbp), %rsi
shlq $0x2, %rsi
callq 0x37c0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x164a8
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x16483
jmp 0x164aa
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x164d6
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x164d4
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16515
movl -0x28(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x16513
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x16506
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x16508
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x164dc
jmp 0x16515
movl -0x2c(%rbp), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x163b7
jmp 0x16532
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x16383
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)