// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts.c
// Function: hts_idx_push
int hts_idx_push(hts_idx_t *idx, int tid, hts_pos_t beg, hts_pos_t end, uint64_t offset, int is_mapped)
{
    int bin;
    if (tid<0) beg = -1, end = 0;
    if (hts_idx_check_range(idx, tid, beg, end) < 0)
        return -1;
    if (tid >= idx->m) { // enlarge the index
        uint32_t new_m = idx->m * 2 > tid + 1 ? idx->m * 2 : tid + 1;
        bidx_t **new_bidx;
        lidx_t *new_lidx;

        new_bidx = (bidx_t**)realloc(idx->bidx, new_m * sizeof(bidx_t*));
        if (!new_bidx) return -1;
        idx->bidx = new_bidx;

        new_lidx = (lidx_t*) realloc(idx->lidx, new_m * sizeof(lidx_t));
        if (!new_lidx) return -1;
        idx->lidx = new_lidx;

        memset(&idx->bidx[idx->m], 0, (new_m - idx->m) * sizeof(bidx_t*));
        memset(&idx->lidx[idx->m], 0, (new_m - idx->m) * sizeof(lidx_t));
        idx->m = new_m;
    }
    if (idx->n < tid + 1) idx->n = tid + 1;
    if (idx->z.finished) return 0;
    if (idx->z.last_tid != tid || (idx->z.last_tid >= 0 && tid < 0)) { // change of chromosome
        if ( tid>=0 && idx->n_no_coor )
        {
            hts_log_error("NO_COOR reads not in a single block at the end %d %d", tid, idx->z.last_tid);
            return -1;
        }
        if (tid>=0 && idx->bidx[tid] != 0)
        {
            hts_log_error("Chromosome blocks not continuous");
            return -1;
        }
        idx->z.last_tid = tid;
        idx->z.last_bin = 0xffffffffu;
    } else if (tid >= 0 && idx->z.last_coor > beg) { // test if positions are out of order
        hts_log_error("Unsorted positions on sequence #%d: %"PRIhts_pos" followed by %"PRIhts_pos, tid+1, idx->z.last_coor+1, beg+1);
        return -1;
    }
    if (end < beg) {
        // Malformed ranges are errors. (Empty ranges (beg==end) are unusual but acceptable.)
        hts_log_error("Invalid record on sequence #%d: end %"PRId64" < begin %"PRId64, tid+1, end, beg+1);
        return -1;
    }
    if ( tid>=0 )
    {
        if (idx->bidx[tid] == 0) idx->bidx[tid] = kh_init(bin);
        // shoehorn [-1,0) (VCF POS=0) into the leftmost bottom-level bin
        if (beg < 0)  beg = 0;
        if (end <= 0) end = 1;
        // idx->z.last_off points to the start of the current record
        if (insert_to_l(&idx->lidx[tid], beg, end,
                        idx->z.last_off, idx->min_shift) < 0) return -1;
    }
    else idx->n_no_coor++;
    bin = hts_reg2bin(beg, end, idx->min_shift, idx->n_lvls);
    if ((int)idx->z.last_bin != bin) { // then possibly write the binning index
        if (idx->z.save_bin != 0xffffffffu) { // save_bin==0xffffffffu only happens to the first record
            if (insert_to_b(idx->bidx[idx->z.save_tid], idx->z.save_bin,
                            idx->z.save_off, idx->z.last_off) < 0) return -1;
        }
        if (idx->z.last_bin == 0xffffffffu && idx->z.save_bin != 0xffffffffu) { // change of chr; keep meta information
            idx->z.off_end = idx->z.last_off;
            if (insert_to_b(idx->bidx[idx->z.save_tid], META_BIN(idx),
                            idx->z.off_beg, idx->z.off_end) < 0) return -1;
            if (insert_to_b(idx->bidx[idx->z.save_tid], META_BIN(idx),
                            idx->z.n_mapped, idx->z.n_unmapped) < 0) return -1;
            idx->z.n_mapped = idx->z.n_unmapped = 0;
            idx->z.off_beg = idx->z.off_end;
        }
        idx->z.save_off = idx->z.last_off;
        idx->z.save_bin = idx->z.last_bin = bin;
        idx->z.save_tid = tid;
    }
    if (is_mapped) ++idx->z.n_mapped;
    else ++idx->z.n_unmapped;
    idx->z.last_off = offset;
    idx->z.last_coor = beg;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x1f9c5
movq $-0x1, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x1f820
cmpl $0x0, %eax
jge 0x1f9ea
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jl 0x1fb02
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
shll %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1fa1b
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
shll %eax
movl %eax, -0x54(%rbp)
jmp 0x1fa24
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movl -0x3c(%rbp), %eax
movl %eax, %esi
shlq $0x3, %rsi
callq 0x4820
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x1fa57
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movl -0x3c(%rbp), %eax
imulq $0x18, %rax, %rsi
callq 0x4820
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1fa8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movq -0x50(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, %eax
movl %eax, %edx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x4250
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x18(%rax), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
subl 0x18(%rcx), %eax
movl %eax, %eax
imulq $0x18, %rax, %rdx
xorl %esi, %esi
callq 0x4250
movl -0x3c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1fb20
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x60(%rax)
je 0x1fb36
movl $0x0, -0x4(%rbp)
jmp 0x1ff1a
movq -0x10(%rbp), %rax
movl 0x58(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x1fb5a
movq -0x10(%rbp), %rax
cmpl $0x0, 0x58(%rax)
jl 0x1fbf2
cmpl $0x0, -0x14(%rbp)
jge 0x1fbf2
cmpl $0x0, -0x14(%rbp)
jl 0x1fb9c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1fb9c
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x58(%rax), %r8d
movl $0x1, %edi
leaq 0xd0b9c(%rip), %rsi     # 0xf071e
leaq 0xd0ba2(%rip), %rdx     # 0xf072b
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
cmpl $0x0, -0x14(%rbp)
jl 0x1fbdb
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x1fbdb
movl $0x1, %edi
leaq 0xd0b5d(%rip), %rsi     # 0xf071e
leaq 0xd0b98(%rip), %rdx     # 0xf0760
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x48(%rax) # imm = 0xFFFFFFFF
jmp 0x1fc48
cmpl $0x0, -0x14(%rbp)
jl 0x1fc46
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq -0x20(%rbp), %rax
jle 0x1fc46
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movq 0x50(%rax), %r8
addq $0x1, %r8
movq -0x20(%rbp), %r9
addq $0x1, %r9
movl $0x1, %edi
leaq 0xd0af2(%rip), %rsi     # 0xf071e
leaq 0xd0b4e(%rip), %rdx     # 0xf0781
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
jmp 0x1fc48
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x1fc8a
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %r8
movq -0x20(%rbp), %r9
addq $0x1, %r9
movl $0x1, %edi
leaq 0xd0aae(%rip), %rsi     # 0xf071e
leaq 0xd0b42(%rip), %rdx     # 0xf07b9
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
cmpl $0x0, -0x14(%rbp)
jl 0x1fd20
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x1fcbf
callq 0x1ff30
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0x20(%rbp)
jge 0x1fcce
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x28(%rbp)
jg 0x1fcdd
movq $0x1, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x14(%rbp), %rax
imulq $0x18, %rax, %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %r8d
callq 0x1ff50
cmpl $0x0, %eax
jge 0x1fd1e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
jmp 0x1fd30
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
callq 0x200d0
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
cmpl -0x38(%rbp), %eax
je 0x1fec7
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x4c(%rax)
je 0x1fdab
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
callq 0x1efb0
cmpl $0x0, %eax
jge 0x1fda9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
jmp 0x1fdab
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x48(%rax)
jne 0x1fe9c
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x4c(%rax)
je 0x1fe9c
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
addl $0x1, %esi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
callq 0x1efb0
cmpl $0x0, %eax
jge 0x1fe21
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x5c(%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
addl $0x1, %esi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rcx
callq 0x1efb0
cmpl $0x0, %eax
jge 0x1fe6b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1ff1a
movq -0x10(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x48(%rax)
movq -0x10(%rbp), %rax
movl %ecx, 0x4c(%rax)
movl -0x14(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x5c(%rax)
cmpl $0x0, -0x34(%rbp)
je 0x1fee5
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x88(%rax)
jmp 0x1fefb
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x90(%rax)
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)