#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[18];
  char button[] = "button_clicked";
  char cycle[] = "cycle_complete";
  int TemporaryDoorCondition = 0;
  printf("Door: CLOSED\n");
  for (; scanf("%s", Command) != EOF;) {
    if (!strcmp(Command, button) && TemporaryDoorCondition == 0) {
      TemporaryDoorCondition = 5;
      printf("Door: OPENING\n");
    } else if (!strcmp(Command, button) && TemporaryDoorCondition == 4) {
      TemporaryDoorCondition = 1;
      printf("Door: CLOSING\n");
    } else if (!strcmp(Command, button) && TemporaryDoorCondition == 5) {
      TemporaryDoorCondition = 6;
      printf("Door: STOPPED_WHILE_OPENING\n");
    } else if (!strcmp(Command, button) && TemporaryDoorCondition == 6) {
      TemporaryDoorCondition = 1;
      printf("Door: CLOSING\n");
    } else if (!strcmp(Command, button) && TemporaryDoorCondition == 1) {
      TemporaryDoorCondition = 2;
      printf("Door: STOPPED_WHILE_CLOSING\n");
    } else if (!strcmp(Command, button) && TemporaryDoorCondition == 2) {
      TemporaryDoorCondition = 5;
      printf("Door: OPENING\n");
    } else if (!strcmp(Command, cycle) && TemporaryDoorCondition == 5) {
      TemporaryDoorCondition = 4;
      printf("Door: OPEN\n");
    } else if (!strcmp(Command, cycle) && TemporaryDoorCondition == 1) {
      TemporaryDoorCondition = 0;
      printf("Door: CLOSED\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xeb8(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xeb2(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xeaa(%rip),%al
mov    %al,-0x21(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x3e(%rbp)
mov    0xe9f(%rip),%eax
mov    %eax,-0x36(%rbp)
mov    0xe99(%rip),%ax
mov    %ax,-0x32(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0x30(%rbp)
movl   $0x0,-0x44(%rbp)
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
je     13a5 <main+0x275>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11fa <main+0xca>
cmpl   $0x0,-0x44(%rbp)
jne    11fa <main+0xca>
movl   $0x5,-0x44(%rbp)
lea    0xe3f(%rip),%rdi
call   1030 <printf@plt>
jmp    13a0 <main+0x270>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1232 <main+0x102>
cmpl   $0x4,-0x44(%rbp)
jne    1232 <main+0x102>
movl   $0x1,-0x44(%rbp)
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    139b <main+0x26b>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    126a <main+0x13a>
cmpl   $0x5,-0x44(%rbp)
jne    126a <main+0x13a>
movl   $0x6,-0x44(%rbp)
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
jmp    1396 <main+0x266>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12a2 <main+0x172>
cmpl   $0x6,-0x44(%rbp)
jne    12a2 <main+0x172>
movl   $0x1,-0x44(%rbp)
lea    0xda6(%rip),%rdi
call   1030 <printf@plt>
jmp    1391 <main+0x261>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12da <main+0x1aa>
cmpl   $0x1,-0x44(%rbp)
jne    12da <main+0x1aa>
movl   $0x2,-0x44(%rbp)
lea    0xd9a(%rip),%rdi
call   1030 <printf@plt>
jmp    138c <main+0x25c>
lea    -0x20(%rbp),%rdi
lea    -0x2f(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1312 <main+0x1e2>
cmpl   $0x2,-0x44(%rbp)
jne    1312 <main+0x1e2>
movl   $0x5,-0x44(%rbp)
lea    0xd27(%rip),%rdi
call   1030 <printf@plt>
jmp    1387 <main+0x257>
lea    -0x20(%rbp),%rdi
lea    -0x3e(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    134a <main+0x21a>
cmpl   $0x5,-0x44(%rbp)
jne    134a <main+0x21a>
movl   $0x4,-0x44(%rbp)
lea    0xd47(%rip),%rdi
call   1030 <printf@plt>
jmp    1382 <main+0x252>
lea    -0x20(%rbp),%rdi
lea    -0x3e(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    137d <main+0x24d>
cmpl   $0x1,-0x44(%rbp)
jne    137d <main+0x24d>
movl   $0x0,-0x44(%rbp)
lea    0xca6(%rip),%rdi
call   1030 <printf@plt>
jmp    1382 <main+0x252>
jmp    1387 <main+0x257>
jmp    138c <main+0x25c>
jmp    1391 <main+0x261>
jmp    1396 <main+0x266>
jmp    139b <main+0x26b>
jmp    13a0 <main+0x270>
jmp    11a2 <main+0x72>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xedd(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    0x2e98(%rip),%rbx
cmp    (%rbx),%rax
je     12ac <main+0x18c>
xor    %r13d,%r13d
movabs $0x64656b63696c63,%rbp
lea    0xeb1(%rip),%r15
mov    %rsp,%r12
mov    (%rsp),%rcx
movabs $0x635f6e6f74747562,%rax
6e 5f 63
xor    %rax,%rcx
mov    0x7(%rsp),%rdx
xor    %rbp,%rdx
xor    %eax,%eax
or     %rcx,%rdx
setne  %al
mov    $0x5,%r14d
mov    %eax,%ecx
or     %r13d,%ecx
jne    11b0 <main+0x90>
lea    0xeda(%rip),%rdi
jmp    1290 <main+0x170>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r14d
test   %eax,%eax
jne    11d0 <main+0xb0>
cmp    $0x4,%r13d
jne    11d0 <main+0xb0>
lea    0xeaa(%rip),%rdi
jmp    1290 <main+0x170>
nopl   0x0(%rax)
test   %eax,%eax
jne    11eb <main+0xcb>
mov    $0x6,%r14d
lea    0xe74(%rip),%rdi
cmp    $0x5,%r13d
je     1290 <main+0x170>
test   %eax,%eax
jne    1206 <main+0xe6>
lea    0xe7b(%rip),%rdi
mov    $0x1,%r14d
cmp    $0x6,%r13d
je     1290 <main+0x170>
test   %eax,%eax
jne    121d <main+0xfd>
mov    $0x2,%r14d
lea    0xe22(%rip),%rdi
cmp    $0x1,%r13d
je     1290 <main+0x170>
test   %eax,%eax
jne    1234 <main+0x114>
lea    0xe57(%rip),%rdi
mov    $0x5,%r14d
cmp    $0x2,%r13d
je     1290 <main+0x170>
mov    (%rsp),%rcx
movabs $0x6f635f656c637963,%rax
5f 63 6f
xor    %rax,%rcx
mov    0x7(%rsp),%rdx
movabs $0x6574656c706d6f,%rax
xor    %rax,%rdx
xor    %eax,%eax
or     %rcx,%rdx
setne  %cl
jne    1274 <main+0x154>
mov    $0x4,%r14d
lea    0xdc0(%rip),%rdi
cmp    $0x5,%r13d
je     1290 <main+0x170>
mov    %cl,%al
test   %eax,%eax
jne    1298 <main+0x178>
xor    %r14d,%r14d
lea    0xd9d(%rip),%rdi
cmp    $0x1,%r13d
jne    1298 <main+0x178>
nopw   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %r14d,%r13d
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
cmp    (%rbx),%rax
jne    1170 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.button = [15 x i8] c"button_clicked\00"
@__const.main.cycle = [15 x i8] c"cycle_complete\00"
@.str = [14 x i8] c"Door: CLOSED\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.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_OPENING\0A\00"
@.str.5 = [29 x i8] c"Door: STOPPED_WHILE_CLOSING\0A\00"
@.str.6 = [12 x i8] c"Door: OPEN\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [18 x i8]
%3 = alloca [15 x i8]
%4 = alloca [15 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [15 x i8]* %3 to i8*
%7 = bitcast [15 x i8]* %4 to i8*
store i32 0, i32* %5
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %101, %0
%10 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %102
14: ; preds = %9
%15 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%17 = call i32 @strcmp(i8* %15, i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
store i32 5, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %101
24: ; preds = %19, %14
%25 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%26 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%27 = call i32 @strcmp(i8* %25, i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = load i32, i32* %5
%31 = icmp eq i32 %30, 4
br i1 %31, label %32, label %34
32: ; preds = %29
store i32 1, i32* %5
%33 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %100
34: ; preds = %29, %24
%35 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%36 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%37 = call i32 @strcmp(i8* %35, i8* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 5
br i1 %41, label %42, label %44
42: ; preds = %39
store i32 6, i32* %5
%43 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %99
44: ; preds = %39, %34
%45 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%46 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%47 = call i32 @strcmp(i8* %45, i8* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, 6
br i1 %51, label %52, label %54
52: ; preds = %49
store i32 1, i32* %5
%53 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %98
54: ; preds = %49, %44
%55 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%56 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%57 = call i32 @strcmp(i8* %55, i8* %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %64, label %59
59: ; preds = %54
%60 = load i32, i32* %5
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %64
62: ; preds = %59
store i32 2, i32* %5
%63 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %97
64: ; preds = %59, %54
%65 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%66 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%67 = call i32 @strcmp(i8* %65, i8* %66)
%68 = icmp ne i32 %67, 0
br i1 %68, label %74, label %69
69: ; preds = %64
%70 = load i32, i32* %5
%71 = icmp eq i32 %70, 2
br i1 %71, label %72, label %74
72: ; preds = %69
store i32 5, i32* %5
%73 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %96
74: ; preds = %69, %64
%75 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%76 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%77 = call i32 @strcmp(i8* %75, i8* %76)
%78 = icmp ne i32 %77, 0
br i1 %78, label %84, label %79
79: ; preds = %74
%80 = load i32, i32* %5
%81 = icmp eq i32 %80, 5
br i1 %81, label %82, label %84
82: ; preds = %79
store i32 4, i32* %5
%83 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %95
84: ; preds = %79, %74
%85 = getelementptr inbounds [18 x i8], [18 x i8]* %2, i64 0, i64 0
%86 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%87 = call i32 @strcmp(i8* %85, i8* %86)
%88 = icmp ne i32 %87, 0
br i1 %88, label %94, label %89
89: ; preds = %84
%90 = load i32, i32* %5
%91 = icmp eq i32 %90, 1
br i1 %91, label %92, label %94
92: ; preds = %89
store i32 0, i32* %5
%93 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %94
94: ; preds = %92, %89, %84
br label %95
95: ; preds = %94, %82
br label %96
96: ; preds = %95, %72
br label %97
97: ; preds = %96, %62
br label %98
98: ; preds = %97, %52
br label %99
99: ; preds = %98, %42
br label %100
100: ; preds = %99, %32
br label %101
101: ; preds = %100, %22
br label %9
102: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@__const.main.button = [15 x i8] c"button_clicked\00"
@__const.main.cycle = [15 x i8] c"cycle_complete\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@str.7 = [13 x i8] c"Door: CLOSED\00"
@str.8 = [11 x i8] c"Door: OPEN\00"
@str.10 = [28 x i8] c"Door: STOPPED_WHILE_CLOSING\00"
@str.12 = [28 x i8] c"Door: STOPPED_WHILE_OPENING\00"
@str.13 = [14 x i8] c"Door: CLOSING\00"
@str.14 = [14 x i8] c"Door: OPENING\00"
define i32 @main() {
%1 = alloca [18 x i8]
%2 = getelementptr inbounds [18 x i8], [18 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
%4 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %43, label %7
7: ; preds = %0, %38
%8 = phi i32 [ %39, %38 ], [ 0, %0 ]
%9 = call i32 @bcmp(i8* dereferenceable(15) %2, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @__const.main.button, i64 0, i64 0), i64 15)
%10 = icmp eq i32 %9, 0
%11 = icmp eq i32 %8, 0
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %34, label %13
13: ; preds = %7
%14 = icmp eq i32 %8, 4
%15 = select i1 %10, i1 %14, i1 false
br i1 %15, label %34, label %16
16: ; preds = %13
%17 = icmp eq i32 %8, 5
%18 = select i1 %10, i1 %17, i1 false
br i1 %18, label %34, label %19
19: ; preds = %16
%20 = icmp eq i32 %8, 6
%21 = select i1 %10, i1 %20, i1 false
br i1 %21, label %34, label %22
22: ; preds = %19
%23 = icmp eq i32 %8, 1
%24 = select i1 %10, i1 %23, i1 false
br i1 %24, label %34, label %25
25: ; preds = %22
%26 = icmp eq i32 %8, 2
%27 = select i1 %10, i1 %26, i1 false
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = call i32 @bcmp(i8* dereferenceable(15) %2, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @__const.main.cycle, i64 0, i64 0), i64 15)
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i1 %17, i1 false
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = select i1 %30, i1 %23, i1 false
br i1 %33, label %34, label %38
34: ; preds = %32, %28, %25, %22, %19, %16, %13, %7
%35 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0), %7 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0), %13 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.12, i64 0, i64 0), %16 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0), %19 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.10, i64 0, i64 0), %22 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0), %25 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0), %28 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0), %32 ]
%36 = phi i32 [ 5, %7 ], [ 1, %13 ], [ 6, %16 ], [ 1, %19 ], [ 2, %22 ], [ 5, %25 ], [ 4, %28 ], [ 0, %32 ]
%37 = call i32 @puts(i8* dereferenceable(1) %35)
br label %38
38: ; preds = %34, %32
%39 = phi i32 [ %8, %32 ], [ %36, %34 ]
%40 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %7
43: ; preds = %38, %0
ret i32 0
}