// File: /workspace/github_c_makefile_star2_O3/zhou-lab[P]tbmate/htslib/regidx.c
// Function: regidx_insert
int regidx_insert(regidx_t *idx, char *line)
{
    if ( !line )
        return _regidx_build_index(idx);

    char *chr_from, *chr_to;
    reg_t reg;
    int ret = idx->parse(line,&chr_from,&chr_to,&reg,idx->payload,idx->usr);
    if ( ret==-2 ) return -1;   // error
    if ( ret==-1 ) return 0;    // skip the line

    int rid;
    idx->str.l = 0;
    kputsn(chr_from, chr_to-chr_from+1, &idx->str);
    if ( khash_str2int_get(idx->seq2regs, idx->str.s, &rid)!=0 )
    {
        idx->nseq++;
        int m_prev = idx->mseq;
        hts_expand0(reglist_t,idx->nseq,idx->mseq,idx->seq);
        hts_expand0(char*,idx->nseq,m_prev,idx->seq_names);
        idx->seq_names[idx->nseq-1] = strdup(idx->str.s);
        rid = khash_str2int_inc(idx->seq2regs, idx->seq_names[idx->nseq-1]);
    }

    reglist_t *list = &idx->seq[rid];
    list->nregs++;
    int m_prev = list->mregs;
    hts_expand(reg_t,list->nregs,list->mregs,list->regs);
    list->regs[list->nregs-1] = reg;
    if ( idx->payload_size )
    {
        if ( m_prev < list->mregs ) list->payload = realloc(list->payload,idx->payload_size*list->mregs);
        memcpy(list->payload + idx->payload_size*(list->nregs-1), idx->payload, idx->payload_size);
    }

    if ( idx->rid_prev==rid )
    {
        if ( idx->start_prev > reg.start || (idx->start_prev==reg.start && idx->end_prev>reg.end) ) 
        { 
            fprintf(stderr,"The regions are not sorted: %s:%d-%d is before %s:%d-%d\n", 
                idx->str.s,idx->start_prev+1,idx->end_prev+1,idx->str.s,reg.start+1,reg.end+1); 
            return -1;
        }
    }
    idx->rid_prev = rid;
    idx->start_prev = reg.start;
    idx->end_prev = reg.end;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
testq %rsi, %rsi
je 0x1270b
movq 0x30(%rbx), %r9
movq 0x60(%rbx), %r8
leaq 0x40(%rsp), %rax
leaq 0x38(%rsp), %rdx
leaq 0x8(%rsp), %rcx
movq %rsi, %rdi
movq %rax, %rsi
callq *0x28(%rbx)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $-0x2, %eax
je 0x12c72
cmpl $-0x1, %eax
je 0x12c70
movq $0x0, 0x38(%rbx)
movq 0x40(%rsp), %r12
movl 0x38(%rsp), %eax
subl %r12d, %eax
incl %eax
movslq %eax, %r15
leaq 0x1(%r15), %rax
cmpq 0x40(%rbx), %rax
jae 0x12718
movq 0x48(%rbx), %rax
xorl %edi, %edi
jmp 0x12766
movq %rbx, %rdi
callq 0x1254e
jmp 0x12c70
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %rsi, 0x40(%rbx)
movq 0x48(%rbx), %rdi
callq 0x37b0
testq %rax, %rax
je 0x12785
movq %rax, 0x48(%rbx)
movq 0x38(%rbx), %rdi
addq %rax, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3850
addq 0x38(%rbx), %r15
movq %r15, 0x38(%rbx)
movq 0x48(%rbx), %rax
movb $0x0, (%rax,%r15)
movq %rbx, 0x10(%rsp)
movq 0x10(%rbx), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x1287e
movq (%rsp), %rax
movl (%rax), %ecx
testl %ecx, %ecx
je 0x127e9
movq 0x10(%rsp), %rax
movq 0x48(%rax), %r12
leal -0x1(%rcx), %esi
movsbl (%r12), %r13d
testl %r13d, %r13d
movq %rcx, 0x20(%rsp)
je 0x127f1
movb 0x1(%r12), %al
testb %al, %al
je 0x127f4
leaq 0x2(%r12), %rcx
movl %r13d, %edx
shll $0x5, %edx
subl %r13d, %edx
movsbl %al, %r13d
addl %edx, %r13d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x127ce
jmp 0x127f4
xorl %r15d, %r15d
jmp 0x12875
xorl %r13d, %r13d
andl %esi, %r13d
movq (%rsp), %rax
movq 0x10(%rax), %rdx
movl $0x1, %ebx
movl %r13d, %r15d
movl %esi, 0x18(%rsp)
movq %rdx, 0x28(%rsp)
movl %r15d, %eax
shrl $0x4, %eax
movl (%rdx,%rax,4), %r14d
leal (%r15,%r15), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x12863
testb $0x1, %al
jne 0x12854
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %r15d, %ecx
movq (%rax,%rcx,8), %rdi
movq %r12, %rsi
callq 0x3620
movq 0x28(%rsp), %rdx
movl 0x18(%rsp), %esi
testl %eax, %eax
je 0x12863
addl %ebx, %r15d
andl %esi, %r15d
incl %ebx
cmpl %r13d, %r15d
jne 0x12810
jmp 0x1287e
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x20(%rsp), %rcx
cmovnel %ecx, %r15d
cmpl %ecx, %r15d
jne 0x129a1
movq 0x10(%rsp), %r13
movl (%r13), %eax
leal 0x1(%rax), %ebp
movl %ebp, (%r13)
movslq 0x4(%r13), %rbx
cmpl %ebx, %eax
jl 0x128f8
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
incl %ecx
movl %ecx, 0x4(%r13)
movq 0x8(%r13), %rdi
movslq %ecx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rsi
callq 0x37b0
movq %rax, 0x8(%r13)
leaq (%rbx,%rbx,4), %rcx
leaq (%rax,%rcx,8), %rdi
movslq 0x4(%r13), %rax
subq %rbx, %rax
shlq $0x3, %rax
leaq (%rax,%rax,4), %rdx
xorl %esi, %esi
callq 0x3090
movl (%r13), %ebp
cmpl %ebx, %ebp
jle 0x12959
decl %ebp
movl %ebp, %eax
sarl %eax
orl %ebp, %eax
movl %eax, %ecx
sarl $0x2, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x4, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x10, %eax
orl %ecx, %eax
movq 0x18(%r13), %rdi
movslq %eax, %r14
leaq 0x8(,%r14,8), %rsi
callq 0x37b0
movq %rax, %r15
movq %rax, 0x18(%r13)
leaq (%rax,%rbx,8), %rdi
subl %ebx, %r14d
incl %r14d
movslq %r14d, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x3090
movl (%r13), %ebp
jmp 0x1295d
movq 0x18(%r13), %r15
movq 0x48(%r13), %rdi
callq 0x35f0
movslq %ebp, %rcx
movq %rax, -0x8(%r15,%rcx,8)
movq 0x10(%r13), %rbx
testq %rbx, %rbx
je 0x12997
movq 0x18(%r13), %rax
movq -0x8(%rax,%rcx,8), %r14
movl 0x8(%rbx), %eax
cmpl 0xc(%rbx), %eax
jb 0x129cb
movl (%rbx), %esi
movl 0x4(%rbx), %eax
addl %eax, %eax
cmpl %eax, %esi
jbe 0x129b9
decl %esi
jmp 0x129bb
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x12b7c
movq (%rsp), %rax
movq 0x20(%rax), %rax
movl %r15d, %ecx
movl (%rax,%rcx,4), %ebp
movq 0x10(%rsp), %r13
jmp 0x12b7c
incl %esi
movq %rbx, %rdi
callq 0x1341c
testl %eax, %eax
js 0x12abd
movl (%rbx), %r12d
leal -0x1(%r12), %esi
movsbl (%r14), %r13d
testl %r13d, %r13d
je 0x12a03
movb 0x1(%r14), %al
testb %al, %al
je 0x12a06
leaq 0x2(%r14), %rcx
movl %r13d, %edx
shll $0x5, %edx
subl %r13d, %edx
movsbl %al, %r13d
addl %edx, %r13d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x129e8
jmp 0x12a06
xorl %r13d, %r13d
andl %esi, %r13d
movq 0x10(%rbx), %rdi
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %eax
leal (,%r13,2), %ecx
shrl %cl, %eax
testb $0x2, %al
je 0x12a2c
movl %r13d, %r12d
jmp 0x12af4
movq %r14, 0x18(%rsp)
movq %rbx, (%rsp)
movl $0x1, %r15d
movl %r13d, %ebx
movq %r12, 0x30(%rsp)
movl %esi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x12ac5
testb $0x1, %al
jne 0x12a8f
movq (%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x18(%rsp), %rsi
callq 0x3620
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
testl %eax, %eax
je 0x12ac5
btl %ebp, %r14d
cmovbl %ebx, %r12d
addl %r15d, %ebx
andl %esi, %ebx
incl %r15d
cmpl %r13d, %ebx
jne 0x12a4c
movb $0x1, %al
movq 0x30(%rsp), %rdx
movl %edx, %ecx
cmpl %edx, %r12d
movq (%rsp), %rbx
movq 0x18(%rsp), %r14
je 0x12ae5
jmp 0x12af4
movl (%rbx), %r12d
jmp 0x12b6d
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x2, %r14b
sete %al
movl %r12d, %ecx
movl %ebx, %r13d
movq (%rsp), %rbx
movq 0x18(%rsp), %r14
movq 0x30(%rsp), %rdx
cmpl %edx, %ecx
cmovel %r13d, %ecx
testb %al, %al
cmovnel %r13d, %ecx
movl %ecx, %r12d
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %edx
leal (%r12,%r12), %ecx
andl $0x1e, %ecx
shrl %cl, %edx
movl %r12d, %esi
testb $0x2, %dl
jne 0x12b21
testb $0x1, %dl
movq 0x10(%rsp), %r13
jne 0x12b52
movq 0x20(%rbx), %rax
movl (%rax,%rsi,4), %ebp
jmp 0x12b7c
movq 0x18(%rbx), %rdx
movq %r14, (%rdx,%rsi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%rbx), %rcx
andl %edx, (%rcx,%rax,4)
movq 0x4(%rbx), %xmm0
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x4(%rbx)
movq 0x10(%rsp), %r13
jmp 0x12b6d
movq 0x18(%rbx), %rdx
movq %r14, (%rdx,%rsi,8)
movl $0x3, %edx
shll %cl, %edx
notl %edx
movq 0x10(%rbx), %rcx
andl %edx, (%rcx,%rax,4)
incl 0x4(%rbx)
movl 0x4(%rbx), %ebp
decl %ebp
movq 0x20(%rbx), %rax
movl %r12d, %ecx
movl %ebp, (%rax,%rcx,4)
movq 0x8(%r13), %rax
movslq %ebp, %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rbx
movl 0xc(%rbx), %eax
movl 0x10(%rbx), %r15d
leal 0x1(%rax), %ecx
movl %ecx, 0xc(%rbx)
cmpl %r15d, %eax
jge 0x12ba3
movq 0x18(%rbx), %rax
jmp 0x12be6
movl %eax, %ecx
sarl %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x2, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
sarl $0x8, %eax
orl %ecx, %eax
movl %eax, %ecx
sarl $0x10, %ecx
orl %eax, %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x10(%rbx)
movq 0x18(%rbx), %rdi
movslq %ecx, %rax
leaq 0x8(,%rax,8), %rsi
callq 0x37b0
movq %rax, 0x18(%rbx)
movl 0xc(%rbx), %ecx
movslq %ecx, %rcx
movq 0x8(%rsp), %rdx
movq %rdx, -0x8(%rax,%rcx,8)
movl 0x5c(%r13), %ecx
testl %ecx, %ecx
je 0x12c37
movl 0x10(%rbx), %edx
movq 0x20(%rbx), %rax
cmpl %edx, %r15d
jge 0x12c1d
imull %ecx, %edx
movslq %edx, %rsi
movq %rax, %rdi
callq 0x37b0
movq %rax, 0x20(%rbx)
movl 0x5c(%r13), %ecx
movslq 0xc(%rbx), %rdi
decq %rdi
movslq %ecx, %rdx
imulq %rdx, %rdi
addq %rax, %rdi
movq 0x60(%r13), %rsi
callq 0x3850
movl 0x8(%rsp), %r10d
cmpl %ebp, 0x50(%r13)
jne 0x12c60
movl 0x54(%r13), %ecx
cmpl %r10d, %ecx
ja 0x12c83
jne 0x12c60
movl 0x58(%r13), %r8d
movl 0xc(%rsp), %r11d
cmpl %r11d, %r8d
ja 0x12c8c
movl 0x8(%rsp), %r10d
movl %ebp, 0x50(%r13)
movl %r10d, 0x54(%r13)
movl 0xc(%rsp), %eax
movl %eax, 0x58(%r13)
xorl %ecx, %ecx
movl %ecx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x58(%r13), %r8d
movl 0xc(%rsp), %r11d
movq 0x4c355(%rip), %rax     # 0x5efe8
movq (%rax), %rdi
movq 0x48(%r13), %rdx
incl %ecx
incl %r8d
incl %r10d
incl %r11d
leaq 0x3bb70(%rip), %rsi     # 0x4e81c
movq %rdx, %r9
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x37e0
addq $0x10, %rsp
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jmp 0x12c72