#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 lookup(char);
char *tripletoquad(char *x, char *r) {
  r[0] = lookup(x[0] >> 2);
  r[1] = lookup(((x[0] & 0b00000011) << 4) | ((x[1] & 0b11110000) >> 4));
  r[2] = lookup(((x[1] & 0b00001111) << 2) | ((x[2] & 0b11000000) >> 6));
  r[3] = lookup(x[2] & 0b00111111);
  return r;
}


x86 assembly (clang, -O0):
<tripletoquad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
sar    $0x2,%eax
movsbl %al,%edi
call   1030 <lookup@plt>
mov    %al,%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
or     %ecx,%eax
movsbl %al,%edi
call   1030 <lookup@plt>
mov    %al,%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
or     %ecx,%eax
movsbl %al,%edi
call   1030 <lookup@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
and    $0x3f,%eax
movsbl %al,%edi
call   1030 <lookup@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tripletoquad>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%al
sar    $0x2,%al
movsbl %al,%edi
call   1030 <lookup@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 <lookup@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 <lookup@plt>
mov    %al,0x2(%r14)
movzbl 0x2(%rbx),%edi
and    $0x3f,%edi
call   1030 <lookup@plt>
mov    %al,0x3(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @tripletoquad(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 = sext i8 %7 to i32
%9 = ashr i32 %8, 2
%10 = trunc i32 %9 to i8
%11 = call signext i8 @lookup(i8 signext %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 = sext i8 %16 to i32
%18 = and i32 %17, 3
%19 = shl i32 %18, 4
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = and i32 %23, 240
%25 = ashr i32 %24, 4
%26 = or i32 %19, %25
%27 = trunc i32 %26 to i8
%28 = call signext i8 @lookup(i8 signext %27)
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 %28, i8* %30
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = and i32 %34, 15
%36 = shl i32 %35, 2
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 2
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = and i32 %40, 192
%42 = ashr i32 %41, 6
%43 = or i32 %36, %42
%44 = trunc i32 %43 to i8
%45 = call signext i8 @lookup(i8 signext %44)
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i64 2
store i8 %45, i8* %47
%48 = load i8*, i8** %3
%49 = getelementptr inbounds i8, i8* %48, i64 2
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = and i32 %51, 63
%53 = trunc i32 %52 to i8
%54 = call signext i8 @lookup(i8 signext %53)
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 3
store i8 %54, i8* %56
%57 = load i8*, i8** %4
ret i8* %57
}

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