// File: 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:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, 0x20(%rsp)
movq %rdi, %rax
movq %rax, 0x28(%rsp)
movq %rdi, 0x2d0(%rsp)
movq %rsi, 0x2c8(%rsp)
movq 0x2c8(%rsp), %rax
movq %rax, 0x30(%rsp)
movb $0x0, 0x2c7(%rsp)
callq 0xb4e0
movq 0x30(%rsp), %rdi
addq $0x20, %rdi
callq 0xb610
testb $0x1, %al
jne 0x2c615
movq 0x30(%rsp), %rsi
addq $0x20, %rsi
leaq 0xa5954(%rip), %rdx     # 0xd1ef8
leaq 0x2a0(%rsp), %rdi
callq 0x1ba50
jmp 0x2c5b3
movq 0x20(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0xb470
jmp 0x2c5c7
leaq 0x2a0(%rsp), %rdi
callq 0xb6e8
jmp 0x2c615
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cf16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xb6e8
jmp 0x2cf16
movq 0x30(%rsp), %rdi
addq $0x40, %rdi
callq 0xb610
testb $0x1, %al
jne 0x2c68f
movq 0x30(%rsp), %rsi
addq $0x40, %rsi
leaq 0xa58c1(%rip), %rdx     # 0xd1ef8
leaq 0x270(%rsp), %rdi
callq 0x1ba50
jmp 0x2c646
movq 0x20(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0xb470
jmp 0x2c65a
leaq 0x270(%rsp), %rdi
callq 0xb6e8
jmp 0x2c68f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x270(%rsp), %rdi
callq 0xb6e8
jmp 0x2cf16
movq 0x30(%rsp), %rdi
addq $0x80, %rdi
callq 0xb610
testb $0x1, %al
jne 0x2c70c
movq 0x30(%rsp), %rsi
subq $-0x80, %rsi
leaq 0xa5844(%rip), %rdx     # 0xd1ef8
leaq 0x250(%rsp), %rdi
callq 0x1ba50
jmp 0x2c6c3
movq 0x20(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0xb470
jmp 0x2c6d7
leaq 0x250(%rsp), %rdi
callq 0xb6e8
jmp 0x2c70c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x250(%rsp), %rdi
callq 0xb6e8
jmp 0x2cf16
movq 0x30(%rsp), %rdi
addq $0xc8, %rdi
callq 0x2e720
cmpq $0x1, %rax
jbe 0x2c8d7
movq 0x30(%rsp), %rax
addq $0xc8, %rax
movq %rax, 0x248(%rsp)
movq 0x248(%rsp), %rdi
callq 0x2e730
movq %rax, 0x240(%rsp)
movq 0x248(%rsp), %rdi
callq 0x2e1d0
movq %rax, 0x238(%rsp)
leaq 0x240(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x2e180
testb $0x1, %al
jne 0x2c782
jmp 0x2c8c2
leaq 0x240(%rsp), %rdi
callq 0x2e760
movq %rax, %rsi
leaq 0x208(%rsp), %rdi
callq 0x2e780
jmp 0x2c7a1
leaq 0xa5605(%rip), %rsi     # 0xd1dad
leaq 0x208(%rsp), %rdi
callq 0x2e240
movb %al, 0x1f(%rsp)
jmp 0x2c7bb
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0x2c7c8
jmp 0x2c891
leaq 0x228(%rsp), %rdi
callq 0x2e100
movq %rax, %rsi
leaq 0x1c8(%rsp), %rdi
callq 0x2e7c0
jmp 0x2c7e7
leaq 0xa87fa(%rip), %rdx     # 0xd4fe8
leaq 0x1e8(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0xfa60
jmp 0x2c805
movq 0x20(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0xb470
jmp 0x2c819
leaq 0x1e8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
jmp 0x2c891
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2c8b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2c882
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x1e8(%rsp), %rdi
callq 0xb6e8
leaq 0x1c8(%rsp), %rdi
callq 0xb6e8
jmp 0x2c8b0
leaq 0x208(%rsp), %rdi
callq 0x2e7f0
leaq 0x240(%rsp), %rdi
callq 0x2e820
jmp 0x2c764
leaq 0x208(%rsp), %rdi
callq 0x2e7f0
jmp 0x2cf16
movq 0x20(%rsp), %rdi
leaq 0xa562a(%rip), %rsi     # 0xd1ef8
callq 0xb360
jmp 0x2c8d5
jmp 0x2c8d7
movq 0x30(%rsp), %rdi
addq $0x60, %rdi
callq 0xb610
testb $0x1, %al
jne 0x2c951
movq 0x30(%rsp), %rsi
addq $0x60, %rsi
leaq 0xa55ff(%rip), %rdx     # 0xd1ef8
leaq 0x1a8(%rsp), %rdi
callq 0x1ba50
jmp 0x2c908
movq 0x20(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0xb470
jmp 0x2c91c
leaq 0x1a8(%rsp), %rdi
callq 0xb6e8
jmp 0x2c951
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0xb6e8
jmp 0x2cf16
movq 0x30(%rsp), %rax
addq $0xc8, %rax
movq %rax, 0x1a0(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x2e730
movq %rax, 0x198(%rsp)
movq 0x1a0(%rsp), %rdi
callq 0x2e1d0
movq %rax, 0x190(%rsp)
leaq 0x198(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x2e180
testb $0x1, %al
jne 0x2c9ac
jmp 0x2ceda
leaq 0x198(%rsp), %rdi
callq 0x2e760
movq %rax, %rsi
leaq 0x160(%rsp), %rdi
callq 0x2e780
jmp 0x2c9cb
leaq 0x180(%rsp), %rdi
callq 0x2e100
movq %rax, %rsi
leaq 0x140(%rsp), %rdi
callq 0x2e7c0
jmp 0x2c9ea
movq 0x20(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0xb470
jmp 0x2c9fe
leaq 0x140(%rsp), %rdi
callq 0xb6e8
leaq 0x180(%rsp), %rdi
callq 0x2e100
movq %rax, %rsi
leaq 0x120(%rsp), %rdi
callq 0x2e850
jmp 0x2ca2a
leaq 0x120(%rsp), %rdi
callq 0xb2a0
cmpq $0x2, %rax
jae 0x2caad
movq 0x20(%rsp), %rdi
leaq 0xa5497(%rip), %rsi     # 0xd1ee0
callq 0xb360
jmp 0x2ca50
jmp 0x2ce92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cecb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x140(%rsp), %rdi
callq 0xb6e8
jmp 0x2cecb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cebe
leaq 0x180(%rsp), %rdi
callq 0x2e100
movq %rax, %rdi
movb $0x0, 0xfe(%rsp)
movb $0x0, 0xfd(%rsp)
callq 0x2e880
movb %al, 0x1e(%rsp)
jmp 0x2cad8
movb 0x1e(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x1d(%rsp)
jne 0x2caec
jmp 0x2cb91
xorl %eax, %eax
movl %eax, %esi
leaq 0x120(%rsp), %rdi
callq 0xb6d0
movq %rax, 0x10(%rsp)
jmp 0x2cb04
movq 0x10(%rsp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x7b, %ecx
movb %al, 0x1d(%rsp)
je 0x2cb91
leaq 0xff(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xb690
movq 0x8(%rsp), %rdx
movb $0x1, 0xfe(%rsp)
leaq 0xa93e1(%rip), %rsi     # 0xd5f1e
leaq 0x100(%rsp), %rdi
callq 0xb4c0
jmp 0x2cb4c
movb $0x1, 0xfd(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x100(%rsp), %rsi
xorl %edx, %edx
callq 0xa80f0
movl %eax, 0x4(%rsp)
jmp 0x2cb71
leaq 0x120(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x4(%rsp), %eax
subl $0x2, %ecx
cmpl %ecx, %eax
sete %al
movb %al, 0x1d(%rsp)
movb 0x1d(%rsp), %al
movb %al, 0x3(%rsp)
testb $0x1, 0xfd(%rsp)
jne 0x2cba5
jmp 0x2cbb2
leaq 0x100(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0xfe(%rsp)
jne 0x2cbbe
jmp 0x2cbcb
leaq 0xff(%rsp), %rdi
callq 0xb3f0
movb 0x3(%rsp), %al
testb $0x1, %al
jne 0x2cbd8
jmp 0x2cc7d
leaq 0xa85af(%rip), %rsi     # 0xd518e
leaq 0xd8(%rsp), %rdi
leaq 0x120(%rsp), %rdx
callq 0xfab0
jmp 0x2cbf6
leaq 0x120(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xb450
leaq 0xd8(%rsp), %rdi
callq 0xb6e8
jmp 0x2cc7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cc5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
testb $0x1, 0xfd(%rsp)
jne 0x2cc50
jmp 0x2cc5d
leaq 0x100(%rsp), %rdi
callq 0xb6e8
jmp 0x2cc5f
testb $0x1, 0xfe(%rsp)
jne 0x2cc6b
jmp 0x2cc78
leaq 0xff(%rsp), %rdi
callq 0xb3f0
jmp 0x2cebe
movq 0x20(%rsp), %rdi
leaq 0xa5146(%rip), %rsi     # 0xd1dcf
callq 0xb360
jmp 0x2cc90
leaq 0x160(%rsp), %rdi
addq $0x20, %rdi
callq 0x2e100
movq %rax, %rdi
addq $0x30, %rdi
callq 0xb610
testb $0x1, %al
jne 0x2cdb4
leaq 0x180(%rsp), %rdi
callq 0x2e100
movq %rax, %rsi
addq $0x30, %rsi
leaq 0xa5228(%rip), %rdx     # 0xd1ef8
leaq 0x98(%rsp), %rdi
callq 0x1ba50
jmp 0x2ccdf
movq 0x30(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0xb1a0
jmp 0x2ccf0
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
movl $0x1, %ecx
callq 0xa8440
jmp 0x2cd11
movq 0x20(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xb470
jmp 0x2cd25
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
leaq 0x78(%rsp), %rdi
callq 0xb6e8
leaq 0x98(%rsp), %rdi
callq 0xb6e8
jmp 0x2cdb4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cda2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2cd98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
leaq 0x78(%rsp), %rdi
callq 0xb6e8
leaq 0x98(%rsp), %rdi
callq 0xb6e8
jmp 0x2cebe
movq 0x30(%rsp), %rsi
leaq 0x38(%rsp), %rdi
callq 0xb1a0
jmp 0x2cdc5
leaq 0x58(%rsp), %rdi
leaq 0x120(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movl $0x1, %ecx
callq 0xa8440
jmp 0x2cde3
movq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xb470
jmp 0x2cdf4
leaq 0x58(%rsp), %rdi
callq 0xb6e8
leaq 0x38(%rsp), %rdi
callq 0xb6e8
movq 0x20(%rsp), %rdi
callq 0xb610
testb $0x1, %al
jne 0x2ce7d
movq 0x20(%rsp), %rdi
callq 0xb2c0
movsbl (%rax), %eax
cmpl $0xa, %eax
je 0x2ce7d
movq 0x20(%rsp), %rdi
leaq 0xa81b4(%rip), %rsi     # 0xd4fe8
callq 0xb360
jmp 0x2ce3b
jmp 0x2ce7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x2ce71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xb6e8
leaq 0x38(%rsp), %rdi
callq 0xb6e8
jmp 0x2cebe
movq 0x20(%rsp), %rdi
leaq 0xa506d(%rip), %rsi     # 0xd1ef6
callq 0xb360
jmp 0x2ce90
jmp 0x2ce92
leaq 0x120(%rsp), %rdi
callq 0xb6e8
leaq 0x160(%rsp), %rdi
callq 0x2e7f0
leaq 0x198(%rsp), %rdi
callq 0x2e820
jmp 0x2c98e
leaq 0x120(%rsp), %rdi
callq 0xb6e8
leaq 0x160(%rsp), %rdi
callq 0x2e7f0
jmp 0x2cf16
movq 0x20(%rsp), %rdi
leaq 0xa5014(%rip), %rsi     # 0xd1efa
callq 0xb360
jmp 0x2ceed
movb $0x1, 0x2c7(%rsp)
testb $0x1, 0x2c7(%rsp)
jne 0x2cf09
movq 0x20(%rsp), %rdi
callq 0xb6e8
movq 0x28(%rsp), %rax
addq $0x2d8, %rsp            # imm = 0x2D8
retq
movq 0x20(%rsp), %rdi
callq 0xb6e8
movq 0x298(%rsp), %rdi
callq 0xb680
nopl (%rax)