// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x38(%rbp)
callq 0x5b800
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0xf2b99
movq $0x0, -0x8(%rbp)
jmp 0xf2d16
movq -0x38(%rbp), %rdi
callq 0xf5750
movq %rax, -0x48(%rbp)
movslq -0x1c(%rbp), %rax
shlq $0x2, %rax
movl %eax, -0x3c(%rbp)
callq 0x5a6c0
movq -0x48(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq %rax, %rdx
movq -0x18(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0xf37c0
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
jne 0xf2c16
movq -0x38(%rbp), %rdi
callq 0xf5750
movq %rax, -0x58(%rbp)
movslq -0x1c(%rbp), %rax
shlq $0x2, %rax
movl %eax, -0x4c(%rbp)
callq 0x5a6c0
movq -0x58(%rbp), %rdi
movl -0x4c(%rbp), %esi
movq %rax, %rdx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
leaq 0xb2e8c(%rip), %r9      # 0x1a5a9a
callq 0xf37c0
movl %eax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpl $0x0, -0x20(%rbp)
jg 0xf2cb7
movq -0x38(%rbp), %rdi
callq 0x5b800
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x5ab20
movq -0x38(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0xf5750
movq %rax, -0x68(%rbp)
movslq -0x1c(%rbp), %rax
shlq $0x2, %rax
movl %eax, -0x5c(%rbp)
callq 0x5a6c0
movq -0x68(%rbp), %rdi
movl -0x5c(%rbp), %esi
movq %rax, %rdx
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
addl $0x1, %r8d
movq -0x18(%rbp), %r9
callq 0xf37c0
xorl %eax, %eax
subl -0x20(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xf2ca9
movq -0x28(%rbp), %rax
movslq -0x30(%rbp), %rcx
movb $0x3f, (%rax,%rcx)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xf2c8a
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0xf2d05
movl -0x20(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x5ab20
movq -0x38(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0xf5750
movq %rax, -0x78(%rbp)
movslq -0x1c(%rbp), %rax
shlq $0x2, %rax
movl %eax, -0x6c(%rbp)
callq 0x5a6c0
movq -0x78(%rbp), %rdi
movl -0x6c(%rbp), %esi
movq %rax, %rdx
movq -0x28(%rbp), %rcx
movl -0x20(%rbp), %r8d
addl $0x1, %r8d
movq -0x18(%rbp), %r9
callq 0xf37c0
movq -0x28(%rbp), %rdi
callq 0x5d400
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)