// File: /workspace/github_cpp_makefile_star2_O2/menhits[P]phplus/src/CppProgram.cpp
// Function: CppProgram::getCppCode[abi:cxx11]()
string CppProgram::getCppCode()
{
	string out;
	
	if (!globalTopCode.empty())
		out+=globalTopCode+"\n";
	
	if (!globalIncludesCode.empty())
		out+=globalIncludesCode+"\n";
	
	if (!globalTypesCode.empty())
		out+=globalTypesCode+"\n";
	
	if (funcs.size()>1)
	{
		for (auto i: funcs)
		{
			if (i.first!="main")
				out+=i.second->getPrototype()+";\n";
		}
		
		out+="\n";
	}
	
	if (!globalVarCode.empty())
		out+=globalVarCode+"\n";
	
	for (auto i: funcs)
	{
		out+=i.second->getPrototype();
		
		string funcSrc=i.second->getSource();
		
		if (funcSrc.size()<2)
		{
			out+="\n{\n\t// empty function\n}\n\n";
		}
		else
		{
			if (i.second->getIfReturnsVal() && funcSrc[0]!='{' && searchInString(funcSrc, ";")==int(funcSrc.size())-2)
				funcSrc="return "+funcSrc;
			out+="\n{\n";
			if (!i.second->varDeclareSource.empty())
				out+=indentString(i.second->varDeclareSource+"\n", indent);
			out+=indentString(funcSrc, indent);
			if (!out.empty() && out.back()!='\n')
				out+=";\n";
			//if (i.first=="main")
			//	out+=indentString("return 0;\n", indent);
			//if (out.substr(out.size()-2, 2)!=";\n")
			//	out+=";\n";
			out+="}\n\n";
		}
	}
	
	out+=
"int main(int argcIn, char** argvIn)\n\
{\n\
	argc = argcIn;\n\
	argv = argvIn;\n\
	if (argc >= 2 && strcmp(argv[1], \"--running-from-Phplus\") == 0)\n\
	{\n\
		argc -= 2;\n\
		if (argc == 0)\n\
			argv = 0;\n\
		else\n\
			argv += 2;\n\
	}\n\
	_main();\n\
	return 0;\n\
}\n";
	
	return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rsi, %r14
movb $0x0, 0x10(%rdi)
cmpq $0x0, 0x28(%rsi)
je 0x17ccc
leaq 0x20(%r14), %rsi
leaq 0x3d24d(%rip), %rdx     # 0x54ef8
leaq 0x8(%rsp), %rdi
callq 0x11fb8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xa540
leaq 0x8(%rsp), %rdi
callq 0xa558
cmpq $0x0, 0x48(%r14)
je 0x17cff
leaq 0x40(%r14), %rsi
leaq 0x3d21a(%rip), %rdx     # 0x54ef8
leaq 0x8(%rsp), %rdi
callq 0x11fb8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xa540
leaq 0x8(%rsp), %rdi
callq 0xa558
cmpq $0x0, 0x88(%r14)
je 0x17d38
leaq 0x80(%r14), %rsi
leaq 0x3d1e1(%rip), %rdx     # 0x54ef8
leaq 0x8(%rsp), %rdi
callq 0x11fb8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xa540
leaq 0x8(%rsp), %rdi
callq 0xa558
cmpq $0x2, 0xf0(%r14)
movq %r14, 0x38(%rsp)
movq %rbx, (%rsp)
jb 0x17dff
movq 0xe0(%r14), %r15
leaq 0xd0(%r14), %r12
leaq 0x8(%rsp), %r14
leaq 0x3d044(%rip), %rbx     # 0x54dad
leaq 0x68(%rsp), %r13
leaq 0x40(%rsp), %rbp
cmpq %r12, %r15
je 0x17de7
leaq 0x20(%r15), %rsi
movq %r14, %rdi
callq 0x1859a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x184e9
testb %al, %al
je 0x17dd2
movq 0x28(%rsp), %rsi
addq $0x70, %rsi
movq %r13, %rdi
callq 0xa3b0
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x3f9e2(%rip), %rdx     # 0x57793
callq 0xc882
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0xa540
movq %rbp, %rdi
callq 0xa558
movq %r13, %rdi
callq 0xa558
movq %r14, %rdi
callq 0x185c4
movq %r15, %rdi
callq 0xa210
movq %rax, %r15
jmp 0x17d73
leaq 0x3d10a(%rip), %rsi     # 0x54ef8
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0xa520
movq 0x38(%rsp), %r14
cmpq $0x0, 0x68(%r14)
je 0x17e32
leaq 0x60(%r14), %rsi
leaq 0x3d0e7(%rip), %rdx     # 0x54ef8
leaq 0x8(%rsp), %rdi
callq 0x11fb8
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0xa540
leaq 0x8(%rsp), %rdi
callq 0xa558
movq 0xe0(%r14), %rax
leaq 0xd0(%r14), %r15
leaq 0x68(%rsp), %rbp
leaq 0xa8(%rsp), %r13
leaq 0xc8(%rsp), %r12
cmpq %r15, %rax
je 0x18074
movq %rax, 0x60(%rsp)
leaq 0x20(%rax), %rsi
leaq 0x8(%rsp), %rdi
callq 0x1859a
movq 0x28(%rsp), %rsi
addq $0x70, %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3b0
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0xa540
movq %rbx, %rdi
callq 0xa558
movq 0x28(%rsp), %rsi
addq $0x50, %rsi
movq %rbx, %rdi
callq 0xa3b0
cmpq $0x2, 0x48(%rsp)
leaq 0x3d027(%rip), %rsi     # 0x54ee0
jb 0x18048
movq 0x28(%rsp), %rax
cmpb $0x1, 0x90(%rax)
jne 0x17f4b
movq 0x40(%rsp), %rax
cmpb $0x7b, (%rax)
je 0x17f4b
movq %rbp, %rdi
leaq 0x40801(%rip), %rsi     # 0x586e2
leaq 0x88(%rsp), %rdx
callq 0xa150
movq %r15, %rbx
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
callq 0x41940
movl %eax, %r14d
movl 0x48(%rsp), %r15d
addl $-0x2, %r15d
movq %rbp, %rdi
callq 0xa558
cmpl %r15d, %r14d
movq 0x38(%rsp), %r14
movq %rbx, %r15
jne 0x17f4b
movq %rbp, %rdi
leaq 0x3fa0e(%rip), %rsi     # 0x57939
leaq 0x40(%rsp), %rbx
movq %rbx, %rdx
callq 0xc8a1
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa350
movq %rbp, %rdi
callq 0xa558
movq (%rsp), %rdi
leaq 0x3ce79(%rip), %rsi     # 0x54dcf
callq 0xa520
movq 0x28(%rsp), %rsi
cmpq $0x0, 0x38(%rsi)
je 0x17fcc
addq $0x30, %rsi
leaq 0x88(%rsp), %rdi
leaq 0x3cf7e(%rip), %rdx     # 0x54ef8
callq 0x11fb8
movq %r12, %rbx
movq %r12, %rdi
movq %r14, %rsi
callq 0xa3b0
movq %rbp, %rdi
leaq 0x88(%rsp), %rsi
movq %rbx, %rdx
pushq $0x1
popq %rcx
callq 0x41afa
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0xa540
movq %rbp, %rdi
callq 0xa558
movq %r12, %rdi
callq 0xa558
leaq 0x88(%rsp), %rdi
callq 0xa558
movq %r13, %rbx
movq %r13, %rdi
movq %r14, %rsi
callq 0xa3b0
movq %rbp, %rdi
leaq 0x40(%rsp), %rsi
movq %rbx, %rdx
pushq $0x1
popq %rcx
callq 0x41afa
movq (%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xa540
movq %rbp, %rdi
callq 0xa558
movq %r13, %rdi
callq 0xa558
movq 0x8(%rbx), %rax
leaq 0x3cedf(%rip), %rsi     # 0x54ef6
testq %rax, %rax
je 0x18048
movq (%rsp), %rcx
movq (%rcx), %rcx
cmpb $0xa, -0x1(%rcx,%rax)
leaq 0x3cec7(%rip), %rsi     # 0x54ef6
je 0x18048
movq (%rsp), %rdi
leaq 0x3f757(%rip), %rsi     # 0x57793
callq 0xa520
leaq 0x3ceae(%rip), %rsi     # 0x54ef6
movq (%rsp), %rdi
callq 0xa520
leaq 0x40(%rsp), %rdi
callq 0xa558
leaq 0x8(%rsp), %rdi
callq 0x185c4
movq 0x60(%rsp), %rdi
callq 0xa210
jmp 0x17e55
leaq 0x3ce7f(%rip), %rsi     # 0x54efa
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0xa520
movq %rbx, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x180a8
jmp 0x180bc
jmp 0x180a8
jmp 0x180bc
jmp 0x180a8
jmp 0x180bc
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0xa558
jmp 0x18187
jmp 0x180bc
movq %rax, %r14
jmp 0x18187
jmp 0x1816c
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0x18151
jmp 0x1816c
movq %rax, %r14
jmp 0x180ef
movq %rax, %r14
jmp 0x180f9
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xa558
leaq 0x68(%rsp), %rdi
callq 0xa558
leaq 0x8(%rsp), %rdi
callq 0x185c4
jmp 0x18161
jmp 0x1816c
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0xa558
jmp 0x18119
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
callq 0xa558
jmp 0x1812b
movq %rax, %r14
leaq 0x88(%rsp), %rdi
jmp 0x18151
jmp 0x1816c
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0xa558
jmp 0x18149
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0xa558
jmp 0x1816f
jmp 0x1815e
jmp 0x1816c
jmp 0x18167
movq %rax, %r14
movq (%rsp), %rbx
jmp 0x18187
movq %rax, %r14
jmp 0x18179
movq %rax, %r14
leaq 0x40(%rsp), %rdi
callq 0xa558
movq (%rsp), %rbx
leaq 0x8(%rsp), %rdi
callq 0x185c4
movq %rbx, %rdi
callq 0xa558
movq %r14, %rdi
callq 0xa500
nop