#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;
scalar_t__ clock();
int /*<<< orphan*/ printf(char *, ...);
long long rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  long long i, j, min_num, a;
  int found_divisor;
  long tries, counter = 0, exponent;
  double stime, ftime;
  long long result, base;
  printf("Searching for primes between %i and %i \n", 1990000001, 2000000000);
  printf("Trying deterministic alorithm \n");
  stime = ((double)clock()) / CLOCKS_PER_SEC;
  if (1990000001 <= 2) {
    counter++;
  }
  if (1990000001 <= 3) {
    counter++;
    min_num = 5;
  } else if (1990000001 % 2 == 0) {
    min_num = 1990000001 + 1;
  } else {
    min_num = 1990000001;
  }
  for (i = min_num; i <= 2000000000; i = i + 2) {
    found_divisor = 0;
    j = 11;
    if ((i % 3 != 0 && i % 5 != 0 && i % 7 != 0) || (i == 5 || i == 7)) {
      do {
        if (i % j == 0 && i != j || i % (j + 2) == 0 && i != (j + 2)) {
          found_divisor = 1;
          break;
        } else {
          j = j + 6;
        }
      } while (j * j <= i);
      if (!found_divisor) {
        counter++;
      }
    }
  }
  ftime = ((double)clock()) / CLOCKS_PER_SEC;
  printf("Deterministic algorithm: found %ld primes \n", counter);
  printf("in %fl secs \n", ftime - stime);
  printf("Trying Fermat test \n");
  srand(time(NULL));
  for (tries = 1; tries <= 10; tries++) {
    stime = ((double)clock()) / CLOCKS_PER_SEC;
    counter = 0;
    if (1990000001 <= 2) {
      counter = 1;
    }
    for (i = min_num; i <= 2000000000; i++) {
      found_divisor = 0;
      j = 0;
      do {
        j++;
        a = rand() % (i - 1) + 1;
        base = a;
        base = base % i;
        exponent = i - 1;
        result = 1;
        while (exponent > 0) {
          if (exponent % 2 == 1) {
            result = (result * base) % (i);
          }
          exponent = exponent >> 1;
          base = (base * base) % (i);
        }
        if (result != 1) {
          found_divisor = 1;
        }
      } while (j < tries && !found_divisor);
      if (!found_divisor) {
        counter++;
      }
    }
    ftime = ((double)clock()) / CLOCKS_PER_SEC;
    printf("Probabilistic algorithm: Found %ld  primes in %fl  secs , (tries = "
           "%ld) \n",
           counter, ftime - stime, tries);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x40(%rbp)
lea    0xe92(%rip),%rdi
mov    $0x769cfd81,%esi
mov    $0x77359400,%edx
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e48(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movq   $0x769cfd81,-0x20(%rbp)
76
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x77359400,-0x10(%rbp)
77
jg     12ec <main+0x19c>
movl   $0x0,-0x2c(%rbp)
movq   $0xb,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     121e <main+0xce>
mov    -0x10(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     121e <main+0xce>
mov    -0x10(%rbp),%rax
mov    $0x7,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1234 <main+0xe4>
cmpq   $0x5,-0x10(%rbp)
je     1234 <main+0xe4>
cmpq   $0x7,-0x10(%rbp)
jne    12d6 <main+0x186>
jmp    1239 <main+0xe9>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    125b <main+0x10b>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    128b <main+0x13b>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x2,%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1297 <main+0x147>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
add    $0x2,%rcx
cmp    %rcx,%rax
je     1297 <main+0x147>
movl   $0x1,-0x2c(%rbp)
jmp    12bb <main+0x16b>
mov    -0x18(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x18(%rbp)
jmp    12a8 <main+0x158>
mov    -0x18(%rbp),%rax
imul   -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1239 <main+0xe9>
cmpl   $0x0,-0x2c(%rbp)
jne    12d1 <main+0x181>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    12d6 <main+0x186>
jmp    12db <main+0x18b>
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    11b9 <main+0x69>
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2ce9(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
lea    0xd4a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movq   $0x1,-0x38(%rbp)
cmpq   $0xa,-0x38(%rbp)
jg     1512 <main+0x3c2>
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2c72(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x77359400,-0x10(%rbp)
77
jg     14c5 <main+0x375>
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
cqto
idiv   %rcx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x68(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x48(%rbp)
movq   $0x1,-0x60(%rbp)
cmpq   $0x0,-0x48(%rbp)
jle    1458 <main+0x308>
mov    -0x48(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x1,%rdx
jne    1434 <main+0x2e4>
mov    -0x60(%rbp),%rax
imul   -0x68(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x60(%rbp)
mov    -0x48(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x68(%rbp),%rax
imul   -0x68(%rbp),%rax
cqto
idivq  -0x10(%rbp)
mov    %rdx,-0x68(%rbp)
jmp    13fe <main+0x2ae>
cmpq   $0x1,-0x60(%rbp)
je     146a <main+0x31a>
movl   $0x1,-0x2c(%rbp)
jmp    146f <main+0x31f>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x69(%rbp)
jge    148e <main+0x33e>
cmpl   $0x0,-0x2c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    13ac <main+0x25c>
cmpl   $0x0,-0x2c(%rbp)
jne    14af <main+0x35f>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    14b4 <main+0x364>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    138f <main+0x23f>
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2b10(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x40(%rbp),%rsi
movsd  -0x58(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x38(%rbp),%rdx
lea    0xb9e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1358 <main+0x208>
xor    %eax,%eax
add    $0x70,%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
xor    %ebx,%ebx
mov    $0x769cfd81,%esi
mov    $0x77359400,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf21(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r8
mov    0x2e46(%rip),%r14
movsd  (%r14),%xmm0
mov    $0x769cfd81,%esi
mov    $0xcccccccd,%edi
jmp    11d8 <main+0x78>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
lea    0x2(%rsi),%rax
cmp    $0x773593ff,%rsi
mov    %rax,%rsi
jae    12a5 <main+0x145>
imul   $0xaaaaaaab,%esi,%eax
cmp    $0x55555556,%eax
jb     1205 <main+0xa5>
mov    %esi,%eax
imul   %rdi,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
mov    %esi,%ecx
sub    %eax,%ecx
je     1205 <main+0xa5>
imul   $0xb6db6db7,%esi,%eax
cmp    $0x24924924,%eax
ja     1212 <main+0xb2>
mov    %rsi,%rax
or     $0x2,%rax
cmp    $0x7,%rax
jne    11c4 <main+0x64>
mov    $0xb,%ebp
jmp    1234 <main+0xd4>
nopl   0x0(%rax)
add    $0x6,%rbp
imul   %rbp,%rbp
add    $0x4,%rcx
cmp    %rsi,%rbp
mov    %rcx,%rbp
ja     11c0 <main+0x60>
mov    %rsi,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1250 <main+0xf0>
mov    %rsi,%rax
xor    %edx,%edx
div    %rbp
cmp    %rbp,%rsi
jne    125b <main+0xfb>
jmp    1264 <main+0x104>
nop
mov    %esi,%eax
xor    %edx,%edx
div    %ebp
cmp    %rbp,%rsi
je     1264 <main+0x104>
test   %rdx,%rdx
je     11c4 <main+0x64>
lea    0x2(%rbp),%rcx
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1290 <main+0x130>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
cmp    %rcx,%rsi
jne    129b <main+0x13b>
jmp    1220 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
cmp    %rcx,%rsi
je     1220 <main+0xc0>
test   %rdx,%rdx
jne    1220 <main+0xc0>
jmp    11c4 <main+0x64>
cvtsi2sd %r8,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
subsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0xd51(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd6c(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x1,%ebx
jmp    1374 <main+0x214>
cs nopw 0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r12,%xmm0
divsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2ca0(%rip),%r14
divsd  (%r14),%xmm0
subsd  (%rsp),%xmm0
lea    0xd0a(%rip),%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0xb,%rbx
je     1498 <main+0x338>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r12
movsd  (%r14),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x769cfd81,%ebp
xor    %r15d,%r15d
jmp    13bd <main+0x25d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
cmp    $0x1,%rsi
sete   %al
add    %rax,%r15
add    $0x1,%rbp
cmp    $0x77359401,%rbp
je     1320 <main+0x1c0>
lea    -0x1(%rbp),%r14
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1080 <rand@plt>
mov    %rax,%rcx
or     %r14,%rcx
shr    $0x20,%rcx
je     13f0 <main+0x290>
cqto
idiv   %r14
mov    %rdx,%rcx
jmp    13f7 <main+0x297>
nopl   (%rax)
xor    %edx,%edx
div    %r14d
mov    %edx,%ecx
add    $0x1,%r13
add    $0x1,%rcx
mov    $0x1,%esi
mov    %r14,%rdi
jmp    142e <main+0x2ce>
nopl   0x0(%rax)
mov    %rsi,%rax
cqto
idiv   %rbp
mov    %rdx,%rsi
mov    %rdi,%rax
shr    %rax
imul   %rcx,%rcx
cmp    $0x1,%rdi
mov    %rax,%rdi
jbe    1480 <main+0x320>
mov    %rcx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1450 <main+0x2f0>
mov    %rcx,%rax
cqto
idiv   %rbp
mov    %rdx,%rcx
test   $0x1,%dil
je     141b <main+0x2bb>
jmp    145e <main+0x2fe>
nopl   (%rax)
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%ecx
test   $0x1,%dil
je     141b <main+0x2bb>
imul   %rcx,%rsi
mov    %rsi,%rax
or     %rbp,%rax
shr    $0x20,%rax
jne    1410 <main+0x2b0>
mov    %esi,%eax
xor    %edx,%edx
div    %ebp
mov    %edx,%esi
jmp    141b <main+0x2bb>
nopl   0x0(%rax,%rax,1)
cmp    %rbx,%r13
jae    13a0 <main+0x240>
cmp    $0x1,%rsi
je     13d0 <main+0x270>
jmp    13a0 <main+0x240>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Searching for primes between %i and %i \0A\00"
@.str.1 = [32 x i8] c"Trying deterministic alorithm \0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [44 x i8] c"Deterministic algorithm: found %ld primes \0A\00"
@.str.3 = [14 x i8] c"in %fl secs \0A\00"
@.str.4 = [21 x i8] c"Trying Fermat test \0A\00"
@.str.5 = [74 x i8] c"Probabilistic algorithm: Found %ld primes in %fl secs , (tries = %ld) \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 1990000001, i32 2000000000)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%16 = call i64 (...) @clock()
%17 = sitofp i64 %16 to double
%18 = load double, double* @CLOCKS_PER_SEC
%19 = fdiv double %17, %18
store double %19, double* %10
store i64 1990000001, i64* %4
%20 = load i64, i64* %4
store i64 %20, i64* %2
br label %21
21: ; preds = %82, %0
%22 = load i64, i64* %2
%23 = icmp sle i64 %22, 2000000000
br i1 %23, label %24, label %85
24: ; preds = %21
store i32 0, i32* %6
store i64 11, i64* %3
%25 = load i64, i64* %2
%26 = srem i64 %25, 3
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = load i64, i64* %2
%30 = srem i64 %29, 5
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i64, i64* %2
%34 = srem i64 %33, 7
%35 = icmp ne i64 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %32, %28, %24
%37 = load i64, i64* %2
%38 = icmp eq i64 %37, 5
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i64, i64* %2
%41 = icmp eq i64 %40, 7
br i1 %41, label %42, label %81
42: ; preds = %39, %36, %32
br label %43
43: ; preds = %68, %42
%44 = load i64, i64* %2
%45 = load i64, i64* %3
%46 = srem i64 %44, %45
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = load i64, i64* %2
%50 = load i64, i64* %3
%51 = icmp ne i64 %49, %50
br i1 %51, label %63, label %52
52: ; preds = %48, %43
%53 = load i64, i64* %2
%54 = load i64, i64* %3
%55 = add nsw i64 %54, 2
%56 = srem i64 %53, %55
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %52
%59 = load i64, i64* %2
%60 = load i64, i64* %3
%61 = add nsw i64 %60, 2
%62 = icmp ne i64 %59, %61
br i1 %62, label %63, label %64
63: ; preds = %58, %48
store i32 1, i32* %6
br label %74
64: ; preds = %58, %52
%65 = load i64, i64* %3
%66 = add nsw i64 %65, 6
store i64 %66, i64* %3
br label %67
67: ; preds = %64
br label %68
68: ; preds = %67
%69 = load i64, i64* %3
%70 = load i64, i64* %3
%71 = mul nsw i64 %69, %70
%72 = load i64, i64* %2
%73 = icmp sle i64 %71, %72
br i1 %73, label %43, label %74
74: ; preds = %68, %63
%75 = load i32, i32* %6
%76 = icmp ne i32 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i64, i64* %8
%79 = add nsw i64 %78, 1
store i64 %79, i64* %8
br label %80
80: ; preds = %77, %74
br label %81
81: ; preds = %80, %39
br label %82
82: ; preds = %81
%83 = load i64, i64* %2
%84 = add nsw i64 %83, 2
store i64 %84, i64* %2
br label %21
85: ; preds = %21
%86 = call i64 (...) @clock()
%87 = sitofp i64 %86 to double
%88 = load double, double* @CLOCKS_PER_SEC
%89 = fdiv double %87, %88
store double %89, double* %11
%90 = load i64, i64* %8
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %90)
%92 = load double, double* %11
%93 = load double, double* %10
%94 = fsub double %92, %93
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %94)
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%97 = call i32 @time(i32* null)
%98 = call i32 @srand(i32 %97)
store i64 1, i64* %7
br label %99
99: ; preds = %183, %85
%100 = load i64, i64* %7
%101 = icmp sle i64 %100, 10
br i1 %101, label %102, label %186
102: ; preds = %99
%103 = call i64 (...) @clock()
%104 = sitofp i64 %103 to double
%105 = load double, double* @CLOCKS_PER_SEC
%106 = fdiv double %104, %105
store double %106, double* %10
store i64 0, i64* %8
%107 = load i64, i64* %4
store i64 %107, i64* %2
br label %108
108: ; preds = %169, %102
%109 = load i64, i64* %2
%110 = icmp sle i64 %109, 2000000000
br i1 %110, label %111, label %172
111: ; preds = %108
store i32 0, i32* %6
store i64 0, i64* %3
br label %112
112: ; preds = %160, %111
%113 = load i64, i64* %3
%114 = add nsw i64 %113, 1
store i64 %114, i64* %3
%115 = call i64 (...) @rand()
%116 = load i64, i64* %2
%117 = sub nsw i64 %116, 1
%118 = srem i64 %115, %117
%119 = add nsw i64 %118, 1
store i64 %119, i64* %5
%120 = load i64, i64* %5
store i64 %120, i64* %13
%121 = load i64, i64* %13
%122 = load i64, i64* %2
%123 = srem i64 %121, %122
store i64 %123, i64* %13
%124 = load i64, i64* %2
%125 = sub nsw i64 %124, 1
store i64 %125, i64* %9
store i64 1, i64* %12
br label %126
126: ; preds = %139, %112
%127 = load i64, i64* %9
%128 = icmp sgt i64 %127, 0
br i1 %128, label %129, label %147
129: ; preds = %126
%130 = load i64, i64* %9
%131 = srem i64 %130, 2
%132 = icmp eq i64 %131, 1
br i1 %132, label %133, label %139
133: ; preds = %129
%134 = load i64, i64* %12
%135 = load i64, i64* %13
%136 = mul nsw i64 %134, %135
%137 = load i64, i64* %2
%138 = srem i64 %136, %137
store i64 %138, i64* %12
br label %139
139: ; preds = %133, %129
%140 = load i64, i64* %9
%141 = ashr i64 %140, 1
store i64 %141, i64* %9
%142 = load i64, i64* %13
%143 = load i64, i64* %13
%144 = mul nsw i64 %142, %143
%145 = load i64, i64* %2
%146 = srem i64 %144, %145
store i64 %146, i64* %13
br label %126
147: ; preds = %126
%148 = load i64, i64* %12
%149 = icmp ne i64 %148, 1
br i1 %149, label %150, label %151
150: ; preds = %147
store i32 1, i32* %6
br label %151
151: ; preds = %150, %147
br label %152
152: ; preds = %151
%153 = load i64, i64* %3
%154 = load i64, i64* %7
%155 = icmp slt i64 %153, %154
br i1 %155, label %156, label %160
156: ; preds = %152
%157 = load i32, i32* %6
%158 = icmp ne i32 %157, 0
%159 = xor i1 %158, true
br label %160
160: ; preds = %156, %152
%161 = phi i1 [ false, %152 ], [ %159, %156 ]
br i1 %161, label %112, label %162
162: ; preds = %160
%163 = load i32, i32* %6
%164 = icmp ne i32 %163, 0
br i1 %164, label %168, label %165
165: ; preds = %162
%166 = load i64, i64* %8
%167 = add nsw i64 %166, 1
store i64 %167, i64* %8
br label %168
168: ; preds = %165, %162
br label %169
169: ; preds = %168
%170 = load i64, i64* %2
%171 = add nsw i64 %170, 1
store i64 %171, i64* %2
br label %108
172: ; preds = %108
%173 = call i64 (...) @clock()
%174 = sitofp i64 %173 to double
%175 = load double, double* @CLOCKS_PER_SEC
%176 = fdiv double %174, %175
store double %176, double* %11
%177 = load i64, i64* %8
%178 = load double, double* %11
%179 = load double, double* %10
%180 = fsub double %178, %179
%181 = load i64, i64* %7
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i64 %177, double %180, i64 %181)
br label %183
183: ; preds = %172
%184 = load i64, i64* %7
%185 = add nsw i64 %184, 1
store i64 %185, i64* %7
br label %99
186: ; preds = %99
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Searching for primes between %i and %i \0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.2 = [44 x i8] c"Deterministic algorithm: found %ld primes \0A\00"
@.str.3 = [14 x i8] c"in %fl secs \0A\00"
@.str.5 = [74 x i8] c"Probabilistic algorithm: Found %ld primes in %fl secs , (tries = %ld) \0A\00"
@str = [31 x i8] c"Trying deterministic alorithm \00"
@str.6 = [20 x i8] c"Trying Fermat test \00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 1990000001, i32 2000000000)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%3 = tail call i64 (...) @clock()
%4 = load double, double* @CLOCKS_PER_SEC
br label %5
5: ; preds = %0, %41
%6 = phi i64 [ 0, %0 ], [ %43, %41 ]
%7 = phi i64 [ 1990000001, %0 ], [ %44, %41 ]
%8 = trunc i64 %7 to i32
%9 = urem i32 %8, 3
%10 = icmp eq i32 %9, 0
%11 = urem i32 %8, 5
%12 = icmp eq i32 %11, 0
%13 = or i1 %10, %12
br i1 %13, label %20, label %14
14: ; preds = %5
%15 = freeze i64 %7
%16 = trunc i64 %15 to i32
%17 = urem i32 %16, 7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
switch i64 %15, label %41 [
i64 7, label %21
i64 5, label %21
]
20: ; preds = %5
switch i64 %7, label %41 [
i64 5, label %21
i64 7, label %21
]
21: ; preds = %19, %19, %14, %20, %20
%22 = phi i64 [ %15, %19 ], [ %15, %19 ], [ %15, %14 ], [ %7, %20 ], [ %7, %20 ]
br label %23
23: ; preds = %35, %21
%24 = phi i64 [ 11, %21 ], [ %36, %35 ]
%25 = urem i64 %22, %24
%26 = icmp ne i64 %25, 0
%27 = icmp eq i64 %22, %24
%28 = or i1 %27, %26
br i1 %28, label %29, label %41
29: ; preds = %23
%30 = add nuw nsw i64 %24, 2
%31 = urem i64 %22, %30
%32 = icmp ne i64 %31, 0
%33 = icmp eq i64 %22, %30
%34 = or i1 %33, %32
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = add nuw nsw i64 %24, 6
%37 = mul nsw i64 %36, %36
%38 = icmp ugt i64 %37, %22
br i1 %38, label %39, label %23
39: ; preds = %35
%40 = add nsw i64 %6, 1
br label %41
41: ; preds = %23, %29, %39, %19, %20
%42 = phi i64 [ %7, %20 ], [ %15, %19 ], [ %22, %39 ], [ %22, %29 ], [ %22, %23 ]
%43 = phi i64 [ %6, %20 ], [ %6, %19 ], [ %40, %39 ], [ %6, %29 ], [ %6, %23 ]
%44 = add nuw nsw i64 %42, 2
%45 = icmp ult i64 %42, 1999999999
br i1 %45, label %5, label %46
46: ; preds = %41
%47 = sitofp i64 %3 to double
%48 = fdiv double %47, %4
%49 = tail call i64 (...) @clock()
%50 = sitofp i64 %49 to double
%51 = load double, double* @CLOCKS_PER_SEC
%52 = fdiv double %50, %51
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i64 %43)
%54 = fsub double %52, %48
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %54)
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%57 = tail call i32 @time(i32* null)
%58 = tail call i32 @srand(i32 %57)
br label %59
59: ; preds = %46, %97
%60 = phi i64 [ 1, %46 ], [ %106, %97 ]
%61 = tail call i64 (...) @clock()
%62 = load double, double* @CLOCKS_PER_SEC
br label %63
63: ; preds = %59, %92
%64 = phi i64 [ 0, %59 ], [ %94, %92 ]
%65 = phi i64 [ 1990000001, %59 ], [ %95, %92 ]
%66 = add nsw i64 %65, -1
br label %67
67: ; preds = %88, %63
%68 = phi i64 [ %69, %88 ], [ 0, %63 ]
%69 = add nuw nsw i64 %68, 1
%70 = tail call i64 (...) @rand()
%71 = srem i64 %70, %66
%72 = add nsw i64 %71, 1
br label %73
73: ; preds = %67, %83
%74 = phi i64 [ %86, %83 ], [ %72, %67 ]
%75 = phi i64 [ %84, %83 ], [ 1, %67 ]
%76 = phi i64 [ %85, %83 ], [ %66, %67 ]
%77 = srem i64 %74, %65
%78 = and i64 %76, 1
%79 = icmp eq i64 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %73
%81 = mul nsw i64 %77, %75
%82 = srem i64 %81, %65
br label %83
83: ; preds = %80, %73
%84 = phi i64 [ %82, %80 ], [ %75, %73 ]
%85 = lshr i64 %76, 1
%86 = mul nsw i64 %77, %77
%87 = icmp ult i64 %76, 2
br i1 %87, label %88, label %73
88: ; preds = %83
%89 = icmp eq i64 %84, 1
%90 = icmp ult i64 %69, %60
%91 = select i1 %90, i1 %89, i1 false
br i1 %91, label %67, label %92
92: ; preds = %88
%93 = zext i1 %89 to i64
%94 = add nuw nsw i64 %64, %93
%95 = add nuw nsw i64 %65, 1
%96 = icmp eq i64 %95, 2000000001
br i1 %96, label %97, label %63
97: ; preds = %92
%98 = sitofp i64 %61 to double
%99 = fdiv double %98, %62
%100 = tail call i64 (...) @clock()
%101 = sitofp i64 %100 to double
%102 = load double, double* @CLOCKS_PER_SEC
%103 = fdiv double %101, %102
%104 = fsub double %103, %99
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i64 %94, double %104, i64 %60)
%106 = add nuw nsw i64 %60, 1
%107 = icmp eq i64 %106, 11
br i1 %107, label %108, label %59
108: ; preds = %97
ret i32 0
}