// File: /workspace/github_c_makefile_star2_O3/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
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq 0x20(%rdi), %r12
movq $0x0, (%rdx)
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
leaq 0x1(%r12), %rdx
movq %rdx, (%rsp)
cmpl %eax, %ecx
jl 0x68800
movq %r14, %rdi
callq 0x66ff6
testl %eax, %eax
jne 0x6892c
movl 0x8(%r14), %eax
testl %eax, %eax
je 0x68933
movl 0xc(%r14), %ecx
cmpl %eax, %ecx
jge 0x68853
movslq %ecx, %rsi
movzbl (%r12,%rsi), %edi
movb $0x1, %r13b
movl %ecx, %edx
cmpl %ebp, %edi
je 0x68869
movslq %eax, %rdi
movq (%rsp), %rdx
leaq (%rdx,%rsi), %r8
movl %ecx, %edx
movl $0x1, %r9d
subl %eax, %r9d
addq %rdx, %r9
xorl %edx, %edx
movl %r9d, %r10d
addl %edx, %r10d
je 0x6885a
movzbl (%r8,%rdx), %r10d
incq %rdx
cmpl %ebp, %r10d
jne 0x68830
addq %rdx, %rsi
cmpq %rdi, %rsi
setl %r13b
addl %ecx, %edx
jmp 0x68869
xorl %r13d, %r13d
movl %ecx, %edx
jmp 0x68869
addq %rsi, %rdx
incq %rdx
cmpq %rdi, %rdx
setl %r13b
movl %eax, %edx
subl %ecx, %edx
movq (%rbx), %rdi
movq 0x10(%rbx), %rax
movslq %edx, %r15
leaq (%r15,%rdi), %rdx
incq %rdx
cmpq 0x8(%rbx), %rdx
jb 0x688cd
movq %rdx, %rcx
shrq %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x2, %rdx
orq %rcx, %rdx
movq %rdx, %rcx
shrq $0x4, %rcx
orq %rdx, %rcx
movq %rcx, %rdx
shrq $0x8, %rdx
orq %rcx, %rdx
movq %rdx, %rsi
shrq $0x10, %rsi
orq %rdx, %rsi
incq %rsi
movq %rsi, 0x8(%rbx)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
movl 0xc(%r14), %ecx
addq %rax, %rdi
movslq %ecx, %rsi
addq %r12, %rsi
movq %r15, %rdx
callq 0x6570
movq (%rbx), %rdx
addq %r15, %rdx
movq %rdx, (%rbx)
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
addl %r15d, %ecx
incl %ecx
movl %ecx, 0xc(%r14)
cmpl %eax, %ecx
jl 0x6891b
movq 0x38(%r14), %rax
movq 0x28(%rax), %rcx
addq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, 0x10(%r14)
movq $0x0, 0x8(%r14)
xorl %eax, %eax
xorl %ecx, %ecx
testb %r13b, %r13b
je 0x687dc
testq %rdx, %rdx
sete %cl
jmp 0x68942
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x68938
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%rbx), %rdx
testq %rdx, %rdx
je 0x68966
xorl %ecx, %ecx
addq %rdx, 0x18(%r14)
movq 0x10(%rbx), %rax
cmpl $0xa, %ebp
jne 0x68960
testb %cl, %cl
jne 0x68960
cmpb $0xd, -0x1(%rax,%rdx)
jne 0x68960
decq %rdx
movq %rdx, (%rbx)
movb $0x0, (%rax,%rdx)
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq