// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/test/test_bgzf.c
// Function: test_bgzf_getline
static int test_bgzf_getline(Files *f, const char *mode, int nthreads) {
    BGZF* bgz = NULL;
    ssize_t bg_put;
    size_t pos;
    kstring_t str = { 0, 0, NULL };
    const char *text = (const char *) f->text;

    bgz = try_bgzf_open(f->tmp_bgzf, mode, __func__);
    if (!bgz) 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 (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;

    for (pos = 0; pos < f->ltext; ) {
        const char *end = strchr(text + pos, '\n');
        size_t l = end ? end - (text + pos) : f->ltext - pos;
        int res;

        if ((res = bgzf_getline(bgz, '\n', &str)) < 0) {
            fprintf(stderr, "%s : %s from bgzf_getline on %s : %s\n",
                    __func__, res < -1 ? "Error" : "Unexpected EOF",
                    f->tmp_bgzf, res < -1 ? strerror(errno) : "EOF");
            goto fail;
        }

        if (str.l != l || memcmp(text + pos, str.s, l) != 0) {
            fprintf(stderr,
                    "%s : Unexpected data from bgzf_getline on %s\n"
                    "Expected : %.*s\n"
                    "Got      : %.*s\n",
                    __func__, f->tmp_bgzf, (int) l, (char *) f->text + pos,
                    (int) str.l, str.s);
            goto fail;
        }

        pos += l + 1;
    }

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

 fail:
    if (bgz) bgzf_close(bgz);
    free(ks_release(&str));
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4240
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rsi
leaq 0xe2319(%rip), %rdx     # 0xea5c6
callq 0x8b70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x82c2
jmp 0x856f
cmpl $0x0, -0x1c(%rbp)
jle 0x82e5
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xe22f0(%rip), %rdx     # 0xea5c6
callq 0x92f0
cmpl $0x0, %eax
je 0x82e5
jmp 0x856f
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
leaq 0xe22be(%rip), %r8      # 0xea5c6
callq 0x9370
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x831d
jmp 0x856f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x28(%rbp), %rdi
leaq 0xe2296(%rip), %rdx     # 0xea5c6
xorl %ecx, %ecx
callq 0x8c10
cmpl $0x0, %eax
je 0x8341
jmp 0x856f
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0xe6231(%rip), %rsi     # 0xee581
leaq 0xe226f(%rip), %rdx     # 0xea5c6
callq 0x8b70
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x836c
jmp 0x856f
cmpl $0x0, -0x1c(%rbp)
jle 0x838f
movq -0x28(%rbp), %rdi
movl -0x1c(%rbp), %esi
leaq 0xe2246(%rip), %rdx     # 0xea5c6
callq 0x92f0
cmpl $0x0, %eax
je 0x838f
jmp 0x856f
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jae 0x8534
movq -0x58(%rbp), %rdi
addq -0x38(%rbp), %rdi
movl $0xa, %esi
callq 0x4160
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x83db
movq -0x60(%rbp), %rax
movq -0x58(%rbp), %rcx
addq -0x38(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
jmp 0x83eb
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x28(%rbp), %rdi
movl $0xa, %esi
leaq -0x50(%rbp), %rdx
callq 0xec50
movl %eax, -0x6c(%rbp)
cmpl $0x0, %eax
jge 0x84ab
movq 0xffbc8(%rip), %rax     # 0x107fe0
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x6c(%rbp), %edx
leaq 0xe21d8(%rip), %rax     # 0xea604
leaq 0xe21cb(%rip), %rcx     # 0xea5fe
cmpl $-0x1, %edx
cmovlq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x80(%rbp)
cmpl $-0x1, -0x6c(%rbp)
jge 0x8468
callq 0x4050
movl (%rax), %edi
callq 0x4120
movq %rax, -0x98(%rbp)
jmp 0x8478
leaq 0xe21a0(%rip), %rax     # 0xea60f
movq %rax, -0x98(%rbp)
jmp 0x8478
movq -0x80(%rbp), %r8
movq -0x88(%rbp), %rcx
movq -0x90(%rbp), %rdi
movq -0x98(%rbp), %r9
leaq 0xe2140(%rip), %rsi     # 0xea5d8
leaq 0xe2127(%rip), %rdx     # 0xea5c6
movb $0x0, %al
callq 0x46d0
jmp 0x856f
movq -0x50(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x84cf
movq -0x58(%rbp), %rdi
addq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0x41b0
cmpl $0x0, %eax
je 0x851f
movq 0xffb0a(%rip), %rax     # 0x107fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x68(%rbp), %rax
movl %eax, %r8d
movq -0x10(%rbp), %rax
movq 0x40(%rax), %r9
addq -0x38(%rbp), %r9
movq -0x50(%rbp), %rax
movl %eax, %r10d
movq -0x40(%rbp), %rax
leaq 0xe210d(%rip), %rsi     # 0xea613
leaq 0xe20b9(%rip), %rdx     # 0xea5c6
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x46d0
jmp 0x856f
movq -0x68(%rbp), %rax
addq $0x1, %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x8397
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x28(%rbp), %rdi
leaq 0xe207f(%rip), %rdx     # 0xea5c6
xorl %ecx, %ecx
callq 0x8c10
cmpl $0x0, %eax
je 0x8555
jmp 0x856f
leaq -0x50(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
callq 0x4590
movl $0x0, -0x4(%rbp)
jmp 0x8597
cmpq $0x0, -0x28(%rbp)
je 0x857f
movq -0x28(%rbp), %rdi
callq 0xe0e0
leaq -0x50(%rbp), %rdi
callq 0x9b90
movq %rax, %rdi
callq 0x4590
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)