#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 /*<<< orphan*/ memcpy(char *, char *, int);
void NESBreakBits(char pixel, char *buf) {
  switch (pixel) {
  case 0:
    memcpy(buf, "00", 2);
    return;
  case 1:
    memcpy(buf, "01", 2);
    return;
  case 2:
    memcpy(buf, "10", 2);
    return;
  case 3:
    memcpy(buf, "11", 2);
    return;
  default:
    memcpy(buf, "00", 2);
    return;
  }
}


x86 assembly (clang, -O0):
<NESBreakBits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11b1 <NESBreakBits+0xa1>
mov    -0x18(%rbp),%rax
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
jmp    11c6 <NESBreakBits+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
jmp    11c6 <NESBreakBits+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
jmp    11c6 <NESBreakBits+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xe77(%rip),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
jmp    11c6 <NESBreakBits+0xb6>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x2,%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<NESBreakBits>:
mov    %rsi,%rax
add    $0xffffffff,%edi
cmp    $0x2,%edi
ja     112e <NESBreakBits+0x1e>
movslq %edi,%rcx
lea    0xee7(%rip),%rdx
movslq (%rdx,%rcx,4),%rsi
add    %rdx,%rsi
jmp    1135 <NESBreakBits+0x25>
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [3 x i8] c"11\00"
define void @NESBreakBits(i8 signext %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 = sext i8 %5 to i32
switch i32 %6, label %19 [
i32 0, label %7
i32 1, label %10
i32 2, label %13
i32 3, label %16
]
7: ; preds = %2
%8 = load i8*, i8** %4
%9 = call i32 @memcpy(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %22
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i32 @memcpy(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %22
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i32 @memcpy(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
br label %22
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32 @memcpy(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
br label %22
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @memcpy(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
br label %22
22: ; preds = %19, %16, %13, %10, %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"10\00"
@.str.3 = [3 x i8] c"11\00"
@reltable.NESBreakBits = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.NESBreakBits to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.NESBreakBits to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.NESBreakBits to i64)) to i32)]
define void @NESBreakBits(i8 signext %0, i8* %1) {
%3 = sext i8 %0 to i32
%4 = add nsw i32 %3, -1
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.NESBreakBits to i8*), i64 %8)
br label %10
10: ; preds = %6, %2
%11 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ], [ %9, %6 ]
%12 = tail call i32 @memcpy(i8* %1, i8* %11, i32 2)
ret void
}