// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/misc/string.cpp
// Function: smooth::String::ConvertTo(char const*) const
char *S::String::ConvertTo(const char *encoding) const
{
	Int	 size = Length() + 1;

	if (size == 1) return NIL;

	Int	 bufferSize = ConvertString((char *) (wchar_t *) wString, size * sizeof(wchar_t), GetInternalFormat(), NIL, 0, encoding);

	if (bufferSize == -1) bufferSize = ConvertString((char *) (wchar_t *) wString, size * sizeof(wchar_t), GetInternalFormat(), NIL, 0, "ISO-8859-1");

	char	*buffer = NIL;

	if (bufferSize <= 0)
	{
		Int	 length = Length();

		buffer = new char [length + 1];

		ConvertString((char *) (wchar_t *) wString, size * sizeof(wchar_t), GetInternalFormat(), buffer, length + 1, encoding);

		for (Int i = -bufferSize; i < length; i++) buffer[i] = '?';

		buffer[length] = 0;
	}
	else
	{
		buffer = new char [bufferSize + 1];

		ConvertString((char *) (wchar_t *) wString, size * sizeof(wchar_t), GetInternalFormat(), buffer, bufferSize + 1, encoding);
	}

	AddTemporaryBuffer(buffer);

	return buffer;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x58370
testl %eax, %eax
je 0xa0e52
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0xa0e5a
movq (%rcx), %rdi
jmp 0xa0e5c
xorl %r15d, %r15d
jmp 0xa0fad
xorl %edi, %edi
leal 0x4(,%rax,4), %ebp
movq 0xc416e(%rip), %rdx     # 0x164fd8
testq %rdx, %rdx
jne 0xa0e7d
leaq 0x60c52(%rip), %rdx     # 0x101ac8
movq %rdx, 0xc415b(%rip)     # 0x164fd8
movl %ebp, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rbx, %r9
callq 0xa1516
movl %eax, %r12d
cmpl $-0x1, %eax
jne 0xa0ed4
movq 0x8(%r14), %rax
testq %rax, %rax
je 0xa0ea2
movq (%rax), %rdi
jmp 0xa0ea4
xorl %edi, %edi
movq 0xc412d(%rip), %rdx     # 0x164fd8
testq %rdx, %rdx
jne 0xa0ebe
leaq 0x60c11(%rip), %rdx     # 0x101ac8
movq %rdx, 0xc411a(%rip)     # 0x164fd8
leaq 0x60c7c(%rip), %r9      # 0x101b41
movl %ebp, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xa1516
movl %eax, %r12d
testl %r12d, %r12d
jle 0xa0ef5
incl %r12d
movq %r12, %rdi
callq 0x577a0
movq %rax, %r15
movq 0x8(%r14), %rax
testq %rax, %rax
je 0xa0f21
movq (%rax), %rdi
jmp 0xa0f23
movq %rbx, (%rsp)
movq %r14, %rdi
callq 0x58370
movl %eax, %r13d
leal 0x1(%r13), %ebx
movslq %ebx, %rdi
callq 0x577a0
movq %rax, %r15
movq 0x8(%r14), %rax
testq %rax, %rax
je 0xa0f4f
movq (%rax), %rdi
jmp 0xa0f51
xorl %edi, %edi
movq 0xc40ae(%rip), %rdx     # 0x164fd8
testq %rdx, %rdx
jne 0xa0f3d
leaq 0x60b92(%rip), %rdx     # 0x101ac8
movq %rdx, 0xc409b(%rip)     # 0x164fd8
movl %ebp, %esi
movq %r15, %rcx
movl %r12d, %r8d
movq %rbx, %r9
callq 0xa1516
jmp 0xa0fa5
xorl %edi, %edi
movq 0xc4080(%rip), %rdx     # 0x164fd8
testq %rdx, %rdx
jne 0xa0f6b
leaq 0x60b64(%rip), %rdx     # 0x101ac8
movq %rdx, 0xc406d(%rip)     # 0x164fd8
movl %ebp, %esi
movq %r15, %rcx
movl %ebx, %r8d
movq (%rsp), %r9
callq 0xa1516
negl %r12d
movslq %r12d, %rax
cmpl %eax, %r13d
movl %eax, %ecx
cmovgl %r13d, %ecx
movslq %ecx, %rcx
cmpq %rax, %rcx
je 0xa0f9d
movb $0x3f, (%r15,%rax)
incq %rax
jmp 0xa0f8e
movslq %r13d, %rax
movb $0x0, (%r15,%rax)
movq %r15, %rdi
callq 0x59bf0
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop