// File: menhits[P]phplus/src/PhplusStdLib.cpp
// Function: addToProgStrToDub(CppProgram*)
void addToProgStrToDub(CppProgram * prog)
{
	if (!prog->hasFunc("$strToDub"))
	{
		string strType=prog->getTypeCode(String);
		
		prog->addFunc("$strToDub", {{strType, "in"}}, "double",
			"double out = 0;\n"
			"int divider = 1;\n"
			"for (int i = 0; i < in._size; i++)\n"
			"{\n"
			"	if (divider == 1)\n"
			"	{\n"
			"		if (in._data[i] >= '0' && in._data[i] <= '9')\n"
			"			out = out * 10 + in._data[i] - '0';\n"
			"		else if (in._data[i] == '.')\n"
			"			divider = 10;\n"
			"	}\n"
			"	else\n"
			"	{\n"
			"		if (in._data[i] >= '0' && in._data[i] <= '9')\n"
			"		{\n"
			"			out += ((double)(in._data[i] - '0')) / (double)divider;\n"
			"			divider *= 10;\n"
			"		}\n"
			"	}\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 0x8425c(%rip), %rsi     # 0xd4c9f
leaq 0x1d0(%rsp), %rdi
callq 0xb4c0
jmp 0x50a52
movq 0x88(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
callq 0x2a8a0
movb %al, 0x87(%rsp)
jmp 0x50a70
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 0x50aaa
jmp 0x50ed9
movq 0x1f0(%rsp), %rax
movq %rax, 0x70(%rsp)
leaq 0xc7a4a(%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 0x50ae9
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 0x8417e(%rip), %rsi     # 0xd4c9f
leaq 0x168(%rsp), %rdi
callq 0xb4c0
jmp 0x50b30
leaq 0xf8(%rsp), %rdi
movq %rdi, 0xf0(%rsp)
leaq 0x81336(%rip), %rdx     # 0xd1e7d
leaq 0x198(%rsp), %rsi
callq 0x96110
jmp 0x50b56
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 0x50ba8
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0xb690
movq 0x50(%rsp), %rdx
leaq 0x81012(%rip), %rsi     # 0xd1bd8
leaq 0xc8(%rsp), %rdi
callq 0xb4c0
jmp 0x50bd5
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xb690
movq 0x48(%rsp), %rdx
leaq 0x840b6(%rip), %rsi     # 0xd4ca9
leaq 0xa0(%rsp), %rdi
callq 0xb4c0
jmp 0x50c02
movq 0x60(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x148(%rsp), %rdx
leaq 0xc8(%rsp), %rcx
leaq 0xa0(%rsp), %r8
callq 0x2a900
jmp 0x50c2e
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 0x50c92
leaq 0x168(%rsp), %rdi
callq 0xb6e8
leaq 0x167(%rsp), %rdi
callq 0xb3f0
leaq 0x198(%rsp), %rdi
callq 0xb6e8
jmp 0x50ed9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50d1c
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 0x50ee1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
leaq 0x188(%rsp), %rdi
callq 0x1a950
jmp 0x50ee1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50ebd
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 0x50dc5
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 0x50d9b
jmp 0x50eb0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50e64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50e4a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c0(%rsp)
movl %eax, 0x1bc(%rsp)
jmp 0x50e30
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 0x50e87
jmp 0x50eb0
leaq 0x168(%rsp), %rdi
callq 0xb6e8
leaq 0x167(%rsp), %rdi
callq 0xb3f0
leaq 0x198(%rsp), %rdi
callq 0xb6e8
jmp 0x50ee1
addq $0x1f8, %rsp            # imm = 0x1F8
retq
movq 0x1c0(%rsp), %rdi
callq 0xb680
nop