// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/classes/misc/encoding/base64.cpp
// Function: smooth::Encoding::Base64::Encode(int) const
S::String S::Encoding::Base64::Encode(Int bytes) const
{
	if (bytes > buffer.Size()) return NIL;
	if (bytes == -1) bytes = buffer.Size();

	String	 b64;

	/* Set last byte to reserve memory and speed up processing.
	 */
	b64[(Int) Math::Ceil(bytes / 3.0) * 4] = 0;

	for (Int i = 0; i < bytes; i += 3)
	{
		Int	 val[4] = { 64, 64, 64, 64 };

				   val[0] = 						      buffer[i + 0]      >> 2;
				   val[1] = ((buffer[i + 0] &  3) << 4) | (((bytes > i + 1) ? buffer[i + 1] : 0) >> 4);
		if (bytes > i + 1) val[2] = ((buffer[i + 1] & 15) << 2) | (((bytes > i + 2) ? buffer[i + 2] : 0) >> 6);
		if (bytes > i + 2) val[3] =   buffer[i + 2] & 63;

		for (Int j = 0; j < 4; j++)
		{
			if	(val[j] >=  0 && val[j] <= 25)	b64[i / 3 * 4 + j] = 'A' + val[j] - 0;
			else if (val[j] >= 26 && val[j] <= 51)	b64[i / 3 * 4 + j] = 'a' + val[j] - 26;
			else if (val[j] >= 52 && val[j] <= 61)	b64[i / 3 * 4 + j] = '0' + val[j] - 52;
			else if (val[j] == 62)			b64[i / 3 * 4 + j] = '+';
			else if (val[j] == 63)			b64[i / 3 * 4 + j] = '/';
			else if (val[j] == 64)			b64[i / 3 * 4 + j] = '=';
		}
	}

	return b64;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq %rsi, 0x20(%rsp)
movq (%rsi), %rax
movl 0x10(%rax), %ebp
cmpl %edx, %ebp
jge 0xa60be
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5a180
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $-0x1, %edx
cmovnel %edx, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5a180
cvtsi2sd %ebp, %xmm0
divsd 0x3d4a6(%rip), %xmm0    # 0xe3580
callq 0x57e30
shll $0x2, %eax
movq %rbx, %rdi
movl %eax, %esi
callq 0x59cc0
andl $0x0, (%rax)
movslq %ebp, %rax
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq 0x18(%rsp), %r13
jge 0xa60ac
movapd 0x5bf24(%rip), %xmm0    # 0x102030
movapd %xmm0, (%rsp)
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movzbl (%rax,%r13), %ecx
movl %ecx, %edx
shrl $0x2, %edx
movl %edx, (%rsp)
shll $0x4, %ecx
andl $0x30, %ecx
leal 0x1(%r13), %edx
cmpl %edx, %ebp
jle 0xa616b
movzbl 0x1(%rax,%r13), %edx
movl %edx, %esi
shrl $0x4, %esi
orl %ecx, %esi
movl %esi, 0x4(%rsp)
leaq 0x2(%r13), %rcx
xorl %esi, %esi
cmpl %ecx, %ebp
jle 0xa615d
movzbl (%rax,%rcx), %esi
shrl $0x6, %esi
shll $0x2, %edx
andl $0x3c, %edx
orl %esi, %edx
movl %edx, 0x8(%rsp)
jmp 0xa6176
movzbl %cl, %ecx
movl %ecx, 0x4(%rsp)
leaq 0x2(%r13), %rcx
cmpl %ecx, %ebp
jle 0xa6185
movzbl (%rax,%rcx), %eax
andl $0x3f, %eax
movl %eax, 0xc(%rsp)
xorl %r14d, %r14d
cmpq $0x4, %r14
je 0xa6238
movl (%rsp,%r14,4), %r15d
cmpl $0x19, %r15d
ja 0xa61ae
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
addl $0x41, %r15d
jmp 0xa61e2
leal -0x1a(%r15), %eax
cmpl $0x19, %eax
ja 0xa61c9
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
addl $0x47, %r15d
jmp 0xa61e2
leal -0x34(%r15), %eax
cmpl $0x9, %eax
ja 0xa61ea
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
addl $-0x4, %r15d
movl %r15d, (%rax)
incq %r14
jmp 0xa6188
cmpl $0x40, %r15d
je 0xa6224
cmpl $0x3f, %r15d
je 0xa6210
cmpl $0x3e, %r15d
jne 0xa61e5
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
movl $0x2b, (%rax)
jmp 0xa61e5
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
movl $0x2f, (%rax)
jmp 0xa61e5
leal (%r12,%r14), %esi
movq %rbx, %rdi
callq 0x59cc0
movl $0x3d, (%rax)
jmp 0xa61e5
addq $0x3, %r13
addq $0x4, %r12
jmp 0xa60fd
jmp 0xa6247
movq %rax, %r14
movq %rbx, %rdi
callq 0x5a588
movq %r14, %rdi
callq 0x58260