#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 */
int /*<<< orphan*/ printf(char *);
void PrintState(int state, int stopped) {
  if (state == -2 && stopped == 1)
    printf("Door: CLOSED");
  if (state == 2 && stopped == 1)
    printf("Door: OPEN");
  if (state == -1 && stopped == 1)
    printf("Door: STOPPED_WHILE_CLOSING");
  if (state == 1 && stopped == 1)
    printf("Door: STOPPED_WHILE_OPENING");
  if (state == -1 && stopped == 0)
    printf("Door: CLOSING");
  if (state == 1 && stopped == 0)
    printf("Door: OPENING");
}


x86 assembly (clang, -O0):
<PrintState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0xfffffffe,-0x4(%rbp)
jne    113e <PrintState+0x2e>
cmpl   $0x1,-0x8(%rbp)
jne    113e <PrintState+0x2e>
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x4(%rbp)
jne    115e <PrintState+0x4e>
cmpl   $0x1,-0x8(%rbp)
jne    115e <PrintState+0x4e>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    117e <PrintState+0x6e>
cmpl   $0x1,-0x8(%rbp)
jne    117e <PrintState+0x6e>
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    119e <PrintState+0x8e>
cmpl   $0x1,-0x8(%rbp)
jne    119e <PrintState+0x8e>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    11be <PrintState+0xae>
cmpl   $0x0,-0x8(%rbp)
jne    11be <PrintState+0xae>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x1,-0x4(%rbp)
jne    11de <PrintState+0xce>
cmpl   $0x0,-0x8(%rbp)
jne    11de <PrintState+0xce>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintState>:
push   %rbp
push   %rbx
push   %rax
cmp    $0xfffffffe,%edi
jne    1128 <PrintState+0x18>
cmp    $0x1,%esi
jne    1128 <PrintState+0x18>
xor    %ebp,%ebp
lea    0xeda(%rip),%rdi
jmp    113b <PrintState+0x2b>
cmp    $0x2,%edi
jne    115b <PrintState+0x4b>
cmp    $0x1,%esi
jne    115b <PrintState+0x4b>
xor    %ebp,%ebp
lea    0xed2(%rip),%rdi
xor    %ebx,%ebx
call   1030 <printf@plt>
test   %bpl,%bpl
je     1154 <PrintState+0x44>
test   %bl,%bl
je     1154 <PrintState+0x44>
lea    0xf0c(%rip),%rdi
jmp    1182 <PrintState+0x72>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0xffffffff,%edi
jne    116e <PrintState+0x5e>
cmp    $0x1,%esi
jne    116e <PrintState+0x5e>
lea    0xeac(%rip),%rdi
jmp    1182 <PrintState+0x72>
cmp    $0x1,%edi
sete   %bl
jne    118d <PrintState+0x7d>
cmp    $0x1,%esi
jne    118d <PrintState+0x7d>
lea    0xeb2(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
test   %esi,%esi
sete   %bpl
jne    1142 <PrintState+0x32>
cmp    $0xffffffff,%edi
jne    1142 <PrintState+0x32>
mov    $0x1,%bpl
lea    0xeac(%rip),%rdi
jmp    113d <PrintState+0x2d>

LLVM IR (-O0):
@.str = [13 x i8] c"Door: CLOSED\00"
@.str.1 = [11 x i8] c"Door: OPEN\00"
@.str.2 = [28 x i8] c"Door: STOPPED_WHILE_CLOSING\00"
@.str.3 = [28 x i8] c"Door: STOPPED_WHILE_OPENING\00"
@.str.4 = [14 x i8] c"Door: CLOSING\00"
@.str.5 = [14 x i8] c"Door: OPENING\00"
define void @PrintState(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, -2
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %7, %2
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %12
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %23, %20
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %31, %28
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %44
39: ; preds = %36
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %39, %36
%45 = load i32, i32* %3
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* %4
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %52
52: ; preds = %50, %47, %44
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Door: CLOSED\00"
@.str.1 = [11 x i8] c"Door: OPEN\00"
@.str.2 = [28 x i8] c"Door: STOPPED_WHILE_CLOSING\00"
@.str.3 = [28 x i8] c"Door: STOPPED_WHILE_OPENING\00"
@.str.4 = [14 x i8] c"Door: CLOSING\00"
@.str.5 = [14 x i8] c"Door: OPENING\00"
define void @PrintState(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, -2
%4 = icmp eq i32 %1, 1
%5 = and i1 %3, %4
br i1 %5, label %18, label %6
6: ; preds = %2
%7 = icmp eq i32 %0, 2
%8 = and i1 %7, %4
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = icmp eq i32 %0, -1
%11 = and i1 %10, %4
br i1 %11, label %27, label %12
12: ; preds = %9
%13 = icmp eq i32 %0, 1
%14 = and i1 %13, %4
br i1 %14, label %27, label %15
15: ; preds = %12
%16 = icmp eq i32 %1, 0
%17 = and i1 %16, %10
br i1 %17, label %18, label %23
18: ; preds = %15, %2, %6
%19 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %15 ]
%20 = phi i1 [ false, %2 ], [ false, %6 ], [ true, %15 ]
%21 = phi i1 [ false, %2 ], [ false, %6 ], [ %13, %15 ]
%22 = tail call i32 @printf(i8* dereferenceable(1) %19)
br label %23
23: ; preds = %18, %15
%24 = phi i1 [ %16, %15 ], [ %20, %18 ]
%25 = phi i1 [ %13, %15 ], [ %21, %18 ]
%26 = and i1 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %23, %12, %9
%28 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %23 ]
%29 = tail call i32 @printf(i8* dereferenceable(1) %28)
br label %30
30: ; preds = %27, %23
ret void
}