// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/kstring.c
// Function: kgetline2
int kgetline2(kstring_t *s, kgets_func2 *fgets_fn, void *fp)
{
	size_t l0 = s->l;

	while (s->l == l0 || s->s[s->l-1] != '\n') {
		if (s->m - s->l < 200) {
			// We return EOF for both EOF and error and the caller
			// needs to check for errors in fp, and we haven't
			// even got there yet.
			//
			// The only way of propagating memory errors is to
			// deliberately call something that we know triggers
			// and error so fp is also set.  This works for
			// hgets, but not for gets where reading <= 0 bytes
			// isn't an error.
			if (ks_resize(s, s->m + 200) < 0) {
				fgets_fn(s->s + s->l, 0, fp);
				return EOF;
			}
		}
		ssize_t len = fgets_fn(s->s + s->l, s->m - s->l, fp);
		if (len <= 0) break;
		s->l += len;
	}

	if (s->l == l0) return EOF;

	if (s->l > l0 && s->s[s->l-1] == '\n') {
		s->l--;
		if (s->l > l0 && s->s[s->l-1] == '\r') s->l--;
	}
	s->s[s->l] = '\0';
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movb $0x1, %al
cmpq -0x28(%rbp), %rcx
movb %al, -0x31(%rbp)
je 0xb801
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0xb80d
jmp 0xb8b4
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
subq (%rcx), %rax
cmpq $0xc8, %rax
jae 0xb86c
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc8, %rsi
callq 0xad90
cmpl $0x0, %eax
jge 0xb86a
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rdi
movq -0x10(%rbp), %rcx
addq (%rcx), %rdi
movq -0x20(%rbp), %rdx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb957
jmp 0xb86c
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rdi
movq -0x10(%rbp), %rcx
addq (%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rsi
movq -0x10(%rbp), %rcx
subq (%rcx), %rsi
movq -0x20(%rbp), %rdx
callq *%rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jg 0xb8a1
jmp 0xb8b4
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0xb7cf
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0xb8cd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb957
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x28(%rbp), %rax
jbe 0xb93d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xb93d
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x28(%rbp), %rax
jbe 0xb93b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0xb93b
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $-0x1, %rcx
movq %rcx, (%rax)
jmp 0xb93d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq