// File: /workspace/github_cpp_makefile_star2_O3/czmccrory[P]ManchesterBaby/assembler.cpp
// Function: Assembler::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
string Assembler::parse(string* line)
{
	string parsed = "";
	// is there a comment, if there is remove it
	if(line->find(";") != string::npos)
	{
		size_t semiColonIndex = line->find(";");

		if (semiColonIndex == 0)
		{
			return ""; //theres nothing useful on the line
		}
		else
		{
			(*line) = line->substr(0, semiColonIndex);
		}

	}

	// find first non whitespace character
	if(line->find_first_not_of(" ") != string::npos)
	{
		size_t firstIndex = line->find_first_not_of(" ");
		(*line) = line->substr(firstIndex, line->length() - firstIndex);


		// 2 cases being there is a space, word is end of line
		if(line->find(" ") != string::npos)
		{
			size_t whiteSpaceIndex = line->find(" ");

			parsed = line->substr(0, whiteSpaceIndex);

			(*line) = line->substr(whiteSpaceIndex, line->length() - whiteSpaceIndex);

			return parsed;
		}
		else
		{
			parsed = (*line);

			(*line) = "";
			return parsed;

		}
	}
	throw (AssemblerException("Expected Operand"));
	return "";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x2c7e(%rip), %rdx      # 0x70e4
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x605e
leaq 0x2cf4(%rip), %rsi      # 0x716e
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
cmpq $-0x1, %rax
je 0x44ea
leaq 0x2cd8(%rip), %rsi      # 0x716e
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
testq %rax, %rax
je 0x4679
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2210
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2250
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x44ea
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x2b5a(%rip), %rsi      # 0x704b
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2300
cmpq $-0x1, %rax
je 0x46ab
leaq 0x2b3a(%rip), %rsi      # 0x704b
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2300
movq 0x8(%r14), %rcx
subq %rax, %rcx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2210
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2250
movq (%r15), %rdi
leaq 0x18(%rsp), %rbp
cmpq %rbp, %rdi
je 0x4561
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x2ae3(%rip), %rsi      # 0x704b
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
cmpq $-0x1, %rax
je 0x4612
leaq 0x2ac3(%rip), %rsi      # 0x704b
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
movq %rax, %r15
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2210
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
callq 0x2250
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0x45d4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%r14), %rcx
subq %r15, %rcx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2210
leaq 0x8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2250
movq (%r15), %rdi
cmpq %rbp, %rdi
je 0x4637
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x4637
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x2110
movq 0x8(%r14), %rdx
leaq 0x2aba(%rip), %rcx      # 0x70e4
movq %r14, %rdi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x22c0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x28(%rsp), %rcx
cmpq %r13, %rcx
je 0x4656
movq %rcx, (%rbx)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x465e
movups (%r13), %xmm0
movups %xmm0, (%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2a5d(%rip), %rdx      # 0x70e4
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x605e
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x4667
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x4667
movl $0x28, %edi
callq 0x20f0
movq %rax, %rbx
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2aa8(%rip), %rsi      # 0x7170
leaq 0x2ab1(%rip), %rdx      # 0x7180
leaq 0x48(%rsp), %rdi
callq 0x605e
movb $0x1, %bpl
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x5cc2
xorl %ebp, %ebp
leaq 0x566e(%rip), %rsi      # 0x9d60
leaq 0x1599(%rip), %rdx      # 0x5c92
movq %rbx, %rdi
callq 0x2310
jmp 0x4739
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x471d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
testb %bpl, %bpl
jne 0x4727
jmp 0x473c
movq %rax, %r14
movq %rbx, %rdi
callq 0x2160
jmp 0x473c
jmp 0x4739
jmp 0x4739
jmp 0x4739
jmp 0x4739
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x4753
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %r14, %rdi
callq 0x2330
nop