#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int X, Y, i = 0, k;
  scanf(" %d", &X);
  while (i < 1000) {
    k = 0;
    while (k < X && i < 1000) {
      printf("N[%d] = %d\n", i, k);
      k++;
      i++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3e8,-0x10(%rbp)
jge    11b6 <main+0x96>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x15(%rbp)
jge    1178 <main+0x58>
cmpl   $0x3e8,-0x10(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1188 <main+0x68>
jmp    11b1 <main+0x91>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <main+0x3a>
jmp    1146 <main+0x26>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
xor    %r15d,%r15d
mov    0x4(%rsp),%eax
lea    0xebe(%rip),%r14
jmp    115c <main+0x3c>
nopl   0x0(%rax,%rax,1)
add    %ebx,%r15d
cmp    $0x3e7,%r15d
jg     1195 <main+0x75>
test   %eax,%eax
jle    1153 <main+0x33>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%ebp
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0x1,%ebx
mov    0x4(%rsp),%eax
cmp    %eax,%ebx
jge    1150 <main+0x30>
cmp    $0x3e7,%ebp
jl     1170 <main+0x50>
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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