#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 *, int, char *);
void print_doors(int doors[]) {
  for (int i = 0; i <= 99; ++i)
    printf("Door #%d: %s\n", i + 1, doors[i] == 1 ? "Open" : "Closed");
}


x86 assembly (clang, -O0):
<print_doors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x63,-0xc(%rbp)
jg     116d <print_doors+0x5d>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xece(%rip),%rdx
lea    0xec2(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_doors+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_doors>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0xee9(%rip),%r12
lea    0xee7(%rip),%r13
lea    0xecd(%rip),%r15
jmp    1150 <print_doors+0x40>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0x64,%rbx
je     1163 <print_doors+0x53>
cmpl   $0x1,(%r14,%rbx,4)
lea    0x1(%rbx),%rbx
mov    %r12,%rdx
je     1140 <print_doors+0x30>
mov    %r13,%rdx
jmp    1140 <print_doors+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Door #%d: %s\0A\00"
@.str.1 = [5 x i8] c"Open\00"
@.str.2 = [7 x i8] c"Closed\00"
define void @print_doors(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %4
4: ; preds = %19, %1
%5 = load i32, i32* %3
%6 = icmp sle i32 %5, 99
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
%10 = load i32*, i32** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %17)
br label %19
19: ; preds = %7
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %4
22: ; preds = %4
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Door #%d: %s\0A\00"
@.str.1 = [5 x i8] c"Open\00"
@.str.2 = [7 x i8] c"Closed\00"
define void @print_doors(i32* nocapture %0) {
br label %3
2: ; preds = %3
ret void
3: ; preds = %1, %3
%4 = phi i64 [ 0, %1 ], [ %5, %3 ]
%5 = add nuw nsw i64 %4, 1
%6 = getelementptr inbounds i32, i32* %0, i64 %4
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%10 = trunc i64 %5 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %9)
%12 = icmp eq i64 %5, 100
br i1 %12, label %2, label %3
}