#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 FindNextPrime(int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int firstPrime;
  int twinPrimeCount = 0;
  firstPrime = FindNextPrime(2);
  do {
    int secondPrime = FindNextPrime(firstPrime + 1);
    if (secondPrime - firstPrime == 2) {
      printf("(%d, %d)\n", firstPrime, secondPrime);
      twinPrimeCount++;
    }
    firstPrime = secondPrime;
  } while (twinPrimeCount < 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x2,%edi
call   1040 <FindNextPrime@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
add    $0x1,%edi
call   1040 <FindNextPrime@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x2,%eax
jne    117b <main+0x5b>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     1143 <main+0x23>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2,%edi
call   1040 <FindNextPrime@plt>
mov    %eax,%ebx
xor    %r15d,%r15d
lea    0xec3(%rip),%r14
jmp    1148 <main+0x28>
nop
mov    %ebp,%ebx
cmp    $0xa,%r15d
jge    116b <main+0x4b>
lea    0x1(%rbx),%edi
call   1040 <FindNextPrime@plt>
mov    %eax,%ebp
sub    %ebx,%eax
cmp    $0x2,%eax
jne    1140 <main+0x20>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x1,%r15d
jmp    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"(%d, %d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @FindNextPrime(i32 2)
store i32 %5, i32* %2
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 1
%9 = call i32 @FindNextPrime(i32 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = load i32, i32* %2
%12 = sub nsw i32 %10, %11
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %6
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %20
20: ; preds = %14, %6
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %22
22: ; preds = %20
%23 = load i32, i32* %3
%24 = icmp slt i32 %23, 10
br i1 %24, label %6, label %25
25: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"(%d, %d)\0A\00"
define i32 @main() {
%1 = tail call i32 @FindNextPrime(i32 2)
br label %2
2: ; preds = %12, %0
%3 = phi i32 [ 0, %0 ], [ %13, %12 ]
%4 = phi i32 [ %1, %0 ], [ %6, %12 ]
%5 = add nsw i32 %4, 1
%6 = tail call i32 @FindNextPrime(i32 %5)
%7 = sub nsw i32 %6, %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%11 = add nsw i32 %3, 1
br label %12
12: ; preds = %9, %2
%13 = phi i32 [ %11, %9 ], [ %3, %2 ]
%14 = icmp slt i32 %13, 10
br i1 %14, label %2, label %15
15: ; preds = %12
ret i32 0
}