// File: /workspace/github_c_makefile_star2_O2/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 %rsp, %rbx
movq 0x48(%rdi), %rax
pushq $0xa
popq %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %r15
leaq 0x1(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x42f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x749b
movq %rbx, 0x18(%rsp)
movq 0x18(%r14), %rdi
leaq 0x6d227(%rip), %rdx     # 0x74578
movq %r12, %rsi
callq 0x7d08
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x74a0
movq %rax, %r12
xorl %ebp, %ebp
leaq 0x6d205(%rip), %r13     # 0x74578
xorl %ebx, %ebx
movq 0x18(%r14), %rsi
cmpq $0xa, %rbx
je 0x73c1
movq %r12, %rdi
movq %r13, %rdx
callq 0x83bc
movq %rax, 0x20(%rsp,%rbx,8)
testq %rax, %rax
js 0x7494
movq 0x40(%r14), %rsi
addq %rbp, %rsi
movq 0x18(%r14), %rcx
movq %r12, %rdi
movq %r15, %rdx
movq %r13, %r8
callq 0x816e
incq %rbx
addq %r15, %rbp
testq %rax, %rax
jns 0x7375
jmp 0x7494
leaq 0x6d1b0(%rip), %rdx     # 0x74578
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x7d69
testl %eax, %eax
jne 0x7494
movq 0x18(%r14), %rdi
leaq 0x70eaf(%rip), %rsi     # 0x78296
leaq 0x6d18a(%rip), %r12     # 0x74578
movq %r12, %rdx
callq 0x7d08
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x74a0
movq %rax, %r13
xorl %ebp, %ebp
cmpq 0x48(%r14), %rbp
jae 0x7477
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 0x8481
testq %rax, %rax
js 0x7494
movq 0x18(%r14), %rcx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %r12, %r8
callq 0x7e14
testq %rax, %rax
js 0x7494
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 0x7f1d
addq %r15, %rbp
testl %eax, %eax
je 0x7409
jmp 0x7494
movq 0x18(%r14), %rsi
leaq 0x6d0f6(%rip), %rdx     # 0x74578
leaq 0x8(%rsp), %rdi
xorl %ebp, %ebp
xorl %ecx, %ecx
callq 0x7d69
testl %eax, %eax
je 0x74d2
movq 0x8(%rsp), %r14
jmp 0x74a3
pushq $-0x1
popq %rbp
jmp 0x74e1
xorl %r14d, %r14d
movq 0x93b36(%rip), %rax     # 0x9afe0
movq (%rax), %rdi
leaq 0x6d0d3(%rip), %rsi     # 0x74587
leaq 0x6d0bd(%rip), %rdx     # 0x74578
xorl %eax, %eax
callq 0x4700
pushq $-0x1
popq %rbp
testq %r14, %r14
je 0x74d2
movq %r14, %rdi
callq 0xad16
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