// File: menhits[P]phplus/src/CppProgram.cpp
// Function: CppProgram::addFunc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void CppProgram::addFunc(const string& name, vector<std::pair<string, string>> args, string returnType, string contents)
{
	if (hasFunc(name))
	{
		throw PhplusError("called CppProgram::addFunc with function name '"+name+"', which already exists", INTERNAL_ERROR);
	}
	
	globalNames->addPp(name, name);
	
	string cppName=globalNames->getCpp(name);
	
	string prototype;
	
	prototype+=returnType;
	
	prototype+=" "+cppName+"(";
	
	for (int i=0; i<int(args.size()); i++)
	{
		if (i)
			prototype+=", ";
		
		prototype+=args[i].first;
		
		prototype+=" ";
		
		prototype+=args[i].second;
	}
	
	prototype+=")";
	
	auto func=CppFunc(new CppFuncBase(prototype, globalNames->makeChild(), (returnType!="" && returnType!="void")));
	funcs[name]=func;
	func->code(contents);
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x58(%rsp)
movq %rdi, 0x1c0(%rsp)
movq %rsi, 0x1b8(%rsp)
movq %rdx, 0x1b0(%rsp)
movq %rcx, 0x1a8(%rsp)
movq %r8, 0x1a0(%rsp)
movq 0x1c0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movq 0x1b8(%rsp), %rsi
callq 0x2a8a0
testb $0x1, %al
jne 0x2a961
jmp 0x2aa8f
movb $0x1, 0x13f(%rsp)
movl $0x38, %edi
callq 0xb1f0
movq %rax, 0x40(%rsp)
movq 0x1b8(%rsp), %rdx
leaq 0xa7490(%rip), %rsi     # 0xd1e17
leaq 0x160(%rsp), %rdi
callq 0xfab0
jmp 0x2a996
leaq 0xa7023(%rip), %rdx     # 0xd19c0
leaq 0x180(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0xfa60
jmp 0x2a9b4
xorl %eax, %eax
movl %eax, %esi
leaq 0x140(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xfbe0
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rcx
leaq 0x180(%rsp), %rsi
movl $0x3, %edx
callq 0x35600
jmp 0x2a9e8
movq 0x40(%rsp), %rdi
movb $0x0, 0x13f(%rsp)
leaq 0xeabcc(%rip), %rsi     # 0x1155c8
leaq -0x10393(%rip), %rdx    # 0x1a670
callq 0xb640
jmp 0x2aec7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2aa74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2aa67
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x140(%rsp), %rdi
callq 0xfc00
leaq 0x180(%rsp), %rdi
callq 0xb6e8
leaq 0x160(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0x13f(%rsp)
jne 0x2aa80
jmp 0x2aa8a
movq 0x40(%rsp), %rdi
callq 0xb2d0
jmp 0x2aeba
movq 0x60(%rsp), %rdi
addq $0xf8, %rdi
movq %rdi, 0x28(%rsp)
callq 0x2d6b0
movq %rax, %rdi
movq 0x1b8(%rsp), %rdx
movq %rdx, %rsi
callq 0x232f0
movq 0x28(%rsp), %rdi
callq 0x2d6b0
movq %rax, %rsi
movq 0x1b8(%rsp), %rdx
leaq 0x118(%rsp), %rdi
callq 0x23eb0
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xb4e0
movq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xb470
jmp 0x2aafd
leaq 0xa6f68(%rip), %rsi     # 0xd1a6c
leaq 0xb8(%rsp), %rdi
leaq 0x118(%rsp), %rdx
callq 0xfab0
jmp 0x2ab1b
leaq 0xac6c6(%rip), %rdx     # 0xd71e8
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0xfa60
jmp 0x2ab39
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xb470
jmp 0x2ab50
leaq 0xd8(%rsp), %rdi
callq 0xb6e8
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
movl $0x0, 0xb4(%rsp)
movq 0x48(%rsp), %rdi
movl 0xb4(%rsp), %eax
movl %eax, 0x24(%rsp)
callq 0x2e200
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl %ecx, %eax
jge 0x2ac97
cmpl $0x0, 0xb4(%rsp)
je 0x2ac1d
leaq 0xaab40(%rip), %rsi     # 0xd56ea
leaq 0xf8(%rsp), %rdi
callq 0xb360
jmp 0x2abb9
jmp 0x2ac1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2aea0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2ac0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0xb6e8
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
jmp 0x2aea0
movq 0x48(%rsp), %rdi
movslq 0xb4(%rsp), %rsi
callq 0x2e220
movq %rax, %rsi
leaq 0xf8(%rsp), %rdi
callq 0xb470
jmp 0x2ac41
leaq 0xa6e24(%rip), %rsi     # 0xd1a6c
leaq 0xf8(%rsp), %rdi
callq 0xb360
jmp 0x2ac57
movq 0x48(%rsp), %rdi
movslq 0xb4(%rsp), %rsi
callq 0x2e220
movq %rax, %rsi
addq $0x20, %rsi
leaq 0xf8(%rsp), %rdi
callq 0xb470
jmp 0x2ac7f
jmp 0x2ac81
movl 0xb4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb4(%rsp)
jmp 0x2ab75
leaq 0xab053(%rip), %rsi     # 0xd5cf1
leaq 0xf8(%rsp), %rdi
callq 0xb360
jmp 0x2acad
movl $0xb0, %edi
callq 0xb390
movq %rax, 0x18(%rsp)
jmp 0x2acbe
movb $0x1, 0x6f(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xb1a0
jmp 0x2acda
movq 0x60(%rsp), %rdi
addq $0xf8, %rdi
callq 0x2d6b0
movq %rax, %rsi
leaq 0x70(%rsp), %rdi
callq 0x23210
jmp 0x2acfa
movq 0x50(%rsp), %rdi
leaq 0xa6d19(%rip), %rsi     # 0xd1a1f
callq 0x2e240
movb %al, 0x17(%rsp)
jmp 0x2ad11
movb 0x17(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x16(%rsp)
jne 0x2ad22
jmp 0x2ad43
movq 0x50(%rsp), %rdi
leaq 0xaae61(%rip), %rsi     # 0xd5b8f
callq 0x2e240
movb %al, 0x15(%rsp)
jmp 0x2ad39
movb 0x15(%rsp), %al
movb %al, 0x16(%rsp)
jmp 0x2ad43
movq 0x18(%rsp), %rdi
movb 0x16(%rsp), %al
movzbl %al, %ecx
andl $0x1, %ecx
leaq 0x80(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x24090
jmp 0x2ad66
movq 0x18(%rsp), %rsi
movb $0x0, 0x6f(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2e270
jmp 0x2ad7f
leaq 0x70(%rsp), %rdi
callq 0x2d6c0
leaq 0x80(%rsp), %rdi
callq 0xb6e8
movq 0x60(%rsp), %rdi
addq $0xc8, %rdi
movq 0x1b8(%rsp), %rsi
callq 0x2e2a0
movq %rax, 0x8(%rsp)
jmp 0x2adb6
movq 0x8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movq %rsi, (%rsp)
callq 0x2e390
movq (%rsp), %rdi
callq 0x2e100
movq 0x58(%rsp), %rsi
movq %rax, %rdi
callq 0x24210
jmp 0x2ade4
leaq 0xa0(%rsp), %rdi
callq 0x2dc60
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2ae6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x2ae5d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x2d6c0
leaq 0x80(%rsp), %rdi
callq 0xb6e8
testb $0x1, 0x6f(%rsp)
jne 0x2ae73
jmp 0x2ae7d
movq 0x18(%rsp), %rdi
callq 0xb350
jmp 0x2aea0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2dc60
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
movq 0x158(%rsp), %rdi
callq 0xb680
nopw (%rax,%rax)