// File: /workspace/github_c_makefile_star2_O3/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 0x8ed25(%rip), %rsi     # 0x129683
leaq 0x58(%rsp), %rdi
callq 0x579f0
leaq 0x5c9ab(%rip), %rsi     # 0xf731a
leaq 0x40(%rsp), %rdi
callq 0x579f0
movq %r14, %rsi
negq %rsi
cmovsq %r14, %rsi
leaq 0x28(%rsp), %rdi
callq 0x56cf0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x58e20
leaq 0x5c980(%rip), %rsi     # 0xf731e
leaq 0x8(%rsp), %rdi
callq 0x579f0
movq %r14, 0x20(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x57f10
movq %rbx, (%rsp)
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x28(%rsp), %rdi
callq 0x57180
movl %eax, %r15d
testl %eax, %eax
jle 0x9aad2
incl %r15d
xorl %r14d, %r14d
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rbx
xorl %ebp, %ebp
cmpl %ebp, 0x78(%rsp)
jle 0x9aa80
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
callq 0x6b610
movq %rax, %rdi
callq 0x568c0
movslq %r14d, %rcx
cmpq %rcx, %rax
jne 0x9aa7d
movq %r13, %rdi
leaq 0x58(%rsp), %rsi
callq 0x570b0
movq %r13, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x562f0
movq %r14, %rdi
movq %rax, %rsi
callq 0x555f0
movq %r13, %rdi
callq 0x59200
leal 0x1(%rbp), %r12d
movl $0x1, %r14d
cmpl %r12d, 0x78(%rsp)
jle 0x9aa78
leaq 0x70(%rsp), %rdi
movl %r12d, %esi
callq 0x6b610
movq %rax, %rdi
callq 0x568c0
testq %rax, %rax
cmovel %ebp, %r12d
movl %r12d, %ebp
jmp 0x9aa80
incl %r14d
movq %r13, %rdi
xorl %esi, %esi
callq 0x58e20
leal -0x2(%r15), %esi
movq %rbx, %rdi
callq 0x58990
movl (%rax), %esi
movq %r13, %rdi
movl $0x1, %edx
callq 0x57bf0
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x562f0
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x555f0
movq %r13, %rdi
callq 0x59200
decl %r15d
cmpl $0x1, %r15d
ja 0x9a9f6
cmpq $0x0, 0x20(%rsp)
movq (%rsp), %rbx
jns 0x9ab11
leaq 0x798ae(%rip), %rsi     # 0x114393
leaq 0x8(%rsp), %rdi
callq 0x579f0
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x562f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x555f0
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x70(%rsp), %rdi
callq 0x63e3c
leaq 0x28(%rsp), %rdi
callq 0x59200
leaq 0x40(%rsp), %rdi
callq 0x59200
leaq 0x58(%rsp), %rdi
callq 0x59200
movq %rbx, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9ab7d
jmp 0x9ab82
jmp 0x9ab7d
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
jmp 0x9ab9d
movq %rax, %r14
jmp 0x9ab9d
movq %rax, %r14
jmp 0x9aba5
movq %rax, %r14
jmp 0x9abaf
movq %rax, %r14
jmp 0x9abb9
jmp 0x9ab7d
jmp 0x9ab82
jmp 0x9ab7d
movq %rax, %r14
jmp 0x9ab8f
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x70(%rsp), %rdi
callq 0x63e3c
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x59200
leaq 0x28(%rsp), %rdi
callq 0x59200
leaq 0x40(%rsp), %rdi
callq 0x59200
leaq 0x58(%rsp), %rdi
callq 0x59200
movq %r14, %rdi
callq 0x57090
nop