// File: metastableB[P]Program-Dependence-Graph-Creator/./pdg.cpp
// Function: PDG::make_program_map()
bool PDG::make_program_map(){
 	if(!valid) {
 		std::cout << "INTERNAL ERROR!\n";
 		return false;
 	}

 	std::string s;
 	int line_no = 1;
 	int scope = 0;
 	Line_Type type;
 	Line *temp;
 	program_map.push_back({0,0,BEGIN});
 	while(std::getline(in,s)){
 		type = get_line_type(s);
 		temp = (Line*) malloc(sizeof(Line));
 		program_map.push_back({line_no,scope,type});
 		switch(type){
 			case Line_Type::ASSIGNMENT:
 				break;
 			case Line_Type::IF:
 				scope++;
 				break;
 			case Line_Type::ELSE:
 				scope++;
 				break;
 			case Line_Type::WHILE:
 				scope++;
 				break;
 			case Line_Type::SCOPE_CLOSE:
 				scope--;
 				(--program_map.end())->scope -= 1;
 				break;
 			default :
 				std::cout << "Unknown Line Type at L:" << line_no << "\""+s+"\""<<std::endl;
 				return false;
 		}
 		//std::cout << "L " << line_no << " scope " << (--program_map.end())->scope << " type " << type << std::endl;
 		line_no++;
 	}
 	total_lines = line_no - 1;
 	if(scope != 0){
 		std::cout << "Scopes did not close properly\n";
 		return false;
 	}
 	in.seekg(0);
 	return true;
 }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
testb $0x1, 0x210(%rax)
jne 0x3dcf
movq 0xb21e(%rip), %rdi      # 0xefd8
leaq 0x62c4(%rip), %rsi      # 0xa085
callq 0x3260
movb $0x0, -0x1(%rbp)
jmp 0x4158
leaq -0x30(%rbp), %rdi
callq 0x33c0
movq -0x100(%rbp), %rdi
movl $0x1, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
addq $0x218, %rdi            # imm = 0x218
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x6, -0x4c(%rbp)
leaq -0x54(%rbp), %rsi
callq 0x5f40
jmp 0x3e14
jmp 0x3e16
movq -0x100(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x30c0
movq %rax, -0x108(%rbp)
jmp 0x3e2f
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3360
movb %al, -0x109(%rbp)
jmp 0x3e4d
movb -0x109(%rbp), %al
testb $0x1, %al
jne 0x3e5c
jmp 0x40ba
leaq -0x88(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3140
jmp 0x3e6e
movq -0x100(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4300
movl %eax, -0x110(%rbp)
jmp 0x3e89
movl -0x110(%rbp), %eax
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31a0
movl $0xc, %edi
callq 0x3390
movq -0x100(%rbp), %rdi
movq %rax, -0x48(%rbp)
addq $0x218, %rdi            # imm = 0x218
movl -0x34(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x8c(%rbp)
leaq -0x94(%rbp), %rsi
callq 0x5f40
jmp 0x3ee3
movl -0x3c(%rbp), %eax
movq %rax, -0x118(%rbp)
subq $0x4, %rax
ja 0x3fb0
movq -0x118(%rbp), %rax
leaq 0x6157(%rip), %rcx      # 0xa05c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x414d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x31a0
jmp 0x414d
jmp 0x40ac
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x40ac
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x40ac
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x40ac
movq -0x100(%rbp), %rdi
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
addq $0x218, %rdi            # imm = 0x218
callq 0x5f70
movq %rax, -0xa0(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5fa0
movq %rax, %rdi
callq 0x5fc0
movl 0x4(%rax), %ecx
subl $0x1, %ecx
movl %ecx, 0x4(%rax)
jmp 0x40ac
movq 0xb021(%rip), %rdi      # 0xefd8
leaq 0x60d8(%rip), %rsi      # 0xa096
callq 0x3260
movq %rax, -0x120(%rbp)
jmp 0x3fcc
movq -0x120(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x3460
movq %rax, -0x128(%rbp)
jmp 0x3fe4
leaq 0x60c3(%rip), %rsi      # 0xa0ae
leaq -0xe0(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x6030
jmp 0x3ffd
leaq 0x60aa(%rip), %rdx      # 0xa0ae
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5fe0
jmp 0x4019
movq -0x128(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3250
movq %rax, -0x130(%rbp)
jmp 0x4035
movq -0x130(%rbp), %rdi
movq 0xaf85(%rip), %rsi      # 0xefc8
callq 0x32c0
jmp 0x404a
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xe0(%rbp), %rdi
callq 0x31a0
movb $0x0, -0x1(%rbp)
movl $0x1, -0xe4(%rbp)
jmp 0x4142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x409b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31a0
leaq -0xe0(%rbp), %rdi
callq 0x31a0
jmp 0x414d
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3e16
movq -0x100(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, 0x214(%rax)
cmpl $0x0, -0x38(%rbp)
je 0x40f8
movq 0xaefe(%rip), %rdi      # 0xefd8
leaq 0x5fcf(%rip), %rsi      # 0xa0b0
callq 0x3260
jmp 0x40e8
movb $0x0, -0x1(%rbp)
movl $0x1, -0xe4(%rbp)
jmp 0x4142
movq -0x100(%rbp), %rax
movq %rax, -0x138(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0xf8(%rbp), %rdi
callq 0x6140
jmp 0x4118
movq -0x138(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0x3370
jmp 0x4134
movb $0x1, -0x1(%rbp)
movl $0x1, -0xe4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x31a0
jmp 0x4158
leaq -0x30(%rbp), %rdi
callq 0x31a0
jmp 0x4166
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x3470
nop