void string_convbase64_8x3_to_6x4(const char *from, char *to) {
  unsigned char base64_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                                 "abcdefghijklmnopqrstuvwxyz0123456789+/";
  to[0] = base64_table[(from[0] & 0xfc) >> 2];
  to[1] = base64_table[((from[0] & 0x03) << 4) + ((from[1] & 0xf0) >> 4)];
  to[2] = base64_table[((from[1] & 0x0f) << 2) + ((from[2] & 0xc0) >> 6)];
  to[3] = base64_table[from[2] & 0x3f];
}


x86 assembly (clang, -O0):
<string_convbase64_8x3_to_6x4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xed5(%rip),%rsi
mov    $0x41,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xfc,%eax
sar    $0x2,%eax
cltq
mov    -0x60(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0x3,%eax
shl    $0x4,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
and    $0xf0,%ecx
sar    $0x4,%ecx
add    %ecx,%eax
cltq
mov    -0x60(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
and    $0xf,%eax
shl    $0x2,%eax
mov    -0x8(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
and    $0xc0,%ecx
sar    $0x6,%ecx
add    %ecx,%eax
cltq
mov    -0x60(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
and    $0x3f,%eax
cltq
mov    -0x60(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_convbase64_8x3_to_6x4>:
movzbl (%rdi),%ecx
shr    $0x2,%rcx
lea    0xef2(%rip),%rax
mov    (%rcx,%rax,1),%cl
mov    %cl,(%rsi)
movzbl (%rdi),%ecx
shl    $0x4,%ecx
and    $0x30,%ecx
movzbl 0x1(%rdi),%edx
shr    $0x4,%rdx
or     %rcx,%rdx
mov    (%rax,%rdx,1),%cl
mov    %cl,0x1(%rsi)
movzbl 0x1(%rdi),%ecx
and    $0xf,%ecx
movzbl 0x2(%rdi),%edx
shr    $0x6,%rdx
lea    (%rdx,%rcx,4),%rcx
mov    (%rax,%rcx,1),%cl
mov    %cl,0x2(%rsi)
movzbl 0x2(%rdi),%ecx
and    $0x3f,%ecx
mov    (%rcx,%rax,1),%al
mov    %al,0x3(%rsi)
ret

LLVM IR (-O0):
@__const.string_convbase64_8x3_to_6x4.base64_table = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define void @string_convbase64_8x3_to_6x4(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [65 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = bitcast [65 x i8]* %5 to i8*
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = and i32 %10, 252
%12 = ashr i32 %11, 2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 0
store i8 %15, i8* %17
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = and i32 %21, 3
%23 = shl i32 %22, 4
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = and i32 %27, 240
%29 = ashr i32 %28, 4
%30 = add nsw i32 %23, %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8 %33, i8* %35
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = and i32 %39, 15
%41 = shl i32 %40, 2
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = and i32 %45, 192
%47 = ashr i32 %46, 6
%48 = add nsw i32 %41, %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 %49
%51 = load i8, i8* %50
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i64 2
store i8 %51, i8* %53
%54 = load i8*, i8** %3
%55 = getelementptr inbounds i8, i8* %54, i64 2
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = and i32 %57, 63
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 %59
%61 = load i8, i8* %60
%62 = load i8*, i8** %4
%63 = getelementptr inbounds i8, i8* %62, i64 3
store i8 %61, i8* %63
ret void
}

LLVM IR (-O2):
@__const.string_convbase64_8x3_to_6x4.base64_table = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\00"
define void @string_convbase64_8x3_to_6x4(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = lshr i8 %3, 2
%5 = zext i8 %4 to i64
%6 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.string_convbase64_8x3_to_6x4.base64_table, i64 0, i64 %5
%7 = load i8, i8* %6
store i8 %7, i8* %1
%8 = load i8, i8* %0
%9 = shl i8 %8, 4
%10 = and i8 %9, 48
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = lshr i8 %12, 4
%14 = or i8 %10, %13
%15 = zext i8 %14 to i64
%16 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.string_convbase64_8x3_to_6x4.base64_table, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %17, i8* %18
%19 = load i8, i8* %11
%20 = shl i8 %19, 2
%21 = and i8 %20, 60
%22 = getelementptr inbounds i8, i8* %0, i64 2
%23 = load i8, i8* %22
%24 = lshr i8 %23, 6
%25 = or i8 %21, %24
%26 = zext i8 %25 to i64
%27 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.string_convbase64_8x3_to_6x4.base64_table, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %28, i8* %29
%30 = load i8, i8* %22
%31 = and i8 %30, 63
%32 = zext i8 %31 to i64
%33 = getelementptr inbounds [65 x i8], [65 x i8]* @__const.string_convbase64_8x3_to_6x4.base64_table, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %34, i8* %35
ret void
}