// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x60, %rsp
movq %rdx, %r14
movq %rdi, %rbx
leaq 0x27f5(%rip), %rsi      # 0x60e4
movq %rsp, %rdi
leaq 0x20(%rsp), %rdx
callq 0x4630
leaq 0x286b(%rip), %rsi      # 0x616e
movq %r14, %rdi
xorl %edx, %edx
callq 0x2360
cmpq $-0x1, %rax
je 0x3957
leaq 0x2854(%rip), %rsi      # 0x616e
movq %r14, %rdi
xorl %edx, %edx
callq 0x2360
testq %rax, %rax
je 0x3a95
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2210
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2230
movq %r15, %rdi
callq 0x20e0
leaq 0x26ed(%rip), %rsi      # 0x604b
movq %r14, %rdi
xorl %edx, %edx
callq 0x2130
cmpq $-0x1, %rax
je 0x3ac1
leaq 0x26d2(%rip), %rsi      # 0x604b
movq %r14, %rdi
xorl %edx, %edx
callq 0x2130
movq 0x8(%r14), %rcx
subq %rax, %rcx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2210
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2230
movq %r15, %rdi
callq 0x20e0
leaq 0x2692(%rip), %rsi      # 0x604b
movq %r14, %rdi
xorl %edx, %edx
callq 0x2360
cmpq $-0x1, %rax
je 0x3a38
leaq 0x267b(%rip), %rsi      # 0x604b
movq %r14, %rdi
xorl %edx, %edx
callq 0x2360
movq %rax, %r15
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2210
movq %rsp, %rdi
leaq 0x20(%rsp), %r12
movq %r12, %rsi
callq 0x2230
movq %r12, %rdi
callq 0x20e0
movq 0x8(%r14), %rcx
subq %r15, %rcx
leaq 0x20(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2210
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2230
movq %r15, %rdi
callq 0x20e0
jmp 0x3a52
movq %rsp, %rdi
movq %r14, %rsi
callq 0x2120
leaq 0x269a(%rip), %rsi      # 0x60e4
movq %r14, %rdi
callq 0x2330
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x3a75
movq %rdx, (%rbx)
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rbx)
jmp 0x3a7b
movups (%rax), %xmm0
movups %xmm0, (%rcx)
movq 0x8(%rsp), %rcx
movq %rcx, 0x8(%rbx)
movq %rax, (%rsp)
andq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
jmp 0x3aa9
leaq 0x2648(%rip), %rsi      # 0x60e4
leaq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x4630
movq %rsp, %rdi
callq 0x20e0
movq %rbx, %rax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0x269d(%rip), %rsi      # 0x6170
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x4630
movb $0x1, %bpl
leaq 0x40(%rsp), %rsi
movq %rbx, %rdi
callq 0x4914
xorl %ebp, %ebp
leaq 0x6275(%rip), %rsi      # 0x9d70
leaq 0xdf2(%rip), %rdx       # 0x48f4
movq %rbx, %rdi
callq 0x22e0
jmp 0x3b35
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0x20e0
testb %bpl, %bpl
jne 0x3b23
jmp 0x3b38
movq %rax, %r14
movq %rbx, %rdi
callq 0x2180
jmp 0x3b38
jmp 0x3b35
jmp 0x3b35
jmp 0x3b35
jmp 0x3b35
movq %rax, %r14
movq %rsp, %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x22f0