// File: /workspace/github_cpp_makefile_star2_O2/conchoecia[P]fasta_stats/src/open_compressed.cc
// Function: pfgets(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
ssize_t pfgets(const int fd, std::string &line) {
	if (fd < 0 || local.open_max <= fd) {
		fprintf(stderr, "Error: pfgets: fd out of range: %d\n", fd);
		return -1;
	}
	if (local.buffers[fd].empty()) {
		fprintf(stderr, "Error: pfgets: buffer unallocated\n");
		return -1;
	}
	line.clear();
	char * const buf = local.buffers[fd].array();
	ssize_t &i = local.buffer_start[fd];
	ssize_t &j = local.buffer_length[fd];
	for (;;) {
		char * const end_of_line = strchr(buf + i, '\n');
		if (end_of_line != NULL) {
			*end_of_line = '\0';
			line += buf + i;
			i = end_of_line - buf + 1;
			return (ssize_t)line.size();
		}
		line += buf + i;
		i = 0;
		j = read(fd, buf, BUFSIZE);
		if (j <= 0) {
			if (j == -1) {
				fprintf(stderr, "Error: read(%d): %s\n", fd, strerror(errno));
			}
			buf[j = 0] = '\0';
			/* only return -1 if we don't return anything else */
			return line.empty() ? -1 : (ssize_t)line.size();
		}
		buf[j] = '\0';
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x8(%rsp)
movl %edi, %ebx
testl %edi, %edi
js 0x4bdc
movl %ebx, %r15d
cmpq %r15, 0x5783(%rip)      # 0xa268
jle 0x4bdc
movq 0x577e(%rip), %rax      # 0xa270
movq (%rax,%r15,8), %rax
cmpq $0x0, 0x8(%rax)
je 0x4bf8
movq 0x8(%rsp), %rax
andq $0x0, 0x8(%rax)
movq (%rax), %rax
movb $0x0, (%rax)
movq 0x5758(%rip), %rax      # 0xa270
movq (%rax,%r15,8), %rax
movq 0x10(%rax), %r14
movq 0x5751(%rip), %rbp      # 0xa278
movq 0x5752(%rip), %rax      # 0xa280
movq %rax, 0x10(%rsp)
movq (%rbp,%r15,8), %r13
addq %r14, %r13
movq %r13, %rdi
pushq $0xa
popq %rsi
callq 0x20f0
testq %rax, %rax
jne 0x4b85
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x2390
andq $0x0, (%rbp,%r15,8)
movl $0x8000, %edx           # imm = 0x8000
movl %ebx, %r13d
movl %ebx, %edi
movq %r14, %rsi
callq 0x2300
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r15,8)
testq %rax, %rax
jle 0x4bb1
movb $0x0, (%r14,%rax)
jmp 0x4b33
movq %rax, %r12
movb $0x0, (%rax)
movq (%rbp,%r15,8), %rsi
addq %r14, %rsi
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x2390
subq %r14, %r12
incq %r12
movq %r12, (%rbp,%r15,8)
movq 0x8(%rbx), %rax
jmp 0x4c17
cmpq $-0x1, %rax
je 0x4c26
movq 0x10(%rsp), %rax
andq $0x0, (%rax,%r15,8)
movb $0x0, (%r14)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rcx
xorl %eax, %eax
cmpq $0x1, %rcx
sbbq %rax, %rax
orq %rcx, %rax
jmp 0x4c17
movq 0x53ed(%rip), %rax      # 0x9fd0
movq (%rax), %rdi
leaq 0x1b66(%rip), %rsi      # 0x6753
movl %ebx, %edx
xorl %eax, %eax
callq 0x22f0
jmp 0x4c14
movq 0x53d1(%rip), %rax      # 0x9fd0
movq (%rax), %rcx
leaq 0x1b6e(%rip), %rdi      # 0x6777
pushq $0x22
popq %rsi
pushq $0x1
popq %rdx
callq 0x23b0
pushq $-0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x53a3(%rip), %rax      # 0x9fd0
movq (%rax), %r12
callq 0x2040
movl (%rax), %edi
callq 0x20d0
leaq 0x1b57(%rip), %rsi      # 0x679a
movq %r12, %rdi
movl %r13d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x22f0
jmp 0x4bb7