// File: /workspace/github_cpp_makefile_star2_O1/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
movq %rdi, %rbx
movq %rsi, 0x10(%rsp)
movl 0x8(%rsi), %r12d
leaq 0x10(%rdi), %rax
movq %rax, 0x8(%rsp)
movq %rax, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
testl %r12d, %r12d
je 0x37872
xorl %r14d, %r14d
leaq 0x17fa9(%rip), %r15     # 0x4f750
xorl %r13d, %r13d
movq 0x10(%rsp), %rax
movq (%rax), %rax
movzbl (%rax,%r14), %ebp
cmpl $0x3d, %ebp
je 0x37875
movl %ebp, %edi
callq 0x222f0
movl %ebp, %ecx
andb $-0x5, %cl
cmpb $0x2b, %cl
je 0x377d9
testl %eax, %eax
je 0x37875
movslq %r13d, %rax
incl %r13d
movb %bpl, 0x1(%rsp,%rax)
cmpl $0x4, %r13d
jne 0x37861
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 0x377ed
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
shlb $0x2, %al
movl %ecx, %edx
shrb $0x4, %dl
andb $0x3, %dl
orb %al, %dl
movb %dl, 0x5(%rsp)
shlb $0x4, %cl
movb 0x3(%rsp), %al
movl %eax, %edx
shrb $0x2, %dl
andb $0xf, %dl
orb %cl, %dl
movb %dl, 0x6(%rsp)
shlb $0x6, %al
addb 0x4(%rsp), %al
movb %al, 0x7(%rsp)
xorl %r13d, %r13d
movsbl 0x5(%rsp,%r13), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r13
cmpq $0x3, %r13
jne 0x37847
xorl %r13d, %r13d
decl %r12d
incq %r14
testl %r12d, %r12d
jne 0x377aa
jmp 0x37875
xorl %r13d, %r13d
testl %r13d, %r13d
je 0x37921
cmpl $0x3, %r13d
jg 0x3789e
movslq %r13d, %rax
leaq 0x1(%rsp,%rax), %rdi
movl $0x3, %edx
subl %r13d, %edx
incq %rdx
xorl %esi, %esi
callq 0x21910
xorl %r15d, %r15d
leaq 0x17ea8(%rip), %r14     # 0x4f750
movsbl 0x1(%rsp,%r15), %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x22760
movb %al, 0x1(%rsp,%r15)
incq %r15
cmpq $0x4, %r15
jne 0x378a8
movb 0x1(%rsp), %al
movb 0x2(%rsp), %cl
shlb $0x2, %al
movl %ecx, %edx
shrb $0x4, %dl
andb $0x3, %dl
orb %al, %dl
movb %dl, 0x5(%rsp)
shlb $0x4, %cl
movb 0x3(%rsp), %al
movl %eax, %edx
shrb $0x2, %dl
andb $0xf, %dl
orb %cl, %dl
movb %dl, 0x6(%rsp)
shlb $0x6, %al
addb 0x4(%rsp), %al
movb %al, 0x7(%rsp)
cmpl $0x2, %r13d
jl 0x37921
decl %r13d
xorl %r14d, %r14d
movsbl 0x5(%rsp,%r14), %esi
movq %rbx, %rdi
callq 0x21ef0
incq %r14
cmpq %r14, %r13
jne 0x3790b
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x37935
movq %rax, %r14
movq (%rbx), %rdi
cmpq 0x8(%rsp), %rdi
je 0x37947
callq 0x22130
movq %r14, %rdi
callq 0x23170
nop