#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 1;
  if (t == 1 && 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    11c2 <isprime+0x92>
mov    -0x8(%rbp),%edi
call   1050 <STT@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    1172 <isprime+0x42>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <isprime+0x92>
cmpl   $0x1,-0xc(%rbp)
jne    11bb <isprime+0x8b>
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%edx
mov    $0x2,%edi
call   1030 <MODULAR_EXPONENTIATION@plt>
cmp    $0x1,%eax
jne    11bb <isprime+0x8b>
mov    -0x8(%rbp),%edi
mov    $0x32,%esi
call   1040 <MILLER_RABIN@plt>
cmp    $0x0,%rax
je     11bb <isprime+0x8b>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <isprime+0x92>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isprime>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x2,%edi
jl     1177 <isprime+0x47>
mov    %edi,%ebx
call   1050 <STT@plt>
mov    $0x1,%ebp
cmp    $0x2,%eax
je     1177 <isprime+0x47>
cmp    $0x1,%eax
jne    1175 <isprime+0x45>
lea    -0x1(%rbx),%esi
mov    $0x2,%edi
mov    %ebx,%edx
call   1030 <MODULAR_EXPONENTIATION@plt>
cmp    $0x1,%eax
jne    1175 <isprime+0x45>
mov    %ebx,%edi
mov    $0x32,%esi
call   1040 <MILLER_RABIN@plt>
test   %rax,%rax
jne    1177 <isprime+0x47>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
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 %29
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 eq i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %8
store i32 1, i32* %2
br label %29
14: ; preds = %8
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
%20 = load i32, i32* %3
%21 = call i32 @MODULAR_EXPONENTIATION(i32 2, i32 %19, i32 %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i32, i32* %3
%25 = call i64 @MILLER_RABIN(i32 %24, i32 50)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 1, i32* %2
br label %29
28: ; preds = %23, %17, %14
store i32 0, i32* %2
br label %29
29: ; preds = %28, %27, %13, %7
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @isprime(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %13, label %3
3: ; preds = %1
%4 = tail call i32 @STT(i32 %0)
switch i32 %4, label %12 [
i32 2, label %13
i32 1, label %5
]
5: ; preds = %3
%6 = add nsw i32 %0, -1
%7 = tail call i32 @MODULAR_EXPONENTIATION(i32 2, i32 %6, i32 %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i64 @MILLER_RABIN(i32 %0, i32 50)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3, %9, %5
br label %13
13: ; preds = %9, %3, %1, %12
%14 = phi i32 [ 0, %12 ], [ 0, %1 ], [ 1, %3 ], [ 1, %9 ]
ret i32 %14
}