#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;
char *get_result(char *, char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char oper[22];
  char res[22];
  char state[22] = "CLOSED";
  char *get_res;
  int l = 0;
  while (scanf("%s", oper) != EOF) {
    get_res = get_result(res, state, oper);
    strcpy(state, get_res);
    if (l == 0) {
      printf("Door: CLOSED\n");
      l = 1;
    }
    printf("Door: %s\n", get_res);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x50(%rbp)
mov    0xe9f(%rip),%ax
mov    %ax,-0x4c(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe8b(%rip),%rdi
call   1060 <scanf@plt>
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%rax
je     11f8 <main+0xb8>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <get_result@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    11e1 <main+0xa1>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x6c(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movaps 0xe9b(%rip),%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0xe(%rsp)
lea    0xe9d(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x2e5e(%rip),%rbp
cmp    0x0(%rbp),%rax
je     1251 <main+0x101>
lea    0x40(%rsp),%rdi
mov    %rsp,%r15
lea    0x20(%rsp),%r14
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <get_result@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe62(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe38(%rip),%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
cmp    0x0(%rbp),%rax
je     1251 <main+0x101>
mov    %rsp,%r15
lea    0x20(%rsp),%rbx
lea    0xe1e(%rip),%r12
lea    0xe14(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x40(%rsp),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <get_result@plt>
mov    %rbp,%r14
mov    %rax,%rbp
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r14,%rbp
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    (%r14),%rax
jne    1210 <main+0xc0>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.state = [22 x i8] c"CLOSED\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 = [14 x i8] c"Door: CLOSED\0A\00"
@.str.2 = [10 x i8] c"Door: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [22 x i8]
%3 = alloca [22 x i8]
%4 = alloca [22 x i8]
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [22 x i8]* %4 to i8*
store i32 0, i32* %6
br label %8
8: ; preds = %25, %0
%9 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%17 = call i8* @get_result(i8* %14, i8* %15, i8* %16)
store i8* %17, i8** %5
%18 = getelementptr inbounds [22 x i8], [22 x i8]* %4, i64 0, i64 0
%19 = load i8*, i8** %5
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %25
25: ; preds = %23, %13
%26 = load i8*, i8** %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %8
28: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@__const.main.state = [22 x i8] c"CLOSED\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.2 = [10 x i8] c"Door: %s\0A\00"
@str = [13 x i8] c"Door: CLOSED\00"
define i32 @main() {
%1 = alloca [22 x i8]
%2 = alloca [22 x i8]
%3 = alloca [22 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %25, label %10
10: ; preds = %0
%11 = call i8* @get_result(i8* %5, i8* %6, i8* %4)
%12 = call i32 @strcpy(i8* %6, i8* %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%15 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%16 = load i64, i64* @EOF
%17 = icmp eq i64 %15, %16
br i1 %17, label %25, label %18
18: ; preds = %10, %18
%19 = call i8* @get_result(i8* %5, i8* %6, i8* %4)
%20 = call i32 @strcpy(i8* %6, i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%22 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%23 = load i64, i64* @EOF
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %18
25: ; preds = %18, %10, %0
ret i32 0
}