#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 */
scalar_t__ prime(int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int i, count = 0;
  for (i = 1; i < 998; ++i) {
    if (prime(i) && prime(i + 2)) {
      printf("%d %d\n", i, i + 2);
      ++count;
    }
  }
  printf("Total: %d\n", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e6,-0x8(%rbp)
jge    11a4 <main+0x84>
mov    -0x8(%rbp),%edi
call   1040 <prime@plt>
cmp    $0x0,%rax
je     1191 <main+0x71>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
call   1040 <prime@plt>
cmp    $0x0,%rax
je     1191 <main+0x71>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
add    $0x2,%edx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x76>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@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
mov    $0x3,%ebx
lea    0xecd(%rip),%r14
xor    %r15d,%r15d
jmp    114b <main+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x3e8,%ebx
je     117a <main+0x5a>
lea    -0x2(%rbx),%ebp
mov    %ebp,%edi
call   1040 <prime@plt>
test   %rax,%rax
je     1140 <main+0x20>
mov    %ebx,%edi
call   1040 <prime@plt>
test   %rax,%rax
je     1140 <main+0x20>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r15d
jmp    1140 <main+0x20>
lea    0xe86(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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