#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*/ printf(char *, int, int);
int main() {
  int last_prime = 0;
  int divisor = 0;
  bool is_prime = false;
  for (int check = 3; check < 10000; ++check) {
    divisor = check / 2;
    is_prime = true;
    while (divisor > 1) {
      if ((check % divisor) == 0) {
        is_prime = false;
        break;
      }
      divisor--;
    }
    if (is_prime) {
      if ((check - last_prime) == 2) {
        printf("Prime pair (with difference of 2): %d, %d\n", last_prime,
               check);
      }
      last_prime = check;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11d5 <main+0xc5>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    1191 <main+0x81>
mov    -0x14(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1183 <main+0x73>
movl   $0x0,-0x10(%rbp)
jmp    1191 <main+0x81>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x4d>
cmpl   $0x0,-0x10(%rbp)
je     11c2 <main+0xb2>
mov    -0x14(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x2,%eax
jne    11bc <main+0xac>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <main+0xb7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <main+0x2b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %esi,%esi
mov    $0x3,%ebx
lea    0xede(%rip),%r14
jmp    113f <main+0x2f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %esi,%eax
add    $0x1,%ebx
mov    %eax,%esi
cmp    $0x2710,%ebx
je     117c <main+0x6c>
cmp    $0x4,%ebx
jb     1163 <main+0x53>
mov    %ebx,%ecx
shr    %ecx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1130 <main+0x20>
lea    -0x1(%rcx),%eax
cmp    $0x3,%ecx
mov    %eax,%ecx
jge    1150 <main+0x40>
mov    %ebx,%ecx
sub    %esi,%ecx
mov    %ebx,%eax
cmp    $0x2,%ecx
jne    1132 <main+0x22>
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
jmp    1132 <main+0x22>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Prime pair (with difference of 2): %d, %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 3, i32* %5
br label %6
6: ; preds = %39, %0
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 10000
br i1 %8, label %9, label %42
9: ; preds = %6
%10 = load i32, i32* %5
%11 = sdiv i32 %10, 2
store i32 %11, i32* %3
store i32 1, i32* %4
br label %12
12: ; preds = %21, %9
%13 = load i32, i32* %3
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = srem i32 %16, %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 0, i32* %4
br label %24
21: ; preds = %15
%22 = load i32, i32* %3
%23 = add nsw i32 %22, -1
store i32 %23, i32* %3
br label %12
24: ; preds = %20, %12
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = load i32, i32* %5
%29 = load i32, i32* %2
%30 = sub nsw i32 %28, %29
%31 = icmp eq i32 %30, 2
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i32, i32* %2
%34 = load i32, i32* %5
%35 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %33, i32 %34)
br label %36
36: ; preds = %32, %27
%37 = load i32, i32* %5
store i32 %37, i32* %2
br label %38
38: ; preds = %36, %24
br label %39
39: ; preds = %38
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %6
42: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"Prime pair (with difference of 2): %d, %d\0A\00"
define i32 @main() {
br label %2
1: ; preds = %20
ret i32 0
2: ; preds = %0, %20
%3 = phi i32 [ 3, %0 ], [ %22, %20 ]
%4 = phi i32 [ 0, %0 ], [ %21, %20 ]
%5 = icmp ugt i32 %3, 3
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = lshr i32 %3, 1
br label %11
8: ; preds = %11
%9 = add nsw i32 %12, -1
%10 = icmp sgt i32 %12, 2
br i1 %10, label %11, label %15
11: ; preds = %6, %8
%12 = phi i32 [ %9, %8 ], [ %7, %6 ]
%13 = srem i32 %3, %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %8
15: ; preds = %8, %2
%16 = sub nsw i32 %3, %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %3)
br label %20
20: ; preds = %11, %15, %18
%21 = phi i32 [ %3, %18 ], [ %3, %15 ], [ %4, %11 ]
%22 = add nuw nsw i32 %3, 1
%23 = icmp eq i32 %22, 10000
br i1 %23, label %1, label %2
}