#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 rand();
int /*<<< orphan*/ solovayPrime(int, int);
int probablePrime(int n, int k) {
  if (n == 2)
    return 1;
  else if (n % 2 == 0 || n == 1)
    return 0;
  while (k-- > 0) {
    if (!solovayPrime(rand() % (n - 2) + 2, n))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<probablePrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1144 <probablePrime+0x24>
movl   $0x1,-0x4(%rbp)
jmp    11ca <probablePrime+0xaa>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1162 <probablePrime+0x42>
cmpl   $0x1,-0x8(%rbp)
jne    116e <probablePrime+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11ca <probablePrime+0xaa>
jmp    1173 <probablePrime+0x53>
jmp    1178 <probablePrime+0x58>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
jle    11c3 <probablePrime+0xa3>
mov    $0x0,%al
call   1040 <rand@plt>
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
call   1030 <solovayPrime@plt>
cmp    $0x0,%eax
jne    11be <probablePrime+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11ca <probablePrime+0xaa>
jmp    1178 <probablePrime+0x58>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<probablePrime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    113e <probablePrime+0x1e>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%r14d
xor    %ebp,%ebp
cmp    $0x1,%edi
je     1131 <probablePrime+0x11>
mov    %r14d,%eax
and    $0x1,%eax
je     1131 <probablePrime+0x11>
mov    %esi,%ebx
lea    -0x2(%r14),%r15d
add    $0x1,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
test   %ebx,%ebx
jle    112c <probablePrime+0xc>
xor    %eax,%eax
call   1040 <rand@plt>
cltd
idiv   %r15d
lea    0x2(%rdx),%edi
mov    %r14d,%esi
call   1030 <solovayPrime@plt>
test   %eax,%eax
jne    1160 <probablePrime+0x40>
jmp    1131 <probablePrime+0x11>

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

LLVM IR (-O2):
define i32 @probablePrime(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %21, label %4
4: ; preds = %2
%5 = and i32 %0, 1
%6 = icmp eq i32 %5, 0
%7 = icmp eq i32 %0, 1
%8 = or i1 %7, %6
br i1 %8, label %21, label %9
9: ; preds = %4
%10 = add nsw i32 %0, -2
br label %11
11: ; preds = %9, %14
%12 = phi i32 [ %15, %14 ], [ %1, %9 ]
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = add nsw i32 %12, -1
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, %10
%18 = add nsw i32 %17, 2
%19 = tail call i32 @solovayPrime(i32 %18, i32 %0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %14, %4, %2
%22 = phi i32 [ 1, %2 ], [ 0, %4 ], [ 1, %11 ], [ 0, %14 ]
ret i32 %22
}