// File: /workspace/github_cpp_makefile_star2_O2/BenLangmead[P]bowtie/./ref_read.h
// Function: RefRecord fastaRefReadAppend<SString<char>>(FileBuf&, bool, SString<char>&, unsigned int&, RefReadInParams&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
static RefRecord fastaRefReadAppend(FileBuf& in,
                                    bool first,
                                    TStr& dst,
				    TIndexOffU& dstoff,
                                    RefReadInParams& rparms,
                                    string* name = NULL)
{
	int c;
	static int lastc = '>';
	if(first) {
		c = in.getPastWhitespace();
		if(c != '>') {
			cerr << "Reference file does not seem to be a FASTA file" << endl;
			throw 1;
		}
		lastc = c;
	}
	assert_neq(-1, lastc);

	// RefRecord params
	size_t len = 0;
	size_t off = 0;
	first = true;

	size_t ilen = dstoff;

	// Chew up the id line; if the next line is either
	// another id line or a comment line, keep chewing
	c = lastc;
	if(c == '>' || c == '#') {
		do {
			while (c == '#') {
				if((c = in.getPastNewline()) == -1) {
					lastc = -1;
					goto bail;
				}
			}
			assert_eq('>', c);
			while(true) {
				c = in.get();
				if(c == -1) {
					lastc = -1;
					goto bail;
				}
				if(c == '\n' || c == '\r') {
					while(c == '\r' || c == '\n') c = in.get();
					if(c == -1) {
						lastc = -1;
						goto bail;
					}
					break;
				}
				if (name) name->push_back(c);
			}
			// c holds the first character on the line after the name
			// line
		} while (c == '>' || c == '#');
	} else {
		ASSERT_ONLY(int cc = toupper(c));
		assert(cc != 'A' && cc != 'C' && cc != 'G' && cc != 'T');
		first = false;
	}

	// Skip over an initial stretch of gaps or ambiguous characters.
	while(true) {
		int cat = dna4Cat[c];
		if(rparms.nsToAs && cat == 2) {
			c = 'A';
		}
		int cc = toupper(c);
		if(rparms.bisulfite && cc == 'C') c = cc = 'T';
		if(cat == 1) {
			break; // to read-in loop
		} else if(cat == 2) {
			off++; // skip it
		} else if(c == '>') {
			lastc = '>';
			goto bail;
		}
		c = in.get();
		if(c == -1) {
			lastc = -1;
			goto bail;
		}
	}
	assert_eq(1, dna4Cat[c]);

	// in now points just past the first character of a sequence
	// line, and c holds the first character
	while(true) {
		// Note: can't have a comment in the middle of a sequence,
		// though a comment can end a sequence
		int cat = asc2dnacat[c];
		assert_neq(2, cat);
		if(cat == 1) {
			// Consume it
			len++;
			// Add it to referenece buffer
			dst.set(asc2dna[c], dstoff++);
			assert_lt((int)dst[dstoff-1], 4);
		}
		c = in.get();
		if(rparms.nsToAs && dna4Cat[c] == 2) c = 'A';
		if (c == -1 || c == '>' || c == '#' || dna4Cat[c] == 2) {
			lastc = c;
			break;
		}
		if(rparms.bisulfite && toupper(c) == 'C') c = 'T';
	}

  bail:
	// Optionally reverse the portion that we just appended.
	// ilen = length of buffer before this last sequence was appended.
	if(rparms.reverse == REF_READ_REVERSE_EACH) {
		// Find limits of the portion we just appended
		dst.reverseWindow(ilen, len);
	}
	return RefRecord((TIndexOffU)off, (TIndexOffU)len, first);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %r15
movq %rdi, %r13
testl %esi, %esi
je 0xac49
movq %r13, %rdi
callq 0x1267a
cmpl $0x3e, %eax
jne 0xae6e
movl $0x3e, 0x27b15(%rip)    # 0x32750
movl (%r12), %eax
movq %rax, 0x20(%rsp)
pushq $0x3e
popq %rax
jmp 0xac62
movl 0x27b01(%rip), %eax     # 0x32750
movl (%r12), %ecx
movq %rcx, 0x20(%rsp)
cmpl $0x3e, %eax
je 0xac62
cmpl $0x23, %eax
jne 0xacdf
cmpl $0x23, %eax
jne 0xac79
movq %r13, %rdi
callq 0x126a4
cmpl $-0x1, %eax
jne 0xac62
jmp 0xae61
movq %r13, %rdi
callq 0x126e0
cmpl $-0x1, %eax
je 0xacd5
cmpl $0xd, %eax
je 0xacaa
cmpl $0xa, %eax
je 0xacaa
testq %rbx, %rbx
je 0xac79
movsbl %al, %esi
movq %rbx, %rdi
callq 0x52b0
jmp 0xac79
movq %r13, %rdi
callq 0x126e0
cmpl $0xa, %eax
je 0xaca2
cmpl $0xd, %eax
je 0xaca2
cmpl $-0x1, %eax
je 0xacd5
cmpl $0x23, %eax
je 0xac62
cmpl $0x3e, %eax
je 0xac62
movq %r12, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movb $0x1, %cl
movl %ecx, 0xc(%rsp)
jmp 0xacf1
movb $0x1, %bpl
xorl %ebx, %ebx
jmp 0xae20
movq %r12, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
xorl %ebx, %ebx
cmpb $0x0, 0x4(%r14)
cltq
movl %eax, %r12d
pushq $0x41
popq %rcx
cmovnel %ecx, %r12d
leaq 0x294b5(%rip), %rcx     # 0x341c0
movb (%rcx,%rax), %r15b
cmpb $0x2, %r15b
cmovnel %eax, %r12d
movl %r12d, %edi
callq 0x56c0
cmpl $0x43, %eax
movl %r12d, %ebp
pushq $0x54
popq %rax
cmovel %eax, %ebp
cmpb $0x0, 0x5(%r14)
cmovel %r12d, %ebp
cmpb $0x1, %r15b
je 0xad68
cmpb $0x2, %r15b
jne 0xad45
incq %rbx
jmp 0xad4e
cmpl $0x3e, %ebp
je 0xae14
movq %r13, %rdi
callq 0x126e0
cmpl $-0x1, %eax
jne 0xacf3
movq 0x10(%rsp), %r15
pushq $-0x1
popq %rax
jmp 0xae1c
xorl %r12d, %r12d
movq 0x10(%rsp), %r15
movslq %ebp, %rax
leaq 0x29a46(%rip), %rcx     # 0x347c0
cmpb $0x1, (%rcx,%rax)
jne 0xada0
incq %r12
leaq 0x29836(%rip), %rcx     # 0x345c0
movb (%rcx,%rax), %al
movq 0x18(%rsp), %rsi
movl (%rsi), %ecx
leal 0x1(%rcx), %edx
movl %edx, (%rsi)
movq 0x8(%r15), %rdx
movb %al, (%rdx,%rcx)
movq %r13, %rdi
callq 0x126e0
cmpb $0x1, 0x4(%r14)
jne 0xadc2
movslq %eax, %rcx
leaq 0x29407(%rip), %rdx     # 0x341c0
cmpb $0x2, (%rdx,%rcx)
pushq $0x41
popq %rbp
je 0xade1
movl %eax, %ecx
incl %ecx
cmpl $0x3f, %ecx
ja 0xaddf
movabsq $-0x7fffffefffffffff, %rdx # imm = 0x8000001000000001
btq %rcx, %rdx
movl %eax, %ebp
jae 0xade1
jmp 0xae5b
movl %eax, %ebp
movslq %ebp, %rax
leaq 0x293d5(%rip), %rcx     # 0x341c0
cmpb $0x2, (%rcx,%rax)
je 0xae59
cmpb $0x1, 0x5(%r14)
jne 0xad70
movl %ebp, %edi
callq 0x56c0
pushq $0x54
popq %rcx
cmpl $0x43, %eax
je 0xae0d
movl %ebp, %ecx
movl %ecx, %ebp
jmp 0xad70
pushq $0x3e
popq %rax
movq 0x10(%rsp), %r15
movl 0xc(%rsp), %ebp
xorl %r12d, %r12d
movl %eax, 0x27927(%rip)     # 0x32750
cmpl $0x2, (%r14)
jne 0xae3f
movq %r15, %rdi
movq 0x20(%rsp), %rsi
movq %r12, %rdx
callq 0x12716
shlq $0x20, %r12
movl %ebx, %eax
orq %r12, %rax
movl %ebp, %edx
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %eax
movl 0xc(%rsp), %ebp
jmp 0xae23
movb $0x1, %bpl
xorl %r12d, %r12d
xorl %ebx, %ebx
pushq $-0x1
popq %rax
jmp 0xae23
movq 0x2717b(%rip), %rdi     # 0x31ff0
leaq 0x1b69a(%rip), %rsi     # 0x26516
callq 0x5350
movq %rax, %rdi
callq 0x5180
pushq $0x4
popq %rdi
callq 0x5190
movl $0x1, (%rax)
movq 0x270c2(%rip), %rsi     # 0x31f60
movq %rax, %rdi
xorl %edx, %edx
callq 0x5630