#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__ is_prime(unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int);
int scanf(char *, unsigned int *);
int main() {
  unsigned maxn;
  if (scanf("%d", &maxn) != 1)
    return 0;
  unsigned nprimes = 2;
  for (unsigned n = 5; n < maxn; n += 2) {
    if (is_prime(n))
      nprimes++;
  }
  printf("%d\n", nprimes);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     1164 <main+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11bb <main+0x8b>
movl   $0x2,-0xc(%rbp)
movl   $0x5,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11ac <main+0x7c>
mov    -0x10(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1199 <main+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <main+0x6e>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <main+0x42>
mov    -0xc(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1185 <main+0x55>
mov    $0x2,%ebx
cmpl   $0x6,0x4(%rsp)
jb     1177 <main+0x47>
mov    $0x2,%ebx
mov    $0x5,%ebp
nop
mov    %ebp,%edi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    $0x2,%ebp
cmp    0x4(%rsp),%ebp
jb     1160 <main+0x30>
lea    0xe85(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%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)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %21
5: ; preds = %0
%6 = load i32, i32* %1
%7 = icmp ugt i32 %6, 5
br i1 %7, label %11, label %8
8: ; preds = %11, %5
%9 = phi i32 [ 2, %5 ], [ %17, %11 ]
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %21
11: ; preds = %5, %11
%12 = phi i32 [ %18, %11 ], [ 5, %5 ]
%13 = phi i32 [ %17, %11 ], [ 2, %5 ]
%14 = call i64 @is_prime(i32 %12)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = add i32 %13, %16
%18 = add i32 %12, 2
%19 = load i32, i32* %1
%20 = icmp ult i32 %18, %19
br i1 %20, label %11, label %8
21: ; preds = %0, %8
ret i32 0
}