// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
callq 0x13f80
movl %eax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1a5ae
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x1a97a
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x1a938
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
callq 0x16f20
movq -0x10(%rbp), %rcx
movq 0x28(%rcx), %rcx
movslq -0x20(%rbp), %rdx
movq %rax, (%rcx,%rdx,8)
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x24(%rbp), %rsi
movl $0x4, %edx
callq 0x64bb0
cmpq $0x4, %rax
je 0x1a619
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a628
leaq -0x24(%rbp), %rdi
callq 0x1a550
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1a7cd
movq -0x18(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x4, %edx
callq 0x64bb0
cmpq $0x4, %rax
je 0x1a65f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a66e
leaq -0x3c(%rbp), %rdi
callq 0x1a550
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x44(%rbp), %rdx
callq 0x19a40
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x44(%rbp)
jg 0x1a693
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x1a97a
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x1a6ec
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x8, %rsi
movl $0x8, %edx
callq 0x64bb0
cmpq $0x8, %rax
je 0x1a6d7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a6ea
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0x1a990
jmp 0x1a6f8
movq -0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x4, %rsi
movl $0x4, %edx
callq 0x64bb0
cmpq $0x4, %rax
je 0x1a720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a733
movq -0x50(%rbp), %rdi
addq $0x4, %rdi
callq 0x1a550
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x50(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rax
movslq (%rax), %rdi
shlq $0x4, %rdi
callq 0x47a0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x1a772
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1a97a
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
shll $0x4, %eax
movslq %eax, %rdx
callq 0x64bb0
movq -0x50(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x1a7ae
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a7bd
movq -0x50(%rbp), %rdi
callq 0x1a9c0
jmp 0x1a7bf
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1a62f
cmpl $0x0, -0x1c(%rbp)
je 0x1a928
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x4, %edx
callq 0x64bb0
cmpq $0x4, %rax
je 0x1a7fb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a80a
movq -0x38(%rbp), %rdi
callq 0x1a550
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rax
movslq (%rax), %rdi
shlq $0x3, %rdi
callq 0x47a0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x1a849
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1a97a
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x38(%rbp), %rax
movl (%rax), %eax
shll $0x3, %eax
movslq %eax, %rdx
callq 0x64bb0
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
shll $0x3, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
je 0x1a883
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a97a
cmpl $0x0, -0x28(%rbp)
je 0x1a8c0
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1a8be
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x58(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x1a990
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1a890
jmp 0x1a8c0
movl $0x1, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x1a917
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x1a90a
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x58(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1a90c
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x1a8c7
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
movl $0x1, %edx
callq 0x16350
jmp 0x1a92a
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1a5b5
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
movl $0x8, %edx
callq 0x64bb0
cmpq $0x8, %rax
je 0x1a960
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
cmpl $0x0, -0x28(%rbp)
je 0x1a973
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x1a990
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)