// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bgzf.c
// Function: bgzf_idx_push
int bgzf_idx_push(BGZF *fp, hts_idx_t *hidx, int tid, hts_pos_t beg, hts_pos_t end, uint64_t offset, int is_mapped) {
    hts_idx_cache_entry *e;
    mtaux_t *mt = fp->mt;

    if (!mt)
        return hts_idx_push(hidx, tid, beg, end, offset, is_mapped);

    // Early check for out of range positions which would fail in hts_idx_push()
    if (hts_idx_check_range(hidx, tid, beg, end) < 0)
        return -1;

    pthread_mutex_lock(&mt->idx_m);

    mt->hts_idx = hidx;
    hts_idx_cache_t *ic = &mt->idx_cache;

    if (ic->nentries >= ic->mentries) {
        int new_sz = ic->mentries ? ic->mentries*2 : 1024;
        if (!(e = realloc(ic->e, new_sz * sizeof(*ic->e)))) {
            pthread_mutex_unlock(&mt->idx_m);
            return -1;
        }
        ic->e = e;
        ic->mentries = new_sz;
    }

    e = &ic->e[ic->nentries++];
    e->tid = tid;
    e->beg = beg;
    e->end = end;
    e->is_mapped = is_mapped;
    e->offset = offset & 0xffff;
    e->block_number = mt->block_number;

    pthread_mutex_unlock(&mt->idx_m);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xbf19
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
movl 0x10(%rbp), %r9d
callq 0x1f990
movl %eax, -0x4(%rbp)
jmp 0xc07e
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x1f820
cmpl $0x0, %eax
jge 0xbf3e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc07e
movq -0x48(%rbp), %rdi
addq $0xe0, %rdi
callq 0x4730
movq -0x18(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x108(%rax)
movq -0x48(%rbp), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl (%rax), %eax
movq -0x50(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jl 0xbff3
movq -0x50(%rbp), %rax
cmpl $0x0, 0x4(%rax)
je 0xbf92
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
movl %eax, -0x58(%rbp)
jmp 0xbf9c
movl $0x400, %eax            # imm = 0x400
movl %eax, -0x58(%rbp)
jmp 0xbf9c
movl -0x58(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x54(%rbp), %rax
imulq $0x28, %rax, %rsi
callq 0x4820
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0xbfdd
movq -0x48(%rbp), %rdi
addq $0xe0, %rdi
callq 0x4330
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc07e
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x54(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x50(%rbp), %rdx
movl (%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, (%rdx)
movslq %ecx, %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movl 0x10(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x38(%rbp), %rcx
andq $0xffff, %rcx           # imm = 0xFFFF
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq 0x110(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x48(%rbp), %rdi
addq $0xe0, %rdi
callq 0x4330
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)