#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 scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
unsigned long long ULLONG_MAX;
scalar_t__ clock();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double, unsigned long long);
int scanf(char *, double *);
unsigned long long sqrt(unsigned long long);
int /*<<< orphan*/ stderr;
int main() {
  unsigned long long i, j, largestFound;
  bool flag;
  clock_t begin, end;
  double time_spent;
  double executingTime;
  if ((scanf("%lf%*c", &executingTime)) != 1) {
    fprintf(stderr, "Incorect input!");
    exit(1);
  }
  begin = clock();
  for (i = 2; i < ULLONG_MAX; i++) {
    flag = 0;
    for (j = 2; j <= sqrt(i); j++) {
      if ((i % j) == 0) {
        flag = 1;
        break;
      }
      time_spent = (double)((end = clock()) - begin) / CLOCKS_PER_SEC;
      if (time_spent >= executingTime) {
        break;
      }
    }
    if (flag == 0) {
      largestFound = i;
    }
    time_spent = (double)((end = clock()) - begin) / CLOCKS_PER_SEC;
    if (time_spent >= executingTime) {
      break;
    }
  }
  printf("Largest found prime number for %g seconds is %llu\n", executingTime,
         largestFound);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
je     11a7 <main+0x47>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
movq   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e23(%rip),%rcx
cmp    (%rcx),%rax
jae    12d0 <main+0x170>
movl   $0x0,-0x24(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <sqrt@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
ja     126f <main+0x10f>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1220 <main+0xc0>
movl   $0x1,-0x24(%rbp)
jmp    126f <main+0x10f>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2da5(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     1259 <main+0xf9>
jmp    126f <main+0x10f>
jmp    125e <main+0xfe>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11dd <main+0x7d>
cmpl   $0x0,-0x24(%rbp)
jne    1281 <main+0x121>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x38(%rbp)
sub    -0x30(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d44(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jb     12ba <main+0x15a>
jmp    12d0 <main+0x170>
jmp    12bf <main+0x15f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11ba <main+0x5a>
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rsi
lea    0xd37(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    127e <main+0x11e>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r14
mov    $0x2,%ebx
mov    0x2e47(%rip),%r12
mov    0x2e48(%rip),%rbp
mov    %rbx,%rdi
call   1070 <sqrt@plt>
mov    %rbx,%r15
cmp    $0x2,%rax
jb     122a <main+0xca>
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     11e0 <main+0x80>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
test   %rdx,%rdx
jne    11eb <main+0x8b>
jmp    1220 <main+0xc0>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %ebp
test   %rdx,%rdx
je     1220 <main+0xc0>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r12),%xmm0
ucomisd (%rsp),%xmm0
jae    121b <main+0xbb>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1070 <sqrt@plt>
cmp    %rax,%rbp
jbe    11c0 <main+0x60>
mov    %rbx,%r15
jmp    1223 <main+0xc3>
mov    %r13,%r15
mov    0x2dbe(%rip),%rbp
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
divsd  (%r12),%xmm1
movsd  (%rsp),%xmm0
ucomisd %xmm0,%xmm1
jae    125e <main+0xfe>
add    $0x1,%rbx
mov    %r15,%r13
cmp    0x0(%rbp),%rbx
jb     11a0 <main+0x40>
lea    0xdb2(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
lea    0xd79(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%lf%*c\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Incorect input!\00"
@ULLONG_MAX = global i64 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [51 x i8] c"Largest found prime number for %g seconds is %llu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %9)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = call i64 (...) @clock()
store i64 %17, i64* %6
store i64 2, i64* %2
br label %18
18: ; preds = %66, %16
%19 = load i64, i64* %2
%20 = load i64, i64* @ULLONG_MAX
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %69
22: ; preds = %18
store i32 0, i32* %5
store i64 2, i64* %3
br label %23
23: ; preds = %46, %22
%24 = load i64, i64* %3
%25 = load i64, i64* %2
%26 = call i64 @sqrt(i64 %25)
%27 = icmp ule i64 %24, %26
br i1 %27, label %28, label %49
28: ; preds = %23
%29 = load i64, i64* %2
%30 = load i64, i64* %3
%31 = urem i64 %29, %30
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %5
br label %49
34: ; preds = %28
%35 = call i64 (...) @clock()
store i64 %35, i64* %7
%36 = load i64, i64* %6
%37 = sub nsw i64 %35, %36
%38 = sitofp i64 %37 to double
%39 = load double, double* @CLOCKS_PER_SEC
%40 = fdiv double %38, %39
store double %40, double* %8
%41 = load double, double* %8
%42 = load double, double* %9
%43 = fcmp oge double %41, %42
br i1 %43, label %44, label %45
44: ; preds = %34
br label %49
45: ; preds = %34
br label %46
46: ; preds = %45
%47 = load i64, i64* %3
%48 = add i64 %47, 1
store i64 %48, i64* %3
br label %23
49: ; preds = %44, %33, %23
%50 = load i32, i32* %5
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = load i64, i64* %2
store i64 %53, i64* %4
br label %54
54: ; preds = %52, %49
%55 = call i64 (...) @clock()
store i64 %55, i64* %7
%56 = load i64, i64* %6
%57 = sub nsw i64 %55, %56
%58 = sitofp i64 %57 to double
%59 = load double, double* @CLOCKS_PER_SEC
%60 = fdiv double %58, %59
store double %60, double* %8
%61 = load double, double* %8
%62 = load double, double* %9
%63 = fcmp oge double %61, %62
br i1 %63, label %64, label %65
64: ; preds = %54
br label %69
65: ; preds = %54
br label %66
66: ; preds = %65
%67 = load i64, i64* %2
%68 = add i64 %67, 1
store i64 %68, i64* %2
br label %18
69: ; preds = %64, %18
%70 = load double, double* %9
%71 = load i64, i64* %4
%72 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), double %70, i64 %71)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%lf%*c\00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Incorect input!\00"
@ULLONG_MAX = global i64 0
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [51 x i8] c"Largest found prime number for %g seconds is %llu\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i64 (...) @clock()
%11 = load i64, i64* @ULLONG_MAX
%12 = icmp ugt i64 %11, 2
br label %13
13: ; preds = %34, %9
%14 = phi i64 [ 2, %9 ], [ %43, %34 ]
%15 = phi i64 [ undef, %9 ], [ %35, %34 ]
%16 = call i64 @sqrt(i64 %14)
%17 = icmp ult i64 %16, 2
br i1 %17, label %34, label %21
18: ; preds = %25
%19 = call i64 @sqrt(i64 %14)
%20 = icmp ugt i64 %33, %19
br i1 %20, label %34, label %21
21: ; preds = %13, %18
%22 = phi i64 [ %33, %18 ], [ 2, %13 ]
%23 = urem i64 %14, %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %34, label %25
25: ; preds = %21
%26 = call i64 (...) @clock()
%27 = sub nsw i64 %26, %10
%28 = sitofp i64 %27 to double
%29 = load double, double* @CLOCKS_PER_SEC
%30 = fdiv double %28, %29
%31 = load double, double* %1
%32 = fcmp ult double %30, %31
%33 = add i64 %22, 1
br i1 %32, label %18, label %34
34: ; preds = %21, %25, %18, %13
%35 = phi i64 [ %14, %13 ], [ %14, %18 ], [ %14, %25 ], [ %15, %21 ]
%36 = call i64 (...) @clock()
%37 = sub nsw i64 %36, %10
%38 = sitofp i64 %37 to double
%39 = load double, double* @CLOCKS_PER_SEC
%40 = fdiv double %38, %39
%41 = load double, double* %1
%42 = fcmp ult double %40, %41
%43 = add nuw i64 %14, 1
%44 = load i64, i64* @ULLONG_MAX
%45 = icmp ult i64 %43, %44
%46 = select i1 %42, i1 %45, i1 false
br i1 %46, label %13, label %47
47: ; preds = %34
%48 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), double %41, i64 %35)
ret i32 0
}