// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, 0x28(%rsp)
movq $0x0, 0x10(%rdi)
leaq 0x2600(%rip), %rsi      # 0x610a
leaq 0x48(%rsp), %rdi
callq 0x4985
leaq 0x25ef(%rip), %rsi      # 0x610a
leaq 0x48(%rsp), %rdi
callq 0x2340
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3b4b
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x3b52
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rsp, %r12
movq %rdx, 0x8(%r12)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2240
movq (%r12), %rdi
cmpq %r15, %rdi
je 0x3b8e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3ba9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21b0
testl %ebp, %ebp
je 0x3bc2
movq $-0x1, %rbx
cmpl $0x4, %ebp
je 0x3e14
jmp 0x3d22
movq %rbx, 0x38(%rsp)
leaq 0x250f(%rip), %rsi      # 0x60dd
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x2300
movq %rax, %rbx
movl %ebx, %r15d
movl %ebx, %r12d
sarl $0x1f, %r12d
andl %ebx, %r12d
leal -0x1(%r12), %ebp
decq %r15
movl %ebx, %r13d
testl %r13d, %r13d
jle 0x3c1c
movl %r15d, %eax
movq (%r14), %rcx
movsbl (%rcx,%rax), %edi
callq 0x2070
decl %r13d
decq %r15
testl %eax, %eax
jne 0x3bf8
leal 0x1(%r13), %r12d
jmp 0x3c1f
movl %ebp, %r13d
xorl %ebp, %ebp
testl %r12d, %r12d
jle 0x3c6d
movq (%r14), %rax
movq %rax, 0x40(%rsp)
movl %r13d, %r12d
movl %r13d, %eax
sarl $0x1f, %eax
andl %r13d, %eax
movl %r13d, %r15d
subl %eax, %r15d
movl %eax, %r13d
decl %r13d
incl %r15d
movq 0x40(%rsp), %rax
movsbl (%rax,%r12), %edi
callq 0x21c0
testl %eax, %eax
je 0x3c68
decq %r12
incl %ebp
cmpl %ebp, %r15d
jne 0x3c49
jmp 0x3c6b
movl %r12d, %r13d
movl %ebp, %ebp
leaq 0x10(%rsp), %r15
testl %r13d, %r13d
js 0x3cae
leal 0x1(%r13), %edx
movq %rsp, %rdi
movq %r14, %rsi
movq %rbp, %rcx
callq 0x21d0
movq %rsp, %rsi
movq 0x28(%rsp), %rdi
callq 0x5166
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x3d19
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3d19
movq 0x5323(%rip), %rdi      # 0x8fd8
leaq 0x249b(%rip), %rsi      # 0x6157
movl $0x1a, %edx
callq 0x2200
movq 0x530b(%rip), %rdi      # 0x8fd8
leaq 0x249e(%rip), %rsi      # 0x6172
movl $0x14, %edx
callq 0x2200
movq 0x52f3(%rip), %rdi      # 0x8fd8
movq 0x38(%rsp), %rsi
callq 0x22f0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x2190
movsbl %al, %esi
movq %rbp, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
testl %r13d, %r13d
js 0x3e14
movq 0x30(%rsp), %rax
movq 0x248(%rax), %r13
addq $0x238, %rax            # imm = 0x238
movq %rax, 0x30(%rsp)
cmpq %rax, %r13
je 0x3e14
movabsq $-0x100000000, %rbp     # imm = 0xFFFFFFFF00000000
movq %r15, (%rsp)
movq 0x20(%r13), %rsi
movq 0x28(%r13), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x4c0a
movl 0x40(%r13), %eax
movl %eax, 0x20(%rsp)
shlq $0x20, %rbx
movabsq $0x100000000, %rax      # imm = 0x100000000
addq %rax, %rbx
sarq $0x20, %rbx
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2300
movq %rax, %rbx
movq %rax, %r12
shlq $0x20, %r12
cmpq %rbp, %r12
je 0x3de3
leaq (%r12,%rbp), %rax
sarq $0x20, %rax
movq (%r14), %r15
movsbl (%r15,%rax), %edi
callq 0x21c0
testl %eax, %eax
jne 0x3d6b
sarq $0x20, %r12
movq 0x8(%rsp), %rax
addq %r12, %r15
movsbl (%rax,%r15), %edi
callq 0x21c0
testl %eax, %eax
jne 0x3d6b
movq 0x28(%rsp), %rdi
movq %rsp, %rsi
callq 0x4ae6
movq (%rsp), %rdi
leaq 0x10(%rsp), %r15
cmpq %r15, %rdi
je 0x3dfe
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
movq %r13, %rdi
callq 0x2130
movq %rax, %r13
cmpq 0x30(%rsp), %rax
jne 0x3d4c
movq 0x28(%rsp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
jne 0x3e65
jmp 0x3e77
jmp 0x3e74
jmp 0x3e74
movq %rax, %r14
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3e77
movq 0x58(%rsp), %rsi
jmp 0x3e6a
jmp 0x3e74
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3e77
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21b0
jmp 0x3e77
movq %rax, %r14
movq 0x28(%rsp), %rdi
callq 0x4a8a
movq %r14, %rdi
callq 0x2310
nop