// File: /workspace/github_cpp_makefile_star2_O1/alfanick[P]rest-cpp/src/rest/utils.cpp
// Function: REST::Utils::base64_encode[abi:cxx11](unsigned char const*, unsigned int)
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
  std::string ret;
  int i = 0;
  int j = 0;
  unsigned char char_array_3[3];
  unsigned char char_array_4[4];

  while (in_len--) {
    char_array_3[i++] = *(bytes_to_encode++);
    if (i == 3) {
      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
      char_array_4[3] = char_array_3[2] & 0x3f;

      for(i = 0; (i <4) ; i++)
        ret += base64_chars[char_array_4[i]];
      i = 0;
    }
  }

  if (i)
  {
    for(j = i; j < 3; j++)
      char_array_3[j] = '\0';

    char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
    char_array_4[3] = char_array_3[2] & 0x3f;

    for (j = 0; (j < i + 1); j++)
      ret += base64_chars[char_array_4[j]];

    while((i++ < 3))
      ret += '=';

  }

  return ret;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x10(%rdi), %r15
movq %r15, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
testl %edx, %edx
je 0x37679
movl %edx, %ebp
movq %rsi, %r14
xorl %r12d, %r12d
movb (%r14), %al
movl %r12d, %ecx
incl %r12d
movb %al, 0x1(%rsp,%rcx)
cmpl $0x3, %r12d
jne 0x3766e
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
movl %eax, %edx
shrb $0x2, %dl
movb %dl, 0x4(%rsp)
movl %ecx, %edx
shrb $0x4, %dl
shlb $0x4, %al
orb %dl, %al
andb $0x3f, %al
movb %al, 0x5(%rsp)
movb 0x3(%rsp), %al
movl %eax, %edx
shrb $0x6, %dl
shlb $0x2, %cl
orb %dl, %cl
andb $0x3f, %cl
movb %cl, 0x6(%rsp)
andb $0x3f, %al
movb %al, 0x7(%rsp)
xorl %r12d, %r12d
movzbl 0x4(%rsp,%r12), %eax
movq 0x180fa(%rip), %rcx     # 0x4f750
movsbl (%rcx,%rax), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r12
cmpq $0x4, %r12
jne 0x37649
xorl %r12d, %r12d
decl %ebp
incq %r14
testl %ebp, %ebp
jne 0x375f7
jmp 0x3767c
xorl %r12d, %r12d
testl %r12d, %r12d
je 0x37734
cmpl $0x2, %r12d
jg 0x376a5
movl %r12d, %eax
leaq 0x1(%rsp,%rax), %rdi
movl $0x2, %edx
subl %r12d, %edx
incq %rdx
xorl %esi, %esi
callq 0x21910
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
movl %eax, %edx
shrb $0x2, %dl
movb %dl, 0x4(%rsp)
movl %ecx, %edx
shrb $0x4, %dl
shlb $0x4, %al
orb %dl, %al
andb $0x3f, %al
movb %al, 0x5(%rsp)
movb 0x3(%rsp), %al
movl %eax, %edx
shrb $0x6, %dl
shlb $0x2, %cl
orb %dl, %cl
andb $0x3f, %cl
movb %cl, 0x6(%rsp)
andb $0x3f, %al
movb %al, 0x7(%rsp)
testl %r12d, %r12d
js 0x3770f
leal 0x1(%r12), %r14d
xorl %r13d, %r13d
movzbl 0x4(%rsp,%r13), %eax
movq 0x18055(%rip), %rcx     # 0x4f750
movsbl (%rcx,%rax), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r13
cmpq %r13, %r14
jne 0x376ee
cmpl $0x4, %r12d
movl $0x3, %ebp
cmovgel %r12d, %ebp
subl %r12d, %ebp
incl %ebp
decl %ebp
je 0x37734
movq %rbx, %rdi
movl $0x3d, %esi
callq 0x21ef0
jmp 0x37721
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3774a
jmp 0x3774a
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r15, %rdi
je 0x3775a
callq 0x22130
movq %r14, %rdi
callq 0x23170