// File: /workspace/github_cpp_makefile_star2_O1/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 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x2c68(%rip), %rdx      # 0x7100
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x6088
leaq 0x2cde(%rip), %rsi      # 0x718a
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
cmpq $-0x1, %rax
je 0x4540
leaq 0x2cc2(%rip), %rsi      # 0x718a
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
movq %rax, %r15
testq %rax, %rax
je 0x451e
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x2210
leaq 0x28(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2250
movq (%r12), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4537
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x4537
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x2bd4(%rip), %rdx      # 0x7100
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x6088
testq %r15, %r15
je 0x46d0
leaq 0x2b20(%rip), %rsi      # 0x7067
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2300
cmpq $-0x1, %rax
je 0x46f9
leaq 0x2b00(%rip), %rsi      # 0x7067
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2300
movq 0x8(%r14), %rcx
subq %rax, %rcx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2210
leaq 0x28(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2250
movq (%r15), %rdi
leaq 0x38(%rsp), %rbp
cmpq %rbp, %rdi
je 0x45b7
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x2aa9(%rip), %rsi      # 0x7067
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
cmpq $-0x1, %rax
je 0x4668
leaq 0x2a89(%rip), %rsi      # 0x7067
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2320
movq %rax, %r15
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2210
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %r12
movq %r12, %rsi
callq 0x2250
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0x462a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%r14), %rcx
subq %r15, %rcx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2210
leaq 0x28(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2250
movq (%r15), %rdi
cmpq %rbp, %rdi
je 0x468d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x468d
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2110
movq 0x8(%r14), %rdx
leaq 0x2a80(%rip), %rcx      # 0x7100
movq %r14, %rdi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x22c0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rcx
cmpq %r13, %rcx
je 0x46ac
movq %rcx, (%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rbx)
jmp 0x46b4
movups (%r13), %xmm0
movups %xmm0, (%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rbx)
movq %r13, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x46e7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2a76(%rip), %rsi      # 0x718c
leaq 0x2a7f(%rip), %rdx      # 0x719c
leaq 0x48(%rsp), %rdi
callq 0x6088
movb $0x1, %bpl
leaq 0x48(%rsp), %rsi
movq %r14, %rdi
callq 0x5ce8
xorl %ebp, %ebp
leaq 0x5620(%rip), %rsi      # 0x9d60
leaq 0x1571(%rip), %rdx      # 0x5cb8
movq %r14, %rdi
callq 0x2310
jmp 0x478a
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x4773
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x4773
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x478d
movq %r14, %rdi
callq 0x2160
jmp 0x478d
jmp 0x478a
jmp 0x478a
jmp 0x478a
jmp 0x478a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x47a4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq %rbx, %rdi
callq 0x2330