#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 /*<<< orphan*/ assert(int);
int /*<<< orphan*/ is_prime(int);
int Is_prime(int N) {
  int i;
  assert(N > 1);
  if (N == 2 || N == 3)
    return 1;
  for (i = 0; i < (N - 2 < 20 ? N - 2 : 20); i++)
    if (!is_prime(N))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<Is_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x2,-0x8(%rbp)
je     1150 <Is_prime+0x30>
cmpl   $0x3,-0x8(%rbp)
jne    115c <Is_prime+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    11d8 <Is_prime+0xb8>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
cmp    $0x14,%eax
jge    1186 <Is_prime+0x66>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <Is_prime+0x73>
mov    $0x14,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <Is_prime+0x73>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    11d1 <Is_prime+0xb1>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%eax
jne    11be <Is_prime+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11d8 <Is_prime+0xb8>
jmp    11c3 <Is_prime+0xa3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <Is_prime+0x43>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Is_prime>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x2,%ebp
setge  %dil
call   1030 <assert@plt>
mov    %ebp,%eax
and    $0xfffffffe,%eax
mov    $0x1,%r14d
cmp    $0x2,%eax
je     1175 <Is_prime+0x55>
cmp    $0x16,%ebp
mov    $0x16,%ebx
cmovl  %ebp,%ebx
cmp    $0x3,%ebx
jl     1175 <Is_prime+0x55>
add    $0xfffffffe,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1040 <is_prime@plt>
test   %eax,%eax
je     1172 <Is_prime+0x52>
add    $0xffffffff,%ebx
jne    1160 <Is_prime+0x40>
jmp    1175 <Is_prime+0x55>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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