// File: /workspace/github_cpp_makefile_star2_O2/nikhilYadala[P]Python_to_cpp/Source/src/render_code.cpp
// Function: source_code::render_code()
void source_code::render_code()
{
	int s=strlen(file_name);
	char *file_to_write=(char *)malloc(s+5);
	*file_to_write='\0';
	strcat(file_to_write,file_name);
	strcat(file_to_write,".cpp\0");
	

	std::ofstream cpp_file(file_to_write);

	
	std::string decl;
	decl.append("#include \"supporting_libs.h\"\n\n");

	std::vector< std::pair< std::string,function_declaration > >::iterator itr = generated_cpp_code.begin();



//code for rendering the cpp classes

  for(std::vector<std::pair <std::string,class_declaration > >
   			::iterator class_itr=generated_cpp_classes.begin();
   			 class_itr!=generated_cpp_classes.end()-1;
   			 class_itr++)
   {
   		decl.append("class ");
   		decl.append((class_itr->second).name);
   		//attach the inherited functions here
   		if((class_itr->second).num_base_func >0)
   		{
   			decl.append(": ");
   			std::vector< std::string >::iterator base_functions_itr = (class_itr->second).base_functions.begin();
   			for(int k=0;k<(class_itr->second).num_base_func;k++)
   			{
   				decl.append("public ");
   				decl.append(*(base_functions_itr));
   				base_functions_itr++;


   			}
   		}
   		decl.append("\n{");
   		decl.append("\n public: \n");
   		decl.append(class_itr->first);
   		decl.append("\n};\n");
   }


// For remaining functions iterate over the generated_cpp_code vec	tor
	for(std::vector< std::pair< std::string,function_declaration > >::iterator itr=generated_cpp_code.begin()+1;itr!=generated_cpp_code.end();++itr)
		{
			 decl.append(itr->second.return_type);
			 decl.append(" ");
			 decl.append(itr->second.name);
			 decl.append("(");
			 for(std::vector< string_pair >::iterator i=itr->second.args.begin();i!=itr->second.args.end();++i)
			 {
			 	decl.append(i->second);
			 	decl.append(" ");
			 	decl.append(i->first);
			 	decl.append(",");
			 }
			 if(*(decl.end()-1) == ',')
			 	*(decl.end()-1)=')';
			 else  decl.append(")");
			 
			decl.append("\n{\n");
			decl.append(itr->first);
			decl.append("\n}\n\n");

		}

			// For main function 
		    	decl.append(itr->second.return_type);
			 decl.append(" ");
			 decl.append(itr->second.name);
			 decl.append("(");
			 for(std::vector< string_pair >::iterator i=itr->second.args.begin();i!=itr->second.args.end();++i)
			 {
			 	decl.append(i->second);
			 	decl.append(" ");
			 	decl.append(i->first);
			 	decl.append(",");
			 }
			 if(*(decl.end()-1) == ',')
			 	*(decl.end()-1)=')';
			 else  decl.append(")");
			 
			decl.append("\n{\n");
			decl.append(itr->first);
			decl.append("\n}\n\n");


		cpp_file<<decl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rdi, %r12
movq 0x30(%rdi), %rbx
movq %rbx, %rdi
callq 0x20d0
addl $0x5, %eax
movslq %eax, %rdi
callq 0x2260
movq %rax, %r14
xorl %r15d, %r15d
movb %r15b, (%rax)
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2330
movq %r14, %rdi
callq 0x20d0
movb %r15b, 0x4(%r14,%rax)
movl $0x7070632e, (%r14,%rax) # imm = 0x7070632E
leaq -0x260(%rbp), %rdi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2200
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x2774(%rip), %rsi      # 0x92b0
leaq -0x48(%rbp), %rdi
callq 0x2340
movq 0x80(%r12), %rax
movq %rax, -0x60(%rbp)
movq %r12, -0x50(%rbp)
movq 0x98(%r12), %rbx
leaq -0x48(%rbp), %r12
leaq 0x276e(%rip), %r13      # 0x92d6
movq -0x50(%rbp), %rax
movq 0xa0(%rax), %rax
addq $-0x60, %rax
cmpq %rax, %rbx
je 0x6c1d
movq %r12, %rdi
leaq 0x2745(%rip), %rsi      # 0x92cf
callq 0x2340
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0x2360
cmpl $0x0, 0x40(%rbx)
jle 0x6bdc
movq %r12, %rdi
leaq 0x253d(%rip), %rsi      # 0x90e8
callq 0x2340
movq 0x48(%rbx), %r14
xorl %r15d, %r15d
cmpl 0x40(%rbx), %r15d
jge 0x6bdc
movq %r12, %rdi
movq %r13, %rsi
callq 0x2340
movq %r12, %rdi
movq %r14, %rsi
callq 0x2360
addq $0x20, %r14
incl %r15d
jmp 0x6bb7
movq %r12, %rdi
leaq 0x26f8(%rip), %rsi      # 0x92de
callq 0x2340
movq %r12, %rdi
leaq 0x26ec(%rip), %rsi      # 0x92e1
callq 0x2340
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2360
movq %r12, %rdi
leaq 0x26de(%rip), %rsi      # 0x92ed
callq 0x2340
addq $0x60, %rbx
jmp 0x6b68
movq -0x50(%rbp), %rax
movq 0x80(%rax), %r13
leaq -0x48(%rbp), %r15
leaq 0x25db(%rip), %r12      # 0x920e
leaq 0x2439(%rip), %rbx      # 0x9073
leaq 0x78(%r13), %r14
movq -0x50(%rbp), %rax
cmpq 0x88(%rax), %r14
je 0x6d30
leaq 0xb8(%r13), %rsi
movq %r15, %rdi
callq 0x2360
movq %r15, %rdi
movq %r12, %rsi
callq 0x2340
leaq 0x98(%r13), %rsi
movq %r15, %rdi
callq 0x2360
movq %r15, %rdi
leaq 0x2447(%rip), %rsi      # 0x90c9
callq 0x2340
movq %r14, -0x58(%rbp)
movq 0xd8(%r13), %r14
cmpq 0xe0(%r13), %r14
je 0x6cd5
addq $0x20, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2360
movq %r15, %rdi
movq %r12, %rsi
callq 0x2340
addq $-0x20, %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2360
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2340
addq $0x40, %r14
jmp 0x6c92
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
jne 0x6cef
movb $0x29, -0x1(%rax,%rcx)
movq -0x58(%rbp), %r13
jmp 0x6d02
movq %r15, %rdi
leaq 0x2320(%rip), %rsi      # 0x9019
callq 0x2340
movq -0x58(%rbp), %r13
movq %r15, %rdi
leaq 0x25e6(%rip), %rsi      # 0x92f2
callq 0x2340
movq %r15, %rdi
movq %r13, %rsi
callq 0x2360
movq %r15, %rdi
leaq 0x25d0(%rip), %rsi      # 0x92f6
callq 0x2340
jmp 0x6c3a
movq -0x60(%rbp), %r13
leaq 0x40(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2360
leaq 0x24c6(%rip), %rsi      # 0x920e
leaq -0x48(%rbp), %rdi
callq 0x2340
leaq 0x20(%r13), %rsi
leaq -0x48(%rbp), %rdi
callq 0x2360
leaq 0x2364(%rip), %rsi      # 0x90c9
leaq -0x48(%rbp), %rdi
callq 0x2340
movq 0x60(%r13), %rbx
leaq -0x48(%rbp), %r14
leaq 0x2491(%rip), %r15      # 0x920e
leaq 0x22ef(%rip), %r12      # 0x9073
cmpq 0x68(%r13), %rbx
je 0x6dc4
addq $0x20, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2360
movq %r14, %rdi
movq %r15, %rsi
callq 0x2340
addq $-0x20, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2360
movq %r14, %rdi
movq %r12, %rsi
callq 0x2340
addq $0x40, %rbx
jmp 0x6d84
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpb $0x2c, -0x1(%rax,%rcx)
jne 0x6dda
movb $0x29, -0x1(%rax,%rcx)
jmp 0x6dea
leaq 0x2238(%rip), %rsi      # 0x9019
leaq -0x48(%rbp), %rdi
callq 0x2340
leaq 0x2501(%rip), %rsi      # 0x92f2
leaq -0x48(%rbp), %rdi
callq 0x2340
leaq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x2360
leaq 0x24e9(%rip), %rsi      # 0x92f6
leaq -0x48(%rbp), %rdi
callq 0x2340
leaq -0x260(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2180
leaq -0x48(%rbp), %rdi
callq 0x20e0
leaq -0x260(%rbp), %rdi
callq 0x22b0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6e59
jmp 0x6e59
jmp 0x6e59
jmp 0x6e59
jmp 0x6e59
jmp 0x6e59
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x20e0
leaq -0x260(%rbp), %rdi
callq 0x22b0
movq %rbx, %rdi
callq 0x2320
nopl (%rax)