#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 *);
int main() {
  char is_open[100] = {0};
  int pass, door;
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door += pass + 1)
      is_open[door] = !is_open[door];
  for (door = 0; door < 100; ++door)
    printf("door #%d is %s.\n", door + 1, (is_open[door] ? "open" : "closed"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x0,-0x74(%rbp)
cmpl   $0x64,-0x74(%rbp)
jge    11a4 <main+0x84>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    1191 <main+0x71>
movslq -0x78(%rbp),%rax
cmpb   $0x0,-0x70(%rbp,%rax,1)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,%cl
movslq -0x78(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
add    -0x78(%rbp),%eax
mov    %eax,-0x78(%rbp)
jmp    1159 <main+0x39>
jmp    1196 <main+0x76>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1149 <main+0x29>
movl   $0x0,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    11f3 <main+0xd3>
mov    -0x78(%rbp),%esi
add    $0x1,%esi
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%ecx
lea    0xe4b(%rip),%rdx
lea    0xe3f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11ab <main+0x8b>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    $0x1,%eax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x0,(%rsp,%rdx,1)
sete   (%rsp,%rdx,1)
add    %rax,%rdx
cmp    $0x64,%rdx
jb     1160 <main+0x50>
mov    %rcx,%rdx
or     $0x1,%rdx
lea    0x1(%rax),%rsi
nopl   0x0(%rax)
cmpb   $0x0,(%rsp,%rdx,1)
sete   (%rsp,%rdx,1)
add    %rsi,%rdx
cmp    $0x64,%rdx
jb     1180 <main+0x70>
add    $0x2,%rcx
add    $0x2,%rax
cmp    $0x64,%rcx
jne    1150 <main+0x40>
xor    %ebx,%ebx
lea    0xe6e(%rip),%r15
lea    0xe62(%rip),%r12
lea    0xe4a(%rip),%r14
jmp    11d0 <main+0xc0>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    $0x64,%rbx
je     11e2 <main+0xd2>
cmpb   $0x0,(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
mov    %r15,%rdx
je     11c0 <main+0xb0>
mov    %r12,%rdx
jmp    11c0 <main+0xb0>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"door #%d is %s.\0A\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [7 x i8] c"closed\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [100 x i8]* %2 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %32, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 100
br i1 %8, label %9, label %35
9: ; preds = %6
%10 = load i32, i32* %3
store i32 %10, i32* %4
br label %11
11: ; preds = %26, %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 100
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = trunc i32 %21 to i8
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %24
store i8 %22, i8* %25
br label %26
26: ; preds = %14
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %4
%30 = add nsw i32 %29, %28
store i32 %30, i32* %4
br label %11
31: ; preds = %11
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %6
35: ; preds = %6
store i32 0, i32* %4
br label %36
36: ; preds = %51, %35
%37 = load i32, i32* %4
%38 = icmp slt i32 %37, 100
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, 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)
%50 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %41, i8* %49)
br label %51
51: ; preds = %39
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %36
54: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"door #%d is %s.\0A\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [7 x i8] c"closed\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %25, %0
%4 = phi i64 [ 1, %0 ], [ %27, %25 ]
%5 = phi i64 [ 0, %0 ], [ %26, %25 ]
br label %6
6: ; preds = %3, %6
%7 = phi i64 [ %5, %3 ], [ %12, %6 ]
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
%11 = zext i1 %10 to i8
store i8 %11, i8* %8
%12 = add nuw nsw i64 %7, %4
%13 = icmp ult i64 %12, 100
br i1 %13, label %6, label %14
14: ; preds = %6
%15 = or i64 %5, 1
%16 = add nuw nsw i64 %4, 1
br label %17
17: ; preds = %17, %14
%18 = phi i64 [ %15, %14 ], [ %23, %17 ]
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
%22 = zext i1 %21 to i8
store i8 %22, i8* %19
%23 = add nuw nsw i64 %18, %16
%24 = icmp ult i64 %23, 100
br i1 %24, label %17, label %25
25: ; preds = %17
%26 = add nuw nsw i64 %5, 2
%27 = add nuw nsw i64 %4, 2
%28 = icmp eq i64 %26, 100
br i1 %28, label %29, label %3
29: ; preds = %25, %29
%30 = phi i64 [ %31, %29 ], [ 0, %25 ]
%31 = add nuw nsw i64 %30, 1
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %30
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%36 = trunc i64 %31 to i32
%37 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %36, i8* %35)
%38 = icmp eq i64 %31, 100
br i1 %38, label %39, label %29
39: ; preds = %29
ret i32 0
}