// File: /workspace/github_c_makefile_star2_O1/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 0x8f315(%rip), %rsi     # 0x12a463
leaq 0x58(%rsp), %rdi
callq 0x579f0
leaq 0x5d017(%rip), %rsi     # 0xf8176
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 0x5cfec(%rip), %rsi     # 0xf817a
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 0x9b2c2
incl %r15d
xorl %r14d, %r14d
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %rbx
xorl %ebp, %ebp
cmpl %ebp, 0x78(%rsp)
jle 0x9b270
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
callq 0x6b6a6
movq %rax, %rdi
callq 0x568c0
movslq %r14d, %rcx
cmpq %rcx, %rax
jne 0x9b26d
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 0x9b268
leaq 0x70(%rsp), %rdi
movl %r12d, %esi
callq 0x6b6a6
movq %rax, %rdi
callq 0x568c0
testq %rax, %rax
cmovel %ebp, %r12d
movl %r12d, %ebp
jmp 0x9b270
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
jg 0x9b1e6
cmpq $0x0, 0x20(%rsp)
movq (%rsp), %rbx
jns 0x9b301
leaq 0x79eae(%rip), %rsi     # 0x115183
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 0x63e08
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 0x9b36d
jmp 0x9b372
jmp 0x9b36d
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
jmp 0x9b38d
movq %rax, %r14
jmp 0x9b38d
movq %rax, %r14
jmp 0x9b395
movq %rax, %r14
jmp 0x9b39f
movq %rax, %r14
jmp 0x9b3a9
jmp 0x9b36d
jmp 0x9b372
jmp 0x9b36d
movq %rax, %r14
jmp 0x9b37f
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x59200
leaq 0x70(%rsp), %rdi
callq 0x63e08
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