// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/hts.c
// Function: idx_read_core
static int idx_read_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);
        if (n < 0) return -3;
        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 -2; // No memory
            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);
            if (p->n < 0) return -3;
            if ((size_t) p->n > SIZE_MAX / sizeof(hts_pair64_t)) return -2;
            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, ((size_t) p->n)<<4) != ((size_t) p->n)<<4) return -1;
            if (is_be) swap_bins(p);
        }
        if (fmt != HTS_FMT_CSI) { // load linear index
            int j, k;
            uint32_t x;
            if (bgzf_read(fp, &x, 4) != 4) return -1;
            if (is_be) ed_swap_4p(&x);
            l->n = x;
            if (l->n < 0) return -3;
            if ((size_t) l->n > SIZE_MAX / sizeof(uint64_t)) return -2;
            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 (k = j = 0; j < l->n && l->offset[j] == 0; k = ++j); // stop at the first non-zero entry
            for (j = l->n-1; j > k; j--) // fill missing values; may happen given older samtools and tabix
                if (l->offset[j-1] == 0) l->offset[j-1] = l->offset[j];
            update_loff(idx, i, 0);
        }
    }
    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);
#ifdef DEBUG_INDEX
    idx_dump(idx);
#endif

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %edx, 0xc(%rsp)
movq %rsi, %r13
movq %rdi, %r14
cmpl $0x0, 0x14(%rdi)
jle 0x1d0af
xorl %r15d, %r15d
leaq 0x4(%rsp), %r12
movq %rsp, %rbx
movq %r14, 0x28(%rsp)
movq %r13, 0x10(%rsp)
leaq (%r15,%r15,2), %rax
shlq $0x3, %rax
addq 0x30(%r14), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq 0x28(%r14), %rcx
movq %rax, 0x30(%rsp)
movq %rax, (%rcx,%r15,8)
movl $0x4, %edx
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
callq 0xbf5d
cmpq $0x4, %rax
jne 0x1d06c
cmpl $0x0, 0x8(%rsp)
js 0x1d075
cmpl $0x0, 0x8(%rsp)
jle 0x1cf68
xorl %r14d, %r14d
movl $0x4, %edx
movq %r13, %rdi
movq %r12, %rsi
callq 0xbf5d
cmpq $0x4, %rax
jne 0x1ce7c
movl 0x4(%rsp), %esi
movq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x1c58e
movl (%rsp), %ecx
testl %ecx, %ecx
js 0x1ce88
je 0x1ce94
movq 0x30(%rsp), %rcx
movq 0x20(%rcx), %rbx
movl %eax, %eax
leaq (%rax,%rax,2), %r12
leaq (%rbx,%r12,8), %rsi
addq $0x8, %rsi
cmpl $0x0, 0xc(%rsp)
je 0x1cea0
movq $0x0, (%rsi)
jmp 0x1ceb3
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1cf52
xorl %eax, %eax
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
jmp 0x1cf52
xorl %eax, %eax
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x1cf52
movl $0x8, %edx
movq %r13, %rdi
callq 0xbf5d
cmpq $0x8, %rax
jne 0x1cf2c
leaq (%rbx,%r12,8), %r12
movq %r13, %rdi
leaq 0x4(%r12), %r13
movl $0x4, %edx
movq %r13, %rsi
callq 0xbf5d
cmpq $0x4, %rax
jne 0x1cf23
movslq (%r13), %rbx
testq %rbx, %rbx
js 0x1cf35
movl %ebx, (%r12)
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x4680
movq %rax, 0x10(%r12)
testq %rax, %rax
je 0x1cf3e
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0xbf5d
movslq (%r13), %rcx
movq %r12, %r13
shlq $0x4, %rcx
cmpq %rcx, %rax
sete %al
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmovnel %ecx, %ebp
jmp 0x1cf4a
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1cf45
xorl %eax, %eax
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1cf4a
xorl %eax, %eax
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x1cf45
xorl %eax, %eax
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq 0x10(%rsp), %r13
leaq 0x4(%rsp), %r12
movq %rsp, %rbx
testb %al, %al
je 0x1d07e
incl %r14d
cmpl 0x8(%rsp), %r14d
jl 0x1ce25
cmpl $0x0, 0xc(%rsp)
movq 0x28(%rsp), %r14
je 0x1d087
movl $0x4, %edx
movq %r13, %rdi
leaq 0x24(%rsp), %rsi
callq 0xbf5d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq $0x4, %rax
jne 0x1d08b
movl 0x24(%rsp), %ebx
movq 0x18(%rsp), %rax
movq %rbx, (%rax)
movq %rbx, 0x8(%rax)
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x4680
movq 0x18(%rsp), %rcx
movq %rax, 0x10(%rcx)
testq %rax, %rax
je 0x1d08f
movq %r13, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0xbf5d
movq 0x18(%rsp), %rdi
movq (%rdi), %rdx
leaq (,%rdx,8), %rsi
xorl %ecx, %ecx
cmpq %rsi, %rax
movq %rsp, %rbx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
jne 0x1d099
testq %rdx, %rdx
jle 0x1d015
movq 0x10(%rdi), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x1d015
incq %rcx
cmpq %rcx, %rdx
jne 0x1d003
movq %rdx, %rcx
leal -0x1(%rdx), %esi
cmpl %ecx, %esi
jle 0x1d059
movq 0x10(%rdi), %rax
movslq %esi, %rdi
movslq %ecx, %rcx
movq %rdx, %rsi
movq %rdi, %rdx
shlq $0x20, %rsi
movabsq $-0x200000000, %rdi     # imm = 0xFFFFFFFE00000000
addq %rdi, %rsi
sarq $0x1d, %rsi
cmpq $0x0, (%rax,%rsi)
jne 0x1d050
movq (%rax,%rdx,8), %rdi
movq %rdi, (%rax,%rsi)
leaq -0x1(%rdx), %rdi
cmpq %rcx, %rdi
jg 0x1d026
movq %r14, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x16d0c
movb $0x1, %cl
movl %ebp, %esi
jmp 0x1d099
xorl %ecx, %ecx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1d09b
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
xorl %ecx, %ecx
jmp 0x1d09b
xorl %ecx, %ecx
movq 0x28(%rsp), %r14
jmp 0x1d09b
movb $0x1, %cl
jmp 0x1d09b
xorl %ecx, %ecx
jmp 0x1d099
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
xorl %ecx, %ecx
movq %rsp, %rbx
movl %esi, %ebp
testb %cl, %cl
je 0x1d0d2
incq %r15
movslq 0x14(%r14), %rax
cmpq %rax, %r15
jl 0x1cdc3
addq $0x20, %r14
movl $0x8, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0xbf5d
xorl %ebp, %ebp
cmpq $0x8, %rax
je 0x1d0d2
movq $0x0, (%r14)
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop