#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__ MILLER_RABIN(int, int);
int MODULAR_EXPONENTIATION(int, int, int);
int STT(int);
int isprime(int n) {
  int t;
  if (n < 2)
    return 0;
  t = STT(n);
  if (t != 2)
    return t;
  else if (MODULAR_EXPONENTIATION(2, n - 1, n) == 1 && MILLER_RABIN(n, 50))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<isprime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1151 <isprime+0x21>
movl   $0x0,-0x4(%rbp)
jmp    11bc <isprime+0x8c>
mov    -0x8(%rbp),%edi
call   1050 <STT@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
je     1171 <isprime+0x41>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <isprime+0x8c>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%edx
mov    $0x2,%edi
call   1030 <MODULAR_EXPONENTIATION@plt>
cmp    $0x1,%eax
jne    11b0 <isprime+0x80>
mov    -0x8(%rbp),%edi
mov    $0x32,%esi
call   1040 <MILLER_RABIN@plt>
cmp    $0x0,%rax
je     11b0 <isprime+0x80>
movl   $0x1,-0x4(%rbp)
jmp    11bc <isprime+0x8c>
jmp    11b5 <isprime+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isprime>:
push   %rbx
xor    %eax,%eax
cmp    $0x2,%edi
jl     1171 <isprime+0x41>
mov    %edi,%ebx
call   1050 <STT@plt>
cmp    $0x2,%eax
jne    1171 <isprime+0x41>
lea    -0x1(%rbx),%esi
mov    $0x2,%edi
mov    %ebx,%edx
call   1030 <MODULAR_EXPONENTIATION@plt>
cmp    $0x1,%eax
jne    1173 <isprime+0x43>
mov    %ebx,%edi
mov    $0x32,%esi
call   1040 <MILLER_RABIN@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1173 <isprime+0x43>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isprime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 2
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %28
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @STT(i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* %4
store i32 %14, i32* %2
br label %28
15: ; preds = %8
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 1
%18 = load i32, i32* %3
%19 = call i32 @MODULAR_EXPONENTIATION(i32 2, i32 %17, i32 %18)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* %3
%23 = call i64 @MILLER_RABIN(i32 %22, i32 50)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 1, i32* %2
br label %28
26: ; preds = %21, %15
br label %27
27: ; preds = %26
store i32 0, i32* %2
br label %28
28: ; preds = %27, %25, %13, %7
%29 = load i32, i32* %2
ret i32 %29
}

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 = tail call i32 @STT(i32 %0)
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = add nsw i32 %0, -1
%8 = tail call i32 @MODULAR_EXPONENTIATION(i32 2, i32 %7, i32 %0)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i64 @MILLER_RABIN(i32 %0, i32 50)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %6, %10
br label %14
14: ; preds = %10, %3, %1, %13
%15 = phi i32 [ 0, %13 ], [ 0, %1 ], [ %4, %3 ], [ 1, %10 ]
ret i32 %15
}