// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/bgzf.c
// Function: bgzf_index_dump_hfile
int bgzf_index_dump_hfile(BGZF *fp, struct hFILE *idx, const char *name)
{
    // Note that the index contains one extra record when indexing files opened
    // for reading. The terminating record is not present when opened for writing.
    // This is not a bug.

    int i;

    if (!fp->idx) {
        hts_log_error("Called for BGZF handle with no index");
        errno = EINVAL;
        return -1;
    }

    if (bgzf_flush(fp) != 0) return -1;

    // discard the entry marking the end of the file
    if (fp->mt && fp->idx)
        fp->idx->noffs--;

    if (hwrite_uint64(fp->idx->noffs - 1, idx) < 0) goto fail;
    for (i=1; i<fp->idx->noffs; i++)
    {
        if (hwrite_uint64(fp->idx->offs[i].caddr, idx) < 0) goto fail;
        if (hwrite_uint64(fp->idx->offs[i].uaddr, idx) < 0) goto fail;
    }
    return 0;

 fail:
    hts_log_error("Error writing to %s : %s", name ? name : "index", strerror(errno));
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpq $0x0, 0x50(%rdi)
je 0xde3f
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0xcb85
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testl %ecx, %ecx
jne 0xe042
cmpq $0x0, 0x48(%r15)
movq 0x50(%r15), %rcx
movl (%rcx), %eax
je 0xddc6
decl %eax
movl %eax, (%rcx)
decl %eax
cltq
movq %rax, 0x8(%rsp)
testb $0x2, 0x30(%r14)
movq 0x18(%r14), %r12
jne 0xde01
movq %r12, %rax
subq 0x8(%r14), %rax
cmpq $0x7, %rax
ja 0xde01
subq (%r14), %r12
addq $0x8, %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0xee24
movq 0x18(%r14), %r12
movq %r12, 0x10(%r14)
movq %rbx, 0x10(%rsp)
movq 0x8(%r14), %rdi
subq %rdi, %r12
cmpq $0x8, %r12
ja 0xde18
cmpq (%r14), %rdi
je 0xde69
cmpq $0x8, %r12
movl $0x8, %r13d
cmovbq %r12, %r13
leaq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x43c0
addq %r13, 0x8(%r14)
cmpq $0x7, %r12
jbe 0xde6c
jmp 0xde84
leaq 0x86fc0(%rip), %rsi     # 0x94e06
leaq 0x86fcf(%rip), %rdx     # 0x94e1c
movl $0x1, %edi
xorl %eax, %eax
callq 0x13de5
callq 0x4050
movl $0x16, (%rax)
jmp 0xe03d
xorl %r13d, %r13d
leaq 0x8(%rsp), %rsi
movl $0x8, %edx
movq %r14, %rdi
movq %r13, %rcx
callq 0xf300
movq %rax, %r13
cmpq $0x8, %r13
jne 0xdffe
movq 0x50(%r15), %rcx
xorl %eax, %eax
cmpl $0x2, (%rcx)
jl 0xe042
movl $0x1, %ebx
xorl %r12d, %r12d
movq 0x8(%rcx), %rax
movq 0x18(%rax,%r12), %rax
movq %rax, 0x8(%rsp)
testb $0x2, 0x30(%r14)
movq 0x8(%r14), %rdi
movq 0x18(%r14), %r13
jne 0xdeec
movq %r13, %rax
subq %rdi, %rax
cmpq $0x7, %rax
ja 0xdeec
subq (%r14), %r13
addq $0x8, %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0xee24
movq 0x8(%r14), %rdi
movq 0x18(%r14), %r13
movq %r13, 0x10(%r14)
subq %rdi, %r13
cmpq $0x8, %r13
ja 0xdefa
cmpq (%r14), %rdi
je 0xdf20
cmpq $0x8, %r13
movl $0x8, %ebp
cmovbq %r13, %rbp
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x43c0
addq %rbp, 0x8(%r14)
cmpq $0x7, %r13
jbe 0xdf22
jmp 0xdf3a
xorl %ebp, %ebp
movl $0x8, %edx
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rcx
callq 0xf300
movq %rax, %rbp
cmpq $0x8, %rbp
jne 0xdffe
movq 0x50(%r15), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax,%r12), %rax
movq %rax, 0x8(%rsp)
testb $0x2, 0x30(%r14)
movq 0x8(%r14), %rdi
movq 0x18(%r14), %r13
jne 0xdf8f
movq %r13, %rax
subq %rdi, %rax
cmpq $0x7, %rax
ja 0xdf8f
subq (%r14), %r13
addq $0x8, %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0xee24
movq 0x8(%r14), %rdi
movq 0x18(%r14), %r13
movq %r13, 0x10(%r14)
subq %rdi, %r13
cmpq $0x8, %r13
ja 0xdf9d
cmpq (%r14), %rdi
je 0xdfc3
cmpq $0x8, %r13
movl $0x8, %ebp
cmovbq %r13, %rbp
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x43c0
addq %rbp, 0x8(%r14)
cmpq $0x7, %r13
jbe 0xdfc5
jmp 0xdfdd
xorl %ebp, %ebp
movl $0x8, %edx
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rcx
callq 0xf300
movq %rax, %rbp
cmpq $0x8, %rbp
jne 0xdffe
incq %rbx
movq 0x50(%r15), %rcx
movslq (%rcx), %rdx
addq $0x10, %r12
xorl %eax, %eax
cmpq %rdx, %rbx
jl 0xdea5
jmp 0xe042
movq 0x10(%rsp), %rax
testq %rax, %rax
leaq 0x8a40c(%rip), %r14     # 0x98419
cmovneq %rax, %r14
callq 0x4050
movl (%rax), %edi
callq 0x4150
leaq 0x86de2(%rip), %rsi     # 0x94e06
leaq 0x86e16(%rip), %rdx     # 0x94e41
movl $0x1, %edi
movq %r14, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x13de5
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq