// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
callq 0x1cf00
movl %eax, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x2938e
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x2984e
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x2980c
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x20(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
callq 0x1ff30
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 0xe620
cmpq $0x4, %rax
je 0x293f9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x29408
leaq -0x24(%rbp), %rdi
callq 0x29330
cmpl $0x0, -0x24(%rbp)
jge 0x2941a
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x2984e
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x29608
movq -0x18(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
movl $0x4, %edx
callq 0xe620
cmpq $0x4, %rax
je 0x29451
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x29460
leaq -0x3c(%rbp), %rdi
callq 0x29330
movq -0x30(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x44(%rbp), %rdx
callq 0x26fa0
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x29485
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2984e
cmpl $0x0, -0x44(%rbp)
jne 0x29497
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x2984e
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 0x294f0
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x8, %rsi
movl $0x8, %edx
callq 0xe620
cmpq $0x8, %rax
je 0x294db
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x294ee
movq -0x50(%rbp), %rdi
addq $0x8, %rdi
callq 0x29860
jmp 0x294fc
movq -0x50(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x4, %rsi
movl $0x4, %edx
callq 0xe620
cmpq $0x4, %rax
je 0x29524
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x29537
movq -0x50(%rbp), %rdi
addq $0x4, %rdi
callq 0x29330
movq -0x50(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jge 0x2954d
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x2984e
movq -0x50(%rbp), %rax
movslq 0x4(%rax), %rax
movabsq $0xfffffffffffffff, %rcx # imm = 0xFFFFFFFFFFFFFFF
cmpq %rcx, %rax
jbe 0x29570
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2984e
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 0x4650
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x295af
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2984e
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x50(%rbp), %rax
movslq 0x4(%rax), %rdx
shlq $0x4, %rdx
callq 0xe620
movq -0x50(%rbp), %rcx
movslq 0x4(%rcx), %rcx
shlq $0x4, %rcx
cmpq %rcx, %rax
je 0x295e9
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x295f8
movq -0x50(%rbp), %rdi
callq 0x29890
jmp 0x295fa
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x29421
cmpl $0x0, -0x1c(%rbp)
je 0x297fc
movq -0x18(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x4, %edx
callq 0xe620
cmpq $0x4, %rax
je 0x29636
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x29645
leaq -0x60(%rbp), %rdi
callq 0x29330
movl -0x60(%rbp), %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, (%rax)
jge 0x29667
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
jmp 0x2984e
movq -0x38(%rbp), %rax
movabsq $0x1fffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFFF
cmpq %rcx, (%rax)
jbe 0x29686
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2984e
movq -0x38(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
shlq $0x3, %rdi
callq 0x4650
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x296c7
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x2984e
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x38(%rbp), %rax
movq (%rax), %rdx
shlq $0x3, %rdx
callq 0xe620
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
shlq $0x3, %rcx
cmpq %rcx, %rax
je 0x296ff
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2984e
cmpl $0x0, -0x28(%rbp)
je 0x2973e
movl $0x0, -0x58(%rbp)
movslq -0x58(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x2973c
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x58(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x29860
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x2970c
jmp 0x2973e
movl $0x0, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movslq -0x58(%rbp), %rcx
movq -0x38(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x61(%rbp)
jge 0x29775
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x58(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
sete %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x2977e
jmp 0x2978e
jmp 0x29780
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2974c
movq -0x38(%rbp), %rax
movq (%rax), %rax
subq $0x1, %rax
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jle 0x297ee
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x297e1
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x58(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x297e3
movl -0x58(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x2979c
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
xorl %edx, %edx
callq 0x1f130
jmp 0x297fe
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x29395
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
movl $0x8, %edx
callq 0xe620
cmpq $0x8, %rax
je 0x29834
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
cmpl $0x0, -0x28(%rbp)
je 0x29847
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x29860
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)