// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r8, (%rsp)
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
callq 0x17166
testb %al, %al
jne 0x173ea
movq 0xf8(%r14), %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x13de2
movq 0xf8(%r14), %rsi
leaq 0x70(%rsp), %rdi
movq %rbx, %rdx
callq 0x1439e
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0xa540
leaq 0x3d86d(%rip), %rsi     # 0x54a6c
leaq 0xc8(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0xc8a1
leaq 0x42788(%rip), %rdx     # 0x599a0
leaq 0x30(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xc882
movq %r15, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xa540
leaq 0x30(%rsp), %rdi
callq 0xa558
leaq 0xc8(%rsp), %rdi
callq 0xa558
xorl %r14d, %r14d
leaq 0x50(%rsp), %rbp
leaq 0x3d7fe(%rip), %rbx     # 0x54a6c
leaq 0x40c20(%rip), %r12     # 0x57e95
xorl %r15d, %r15d
movq (%r13), %rsi
movq 0x8(%r13), %rax
subq %rsi, %rax
shrq $0x6, %rax
cltq
cmpq %rax, %r15
jge 0x172d5
testq %r14, %r14
je 0x172a2
movq %rbp, %rdi
movq %r12, %rsi
callq 0xa520
movq (%r13), %rsi
addq %r14, %rsi
movq %rbp, %rdi
callq 0xa540
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xa520
movq (%r13), %rax
leaq (%rax,%r14), %rsi
addq $0x20, %rsi
movq %rbp, %rdi
callq 0xa540
incq %r15
addq $0x40, %r14
jmp 0x17278
leaq 0x411bd(%rip), %rsi     # 0x58499
leaq 0x50(%rsp), %rdi
callq 0xa520
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
movl $0xb0, %edi
callq 0xa2c0
movq %rax, %r13
leaq 0xa8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xa3b0
movq 0xf8(%r14), %rsi
leaq 0x20(%rsp), %rdi
callq 0x13d84
leaq 0x3d6f3(%rip), %rsi     # 0x54a1f
movq %r15, %rdi
callq 0x184e9
testb %al, %al
je 0x17349
leaq 0x40ff8(%rip), %rsi     # 0x58337
movq %r15, %rdi
callq 0x184e9
jmp 0x1734b
xorl %eax, %eax
movb $0x1, %bpl
movzbl %al, %ecx
leaq 0xa8(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r13, %rdi
callq 0x14498
xorl %ebp, %ebp
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x19472
leaq 0x28(%rsp), %rdi
callq 0xc984
leaq 0xa8(%rsp), %rdi
callq 0xa558
addq $0xc8, %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x184f4
leaq 0x30(%rsp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x186e8
movq (%rbx), %rdi
movq (%rsp), %rsi
callq 0x145a2
leaq 0x38(%rsp), %rdi
callq 0xc984
leaq 0x50(%rsp), %rdi
callq 0xa558
leaq 0x70(%rsp), %rdi
callq 0xa558
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x38
popq %rdi
callq 0xa1b0
movq %rax, %r15
leaq 0x3da1b(%rip), %rsi     # 0x54e17
leaq 0x70(%rsp), %rdi
movq %rbx, %rdx
callq 0xc8a1
leaq 0x3d5b0(%rip), %rdx     # 0x549c0
leaq 0xe8(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xc882
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rcx
movaps %xmm0, (%rcx)
movb $0x1, %bpl
leaq 0xe8(%rsp), %rsi
pushq $0x3
popq %rdx
movq %r15, %rdi
callq 0x19f06
xorl %ebp, %ebp
leaq 0x60149(%rip), %rsi     # 0x77598
leaq -0x5dc4(%rip), %rdx     # 0x11692
movq %r15, %rdi
callq 0xa4e0
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xc984
leaq 0xe8(%rsp), %rdi
callq 0xa558
jmp 0x17483
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x70(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
jne 0x1749a
jmp 0x1752a
movq %rax, %rbx
movq %r15, %rdi
callq 0xa230
jmp 0x1752a
movq %rax, %rbx
movb $0x1, %bpl
jmp 0x174f5
movq %rax, %rbx
jmp 0x17507
jmp 0x17513
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xa558
jmp 0x174c8
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xa558
jmp 0x17516
jmp 0x17513
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xc984
jmp 0x17516
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xc984
leaq 0xa8(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
je 0x17516
movq %r13, %rdi
callq 0xa2a0
jmp 0x17516
jmp 0x17513
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xa558
leaq 0x70(%rsp), %rdi
callq 0xa558
movq %rbx, %rdi
callq 0xa500