#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*/ printf(char *);
void print_state(unsigned char data) {
  if (data == 1)
    printf("STATE_LEFT\n");
  else if (data == 2)
    printf("STATE_CENTER_FWD\n");
  else if (data == 3)
    printf("STATE_RIGHT\n");
  else if (data == 4)
    printf("STATE_CENTER_BCK\n");
  else if (data == 1)
    printf("STATE_LEFT\n");
}


x86 assembly (clang, -O0):
<print_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    113c <print_state+0x2c>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <print_state+0xb3>
movzbl -0x1(%rbp),%eax
cmp    $0x2,%eax
jne    115a <print_state+0x4a>
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
jmp    11be <print_state+0xae>
movzbl -0x1(%rbp),%eax
cmp    $0x3,%eax
jne    1178 <print_state+0x68>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <print_state+0xa9>
movzbl -0x1(%rbp),%eax
cmp    $0x4,%eax
jne    1196 <print_state+0x86>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <print_state+0xa4>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    11af <print_state+0x9f>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
jmp    11b4 <print_state+0xa4>
jmp    11b9 <print_state+0xa9>
jmp    11be <print_state+0xae>
jmp    11c3 <print_state+0xb3>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_state>:
add    $0xff,%dil
cmp    $0x3,%dil
ja     1131 <print_state+0x21>
movsbq %dil,%rax
lea    0xf17(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@.str = [12 x i8] c"STATE_LEFT\0A\00"
@.str.1 = [18 x i8] c"STATE_CENTER_FWD\0A\00"
@.str.2 = [13 x i8] c"STATE_RIGHT\0A\00"
@.str.3 = [18 x i8] c"STATE_CENTER_BCK\0A\00"
define void @print_state(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %36
8: ; preds = %1
%9 = load i8, i8* %2
%10 = zext i8 %9 to i32
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %35
14: ; preds = %8
%15 = load i8, i8* %2
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 3
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %34
20: ; preds = %14
%21 = load i8, i8* %2
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %33
26: ; preds = %20
%27 = load i8, i8* %2
%28 = zext i8 %27 to i32
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
br label %33
33: ; preds = %32, %24
br label %34
34: ; preds = %33, %18
br label %35
35: ; preds = %34, %12
br label %36
36: ; preds = %35, %6
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c"STATE_CENTER_BCK\00"
@str.4 = [12 x i8] c"STATE_RIGHT\00"
@str.5 = [17 x i8] c"STATE_CENTER_FWD\00"
@str.6 = [11 x i8] c"STATE_LEFT\00"
@reltable.print_state = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.6 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_state to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str.5 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_state to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @str.4 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_state to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @str to i64), i64 ptrtoint ([4 x i32]* @reltable.print_state to i64)) to i32)]
define void @print_state(i8 zeroext %0) {
%2 = add i8 %0, -1
%3 = icmp ult i8 %2, 4
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = sext i8 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.print_state to i8*), i64 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) %7)
br label %9
9: ; preds = %1, %4
ret void
}