#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 */
char _get_base64_char(unsigned char);
void _write_base64_unit(char *str, unsigned char *buffer) {
  str[0] = _get_base64_char(buffer[0] >> 2);
  str[1] = _get_base64_char(((buffer[0] << 4) | (buffer[1] >> 4)) & 0x3f);
  str[2] = _get_base64_char(((buffer[1] << 2) | (buffer[2] >> 6)) & 0x3f);
  str[3] = _get_base64_char(buffer[2] & 0x3f);
}


x86 assembly (clang, -O0):
<_write_base64_unit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
sar    $0x2,%eax
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
shl    $0x4,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
and    $0x3f,%eax
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%eax
shl    $0x2,%eax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
sar    $0x6,%ecx
or     %ecx,%eax
and    $0x3f,%eax
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0x3f,%eax
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,0x3(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_write_base64_unit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%al
shr    $0x2,%al
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,(%r14)
mov    (%rbx),%al
mov    0x1(%rbx),%cl
shr    $0x4,%cl
shl    $0x4,%al
or     %cl,%al
and    $0x3f,%al
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,0x1(%r14)
mov    0x1(%rbx),%al
mov    0x2(%rbx),%cl
shr    $0x6,%cl
shl    $0x2,%al
or     %cl,%al
and    $0x3f,%al
movzbl %al,%edi
call   1030 <_get_base64_char@plt>
mov    %al,0x2(%r14)
movzbl 0x2(%rbx),%edi
and    $0x3f,%edi
call   1030 <_get_base64_char@plt>
mov    %al,0x3(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @_write_base64_unit(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = ashr i32 %8, 2
%10 = trunc i32 %9 to i8
%11 = call signext i8 @_get_base64_char(i8 zeroext %10)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = shl i32 %17, 4
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = ashr i32 %22, 4
%24 = or i32 %18, %23
%25 = and i32 %24, 63
%26 = trunc i32 %25 to i8
%27 = call signext i8 @_get_base64_char(i8 zeroext %26)
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 %27, i8* %29
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 2
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = ashr i32 %38, 6
%40 = or i32 %34, %39
%41 = and i32 %40, 63
%42 = trunc i32 %41 to i8
%43 = call signext i8 @_get_base64_char(i8 zeroext %42)
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 2
store i8 %43, i8* %45
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 2
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = and i32 %49, 63
%51 = trunc i32 %50 to i8
%52 = call signext i8 @_get_base64_char(i8 zeroext %51)
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 3
store i8 %52, i8* %54
ret void
}

LLVM IR (-O2):
define void @_write_base64_unit(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = lshr i8 %3, 2
%5 = tail call signext i8 @_get_base64_char(i8 zeroext %4)
store i8 %5, i8* %0
%6 = load i8, i8* %1
%7 = shl i8 %6, 4
%8 = getelementptr inbounds i8, i8* %1, i64 1
%9 = load i8, i8* %8
%10 = lshr i8 %9, 4
%11 = and i8 %7, 48
%12 = or i8 %11, %10
%13 = tail call signext i8 @_get_base64_char(i8 zeroext %12)
%14 = getelementptr inbounds i8, i8* %0, i64 1
store i8 %13, i8* %14
%15 = load i8, i8* %8
%16 = shl i8 %15, 2
%17 = getelementptr inbounds i8, i8* %1, i64 2
%18 = load i8, i8* %17
%19 = lshr i8 %18, 6
%20 = and i8 %16, 60
%21 = or i8 %20, %19
%22 = tail call signext i8 @_get_base64_char(i8 zeroext %21)
%23 = getelementptr inbounds i8, i8* %0, i64 2
store i8 %22, i8* %23
%24 = load i8, i8* %17
%25 = and i8 %24, 63
%26 = tail call signext i8 @_get_base64_char(i8 zeroext %25)
%27 = getelementptr inbounds i8, i8* %0, i64 3
store i8 %26, i8* %27
ret void
}