#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 CharToBase(char);
unsigned char PackByte(char bases[4]) {
  return ((CharToBase(bases[0]) << 0) | (CharToBase(bases[1]) << 2) |
          (CharToBase(bases[2]) << 4) | (CharToBase(bases[3]) << 6));
}


x86 assembly (clang, -O0):
<PackByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CharToBase@plt>
shl    $0x0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <CharToBase@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x2,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <CharToBase@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
shl    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <CharToBase@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
shl    $0x6,%ecx
or     %ecx,%eax
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PackByte>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1030 <CharToBase@plt>
mov    %eax,%r14d
movsbl 0x1(%r15),%edi
call   1030 <CharToBase@plt>
mov    %eax,%ebp
shl    $0x2,%ebp
or     %r14d,%ebp
movsbl 0x2(%r15),%edi
call   1030 <CharToBase@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl 0x3(%r15),%edi
call   1030 <CharToBase@plt>
shl    $0x6,%eax
or     %ebx,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @PackByte(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = call i32 @CharToBase(i8 signext %5)
%7 = shl i32 %6, 0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8, i8* %9
%11 = call i32 @CharToBase(i8 signext %10)
%12 = shl i32 %11, 2
%13 = or i32 %7, %12
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 2
%16 = load i8, i8* %15
%17 = call i32 @CharToBase(i8 signext %16)
%18 = shl i32 %17, 4
%19 = or i32 %13, %18
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 3
%22 = load i8, i8* %21
%23 = call i32 @CharToBase(i8 signext %22)
%24 = shl i32 %23, 6
%25 = or i32 %19, %24
%26 = trunc i32 %25 to i8
ret i8 %26
}

LLVM IR (-O2):
define zeroext i8 @PackByte(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @CharToBase(i8 signext %2)
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = tail call i32 @CharToBase(i8 signext %5)
%7 = shl i32 %6, 2
%8 = or i32 %7, %3
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = tail call i32 @CharToBase(i8 signext %10)
%12 = shl i32 %11, 4
%13 = or i32 %8, %12
%14 = getelementptr inbounds i8, i8* %0, i64 3
%15 = load i8, i8* %14
%16 = tail call i32 @CharToBase(i8 signext %15)
%17 = shl i32 %16, 6
%18 = or i32 %13, %17
%19 = trunc i32 %18 to i8
ret i8 %19
}