// File: nikhilYadala[P]Python_to_cpp/Source/src/functionize.cpp
// Function: self_sanitize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
void self_sanitize(std::string* code) {
	int itr = code->find("self.", 0);
    while(itr != std::string::npos) {
        code->replace(itr, 5, ""); 
        itr = code->find("self.", itr);
    }

    itr = code->find("self", 0);
    while(itr != std::string::npos) {
        code->replace(itr, 4, ""); 
        itr = code->find("self", itr);
    }

    itr = code->find("import re", 0);
    while(itr != std::string::npos) {
        code->replace(itr, 9, ""); 
        itr = code->find("self", itr);
    }

    int rem = code->find("re.search(");
    if(rem!=std::string::npos){
    itr =  code->find("re.search(")+10;
    	// std::cout<<">>>>>>>>>>>"<<itr<<"  "<<"\n";
    while(*(code->begin()+itr)==' ')
    	itr++;


    std::string s ="",r="";
    while(*(code->begin()+itr)!=','){
    	r.push_back(*(code->begin()+itr));
    	itr++;
    }
    itr++;

    while(*(code->begin()+itr)!=')'){
    	s.push_back(*(code->begin()+itr));
    	itr++;
    }
    rem=itr-rem+1;
       itr = code->find("re.search(", 0);
    while(itr != std::string::npos) {
        code->replace(itr, rem, "std::regex_match("+s+",std::regex("+r+"))"); 
        itr = code->find("re.search(", itr);
    	}
	}
	// if(std::find(tokens.begin(), tokens.end(),"re.search")!=tokens.end())
	// {
	// 	converted_code.append((size_t)lines[i].second*tab_size,' ');	
	// 	converted_code.append("bool "+v+" = std::regex_match("+*(itr+8)+", std::regex_match("+*(itr+6)+"))"+"\n");		

	// }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xb7ef(%rip), %rsi      # 0x161c9
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rax
cmpq $-0x1, %rax
je 0xaa22
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
movl $0x5, %edx
leaq 0xb80a(%rip), %rcx      # 0x1620e
callq 0x3160
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rdx
leaq 0xb7b1(%rip), %rsi      # 0x161c9
callq 0x3440
movl %eax, -0xc(%rbp)
jmp 0xa9e6
movq -0x8(%rbp), %rdi
leaq 0xb7a2(%rip), %rsi      # 0x161cf
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rax
cmpq $-0x1, %rax
je 0xaa75
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
movl $0x4, %edx
leaq 0xb7b7(%rip), %rcx      # 0x1620e
callq 0x3160
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rdx
leaq 0xb764(%rip), %rsi      # 0x161cf
callq 0x3440
movl %eax, -0xc(%rbp)
jmp 0xaa39
movq -0x8(%rbp), %rdi
leaq 0xb754(%rip), %rsi      # 0x161d4
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rax
cmpq $-0x1, %rax
je 0xaac8
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rsi
movl $0x9, %edx
leaq 0xb764(%rip), %rcx      # 0x1620e
callq 0x3160
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rdx
leaq 0xb711(%rip), %rsi      # 0x161cf
callq 0x3440
movl %eax, -0xc(%rbp)
jmp 0xaa8c
movq -0x8(%rbp), %rdi
leaq 0xb70b(%rip), %rsi      # 0x161de
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
movl %eax, -0x10(%rbp)
movslq -0x10(%rbp), %rax
cmpq $-0x1, %rax
je 0xaec7
movq -0x8(%rbp), %rdi
leaq 0xb6e6(%rip), %rsi      # 0x161de
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
addq $0xa, %rax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31d0
movq %rax, -0x20(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x6f90
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %eax
cmpl $0x20, %eax
jne 0xab42
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xab08
leaq -0x41(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x3400
movq -0x148(%rbp), %rdx
leaq 0xb6ae(%rip), %rsi      # 0x1620e
leaq -0x40(%rbp), %rdi
callq 0x3340
jmp 0xab6b
leaq -0x41(%rbp), %rdi
callq 0x32a0
leaq -0x79(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3400
movq -0x150(%rbp), %rdx
leaq 0xb67c(%rip), %rsi      # 0x1620e
leaq -0x78(%rbp), %rdi
callq 0x3340
jmp 0xab9d
leaq -0x79(%rbp), %rdi
callq 0x32a0
movq -0x8(%rbp), %rdi
callq 0x31d0
movq %rax, -0x90(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x6f90
movq %rax, -0x88(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %eax
cmpl $0x2c, %eax
je 0xac79
movq -0x8(%rbp), %rdi
callq 0x31d0
movq %rax, -0xa0(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x6f90
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %esi
leaq -0x78(%rbp), %rdi
callq 0x31c0
jmp 0xac26
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xaba6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x32a0
jmp 0xaed0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x32a0
jmp 0xaebc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xaeb3
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x31d0
movq %rax, -0xb0(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x6f90
movq %rax, -0xa8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %eax
cmpl $0x29, %eax
je 0xad0c
movq -0x8(%rbp), %rdi
callq 0x31d0
movq %rax, -0xc0(%rbp)
movslq -0xc(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x6f90
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %esi
leaq -0x40(%rbp), %rdi
callq 0x31c0
jmp 0xacfe
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xac82
movl -0xc(%rbp), %eax
subl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xb4bb(%rip), %rsi      # 0x161de
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rax
cmpq $-0x1, %rax
je 0xae9f
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
movslq -0xc(%rbp), %rax
movq %rax, -0x160(%rbp)
movslq -0x10(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq 0xb484(%rip), %rsi      # 0x161e9
leaq -0x140(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x7040
jmp 0xad77
leaq 0xb47d(%rip), %rdx      # 0x161fb
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x6ff0
jmp 0xad93
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0xb6d0
jmp 0xadac
leaq 0xb455(%rip), %rdx      # 0x16208
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6ff0
jmp 0xadc8
movq -0x158(%rbp), %rdx
movq -0x160(%rbp), %rsi
movq -0x168(%rbp), %rdi
leaq -0xe0(%rbp), %rcx
callq 0x30c0
jmp 0xadeb
leaq -0xe0(%rbp), %rdi
callq 0x3170
leaq -0x100(%rbp), %rdi
callq 0x3170
leaq -0x120(%rbp), %rdi
callq 0x3170
leaq -0x140(%rbp), %rdi
callq 0x3170
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rdx
leaq 0xb3b4(%rip), %rsi      # 0x161de
callq 0x3440
movl %eax, -0xc(%rbp)
jmp 0xad2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xae91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xae85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xae79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x3170
leaq -0x100(%rbp), %rdi
callq 0x3170
leaq -0x120(%rbp), %rdi
callq 0x3170
leaq -0x140(%rbp), %rdi
callq 0x3170
jmp 0xaeb3
leaq -0x78(%rbp), %rdi
callq 0x3170
leaq -0x40(%rbp), %rdi
callq 0x3170
jmp 0xaec7
leaq -0x78(%rbp), %rdi
callq 0x3170
leaq -0x40(%rbp), %rdi
callq 0x3170
jmp 0xaed0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x33f0
nopl (%rax)