// File: /workspace/github_cpp_makefile_star2_O3/auton1[P]viterbi/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 = _bgzf_tell((_bgzf_file_t)fp->fp);
			fp->block_offset = 0;
			fp->block_length = 0;
		} 
	} while (state == 0);
	if (str->l == 0 && state < 0) return state;
	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 0x18(%rdi), %r12
movq $0x0, (%rdx)
movl 0x8(%rdi), %eax
movl 0xc(%rdi), %ecx
leaq 0x1(%r12), %rdx
movq %rdx, (%rsp)
cmpl %eax, %ecx
jl 0x37e59
movq %r14, %rdi
callq 0x376fc
testl %eax, %eax
jne 0x37f76
movl 0x8(%r14), %eax
testl %eax, %eax
je 0x37f7d
movl 0xc(%r14), %ecx
cmpl %eax, %ecx
jge 0x37eac
movslq %ecx, %rsi
movzbl (%r12,%rsi), %edi
movb $0x1, %r13b
movl %ecx, %edx
cmpl %ebp, %edi
je 0x37ec2
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 0x37eb3
movzbl (%r8,%rdx), %r10d
incq %rdx
cmpl %ebp, %r10d
jne 0x37e89
addq %rdx, %rsi
cmpq %rdi, %rsi
setl %r13b
addl %ecx, %edx
jmp 0x37ec2
xorl %r13d, %r13d
movl %ecx, %edx
jmp 0x37ec2
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 0x37f26
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 0x5720
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
movl 0xc(%r14), %ecx
addq %rax, %rdi
movslq %ecx, %rsi
addq %r12, %rsi
movq %r15, %rdx
callq 0x5380
addq %r15, (%rbx)
movl 0x8(%r14), %eax
movl 0xc(%r14), %ecx
addl %r15d, %ecx
incl %ecx
movl %ecx, 0xc(%r14)
cmpl %eax, %ecx
jl 0x37f68
movq 0x30(%r14), %rdi
callq 0x5560
movq %rax, 0x10(%r14)
movq $0x0, 0x8(%r14)
xorl %eax, %eax
xorl %ecx, %ecx
testb %r13b, %r13b
je 0x37e35
movq (%rbx), %rcx
jmp 0x37f8a
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x37f82
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%rbx), %rcx
testq %rcx, %rcx
je 0x37f94
movq 0x10(%rbx), %rax
movb $0x0, (%rax,%rcx)
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq