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


x86 assembly (clang, -O0):
<PackByteBWA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <CharToBaseBWA@plt>
shl    $0x0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <CharToBaseBWA@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
shl    $0x2,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <CharToBaseBWA@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
shl    $0x4,%ecx
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <CharToBaseBWA@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):
<PackByteBWA>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
movsbl 0x3(%rdi),%edi
call   1030 <CharToBaseBWA@plt>
mov    %eax,%r14d
movsbl 0x2(%r15),%edi
call   1030 <CharToBaseBWA@plt>
mov    %eax,%ebp
shl    $0x2,%ebp
or     %r14d,%ebp
movsbl 0x1(%r15),%edi
call   1030 <CharToBaseBWA@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
movsbl (%r15),%edi
call   1030 <CharToBaseBWA@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 @PackByteBWA(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 3
%5 = load i8, i8* %4
%6 = call i32 @CharToBaseBWA(i8 signext %5)
%7 = shl i32 %6, 0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = load i8, i8* %9
%11 = call i32 @CharToBaseBWA(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 1
%16 = load i8, i8* %15
%17 = call i32 @CharToBaseBWA(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 0
%22 = load i8, i8* %21
%23 = call i32 @CharToBaseBWA(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 @PackByteBWA(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 3
%3 = load i8, i8* %2
%4 = tail call i32 @CharToBaseBWA(i8 signext %3)
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = tail call i32 @CharToBaseBWA(i8 signext %6)
%8 = shl i32 %7, 2
%9 = or i32 %8, %4
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = tail call i32 @CharToBaseBWA(i8 signext %11)
%13 = shl i32 %12, 4
%14 = or i32 %9, %13
%15 = load i8, i8* %0
%16 = tail call i32 @CharToBaseBWA(i8 signext %15)
%17 = shl i32 %16, 6
%18 = or i32 %14, %17
%19 = trunc i32 %18 to i8
ret i8 %19
}