#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 *);
int /*<<< orphan*/ strcmp(char *, char *);
int main() {
  char command[20];
  int command_history[100] = {0};
  int i = 0;
  while (scanf("%s", command) != EOF) {
    if (!i)
      printf("Door: CLOSED");
    if (!strcmp(command, "button_clicked") &&
        (command_history[i] == 0 || command_history[i] == 5)) {
      command_history[i + 1] = 1;
      printf("\nDoor: OPENING");
    } else if (!strcmp(command, "cycle_complete") && command_history[i] == 0)
      continue;
    else if (!strcmp(command, "button_clicked") && command_history[i] == 1) {
      command_history[i + 1] = 2;
      printf("\nDoor: STOPPED_WHILE_OPENING");
    } else if (!strcmp(command, "cycle_complete") && command_history[i] == 1) {
      command_history[i + 1] = 3;
      printf("\nDoor: OPEN");
    } else if (!strcmp(command, "button_clicked") &&
               (command_history[i] == 2 || command_history[i] == 3)) {
      command_history[i + 1] = 4;
      printf("\nDoor: CLOSING");
    } else if (!strcmp(command, "cycle_complete") &&
               (command_history[i] == 2 || command_history[i] == 5))
      continue;
    else if (!strcmp(command, "cycle_complete") && command_history[i] == 3)
      continue;
    else if (!strcmp(command, "button_clicked") && command_history[i] == 4) {
      command_history[i + 1] = 5;
      printf("\nDoor: STOPPED_WHILE_CLOSING");
    } else if (!strcmp(command, "cycle_complete") && command_history[i] == 4) {
      command_history[i + 1] = 0;
      printf("\nDoor: CLOSED");
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x0,-0x1b4(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1060 <scanf@plt>
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%rax
je     14b5 <main+0x375>
cmpl   $0x0,-0x1b4(%rbp)
jne    11a8 <main+0x68>
lea    0xee3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1212 <main+0xd2>
movslq -0x1b4(%rbp),%rax
cmpl   $0x0,-0x1b0(%rbp,%rax,4)
je     11eb <main+0xab>
movslq -0x1b4(%rbp),%rax
cmpl   $0x5,-0x1b0(%rbp,%rax,4)
05
jne    1212 <main+0xd2>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x1,-0x1b0(%rbp,%rax,4)
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
jmp    14a1 <main+0x361>
lea    -0x20(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1245 <main+0x105>
movslq -0x1b4(%rbp),%rax
cmpl   $0x0,-0x1b0(%rbp,%rax,4)
jne    1245 <main+0x105>
jmp    116f <main+0x2f>
lea    -0x20(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    129a <main+0x15a>
movslq -0x1b4(%rbp),%rax
cmpl   $0x1,-0x1b0(%rbp,%rax,4)
01
jne    129a <main+0x15a>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x2,-0x1b0(%rbp,%rax,4)
lea    0xda0(%rip),%rdi
call   1030 <printf@plt>
jmp    1497 <main+0x357>
lea    -0x20(%rbp),%rdi
lea    0xd7c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12ef <main+0x1af>
movslq -0x1b4(%rbp),%rax
cmpl   $0x1,-0x1b0(%rbp,%rax,4)
01
jne    12ef <main+0x1af>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x3,-0x1b0(%rbp,%rax,4)
lea    0xd68(%rip),%rdi
call   1030 <printf@plt>
jmp    1492 <main+0x352>
lea    -0x20(%rbp),%rdi
lea    0xd09(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1359 <main+0x219>
movslq -0x1b4(%rbp),%rax
cmpl   $0x2,-0x1b0(%rbp,%rax,4)
02
je     1332 <main+0x1f2>
movslq -0x1b4(%rbp),%rax
cmpl   $0x3,-0x1b0(%rbp,%rax,4)
03
jne    1359 <main+0x219>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x4,-0x1b0(%rbp,%rax,4)
lea    0xd0a(%rip),%rdi
call   1030 <printf@plt>
jmp    148d <main+0x34d>
lea    -0x20(%rbp),%rdi
lea    0xcbd(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    13a1 <main+0x261>
movslq -0x1b4(%rbp),%rax
cmpl   $0x2,-0x1b0(%rbp,%rax,4)
02
je     139c <main+0x25c>
movslq -0x1b4(%rbp),%rax
cmpl   $0x5,-0x1b0(%rbp,%rax,4)
05
jne    13a1 <main+0x261>
jmp    116f <main+0x2f>
lea    -0x20(%rbp),%rdi
lea    0xc75(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    13d4 <main+0x294>
movslq -0x1b4(%rbp),%rax
cmpl   $0x3,-0x1b0(%rbp,%rax,4)
03
jne    13d4 <main+0x294>
jmp    116f <main+0x2f>
lea    -0x20(%rbp),%rdi
lea    0xc24(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1429 <main+0x2e9>
movslq -0x1b4(%rbp),%rax
cmpl   $0x4,-0x1b0(%rbp,%rax,4)
04
jne    1429 <main+0x2e9>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x5,-0x1b0(%rbp,%rax,4)
lea    0xc49(%rip),%rdi
call   1030 <printf@plt>
jmp    147e <main+0x33e>
lea    -0x20(%rbp),%rdi
lea    0xbed(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1479 <main+0x339>
movslq -0x1b4(%rbp),%rax
cmpl   $0x4,-0x1b0(%rbp,%rax,4)
04
jne    1479 <main+0x339>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
cltq
movl   $0x0,-0x1b0(%rbp,%rax,4)
lea    0xc11(%rip),%rdi
call   1030 <printf@plt>
jmp    147e <main+0x33e>
jmp    1483 <main+0x343>
jmp    1488 <main+0x348>
jmp    148d <main+0x34d>
jmp    1492 <main+0x352>
jmp    1497 <main+0x357>
jmp    149c <main+0x35c>
jmp    14a1 <main+0x361>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    116f <main+0x2f>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0x20(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1040 <memset@plt>
lea    0xea7(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    0x2e80(%rip),%r13
cmp    0x0(%r13),%rax
jne    1182 <main+0x52>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
lea    0xe74(%rip),%r15
mov    %rsp,%r12
movabs $0x6574656c706d6f,%rbp
jmp    11c1 <main+0x91>
lea    0xe70(%rip),%rdi
mov    %esi,0x24(%rsp,%r14,4)
call   1030 <printf@plt>
add    $0x1,%r14
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    0x0(%r13),%rax
je     116e <main+0x3e>
test   %r14,%r14
jne    11d2 <main+0xa2>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    (%rsp),%rcx
movabs $0x635f6e6f74747562,%rax
6e 5f 63
xor    %rax,%rcx
mov    0x7(%rsp),%rdx
movabs $0x64656b63696c63,%rax
xor    %rax,%rdx
xor    %eax,%eax
or     %rcx,%rdx
setne  %dl
jne    1212 <main+0xe2>
mov    0x20(%rsp,%r14,4),%ecx
mov    $0x1,%esi
test   %ecx,%ecx
je     119b <main+0x6b>
cmp    $0x5,%ecx
je     119b <main+0x6b>
mov    (%rsp),%rsi
movabs $0x6f635f656c637963,%rcx
5f 63 6f
xor    %rcx,%rsi
mov    0x7(%rsp),%rdi
xor    %rbp,%rdi
xor    %ecx,%ecx
or     %rsi,%rdi
setne  %bl
jne    1241 <main+0x111>
cmpl   $0x0,0x20(%rsp,%r14,4)
je     11b0 <main+0x80>
mov    %dl,%al
test   %eax,%eax
jne    124f <main+0x11f>
cmpl   $0x1,0x20(%rsp,%r14,4)
je     12c8 <main+0x198>
mov    %bl,%cl
test   %ecx,%ecx
jne    125d <main+0x12d>
cmpl   $0x1,0x20(%rsp,%r14,4)
je     12d9 <main+0x1a9>
test   %eax,%eax
jne    126e <main+0x13e>
mov    0x20(%rsp,%r14,4),%edx
and    $0xfffffffe,%edx
cmp    $0x2,%edx
je     12ea <main+0x1ba>
test   %ecx,%ecx
jne    128a <main+0x15a>
mov    0x20(%rsp,%r14,4),%edx
cmp    $0x5,%edx
ja     128a <main+0x15a>
mov    $0x2c,%esi
bt     %edx,%esi
jb     11b0 <main+0x80>
test   %eax,%eax
jne    12a6 <main+0x176>
mov    $0x5,%esi
cmpl   $0x4,0x20(%rsp,%r14,4)
lea    0xdc8(%rip),%rdi
je     11a2 <main+0x72>
test   %ecx,%ecx
jne    11ac <main+0x7c>
xor    %esi,%esi
cmpl   $0x4,0x20(%rsp,%r14,4)
lea    0xdc8(%rip),%rdi
je     11a2 <main+0x72>
jmp    11ac <main+0x7c>
mov    $0x2,%esi
lea    0xd5c(%rip),%rdi
jmp    11a2 <main+0x72>
mov    $0x3,%esi
lea    0xd68(%rip),%rdi
jmp    11a2 <main+0x72>
mov    $0x4,%esi
lea    0xd63(%rip),%rdi
jmp    11a2 <main+0x72>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [13 x i8] c"Door: CLOSED\00"
@.str.2 = [15 x i8] c"button_clicked\00"
@.str.3 = [15 x i8] c"\0ADoor: OPENING\00"
@.str.4 = [15 x i8] c"cycle_complete\00"
@.str.5 = [29 x i8] c"\0ADoor: STOPPED_WHILE_OPENING\00"
@.str.6 = [12 x i8] c"\0ADoor: OPEN\00"
@.str.7 = [15 x i8] c"\0ADoor: CLOSING\00"
@.str.8 = [29 x i8] c"\0ADoor: STOPPED_WHILE_CLOSING\00"
@.str.9 = [14 x i8] c"\0ADoor: CLOSED\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [100 x i32]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast [100 x i32]* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %65, label %8
8: ; preds = %0, %60
%9 = phi i64 [ %61, %60 ], [ 0, %0 ]
%10 = icmp eq i64 %9, 0
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %9
br label %12
12: ; preds = %8, %42
br i1 %10, label %13, label %15
13: ; preds = %12
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %12
%16 = call i32 @bcmp(i8* dereferenceable(15) %3, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32, i32* %11
switch i32 %19, label %20 [
i32 0, label %54
i32 5, label %54
]
20: ; preds = %18, %15
%21 = call i32 @bcmp(i8* dereferenceable(15) %3, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i64 15)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %11
%25 = icmp eq i32 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %23, %20
br i1 %17, label %27, label %30
27: ; preds = %26
%28 = load i32, i32* %11
%29 = icmp eq i32 %28, 1
br i1 %29, label %54, label %30
30: ; preds = %27, %26
br i1 %22, label %31, label %34
31: ; preds = %30
%32 = load i32, i32* %11
%33 = icmp eq i32 %32, 1
br i1 %33, label %54, label %34
34: ; preds = %31, %30
br i1 %17, label %35, label %39
35: ; preds = %34
%36 = load i32, i32* %11
%37 = and i32 %36, -2
%38 = icmp eq i32 %37, 2
br i1 %38, label %54, label %39
39: ; preds = %35, %34
br i1 %22, label %40, label %46
40: ; preds = %39
%41 = load i32, i32* %11
switch i32 %41, label %46 [
i32 2, label %42
i32 5, label %42
i32 3, label %42
]
42: ; preds = %40, %40, %40, %23
%43 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %65, label %12
46: ; preds = %40, %39
br i1 %17, label %47, label %50
47: ; preds = %46
%48 = load i32, i32* %11
%49 = icmp eq i32 %48, 4
br i1 %49, label %54, label %50
50: ; preds = %47, %46
br i1 %22, label %51, label %60
51: ; preds = %50
%52 = load i32, i32* %11
%53 = icmp eq i32 %52, 4
br i1 %53, label %54, label %60
54: ; preds = %35, %31, %27, %18, %18, %51, %47
%55 = phi i32 [ 5, %47 ], [ 0, %51 ], [ 1, %18 ], [ 1, %18 ], [ 2, %27 ], [ 3, %31 ], [ 4, %35 ]
%56 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), %47 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), %51 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %18 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), %27 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), %31 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), %35 ]
%57 = add nuw nsw i64 %9, 1
%58 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %57
store i32 %55, i32* %58
%59 = call i32 @printf(i8* dereferenceable(1) %56)
br label %60
60: ; preds = %54, %51, %50
%61 = add nuw i64 %9, 1
%62 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%63 = load i64, i64* @EOF
%64 = icmp eq i64 %62, %63
br i1 %64, label %65, label %8
65: ; preds = %60, %42, %0
ret i32 0
}