#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 char64(unsigned char);
void encoder(unsigned char *in, char *out) {
  out[0] = char64(in[0] >> 2);
  out[1] = char64((in[0] << 4) | (in[1] >> 4));
  out[2] = char64((in[1] << 2) | (in[2] >> 6));
  out[3] = char64(in[2]);
}


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

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

LLVM IR (-O0):
define void @encoder(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%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 @char64(i8 zeroext %10)
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 %11, i8* %13
%14 = load i8*, i8** %3
%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** %3
%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 = trunc i32 %24 to i8
%26 = call signext i8 @char64(i8 zeroext %25)
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 %26, i8* %28
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 2
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = ashr i32 %37, 6
%39 = or i32 %33, %38
%40 = trunc i32 %39 to i8
%41 = call signext i8 @char64(i8 zeroext %40)
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i64 2
store i8 %41, i8* %43
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 2
%46 = load i8, i8* %45
%47 = call signext i8 @char64(i8 zeroext %46)
%48 = load i8*, i8** %4
%49 = getelementptr inbounds i8, i8* %48, i64 3
store i8 %47, i8* %49
ret void
}

LLVM IR (-O2):
define void @encoder(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = lshr i8 %3, 2
%5 = tail call signext i8 @char64(i8 zeroext %4)
store i8 %5, i8* %1
%6 = load i8, i8* %0
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = tail call i8 @llvm.fshl.i8(i8 %6, i8 %8, i8 4)
%10 = tail call signext i8 @char64(i8 zeroext %9)
%11 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %10, i8* %11
%12 = load i8, i8* %7
%13 = getelementptr inbounds i8, i8* %0, i64 2
%14 = load i8, i8* %13
%15 = tail call i8 @llvm.fshl.i8(i8 %12, i8 %14, i8 2)
%16 = tail call signext i8 @char64(i8 zeroext %15)
%17 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %16, i8* %17
%18 = load i8, i8* %13
%19 = tail call signext i8 @char64(i8 zeroext %18)
%20 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %19, i8* %20
ret void
}