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


x86 assembly (clang, -O0):
<printMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x5,%rax
ja     11ad <printMsg+0x9d>
mov    -0x10(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <printMsg+0x9d>
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <printMsg+0x9d>
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <printMsg+0x9d>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <printMsg+0x9d>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <printMsg+0x9d>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMsg>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x5,%ebx
ja     114b <printMsg+0x2b>
movslq %ebx,%rax
lea    0xf02(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
pop    %rbx
jmp    1030 <puts@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Door: \00"
@.str.1 = [8 x i8] c"CLOSED\0A\00"
@.str.2 = [9 x i8] c"OPENING\0A\00"
@.str.3 = [6 x i8] c"OPEN\0A\00"
@.str.4 = [9 x i8] c"CLOSING\0A\00"
@.str.5 = [23 x i8] c"STOPPED_WHILE_CLOSING\0A\00"
@.str.6 = [23 x i8] c"STOPPED_WHILE_OPENING\0A\00"
define void @printMsg(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %17 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %17
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %17
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %17
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %17
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %17
17: ; preds = %1, %15, %13, %11, %9, %7, %5
ret void
}

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