// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/regidx.c
// Function: regidx_push
int regidx_push(regidx_t *idx, char *chr_beg, char *chr_end, hts_pos_t beg, hts_pos_t end, void *payload)
{
    if (beg < 0) beg = 0;
    if (end < 0) end = 0;
    if ( beg > MAX_COOR_0 ) beg = MAX_COOR_0;
    if ( end > MAX_COOR_0 ) end = MAX_COOR_0;

    int rid;
    if (kputsn(chr_beg, chr_end-chr_beg+1, ks_clear(&idx->str)) < 0) return -1;
    if ( khash_str2int_get(idx->seq2regs, idx->str.s, &rid)!=0 )
    {
        // new chromosome
        int m_tmp = idx->mseq;
        if (hts_resize(char*, idx->nseq + 1, &m_tmp,
                       &idx->seq_names, HTS_RESIZE_CLEAR) < 0) {
            return -1;
        }
        if (hts_resize(reglist_t, idx->nseq + 1, &idx->mseq,
                       &idx->seq, HTS_RESIZE_CLEAR) < 0) {
            return -1;
        }
        assert(m_tmp == idx->mseq);
        idx->seq_names[idx->nseq] = strdup(idx->str.s);
        rid = khash_str2int_inc(idx->seq2regs, idx->seq_names[idx->nseq]);
        idx->nseq++;
    }

    reglist_t *list = &idx->seq[rid];
    list->seq = idx->seq_names[rid];
    int mreg = list->mreg;
    if (hts_resize(reg_t, list->nreg + 1, &list->mreg, &list->reg, 0) < 0)
        return -1;
    list->reg[list->nreg].beg = beg;
    list->reg[list->nreg].end = end;
    if ( idx->payload_size ) {
        if ( mreg != list->mreg ) {
            uint8_t *new_dat = realloc(list->dat, idx->payload_size*list->mreg);
            if (!new_dat) return -1;
            list->dat = new_dat;
        }
        memcpy(list->dat + idx->payload_size*list->nreg, payload, idx->payload_size);
    }
    list->nreg++;
    if ( !list->unsorted && list->nreg>1 && cmp_regs(&list->reg[list->nreg-2],&list->reg[list->nreg-1])>0 ) list->unsorted = 1;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0x2ddb2
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x2ddc1
movq $0x0, -0x30(%rbp)
movabsq $0x800000000, %rax      # imm = 0x800000000
cmpq %rax, -0x28(%rbp)
jbe 0x2dddf
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, -0x28(%rbp)
movabsq $0x800000000, %rax      # imm = 0x800000000
cmpq %rax, -0x30(%rbp)
jbe 0x2ddfd
movabsq $0x800000000, %rax      # imm = 0x800000000
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
addq $0x48, %rdi
callq 0x2dc90
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq %rax, %rdx
callq 0x2dbe0
cmpl $0x0, %eax
jge 0x2de46
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2e19f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x2d9c0
cmpl $0x0, %eax
je 0x2dfc4
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
cmpl -0x40(%rbp), %eax
jle 0x2debd
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
movq -0x10(%rbp), %r8
addq $0x18, %r8
movl $0x8, %edi
movl $0x4, %edx
leaq -0x40(%rbp), %rcx
movl $0x1, %r9d
leaq 0xc31d8(%rip), %rax     # 0xf1087
movq %rax, (%rsp)
callq 0x1e4a0
movl %eax, -0x6c(%rbp)
jmp 0x2dec4
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x2dec4
movl -0x6c(%rbp), %eax
cmpl $0x0, %eax
jge 0x2ded8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2e19f
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jle 0x2df2b
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
movq -0x10(%rbp), %rcx
addq $0x4, %rcx
movq -0x10(%rbp), %r8
addq $0x8, %r8
movl $0x38, %edi
movl $0x4, %edx
movl $0x1, %r9d
leaq 0xc316a(%rip), %rax     # 0xf1087
movq %rax, (%rsp)
callq 0x1e4a0
movl %eax, -0x70(%rbp)
jmp 0x2df32
xorl %eax, %eax
movl %eax, -0x70(%rbp)
jmp 0x2df32
movl -0x70(%rbp), %eax
cmpl $0x0, %eax
jge 0x2df46
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2e19f
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jne 0x2df54
jmp 0x2df73
leaq 0xc3138(%rip), %rdi     # 0xf1093
leaq 0xc3144(%rip), %rsi     # 0xf10a6
movl $0xac, %edx
leaq 0xc3141(%rip), %rcx     # 0xf10af
callq 0x42e0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x4920
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %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
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2e1b0
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x3c(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x48(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jbe 0x2e050
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
movq -0x48(%rbp), %rcx
addq $0x10, %rcx
movq -0x48(%rbp), %r8
addq $0x18, %r8
movl $0x10, %edi
movl $0x4, %edx
xorl %r9d, %r9d
leaq 0xc3045(%rip), %rax     # 0xf1087
movq %rax, (%rsp)
callq 0x1e4a0
movl %eax, -0x74(%rbp)
jmp 0x2e057
xorl %eax, %eax
movl %eax, -0x74(%rbp)
jmp 0x2e057
movl -0x74(%rbp), %eax
cmpl $0x0, %eax
jge 0x2e06b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2e19f
movq -0x28(%rbp), %rcx
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rdx
movl 0xc(%rdx), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x48(%rbp), %rdx
movl 0xc(%rdx), %edx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x2e12c
movl -0x4c(%rbp), %eax
movq -0x48(%rbp), %rcx
cmpl 0x10(%rcx), %eax
je 0x2e0ff
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x48(%rbp), %rcx
imull 0x10(%rcx), %eax
movl %eax, %eax
movl %eax, %esi
callq 0x4820
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x2e0f3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2e19f
movq -0x58(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movq -0x48(%rbp), %rcx
imull 0xc(%rcx), %eax
movl %eax, %eax
addq %rax, %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq 0x38(%rax), %rdx
callq 0x43b0
movq -0x48(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq -0x48(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x2e198
movq -0x48(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jbe 0x2e198
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
subl $0x2, %eax
movl %eax, %eax
shlq $0x4, %rax
addq %rax, %rdi
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x48(%rbp), %rax
movl 0xc(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
shlq $0x4, %rax
addq %rax, %rsi
callq 0x2e250
cmpl $0x0, %eax
jle 0x2e198
movq -0x48(%rbp), %rax
movl $0x1, 0x30(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)