#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__ is_prime(int);
int /*<<< orphan*/ printf(char *, int const, ...);
void twin_primes() {
  const int m = 10;
  int i;
  int i2;
  short printed = 0;
  printf("\tTwin Primes to %d\t\n", m);
  for (i = 2; i > 0; i++) {
    i2 = i + 2;
    if (is_prime(i) == 0 && is_prime(i2) == 0) {
      printf("\t[%d ; %d]\t\n", i, i2);
      printed = printed + 1;
      if (printed == m)
        break;
    }
  }
}


x86 assembly (clang, -O0):
<twin_primes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x4(%rbp)
movw   $0x0,-0xe(%rbp)
lea    0xec4(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11cf <twin_primes+0xaf>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
jne    11bc <twin_primes+0x9c>
mov    -0xc(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
jne    11bc <twin_primes+0x9c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0xe(%rbp),%eax
add    $0x1,%eax
mov    %ax,-0xe(%rbp)
movswl -0xe(%rbp),%eax
cmp    $0xa,%eax
jne    11b7 <twin_primes+0x97>
jmp    11cf <twin_primes+0xaf>
jmp    11bc <twin_primes+0x9c>
jmp    11c1 <twin_primes+0xa1>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114f <twin_primes+0x2f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twin_primes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x2,%ebx
lea    0xecf(%rip),%r14
xor    %r15d,%r15d
jmp    1153 <twin_primes+0x33>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
lea    0x2(%rbx),%ebp
mov    %ebx,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
jne    1150 <twin_primes+0x30>
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
jne    1150 <twin_primes+0x30>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r15d
cmp    $0xa,%r15w
jne    1150 <twin_primes+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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