// File: 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
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x310(%rbp)
movq 0x30(%rax), %rdi
callq 0x3100
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
addl $0x5, %eax
movslq %eax, %rdi
callq 0x3310
movq %rax, %rcx
movq -0x310(%rbp), %rax
movq %rcx, -0x18(%rbp)
movq -0x18(%rbp), %rcx
movb $0x0, (%rcx)
movq -0x18(%rbp), %rdi
movq 0x30(%rax), %rsi
callq 0x3410
movq -0x18(%rbp), %rdi
leaq 0x5e58(%rip), %rsi      # 0x162a9
callq 0x3410
movq -0x18(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x10, %edx
callq 0x32b0
leaq -0x238(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x3360
movq -0x308(%rbp), %rdi
leaq 0x5e23(%rip), %rsi      # 0x162af
callq 0x3420
jmp 0x10493
movq -0x310(%rbp), %rdi
addq $0x80, %rdi
callq 0xd620
movq -0x310(%rbp), %rdi
movq %rax, -0x250(%rbp)
addq $0x98, %rdi
callq 0x10bd0
movq %rax, -0x258(%rbp)
movq -0x310(%rbp), %rdi
addq $0x98, %rdi
callq 0x10c40
movq %rax, -0x268(%rbp)
leaq -0x268(%rbp), %rdi
movl $0x1, %esi
callq 0x10c70
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x10c00
testb $0x1, %al
jne 0x10515
jmp 0x106d1
leaq 0x5db2(%rip), %rsi      # 0x162ce
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1052a
leaq -0x258(%rbp), %rdi
callq 0x10cb0
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x1054b
leaq -0x258(%rbp), %rdi
callq 0x10cb0
cmpl $0x0, 0x40(%rax)
jle 0x10659
leaq 0x5b90(%rip), %rsi      # 0x160f8
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10576
leaq -0x258(%rbp), %rdi
callq 0x10cb0
movq %rax, %rdi
addq $0x20, %rdi
addq $0x28, %rdi
callq 0x74f0
movq %rax, -0x270(%rbp)
movl $0x0, -0x274(%rbp)
movl -0x274(%rbp), %eax
movl %eax, -0x314(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x10cb0
movq %rax, %rcx
movl -0x314(%rbp), %eax
cmpl 0x40(%rcx), %eax
jge 0x10657
leaq 0x5d01(%rip), %rsi      # 0x162d5
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x105e2
leaq -0x270(%rbp), %rdi
callq 0x7590
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x105ff
leaq -0x270(%rbp), %rdi
xorl %esi, %esi
callq 0x7550
movq %rax, -0x280(%rbp)
movl -0x274(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x274(%rbp)
jmp 0x105a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x3170
leaq -0x218(%rbp), %rdi
callq 0x3380
jmp 0x10bc0
jmp 0x10659
leaq 0x5c7d(%rip), %rsi      # 0x162dd
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1066e
leaq 0x5c6b(%rip), %rsi      # 0x162e0
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10683
leaq -0x258(%rbp), %rdi
callq 0x10cb0
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x106a0
leaq 0x5c45(%rip), %rsi      # 0x162ec
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x106b5
jmp 0x106b7
leaq -0x258(%rbp), %rdi
xorl %esi, %esi
callq 0x10cd0
movq %rax, -0x288(%rbp)
jmp 0x104c7
movq -0x310(%rbp), %rdi
addq $0x80, %rdi
callq 0xd620
movq %rax, -0x298(%rbp)
leaq -0x298(%rbp), %rdi
movl $0x1, %esi
callq 0xd650
movq %rax, -0x290(%rbp)
movq -0x310(%rbp), %rdi
addq $0x80, %rdi
callq 0x10d50
movq %rax, -0x2a0(%rbp)
leaq -0x290(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x10d10
testb $0x1, %al
jne 0x10739
jmp 0x1096b
leaq -0x290(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x1075a
leaq 0x5abd(%rip), %rsi      # 0x1621e
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1076f
leaq -0x290(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10790
leaq 0x5942(%rip), %rsi      # 0x160d9
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x107a5
leaq -0x290(%rbp), %rdi
callq 0xd730
movq %rax, %rdi
addq $0x20, %rdi
addq $0x40, %rdi
callq 0x7690
movq %rax, -0x2a8(%rbp)
leaq -0x290(%rbp), %rdi
callq 0xd730
movq %rax, %rdi
addq $0x20, %rdi
addq $0x40, %rdi
callq 0x7700
movq %rax, -0x2b0(%rbp)
leaq -0x2a8(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x76c0
testb $0x1, %al
jne 0x10804
jmp 0x1087f
leaq -0x2a8(%rbp), %rdi
callq 0x7730
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10825
leaq 0x59f2(%rip), %rsi      # 0x1621e
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1083a
leaq -0x2a8(%rbp), %rdi
callq 0x7730
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10857
leaq 0x5825(%rip), %rsi      # 0x16083
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1086c
jmp 0x1086e
leaq -0x2a8(%rbp), %rdi
callq 0x7750
jmp 0x107c8
leaq -0x238(%rbp), %rdi
callq 0x3140
movq %rax, -0x2c0(%rbp)
leaq -0x2c0(%rbp), %rdi
movl $0x1, %esi
callq 0x10d80
movq %rax, -0x2b8(%rbp)
leaq -0x2b8(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x108fa
leaq -0x238(%rbp), %rdi
callq 0x3140
movq %rax, -0x2d0(%rbp)
leaq -0x2d0(%rbp), %rdi
movl $0x1, %esi
callq 0x10d80
movq %rax, -0x2c8(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x6f70
movb $0x29, (%rax)
jmp 0x10911
leaq 0x5728(%rip), %rsi      # 0x16029
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x1090f
jmp 0x10911
leaq 0x59d9(%rip), %rsi      # 0x162f1
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10926
leaq -0x290(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10943
leaq 0x59ab(%rip), %rsi      # 0x162f5
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10958
jmp 0x1095a
leaq -0x290(%rbp), %rdi
callq 0xd770
jmp 0x10703
leaq -0x250(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
addq $0x40, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x1098c
leaq 0x588b(%rip), %rsi      # 0x1621e
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x109a1
leaq -0x250(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x109c2
leaq 0x5710(%rip), %rsi      # 0x160d9
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x109d7
leaq -0x250(%rbp), %rdi
callq 0xd730
movq %rax, %rdi
addq $0x20, %rdi
addq $0x40, %rdi
callq 0x7690
movq %rax, -0x2d8(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xd730
movq %rax, %rdi
addq $0x20, %rdi
addq $0x40, %rdi
callq 0x7700
movq %rax, -0x2e0(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x76c0
testb $0x1, %al
jne 0x10a36
jmp 0x10ab1
leaq -0x2d8(%rbp), %rdi
callq 0x7730
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10a57
leaq 0x57c0(%rip), %rsi      # 0x1621e
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10a6c
leaq -0x2d8(%rbp), %rdi
callq 0x7730
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10a89
leaq 0x55f3(%rip), %rsi      # 0x16083
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10a9e
jmp 0x10aa0
leaq -0x2d8(%rbp), %rdi
callq 0x7750
jmp 0x109fa
leaq -0x238(%rbp), %rdi
callq 0x3140
movq %rax, -0x2f0(%rbp)
leaq -0x2f0(%rbp), %rdi
movl $0x1, %esi
callq 0x10d80
movq %rax, -0x2e8(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x6f70
movsbl (%rax), %eax
cmpl $0x2c, %eax
jne 0x10b2c
leaq -0x238(%rbp), %rdi
callq 0x3140
movq %rax, -0x300(%rbp)
leaq -0x300(%rbp), %rdi
movl $0x1, %esi
callq 0x10d80
movq %rax, -0x2f8(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x6f70
movb $0x29, (%rax)
jmp 0x10b43
leaq 0x54f6(%rip), %rsi      # 0x16029
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10b41
jmp 0x10b43
leaq 0x57a7(%rip), %rsi      # 0x162f1
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10b58
leaq -0x250(%rbp), %rdi
callq 0xd730
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
callq 0x3430
jmp 0x10b75
leaq 0x5779(%rip), %rsi      # 0x162f5
leaq -0x238(%rbp), %rdi
callq 0x3420
jmp 0x10b8a
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x31f0
jmp 0x10b9f
leaq -0x238(%rbp), %rdi
callq 0x3170
leaq -0x218(%rbp), %rdi
callq 0x3380
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x33f0
nopl (%rax)