#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 */
scalar_t__ EOF;
int isprime(int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main() {
  int primes[1000000];
  int i;
  primes[0] = 0;
  for (i = 1; i < 1000000; i++) {
    if (isprime(i) == 1)
      primes[i] = primes[i - 1] + 1;
    else
      primes[i] = primes[i - 1];
  }
  while (scanf("%d\n", &i) != EOF) {
    printf("%d\n", primes[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3d0910(%rbp)
movl   $0x1,-0x3d0914(%rbp)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    11db <main+0xab>
mov    -0x3d0914(%rbp),%edi
call   1040 <isprime@plt>
cmp    $0x1,%eax
jne    11a2 <main+0x72>
mov    -0x3d0914(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x3d0910(%rbp,%rax,4),%ecx
add    $0x1,%ecx
movslq -0x3d0914(%rbp),%rax
mov    %ecx,-0x3d0910(%rbp,%rax,4)
jmp    11c2 <main+0x92>
mov    -0x3d0914(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x3d0910(%rbp,%rax,4),%ecx
movslq -0x3d0914(%rbp),%rax
mov    %ecx,-0x3d0910(%rbp,%rax,4)
jmp    11c7 <main+0x97>
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    1156 <main+0x26>
jmp    11e0 <main+0xb0>
lea    0xe19(%rip),%rdi
lea    -0x3d0914(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2dee(%rip),%rcx
cmp    (%rcx),%rax
je     1222 <main+0xf2>
movslq -0x3d0914(%rbp),%rax
mov    -0x3d0910(%rbp,%rax,4),%esi
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
jmp    11e0 <main+0xb0>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x3d0910,%rsp
movl   $0x0,0x10(%rsp)
mov    $0x1,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <isprime@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebp
mov    %ebp,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0xf4240,%rbx
jne    1150 <main+0x20>
movl   $0xf4240,0xc(%rsp)
lea    0xe7f(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e56(%rip),%rbp
cmp    0x0(%rbp),%rax
je     11d2 <main+0xa2>
lea    0xe61(%rip),%rbx
lea    0xc(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq 0xc(%rsp),%rax
mov    0x10(%rsp,%rax,4),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
cmp    0x0(%rbp),%rax
jne    11b0 <main+0x80>
xor    %eax,%eax
add    $0x3d0910,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000000 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 0
store i32 0, i32* %4
store i32 1, i32* %3
br label %5
5: ; preds = %32, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1000000
br i1 %7, label %8, label %35
8: ; preds = %5
%9 = load i32, i32* %3
%10 = call i32 @isprime(i32 %9)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %20
store i32 %18, i32* %21
br label %31
22: ; preds = %8
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %29
store i32 %27, i32* %30
br label %31
31: ; preds = %22, %12
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %5
35: ; preds = %5
br label %36
36: ; preds = %40, %35
%37 = call i64 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%38 = load i64, i64* @EOF
%39 = icmp ne i64 %37, %38
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
br label %36
46: ; preds = %36
ret i32 0
}

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