#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__ ft_is_prime(int);
int next_next_prime(int n) {
  int next;
  int current;
  next = 0;
  current = n % 2 == 0 ? n + 1 : n + 2;
  while (!ft_is_prime(current) || next == 0) {
    if (ft_is_prime(current))
      next++;
    current += 2;
  }
  return (current);
}


x86 assembly (clang, -O0):
<next_next_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1144 <next_next_prime+0x34>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <next_next_prime+0x3d>
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <ft_is_prime@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1177 <next_next_prime+0x67>
cmpl   $0x0,-0x8(%rbp)
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1187 <next_next_prime+0x77>
jmp    11b0 <next_next_prime+0xa0>
mov    -0xc(%rbp),%edi
call   1030 <ft_is_prime@plt>
cmp    $0x0,%rax
je     11a2 <next_next_prime+0x92>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <next_next_prime+0x43>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_next_prime>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
and    $0x1,%eax
cmp    $0x1,%eax
sbb    $0x0,%ebx
add    $0x2,%ebx
mov    %ebx,%edi
call   1030 <ft_is_prime@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <ft_is_prime@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x2,%ebx
mov    %ebx,%edi
call   1030 <ft_is_prime@plt>
test   %rax,%rax
je     1130 <next_next_prime+0x20>
test   %ebp,%ebp
je     1130 <next_next_prime+0x20>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @next_next_prime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = srem i32 %5, 2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
br label %14
11: ; preds = %1
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 2
br label %14
14: ; preds = %11, %8
%15 = phi i32 [ %10, %8 ], [ %13, %11 ]
store i32 %15, i32* %4
br label %16
16: ; preds = %32, %14
%17 = load i32, i32* %4
%18 = call i64 @ft_is_prime(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br label %23
23: ; preds = %20, %16
%24 = phi i1 [ true, %16 ], [ %22, %20 ]
br i1 %24, label %25, label %35
25: ; preds = %23
%26 = load i32, i32* %4
%27 = call i64 @ft_is_prime(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 2
store i32 %34, i32* %4
br label %16
35: ; preds = %23
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @next_next_prime(i32 %0) {
%2 = and i32 %0, 1
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i32 1, i32 2
%5 = add nsw i32 %4, %0
%6 = tail call i64 @ft_is_prime(i32 %5)
br label %7
7: ; preds = %1, %7
%8 = phi i32 [ %5, %1 ], [ %14, %7 ]
%9 = phi i32 [ 0, %1 ], [ %13, %7 ]
%10 = tail call i64 @ft_is_prime(i32 %8)
%11 = icmp ne i64 %10, 0
%12 = zext i1 %11 to i32
%13 = add nuw nsw i32 %9, %12
%14 = add nsw i32 %8, 2
%15 = tail call i64 @ft_is_prime(i32 %14)
%16 = icmp eq i64 %15, 0
%17 = icmp eq i32 %13, 0
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %7, label %19
19: ; preds = %7
ret i32 %14
}