#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
size_t ybase64_encode(const void *from, const size_t from_len, void *to,
                      const size_t to_len) {
  static const char base64_encoding_map[65] =
      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  if (NULL == from || 0 == from_len) {
    return 0;
  }
  const size_t chunk_len = from_len / 3;
  const size_t aligned_len = chunk_len * 3;
  size_t left = from_len - aligned_len;
  const size_t left_char = left ? (left + 1) : 0;
  const size_t padding = left ? (3 - left) : 0;
  const size_t need_len = left_char + chunk_len * 4 + padding + 1;
  if (NULL == to) {
    return need_len;
  }
  if (to_len < need_len) {
    return 0;
  }
  unsigned char b1, b2, b3;
  unsigned char c1, c2, c3, c4;
  unsigned int m;
  unsigned int bits;
  const unsigned char *p_from = (const unsigned char *)from;
  unsigned char *p_to = (unsigned char *)to;
  size_t i = 0, j = 0;
  for (; i < aligned_len;) {
    b1 = *(p_from + i);
    b2 = *(p_from + i + 1);
    b3 = *(p_from + i + 2);
    i += 3;
    bits = (b1 << 16) | (b2 << 8) | (b3);
    m = (bits & 0xfc0000) >> 18;
    c1 = base64_encoding_map[m];
    m = (bits & 0x3f000) >> 12;
    c2 = base64_encoding_map[m];
    m = (bits & 0xfc0) >> 6;
    c3 = base64_encoding_map[m];
    m = (bits & 0x3f);
    c4 = base64_encoding_map[m];
    if (p_to) {
      *(p_to + j) = c1;
      *(p_to + j + 1) = c2;
      *(p_to + j + 2) = c3;
      *(p_to + j + 3) = c4;
    }
    j += 4;
  }
  switch (padding) {
  case 0:
    break;
  case 2: {
    b1 = *(p_from + i);
    m = b1 >> 2;
    c1 = base64_encoding_map[m];
    m = (b1 & 0x3) << 4;
    c2 = base64_encoding_map[m];
    if (p_to) {
      *(p_to + j) = c1;
      *(p_to + j + 1) = c2;
      *(p_to + j + 2) = '=';
      *(p_to + j + 3) = '=';
    }
    j += 4;
  } break;
  case 1: {
    b1 = *(p_from + i);
    b2 = *(p_from + i + 1);
    m = b1 >> 2;
    c1 = base64_encoding_map[m];
    m = ((b1 & 0x3) << 4) | (b2 >> 4);
    c2 = base64_encoding_map[m];
    m = (b2 & 0xf) << 2;
    c3 = base64_encoding_map[m];
    if (p_to) {
      *(p_to + j) = c1;
      *(p_to + j + 1) = c2;
      *(p_to + j + 2) = c3;
      *(p_to + j + 3) = '=';
    }
    j += 4;
  } break;
  }
  *(p_to + j) = '\0';
  assert(need_len == j + 1);
  return need_len;
}


x86 assembly (clang, -O0):
<ybase64_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
je     1143 <ybase64_encode+0x33>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1150 <ybase64_encode+0x40>
movq   $0x0,-0x8(%rbp)
jmp    15ad <ybase64_encode+0x49d>
mov    -0x18(%rbp),%rax
mov    $0x3,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
imul   $0x3,-0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1196 <ybase64_encode+0x86>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x90(%rbp)
jmp    11a4 <ybase64_encode+0x94>
xor    %eax,%eax
mov    %rax,-0x90(%rbp)
jmp    11a4 <ybase64_encode+0x94>
mov    -0x90(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     11cf <ybase64_encode+0xbf>
mov    $0x3,%eax
sub    -0x40(%rbp),%rax
mov    %rax,-0x98(%rbp)
jmp    11dd <ybase64_encode+0xcd>
xor    %eax,%eax
mov    %rax,-0x98(%rbp)
jmp    11dd <ybase64_encode+0xcd>
mov    -0x98(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
add    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    121c <ybase64_encode+0x10c>
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    15ad <ybase64_encode+0x49d>
mov    -0x28(%rbp),%rax
cmp    -0x58(%rbp),%rax
jae    1237 <ybase64_encode+0x127>
movq   $0x0,-0x8(%rbp)
jmp    15ad <ybase64_encode+0x49d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
mov    -0x80(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    139d <ybase64_encode+0x28d>
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x59(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    0x1(%rax,%rcx,1),%al
mov    %al,-0x5a(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    0x2(%rax,%rcx,1),%al
mov    %al,-0x5b(%rbp)
mov    -0x80(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x80(%rbp)
movzbl -0x59(%rbp),%eax
shl    $0x10,%eax
movzbl -0x5a(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movzbl -0x5b(%rbp),%ecx
or     %ecx,%eax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
and    $0xfc0000,%eax
shr    $0x12,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xd2d(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5c(%rbp)
mov    -0x68(%rbp),%eax
and    $0x3f000,%eax
shr    $0xc,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xd0d(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5d(%rbp)
mov    -0x68(%rbp),%eax
and    $0xfc0,%eax
shr    $0x6,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xced(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5e(%rbp)
mov    -0x68(%rbp),%eax
and    $0x3f,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xcd2(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5f(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1386 <ybase64_encode+0x276>
mov    -0x5c(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x5d(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x1(%rax,%rcx,1)
mov    -0x5e(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x2(%rax,%rcx,1)
mov    -0x5f(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x3(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x88(%rbp)
jmp    125a <ybase64_encode+0x14a>
mov    -0x50(%rbp),%rax
mov    %rax,-0xa0(%rbp)
test   %rax,%rax
je     13e2 <ybase64_encode+0x2d2>
jmp    13b6 <ybase64_encode+0x2a6>
mov    -0xa0(%rbp),%rax
sub    $0x1,%rax
je     1495 <ybase64_encode+0x385>
jmp    13cc <ybase64_encode+0x2bc>
mov    -0xa0(%rbp),%rax
sub    $0x2,%rax
je     13e7 <ybase64_encode+0x2d7>
jmp    1577 <ybase64_encode+0x467>
jmp    1577 <ybase64_encode+0x467>
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x59(%rbp)
movzbl -0x59(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xbf5(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5c(%rbp)
movzbl -0x59(%rbp),%eax
and    $0x3,%eax
shl    $0x4,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xbd6(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5d(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     147e <ybase64_encode+0x36e>
mov    -0x5c(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x5d(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x1(%rax,%rcx,1)
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
movb   $0x3d,0x2(%rax,%rcx,1)
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
movb   $0x3d,0x3(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x88(%rbp)
jmp    1577 <ybase64_encode+0x467>
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x59(%rbp)
mov    -0x70(%rbp),%rax
mov    -0x80(%rbp),%rcx
mov    0x1(%rax,%rcx,1),%al
mov    %al,-0x5a(%rbp)
movzbl -0x59(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xb38(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5c(%rbp)
movzbl -0x59(%rbp),%eax
and    $0x3,%eax
shl    $0x4,%eax
movzbl -0x5a(%rbp),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xb10(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5d(%rbp)
movzbl -0x5a(%rbp),%eax
and    $0xf,%eax
shl    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,%ecx
lea    0xaf1(%rip),%rax
mov    (%rax,%rcx,1),%al
mov    %al,-0x5e(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     1565 <ybase64_encode+0x455>
mov    -0x5c(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x5d(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x1(%rax,%rcx,1)
mov    -0x5e(%rbp),%dl
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
mov    %dl,0x2(%rax,%rcx,1)
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
movb   $0x3d,0x3(%rax,%rcx,1)
mov    -0x88(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x88(%rbp)
mov    -0x78(%rbp),%rax
mov    -0x88(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rax
mov    -0x88(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ybase64_encode>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %rdi,%rdi
je     1287 <ybase64_encode+0x177>
test   %rsi,%rsi
je     1287 <ybase64_encode+0x177>
mov    %rdx,%r11
movabs $0xaaaaaaaaaaaaaaab,%rdx
aa aa aa
mov    %rsi,%rax
mul    %rdx
shr    %rdx
lea    (%rdx,%rdx,2),%r10
mov    %rsi,%rax
sub    %r10,%rax
lea    0x1(%rax),%r9
mov    $0x3,%r8d
sub    %rax,%r8
test   %rax,%rax
cmove  %rax,%r9
cmove  %rax,%r8
lea    (%r9,%rdx,4),%r9
lea    (%r8,%r9,1),%r14
add    $0x1,%r14
test   %r11,%r11
je     1287 <ybase64_encode+0x177>
cmp    %rcx,%r14
jbe    1187 <ybase64_encode+0x77>
xor    %r14d,%r14d
jmp    1287 <ybase64_encode+0x177>
cmp    $0x3,%rsi
jae    1194 <ybase64_encode+0x84>
xor    %esi,%esi
xor    %r12d,%r12d
jmp    1201 <ybase64_encode+0xf1>
xor    %r12d,%r12d
lea    0xe62(%rip),%r15
xor    %esi,%esi
movzbl (%rdi,%rsi,1),%ecx
movzbl 0x1(%rdi,%rsi,1),%ebx
movzbl 0x2(%rdi,%rsi,1),%edx
add    $0x3,%rsi
mov    %ecx,%eax
shl    $0x10,%eax
shl    $0x8,%ebx
or     %ebx,%eax
or     %edx,%ebx
and    $0x3f,%edx
movzbl (%rdx,%r15,1),%edx
shr    $0x6,%ebx
and    $0x3f,%ebx
movzbl (%rbx,%r15,1),%ebx
shr    $0xc,%eax
and    $0x3f,%eax
movzbl (%rax,%r15,1),%eax
shr    $0x2,%rcx
movzbl (%rcx,%r15,1),%ecx
mov    %cl,(%r11,%r12,1)
mov    %al,0x1(%r11,%r12,1)
mov    %bl,0x2(%r11,%r12,1)
mov    %dl,0x3(%r11,%r12,1)
add    $0x4,%r12
cmp    %r10,%rsi
jb     11a0 <ybase64_encode+0x90>
add    %r8,%r9
cmp    $0x1,%r8
je     1221 <ybase64_encode+0x111>
cmp    $0x2,%r8
jne    1274 <ybase64_encode+0x164>
movzbl (%rdi,%rsi,1),%eax
mov    %eax,%edx
shl    $0x4,%edx
and    $0x30,%edx
mov    $0x3d,%sil
jmp    1247 <ybase64_encode+0x137>
movzbl (%rdi,%rsi,1),%eax
movzbl 0x1(%rdi,%rsi,1),%edx
mov    %edx,%ecx
and    $0xf,%ecx
lea    0xdca(%rip),%rsi
mov    (%rsi,%rcx,4),%sil
mov    %eax,%ecx
shl    $0x4,%ecx
and    $0x30,%ecx
shr    $0x4,%edx
or     %ecx,%edx
mov    %edx,%ecx
lea    0xdb0(%rip),%rdx
mov    (%rcx,%rdx,1),%cl
mov    %eax,%eax
shr    $0x2,%rax
mov    (%rax,%rdx,1),%al
mov    %al,(%r11,%r12,1)
mov    %cl,0x1(%r11,%r12,1)
mov    %sil,0x2(%r11,%r12,1)
movb   $0x3d,0x3(%r11,%r12,1)
add    $0x4,%r12
movb   $0x0,(%r11,%r12,1)
xor    %edi,%edi
cmp    %r12,%r9
sete   %dil
call   1030 <assert@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ybase64_encode.base64_encoding_map = internal constant [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define i64 @ybase64_encode(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
%19 = alloca i8
%20 = alloca i8
%21 = alloca i8
%22 = alloca i8
%23 = alloca i32
%24 = alloca i32
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i64
%28 = alloca i64
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%29 = load i8*, i8** %6
%30 = icmp eq i8* null, %29
br i1 %30, label %34, label %31
31: ; preds = %4
%32 = load i64, i64* %7
%33 = icmp eq i64 0, %32
br i1 %33, label %34, label %35
34: ; preds = %31, %4
store i64 0, i64* %5
br label %279
35: ; preds = %31
%36 = load i64, i64* %7
%37 = udiv i64 %36, 3
store i64 %37, i64* %10
%38 = load i64, i64* %10
%39 = mul i64 %38, 3
store i64 %39, i64* %11
%40 = load i64, i64* %7
%41 = load i64, i64* %11
%42 = sub i64 %40, %41
store i64 %42, i64* %12
%43 = load i64, i64* %12
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %35
%46 = load i64, i64* %12
%47 = add i64 %46, 1
br label %49
48: ; preds = %35
br label %49
49: ; preds = %48, %45
%50 = phi i64 [ %47, %45 ], [ 0, %48 ]
store i64 %50, i64* %13
%51 = load i64, i64* %12
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load i64, i64* %12
%55 = sub i64 3, %54
br label %57
56: ; preds = %49
br label %57
57: ; preds = %56, %53
%58 = phi i64 [ %55, %53 ], [ 0, %56 ]
store i64 %58, i64* %14
%59 = load i64, i64* %13
%60 = load i64, i64* %10
%61 = mul i64 %60, 4
%62 = add i64 %59, %61
%63 = load i64, i64* %14
%64 = add i64 %62, %63
%65 = add i64 %64, 1
store i64 %65, i64* %15
%66 = load i8*, i8** %8
%67 = icmp eq i8* null, %66
br i1 %67, label %68, label %70
68: ; preds = %57
%69 = load i64, i64* %15
store i64 %69, i64* %5
br label %279
70: ; preds = %57
%71 = load i64, i64* %9
%72 = load i64, i64* %15
%73 = icmp ult i64 %71, %72
br i1 %73, label %74, label %75
74: ; preds = %70
store i64 0, i64* %5
br label %279
75: ; preds = %70
%76 = load i8*, i8** %6
store i8* %76, i8** %25
%77 = load i8*, i8** %8
store i8* %77, i8** %26
store i64 0, i64* %27
store i64 0, i64* %28
br label %78
78: ; preds = %158, %75
%79 = load i64, i64* %27
%80 = load i64, i64* %11
%81 = icmp ult i64 %79, %80
br i1 %81, label %82, label %161
82: ; preds = %78
%83 = load i8*, i8** %25
%84 = load i64, i64* %27
%85 = getelementptr inbounds i8, i8* %83, i64 %84
%86 = load i8, i8* %85
store i8 %86, i8* %16
%87 = load i8*, i8** %25
%88 = load i64, i64* %27
%89 = getelementptr inbounds i8, i8* %87, i64 %88
%90 = getelementptr inbounds i8, i8* %89, i64 1
%91 = load i8, i8* %90
store i8 %91, i8* %17
%92 = load i8*, i8** %25
%93 = load i64, i64* %27
%94 = getelementptr inbounds i8, i8* %92, i64 %93
%95 = getelementptr inbounds i8, i8* %94, i64 2
%96 = load i8, i8* %95
store i8 %96, i8* %18
%97 = load i64, i64* %27
%98 = add i64 %97, 3
store i64 %98, i64* %27
%99 = load i8, i8* %16
%100 = zext i8 %99 to i32
%101 = shl i32 %100, 16
%102 = load i8, i8* %17
%103 = zext i8 %102 to i32
%104 = shl i32 %103, 8
%105 = or i32 %101, %104
%106 = load i8, i8* %18
%107 = zext i8 %106 to i32
%108 = or i32 %105, %107
store i32 %108, i32* %24
%109 = load i32, i32* %24
%110 = and i32 %109, 16515072
%111 = lshr i32 %110, 18
store i32 %111, i32* %23
%112 = load i32, i32* %23
%113 = zext i32 %112 to i64
%114 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %113
%115 = load i8, i8* %114
store i8 %115, i8* %19
%116 = load i32, i32* %24
%117 = and i32 %116, 258048
%118 = lshr i32 %117, 12
store i32 %118, i32* %23
%119 = load i32, i32* %23
%120 = zext i32 %119 to i64
%121 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %120
%122 = load i8, i8* %121
store i8 %122, i8* %20
%123 = load i32, i32* %24
%124 = and i32 %123, 4032
%125 = lshr i32 %124, 6
store i32 %125, i32* %23
%126 = load i32, i32* %23
%127 = zext i32 %126 to i64
%128 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %127
%129 = load i8, i8* %128
store i8 %129, i8* %21
%130 = load i32, i32* %24
%131 = and i32 %130, 63
store i32 %131, i32* %23
%132 = load i32, i32* %23
%133 = zext i32 %132 to i64
%134 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %133
%135 = load i8, i8* %134
store i8 %135, i8* %22
%136 = load i8*, i8** %26
%137 = icmp ne i8* %136, null
br i1 %137, label %138, label %158
138: ; preds = %82
%139 = load i8, i8* %19
%140 = load i8*, i8** %26
%141 = load i64, i64* %28
%142 = getelementptr inbounds i8, i8* %140, i64 %141
store i8 %139, i8* %142
%143 = load i8, i8* %20
%144 = load i8*, i8** %26
%145 = load i64, i64* %28
%146 = getelementptr inbounds i8, i8* %144, i64 %145
%147 = getelementptr inbounds i8, i8* %146, i64 1
store i8 %143, i8* %147
%148 = load i8, i8* %21
%149 = load i8*, i8** %26
%150 = load i64, i64* %28
%151 = getelementptr inbounds i8, i8* %149, i64 %150
%152 = getelementptr inbounds i8, i8* %151, i64 2
store i8 %148, i8* %152
%153 = load i8, i8* %22
%154 = load i8*, i8** %26
%155 = load i64, i64* %28
%156 = getelementptr inbounds i8, i8* %154, i64 %155
%157 = getelementptr inbounds i8, i8* %156, i64 3
store i8 %153, i8* %157
br label %158
158: ; preds = %138, %82
%159 = load i64, i64* %28
%160 = add i64 %159, 4
store i64 %160, i64* %28
br label %78
161: ; preds = %78
%162 = load i64, i64* %14
switch i64 %162, label %268 [
i64 0, label %163
i64 2, label %164
i64 1, label %207
]
163: ; preds = %161
br label %268
164: ; preds = %161
%165 = load i8*, i8** %25
%166 = load i64, i64* %27
%167 = getelementptr inbounds i8, i8* %165, i64 %166
%168 = load i8, i8* %167
store i8 %168, i8* %16
%169 = load i8, i8* %16
%170 = zext i8 %169 to i32
%171 = ashr i32 %170, 2
store i32 %171, i32* %23
%172 = load i32, i32* %23
%173 = zext i32 %172 to i64
%174 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %173
%175 = load i8, i8* %174
store i8 %175, i8* %19
%176 = load i8, i8* %16
%177 = zext i8 %176 to i32
%178 = and i32 %177, 3
%179 = shl i32 %178, 4
store i32 %179, i32* %23
%180 = load i32, i32* %23
%181 = zext i32 %180 to i64
%182 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %181
%183 = load i8, i8* %182
store i8 %183, i8* %20
%184 = load i8*, i8** %26
%185 = icmp ne i8* %184, null
br i1 %185, label %186, label %204
186: ; preds = %164
%187 = load i8, i8* %19
%188 = load i8*, i8** %26
%189 = load i64, i64* %28
%190 = getelementptr inbounds i8, i8* %188, i64 %189
store i8 %187, i8* %190
%191 = load i8, i8* %20
%192 = load i8*, i8** %26
%193 = load i64, i64* %28
%194 = getelementptr inbounds i8, i8* %192, i64 %193
%195 = getelementptr inbounds i8, i8* %194, i64 1
store i8 %191, i8* %195
%196 = load i8*, i8** %26
%197 = load i64, i64* %28
%198 = getelementptr inbounds i8, i8* %196, i64 %197
%199 = getelementptr inbounds i8, i8* %198, i64 2
store i8 61, i8* %199
%200 = load i8*, i8** %26
%201 = load i64, i64* %28
%202 = getelementptr inbounds i8, i8* %200, i64 %201
%203 = getelementptr inbounds i8, i8* %202, i64 3
store i8 61, i8* %203
br label %204
204: ; preds = %186, %164
%205 = load i64, i64* %28
%206 = add i64 %205, 4
store i64 %206, i64* %28
br label %268
207: ; preds = %161
%208 = load i8*, i8** %25
%209 = load i64, i64* %27
%210 = getelementptr inbounds i8, i8* %208, i64 %209
%211 = load i8, i8* %210
store i8 %211, i8* %16
%212 = load i8*, i8** %25
%213 = load i64, i64* %27
%214 = getelementptr inbounds i8, i8* %212, i64 %213
%215 = getelementptr inbounds i8, i8* %214, i64 1
%216 = load i8, i8* %215
store i8 %216, i8* %17
%217 = load i8, i8* %16
%218 = zext i8 %217 to i32
%219 = ashr i32 %218, 2
store i32 %219, i32* %23
%220 = load i32, i32* %23
%221 = zext i32 %220 to i64
%222 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %221
%223 = load i8, i8* %222
store i8 %223, i8* %19
%224 = load i8, i8* %16
%225 = zext i8 %224 to i32
%226 = and i32 %225, 3
%227 = shl i32 %226, 4
%228 = load i8, i8* %17
%229 = zext i8 %228 to i32
%230 = ashr i32 %229, 4
%231 = or i32 %227, %230
store i32 %231, i32* %23
%232 = load i32, i32* %23
%233 = zext i32 %232 to i64
%234 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %233
%235 = load i8, i8* %234
store i8 %235, i8* %20
%236 = load i8, i8* %17
%237 = zext i8 %236 to i32
%238 = and i32 %237, 15
%239 = shl i32 %238, 2
store i32 %239, i32* %23
%240 = load i32, i32* %23
%241 = zext i32 %240 to i64
%242 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %241
%243 = load i8, i8* %242
store i8 %243, i8* %21
%244 = load i8*, i8** %26
%245 = icmp ne i8* %244, null
br i1 %245, label %246, label %265
246: ; preds = %207
%247 = load i8, i8* %19
%248 = load i8*, i8** %26
%249 = load i64, i64* %28
%250 = getelementptr inbounds i8, i8* %248, i64 %249
store i8 %247, i8* %250
%251 = load i8, i8* %20
%252 = load i8*, i8** %26
%253 = load i64, i64* %28
%254 = getelementptr inbounds i8, i8* %252, i64 %253
%255 = getelementptr inbounds i8, i8* %254, i64 1
store i8 %251, i8* %255
%256 = load i8, i8* %21
%257 = load i8*, i8** %26
%258 = load i64, i64* %28
%259 = getelementptr inbounds i8, i8* %257, i64 %258
%260 = getelementptr inbounds i8, i8* %259, i64 2
store i8 %256, i8* %260
%261 = load i8*, i8** %26
%262 = load i64, i64* %28
%263 = getelementptr inbounds i8, i8* %261, i64 %262
%264 = getelementptr inbounds i8, i8* %263, i64 3
store i8 61, i8* %264
br label %265
265: ; preds = %246, %207
%266 = load i64, i64* %28
%267 = add i64 %266, 4
store i64 %267, i64* %28
br label %268
268: ; preds = %161, %265, %204, %163
%269 = load i8*, i8** %26
%270 = load i64, i64* %28
%271 = getelementptr inbounds i8, i8* %269, i64 %270
store i8 0, i8* %271
%272 = load i64, i64* %15
%273 = load i64, i64* %28
%274 = add i64 %273, 1
%275 = icmp eq i64 %272, %274
%276 = zext i1 %275 to i32
%277 = call i32 @assert(i32 %276)
%278 = load i64, i64* %15
store i64 %278, i64* %5
br label %279
279: ; preds = %268, %74, %68, %34
%280 = load i64, i64* %5
ret i64 %280
}

LLVM IR (-O2):
@ybase64_encode.base64_encoding_map = internal unnamed_addr constant [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define i64 @ybase64_encode(i8* %0, i64 %1, i8* writeonly %2, i64 %3) {
%5 = icmp eq i8* %0, null
%6 = icmp eq i64 %1, 0
%7 = or i1 %5, %6
br i1 %7, label %117, label %8
8: ; preds = %4
%9 = udiv i64 %1, 3
%10 = mul nuw i64 %9, 3
%11 = urem i64 %1, 3
%12 = icmp eq i64 %11, 0
%13 = add i64 %11, 1
%14 = select i1 %12, i64 0, i64 %13
%15 = sub i64 3, %11
%16 = select i1 %12, i64 0, i64 %15
%17 = shl i64 %9, 2
%18 = add i64 %14, %17
%19 = add i64 %18, %16
%20 = add i64 %19, 1
%21 = icmp eq i8* %2, null
br i1 %21, label %117, label %22
22: ; preds = %8
%23 = icmp ugt i64 %20, %3
br i1 %23, label %117, label %24
24: ; preds = %22
%25 = icmp ult i64 %1, 3
br i1 %25, label %67, label %26
26: ; preds = %24, %26
%27 = phi i64 [ %65, %26 ], [ 0, %24 ]
%28 = phi i64 [ %35, %26 ], [ 0, %24 ]
%29 = getelementptr inbounds i8, i8* %0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %29, i64 1
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %29, i64 2
%34 = load i8, i8* %33
%35 = add i64 %28, 3
%36 = zext i8 %30 to i32
%37 = zext i8 %32 to i32
%38 = shl nuw nsw i32 %37, 8
%39 = zext i8 %34 to i32
%40 = shl nuw nsw i32 %36, 16
%41 = or i32 %38, %40
%42 = and i32 %39, 63
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = or i32 %38, %39
%47 = lshr i32 %46, 6
%48 = and i32 %47, 63
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = lshr i32 %41, 12
%53 = and i32 %52, 63
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = lshr i32 %36, 2
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %58
%60 = load i8, i8* %59
%61 = getelementptr inbounds i8, i8* %2, i64 %27
store i8 %60, i8* %61
%62 = getelementptr inbounds i8, i8* %61, i64 1
store i8 %56, i8* %62
%63 = getelementptr inbounds i8, i8* %61, i64 2
store i8 %51, i8* %63
%64 = getelementptr inbounds i8, i8* %61, i64 3
store i8 %45, i8* %64
%65 = add i64 %27, 4
%66 = icmp ult i64 %35, %10
br i1 %66, label %26, label %67
67: ; preds = %26, %24
%68 = phi i64 [ 0, %24 ], [ %35, %26 ]
%69 = phi i64 [ 0, %24 ], [ %65, %26 ]
switch i64 %16, label %111 [
i64 1, label %76
i64 2, label %70
]
70: ; preds = %67
%71 = getelementptr inbounds i8, i8* %0, i64 %68
%72 = load i8, i8* %71
%73 = zext i8 %72 to i32
%74 = shl nuw nsw i32 %73, 4
%75 = and i32 %74, 48
br label %92
76: ; preds = %67
%77 = getelementptr inbounds i8, i8* %0, i64 %68
%78 = load i8, i8* %77
%79 = getelementptr inbounds i8, i8* %77, i64 1
%80 = load i8, i8* %79
%81 = zext i8 %78 to i32
%82 = zext i8 %80 to i32
%83 = shl nuw nsw i32 %82, 2
%84 = and i32 %83, 60
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = shl nuw nsw i32 %81, 4
%89 = and i32 %88, 48
%90 = lshr i32 %82, 4
%91 = or i32 %89, %90
br label %92
92: ; preds = %70, %76
%93 = phi i32 [ %73, %70 ], [ %81, %76 ]
%94 = phi i32 [ %75, %70 ], [ %91, %76 ]
%95 = phi i8 [ 61, %70 ], [ %87, %76 ]
%96 = zext i32 %94 to i64
%97 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %96
%98 = load i8, i8* %97
%99 = lshr i32 %93, 2
%100 = zext i32 %99 to i64
%101 = getelementptr inbounds [65 x i8], [65 x i8]* @ybase64_encode.base64_encoding_map, i64 0, i64 %100
%102 = load i8, i8* %101
%103 = getelementptr inbounds i8, i8* %2, i64 %69
store i8 %102, i8* %103
%104 = getelementptr inbounds i8, i8* %2, i64 %69
%105 = getelementptr inbounds i8, i8* %2, i64 %69
%106 = getelementptr inbounds i8, i8* %2, i64 %69
%107 = getelementptr inbounds i8, i8* %106, i64 1
store i8 %98, i8* %107
%108 = getelementptr inbounds i8, i8* %105, i64 2
store i8 %95, i8* %108
%109 = getelementptr inbounds i8, i8* %104, i64 3
store i8 61, i8* %109
%110 = add i64 %69, 4
br label %111
111: ; preds = %92, %67
%112 = phi i64 [ %69, %67 ], [ %110, %92 ]
%113 = getelementptr inbounds i8, i8* %2, i64 %112
store i8 0, i8* %113
%114 = icmp eq i64 %19, %112
%115 = zext i1 %114 to i32
%116 = tail call i32 @assert(i32 %115)
br label %117
117: ; preds = %111, %8, %22, %4
%118 = phi i64 [ 0, %4 ], [ %20, %111 ], [ %20, %8 ], [ 0, %22 ]
ret i64 %118
}