#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  char arr[15];
  int reminder[100], count = 0, status = 1, counter;
  char text1[] = "button_clicked";
  char text2[] = "cycle_complete";
  while (scanf("%s", arr) != EOF) {
    if (status == 1) {
      if (strcmp(text1, arr) == 0) {
        status = 4;
        reminder[count] = 4;
        count++;
        arr[0] = '0';
      }
    }
    if (status == 2) {
      if (strcmp(text1, arr) == 0) {
        status = 3;
        reminder[count] = 3;
        count++;
        arr[0] = '0';
      }
    }
    if (status == 3) {
      if (strcmp(text1, arr) == 0) {
        status = 5;
        reminder[count] = 5;
        count++;
        arr[0] = '0';
      }
      if (strcmp(text2, arr) == 0) {
        status = 1;
        reminder[count] = 1;
        count++;
        arr[0] = '0';
      }
    }
    if (status == 4) {
      if (strcmp(text1, arr) == 0) {
        status = 6;
        reminder[count] = 6;
        count++;
        arr[0] = '0';
      }
      if (strcmp(text2, arr) == 0) {
        status = 2;
        reminder[count] = 2;
        count++;
        arr[0] = '0';
      }
    }
    if (status == 5) {
      if (strcmp(text1, arr) == 0) {
        status = 4;
        reminder[count] = 4;
        count++;
        arr[0] = '0';
      }
    }
    if (status == 6) {
      if (strcmp(text1, arr) == 0) {
        status = 3;
        reminder[count] = 3;
        count++;
        arr[0] = '0';
      }
    }
  }
  printf("Door: CLOSED\n");
  for (counter = 0; counter < count; counter++) {
    if (reminder[counter] == 1)
      printf("Door: CLOSED\n");
    if (reminder[counter] == 2)
      printf("Door: OPEN\n");
    if (reminder[counter] == 3)
      printf("Door: CLOSING\n");
    if (reminder[counter] == 4)
      printf("Door: OPENING\n");
    if (reminder[counter] == 5)
      printf("Door: STOPPED_WHILE_CLOSING\n");
    if (reminder[counter] == 6)
      printf("Door: STOPPED_WHILE_OPENING\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1b4(%rbp)
movl   $0x1,-0x1b8(%rbp)
mov    0xea3(%rip),%rax
mov    %rax,-0x1cb(%rbp)
mov    0xe9e(%rip),%eax
mov    %eax,-0x1c3(%rbp)
mov    0xe95(%rip),%ax
mov    %ax,-0x1bf(%rbp)
mov    0xe8a(%rip),%al
mov    %al,-0x1bd(%rbp)
mov    0xe7e(%rip),%rax
mov    %rax,-0x1da(%rbp)
mov    0xe79(%rip),%eax
mov    %eax,-0x1d2(%rbp)
mov    0xe70(%rip),%ax
mov    %ax,-0x1ce(%rbp)
mov    0xe65(%rip),%al
mov    %al,-0x1cc(%rbp)
lea    -0x13(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e13(%rip),%rcx
cmp    (%rcx),%rax
je     1497 <main+0x367>
cmpl   $0x1,-0x1b8(%rbp)
jne    1239 <main+0x109>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <main+0x104>
movl   $0x4,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x4,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    1239 <main+0x109>
cmpl   $0x2,-0x1b8(%rbp)
jne    1294 <main+0x164>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    128f <main+0x15f>
movl   $0x3,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x3,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    1294 <main+0x164>
cmpl   $0x3,-0x1b8(%rbp)
jne    1338 <main+0x208>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12ea <main+0x1ba>
movl   $0x5,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x5,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
lea    -0x1da(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1333 <main+0x203>
movl   $0x1,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x1,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    1338 <main+0x208>
cmpl   $0x4,-0x1b8(%rbp)
jne    13dc <main+0x2ac>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    138e <main+0x25e>
movl   $0x6,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x6,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
lea    -0x1da(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    13d7 <main+0x2a7>
movl   $0x2,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x2,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    13dc <main+0x2ac>
cmpl   $0x5,-0x1b8(%rbp)
jne    1437 <main+0x307>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1432 <main+0x302>
movl   $0x4,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x4,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    1437 <main+0x307>
cmpl   $0x6,-0x1b8(%rbp)
jne    1492 <main+0x362>
lea    -0x1cb(%rbp),%rdi
lea    -0x13(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    148d <main+0x35d>
movl   $0x3,-0x1b8(%rbp)
movslq -0x1b4(%rbp),%rax
movl   $0x3,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movb   $0x30,-0x13(%rbp)
jmp    1492 <main+0x362>
jmp    11be <main+0x8e>
lea    0xb83(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1bc(%rbp)
mov    -0x1bc(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    159e <main+0x46e>
movslq -0x1bc(%rbp),%rax
cmpl   $0x1,-0x1b0(%rbp,%rax,4)
01
jne    14e0 <main+0x3b0>
lea    0xb46(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1bc(%rbp),%rax
cmpl   $0x2,-0x1b0(%rbp,%rax,4)
02
jne    1501 <main+0x3d1>
lea    0xb33(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1bc(%rbp),%rax
cmpl   $0x3,-0x1b0(%rbp,%rax,4)
03
jne    1522 <main+0x3f2>
lea    0xb1e(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1bc(%rbp),%rax
cmpl   $0x4,-0x1b0(%rbp,%rax,4)
04
jne    1543 <main+0x413>
lea    0xb0c(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1bc(%rbp),%rax
cmpl   $0x5,-0x1b0(%rbp,%rax,4)
05
jne    1564 <main+0x434>
lea    0xafa(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1bc(%rbp),%rax
cmpl   $0x6,-0x1b0(%rbp,%rax,4)
06
jne    1585 <main+0x455>
lea    0xaf6(%rip),%rdi
call   1030 <printf@plt>
jmp    158a <main+0x45a>
mov    -0x1bc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1bc(%rbp)
jmp    14ad <main+0x37d>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1c8,%rsp
movabs $0x64656b63696c63,%rax
mov    %rax,0x27(%rsp)
movabs $0x635f6e6f74747562,%rax
6e 5f 63
mov    %rax,0x20(%rsp)
movabs $0x6574656c706d6f,%rax
mov    %rax,0x17(%rsp)
movabs $0x6f635f656c637963,%rax
5f 63 6f
mov    %rax,0x10(%rsp)
lea    0xec2(%rip),%rdi
lea    0x1(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e53(%rip),%rbp
cmp    0x0(%rbp),%rax
jne    11ac <main+0x7c>
lea    0xf06(%rip),%rdi
call   1030 <puts@plt>
jmp    13d5 <main+0x2a5>
xor    %ebx,%ebx
mov    $0x1,%r15d
lea    0x20(%rsp),%r14
lea    0x1(%rsp),%r13
lea    0xe3b(%rip),%r12
jmp    11f9 <main+0xc9>
movslq %ebx,%rbx
movl   $0x1,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x1,%r15d
lea    0xe5f(%rip),%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1392 <main+0x262>
lea    -0x1(%r15),%eax
cmp    $0x3,%eax
ja     1312 <main+0x1e2>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x1,%r15d
test   %rax,%rax
jne    11e0 <main+0xb0>
movslq %ebx,%rax
movl   $0x4,0x30(%rsp,%rax,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x4,%r15d
test   %rax,%rax
jne    1267 <main+0x137>
movslq %ebx,%rbx
movl   $0x6,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x6,%r15d
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1350 <main+0x220>
movslq %ebx,%rbx
movl   $0x2,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x2,%r15d
jmp    11e0 <main+0xb0>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x2,%r15d
test   %rax,%rax
jne    11e0 <main+0xb0>
movslq %ebx,%rbx
movl   $0x3,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x3,%r15d
test   %rax,%rax
jne    12fc <main+0x1cc>
movslq %ebx,%rbx
movl   $0x5,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x5,%r15d
lea    0x10(%rsp),%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c7 <main+0x97>
cmp    $0x5,%r15d
jne    1350 <main+0x220>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x5,%r15d
test   %rax,%rax
jne    11e0 <main+0xb0>
movslq %ebx,%rbx
movl   $0x4,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x4,%r15d
jmp    11e0 <main+0xb0>
cmp    $0x6,%r15d
jne    11e0 <main+0xb0>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
mov    $0x6,%r15d
test   %rax,%rax
jne    11e0 <main+0xb0>
movslq %ebx,%rbx
movl   $0x3,0x30(%rsp,%rbx,4)
add    $0x1,%ebx
movb   $0x30,0x1(%rsp)
mov    $0x3,%r15d
jmp    11e0 <main+0xb0>
lea    0xd0f(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
jle    13d5 <main+0x2a5>
mov    %ebx,%ebx
xor    %ebp,%ebp
lea    0xc63(%rip),%r14
jmp    13b9 <main+0x289>
nop
add    $0x1,%rbp
cmp    %rbp,%rbx
je     13d5 <main+0x2a5>
mov    0x30(%rsp,%rbp,4),%eax
add    $0xffffffff,%eax
cmp    $0x5,%eax
ja     13b0 <main+0x280>
cltq
movslq (%r14,%rax,4),%rdi
add    %r14,%rdi
call   1030 <puts@plt>
jmp    13b0 <main+0x280>
xor    %eax,%eax
add    $0x1c8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.text1 = [15 x i8] c"button_clicked\00"
@__const.main.text2 = [15 x i8] c"cycle_complete\00"
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [14 x i8] c"Door: CLOSED\0A\00"
@.str.2 = [12 x i8] c"Door: OPEN\0A\00"
@.str.3 = [15 x i8] c"Door: CLOSING\0A\00"
@.str.4 = [15 x i8] c"Door: OPENING\0A\00"
@.str.5 = [29 x i8] c"Door: STOPPED_WHILE_CLOSING\0A\00"
@.str.6 = [29 x i8] c"Door: STOPPED_WHILE_OPENING\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [100 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [15 x i8]
%8 = alloca [15 x i8]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 1, i32* %5
%9 = bitcast [15 x i8]* %7 to i8*
%10 = bitcast [15 x i8]* %8 to i8*
br label %11
11: ; preds = %136, %0
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%13 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %137
16: ; preds = %11
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%21 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%22 = call i64 @strcmp(i8* %20, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %19
store i32 4, i32* %5
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %26
store i32 4, i32* %27
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
%30 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %30
br label %31
31: ; preds = %24, %19
br label %32
32: ; preds = %31, %16
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %48
35: ; preds = %32
%36 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%37 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%38 = call i64 @strcmp(i8* %36, i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %35
store i32 3, i32* %5
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %42
store i32 3, i32* %43
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
%46 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %46
br label %47
47: ; preds = %40, %35
br label %48
48: ; preds = %47, %32
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 3
br i1 %50, label %51, label %76
51: ; preds = %48
%52 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%53 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%54 = call i64 @strcmp(i8* %52, i8* %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %63
56: ; preds = %51
store i32 5, i32* %5
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %58
store i32 5, i32* %59
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
%62 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %62
br label %63
63: ; preds = %56, %51
%64 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%65 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%66 = call i64 @strcmp(i8* %64, i8* %65)
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %75
68: ; preds = %63
store i32 1, i32* %5
%69 = load i32, i32* %4
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %70
store i32 1, i32* %71
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
%74 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %74
br label %75
75: ; preds = %68, %63
br label %76
76: ; preds = %75, %48
%77 = load i32, i32* %5
%78 = icmp eq i32 %77, 4
br i1 %78, label %79, label %104
79: ; preds = %76
%80 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%81 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%82 = call i64 @strcmp(i8* %80, i8* %81)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %79
store i32 6, i32* %5
%85 = load i32, i32* %4
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %86
store i32 6, i32* %87
%88 = load i32, i32* %4
%89 = add nsw i32 %88, 1
store i32 %89, i32* %4
%90 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %90
br label %91
91: ; preds = %84, %79
%92 = getelementptr inbounds [15 x i8], [15 x i8]* %8, i64 0, i64 0
%93 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%94 = call i64 @strcmp(i8* %92, i8* %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %103
96: ; preds = %91
store i32 2, i32* %5
%97 = load i32, i32* %4
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %98
store i32 2, i32* %99
%100 = load i32, i32* %4
%101 = add nsw i32 %100, 1
store i32 %101, i32* %4
%102 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %102
br label %103
103: ; preds = %96, %91
br label %104
104: ; preds = %103, %76
%105 = load i32, i32* %5
%106 = icmp eq i32 %105, 5
br i1 %106, label %107, label %120
107: ; preds = %104
%108 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%109 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%110 = call i64 @strcmp(i8* %108, i8* %109)
%111 = icmp eq i64 %110, 0
br i1 %111, label %112, label %119
112: ; preds = %107
store i32 4, i32* %5
%113 = load i32, i32* %4
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %114
store i32 4, i32* %115
%116 = load i32, i32* %4
%117 = add nsw i32 %116, 1
store i32 %117, i32* %4
%118 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %118
br label %119
119: ; preds = %112, %107
br label %120
120: ; preds = %119, %104
%121 = load i32, i32* %5
%122 = icmp eq i32 %121, 6
br i1 %122, label %123, label %136
123: ; preds = %120
%124 = getelementptr inbounds [15 x i8], [15 x i8]* %7, i64 0, i64 0
%125 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%126 = call i64 @strcmp(i8* %124, i8* %125)
%127 = icmp eq i64 %126, 0
br i1 %127, label %128, label %135
128: ; preds = %123
store i32 3, i32* %5
%129 = load i32, i32* %4
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %130
store i32 3, i32* %131
%132 = load i32, i32* %4
%133 = add nsw i32 %132, 1
store i32 %133, i32* %4
%134 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
store i8 48, i8* %134
br label %135
135: ; preds = %128, %123
br label %136
136: ; preds = %135, %120
br label %11
137: ; preds = %11
%138 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %6
br label %139
139: ; preds = %192, %137
%140 = load i32, i32* %6
%141 = load i32, i32* %4
%142 = icmp slt i32 %140, %141
br i1 %142, label %143, label %195
143: ; preds = %139
%144 = load i32, i32* %6
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %145
%147 = load i32, i32* %146
%148 = icmp eq i32 %147, 1
br i1 %148, label %149, label %151
149: ; preds = %143
%150 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %151
151: ; preds = %149, %143
%152 = load i32, i32* %6
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %153
%155 = load i32, i32* %154
%156 = icmp eq i32 %155, 2
br i1 %156, label %157, label %159
157: ; preds = %151
%158 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %159
159: ; preds = %157, %151
%160 = load i32, i32* %6
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %161
%163 = load i32, i32* %162
%164 = icmp eq i32 %163, 3
br i1 %164, label %165, label %167
165: ; preds = %159
%166 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %167
167: ; preds = %165, %159
%168 = load i32, i32* %6
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %169
%171 = load i32, i32* %170
%172 = icmp eq i32 %171, 4
br i1 %172, label %173, label %175
173: ; preds = %167
%174 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %175
175: ; preds = %173, %167
%176 = load i32, i32* %6
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %177
%179 = load i32, i32* %178
%180 = icmp eq i32 %179, 5
br i1 %180, label %181, label %183
181: ; preds = %175
%182 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %183
183: ; preds = %181, %175
%184 = load i32, i32* %6
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %185
%187 = load i32, i32* %186
%188 = icmp eq i32 %187, 6
br i1 %188, label %189, label %191
189: ; preds = %183
%190 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
br label %191
191: ; preds = %189, %183
br label %192
192: ; preds = %191
%193 = load i32, i32* %6
%194 = add nsw i32 %193, 1
store i32 %194, i32* %6
br label %139
195: ; preds = %139
ret i32 0
}

LLVM IR (-O2):
@__const.main.text1 = [15 x i8] c"button_clicked\00"
@__const.main.text2 = [15 x i8] c"cycle_complete\00"
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@str.7 = [28 x i8] c"Door: STOPPED_WHILE_OPENING\00"
@str.8 = [28 x i8] c"Door: STOPPED_WHILE_CLOSING\00"
@str.9 = [14 x i8] c"Door: OPENING\00"
@str.10 = [14 x i8] c"Door: CLOSING\00"
@str.11 = [11 x i8] c"Door: OPEN\00"
@str.12 = [13 x i8] c"Door: CLOSED\00"
@reltable.main = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.12 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @str.11 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.10 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @str.9 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.8 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @str.7 to i64), i64 ptrtoint ([6 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [100 x i32]
%3 = alloca [15 x i8]
%4 = alloca [15 x i8]
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%6 = bitcast [100 x i32]* %2 to i8*
%7 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
br label %112
14: ; preds = %0, %87
%15 = phi i32 [ %89, %87 ], [ 1, %0 ]
%16 = phi i32 [ %88, %87 ], [ 0, %0 ]
switch i32 %15, label %65 [
i32 1, label %17
i32 2, label %24
i32 3, label %31
i32 4, label %48
]
17: ; preds = %14
%18 = call i64 @strcmp(i8* %7, i8* %5)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %87
20: ; preds = %17
%21 = sext i32 %16 to i64
%22 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %21
store i32 4, i32* %22
%23 = add nsw i32 %16, 1
store i8 48, i8* %5
br label %48
24: ; preds = %14
%25 = call i64 @strcmp(i8* %7, i8* %5)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %87
27: ; preds = %24
%28 = sext i32 %16 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %28
store i32 3, i32* %29
%30 = add nsw i32 %16, 1
store i8 48, i8* %5
br label %31
31: ; preds = %14, %27
%32 = phi i32 [ %30, %27 ], [ %16, %14 ]
%33 = call i64 @strcmp(i8* %7, i8* %5)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = sext i32 %32 to i64
%37 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %36
store i32 5, i32* %37
%38 = add nsw i32 %32, 1
store i8 48, i8* %5
br label %39
39: ; preds = %35, %31
%40 = phi i32 [ %38, %35 ], [ %32, %31 ]
%41 = phi i32 [ 5, %35 ], [ 3, %31 ]
%42 = call i64 @strcmp(i8* %8, i8* %5)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %65
44: ; preds = %39
%45 = sext i32 %40 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %45
store i32 1, i32* %46
%47 = add nsw i32 %40, 1
store i8 48, i8* %5
br label %87
48: ; preds = %14, %20
%49 = phi i32 [ %23, %20 ], [ %16, %14 ]
%50 = call i64 @strcmp(i8* %7, i8* %5)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = sext i32 %49 to i64
%54 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %53
store i32 6, i32* %54
%55 = add nsw i32 %49, 1
store i8 48, i8* %5
br label %56
56: ; preds = %52, %48
%57 = phi i32 [ %55, %52 ], [ %49, %48 ]
%58 = phi i32 [ 6, %52 ], [ 4, %48 ]
%59 = call i64 @strcmp(i8* %8, i8* %5)
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %76
61: ; preds = %56
%62 = sext i32 %57 to i64
%63 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %62
store i32 2, i32* %63
%64 = add nsw i32 %57, 1
store i8 48, i8* %5
br label %87
65: ; preds = %14, %39
%66 = phi i32 [ %40, %39 ], [ %16, %14 ]
%67 = phi i32 [ %41, %39 ], [ %15, %14 ]
%68 = icmp eq i32 %67, 5
br i1 %68, label %69, label %76
69: ; preds = %65
%70 = call i64 @strcmp(i8* %7, i8* %5)
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %87
72: ; preds = %69
%73 = sext i32 %66 to i64
%74 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %73
store i32 4, i32* %74
%75 = add nsw i32 %66, 1
store i8 48, i8* %5
br label %87
76: ; preds = %56, %65
%77 = phi i32 [ %66, %65 ], [ %57, %56 ]
%78 = phi i32 [ %67, %65 ], [ %58, %56 ]
%79 = icmp eq i32 %78, 6
br i1 %79, label %80, label %87
80: ; preds = %76
%81 = call i64 @strcmp(i8* %7, i8* %5)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %87
83: ; preds = %80
%84 = sext i32 %77 to i64
%85 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %84
store i32 3, i32* %85
%86 = add nsw i32 %77, 1
store i8 48, i8* %5
br label %87
87: ; preds = %17, %24, %44, %61, %69, %72, %80, %83, %76
%88 = phi i32 [ %86, %83 ], [ %77, %80 ], [ %77, %76 ], [ %66, %69 ], [ %75, %72 ], [ %64, %61 ], [ %47, %44 ], [ %16, %17 ], [ %16, %24 ]
%89 = phi i32 [ 3, %83 ], [ 6, %80 ], [ %78, %76 ], [ 5, %69 ], [ 4, %72 ], [ 2, %61 ], [ 1, %44 ], [ 1, %17 ], [ 2, %24 ]
%90 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%91 = load i64, i64* @EOF
%92 = icmp eq i64 %90, %91
br i1 %92, label %93, label %14
93: ; preds = %87
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%95 = icmp sgt i32 %88, 0
br i1 %95, label %96, label %112
96: ; preds = %93
%97 = zext i32 %88 to i64
br label %98
98: ; preds = %96, %109
%99 = phi i64 [ 0, %96 ], [ %110, %109 ]
%100 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %99
%101 = load i32, i32* %100
%102 = add i32 %101, -1
%103 = icmp ult i32 %102, 6
br i1 %103, label %104, label %109
104: ; preds = %98
%105 = sext i32 %102 to i64
%106 = shl i64 %105, 2
%107 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.main to i8*), i64 %106)
%108 = call i32 @puts(i8* dereferenceable(1) %107)
br label %109
109: ; preds = %98, %104
%110 = add nuw nsw i64 %99, 1
%111 = icmp eq i64 %110, %97
br i1 %111, label %112, label %98
112: ; preds = %109, %12, %93
ret i32 0
}