#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 */
char EOF;
int /*<<< orphan*/ commands(char *);
int /*<<< orphan*/ printf(char *);
char read(char *);
int main() {
  char c;
  char string[15];
  printf("Door: CLOSED");
  while (c != EOF) {
    c = read(string);
    if (c == '\n') {
      commands(string);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x5(%rbp),%eax
mov    0x2e92(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1188 <main+0x58>
lea    -0x14(%rbp),%rdi
call   1050 <read@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    1183 <main+0x53>
lea    -0x14(%rbp),%rdi
call   1030 <commands@plt>
jmp    114b <main+0x1b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
lea    0x1(%rsp),%r14
mov    0x2e97(%rip),%r15
jmp    1165 <main+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    (%r15),%bl
je     117d <main+0x4d>
mov    %r14,%rdi
call   1050 <read@plt>
mov    %eax,%ebx
cmp    $0xa,%al
jne    1160 <main+0x30>
mov    %r14,%rdi
call   1030 <commands@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Door: CLOSED\00"
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [15 x i8]
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %20, %0
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %21
11: ; preds = %5
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%13 = call signext i8 @read(i8* %12)
store i8 %13, i8* %2
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%19 = call i32 @commands(i8* %18)
br label %20
20: ; preds = %17, %11
br label %5
21: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Door: CLOSED\00"
@EOF = global i8 0
define i32 @main() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %4
4: ; preds = %0, %9
%5 = call signext i8 @read(i8* %2)
%6 = icmp eq i8 %5, 10
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = call i32 @commands(i8* %2)
br label %9
9: ; preds = %7, %4
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %5, %10
br i1 %11, label %12, label %4
12: ; preds = %9
ret i32 0
}