// File: /workspace/github_cpp_makefile_star2_O1/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 0x3b4e(%rip), %rdx      # 0x7100
leaq 0x10(%rsp), %rdi
movq %rdx, %rsi
callq 0x6088
movq 0x70(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x90(%rsp,%rax)
jne 0x3737
movq 0x69f3(%rip), %r15      # 0x9fd0
leaq 0x3aea(%rip), %rsi      # 0x70ce
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 0x69c1(%rip), %rdi      # 0x9fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq 0x40(%rsp), %rbp
leaq 0x30(%rsp), %r12
movq 0x69a3(%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 0x36ff
movq %rbp, 0x30(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x5ee4
movl $0x11, %edx
movq %r13, %rdi
leaq 0x3a4c(%rip), %rsi      # 0x70da
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 0x3c80
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x362d
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x362d
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x371b
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 0x3969(%rip), %rsi      # 0x70bd
leaq 0x3972(%rip), %rdx      # 0x70cd
leaq 0x50(%rsp), %rdi
callq 0x6088
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x5ce8
xorl %ebp, %ebp
leaq 0x65e2(%rip), %rsi      # 0x9d60
leaq 0x2533(%rip), %rdx      # 0x5cb8
movq %r14, %rdi
callq 0x2310
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x37af
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x37af
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x3851
movq %r14, %rdi
callq 0x2160
jmp 0x3851
movq %rax, %rbx
jmp 0x386d
movq %rax, %rbx
jmp 0x3851
jmp 0x37d4
movq %rdx, %r14
movq %rax, %rbx
jmp 0x37f9
movq %rdx, %r14
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %rbp, %rdi
je 0x37f9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x21f0
cmpl $0x1, %r14d
jne 0x3851
movq %rbx, %rdi
callq 0x20c0
movq %rax, %rbx
movq 0x67bf(%rip), %rdi      # 0x9fd0
leaq 0x3888(%rip), %rsi      # 0x70a0
movl $0x1c, %edx
callq 0x2230
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x679e(%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 0x386d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x70(%rsp), %rdi
callq 0x2060
movq %rbx, %rdi
callq 0x2330
movq %rax, %rdi
callq 0x5ca7
nop