// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/bgzf.c
// Function: bgzf_getline
int bgzf_getline(BGZF *fp, int delim, kstring_t *str)
{
    int l, state = 0;
    str->l = 0;
    do {
        if (fp->block_offset >= fp->block_length) {
            if (bgzf_read_block(fp) != 0) { state = -2; break; }
            if (fp->block_length == 0) { state = -1; break; }
        }
        unsigned char *buf = fp->uncompressed_block;

        // Equivalent to a naive byte by byte search from
        // buf + block_offset to buf + block_length.
        void *e = memchr(&buf[fp->block_offset], delim,
                         fp->block_length - fp->block_offset);
        l = e ? (unsigned char *)e - buf : fp->block_length;

        if (l < fp->block_length) state = 1;
        l -= fp->block_offset;
        if (ks_expand(str, l + 2) < 0) { state = -3; break; }
        memcpy(str->s + str->l, buf + fp->block_offset, l);
        str->l += l;
        fp->block_offset += l + 1;
        if (fp->block_offset >= fp->block_length) {
            fp->block_address = bgzf_htell(fp);
            fp->block_offset = 0;
            fp->block_length = 0;
        }
    } while (state == 0);
    if (state < -1) return state;
    if (str->l == 0 && state < 0) return state;
    fp->uncompressed_address += str->l + 1;
    if ( delim=='\n' && str->l>0 && str->s[str->l-1]=='\r' ) str->l--;
    str->s[str->l] = 0;
    return str->l <= INT_MAX ? (int) str->l : INT_MAX;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jl 0x10fa7
movq -0x10(%rbp), %rdi
callq 0xceb0
cmpl $0x0, %eax
je 0x10f8f
movl $0xfffffffe, -0x28(%rbp) # imm = 0xFFFFFFFE
jmp 0x110da
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x10fa5
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
jmp 0x110da
jmp 0x10fa7
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
subl 0x10(%rcx), %eax
movslq %eax, %rdx
callq 0x4530
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x10ff7
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x11003
movq -0x10(%rbp), %rax
movslq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x1101d
movl $0x1, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movl -0x24(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movl -0x24(%rbp), %eax
addl $0x2, %eax
movslq %eax, %rsi
callq 0x111a0
cmpl $0x0, %eax
jge 0x1104f
movl $0xfffffffd, -0x28(%rbp) # imm = 0xFFFFFFFD
jmp 0x110da
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
addq (%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movslq 0x10(%rax), %rax
addq %rax, %rsi
movslq -0x24(%rbp), %rdx
callq 0x43b0
movslq -0x24(%rbp), %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
addl 0x10(%rax), %ecx
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jl 0x110ce
movq -0x10(%rbp), %rdi
callq 0xdd80
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x8(%rax)
jmp 0x110d0
cmpl $0x0, -0x28(%rbp)
je 0x10f65
cmpl $-0x1, -0x28(%rbp)
jge 0x110eb
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x11193
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x11106
cmpl $0x0, -0x28(%rbp)
jge 0x11106
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x11193
movq -0x20(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
cmpl $0xa, -0x14(%rbp)
jne 0x11157
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jbe 0x11157
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x11157
movq -0x20(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
cmpq $0x7fffffff, (%rax)     # imm = 0x7FFFFFFF
ja 0x11183
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x44(%rbp)
jmp 0x1118d
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x44(%rbp)
jmp 0x1118d
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)