// File: /workspace/github_cpp_makefile_star2_O3/czmccrory[P]ManchesterBaby/assembler.cpp
// Function: Assembler::assembleFirstPass()
void Assembler::assembleFirstPass()
{
	ifstream ifs(filePath);
	int counter = 0;
	int* lineCounter = &counter;
	string line = "";

	if (! ifs)
	{
		throw AssemblerException("Invalid filename");
	}

	cout << "FIRST PASS:" << endl;

	try
	{
		while (getline(ifs, line)) //while nextLine exists
		{
			string lineCopy = line;
			string* linePtr = &lineCopy;
			cout << "assembling line: " << line << endl;
		 	assembleLineFirstPass(linePtr, lineCounter);
		}
	}
	catch (AssemblerException &e)
	{
		cout << "\033[1;31mAssembler Error: \033[0m" << e.what() << endl;
		exit (0);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, %rbx
leaq 0x50(%rdi), %rsi
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x22e0
movl $0x0, 0xc(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x3b4c(%rip), %rdx      # 0x70e4
leaq 0x10(%rsp), %rdi
movq %rdx, %rsi
callq 0x605e
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x371d
movq 0x6a0d(%rip), %r15      # 0x9fd0
leaq 0x3ae8(%rip), %rsi      # 0x70b2
movl $0xb, %edx
movq %r15, %rdi
callq 0x2230
movq (%r15), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq 0x69db(%rip), %rdi      # 0x9fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x40(%rsp), %rbp
leaq 0x30(%rsp), %r12
movq 0x69bd(%rip), %r13      # 0x9fd0
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2360
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x36e5
movq %rbp, 0x30(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x5ebe
movl $0x11, %edx
movq %r13, %rdi
leaq 0x3a4a(%rip), %rsi      # 0x70be
callq 0x2230
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %r13, %rdi
callq 0x2230
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %rbx, %rdi
movq %r12, %rsi
leaq 0xc(%rsp), %rdx
callq 0x3c52
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3613
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x3613
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x3701
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x70(%rsp), %rdi
callq 0x2060
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x20f0
movq %rax, %r14
leaq 0x60(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x3967(%rip), %rsi      # 0x70a1
leaq 0x3970(%rip), %rdx      # 0x70b1
leaq 0x50(%rsp), %rdi
callq 0x605e
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x5cc2
xorl %ebp, %ebp
leaq 0x65fc(%rip), %rsi      # 0x9d60
leaq 0x2527(%rip), %rdx      # 0x5c92
movq %r14, %rdi
callq 0x2310
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x378d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
testb %bpl, %bpl
jne 0x379a
jmp 0x3833
movq %rax, %rbx
movq %r14, %rdi
callq 0x2160
jmp 0x3833
movq %rax, %rbx
jmp 0x384f
movq %rax, %rbx
jmp 0x3833
jmp 0x37b6
movq %rdx, %r14
movq %rax, %rbx
jmp 0x37db
movq %rdx, %r14
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x37db
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpl $0x1, %r14d
jne 0x3833
movq %rbx, %rdi
callq 0x20c0
movq %rax, %rbx
movq 0x67dd(%rip), %rdi      # 0x9fd0
leaq 0x388a(%rip), %rsi      # 0x7084
movl $0x1c, %edx
callq 0x2230
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x67bc(%rip), %rdi      # 0x9fd0
movq %rax, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x20e0
xorl %edi, %edi
callq 0x2240
movq %rax, %rbx
callq 0x22f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x384f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x70(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2330
movq %rax, %rdi
callq 0x5c81
nop