// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/hts.c
// Function: hts_idx_load_local
static hts_idx_t *hts_idx_load_local(const char *fn)
{
    uint8_t magic[4];
    int i, is_be;
    hts_idx_t *idx = NULL;
    uint8_t *meta = NULL;
    BGZF *fp = bgzf_open(fn, "r");
    if (fp == NULL) return NULL;
    is_be = ed_is_big();
    if (bgzf_read(fp, magic, 4) != 4) goto fail;

    if (memcmp(magic, "CSI\1", 4) == 0) {
        uint32_t x[3], n;
        if (bgzf_read(fp, x, 12) != 12) goto fail;
        if (is_be) for (i = 0; i < 3; ++i) ed_swap_4p(&x[i]);
        if (x[2]) {
            if ((meta = (uint8_t*)malloc(x[2])) == NULL) goto fail;
            if (bgzf_read(fp, meta, x[2]) != x[2]) goto fail;
        }
        if (bgzf_read(fp, &n, 4) != 4) goto fail;
        if (is_be) ed_swap_4p(&n);
        if ((idx = hts_idx_init(n, HTS_FMT_CSI, 0, x[0], x[1])) == NULL) goto fail;
        idx->l_meta = x[2];
        idx->meta = meta;
        meta = NULL;
        if (hts_idx_load_core(idx, fp, HTS_FMT_CSI) < 0) goto fail;
    }
    else if (memcmp(magic, "TBI\1", 4) == 0) {
        uint32_t x[8];
        if (bgzf_read(fp, x, 32) != 32) goto fail;
        if (is_be) for (i = 0; i < 8; ++i) ed_swap_4p(&x[i]);
        if ((idx = hts_idx_init(x[0], HTS_FMT_TBI, 0, 14, 5)) == NULL) goto fail;
        idx->l_meta = 28 + x[7];
        if ((idx->meta = (uint8_t*)malloc(idx->l_meta)) == NULL) goto fail;
        memcpy(idx->meta, &x[1], 28);
        if (bgzf_read(fp, idx->meta + 28, x[7]) != x[7]) goto fail;
        if (hts_idx_load_core(idx, fp, HTS_FMT_TBI) < 0) goto fail;
    }
    else if (memcmp(magic, "BAI\1", 4) == 0) {
        uint32_t n;
        if (bgzf_read(fp, &n, 4) != 4) goto fail;
        if (is_be) ed_swap_4p(&n);
        idx = hts_idx_init(n, HTS_FMT_BAI, 0, 14, 5);
        if (hts_idx_load_core(idx, fp, HTS_FMT_BAI) < 0) goto fail;
    }
    else { errno = EINVAL; goto fail; }

    bgzf_close(fp);
    return idx;

fail:
    bgzf_close(fp);
    hts_idx_destroy(idx);
    free(meta);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x685ec(%rip), %rsi     # 0xdfd96
callq 0x9afb0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x777c7
movq $0x0, -0x8(%rbp)
jmp 0x77b15
callq 0x72270
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x14(%rbp), %rsi
movl $0x4, %edx
callq 0x9c7b0
cmpq $0x4, %rax
je 0x777ec
jmp 0x77af2
leaq -0x14(%rbp), %rax
movl (%rax), %eax
subl $0x1495343, %eax        # imm = 0x1495343
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x77923
movq -0x38(%rbp), %rdi
leaq -0x44(%rbp), %rsi
movl $0xc, %edx
callq 0x9c7b0
cmpq $0xc, %rax
je 0x77823
jmp 0x77af2
cmpl $0x0, -0x1c(%rbp)
je 0x77857
movl $0x0, -0x18(%rbp)
cmpl $0x3, -0x18(%rbp)
jge 0x77855
movslq -0x18(%rbp), %rax
leaq -0x44(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
callq 0x758f0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x77830
jmp 0x77857
cmpl $0x0, -0x3c(%rbp)
je 0x77897
movl -0x3c(%rbp), %eax
movl %eax, %edi
callq 0x69c0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x77876
jmp 0x77af2
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x3c(%rbp), %eax
movl %eax, %edx
callq 0x9c7b0
movl -0x3c(%rbp), %ecx
cmpq %rcx, %rax
je 0x77895
jmp 0x77af2
jmp 0x77897
movq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x4, %edx
callq 0x9c7b0
cmpq $0x4, %rax
je 0x778b4
jmp 0x77af2
cmpl $0x0, -0x1c(%rbp)
je 0x778c3
leaq -0x48(%rbp), %rdi
callq 0x758f0
movl -0x48(%rbp), %edi
movl -0x44(%rbp), %ecx
movl -0x40(%rbp), %r8d
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x74230
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x778e7
jmp 0x77af2
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x787d0
cmpl $0x0, %eax
jge 0x7791e
jmp 0x77af2
jmp 0x77adf
leaq -0x14(%rbp), %rax
movl (%rax), %eax
subl $0x1494254, %eax        # imm = 0x1494254
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x77a54
movq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x20, %edx
callq 0x9c7b0
cmpq $0x20, %rax
je 0x7795a
jmp 0x77af2
cmpl $0x0, -0x1c(%rbp)
je 0x7798e
movl $0x0, -0x18(%rbp)
cmpl $0x8, -0x18(%rbp)
jge 0x7798c
movslq -0x18(%rbp), %rax
leaq -0x70(%rbp), %rdi
shlq $0x2, %rax
addq %rax, %rdi
callq 0x758f0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x77967
jmp 0x7798e
movl -0x70(%rbp), %edi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x74230
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x779b9
jmp 0x77af2
movl -0x54(%rbp), %ecx
addl $0x1c, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
callq 0x69c0
movq -0x28(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0x779e7
jmp 0x77af2
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x6c(%rbp), %rcx
movq %rcx, (%rax)
movq -0x64(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x5c(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x54(%rbp), %ecx
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
addq $0x1c, %rsi
movl -0x54(%rbp), %eax
movl %eax, %edx
callq 0x9c7b0
movl -0x54(%rbp), %ecx
cmpq %rcx, %rax
je 0x77a33
jmp 0x77af2
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x2, %edx
callq 0x787d0
cmpl $0x0, %eax
jge 0x77a4f
jmp 0x77af2
jmp 0x77add
leaq -0x14(%rbp), %rax
movl (%rax), %eax
subl $0x1494142, %eax        # imm = 0x1494142
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x77ace
movq -0x38(%rbp), %rdi
leaq -0x74(%rbp), %rsi
movl $0x4, %edx
callq 0x9c7b0
cmpq $0x4, %rax
je 0x77a84
jmp 0x77af2
cmpl $0x0, -0x1c(%rbp)
je 0x77a93
leaq -0x74(%rbp), %rdi
callq 0x758f0
movl -0x74(%rbp), %edi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0xe, %ecx
movl $0x5, %r8d
callq 0x74230
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0x787d0
cmpl $0x0, %eax
jge 0x77acc
jmp 0x77af2
jmp 0x77adb
callq 0x6060
movl $0x16, (%rax)
jmp 0x77af2
jmp 0x77add
jmp 0x77adf
movq -0x38(%rbp), %rdi
callq 0x9d380
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x77b15
movq -0x38(%rbp), %rdi
callq 0x9d380
movq -0x28(%rbp), %rdi
callq 0x75440
movq -0x30(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)