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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    1195 <main+0x75>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     116d <main+0x4d>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114d <main+0x2d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
xor    %edx,%edx
lea    0xec1(%rip),%r14
xor    %ebp,%ebp
jmp    116a <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
lea    0x1(%rdx),%ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
mov    %ebx,%edx
cmp    $0x3e8,%ebp
je     1174 <main+0x54>
cmp    0xc(%rsp),%edx
jl     1150 <main+0x30>
xor    %edx,%edx
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 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
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 0, i32* %2
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1000
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 0, i32* %3
br label %14
14: ; preds = %13, %9
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
br label %19
19: ; preds = %14
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %6
22: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 0, %0 ], [ %10, %4 ]
%6 = phi i32 [ 0, %0 ], [ %12, %4 ]
%7 = load i32, i32* %1
%8 = icmp slt i32 %5, %7
%9 = select i1 %8, i32 %5, i32 0
%10 = add nsw i32 %9, 1
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %9)
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, 1000
br i1 %13, label %14, label %4
14: ; preds = %4
ret i32 0
}