#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 */
double CLOCKS_PER_SEC;
double clock();
scalar_t__ isPrime(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double clockStart, clockEnd;
  unsigned int pivot = 3;
  unsigned int j = 2;
  printf("Algorithm is online, Please wait....\n");
  clockStart = clock();
  while (j < 10001) {
    pivot += 2;
    if (isPrime(pivot))
      j++;
  }
  clockEnd = clock();
  printf("Algorithm end.\n");
  printf("Time: %f", (clockEnd - clockStart) / CLOCKS_PER_SEC);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x2711,-0x28(%rbp)
jae    11a4 <main+0x74>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <isPrime@plt>
cmp    $0x0,%rax
je     119f <main+0x6f>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116e <main+0x3e>
mov    $0x0,%al
call   1030 <clock@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    0x2e19(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe5c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x2,%ebp
mov    $0x5,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   1060 <isPrime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x2,%ebx
cmp    $0x2711,%ebp
jb     1170 <main+0x30>
xor    %eax,%eax
call   1040 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
mov    0x2e33(%rip),%rax
divsd  (%rax),%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Algorithm is online, Please wait....\0A\00"
@.str.1 = [16 x i8] c"Algorithm end.\0A\00"
@.str.2 = [9 x i8] c"Time: %f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 3, i32* %8
store i32 2, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = call double (...) @clock()
store double %11, double* %6
br label %12
12: ; preds = %24, %2
%13 = load i32, i32* %9
%14 = icmp ult i32 %13, 10001
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %8
%17 = add i32 %16, 2
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = call i64 @isPrime(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* %9
%23 = add i32 %22, 1
store i32 %23, i32* %9
br label %24
24: ; preds = %21, %15
br label %12
25: ; preds = %12
%26 = call double (...) @clock()
store double %26, double* %7
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%28 = load double, double* %7
%29 = load double, double* %6
%30 = fsub double %28, %29
%31 = load double, double* @CLOCKS_PER_SEC
%32 = fdiv double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %32)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [9 x i8] c"Time: %f\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@str = [37 x i8] c"Algorithm is online, Please wait....\00"
@str.3 = [15 x i8] c"Algorithm end.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%4 = tail call double (...) @clock()
br label %5
5: ; preds = %2, %5
%6 = phi i32 [ 2, %2 ], [ %12, %5 ]
%7 = phi i32 [ 3, %2 ], [ %8, %5 ]
%8 = add i32 %7, 2
%9 = tail call i64 @isPrime(i32 %8)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
%12 = add nuw nsw i32 %6, %11
%13 = icmp ult i32 %12, 10001
br i1 %13, label %5, label %14
14: ; preds = %5
%15 = tail call double (...) @clock()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.3, i64 0, i64 0))
%17 = fsub double %15, %4
%18 = load double, double* @CLOCKS_PER_SEC
%19 = fdiv double %17, %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %19)
ret i32 0
}