// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/misc/string.cpp
// Function: smooth::String::ImportFrom(char const*, char const*)
S::Int S::String::ImportFrom(const char *format, const char *str)
{
	Clean();

	if (str == NIL) return Success();

	Int	 width = 1;

	if	(strncmp(format, "UCS-4", 5)		== 0) width = 4;
	else if	(strncmp(format, "UCS-2", 5)		== 0) width = 2;
	else if	(strncmp(format, "UTF-32", 6)		== 0) width = 4;
	else if	(strncmp(format, "UTF-16", 6)		== 0) width = 2;
	else if	(strncmp(format, "CSUCS4", 6)		== 0) width = 4;
	else if	(strncmp(format, "ISO-10646-UCS-4", 15)	== 0) width = 4;
	else if	(strncmp(format, "ISO-10646-UCS-2", 15)	== 0) width = 2;
	else if	(strncmp(format, "UNICODELITTLE", 13)	== 0) width = 2;
	else if	(strncmp(format, "UNICODEBIG", 10)	== 0) width = 2;
	else if	(strncmp(format, "CSUNICODE", 9)	== 0) width = 2;
	else if	(strncmp(format, "UNICODE-1-1", 11)	== 0) width = 2;
	else if	(strncmp(format, "CSUNICODE11", 11)	== 0) width = 2;

	Int	 length = -1;

	if	(width == 1) while (true) { if (((char  *) str)[++length] == 0) { length *= 1; break; } }
	else if (width == 2) while (true) { if (((short *) str)[++length] == 0) { length *= 2; break; } }
	else if (width == 4) while (true) { if (((int   *) str)[++length] == 0) { length *= 4; break; } }

	Int	 size = ConvertString(str, length, format, NIL, 0, GetInternalFormat());

	if	(size < 0 && strcmp(format, "ISO-8859-1") != 0) return ImportFrom("ISO-8859-1", str);
	else if (size < 0)					return Error();

	size = size / sizeof(wchar_t) + 1;

	wString.Resize(size);

	ConvertString(str, length, format, (char *) (wchar_t *) wString, size * sizeof(wchar_t), GetInternalFormat());

	wString[size - 1] = 0;

	return Success();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x60a9a(%rip), %r12     # 0x101b41
movq %rbx, %rdi
callq 0x58af0
testq %r14, %r14
je 0xa12cc
movq %r15, %rdi
leaq 0x60a2e(%rip), %rsi     # 0x101af0
pushq $0x5
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa11f5
movq %r15, %rdi
leaq 0x60a24(%rip), %rsi     # 0x101b00
pushq $0x5
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x609db(%rip), %rsi     # 0x101ad1
pushq $0x6
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa11f5
movq %r15, %rdi
leaq 0x609c8(%rip), %rsi     # 0x101ad8
pushq $0x6
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x609b5(%rip), %rsi     # 0x101adf
pushq $0x6
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa11f5
movq %r15, %rdi
leaq 0x609a2(%rip), %rsi     # 0x101ae6
pushq $0xf
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa11f5
movq %r15, %rdi
leaq 0x60998(%rip), %rsi     # 0x101af6
pushq $0xf
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x6098e(%rip), %rsi     # 0x101b06
pushq $0xd
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x60982(%rip), %rsi     # 0x101b14
pushq $0xa
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x60977(%rip), %rsi     # 0x101b1f
pushq $0x9
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x6096b(%rip), %rsi     # 0x101b29
pushq $0xb
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r15, %rdi
leaq 0x60961(%rip), %rsi     # 0x101b35
pushq $0xb
popq %rdx
callq 0x56c10
testl %eax, %eax
je 0xa120b
movq %r14, %rax
pushq $-0x1
popq %r13
incl %r13d
cmpb $0x0, (%rax)
leaq 0x1(%rax), %rax
jne 0xa11e7
jmp 0xa1220
movq %r14, %rax
pushq $-0x4
popq %r13
addl $0x4, %r13d
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jne 0xa11fc
jmp 0xa1220
movq %r14, %rax
pushq $-0x2
popq %r13
addl $0x2, %r13d
cmpw $0x0, (%rax)
leaq 0x2(%rax), %rax
jne 0xa1212
movq 0xc3db1(%rip), %r9      # 0x164fd8
testq %r9, %r9
jne 0xa123a
leaq 0x60895(%rip), %r9      # 0x101ac8
movq %r9, 0xc3d9e(%rip)      # 0x164fd8
movq %r14, %rdi
movl %r13d, %esi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0xa1516
testl %eax, %eax
jns 0xa126c
movq %r15, %rdi
movq %r12, %rsi
callq 0x58e40
movq %r12, %r15
testl %eax, %eax
jne 0xa10a7
pushq $-0x1
popq %rax
jmp 0xa12ce
movl %eax, %ebp
shrl $0x2, %ebp
leal 0x1(%rbp), %r12d
movq %rbx, %rdi
movl %r12d, %esi
callq 0xa260a
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0xa128e
movq (%rax), %rcx
jmp 0xa1290
xorl %ecx, %ecx
shll $0x2, %r12d
movq 0xc3d3d(%rip), %r9      # 0x164fd8
testq %r9, %r9
jne 0xa12ae
leaq 0x60821(%rip), %r9      # 0x101ac8
movq %r9, 0xc3d2a(%rip)      # 0x164fd8
movq %r14, %rdi
movl %r13d, %esi
movq %r15, %rdx
movl %r12d, %r8d
callq 0xa1516
movq 0x8(%rbx), %rax
movq (%rax), %rax
movl %ebp, %ecx
andl $0x0, (%rax,%rcx,4)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop