#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 */
int /*<<< orphan*/ init();
scalar_t__ isPrime(int);
int /*<<< orphan*/ printTransitions(int, int);
int /*<<< orphan*/ record(int, int);
int main() {
  int last_prime = 3, n = 5, count = 2;
  init();
  record(2, 3);
  while (count < 1000000) {
    if (isPrime(n)) {
      record(last_prime, n);
      last_prime = n;
      count++;
    }
    n += 2;
    if (count < 1000000) {
      if (isPrime(n)) {
        record(last_prime, n);
        last_prime = n;
        count++;
      }
      n += 4;
    }
  }
  printTransitions(1000000, last_prime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    $0x0,%al
call   1060 <init@plt>
mov    $0x2,%edi
mov    $0x3,%esi
call   1030 <record@plt>
cmpl   $0xf4240,-0x10(%rbp)
jge    1203 <main+0xc3>
mov    -0xc(%rbp),%edi
call   1050 <isPrime@plt>
cmp    $0x0,%rax
je     11b3 <main+0x73>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <record@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xf4240,-0x10(%rbp)
jge    11fe <main+0xbe>
mov    -0xc(%rbp),%edi
call   1050 <isPrime@plt>
cmp    $0x0,%rax
je     11f5 <main+0xb5>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <record@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    117a <main+0x3a>
mov    -0x8(%rbp),%esi
mov    $0xf4240,%edi
call   1040 <printTransitions@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <init@plt>
mov    $0x2,%r15d
mov    $0x3,%r14d
mov    $0x2,%edi
mov    $0x3,%esi
call   1030 <record@plt>
mov    $0x5,%ebx
jmp    118d <main+0x4d>
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <record@plt>
add    $0x1,%r15d
mov    %ebp,%r14d
add    $0x6,%ebx
cmp    $0xf4240,%r15d
jge    11c9 <main+0x89>
mov    %ebx,%edi
call   1050 <isPrime@plt>
test   %rax,%rax
je     11b3 <main+0x73>
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <record@plt>
cmp    $0xf423e,%r15d
jg     11c7 <main+0x87>
add    $0x1,%r15d
mov    %ebx,%r14d
lea    0x2(%rbx),%ebp
mov    %ebp,%edi
call   1050 <isPrime@plt>
test   %rax,%rax
jne    1170 <main+0x30>
mov    %r14d,%ebp
jmp    1181 <main+0x41>
mov    %ebx,%ebp
mov    $0xf4240,%edi
mov    %ebp,%esi
call   1040 <printTransitions@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 5, i32* %3
store i32 2, i32* %4
%5 = call i32 (...) @init()
%6 = call i32 @record(i32 2, i32 3)
br label %7
7: ; preds = %40, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 1000000
br i1 %9, label %10, label %41
10: ; preds = %7
%11 = load i32, i32* %3
%12 = call i64 @isPrime(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @record(i32 %15, i32 %16)
%18 = load i32, i32* %3
store i32 %18, i32* %2
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %21
21: ; preds = %14, %10
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 2
store i32 %23, i32* %3
%24 = load i32, i32* %4
%25 = icmp slt i32 %24, 1000000
br i1 %25, label %26, label %40
26: ; preds = %21
%27 = load i32, i32* %3
%28 = call i64 @isPrime(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @record(i32 %31, i32 %32)
%34 = load i32, i32* %3
store i32 %34, i32* %2
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %37
37: ; preds = %30, %26
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 4
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %21
br label %7
41: ; preds = %7
%42 = load i32, i32* %2
%43 = call i32 @printTransitions(i32 1000000, i32 %42)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @init()
%2 = tail call i32 @record(i32 2, i32 3)
br label %3
3: ; preds = %0, %22
%4 = phi i32 [ 2, %0 ], [ %24, %22 ]
%5 = phi i32 [ 5, %0 ], [ %25, %22 ]
%6 = phi i32 [ 3, %0 ], [ %23, %22 ]
%7 = tail call i64 @isPrime(i32 %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = tail call i32 @record(i32 %6, i32 %5)
%11 = add nsw i32 %4, 1
%12 = icmp slt i32 %4, 999999
br i1 %12, label %13, label %27
13: ; preds = %3, %9
%14 = phi i32 [ %11, %9 ], [ %4, %3 ]
%15 = phi i32 [ %5, %9 ], [ %6, %3 ]
%16 = add nuw nsw i32 %5, 2
%17 = tail call i64 @isPrime(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = tail call i32 @record(i32 %15, i32 %16)
%21 = add nsw i32 %14, 1
br label %22
22: ; preds = %13, %19
%23 = phi i32 [ %16, %19 ], [ %15, %13 ]
%24 = phi i32 [ %21, %19 ], [ %14, %13 ]
%25 = add nuw nsw i32 %5, 6
%26 = icmp slt i32 %24, 1000000
br i1 %26, label %3, label %27
27: ; preds = %9, %22
%28 = phi i32 [ %23, %22 ], [ %5, %9 ]
%29 = tail call i32 @printTransitions(i32 1000000, i32 %28)
ret i32 0
}