#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(int state) {
  if (state == 0)
    printf("Door: CLOSED\n");
  if (state == 2)
    printf("Door: OPEN\n");
  if (state == 1)
    printf("Door: OPENING\n");
  if (state == 3)
    printf("Door: CLOSING\n");
  if (state == 4)
    printf("Door: STOPPED_WHILE_CLOSING\n");
  if (state == 5)
    printf("Door: STOPPED_WHILE_OPENING\n");
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1131 <print+0x21>
lea    0xed4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
jne    1147 <print+0x37>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    115d <print+0x4d>
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x3,-0x4(%rbp)
jne    1173 <print+0x63>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x4,-0x4(%rbp)
jne    1189 <print+0x79>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x5,-0x4(%rbp)
jne    119f <print+0x8f>
lea    0xebb(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
cmp    $0x5,%edi
ja     112b <print+0x1b>
movslq %edi,%rax
lea    0xf4d(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1030 <puts@plt>
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Door: CLOSED\0A\00"
@.str.1 = [12 x i8] c"Door: OPEN\0A\00"
@.str.2 = [15 x i8] c"Door: OPENING\0A\00"
@.str.3 = [15 x i8] c"Door: CLOSING\0A\00"
@.str.4 = [29 x i8] c"Door: STOPPED_WHILE_CLOSING\0A\00"
@.str.5 = [29 x i8] c"Door: STOPPED_WHILE_OPENING\0A\00"
define void @print(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 4
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 5
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
ret void
}

LLVM IR (-O2):
@str = [28 x i8] c"Door: STOPPED_WHILE_OPENING\00"
@str.6 = [28 x i8] c"Door: STOPPED_WHILE_CLOSING\00"
@str.7 = [14 x i8] c"Door: CLOSING\00"
@str.8 = [14 x i8] c"Door: OPENING\00"
@str.9 = [11 x i8] c"Door: OPEN\00"
@str.10 = [13 x i8] c"Door: CLOSED\00"
@reltable.print = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.6 to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str to i64), i64 ptrtoint ([6 x i32]* @reltable.print to i64)) to i32)]
define void @print(i32 %0) {
%2 = icmp ult i32 %0, 6
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.print to i8*), i64 %5)
%7 = tail call i32 @puts(i8* dereferenceable(1) %6)
br label %8
8: ; preds = %1, %3
ret void
}