// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/htslib/hts.c
// Function: hts_idx_load_core
static int hts_idx_load_core(hts_idx_t *idx, BGZF *fp, int fmt)
{
    int32_t i, n, is_be;
    is_be = ed_is_big();
    if (idx == NULL) return -4;
    for (i = 0; i < idx->n; ++i) {
        bidx_t *h;
        lidx_t *l = &idx->lidx[i];
        uint32_t key;
        int j, absent;
        bins_t *p;
        h = idx->bidx[i] = kh_init(bin);
        if (bgzf_read(fp, &n, 4) != 4) return -1;
        if (is_be) ed_swap_4p(&n);
        for (j = 0; j < n; ++j) {
            khint_t k;
            if (bgzf_read(fp, &key, 4) != 4) return -1;
            if (is_be) ed_swap_4p(&key);
            k = kh_put(bin, h, key, &absent);
            if (absent <= 0) return -3; // Duplicate bin number
            p = &kh_val(h, k);
            if (fmt == HTS_FMT_CSI) {
                if (bgzf_read(fp, &p->loff, 8) != 8) return -1;
                if (is_be) ed_swap_8p(&p->loff);
            } else p->loff = 0;
            if (bgzf_read(fp, &p->n, 4) != 4) return -1;
            if (is_be) ed_swap_4p(&p->n);
            p->m = p->n;
            p->list = (hts_pair64_t*)malloc(p->m * sizeof(hts_pair64_t));
            if (p->list == NULL) return -2;
            if (bgzf_read(fp, p->list, p->n<<4) != p->n<<4) return -1;
            if (is_be) swap_bins(p);
        }
        if (fmt != HTS_FMT_CSI) { // load linear index
            int j;
            if (bgzf_read(fp, &l->n, 4) != 4) return -1;
            if (is_be) ed_swap_4p(&l->n);
            l->m = l->n;
            l->offset = (uint64_t*)malloc(l->n * sizeof(uint64_t));
            if (l->offset == NULL) return -2;
            if (bgzf_read(fp, l->offset, l->n << 3) != l->n << 3) return -1;
            if (is_be) for (j = 0; j < l->n; ++j) ed_swap_8p(&l->offset[j]);
            for (j = 1; j < l->n; ++j) // fill missing values; may happen given older samtools and tabix
                if (l->offset[j] == 0) l->offset[j] = l->offset[j-1];
            update_loff(idx, i, 1);
        }
    }
    if (bgzf_read(fp, &idx->n_no_coor, 8) != 8) idx->n_no_coor = 0;
    if (is_be) ed_swap_8p(&idx->n_no_coor);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, 0xc(%rsp)
testq %rdi, %rdi
je 0x10af4
movq %rsi, %r15
movq %rdi, %rbx
xorl %ecx, %ecx
pushq $0x4
popq %r12
pushq $-0x1
popq %r13
movq %rdi, 0x20(%rsp)
movslq 0x14(%rbx), %rax
cmpq %rax, %rcx
jge 0x10b16
movq %rcx, %rax
shlq $0x4, %rax
addq 0x30(%rbx), %rax
movq %rax, 0x28(%rsp)
movq %rcx, %r14
callq 0xec8f
movq %rbx, %rcx
movq %rax, %rbx
movq 0x28(%rcx), %rax
movq %r14, 0x30(%rsp)
movq %rbx, (%rax,%r14,8)
movq %r15, %rdi
leaq 0x1c(%rsp), %rsi
movq %r12, %rdx
callq 0x37049
cmpq $0x4, %rax
jne 0x10b04
incl %r13d
cmpl 0x1c(%rsp), %r13d
jge 0x10a38
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
movq %r12, %rdx
callq 0x37049
cmpq $0x4, %rax
jne 0x10af8
movl 0x18(%rsp), %esi
movq %rbx, %rdi
leaq 0x14(%rsp), %rdx
callq 0x104a1
cmpl $0x0, 0x14(%rsp)
jle 0x10afc
movq 0x20(%rbx), %rbp
movl %eax, %eax
imulq $0x18, %rax, %r14
leaq (%r14,%rbp), %rsi
addq $0x8, %rsi
cmpl $0x0, 0xc(%rsp)
je 0x1099e
andq $0x0, (%rsi)
jmp 0x109b3
movq %r15, %rdi
pushq $0x8
popq %rdx
callq 0x37049
cmpq $0x8, %rax
jne 0x10af8
addq %r14, %rbp
leaq 0x4(%rbp), %r14
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x37049
cmpq $0x4, %rax
jne 0x10af8
movl %r13d, 0x10(%rsp)
movq %rbx, %r13
movq %r12, %rbx
movq %r15, %r12
movslq 0x4(%rbp), %r15
movl %r15d, (%rbp)
movq %r15, %rdi
shlq $0x4, %rdi
callq 0x46f0
movq %rax, 0x10(%rbp)
testq %rax, %rax
je 0x10b00
shll $0x4, %r15d
movslq %r15d, %rdx
movq %r12, %r15
movq %r12, %rdi
movq %rax, %rsi
callq 0x37049
movl (%r14), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
movq %rbx, %r12
movq %r13, %rbx
movl 0x10(%rsp), %r13d
je 0x1093b
jmp 0x10af8
cmpl $0x0, 0xc(%rsp)
pushq $-0x1
popq %r13
movq 0x20(%rsp), %rbx
je 0x10ae7
movq %r15, %rdi
movq 0x28(%rsp), %r14
movq %r14, %rsi
movq %r12, %rdx
callq 0x37049
cmpq $0x4, %rax
jne 0x10b04
movslq (%r14), %rbx
movl %ebx, 0x4(%r14)
movq %rbx, %rdi
shlq $0x3, %rdi
callq 0x46f0
movq %rax, 0x8(%r14)
testq %rax, %rax
je 0x10b00
leal (,%rbx,8), %ecx
movslq %ecx, %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x37049
movq 0x28(%rsp), %rdi
movslq (%rdi), %rcx
leal (,%rcx,8), %edx
movslq %edx, %rdx
cmpq %rdx, %rax
jne 0x10b04
pushq $0x1
popq %rax
movq 0x20(%rsp), %rbx
cmpq %rcx, %rax
jge 0x10ad7
movq 0x8(%rdi), %rdx
cmpq $0x0, (%rdx,%rax,8)
jne 0x10ad2
movq -0x8(%rdx,%rax,8), %rsi
movq %rsi, (%rdx,%rax,8)
incq %rax
jmp 0x10ab9
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xe703
movq 0x30(%rsp), %rcx
incq %rcx
jmp 0x108e9
pushq $-0x4
jmp 0x10b02
pushq $-0x1
jmp 0x10b02
pushq $-0x3
jmp 0x10b02
pushq $-0x2
popq %r13
movl %r13d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x20, %rbx
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x37049
xorl %r13d, %r13d
cmpq $0x8, %rax
je 0x10b04
andq $0x0, (%rbx)
jmp 0x10b04
nop