// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10040, %rsp          # imm = 0x10040
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe7733(%rip), %rsi     # 0xee581
leaq 0xe352e(%rip), %rdx     # 0xea383
callq 0x8b70
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6e71
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7039
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq 0x101674(%rip), %rdx    # 0x1084f8
leaq 0xe34f8(%rip), %rcx     # 0xea383
callq 0x9540
cmpl $0x0, %eax
je 0x6e9a
jmp 0x7012
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq 0x10164b(%rip), %rdx    # 0x1084f8
leaq 0xe34cf(%rip), %rcx     # 0xea383
callq 0x9600
cmpl $0x0, %eax
je 0x6ec3
jmp 0x7012
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
leaq 0xe76af(%rip), %rsi     # 0xee581
callq 0x8af0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
leaq -0x8020(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movl $0x8000, %edx           # imm = 0x8000
leaq 0xe3485(%rip), %rcx     # 0xea383
callq 0x8dc0
movq %rax, -0x10028(%rbp)
cmpq $0x0, -0x10028(%rbp)
jge 0x6f19
jmp 0x7012
movq -0x20(%rbp), %rdi
leaq -0x10020(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %r8
movl $0x8000, %edx           # imm = 0x8000
leaq 0xe344b(%rip), %rcx     # 0xea383
callq 0x8dc0
movq %rax, -0x10030(%rbp)
cmpq $0x0, -0x10030(%rbp)
jge 0x6f53
jmp 0x7012
leaq -0x8020(%rbp), %rdi
leaq -0x10020(%rbp), %rsi
movq -0x10028(%rbp), %rdx
movq -0x10030(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x10(%rax), %r8
movq -0x10(%rbp), %rax
movq 0x20(%rax), %r9
leaq 0xe33fd(%rip), %rax     # 0xea383
movq %rax, (%rsp)
callq 0x8e70
cmpl $0x0, %eax
je 0x6f96
jmp 0x7012
jmp 0x6f98
xorl %eax, %eax
cmpq $0x0, -0x10028(%rbp)
movb %al, -0x10031(%rbp)
jle 0x6fbb
cmpq $0x0, -0x10030(%rbp)
setg %al
movb %al, -0x10031(%rbp)
movb -0x10031(%rbp), %al
testb $0x1, %al
jne 0x6edb
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
leaq -0x20(%rbp), %rdi
leaq 0xe33a7(%rip), %rdx     # 0xea383
callq 0x96c0
cmpl $0x0, %eax
je 0x6fe8
jmp 0x7012
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x18(%rbp), %rdi
leaq 0xe3388(%rip), %rdx     # 0xea383
xorl %ecx, %ecx
callq 0x8c10
cmpl $0x0, %eax
je 0x7009
jmp 0x7012
movl $0x0, -0x4(%rbp)
jmp 0x7039
cmpq $0x0, -0x20(%rbp)
je 0x7022
movq -0x20(%rbp), %rdi
callq 0x4490
cmpq $0x0, -0x18(%rbp)
je 0x7032
movq -0x18(%rbp), %rdi
callq 0xe0e0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x10040, %rsp          # imm = 0x10040
popq %rbp
retq
nopw %cs:(%rax,%rax)