#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*/ test(int, int, int);
int isPrime(int n) {
  if (n < 2)
    return 0;
  int a[] = {2, 3, 61};
  int i;
  for (i = 0; i < 3; i++)
    if (!test(n, a[i], n - 1))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1131 <isPrime+0x21>
movl   $0x0,-0x4(%rbp)
jmp    119b <isPrime+0x8b>
mov    0xec8(%rip),%rax
mov    %rax,-0x14(%rbp)
mov    0xec6(%rip),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1194 <isPrime+0x84>
mov    -0x8(%rbp),%edi
movslq -0x18(%rbp),%rax
mov    -0x14(%rbp,%rax,4),%esi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
call   1030 <test@plt>
cmp    $0x0,%eax
jne    1181 <isPrime+0x71>
movl   $0x0,-0x4(%rbp)
jmp    119b <isPrime+0x8b>
jmp    1186 <isPrime+0x76>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <isPrime+0x3c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrime>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     115c <isPrime+0x4c>
mov    %edi,%ebx
lea    -0x1(%rbx),%r14d
mov    $0x2,%esi
mov    %r14d,%edx
call   1030 <test@plt>
test   %eax,%eax
je     115c <isPrime+0x4c>
mov    %ebx,%edi
mov    $0x3,%esi
mov    %r14d,%edx
call   1030 <test@plt>
test   %eax,%eax
je     115c <isPrime+0x4c>
mov    %ebx,%edi
mov    $0x3d,%esi
mov    %r14d,%edx
call   1030 <test@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.isPrime.a = [3 x i32] [i32 2, i32 3, i32 61]
define i32 @isPrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i32]
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %30
9: ; preds = %1
%10 = bitcast [3 x i32]* %4 to i8*
store i32 0, i32* %5
br label %11
11: ; preds = %26, %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 1
%22 = call i32 @test(i32 %15, i32 %19, i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %14
store i32 0, i32* %2
br label %30
25: ; preds = %14
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %11
29: ; preds = %11
store i32 1, i32* %2
br label %30
30: ; preds = %29, %24, %8
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @isPrime(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = add nsw i32 %0, -1
%5 = tail call i32 @test(i32 %0, i32 2, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = tail call i32 @test(i32 %0, i32 3, i32 %4)
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @test(i32 %0, i32 61, i32 %4)
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %3, %7, %1
%15 = phi i32 [ 0, %1 ], [ 0, %3 ], [ 0, %7 ], [ %13, %10 ]
ret i32 %15
}