// File: /workspace/github_c_makefile_star2_O3/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, %ebp
movq %rsi, %r14
movq %rdi, %rbx
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 0x89ec2(%rip), %rdx     # 0x91425
movq %r14, %rsi
callq 0x865e
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7873
movq %rax, %r14
movl %ebp, 0x14(%rsp)
movq 0x18(%rbx), %rbp
movq %rax, %rdi
callq 0xc4d8
testl %eax, %eax
jne 0x785c
testl %r12d, %r12d
jle 0x75b3
leaq 0x89e85(%rip), %rdx     # 0x91425
movq %r14, %rdi
movl %r12d, %esi
callq 0x8915
testl %eax, %eax
jne 0x7864
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rsi
movq 0x48(%rbx), %rdx
leaq 0x89e5f(%rip), %r8      # 0x91425
movq %r14, %rdi
callq 0x893c
testq %rax, %rax
js 0x7864
testq %r13, %r13
je 0x783e
movq 0x18(%rbx), %rsi
leaq 0x89e3a(%rip), %rdx     # 0x91425
leaq 0x8(%rsp), %rdi
xorl %ecx, %ecx
callq 0x86bf
testl %eax, %eax
jne 0x7864
movq 0x18(%rbx), %rdi
leaq 0x8dce1(%rip), %rsi     # 0x952eb
leaq 0x89e14(%rip), %rdx     # 0x91425
callq 0x865e
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x7873
movq %rax, %r14
testl %r12d, %r12d
jle 0x7646
leaq 0x89df2(%rip), %rdx     # 0x91425
movq %r14, %rdi
movl %r12d, %esi
callq 0x8915
testl %eax, %eax
jne 0x7864
testq %r13, %r13
je 0x7889
cmpq $0x0, 0x48(%rbx)
je 0x76ee
shrq $0x3, %r15
movq $0x0, (%rsp)
xorl %ebp, %ebp
leaq 0x8a081(%rip), %rax     # 0x916f0
movq (%rax,%rbp,8), %r13
addq (%rsp), %r13
movq 0x18(%rbx), %rdx
movq %r14, %rdi
movq %r13, %rsi
leaq 0x89d9d(%rip), %rcx     # 0x91425
callq 0x8a21
testl %eax, %eax
jne 0x7864
movl $0x10, %r12d
cmpq 0x48(%rbx), %r13
jae 0x76d0
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
leaq 0x89d6a(%rip), %r8      # 0x91425
callq 0x8a90
testl %eax, %eax
js 0x7864
incq %r13
decq %r12
jne 0x769b
incq %rbp
cmpq $0x3, %rbp
jne 0x7668
movq (%rsp), %rcx
addq %r15, %rcx
movq %rcx, (%rsp)
cmpq 0x48(%rbx), %rcx
jb 0x7666
movq 0x18(%rbx), %rdx
leaq 0x89d2c(%rip), %rcx     # 0x91425
movq %r14, %rdi
xorl %esi, %esi
callq 0x8a21
testl %eax, %eax
jne 0x7864
xorl %r15d, %r15d
leaq 0x89d10(%rip), %r12     # 0x91425
cmpq 0x48(%rbx), %r15
jae 0x774a
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r15), %edx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %r8
callq 0x8a90
testl %eax, %eax
js 0x7864
incq %r15
cmpq $0x11170, %r15          # imm = 0x11170
jne 0x7715
movl 0x14(%rsp), %esi
testl %esi, %esi
jle 0x781f
movq 0x48(%rbx), %rax
shrq %rax
movq %rax, (%rsp)
movq %r14, %rdi
callq 0xbe30
xorl %ebp, %ebp
leaq 0x89cb3(%rip), %r12     # 0x91425
movq 0x18(%rbx), %rdx
movq %r14, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x8a21
testl %eax, %eax
jne 0x7864
xorl %r13d, %r13d
cmpq 0x48(%rbx), %r13
jae 0x77c0
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r8
callq 0x8a90
testl %eax, %eax
js 0x7864
incq %r13
cmpq $0x40, %r13
jne 0x778e
movq 0x18(%rbx), %rdx
movq %r14, %rdi
movq (%rsp), %rsi
movq %r12, %rcx
callq 0x8a21
testl %eax, %eax
jne 0x7864
movl $0x40, %r15d
movq (%rsp), %r13
cmpq 0x48(%rbx), %r13
jae 0x7812
movq 0x18(%rbx), %rcx
movq 0x40(%rbx), %rax
movzbl (%rax,%r13), %edx
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %r8
callq 0x8a90
testl %eax, %eax
js 0x7864
incq %r13
decq %r15
jne 0x77e5
incq %rbp
cmpq $0xa, %rbp
jne 0x7772
movq 0x18(%rbx), %rsi
leaq 0x89bfb(%rip), %rdx     # 0x91425
leaq 0x8(%rsp), %rdi
xorl %ebx, %ebx
xorl %ecx, %ecx
callq 0x86bf
testl %eax, %eax
jne 0x7864
jmp 0x7878
movq 0x20(%rbx), %rsi
leaq 0x89bdc(%rip), %rcx     # 0x91425
movq %r14, %rdi
xorl %edx, %edx
callq 0x89eb
testl %eax, %eax
jne 0x7864
jmp 0x75e0
movq %rbp, %rdi
callq 0x4a7e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x7873
callq 0xbb59
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rbx), %rsi
movq 0xabc64(%rip), %rdx     # 0xb34f8
leaq 0x89b8a(%rip), %rcx     # 0x91425
movq %r14, %rdi
callq 0x89b5
testl %eax, %eax
jne 0x7864
jmp 0x764f