// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test_bgzf.c
// Function: test_index_load_dump
static int test_index_load_dump(Files *f) {
    BGZF* bgz = NULL;
    FILE *fdest = NULL;
    unsigned char buf_src[BUFSZ], buf_dest[BUFSZ];
    ssize_t got_src, got_dest;

    bgz = try_bgzf_open(f->src_bgzf, "r", __func__);
    if (!bgz) return -1;

    if (try_bgzf_index_load(bgz, f->src_bgzf, idx_suffix, __func__) != 0) {
        goto fail;
    }

    if (try_bgzf_index_dump(bgz, f->tmp_bgzf, idx_suffix, __func__) != 0) {
        goto fail;
    }

    fdest = try_fopen(f->tmp_idx, "r");
    do {
        got_src  = try_fread(f->f_idx, buf_src,  BUFSZ, __func__, f->src_idx);
        if (got_src < 0) goto fail;
        got_dest = try_fread(fdest,    buf_dest, BUFSZ, __func__, f->tmp_idx);
        if (got_dest < 0) goto fail;
        if (compare_buffers(buf_src, buf_dest, got_src, got_dest,
                            f->src_idx, f->tmp_idx, __func__) != 0) goto fail;
    } while (got_src > 0 && got_dest > 0);
    if (try_fclose(&fdest, f->tmp_idx, __func__) != 0) goto fail;

    if (try_bgzf_close(&bgz, f->src_bgzf, __func__, 0) != 0) goto fail;

    return 0;

 fail:
    if (fdest) fclose(fdest);
    if (bgz) bgzf_close(bgz);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10018, %rsp          # imm = 0x10018
movq %rdi, %r14
movq $0x0, 0x8(%rsp)
movq 0x8(%rdi), %rdi
leaq 0x9109a(%rip), %rsi     # 0x98344
leaq 0x8d0d2(%rip), %rdx     # 0x94383
callq 0x85b7
movq %rax, 0x8(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0x7326
movq %rax, %r15
movq 0x8(%r14), %rsi
movq 0xae225(%rip), %rdx     # 0xb54f8
leaq 0x8d0a9(%rip), %rcx     # 0x94383
movq %rax, %rdi
callq 0x891b
testl %eax, %eax
jne 0x7307
movq 0x18(%r14), %rsi
movq 0xae207(%rip), %rdx     # 0xb54f8
leaq 0x8d08b(%rip), %r12     # 0x94383
movq %r15, %rdi
movq %r12, %rcx
callq 0x8951
testl %eax, %eax
je 0x733a
xorl %r15d, %r15d
testq %r15, %r15
je 0x7317
movq %r15, %rdi
callq 0x44a0
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x7326
callq 0xbc44
movl %ebx, %eax
addq $0x10018, %rsp          # imm = 0x10018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r14), %rdi
leaq 0x90fff(%rip), %rsi     # 0x98344
callq 0x859b
movq %rax, %r15
movq 0x10(%r14), %rcx
movq 0x38(%r14), %rdi
leaq 0x10(%rsp), %rsi
movq %r12, %rdx
callq 0x8700
testq %rax, %rax
js 0x7406
movq %rax, %rbp
movq 0x20(%r14), %rcx
movq %r15, %rdi
leaq 0x8010(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x8700
testq %rax, %rax
js 0x7406
movq %rax, %r13
movq 0x10(%r14), %r8
movq 0x20(%r14), %r9
movq %r12, (%rsp)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %rax, %rcx
callq 0x8760
testl %eax, %eax
jne 0x7406
testq %rbp, %rbp
je 0x73bd
testq %r13, %r13
jne 0x734d
movq 0x20(%r14), %r12
movq %r15, %rdi
callq 0x44a0
testl %eax, %eax
jne 0x73fb
movq 0x8(%r14), %rsi
leaq 0x8cfab(%rip), %rdx     # 0x94383
leaq 0x8(%rsp), %rdi
xorl %r15d, %r15d
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jne 0x730a
xorl %ebx, %ebx
jmp 0x7326
movq %r12, %rdi
callq 0x49fe
xorl %r15d, %r15d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x730a