#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 INT_MAX;
int /*<<< orphan*/ assert(int);
scalar_t__ is_prime(int);
int next_twinprime(int num) {
  assert(num >= 2);
  while (num < INT_MAX) {
    num++;
    if (is_prime(num) && is_prime(num - 2))
      return num;
  }
  return -1;
}


x86 assembly (clang, -O0):
<next_twinprime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
jge    118e <next_twinprime+0x6e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1189 <next_twinprime+0x69>
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
je     1189 <next_twinprime+0x69>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1195 <next_twinprime+0x75>
jmp    113c <next_twinprime+0x1c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_twinprime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x2,%ebx
setge  %dil
call   1030 <assert@plt>
mov    0x2eaa(%rip),%r15
mov    $0xffffffff,%r14d
cmp    %ebx,(%r15)
jg     1157 <next_twinprime+0x37>
jmp    1179 <next_twinprime+0x59>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%ebx
cmp    (%r15),%ebp
jge    1179 <next_twinprime+0x59>
lea    0x1(%rbx),%ebp
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1150 <next_twinprime+0x30>
lea    -0x1(%rbx),%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     1150 <next_twinprime+0x30>
add    $0x1,%ebx
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @next_twinprime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 2
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
br label %8
8: ; preds = %25, %1
%9 = load i32, i32* %3
%10 = load i32, i32* @INT_MAX
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = call i64 @is_prime(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %12
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 2
%21 = call i64 @is_prime(i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i32, i32* %3
store i32 %24, i32* %2
br label %27
25: ; preds = %18, %12
br label %8
26: ; preds = %8
store i32 -1, i32* %2
br label %27
27: ; preds = %26, %23
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @next_twinprime(i32 %0) {
%2 = icmp sgt i32 %0, 1
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = load i32, i32* @INT_MAX
%6 = icmp sgt i32 %5, %0
br i1 %6, label %7, label %19
7: ; preds = %1, %16
%8 = phi i32 [ %9, %16 ], [ %0, %1 ]
%9 = add nsw i32 %8, 1
%10 = tail call i64 @is_prime(i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %7
%13 = add nsw i32 %8, -1
%14 = tail call i64 @is_prime(i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12, %7
%17 = load i32, i32* @INT_MAX
%18 = icmp slt i32 %9, %17
br i1 %18, label %7, label %19
19: ; preds = %12, %16, %1
%20 = phi i32 [ -1, %1 ], [ -1, %16 ], [ %9, %12 ]
ret i32 %20
}