#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 long);
int /*<<< orphan*/ printf(char *, float);
float timeit();
int main(int argc, char *argv[]) {
  float start = timeit();
  unsigned long curr, cnt;
  for (curr = 3, cnt = 1; cnt < 10001; curr += 2) {
    if (is_prime(curr))
      cnt++;
  }
  float stop = timeit();
  printf("Answer: %ld\n", curr - 2);
  printf("Time: %.8f\n", stop - start);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <timeit@plt>
movss  %xmm0,-0x14(%rbp)
movq   $0x3,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
cmpq   $0x2711,-0x28(%rbp)
jae    11a5 <main+0x75>
mov    -0x20(%rbp),%rdi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     118f <main+0x5f>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1194 <main+0x64>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1162 <main+0x32>
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0x34(%rbp)
test   %rax,%rax
movss  %xmm0,-0x30(%rbp)
js     11f2 <main+0xc2>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
movss  -0x2c(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x1,%r14d
mov    $0x1,%ebx
nopl   0x0(%rax)
add    $0x2,%r14
mov    %r14,%rdi
call   1040 <is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffffffffffff,%rbx
cmp    $0x2711,%rbx
jb     1150 <main+0x20>
xor    %eax,%eax
call   1050 <timeit@plt>
movss  %xmm0,(%rsp)
test   %r14,%r14
js     1188 <main+0x58>
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
jmp    11a1 <main+0x71>
mov    %r14,%rax
shr    %rax
and    $0x1,%r14d
or     %rax,%r14
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
addss  %xmm0,%xmm0
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
movss  (%rsp),%xmm0
subss  0x4(%rsp),%xmm0
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Answer: %ld\0A\00"
@.str.1 = [12 x i8] c"Time: %.8f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call float (...) @timeit()
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 3, %2 ], [ %9, %4 ]
%6 = phi i64 [ 1, %2 ], [ %11, %4 ]
%7 = tail call i64 @is_prime(i64 %5)
%8 = icmp ne i64 %7, 0
%9 = add i64 %5, 2
%10 = zext i1 %8 to i64
%11 = add nuw nsw i64 %6, %10
%12 = icmp ult i64 %11, 10001
br i1 %12, label %4, label %13
13: ; preds = %4
%14 = tail call float (...) @timeit()
%15 = uitofp i64 %5 to float
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), float %15)
%17 = fsub float %14, %3
%18 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), float %17)
ret i32 0
}