// File: metastableB[P]Program-Dependence-Graph-Creator/./pdg.cpp
// Function: PDG::make_variable_map()
bool PDG::make_variable_map(){
	if(!valid) { std::cout << "INTERNAL ERROR! EXITING\n"; return false;}
	std::string s;
	//std::cout << "RUNNING";
	in.clear();
	in.seekg(0,std::ios::beg);
	for(int i = 1; i <= total_lines; i++){
		/*
		 * If its an assignment statement. Update the assignment value
		 * else check any variable has been used
		 * this variable should be defined previously
		 * update dependency of this graph
		 */
		 getline(in,s);
		 //std::cout << s << std::endl;
		 auto &it = program_map[i];
		 auto variables = get_var(s,it);
		 if(variables.empty()) continue;
		 //std::cout << "got " << variables[0] << std::endl;
		 if(it.type == Line_Type::ASSIGNMENT){
		 	variable_map[variables[0]] = it.line_no;
		 	auto i = variables.begin();
		 	i++;
		 	while(i!= variables.end()) {g_ddg[it.line_no][variable_map[*i]] = 1;i++;}
		 } else {
		 	for(auto v : variables)
		 		g_ddg[it.line_no][variable_map[v]] = 1;
		 }
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
testb $0x1, 0x210(%rax)
jne 0x4f8f
movq 0xa05e(%rip), %rdi      # 0xefd8
leaq 0x51bd(%rip), %rsi      # 0xa13e
callq 0x3260
movb $0x0, -0x1(%rbp)
jmp 0x5367
leaq -0x30(%rbp), %rdi
callq 0x33c0
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
xorl %esi, %esi
callq 0x3440
jmp 0x4fb2
movq -0x108(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x33a0
jmp 0x4fc4
movl $0x1, -0x40(%rbp)
movq -0x108(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0x214(%rcx), %eax
jg 0x5343
movq -0x108(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x30c0
jmp 0x4ff3
movq -0x108(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
movslq -0x40(%rbp), %rsi
callq 0x6570
movq %rax, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3140
jmp 0x501d
movq -0x108(%rbp), %rsi
movq -0x48(%rbp), %rax
movl 0x8(%rax), %ecx
movl %ecx, -0x88(%rbp)
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x98(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rcx
movl -0x98(%rbp), %r8d
leaq -0x60(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x5380
jmp 0x5072
leaq -0x80(%rbp), %rdi
callq 0x31a0
leaq -0x60(%rbp), %rdi
callq 0x6590
testb $0x1, %al
jne 0x508a
jmp 0x50c4
movl $0x4, -0xa4(%rbp)
jmp 0x5311
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x535c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31a0
jmp 0x535c
movq -0x48(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x5210
movq -0x108(%rbp), %rax
movq -0x48(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x11c(%rbp)
addq $0x230, %rax            # imm = 0x230
movq %rax, -0x118(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x66b0
movq -0x118(%rbp), %rdi
movq %rax, %rsi
callq 0x65d0
movq %rax, -0x110(%rbp)
jmp 0x5117
movq -0x110(%rbp), %rax
movl -0x11c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x60(%rbp), %rdi
callq 0x66d0
movq %rax, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x6700
movq %rax, -0xb8(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x6780
movq %rax, -0xc0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x6740
testb $0x1, %al
jne 0x5177
jmp 0x520b
movq -0x108(%rbp), %rax
movq 0x268(%rax), %rcx
movq -0x48(%rbp), %rdx
movslq (%rdx), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x138(%rbp)
addq $0x230, %rax            # imm = 0x230
movq %rax, -0x130(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x67b0
movq -0x130(%rbp), %rdi
movq %rax, %rsi
callq 0x65d0
movq %rax, -0x128(%rbp)
jmp 0x51c8
movq -0x138(%rbp), %rax
movq -0x128(%rbp), %rcx
movslq (%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
leaq -0xb0(%rbp), %rdi
xorl %esi, %esi
callq 0x6700
movq %rax, -0xc8(%rbp)
jmp 0x514b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5338
jmp 0x5307
leaq -0x60(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x66d0
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x6780
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x6740
testb $0x1, %al
jne 0x525d
jmp 0x5305
leaq -0xd8(%rbp), %rdi
callq 0x67b0
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
callq 0x3140
jmp 0x527a
movq -0x108(%rbp), %rdi
movq 0x268(%rdi), %rax
movq -0x48(%rbp), %rcx
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x148(%rbp)
addq $0x230, %rdi            # imm = 0x230
leaq -0x100(%rbp), %rsi
callq 0x65d0
movq %rax, -0x140(%rbp)
jmp 0x52b6
movq -0x148(%rbp), %rax
movq -0x140(%rbp), %rcx
movslq (%rcx), %rcx
movl $0x1, (%rax,%rcx,4)
leaq -0x100(%rbp), %rdi
callq 0x31a0
leaq -0xd8(%rbp), %rdi
callq 0x67d0
jmp 0x5241
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x31a0
jmp 0x5338
jmp 0x5307
movl $0x0, -0xa4(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x67f0
movl -0xa4(%rbp), %eax
testl %eax, %eax
je 0x5328
jmp 0x5326
jmp 0x532a
jmp 0x532a
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x4fcb
leaq -0x60(%rbp), %rdi
callq 0x67f0
jmp 0x535c
movb $0x1, -0x1(%rbp)
movl $0x1, -0xa4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x31a0
jmp 0x5367
leaq -0x30(%rbp), %rdi
callq 0x31a0
jmp 0x5375
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3470
nop