#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 is_it_prime(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int twins() {
  int i = 1, doubles = 0;
  for (i > 0; i <= 1000; i++) {
    if (is_it_prime(i) == 1) {
      if (is_it_prime(i + 2) == 1) {
        printf("%d. (%d, %d)\n", doubles + 1, i, i + 2);
        doubles++;
        if (doubles == 10) {
          break;
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<twins>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jg     11b8 <twins+0x98>
mov    -0x8(%rbp),%edi
call   1040 <is_it_prime@plt>
cmp    $0x1,%eax
jne    11a5 <twins+0x85>
mov    -0x8(%rbp),%edi
add    $0x2,%edi
call   1040 <is_it_prime@plt>
cmp    $0x1,%eax
jne    11a0 <twins+0x80>
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    $0x2,%ecx
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    119b <twins+0x7b>
jmp    11b8 <twins+0x98>
jmp    11a0 <twins+0x80>
jmp    11a5 <twins+0x85>
jmp    11aa <twins+0x8a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <twins+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twins>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r15d,%r15d
mov    $0x3,%ebx
lea    0xeca(%rip),%r14
jmp    114b <twins+0x2b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x3eb,%ebx
je     117f <twins+0x5f>
lea    -0x2(%rbx),%ebp
mov    %ebp,%edi
call   1040 <is_it_prime@plt>
cmp    $0x1,%eax
jne    1140 <twins+0x20>
mov    %ebx,%edi
call   1040 <is_it_prime@plt>
cmp    $0x1,%eax
jne    1140 <twins+0x20>
add    $0x1,%r15d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
cmp    $0xa,%r15d
jne    1140 <twins+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"%d. (%d, %d)\0A\00"
define i32 @twins() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = icmp sgt i32 %4, 0
%6 = zext i1 %5 to i32
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 1000
br i1 %9, label %10, label %37
10: ; preds = %7
%11 = load i32, i32* %2
%12 = call i32 @is_it_prime(i32 %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 2
%17 = call i32 @is_it_prime(i32 %16)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %32
19: ; preds = %14
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = load i32, i32* %2
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 2
%25 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %24)
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %19
br label %37
31: ; preds = %19
br label %32
32: ; preds = %31, %14
br label %33
33: ; preds = %32, %10
br label %34
34: ; preds = %33
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %7
37: ; preds = %30, %7
%38 = load i32, i32* %1
ret i32 %38
}

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