#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];
  int pass;
  int door;
  for (door = 0; door < 100; ++door)
    is_open[door] = 0;
  for (pass = 0; pass < 100; ++pass)
    for (door = pass; door < 100; door = 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)
movl   $0x0,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    114a <main+0x3a>
movslq -0x78(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1129 <main+0x19>
movl   $0x0,-0x74(%rbp)
cmpl   $0x64,-0x74(%rbp)
jge    11ac <main+0x9c>
mov    -0x74(%rbp),%eax
mov    %eax,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    1199 <main+0x89>
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    -0x78(%rbp),%eax
add    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1161 <main+0x51>
jmp    119e <main+0x8e>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1151 <main+0x41>
movl   $0x0,-0x78(%rbp)
cmpl   $0x64,-0x78(%rbp)
jge    11fb <main+0xeb>
mov    -0x78(%rbp),%esi
add    $0x1,%esi
movslq -0x78(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%ecx
lea    0xe43(%rip),%rdx
lea    0xe37(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11b3 <main+0xa3>
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
store i32 0, i32* %4
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %8
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
br label %5
15: ; preds = %5
store i32 0, i32* %3
br label %16
16: ; preds = %42, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %45
19: ; preds = %16
%20 = load i32, i32* %3
store i32 %20, i32* %4
br label %21
21: ; preds = %36, %19
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 100
br i1 %23, label %24, label %41
24: ; preds = %21
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
%32 = trunc i32 %31 to i8
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %24
%37 = load i32, i32* %4
%38 = load i32, i32* %3
%39 = add nsw i32 %37, %38
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %21
41: ; preds = %21
br label %42
42: ; preds = %41
%43 = load i32, i32* %3
%44 = add nsw i32 %43, 1
store i32 %44, i32* %3
br label %16
45: ; preds = %16
store i32 0, i32* %4
br label %46
46: ; preds = %61, %45
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 100
br i1 %48, label %49, label %64
49: ; preds = %46
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp ne i32 %56, 0
%58 = zext i1 %57 to i64
%59 = select i1 %57, 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)
%60 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %51, i8* %59)
br label %61
61: ; preds = %49
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
br label %46
64: ; preds = %46
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
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %4
4: ; preds = %26, %0
%5 = phi i64 [ 1, %0 ], [ %28, %26 ]
%6 = phi i64 [ 0, %0 ], [ %27, %26 ]
br label %7
7: ; preds = %4, %7
%8 = phi i64 [ %6, %4 ], [ %13, %7 ]
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = zext i1 %11 to i8
store i8 %12, i8* %9
%13 = add nuw nsw i64 %8, %5
%14 = icmp ult i64 %13, 100
br i1 %14, label %7, label %15
15: ; preds = %7
%16 = or i64 %6, 1
%17 = add nuw nsw i64 %5, 1
br label %18
18: ; preds = %18, %15
%19 = phi i64 [ %16, %15 ], [ %24, %18 ]
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
%23 = zext i1 %22 to i8
store i8 %23, i8* %20
%24 = add nuw nsw i64 %19, %17
%25 = icmp ult i64 %24, 100
br i1 %25, label %18, label %26
26: ; preds = %18
%27 = add nuw nsw i64 %6, 2
%28 = add nuw nsw i64 %5, 2
%29 = icmp eq i64 %27, 100
br i1 %29, label %30, label %4
30: ; preds = %26, %30
%31 = phi i64 [ %32, %30 ], [ 0, %26 ]
%32 = add nuw nsw i64 %31, 1
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %31
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 0
%36 = select i1 %35, 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)
%37 = trunc i64 %32 to i32
%38 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %37, i8* %36)
%39 = icmp eq i64 %32, 100
br i1 %39, label %40, label %30
40: ; preds = %30
ret i32 0
}