// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/pat.cpp
// Function: RawPatternSource::nextBatchFromFile(PerThreadReadBuf&, bool, unsigned long)
pair<bool, int> RawPatternSource::nextBatchFromFile(
	PerThreadReadBuf& pt,
	bool batch_a,
	size_t readi)
{
	int c = getc_wrapper();
	while(c >= 0 && (c == '\n' || c == '\r')) {
		c = getc_wrapper();
	}
	EList<Read>& readbuf = batch_a ? pt.bufa_ : pt.bufb_;
	// Read until we run out of input or until we've filled the buffer
	for(; readi < pt.max_buf_ && c >= 0; readi++) {
		readbuf[readi].readOrigBuf.clear();
		while(c >= 0 && (c == '\n' || c == '\r')) {
			c = getc_wrapper();
		}
		while(c >= 0 && (c != '\n' && c != '\r')) {
			readbuf[readi].readOrigBuf.append(c);
			c = getc_wrapper();
		}
                if (c == '\n') {
			readbuf[readi].readOrigBuf.append(c);
			c = getc_wrapper();
			if (c == '\r')
				readbuf[readi].readOrigBuf.append(c);
			else {
				ungetc_wrapper(c);
				c = '\n'; // reset to last character seen
			}
                }
        }
	while (readi > 0 && readbuf[readi-1].readOrigBuf.length() == 0)
		readi--;
	return make_pair(c < 0, readi);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
movq %r15, %rdi
callq 0x4398e
testl %eax, %eax
js 0x43343
cmpl $0xa, %eax
je 0x4332d
cmpl $0xd, %eax
je 0x4332d
xorb $0x1, %bpl
movzbl %bpl, %r13d
shll $0x5, %r13d
orq $0x8, %r13
movq %rbx, %rcx
shlq $0x20, %rcx
movq %rcx, 0x8(%rsp)
imulq $0x268, %rbx, %r12      # imm = 0x268
addq $-0x128, %r12           # imm = 0xFED8
leaq 0x7(%rsp), %rbp
testl %eax, %eax
js 0x43468
cmpq (%r14), %rbx
jae 0x43468
movq 0x8(%r14,%r13), %rcx
movq %rbx, 0x10(%rsp)
imulq $0x268, %rbx, %rbx      # imm = 0x268
andq $0x0, 0x140(%rcx,%rbx)
testl %eax, %eax
js 0x433d9
cmpl $0xd, %eax
je 0x433ab
cmpl $0xa, %eax
jne 0x433d9
movq %r15, %rdi
callq 0x4398e
jmp 0x4339d
movq 0x8(%r14,%r13), %rcx
leaq (%rcx,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
movb %al, 0x7(%rsp)
movq %rbp, %rsi
callq 0x439de
movq %r15, %rdi
callq 0x4398e
testl %eax, %eax
js 0x43445
cmpl $0xa, %eax
je 0x433e9
cmpl $0xd, %eax
jne 0x433b5
jmp 0x43445
movq 0x8(%r14,%r13), %rax
leaq (%rax,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
movb $0xa, 0x6(%rsp)
leaq 0x6(%rsp), %rsi
callq 0x439de
movq %r15, %rdi
callq 0x4398e
cmpl $0xd, %eax
jne 0x43438
movq 0x8(%r14,%r13), %rax
leaq (%rax,%rbx), %rdi
addq $0x120, %rdi            # imm = 0x120
movb $0xd, 0x5(%rsp)
leaq 0x5(%rsp), %rsi
callq 0x439de
pushq $0xd
jmp 0x43444
movq %r15, %rdi
movl %eax, %esi
callq 0x43a4c
pushq $0xa
popq %rax
movq 0x10(%rsp), %rbx
incq %rbx
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rcx, 0x8(%rsp)
addq $0x268, %r12            # imm = 0x268
jmp 0x43372
shrl $0x1f, %eax
movq 0x8(%rsp), %rdi
addq %rax, %rdi
pushq $-0x1
popq %rcx
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
movq %rdi, %rax
incq %rcx
cmpq %rcx, %rbx
je 0x434a3
leaq (%rax,%rdx), %rdi
movq 0x8(%r14,%r13), %rsi
cmpq $0x0, (%rsi,%r12)
leaq -0x268(%r12), %r12
je 0x43480
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq