#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int pancakes[1000];
  int i = 0;
  for (i; i < 1000; i++) {
    printf("Enter n:\n");
    scanf("%d", &pancakes[i]);
    if (pancakes[i] == 42)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xfb4(%rbp)
cmpl   $0x3e8,-0xfb4(%rbp)
jge    11ac <main+0x8c>
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
movslq -0xfb4(%rbp),%rax
lea    -0xfb0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe96(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xfb4(%rbp),%rax
cmpl   $0x2a,-0xfb0(%rbp,%rax,4)
2a
jne    1193 <main+0x73>
jmp    11ac <main+0x8c>
jmp    1198 <main+0x78>
mov    -0xfb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfb4(%rbp)
jmp    113c <main+0x1c>
xor    %eax,%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xfa0,%rsp
xor    %ebx,%ebx
lea    0xece(%rip),%r14
lea    0xec4(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
lea    (%rsp,%rbx,1),%rsi
mov    %r15,%rdi
call   1040 <scanf@plt>
cmpl   $0x2a,(%rsp,%rbx,1)
je     116a <main+0x4a>
lea    0x4(%rbx),%rax
cmp    $0xf9c,%rbx
mov    %rax,%rbx
jne    1140 <main+0x20>
xor    %eax,%eax
add    $0xfa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"Enter n:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = load i32, i32* %3
br label %5
5: ; preds = %21, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1000
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 42
br i1 %18, label %19, label %20
19: ; preds = %8
br label %24
20: ; preds = %8
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %5
24: ; preds = %19, %5
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [9 x i8] c"Enter n:\00"
define i32 @main() {
%1 = alloca [1000 x i32]
%2 = bitcast [1000 x i32]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %10, %3 ]
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %4
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 42
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 1000
%12 = select i1 %9, i1 true, i1 %11
br i1 %12, label %13, label %3
13: ; preds = %3
ret i32 0
}