// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test_bgzf.c
// Function: test_tell_read
static int test_tell_read(Files *f, const char *mode) {

    BGZF* bgz = NULL;
    ssize_t bg_put;
    size_t num_points = 10;
    size_t i, iskip = f->ltext / num_points;
    int64_t point_vos[num_points];

    unsigned char *bg_buf = calloc(iskip+1,1);
    if (!bg_buf) return -1;

    bgz = try_bgzf_open(f->tmp_bgzf, mode, __func__);
    if (!bgz) goto fail;

    for (i = 0; i < num_points; i++) {
        point_vos[i] = try_bgzf_tell(bgz, f->tmp_bgzf, __func__);
        if (point_vos[i] < 0) goto fail;
        bg_put = try_bgzf_write(bgz, f->text + i * iskip, iskip, f->tmp_bgzf, __func__);
        if (bg_put < 0) goto fail;
    }

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

    bgz = try_bgzf_open(f->tmp_bgzf, "r", __func__);
    if (!bgz) goto fail;

    for (i = 0; i < f->ltext; i += iskip) {
        if (try_bgzf_tell_expect(bgz, point_vos[i/iskip], f->tmp_bgzf, __func__) < 0) {
            goto fail;
        }
        if (try_bgzf_read(bgz, bg_buf, iskip, f->tmp_bgzf, __func__) < 0) {
            goto fail;
        }
        if (compare_buffers(f->text+i, bg_buf, iskip, iskip,
                f->tmp_bgzf, f->tmp_bgzf, __func__) != 0) {
            goto fail;
        }
    }

    if (try_bgzf_close(&bgz, f->tmp_bgzf, __func__, 0) != 0) goto fail;
    free(bg_buf);
    return 0;

 fail:
    fprintf(stderr, "%s: failed\n", __func__);
    if (bgz) bgzf_close(bgz);
    free(bg_buf);
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r12
movq %rdi, %r14
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
mulq 0x48(%rdi)
movq %rdx, %r15
movq %rsp, %rbx
shrq $0x3, %r15
leaq 0x1(%r15), %rdi
movl $0x1, %esi
callq 0x42f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7e83
movq %rbx, 0x18(%rsp)
movq 0x18(%r14), %rdi
leaq 0x89894(%rip), %rdx     # 0x91594
movq %r12, %rsi
callq 0x865e
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7e8a
movq %rax, %r12
xorl %ebp, %ebp
leaq 0x89872(%rip), %r13     # 0x91594
xorl %ebx, %ebx
movq 0x18(%r14), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x8ae5
movq %rax, 0x20(%rsp,%rbx,8)
testq %rax, %rax
js 0x7e4b
movq 0x40(%r14), %rsi
addq %rbp, %rsi
movq 0x18(%r14), %rcx
movq %r12, %rdi
movq %r15, %rdx
movq %r13, %r8
callq 0x893c
testq %rax, %rax
js 0x7e4b
incq %rbx
addq %r15, %rbp
cmpq $0xa, %rbx
jne 0x7d24
movq 0x18(%r14), %rsi
leaq 0x8981a(%rip), %rdx     # 0x91594
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x86bf
testl %eax, %eax
jne 0x7e4b
movq 0x18(%r14), %rdi
leaq 0x8d552(%rip), %rsi     # 0x952eb
leaq 0x897f4(%rip), %r12     # 0x91594
movq %r12, %rdx
callq 0x865e
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7e8a
cmpq $0x0, 0x48(%r14)
je 0x7e2e
movq %rax, %r13
xorl %ebp, %ebp
movq %rbp, %rax
xorl %edx, %edx
divq %r15
movq 0x20(%rsp,%rax,8), %rsi
movq 0x18(%r14), %rdx
movq %r13, %rdi
movq %r12, %rcx
callq 0x8b3d
testq %rax, %rax
js 0x7e4b
movq 0x18(%r14), %rcx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r8
callq 0x8732
testq %rax, %rax
js 0x7e4b
movq 0x40(%r14), %rdi
addq %rbp, %rdi
movq 0x18(%r14), %r8
movq %r12, (%rsp)
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r15, %rcx
movq %r8, %r9
callq 0x87f7
testl %eax, %eax
jne 0x7e4b
addq %r15, %rbp
cmpq 0x48(%r14), %rbp
jb 0x7dc2
movq 0x18(%r14), %rsi
leaq 0x8975b(%rip), %rdx     # 0x91594
leaq 0x8(%rsp), %rdi
xorl %ebp, %ebp
xorl %ecx, %ecx
callq 0x86bf
testl %eax, %eax
je 0x7e94
movq 0x8(%rsp), %r14
movq 0xab189(%rip), %rax     # 0xb2fe0
movq (%rax), %rdi
leaq 0x89742(%rip), %rsi     # 0x915a3
leaq 0x8972c(%rip), %rdx     # 0x91594
xorl %eax, %eax
callq 0x4700
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x7e94
movq %r14, %rdi
callq 0xbb59
jmp 0x7e94
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x7ea3
callq 0x4ac0
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rdi
callq 0x45b0
movq 0x18(%rsp), %rbx
movq %rbx, %rsp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq