// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/bgzf.c
// Function: bgzf_getline
int bgzf_getline(BGZF *fp, int delim, kstring_t *str)
{
    int l, state = 0;
    unsigned char *buf = (unsigned char*)fp->uncompressed_block;
    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; }
        }
        for (l = fp->block_offset; l < fp->block_length && buf[l] != delim; ++l);
        if (l < fp->block_length) state = 1;
        l -= fp->block_offset;
        if (str->l + l + 1 >= str->m) {
            str->m = str->l + l + 2;
            kroundup32(str->m);
            str->s = (char*)realloc(str->s, str->m);
        }
        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 = htell(fp->fp);
            fp->block_offset = 0;
            fp->block_length = 0;
        }
    } while (state == 0);
    if (str->l == 0 && state < 0) return state;
    fp->uncompressed_address += str->l;
    if ( delim=='\n' && str->l>0 && str->s[str->l-1]=='\r' ) str->l--;
    str->s[str->l] = 0;
    return str->l;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movl %esi, %ebp
movq %rdi, %r14
movq 0x20(%rdi), %r13
andq $0x0, (%rdx)
movl 0x8(%rdi), %edi
movl 0xc(%r14), %ecx
movq %r14, 0x10(%rsp)
movl %esi, 0xc(%rsp)
cmpl %edi, %ecx
jl 0x5d533
movq %r14, %rdi
callq 0x5c1fd
testl %eax, %eax
jne 0x5d633
movl 0x8(%r14), %edi
testl %edi, %edi
je 0x5d637
movl 0xc(%r14), %ecx
movslq %ecx, %rsi
movslq %edi, %r15
cmpl %r15d, %esi
movl %r15d, %r8d
cmovgl %esi, %r8d
movq %rsi, %rbx
cmpq %r15, %rbx
jge 0x5d55d
movzbl (%r13,%rbx), %eax
cmpl %ebp, %eax
je 0x5d55a
incq %rbx
jmp 0x5d546
movl %ebx, %r8d
subl %ecx, %r8d
movq (%r12), %rdi
movq 0x10(%r12), %rax
movslq %r8d, %rbp
leaq (%rdi,%rbp), %rcx
incq %rcx
cmpq 0x8(%r12), %rcx
jae 0x5d581
movq 0x10(%rsp), %r14
jmp 0x5d5d4
movq %rcx, %rsi
shrq %rsi
orq %rcx, %rsi
movq %rsi, %rcx
shrq $0x2, %rcx
orq %rsi, %rcx
movq %rcx, %rsi
shrq $0x4, %rsi
orq %rcx, %rsi
movq %rsi, %rcx
shrq $0x8, %rcx
orq %rsi, %rcx
movq %rcx, %rsi
shrq $0x10, %rsi
orq %rcx, %rsi
incq %rsi
movq %rsi, 0x8(%r12)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x10(%r12)
movq (%r12), %rdi
movq 0x10(%rsp), %r14
movslq 0xc(%r14), %rsi
addq %rax, %rdi
addq %r13, %rsi
movq %rbp, %rdx
callq 0x6570
movq (%r12), %r8
addq %rbp, %r8
movq %r8, (%r12)
movl 0x8(%r14), %edi
movl 0xc(%r14), %ecx
addl %ebp, %ecx
incl %ecx
movl %ecx, 0xc(%r14)
cmpl %edi, %ecx
jl 0x5d61d
movq 0x38(%r14), %rcx
movq 0x28(%rcx), %rsi
addq 0x8(%rcx), %rsi
subq (%rcx), %rsi
movq %rsi, 0x10(%r14)
andq $0x0, 0x8(%r14)
xorl %edi, %edi
xorl %ecx, %ecx
cmpq %r15, %rbx
movl 0xc(%rsp), %ebp
jge 0x5d50f
testq %r8, %r8
sete %sil
jmp 0x5d645
pushq $-0x2
jmp 0x5d639
pushq $-0x1
popq %rax
movq (%r12), %r8
testq %r8, %r8
je 0x5d670
xorl %esi, %esi
addq %r8, 0x18(%r14)
movq 0x10(%r12), %rcx
cmpl $0xa, %ebp
jne 0x5d667
testb %sil, %sil
jne 0x5d667
cmpb $0xd, -0x1(%rcx,%r8)
jne 0x5d667
decq %r8
movq %r8, (%r12)
movb $0x0, (%rcx,%r8)
movl (%r12), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq