// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/misc/encoding/urlencode.cpp
// Function: smooth::Encoding::URLEncode::Encode(smooth::String const&, bool)
S::String S::Encoding::URLEncode::Encode(const String &string, Bool encodeReserved)
{
	/* Convert input string to UTF-8.
	 */
	String	 utf8;

	utf8.ImportFrom("ISO-8859-1", string.ConvertTo("UTF-8"));

	/* Encode UTF-8 string using URL encode.
	 */
	String	 encoded;
	Int	 length = utf8.Length();

	for (Int i = 0, e = 0; i < length; i++)
	{
		wchar_t	 value = utf8[i];

		if ((value >= 'A' && value <= 'Z') || (value >= 'a' && value <= 'z') || (value >= '0' && value <= '9') ||
		    (value == '-' || value == '_' || value == '.' || value == '~') ||
		    (!encodeReserved && (value == '!' || value == '*' || value == '\'' || value == '(' || value == ')' || value == ';' ||
					 value == ':' || value == '@' || value == '&'  || value == '=' || value == '+' || value == '$' ||
					 value == ',' || value == '/' || value == '?'  || value == '#' || value == '[' || value == ']')))
		{
			encoded[e++] = value;
		}
		else
		{
			String	 hex = Number((Int64) value).ToHexString(2).ToUpper();

			encoded[e++] = '%';
			encoded[e++] = hex[0];
			encoded[e++] = hex[1];
		}
	}

	return encoded;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xa8(%rbp)
movb %dl, %al
movq %rdi, %rcx
movq %rcx, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
callq 0x5da90
movq -0x10(%rbp), %rdi
leaq 0xa8aa5(%rip), %rsi     # 0x1a5be6
callq 0x5c120
movq %rax, -0x98(%rbp)
jmp 0xfd14f
movq -0x98(%rbp), %rdx
leaq 0xa893d(%rip), %rsi     # 0x1a5a9a
leaq -0x30(%rbp), %rdi
callq 0x5ae70
jmp 0xfd168
movq -0xa8(%rbp), %rdi
movb $0x0, -0x3d(%rbp)
xorl %esi, %esi
callq 0x5da90
jmp 0xfd17c
leaq -0x30(%rbp), %rdi
callq 0x5b800
movl %eax, -0xac(%rbp)
jmp 0xfd18d
movl -0xac(%rbp), %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0xfd476
movl -0x48(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x5d4e0
movq %rax, -0xb8(%rbp)
jmp 0xfd1c5
movq -0xb8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x50(%rbp)
cmpl $0x41, -0x50(%rbp)
jl 0xfd1e1
cmpl $0x5a, -0x50(%rbp)
jle 0xfd297
cmpl $0x61, -0x50(%rbp)
jl 0xfd1f1
cmpl $0x7a, -0x50(%rbp)
jle 0xfd297
cmpl $0x30, -0x50(%rbp)
jl 0xfd201
cmpl $0x39, -0x50(%rbp)
jle 0xfd297
cmpl $0x2d, -0x50(%rbp)
je 0xfd297
cmpl $0x5f, -0x50(%rbp)
je 0xfd297
cmpl $0x2e, -0x50(%rbp)
je 0xfd297
cmpl $0x7e, -0x50(%rbp)
je 0xfd297
testb $0x1, -0x11(%rbp)
jne 0xfd2f5
cmpl $0x21, -0x50(%rbp)
je 0xfd297
cmpl $0x2a, -0x50(%rbp)
je 0xfd297
cmpl $0x27, -0x50(%rbp)
je 0xfd297
cmpl $0x28, -0x50(%rbp)
je 0xfd297
cmpl $0x29, -0x50(%rbp)
je 0xfd297
cmpl $0x3b, -0x50(%rbp)
je 0xfd297
cmpl $0x3a, -0x50(%rbp)
je 0xfd297
cmpl $0x40, -0x50(%rbp)
je 0xfd297
cmpl $0x26, -0x50(%rbp)
je 0xfd297
cmpl $0x3d, -0x50(%rbp)
je 0xfd297
cmpl $0x2b, -0x50(%rbp)
je 0xfd297
cmpl $0x24, -0x50(%rbp)
je 0xfd297
cmpl $0x2c, -0x50(%rbp)
je 0xfd297
cmpl $0x2f, -0x50(%rbp)
je 0xfd297
cmpl $0x3f, -0x50(%rbp)
je 0xfd297
cmpl $0x23, -0x50(%rbp)
je 0xfd297
cmpl $0x5b, -0x50(%rbp)
je 0xfd297
cmpl $0x5d, -0x50(%rbp)
jne 0xfd2f5
movq -0xa8(%rbp), %rdi
movl -0x50(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0x4c(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0x4c(%rbp)
callq 0x5d4e0
movq %rax, -0xc0(%rbp)
jmp 0xfd2bf
movq -0xc0(%rbp), %rax
movl -0xc4(%rbp), %ecx
movl %ecx, (%rax)
jmp 0xfd466
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xfd4b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xfd4a5
movslq -0x50(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x5dd30
jmp 0xfd307
leaq -0x80(%rbp), %rdi
leaq -0x90(%rbp), %rsi
movl $0x2, %edx
callq 0x5bf10
jmp 0xfd31e
leaq -0x68(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x5a070
jmp 0xfd32d
leaq -0x80(%rbp), %rdi
callq 0x5df00
leaq -0x90(%rbp), %rdi
callq 0x5d990
movq -0xa8(%rbp), %rdi
movl -0x4c(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0x4c(%rbp)
callq 0x5d4e0
movq %rax, -0xd0(%rbp)
jmp 0xfd361
movq -0xd0(%rbp), %rax
movl $0x25, (%rax)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
callq 0x5d4e0
movq %rax, -0xd8(%rbp)
jmp 0xfd382
movq -0xa8(%rbp), %rdi
movq -0xd8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
movl -0x4c(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0x4c(%rbp)
callq 0x5d4e0
movq %rax, -0xe0(%rbp)
jmp 0xfd3b0
movq -0xe0(%rbp), %rax
movl -0xe4(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x68(%rbp), %rdi
movl $0x1, %esi
callq 0x5d4e0
movq %rax, -0xf0(%rbp)
jmp 0xfd3d6
movq -0xa8(%rbp), %rdi
movq -0xf0(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
movl -0x4c(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0x4c(%rbp)
callq 0x5d4e0
movq %rax, -0xf8(%rbp)
jmp 0xfd404
movq -0xf8(%rbp), %rax
movl -0xfc(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x68(%rbp), %rdi
callq 0x5df00
jmp 0xfd466
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xfd441
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5df00
leaq -0x90(%rbp), %rdi
callq 0x5d990
jmp 0xfd4a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x5df00
jmp 0xfd4a5
jmp 0xfd468
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0xfd1a4
movb $0x1, -0x3d(%rbp)
testb $0x1, -0x3d(%rbp)
jne 0xfd48c
movq -0xa8(%rbp), %rdi
callq 0x5df00
leaq -0x30(%rbp), %rdi
callq 0x5df00
movq -0xa0(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xa8(%rbp), %rdi
callq 0x5df00
leaq -0x30(%rbp), %rdi
callq 0x5df00
movq -0x38(%rbp), %rdi
callq 0x5b6b0
nopw %cs:(%rax,%rax)