// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x16578
movq -0x10(%rbp), %rdi
callq 0x16370
movl %eax, -0x4(%rbp)
jmp 0x16a61
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x60(%rcx), %r8
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %r9
leaq -0x20(%rbp), %rsi
leaq -0x28(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq *%rax
movl %eax, -0x34(%rbp)
cmpl $-0x2, -0x34(%rbp)
jne 0x165b7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16a61
cmpl $-0x1, -0x34(%rbp)
jne 0x165c9
movl $0x0, -0x4(%rbp)
jmp 0x16a61
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movl %eax, %esi
movq -0x10(%rbp), %rdx
addq $0x38, %rdx
callq 0x16a70
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0x16260
cmpl $0x0, %eax
je 0x16825
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x16723
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
sarl %ecx
movq -0x10(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x2, %ecx
movq -0x10(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x8, %ecx
movq -0x10(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
sarl $0x10, %ecx
movq -0x10(%rbp), %rax
orl 0x4(%rax), %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x4(%rax), %rax
imulq $0x28, %rax, %rsi
callq 0x37c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x40(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
subl -0x40(%rbp), %eax
cltq
imulq $0x28, %rax, %rdx
xorl %esi, %esi
callq 0x3090
movq -0x10(%rbp), %rax
movl (%rax), %eax
cmpl -0x3c(%rbp), %eax
jle 0x167d5
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
sarl %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x2, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x4, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x8, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x10, %eax
orl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x3c(%rbp), %rsi
shlq $0x3, %rsi
callq 0x37c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x44(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x3c(%rbp), %eax
subl -0x44(%rbp), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x3090
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x35f0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x16be0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x16916
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
sarl %ecx
movq -0x50(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
sarl $0x2, %ecx
movq -0x50(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
sarl $0x4, %ecx
movq -0x50(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
sarl $0x8, %ecx
movq -0x50(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
sarl $0x10, %ecx
movq -0x50(%rbp), %rax
orl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rax
movslq 0x10(%rax), %rsi
shlq $0x3, %rsi
callq 0x37c0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq -0x30(%rbp), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x5c(%rax)
je 0x169a9
movl -0x54(%rbp), %eax
movq -0x50(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x16973
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movq -0x50(%rbp), %rcx
imull 0x10(%rcx), %eax
movslq %eax, %rsi
callq 0x37c0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
subl $0x1, %ecx
imull %ecx, %eax
cltq
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x5c(%rax), %rdx
callq 0x3860
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
cmpl -0x38(%rbp), %eax
jne 0x16a3c
movq -0x10(%rbp), %rax
movl 0x54(%rax), %eax
cmpl -0x30(%rbp), %eax
ja 0x169dd
movq -0x10(%rbp), %rax
movl 0x54(%rax), %eax
cmpl -0x30(%rbp), %eax
jne 0x16a3a
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
cmpl -0x2c(%rbp), %eax
jbe 0x16a3a
movq 0x6e604(%rip), %rax     # 0x84fe8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x10(%rbp), %rax
movl 0x54(%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl 0x58(%rax), %r8d
addl $0x1, %r8d
movq -0x10(%rbp), %rax
movq 0x48(%rax), %r9
movl -0x30(%rbp), %r10d
addl $0x1, %r10d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
leaq 0x600df(%rip), %rsi     # 0x76b01
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x37f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x16a61
jmp 0x16a3c
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x54(%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)