// File: menhits[P]phplus/src/PhplusStdLib.cpp
// Function: addToProgIntToStr(CppProgram*)
void addToProgIntToStr(CppProgram * prog)
{
	if (!prog->hasFunc("$intToStr"))
	{
		string strType=prog->getTypeCode(String);
		
		prog->addFunc("$intToStr", {{"int", "in"}}, prog->getTypeCode(String),
			"bool neg = in < 0;\n"
			"if (neg) in *= -1;\n"
			"int val = in;\n"
			"int size = 0;\n"
			"while (val)\n"
			"{\n"
			"	size++;\n"
			"	val /= 10;\n"
			"}\n"
			"if (size == 0)\n\tsize = 1;\n"
			"if (neg)\n\tsize++;\n"
			"unsigned char * data = (unsigned char *)malloc(size);\n"
			"val = in;\n"
			"for (int i = 0; i<(neg ? size-1 : size); i++)\n"
			"{\n"
			"	data[size-i-1] = (val % 10) + '0';\n"
			"	val /= 10;\n"
			"}\n"
			"if (neg)\n\tdata[0] = '-';\n"
			"return "+strType+"(size, data);\n"
		);
	}
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x210(%rsp)
movq 0x210(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x1ef(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xb690
movq 0x90(%rsp), %rdx
leaq 0x84a1b(%rip), %rsi     # 0xd4a3e
leaq 0x1f0(%rsp), %rdi
callq 0xb4c0
jmp 0x50032
movq 0x88(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x2a8a0
movb %al, 0x87(%rsp)
jmp 0x50050
movb 0x87(%rsp), %al
xorb $-0x1, %al
movb %al, 0x86(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0xb6e8
leaq 0x1ef(%rsp), %rdi
callq 0xb3f0
movb 0x86(%rsp), %al
testb $0x1, %al
jne 0x5008a
jmp 0x504ef
movq 0x210(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0xc846a(%rip), %rsi     # 0x118508
leaq 0x1a8(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x1a920
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq 0x1b8(%rsp), %rdi
callq 0x285b0
jmp 0x500c9
leaq 0x1a8(%rsp), %rdi
callq 0x1a950
movq 0x210(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x187(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xb690
movq 0x68(%rsp), %rdx
leaq 0x8493d(%rip), %rsi     # 0xd4a3e
leaq 0x188(%rsp), %rdi
callq 0xb4c0
jmp 0x50110
leaq 0x118(%rsp), %rdi
movq %rdi, 0x110(%rsp)
leaq 0x81abe(%rip), %rsi     # 0xd1be5
leaq 0x81d4f(%rip), %rdx     # 0xd1e7d
callq 0x962a0
jmp 0x50135
leaq 0x118(%rsp), %rax
movq %rax, 0x158(%rsp)
movq $0x1, 0x160(%rsp)
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2f150
movq 0x58(%rsp), %rcx
movq 0x158(%rsp), %rsi
movq 0x160(%rsp), %rdx
leaq 0x168(%rsp), %rdi
callq 0x96080
jmp 0x50187
movq 0x210(%rsp), %rax
movq %rax, 0x48(%rsp)
leaq 0xc836d(%rip), %rsi     # 0x118508
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x1a920
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0xe8(%rsp), %rdi
callq 0x285b0
jmp 0x501c6
leaq 0x8487b(%rip), %rsi     # 0xd4a48
leaq 0x98(%rsp), %rdi
leaq 0x1b8(%rsp), %rdx
callq 0xfab0
jmp 0x501e4
leaq 0x84844(%rip), %rdx     # 0xd4a2f
leaq 0xb8(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xfa60
jmp 0x50202
movq 0x60(%rsp), %rdi
leaq 0x188(%rsp), %rsi
leaq 0x168(%rsp), %rdx
leaq 0xe8(%rsp), %rcx
leaq 0xb8(%rsp), %r8
callq 0x2a900
jmp 0x5022e
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
leaq 0x98(%rsp), %rdi
callq 0xb6e8
leaq 0xe8(%rsp), %rdi
callq 0xb6e8
leaq 0xd8(%rsp), %rdi
callq 0x1a950
leaq 0x168(%rsp), %rdi
callq 0x2e540
leaq 0x10f(%rsp), %rdi
callq 0x33c90
leaq 0x118(%rsp), %rax
movq %rax, 0x38(%rsp)
addq $0x40, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
addq $-0x40, %rdi
movq %rdi, 0x30(%rsp)
callq 0x2e470
movq 0x38(%rsp), %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x40(%rsp)
jne 0x50292
leaq 0x188(%rsp), %rdi
callq 0xb6e8
leaq 0x187(%rsp), %rdi
callq 0xb3f0
leaq 0x1b8(%rsp), %rdi
callq 0xb6e8
jmp 0x504ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x5031c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x1f0(%rsp), %rdi
callq 0xb6e8
leaq 0x1ef(%rsp), %rdi
callq 0xb3f0
jmp 0x504f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x1a950
jmp 0x504f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x504d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
movq 0x110(%rsp), %rax
leaq 0x118(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x28(%rsp)
je 0x503c5
movq 0x28(%rsp), %rdi
addq $-0x40, %rdi
movq %rdi, 0x20(%rsp)
callq 0x2e470
movq 0x20(%rsp), %rax
leaq 0x118(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x28(%rsp)
jne 0x5039b
jmp 0x504c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x5047a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x50460
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x50453
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
jmp 0x50446
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1e0(%rsp)
movl %eax, 0x1dc(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xb6e8
leaq 0x98(%rsp), %rdi
callq 0xb6e8
leaq 0xe8(%rsp), %rdi
callq 0xb6e8
leaq 0xd8(%rsp), %rdi
callq 0x1a950
leaq 0x168(%rsp), %rdi
callq 0x2e540
leaq 0x10f(%rsp), %rdi
callq 0x33c90
leaq 0x118(%rsp), %rax
movq %rax, 0x10(%rsp)
addq $0x40, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
addq $-0x40, %rdi
movq %rdi, 0x8(%rsp)
callq 0x2e470
movq 0x10(%rsp), %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
movq %rax, 0x18(%rsp)
jne 0x5049d
jmp 0x504c6
leaq 0x188(%rsp), %rdi
callq 0xb6e8
leaq 0x187(%rsp), %rdi
callq 0xb3f0
leaq 0x1b8(%rsp), %rdi
callq 0xb6e8
jmp 0x504f7
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x1e0(%rsp), %rdi
callq 0xb680
nopw %cs:(%rax,%rax)