// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/i18n/number.cpp
// Function: smooth::I18n::Number::GetLocalizedNumberString(long long)
S::String S::I18n::Number::GetLocalizedNumberString(Int64 number)
{
	/* Localize a number according to the current locale settings
	 */
	Int	 negFormat = 1;
	String	 sThousand = ".";
	String	 sGrouping = "3;0";

#ifdef __WIN32__
	wchar_t	 buffer[10];

	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, buffer, 2);
	negFormat = String(buffer).ToInt();

	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, buffer, 4);
	sThousand = buffer;

	GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, buffer, 10);
	sGrouping = buffer;
#endif

	String	 nString = String::FromInt(number >= 0 ? number : -number);
	String	 retVal;

	/* Separate number blocks.
	 */
	const Array<String>	&groupSize = sGrouping.Explode(";");
	Int			 group	   = 0;
	Int			 count	   = 0;

	for (Int i = nString.Length() - 1; i >= 0; i--)
	{
		if (groupSize.Length() > group && groupSize.GetNth(group).ToInt() == count++)
		{
			retVal = String(sThousand).Append(retVal);

			count = 1;
			group++;

			if (groupSize.Length() > group && groupSize.GetNth(group).ToInt() == 0) group--;
		}

		retVal = String().FillN(nString[i], 1).Append(retVal);
	}

	/* Format negative numbers according to the locale.
	 */
	if (number < 0)
	{
		switch (negFormat)
		{
			case 0:		// (1.1)
				retVal = String("(").Append(retVal).Append(")");
				break;
			case 1:		// -1.1
				retVal = String("-").Append(retVal);
				break;
			case 2:		// - 1.1
				retVal = String("- ").Append(retVal);
				break;
			case 3:		// 1.1-
				retVal.Append("-");
				break;
			case 4:		// 1.1 -
				retVal.Append(" -");
				break;
		}
	}

	return retVal;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x82a0d(%rip), %rsi     # 0x1193b3
leaq 0x58(%rsp), %rdi
callq 0x58c40
leaq 0x50863(%rip), %rsi     # 0xe721a
leaq 0x40(%rsp), %rdi
callq 0x58c40
movq %r14, %rsi
negq %rsi
cmovsq %r14, %rsi
leaq 0x28(%rsp), %rdi
callq 0x57e80
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5a180
leaq 0x50838(%rip), %rsi     # 0xe721e
leaq 0x8(%rsp), %rdi
callq 0x58c40
leaq 0x70(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x591a0
movq %r14, 0x20(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x5a588
leaq 0x28(%rsp), %rdi
callq 0x58370
movl %eax, %ebp
xorl %r13d, %r13d
leaq 0x8(%rsp), %r12
pushq $0x1
popq %r14
xorl %r15d, %r15d
testl %ebp, %ebp
jle 0x96aff
cmpl %r13d, 0x78(%rsp)
jle 0x96ab7
leaq 0x70(%rsp), %rdi
movl %r13d, %esi
callq 0x6bb28
movq %rax, %rdi
callq 0x57a10
movslq %r15d, %rcx
cmpq %rcx, %rax
jne 0x96ab4
movq %r12, %rdi
leaq 0x58(%rsp), %rsi
callq 0x58280
movq %r12, %rdi
movq %rbx, %rsi
callq 0x573e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x56630
movq %r12, %rdi
callq 0x5a588
leal 0x1(%r13), %r15d
cmpl %r15d, 0x78(%rsp)
jle 0x96aac
leaq 0x70(%rsp), %rdi
movl %r15d, %esi
callq 0x6bb28
movq %rax, %rdi
callq 0x57a10
testq %rax, %rax
cmovel %r13d, %r15d
movl %r15d, %r13d
movl %r14d, %r15d
jmp 0x96ab7
incl %r15d
movq %r12, %rdi
xorl %esi, %esi
callq 0x5a180
decl %ebp
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
callq 0x59cc0
movl (%rax), %esi
movq %r12, %rdi
movl %r14d, %edx
callq 0x58e70
movq %rax, %rdi
movq %rbx, %rsi
callq 0x573e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x56630
movq %r12, %rdi
callq 0x5a588
jmp 0x96a2e
cmpq $0x0, 0x20(%rsp)
jns 0x96b3a
leaq 0x6d715(%rip), %rsi     # 0x104223
leaq 0x8(%rsp), %rdi
callq 0x58c40
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x573e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x56630
leaq 0x8(%rsp), %rdi
callq 0x5a588
leaq 0x70(%rsp), %rdi
callq 0x64988
leaq 0x28(%rsp), %rdi
callq 0x5a588
leaq 0x40(%rsp), %rdi
callq 0x5a588
leaq 0x58(%rsp), %rdi
callq 0x5a588
movq %rbx, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x96ba6
jmp 0x96bab
jmp 0x96ba6
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a588
jmp 0x96bc2
movq %rax, %r14
jmp 0x96bc2
movq %rax, %r14
jmp 0x96bca
movq %rax, %r14
jmp 0x96bd4
movq %rax, %r14
jmp 0x96bde
jmp 0x96ba6
jmp 0x96bab
jmp 0x96ba6
movq %rax, %r14
jmp 0x96bb8
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x5a588
leaq 0x70(%rsp), %rdi
callq 0x64988
movq %rbx, %rdi
callq 0x5a588
leaq 0x28(%rsp), %rdi
callq 0x5a588
leaq 0x40(%rsp), %rdi
callq 0x5a588
leaq 0x58(%rsp), %rdi
callq 0x5a588
movq %r14, %rdi
callq 0x58260