#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 */
typedef double time_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
double clock();
int /*<<< orphan*/ printf(char *, double);
int sqrt(int);
int main() {
  time_t t = clock();
  int numberOfPrimes = 0;
  for (int i = 10000 - 1; i > 1; i--) {
    int flag = 0;
    for (int j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 0)
      numberOfPrimes++;
  }
  printf("%d\n", numberOfPrimes);
  printf("%lf\n", (double)((double)clock() - t) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x270f,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jle    11e1 <main+0xb1>
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11bb <main+0x8b>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cmp    $0x0,%edx
jne    11a8 <main+0x78>
movl   $0x1,-0x1c(%rbp)
jmp    11bb <main+0x8b>
jmp    11ad <main+0x7d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <main+0x41>
cmpl   $0x0,-0x1c(%rbp)
jne    11ce <main+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d3 <main+0xa3>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1159 <main+0x29>
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
subsd  -0x10(%rbp),%xmm0
mov    0x2de3(%rip),%rax
divsd  (%rax),%xmm0
lea    0xdf4(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <clock@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x270f,%r15d
jmp    1178 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
setne  %cl
movzbl %cl,%eax
add    %eax,%r14d
lea    -0x1(%r15),%eax
cmp    $0x2,%r15d
mov    %eax,%r15d
jbe    11b2 <main+0x82>
mov    %r15d,%edi
call   1050 <sqrt@plt>
mov    $0x1,%cl
cmp    $0x2,%eax
jl     1165 <main+0x35>
mov    $0x2,%ebx
nopl   0x0(%rax)
mov    %r15d,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%ebp
test   %edx,%edx
je     1160 <main+0x30>
lea    0x1(%rbx),%r12d
mov    %r15d,%edi
call   1050 <sqrt@plt>
cmp    %eax,%ebx
mov    %r12d,%ebx
jl     1190 <main+0x60>
jmp    1160 <main+0x30>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2e0e(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [5 x i8] c"%lf\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main() {
%1 = tail call double (...) @clock()
br label %2
2: ; preds = %0, %25
%3 = phi i32 [ 9999, %0 ], [ %29, %25 ]
%4 = phi i32 [ 0, %0 ], [ %28, %25 ]
%5 = tail call i32 @sqrt(i32 %3)
%6 = icmp slt i32 %5, 2
br i1 %6, label %25, label %19
7: ; preds = %25
%8 = sitofp i32 %28 to double
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %8)
%10 = tail call double (...) @clock()
%11 = fsub double %10, %1
%12 = load double, double* @CLOCKS_PER_SEC
%13 = fdiv double %11, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %13)
ret i32 0
15: ; preds = %19
%16 = add nuw nsw i32 %20, 1
%17 = tail call i32 @sqrt(i32 %3)
%18 = icmp slt i32 %20, %17
br i1 %18, label %19, label %23
19: ; preds = %2, %15
%20 = phi i32 [ %16, %15 ], [ 2, %2 ]
%21 = urem i32 %3, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %15
23: ; preds = %19, %15
%24 = xor i1 %22, true
br label %25
25: ; preds = %23, %2
%26 = phi i1 [ true, %2 ], [ %24, %23 ]
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %4, %27
%29 = add nsw i32 %3, -1
%30 = icmp ugt i32 %3, 2
br i1 %30, label %2, label %7
}