#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 *, char *);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char operator[20];
  char door[30] = "CLOSED";
  while (scanf("%s", operator) != EOF) {
    printf("\nDoor: %s", door);
    if (!strcmp(operator, "button_clicked")) {
      if (!(strcmp(door, "CLOSED"))) {
        strcpy(door, "OPENING");
      } else if (!strcmp(door, "OPEN")) {
        strcpy(door, "CLOSING");
      } else if (!strcmp(door, "OPENING")) {
        strcpy(door, "STOPPED_WHILE_OPENING");
      } else if (!strcmp(door, "CLOSING")) {
        strcpy(door, "STOPPED_WHILE_CLOSING");
      } else if (!strcmp(door, "STOPPED_WHILE_CLOSING")) {
        strcpy(door, "OPENING");
      } else if (!strcmp(door, "STOPPED_WHILE_OPENING")) {
        strcpy(door, "CLOSING");
      }
    } else if (!strcmp(operator, "cycle_complete")) {
      if (!strcmp(door, "CLOSING")) {
        strcpy(door, "CLOSED");
      } else if (!strcmp(door, "OPENING")) {
        strcpy(door, "OPEN");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xea4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xea2(%rip),%eax
mov    %eax,-0x28(%rbp)
mov    0xe9c(%rip),%ax
mov    %ax,-0x24(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1060 <scanf@plt>
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%rax
je     137e <main+0x23e>
lea    -0x40(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12fa <main+0x1ba>
lea    -0x40(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11fb <main+0xbb>
lea    -0x40(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12f5 <main+0x1b5>
lea    -0x40(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1229 <main+0xe9>
lea    -0x40(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12f0 <main+0x1b0>
lea    -0x40(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1257 <main+0x117>
lea    -0x40(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12eb <main+0x1ab>
lea    -0x40(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1285 <main+0x145>
lea    -0x40(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12e6 <main+0x1a6>
lea    -0x40(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12b3 <main+0x173>
lea    -0x40(%rbp),%rdi
lea    0xda8(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12e1 <main+0x1a1>
lea    -0x40(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12dc <main+0x19c>
lea    -0x40(%rbp),%rdi
lea    0xd90(%rip),%rsi
call   1030 <strcpy@plt>
jmp    12e1 <main+0x1a1>
jmp    12e6 <main+0x1a6>
jmp    12eb <main+0x1ab>
jmp    12f0 <main+0x1b0>
jmp    12f5 <main+0x1b5>
jmp    1379 <main+0x239>
lea    -0x20(%rbp),%rdi
lea    0xd6a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1374 <main+0x234>
lea    -0x40(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1341 <main+0x201>
lea    -0x40(%rbp),%rdi
lea    0xd00(%rip),%rsi
call   1030 <strcpy@plt>
jmp    136f <main+0x22f>
lea    -0x40(%rbp),%rdi
lea    0xd05(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    136a <main+0x22a>
lea    -0x40(%rbp),%rdi
lea    0xcd9(%rip),%rsi
call   1030 <strcpy@plt>
jmp    136f <main+0x22f>
jmp    1374 <main+0x234>
jmp    1379 <main+0x239>
jmp    1184 <main+0x44>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movups 0xf09(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movdqa 0xeee(%rip),%xmm0
movdqa %xmm0,(%rsp)
lea    0xf07(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e79(%rip),%r13
cmp    0x0(%r13),%rax
jne    1186 <main+0x56>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
movabs $0x635f6e6f74747562,%rbp
6e 5f 63
movabs $0x64656b63696c63,%r14
lea    0xec1(%rip),%r15
lea    0x20(%rsp),%r12
jmp    11d9 <main+0xa9>
lea    0xee7(%rip),%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    0x0(%r13),%rax
je     1175 <main+0x45>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x20(%rsp),%rax
xor    %rbp,%rax
mov    0x27(%rsp),%rcx
xor    %r14,%rcx
or     %rax,%rcx
je     1260 <main+0x130>
mov    0x20(%rsp),%rax
movabs $0x6f635f656c637963,%rcx
5f 63 6f
xor    %rcx,%rax
mov    0x27(%rsp),%rcx
movabs $0x6574656c706d6f,%rdx
xor    %rdx,%rcx
or     %rax,%rcx
jne    11c8 <main+0x98>
mov    (%rsp),%rax
lea    0xe46(%rip),%rsi
movabs $0x474e49534f4c43,%rcx
cmp    %rcx,%rax
je     11c0 <main+0x90>
movabs $0x474e494e45504f,%rcx
cmp    %rcx,%rax
jne    11c8 <main+0x98>
lea    0xe24(%rip),%rsi
jmp    11c0 <main+0x90>
nop
mov    (%rsp),%eax
mov    $0x534f4c43,%ecx
xor    %ecx,%eax
mov    0x3(%rsp),%ecx
mov    $0x444553,%edx
xor    %edx,%ecx
or     %eax,%ecx
lea    0xe13(%rip),%rsi
je     11c0 <main+0x90>
mov    (%rsp),%eax
mov    $0x4e45504f,%ecx
xor    %ecx,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
lea    0xe0b(%rip),%rsi
je     11c0 <main+0x90>
mov    (%rsp),%rax
lea    0xdd6(%rip),%rsi
movabs $0x474e494e45504f,%rcx
cmp    %rcx,%rax
je     11c0 <main+0x90>
movabs $0x474e49534f4c43,%rcx
cmp    %rcx,%rax
je     11ab <main+0x7b>
movdqu 0x6(%rsp),%xmm0
pcmpeqb 0xd1f(%rip),%xmm0
movdqa (%rsp),%xmm1
pcmpeqb 0xd22(%rip),%xmm1
pand   %xmm0,%xmm1
pmovmskb %xmm1,%eax
lea    0xd94(%rip),%rsi
cmp    $0xffff,%eax
je     11c0 <main+0x90>
movdqu 0x6(%rsp),%xmm0
pcmpeqb 0xd0a(%rip),%xmm0
movdqa (%rsp),%xmm1
pcmpeqb 0xd0d(%rip),%xmm1
pand   %xmm0,%xmm1
pmovmskb %xmm1,%eax
lea    0xd75(%rip),%rsi
cmp    $0xffff,%eax
jne    11c8 <main+0x98>
jmp    11c0 <main+0x90>

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

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