#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 generate_next_num(int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  char check_self_num[1000001];
  int i, next;
  memset(&check_self_num[0], 0x0, sizeof(char) * 1000001);
  for (i = 1; i < 1000001; i++) {
    if (check_self_num[i] == 0x0) {
      printf("%u\n", i);
    }
    next = generate_next_num(i);
    if (next < 1000001) {
      check_self_num[next] = 0x1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4260,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xf4250(%rbp),%rdi
xor    %esi,%esi
mov    $0xf4241,%edx
call   1040 <memset@plt>
movl   $0x1,-0xf4254(%rbp)
cmpl   $0xf4241,-0xf4254(%rbp)
jge    11e2 <main+0xb2>
movslq -0xf4254(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    1199 <main+0x69>
mov    -0xf4254(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0xf4254(%rbp),%edi
call   1050 <generate_next_num@plt>
mov    %eax,-0xf4258(%rbp)
cmpl   $0xf4241,-0xf4258(%rbp)
jge    11c9 <main+0x99>
movslq -0xf4258(%rbp),%rax
movb   $0x1,-0xf4250(%rbp,%rax,1)
01
jmp    11ce <main+0x9e>
mov    -0xf4254(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4254(%rbp)
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0xf4260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xf4248,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xf4241,%edx
call   1040 <memset@plt>
mov    $0x1,%ebx
lea    0xeab(%rip),%r14
jmp    116d <main+0x3d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0xf4241,%rbx
je     1193 <main+0x63>
cmpb   $0x0,(%rsp,%rbx,1)
jne    117d <main+0x4d>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1050 <generate_next_num@plt>
cmp    $0xf4240,%eax
jg     1160 <main+0x30>
cltq
movb   $0x1,(%rsp,%rax,1)
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0xf4248,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
define i32 @main() {
%1 = alloca [1000001 x i8]
%2 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 1000001)
br label %4
4: ; preds = %0, %18
%5 = phi i64 [ 1, %0 ], [ %19, %18 ]
%6 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
%9 = trunc i64 %5 to i32
br i1 %8, label %10, label %12
10: ; preds = %4
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %12
12: ; preds = %4, %10
%13 = call i32 @generate_next_num(i32 %9)
%14 = icmp slt i32 %13, 1000001
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = sext i32 %13 to i64
%17 = getelementptr inbounds [1000001 x i8], [1000001 x i8]* %1, i64 0, i64 %16
store i8 1, i8* %17
br label %18
18: ; preds = %12, %15
%19 = add nuw nsw i64 %5, 1
%20 = icmp eq i64 %19, 1000001
br i1 %20, label %21, label %4
21: ; preds = %18
ret i32 0
}