// File: /workspace/github_cpp_makefile_star2_O3/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
leaq 0x10(%rdi), %r15
movq %rdi, %rbx
movq %r15, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
testl %edx, %edx
je 0x37601
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 0x37538
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
movb 0x3(%rsp), %sil
xorl %r12d, %r12d
movl %eax, %edx
shlb $0x4, %al
shrb $0x2, %dl
movb %dl, 0x4(%rsp)
movl %ecx, %edx
shlb $0x2, %cl
shrb $0x4, %dl
orb %dl, %al
movl %esi, %edx
andb $0x3f, %sil
shrb $0x6, %dl
andb $0x3f, %al
orb %dl, %cl
movb %al, 0x5(%rsp)
andb $0x3f, %cl
movb %cl, 0x6(%rsp)
movb %sil, 0x7(%rsp)
movzbl 0x4(%rsp,%r12), %eax
movq 0x17220(%rip), %rcx     # 0x4e740
movsbl (%rcx,%rax), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r12
cmpq $0x4, %r12
jne 0x37513
xorl %r12d, %r12d
decl %ebp
incq %r14
testl %ebp, %ebp
jne 0x374bd
testl %r12d, %r12d
je 0x37601
cmpl $0x2, %r12d
jg 0x3756e
movl $0x2, %edx
movl %r12d, %eax
leaq 0x1(%rsp,%rax), %rdi
xorl %esi, %esi
subl %r12d, %edx
incq %rdx
callq 0x21910
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
movb 0x3(%rsp), %sil
movl %eax, %edx
shlb $0x4, %al
shrb $0x2, %dl
movb %dl, 0x4(%rsp)
movl %ecx, %edx
shlb $0x2, %cl
shrb $0x4, %dl
orb %dl, %al
movl %esi, %edx
andb $0x3f, %sil
shrb $0x6, %dl
andb $0x3f, %al
orb %dl, %cl
movb %al, 0x5(%rsp)
andb $0x3f, %cl
movb %cl, 0x6(%rsp)
movb %sil, 0x7(%rsp)
testl %r12d, %r12d
js 0x375dc
leal 0x1(%r12), %r14d
xorl %r13d, %r13d
movzbl 0x4(%rsp,%r13), %eax
movq 0x17178(%rip), %rcx     # 0x4e740
movsbl (%rcx,%rax), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r13
cmpq %r13, %r14
jne 0x375bb
cmpl $0x4, %r12d
movl $0x3, %ebp
cmovgel %r12d, %ebp
subl %r12d, %ebp
incl %ebp
decl %ebp
je 0x37601
movl $0x3d, %esi
movq %rbx, %rdi
callq 0x21ef0
jmp 0x375ee
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37617
jmp 0x37617
movq (%rbx), %rdi
movq %rax, %r14
cmpq %r15, %rdi
je 0x37627
callq 0x22130
movq %r14, %rdi
callq 0x23160