// File: /workspace/github_cpp_makefile_star2_O2/metastableB[P]Program-Dependence-Graph-Creator/./pdg.cpp
// Function: PDG::get_var(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Line)
std::vector<std::string>
PDG::get_var(std::string s, struct Line it) {
	std::vector<std::string> var;
	/*
	 * If an assignment statement,
	 * the string to the left of an = is a variable.
	 * else search for existing variables in the string
	 * make sure they are not substrings and add tit */
	 s= " " + s + " ";
	 int pos = -1;
	 if(it.type == Line_Type::SCOPE_CLOSE) return var;
	 else if(it.type == Line_Type::ASSIGNMENT){
	 	//std::cout << "s" << s <<std::endl;
	 	int m = s.find("=");
	 	pos = m;
	 	m -= 1;
	 	int cnt = 0;
	 	while(m>=0 && std::isspace(s[m])) m--;
	 	while(m>=0 && std::isalnum(s[m])) {m--;cnt++;}
	 	if(m < 0){ 
	 		std::cout << "ERROR Extracting variable " << 
	 	 			"from assignment L : " << it.line_no << std::endl;
	 	 	return var;
	 	 }
	 	 var.push_back(s.substr(++m,cnt));
	 } 
	 for(auto v:variable_map){
	 	while((pos = s.find(v.first,pos+1)) != std::string::npos) {
	 		/*
	 		 * we might have a match. This can be a
	 		 * false positive as well.
	 		 */
	 		 if(!std::isalnum(s[pos-1]) && !std::isalnum(s[pos+v.first.length()])){
	 		 	/* WE have a variable people! */
	 		 	var.push_back(v.first);
	 		 	break;
	 		 }
	 	}
	 }
	 return var;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, (%rsp)
andq $0x0, 0x10(%rdi)
leaq 0x1d88(%rip), %rsi      # 0x510a
leaq 0x38(%rsp), %rdi
callq 0x397e
leaq 0x1d77(%rip), %rdx      # 0x510a
leaq 0x10(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x395f
leaq 0x10(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2240
movq %r12, %rdi
callq 0x2100
leaq 0x38(%rsp), %rdi
callq 0x2100
testl %ebp, %ebp
je 0x33da
cmpl $0x4, %ebp
je 0x3482
pushq $-0x1
popq %r12
jmp 0x34c5
movq %rbx, 0x8(%rsp)
leaq 0x1cf7(%rip), %rsi      # 0x50dd
movq %r14, %rdi
xorl %edx, %edx
callq 0x2370
movq %rax, %r12
movl %r12d, %ebx
movl %r12d, %r13d
sarl $0x1f, %r13d
andl %r12d, %r13d
decl %r13d
decq %rbx
movl %r12d, %ebp
testl %ebp, %ebp
jle 0x3426
movl %ebx, %eax
movq (%r14), %rcx
movsbl (%rcx,%rax), %edi
callq 0x2060
decl %ebp
decq %rbx
testl %eax, %eax
jne 0x3409
jmp 0x3429
movl %r13d, %ebp
xorl %r13d, %r13d
movl %ebp, %ebx
testl %ebx, %ebx
js 0x344b
movl %ebx, %eax
movq (%r14), %rcx
movsbl (%rcx,%rax), %edi
callq 0x21e0
testl %eax, %eax
je 0x3495
decl %ebx
incq %r13
jmp 0x342e
movq 0x4b86(%rip), %rdi      # 0x7fd8
leaq 0x1cfe(%rip), %rsi      # 0x5157
callq 0x21b0
leaq 0x1d0d(%rip), %rsi      # 0x5172
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x2320
movq %rax, %rdi
callq 0x2110
movq (%rsp), %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %ebp
subq %r13, %rbp
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x21f0
leaq 0x10(%rsp), %rsi
movq (%rsp), %rdi
callq 0x429a
leaq 0x10(%rsp), %rdi
callq 0x2100
movabsq $-0x100000000, %rbx     # imm = 0xFFFFFFFF00000000
movq 0x248(%r15), %rbp
addq $0x238, %r15            # imm = 0x238
movq %r15, 0x8(%rsp)
leaq 0x10(%rsp), %r13
cmpq 0x8(%rsp), %rbp
je 0x3482
leaq 0x20(%rbp), %rsi
movq %r13, %rdi
callq 0x3b60
incl %r12d
movslq %r12d, %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2380
movq %rax, %r12
shlq $0x20, %rax
cmpq %rbx, %rax
je 0x3554
addq %rbx, %rax
sarq $0x20, %rax
movq (%r14), %r15
movsbl (%r15,%rax), %edi
callq 0x21e0
testl %eax, %eax
jne 0x34fa
movslq %r12d, %rax
movq 0x18(%rsp), %rcx
addq %rax, %r15
movsbl (%rcx,%r15), %edi
callq 0x21e0
testl %eax, %eax
jne 0x34fa
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x3b7e
movq %r13, %rdi
callq 0x2100
movq %rbp, %rdi
callq 0x2140
movq %rax, %rbp
jmp 0x34e7
jmp 0x357e
jmp 0x358d
jmp 0x358d
movq %rax, %r14
leaq 0x38(%rsp), %rdi
jmp 0x3586
jmp 0x358d
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x2100
jmp 0x3590
movq %rax, %r14
movq (%rsp), %rdi
callq 0x3b3e
movq %r14, %rdi
callq 0x2330
nop