// File: simonrharris[P]SKA/src/DNA.cpp
// Function: readNextFastaSequence(igzstream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
int readNextFastaSequence(igzstream & gzfileStream, const std::string & filename, std::string & name, std::string & sequence){
	std::string line;
	line.reserve(10000);
	if (gzfileStream.get()!='>'){//check the fist character is a > and remove it
		std::cerr << "Error: " << filename << " is not in the correct format. Expecting header line to start with >." << std::endl << std::endl;
		return 1;
	}
  	std::getline(gzfileStream, line);//read the rest of the headerline
  	std::stringstream headerstream;
	headerstream << line;//convert the sequence to stringstream
	std::getline(headerstream, name, ' ');
  	while (gzfileStream.peek()!=EOF && gzfileStream.peek()!='>'){//read the sequence
  		std::getline(gzfileStream, line);
  		sequence.append(line);
  	}
	if (gzfileStream.fail()){
		std::cerr << filename << " is not in the correct format." << std::endl << std::endl;
		return 1;
	}
	sequence.erase(std::remove_if( sequence.begin(), sequence.end(), ::isspace ), sequence.end() );//remove any gaps from the sequence
	std::transform(sequence.begin(), sequence.end(), sequence.begin(), ::toupper);//change all letters in the string to upper case
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2b0, %rsp            # imm = 0x2B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x240(%rbp)
callq 0x6730
movq -0x240(%rbp), %rdi
movl $0x2710, %esi           # imm = 0x2710
callq 0x6810
jmp 0x84ee
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
callq 0x6630
movl %eax, -0x244(%rbp)
jmp 0x8506
movl -0x244(%rbp), %eax
cmpl $0x3e, %eax
je 0x85bb
movq 0x70ad4(%rip), %rdi     # 0x78ff0
leaq 0x50b47(%rip), %rsi     # 0x5906a
callq 0x6520
movq %rax, -0x250(%rbp)
jmp 0x8531
movq -0x250(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x64d0
movq %rax, -0x258(%rbp)
jmp 0x854a
movq -0x258(%rbp), %rdi
leaq 0x50b1a(%rip), %rsi     # 0x59072
callq 0x6520
movq %rax, -0x260(%rbp)
jmp 0x8566
movq -0x260(%rbp), %rdi
movq 0x70a1c(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x268(%rbp)
jmp 0x8582
movq -0x268(%rbp), %rdi
movq 0x70a00(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x8597
movl $0x1, -0x4(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8893
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x88a8
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq -0x48(%rbp), %rsi
callq 0x60d0
jmp 0x85d1
leaq -0x1e0(%rbp), %rdi
callq 0x63a0
jmp 0x85df
leaq -0x1d0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x64d0
jmp 0x85f1
movq -0x20(%rbp), %rsi
leaq -0x1e0(%rbp), %rdi
movl $0x20, %edx
callq 0x6960
jmp 0x8608
jmp 0x860a
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
callq 0x61c0
movl %eax, -0x26c(%rbp)
jmp 0x8622
movl -0x26c(%rbp), %ecx
xorl %eax, %eax
cmpl $-0x1, %ecx
movb %al, -0x26d(%rbp)
je 0x865f
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
callq 0x61c0
movl %eax, -0x274(%rbp)
jmp 0x864d
movl -0x274(%rbp), %eax
cmpl $0x3e, %eax
setne %al
movb %al, -0x26d(%rbp)
movb -0x26d(%rbp), %al
testb $0x1, %al
jne 0x866b
jmp 0x86b2
movq -0x10(%rbp), %rdi
addq $0x188, %rdi            # imm = 0x188
leaq -0x48(%rbp), %rsi
callq 0x60d0
jmp 0x8681
movq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x69c0
jmp 0x8690
jmp 0x860a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x6410
jmp 0x88a8
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6030
movb %al, -0x275(%rbp)
jmp 0x86cd
movb -0x275(%rbp), %al
testb $0x1, %al
jne 0x86d9
jmp 0x8752
movq -0x18(%rbp), %rsi
movq 0x7090c(%rip), %rdi     # 0x78ff0
callq 0x64d0
movq %rax, -0x280(%rbp)
jmp 0x86f2
movq -0x280(%rbp), %rdi
leaq 0x509b8(%rip), %rsi     # 0x590b8
callq 0x6520
movq %rax, -0x288(%rbp)
jmp 0x870e
movq -0x288(%rbp), %rdi
movq 0x70874(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x290(%rbp)
jmp 0x872a
movq -0x290(%rbp), %rdi
movq 0x70858(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x873f
movl $0x1, -0x4(%rbp)
movl $0x1, -0x58(%rbp)
jmp 0x8887
movq -0x28(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x64a0
movq %rax, -0x1f8(%rbp)
movq -0x28(%rbp), %rdi
callq 0x62e0
movq %rax, -0x200(%rbp)
movq -0x1f8(%rbp), %rdi
movq -0x200(%rbp), %rsi
movq 0x707f2(%rip), %rdx     # 0x78f80
callq 0x91c0
movq %rax, -0x298(%rbp)
jmp 0x879c
movq -0x298(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x9210
movq -0x28(%rbp), %rdi
callq 0x62e0
movq %rax, -0x210(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x9210
movq -0x2a0(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
movq -0x208(%rbp), %rdx
callq 0x6100
movq %rax, -0x2a8(%rbp)
jmp 0x8803
movq -0x2a8(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x28(%rbp), %rdi
callq 0x64a0
movq %rax, -0x220(%rbp)
movq -0x28(%rbp), %rdi
callq 0x62e0
movq %rax, -0x228(%rbp)
movq -0x28(%rbp), %rdi
callq 0x64a0
movq %rax, -0x230(%rbp)
movq -0x220(%rbp), %rdi
movq -0x228(%rbp), %rsi
movq -0x230(%rbp), %rdx
movq 0x7077b(%rip), %rcx     # 0x78fd8
callq 0x9250
movq %rax, -0x2b0(%rbp)
jmp 0x886b
movq -0x2b0(%rbp), %rax
movq %rax, -0x238(%rbp)
movl $0x0, -0x4(%rbp)
movl $0x1, -0x58(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x6410
leaq -0x48(%rbp), %rdi
callq 0x6a08
movl -0x4(%rbp), %eax
addq $0x2b0, %rsp            # imm = 0x2B0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x6a08
movq -0x50(%rbp), %rdi
callq 0x6900
nopw (%rax,%rax)