// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test_bgzf.c
// Function: test_index_useek_getc
static int test_index_useek_getc(Files *f, const char *mode,
                                 int cache_size, int nthreads) {
    BGZF* bgz = NULL;
    ssize_t bg_put;
    size_t i, j, k, iskip = f->ltext / 10;
    int is_uncompressed = strchr(mode, 'u') != NULL;
    size_t offsets[3] = { 0, 100, 50 };

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

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

    if (nthreads > 0 && try_bgzf_mt(bgz, nthreads, __func__) != 0) goto fail;

    bg_put = try_bgzf_write(bgz, f->text, f->ltext, f->tmp_bgzf, __func__);
    if (bg_put < 0) goto fail;

    if (!is_uncompressed) {
        if (try_bgzf_index_dump(bgz, f->tmp_idx, NULL, __func__) != 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;

    if (nthreads > 0 && try_bgzf_mt(bgz, nthreads, __func__) != 0) goto fail;

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

    for (i = 0; i < f->ltext; i += iskip) {
        for (k = 0; k < sizeof(offsets) / sizeof(offsets[0]); k++) {
            size_t o = offsets[k];
            if (try_bgzf_useek(bgz, i + o, SEEK_SET, f->tmp_bgzf, __func__) != 0) {
                goto fail;
            }

            for (j = 0; j < 16 && i + o + j < f->ltext; j++) {
                if (try_bgzf_getc(bgz, i + o + j, f->text[i + o + j],
                                  f->tmp_bgzf, __func__) < 0) goto fail;
            }
        }
    }

    if (try_bgzf_useek(bgz, 0, SEEK_SET, f->tmp_bgzf, __func__) != 0) {
        goto fail;
    }
    for (j = 0; j < 70000 && j < f->ltext; j++) { // Should force a block load
        if (try_bgzf_getc(bgz, j, f->text[j],
                          f->tmp_bgzf, __func__) < 0) goto fail;
    }

    if (cache_size > 0) {
        size_t mid = f->ltext / 2;
        bgzf_set_cache_size(bgz, cache_size);

        for (i = 0; i < 10; i++) {
            if (try_bgzf_useek(bgz, 0, SEEK_SET, f->tmp_bgzf, __func__) != 0) {
                goto fail;
            }
            for (j = 0; j < 64 && j < f->ltext; j++) {
                if (try_bgzf_getc(bgz, j, f->text[j],
                                  f->tmp_bgzf, __func__) < 0) goto fail;
            }

            if (try_bgzf_useek(bgz, mid, SEEK_SET,
                               f->tmp_bgzf, __func__) != 0) {
                goto fail;
            }
            for (j = 0; j < 64 && j + mid < f->ltext; j++) {
                if (try_bgzf_getc(bgz, j + mid, f->text[j + mid],
                                  f->tmp_bgzf, __func__) < 0) goto fail;
            }
        }
    }

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

    return 0;

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %r12d
movl %edx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %rbx
movq $0x0, 0x10(%rsp)
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
mulq 0x48(%rdi)
movq %rdx, %r15
movq %rsi, %rdi
movl $0x75, %esi
callq 0x4180
movq %rax, %r13
movq 0x18(%rbx), %rdi
leaq 0x8cfa9(%rip), %rdx     # 0x94409
movq %r14, %rsi
callq 0x85b7
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7764
movq %rax, %r14
movq 0x18(%rbx), %rbp
movq %rax, %rdi
callq 0xc5b8
testl %eax, %eax
jne 0x775c
testl %r12d, %r12d
jle 0x74ac
leaq 0x8cf70(%rip), %rdx     # 0x94409
movq %r14, %rdi
movl %r12d, %esi
callq 0x887e
testl %eax, %eax
jne 0x7764
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
leaq 0x8cf4a(%rip), %r8      # 0x94409
movq %r14, %rdi
callq 0x88a5
testq %rax, %rax
js 0x7764
testq %r13, %r13
je 0x773e
movq 0x18(%rbx), %rsi
leaq 0x8cf25(%rip), %rdx     # 0x94409
leaq 0x10(%rsp), %rdi
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
jne 0x7764
movq 0x18(%rbx), %rdi
leaq 0x90e41(%rip), %rsi     # 0x98344
leaq 0x8ceff(%rip), %rdx     # 0x94409
callq 0x85b7
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x7764
movq %rax, %r14
testl %r12d, %r12d
jle 0x753f
leaq 0x8cedd(%rip), %rdx     # 0x94409
movq %r14, %rdi
movl %r12d, %esi
callq 0x887e
testl %eax, %eax
jne 0x7764
testq %r13, %r13
je 0x7789
cmpq $0x0, 0x48(%rbx)
je 0x75e7
shrq $0x3, %r15
movq $0x0, (%rsp)
xorl %ebp, %ebp
leaq 0x8d168(%rip), %rax     # 0x946d0
movq (%rax,%rbp,8), %r13
addq (%rsp), %r13
movq 0x18(%rbx), %rdx
movq %r14, %rdi
movq %r13, %rsi
leaq 0x8ce88(%rip), %rcx     # 0x94409
callq 0x8987
testl %eax, %eax
jne 0x7764
movl $0x10, %r12d
cmpq 0x48(%rbx), %r13
jae 0x75c9
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
leaq 0x8ce55(%rip), %r8      # 0x94409
callq 0x89f6
testl %eax, %eax
js 0x7764
incq %r13
decq %r12
jne 0x7594
incq %rbp
cmpq $0x3, %rbp
jne 0x7561
movq (%rsp), %rcx
addq %r15, %rcx
movq %rcx, (%rsp)
cmpq 0x48(%rbx), %rcx
jb 0x755f
movq 0x18(%rbx), %rdx
leaq 0x8ce17(%rip), %rcx     # 0x94409
movq %r14, %rdi
xorl %esi, %esi
callq 0x8987
testl %eax, %eax
jne 0x7764
xorl %r15d, %r15d
leaq 0x8cdfb(%rip), %r12     # 0x94409
cmpq 0x48(%rbx), %r15
jae 0x7643
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r15), %edx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %r8
callq 0x89f6
testl %eax, %eax
js 0x7764
incq %r15
cmpq $0x11170, %r15          # imm = 0x11170
jne 0x760e
cmpl $0x0, 0x8(%rsp)
jle 0x77b3
movq 0x48(%rbx), %r15
shrq %r15
movq %r14, %rdi
movl 0x8(%rsp), %esi
callq 0xbf22
movq $0x0, 0x8(%rsp)
leaq 0x8cd98(%rip), %r12     # 0x94409
movq $0x0, (%rsp)
movq 0x18(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x8987
testl %eax, %eax
jne 0x77ac
xorl %r13d, %r13d
cmpq 0x48(%rbx), %r13
jae 0x76c7
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r8
callq 0x89f6
testl %eax, %eax
js 0x77ac
incq %r13
cmpq $0x40, %r13
jne 0x7695
movq 0x18(%rbx), %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x8987
testl %eax, %eax
jne 0x77ac
movl $0x40, %ebp
movq %r15, %r13
cmpq 0x48(%rbx), %r13
jae 0x771a
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r8
callq 0x89f6
testl %eax, %eax
js 0x77ac
incq %r13
decq %rbp
jne 0x76e9
movq (%rsp), %rax
cmpq $0x9, %rax
leaq 0x1(%rax), %rax
setae %cl
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
cmpq $0xa, %rax
jne 0x7679
jmp 0x77b3
movq 0x20(%rbx), %rsi
leaq 0x8ccc0(%rip), %rcx     # 0x94409
movq %r14, %rdi
xorl %edx, %edx
callq 0x8951
testl %eax, %eax
jne 0x7764
jmp 0x74d9
movq %rbp, %rdi
callq 0x4a40
movq 0x10(%rsp), %rdi
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testq %rdi, %rdi
je 0x7778
callq 0xbc44
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rsi
movq 0xadd64(%rip), %rdx     # 0xb54f8
leaq 0x8cc6e(%rip), %rcx     # 0x94409
movq %r14, %rdi
callq 0x891b
testl %eax, %eax
jne 0x7764
jmp 0x7548
testb $0x1, 0x8(%rsp)
je 0x7764
movq 0x18(%rbx), %rsi
leaq 0x8cc4b(%rip), %rdx     # 0x94409
leaq 0x10(%rsp), %rdi
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x861b
testl %eax, %eax
jne 0x7764
jmp 0x7778