// File: menhits[P]phplus/src/PhplusStdLib.cpp
// Function: addToProgStrToInt(CppProgram*)
void addToProgStrToInt(CppProgram * prog)
{
	if (!prog->hasFunc("$strToInt"))
	{
		string strType=prog->getTypeCode(String);
		
		prog->addFunc("$strToInt", {{strType, "in"}}, "int",
			"int out = 0;\n"
			"for (int i = 0; i < in._size; i++)\n"
			"{\n"
			"	if (in._data[i] >= '0' && in._data[i] <= '9')\n"
			"	{\n"
			"		out = out * 10 + in._data[i] - '0';\n"
			"	}\n"
			"	else if (in._data[i] == '.')\n"
			"		break;\n"
			"}\n"
			"if (in._size > 0 && in._data[0] == '-')\n"
			"	out *= -1;\n"
			"return out;\n"
		);
	}
}

// Assembly:
subq $0x1f8, %rsp            # imm = 0x1F8
movq %rdi, 0x1f0(%rsp)
movq 0x1f0(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x1cf(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xb690
movq 0x90(%rsp), %rdx
leaq 0x8464b(%rip), %rsi     # 0xd4b9e
leaq 0x1d0(%rsp), %rdi
callq 0xb4c0
jmp 0x50562
movq 0x88(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x2a8a0
movb %al, 0x87(%rsp)
jmp 0x50580
movb 0x87(%rsp), %al
xorb $-0x1, %al
movb %al, 0x86(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
leaq 0x1cf(%rsp), %rdi
callq 0xb3f0
movb 0x86(%rsp), %al
testb $0x1, %al
jne 0x505ba
jmp 0x509e9
movq 0x1f0(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0xc7f3a(%rip), %rsi     # 0x118508
leaq 0x188(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x1a920
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq 0x198(%rsp), %rdi
callq 0x285b0
jmp 0x505f9
leaq 0x188(%rsp), %rdi
callq 0x1a950
movq 0x1f0(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x167(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xb690
movq 0x68(%rsp), %rdx
leaq 0x8456d(%rip), %rsi     # 0xd4b9e
leaq 0x168(%rsp), %rdi
callq 0xb4c0
jmp 0x50640
leaq 0xf8(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
leaq 0x81826(%rip), %rdx     # 0xd1e7d
leaq 0x198(%rsp), %rsi
callq 0x96110
jmp 0x50666
leaq 0xf8(%rsp), %rax
movq %rax, 0x138(%rsp)
movq $0x1, 0x140(%rsp)
leaq 0xef(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x2f150
movq 0x58(%rsp), %rcx
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
leaq 0x148(%rsp), %rdi
callq 0x96080
jmp 0x506b8
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xb690
movq 0x50(%rsp), %rdx
leaq 0x8150f(%rip), %rsi     # 0xd1be5
leaq 0xc8(%rsp), %rdi
callq 0xb4c0
jmp 0x506e5
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xb690
movq 0x48(%rsp), %rdx
leaq 0x844a5(%rip), %rsi     # 0xd4ba8
leaq 0xa0(%rsp), %rdi
callq 0xb4c0
jmp 0x50712
movq 0x60(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
leaq 0xa0(%rsp), %r8
callq 0x2a900
jmp 0x5073e
leaq 0xa0(%rsp), %rdi
callq 0xb6e8
leaq 0x9f(%rsp), %rdi
callq 0xb3f0
leaq 0xc8(%rsp), %rdi
callq 0xb6e8
leaq 0xc7(%rsp), %rdi
callq 0xb3f0
leaq 0x148(%rsp), %rdi
callq 0x2e540
leaq 0xef(%rsp), %rdi
callq 0x33c90
leaq 0xf8(%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 0x507a2
leaq 0x168(%rsp), %rdi
callq 0xb6e8
leaq 0x167(%rsp), %rdi
callq 0xb3f0
leaq 0x198(%rsp), %rdi
callq 0xb6e8
jmp 0x509e9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x5082c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
leaq 0x1cf(%rsp), %rdi
callq 0xb3f0
jmp 0x509f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1a950
jmp 0x509f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x509cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
movq 0xf0(%rsp), %rax
leaq 0xf8(%rsp), %rcx
cmpq %rax, %rcx
movq %rax, 0x28(%rsp)
je 0x508d5
movq 0x28(%rsp), %rdi
addq $-0x40, %rdi
movq %rdi, 0x20(%rsp)
callq 0x2e470
movq 0x20(%rsp), %rax
leaq 0xf8(%rsp), %rcx
cmpq %rcx, %rax
movq %rax, 0x28(%rsp)
jne 0x508ab
jmp 0x509c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50974
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x5095a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50940
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0xb6e8
leaq 0x9f(%rsp), %rdi
callq 0xb3f0
leaq 0xc8(%rsp), %rdi
callq 0xb6e8
leaq 0xc7(%rsp), %rdi
callq 0xb3f0
leaq 0x148(%rsp), %rdi
callq 0x2e540
leaq 0xef(%rsp), %rdi
callq 0x33c90
leaq 0xf8(%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 0x50997
jmp 0x509c0
leaq 0x168(%rsp), %rdi
callq 0xb6e8
leaq 0x167(%rsp), %rdi
callq 0xb3f0
leaq 0x198(%rsp), %rdi
callq 0xb6e8
jmp 0x509f1
addq $0x1f8, %rsp            # imm = 0x1F8
retq
movq 0x1c0(%rsp), %rdi
callq 0xb680
nop