// File: /workspace/github_cpp_makefile_star2_O3/alfanick[P]rest-cpp/src/rest/utils.cpp
// Function: REST::Utils::base64_decode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string base64_decode(std::string const& encoded_string) {
  int in_len = encoded_string.size();
  int i = 0;
  int j = 0;
  int in_ = 0;
  unsigned char char_array_4[4], char_array_3[3];
  std::string ret;

  while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
    char_array_4[i++] = encoded_string[in_]; in_++;
    if (i ==4) {
      for (i = 0; i <4; i++)
        char_array_4[i] = base64_chars.find(char_array_4[i]);

      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];

      for (i = 0; (i < 3); i++)
        ret += char_array_3[i];
      i = 0;
    }
  }

  if (i) {
    for (j = i; j <4; j++)
      char_array_4[j] = 0;

    for (j = 0; j <4; j++)
      char_array_4[j] = base64_chars.find(char_array_4[j]);

    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
    char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
    char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];

    for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
  }

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x8(%rsi), %r12d
leaq 0x10(%rdi), %rax
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movq %rax, 0x8(%rsp)
movb $0x0, 0x10(%rdi)
testl %r12d, %r12d
je 0x377f1
leaq 0x170cf(%rip), %r15     # 0x4e740
xorl %r14d, %r14d
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq (%rax), %rax
movzbl (%rax,%r14), %ebp
cmpl $0x3d, %ebp
je 0x37741
movl %ebp, %edi
callq 0x222f0
movl %ebp, %ecx
andb $-0x5, %cl
cmpb $0x2b, %cl
je 0x376a6
testl %eax, %eax
je 0x37741
movslq %r13d, %rax
incl %r13d
movb %bpl, 0x1(%rsp,%rax)
cmpl $0x4, %r13d
jne 0x37732
xorl %r13d, %r13d
movsbl 0x1(%rsp,%r13), %esi
movq %r15, %rdi
xorl %edx, %edx
callq 0x22760
movb %al, 0x1(%rsp,%r13)
incq %r13
cmpq $0x4, %r13
jne 0x376ba
movb 0x2(%rsp), %cl
movb 0x1(%rsp), %al
movb 0x3(%rsp), %sil
xorl %r13d, %r13d
movl %ecx, %edx
shlb $0x2, %al
shlb $0x4, %cl
shrb $0x4, %dl
andb $0x3, %dl
orb %al, %dl
movb %dl, 0x5(%rsp)
movl %esi, %edx
shlb $0x6, %sil
addb 0x4(%rsp), %sil
shrb $0x2, %dl
andb $0xf, %dl
orb %cl, %dl
movb %dl, 0x6(%rsp)
movb %sil, 0x7(%rsp)
movsbl 0x5(%rsp,%r13), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r13
cmpq $0x3, %r13
jne 0x37718
xorl %r13d, %r13d
decl %r12d
incq %r14
testl %r12d, %r12d
jne 0x37677
testl %r13d, %r13d
je 0x377f1
cmpl $0x3, %r13d
jg 0x3776a
movl $0x3, %edx
movslq %r13d, %rax
xorl %esi, %esi
subl %r13d, %edx
leaq 0x1(%rsp,%rax), %rdi
incq %rdx
callq 0x21910
leaq 0x16fcf(%rip), %r14     # 0x4e740
xorl %r15d, %r15d
movsbl 0x1(%rsp,%r15), %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x22760
movb %al, 0x1(%rsp,%r15)
incq %r15
cmpq $0x4, %r15
jne 0x37774
movb 0x2(%rsp), %cl
movb 0x1(%rsp), %al
movb 0x3(%rsp), %sil
movl %ecx, %edx
shlb $0x2, %al
shlb $0x4, %cl
shrb $0x4, %dl
andb $0x3, %dl
orb %al, %dl
movb %dl, 0x5(%rsp)
movl %esi, %edx
shlb $0x6, %sil
addb 0x4(%rsp), %sil
shrb $0x2, %dl
andb $0xf, %dl
orb %cl, %dl
movb %dl, 0x6(%rsp)
movb %sil, 0x7(%rsp)
cmpl $0x2, %r13d
jl 0x377f1
decl %r13d
xorl %r14d, %r14d
movsbl 0x5(%rsp,%r14), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r14
cmpq %r14, %r13
jne 0x377db
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37805
movq (%rbx), %rdi
movq %rax, %r14
cmpq 0x8(%rsp), %rdi
je 0x37817
callq 0x22130
movq %r14, %rdi
callq 0x23160
nop