#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;
scalar_t__ check_cycle_complete_function(char *);
int command_input_and_function(char *);
int /*<<< orphan*/ door_condition_bc(char *);
int /*<<< orphan*/ door_condition_cc(char *);
scalar_t__ is_correct_length(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ scanf(char *, char *);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
int main() {
  char command[20] = {0};
  char condition[21] = "CLOSED";
  printf("Door: %s\n", condition);
  while (scanf("%s", command) != EOF) {
    if (is_correct_length(command) == 0) {
      if (command_input_and_function(command) == 1) {
        strcpy(condition, door_condition_bc(condition));
        printf("Door: %s\n", condition);
      }
      if (command_input_and_function(command) == 2) {
        if (check_cycle_complete_function(condition) == 0) {
          strcpy(condition, door_condition_cc(condition));
        }
        printf("Door: %s\n", condition);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    0xe4a(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe47(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe45(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xe40(%rip),%al
mov    %al,-0x2c(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe2d(%rip),%rdi
call   1090 <scanf@plt>
mov    0x2dea(%rip),%rcx
cmp    (%rcx),%rax
je     12b3 <main+0x123>
lea    -0x20(%rbp),%rdi
call   10a0 <is_correct_length@plt>
cmp    $0x0,%rax
jne    12ae <main+0x11e>
lea    -0x20(%rbp),%rdi
call   1060 <command_input_and_function@plt>
cmp    $0x1,%eax
jne    1258 <main+0xc8>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   10b0 <door_condition_bc@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xdc2(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <command_input_and_function@plt>
cmp    $0x2,%eax
jne    12a9 <main+0x119>
lea    -0x40(%rbp),%rdi
call   1080 <check_cycle_complete_function@plt>
cmp    $0x0,%rax
jne    1299 <main+0x109>
lea    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1070 <door_condition_cc@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xd71(%rip),%rdi
call   1040 <printf@plt>
jmp    12ae <main+0x11e>
jmp    11e7 <main+0x57>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
movaps 0xe5d(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x2d(%rsp)
lea    0xe5d(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1040 <printf@plt>
lea    0xe56(%rip),%rdi
mov    %rsp,%rsi
call   1080 <scanf@plt>
mov    0x2e10(%rip),%r13
cmp    0x0(%r13),%rax
jne    11ee <main+0x6e>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %rsp,%rbx
lea    0x20(%rsp),%r14
lea    0xe18(%rip),%r15
lea    0xe1b(%rip),%r12
jmp    1231 <main+0xb1>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <scanf@plt>
cmp    0x0(%r13),%rax
je     11de <main+0x5e>
mov    %rbx,%rdi
call   1090 <is_correct_length@plt>
test   %rax,%rax
jne    1220 <main+0xa0>
mov    %rbx,%rdi
call   1050 <command_input_and_function@plt>
cmp    $0x1,%eax
jne    1268 <main+0xe8>
mov    %r14,%rdi
call   10a0 <door_condition_bc@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <command_input_and_function@plt>
cmp    $0x2,%eax
jne    1220 <main+0xa0>
mov    %r14,%rdi
call   1070 <check_cycle_complete_function@plt>
test   %rax,%rax
jne    1206 <main+0x86>
mov    %r14,%rdi
call   1060 <door_condition_cc@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
jmp    1206 <main+0x86>

LLVM IR (-O0):
@__const.main.condition = [21 x i8] c"CLOSED\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [10 x i8] c"Door: %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [21 x i8]
store i32 0, i32* %1
%4 = bitcast [20 x i8]* %2 to i8*
%5 = bitcast [21 x i8]* %3 to i8*
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %45, %0
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %46
13: ; preds = %8
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = call i64 @is_correct_length(i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %45
17: ; preds = %13
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%19 = call i32 @command_input_and_function(i8* %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%24 = call i32 @door_condition_bc(i8* %23)
%25 = call i32 @strcpy(i8* %22, i32 %24)
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %21, %17
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%30 = call i32 @command_input_and_function(i8* %29)
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %44
32: ; preds = %28
%33 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%34 = call i64 @check_cycle_complete_function(i8* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%39 = call i32 @door_condition_cc(i8* %38)
%40 = call i32 @strcpy(i8* %37, i32 %39)
br label %41
41: ; preds = %36, %32
%42 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%43 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %28
br label %45
45: ; preds = %44, %13
br label %8
46: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@__const.main.condition = [21 x i8] c"CLOSED\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [10 x i8] c"Door: %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [21 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %34, label %9
9: ; preds = %0, %30
%10 = call i64 @is_correct_length(i8* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = call i32 @command_input_and_function(i8* %3)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @door_condition_bc(i8* %4)
%17 = call i32 @strcpy(i8* %4, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %19
19: ; preds = %15, %12
%20 = call i32 @command_input_and_function(i8* %3)
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = call i64 @check_cycle_complete_function(i8* %4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = call i32 @door_condition_cc(i8* %4)
%27 = call i32 @strcpy(i8* %4, i32 %26)
br label %28
28: ; preds = %25, %22
%29 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %30
30: ; preds = %19, %28, %9
%31 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%32 = load i64, i64* @EOF
%33 = icmp eq i64 %31, %32
br i1 %33, label %34, label %9
34: ; preds = %30, %0
ret i32 0
}