// File: /workspace/github_c_makefile_star2_O1/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
movq $0x0, 0x8(%rsp)
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 0x7dde
movq %rbx, 0x18(%rsp)
movq 0x18(%r14), %rdi
leaq 0x8c929(%rip), %rdx     # 0x94578
movq %r12, %rsi
callq 0x85b7
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7d9a
movq %rax, %r12
xorl %ebp, %ebp
leaq 0x8c907(%rip), %r13     # 0x94578
xorl %ebx, %ebx
movq 0x18(%r14), %rsi
movq %r12, %rdi
movq %r13, %rdx
callq 0x8a49
movq %rax, 0x20(%rsp,%rbx,8)
testq %rax, %rax
js 0x7d9a
movq 0x40(%r14), %rsi
addq %rbp, %rsi
movq 0x18(%r14), %rcx
movq %r12, %rdi
movq %r15, %rdx
movq %r13, %r8
callq 0x88a5
testq %rax, %rax
js 0x7d9a
incq %rbx
addq %r15, %rbp
cmpq $0xa, %rbx
jne 0x7c73
movq 0x18(%r14), %rsi
leaq 0x8c8af(%rip), %rdx     # 0x94578
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
jne 0x7d9a
movq 0x18(%r14), %rdi
leaq 0x9065c(%rip), %rsi     # 0x98344
leaq 0x8c889(%rip), %r12     # 0x94578
movq %r12, %rdx
callq 0x85b7
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7d9a
cmpq $0x0, 0x48(%r14)
je 0x7d7d
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 0x8aa1
testq %rax, %rax
js 0x7d9a
movq 0x18(%r14), %rcx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r8
callq 0x868e
testq %rax, %rax
js 0x7d9a
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 0x8760
testl %eax, %eax
jne 0x7d9a
addq %r15, %rbp
cmpq 0x48(%r14), %rbp
jb 0x7d11
movq 0x18(%r14), %rsi
leaq 0x8c7f0(%rip), %rdx     # 0x94578
leaq 0x8(%rsp), %rdi
xorl %ebp, %ebp
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
je 0x7dcd
movq 0xad23f(%rip), %rax     # 0xb4fe0
movq (%rax), %rdi
leaq 0x8c7dc(%rip), %rsi     # 0x94587
leaq 0x8c7c6(%rip), %rdx     # 0x94578
xorl %eax, %eax
callq 0x4700
movq 0x8(%rsp), %rdi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x7dcd
callq 0xbc44
movq 0x10(%rsp), %rdi
callq 0x45b0
movq 0x18(%rsp), %rbx
jmp 0x7de3
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rsp
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq