// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
leaq 0x5625(%rip), %rsi      # 0xb1d9
movl $0x5, %ecx
xorl %edx, %edx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
je 0x5c13
leaq 0x564b(%rip), %r15      # 0xb21e
leaq 0x55ff(%rip), %r12      # 0xb1d9
sarq $0x20, %r14
movl $0x5, %edx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2240
movl $0x5, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
jne 0x5bda
leaq 0x55c5(%rip), %rsi      # 0xb1df
movl $0x4, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
je 0x5c7c
leaq 0x55e2(%rip), %r15      # 0xb21e
leaq 0x559c(%rip), %r12      # 0xb1df
sarq $0x20, %r14
movl $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2240
movl $0x4, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
jne 0x5c43
leaq 0x5561(%rip), %rsi      # 0xb1e4
movl $0x9, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
je 0x5ce5
leaq 0x5579(%rip), %r15      # 0xb21e
leaq 0x5533(%rip), %r12      # 0xb1df
sarq $0x20, %r14
movl $0x9, %edx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x2240
movl $0x4, %ecx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x2370
movq %rax, %r14
shlq $0x20, %r14
cmpq %r13, %r14
jne 0x5cac
leaq 0x5502(%rip), %rsi      # 0xb1ee
movl $0xa, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2370
cmpl $-0x1, %eax
je 0x603e
movq %rax, -0xb0(%rbp)
movabsq $0x100000000, %r12      # imm = 0x100000000
leaq 0x54d2(%rip), %rsi      # 0xb1ee
movl $0xa, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2370
movq (%rbx), %rcx
shlq $0x20, %rax
movq %r13, %rdx
movabsq $0xa00000000, %r13      # imm = 0xA00000000
addq %rax, %r13
movq %r13, %r15
sarq $0x20, %r15
decq %r15
addq %rdx, %r13
addq %r12, %r13
cmpb $0x20, 0x1(%rcx,%r15)
leaq 0x1(%r15), %r15
je 0x5d4f
leaq -0xc0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x54ae(%rip), %r14      # 0xb21e
leaq -0xd0(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x4e92
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0xa8(%rbp), %rdi
movq %r14, %rsi
movq %r14, %rdx
callq 0x4e92
movq (%rbx), %rax
sarq $0x20, %r13
movb (%rax,%r13), %al
cmpb $0x2c, %al
je 0x5dcf
leaq -0xa8(%rbp), %r13
movsbl %al, %esi
movq %r13, %rdi
callq 0x21a0
movq (%rbx), %rax
movb 0x1(%rax,%r15), %al
incq %r15
cmpb $0x2c, %al
jne 0x5db5
movslq %r15d, %r13
shlq $0x20, %r15
movq -0xb0(%rbp), %rax
shlq $0x20, %rax
subq %rax, %r15
movabsq $0x200000000, %r14      # imm = 0x200000000
addq %r15, %r14
incq %r13
leaq -0xd0(%rbp), %r15
movq (%rbx), %rax
movb (%rax,%r13), %al
cmpb $0x29, %al
je 0x5e19
addq %r12, %r14
incq %r13
movsbl %al, %esi
movq %r15, %rdi
callq 0x21a0
jmp 0x5dfb
leaq 0x53ce(%rip), %rsi      # 0xb1ee
movl $0xa, %ecx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2370
movq %rax, %r15
shlq $0x20, %r15
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
cmpq %r13, %r15
je 0x600e
sarq $0x20, %r14
leaq -0xf0(%rbp), %r13
movq %r13, %rdi
leaq 0x539b(%rip), %rsi      # 0xb1f9
leaq -0xd0(%rbp), %rdx
callq 0x4ba5
movq %r13, %r12
movq %r13, %rdi
leaq 0x5394(%rip), %rsi      # 0xb20b
callq 0x23c0
leaq -0x58(%rbp), %rsi
movq %rsi, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5ea0
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x5ea6
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x2090
leaq -0x78(%rbp), %rsi
movq %rsi, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5efe
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x5f04
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x88(%rbp), %rdi
leaq 0x52ef(%rip), %rsi      # 0xb218
callq 0x23c0
leaq -0x38(%rbp), %rsi
movq %rsi, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5f52
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x5f58
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
sarq $0x20, %r15
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2240
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5f9b
callq 0x21c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x5fb0
callq 0x21c0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5fc2
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x5fda
callq 0x21c0
movl $0xa, %ecx
movq %rbx, %rdi
leaq 0x5205(%rip), %rsi      # 0xb1ee
movq %r15, %rdx
callq 0x2370
movq %rax, %r15
shlq $0x20, %r15
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
cmpq %rax, %r15
movq %r12, %r13
jne 0x5e54
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x6026
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x603e
callq 0x21c0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x60dc
jmp 0x60c1
movq %rax, %rbx
jmp 0x60a5
movq %rax, %rbx
jmp 0x6093
movq %rax, %rbx
jmp 0x607e
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x607e
callq 0x21c0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x6093
callq 0x21c0
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x60a5
callq 0x21c0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x60c4
callq 0x21c0
jmp 0x60c4
jmp 0x60c1
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x60dc
callq 0x21c0
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x60f4
callq 0x21c0
movq %rbx, %rdi
callq 0x2380