#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__ isWitness(unsigned int, unsigned int);
unsigned int lrand48();
int isMillerRabinPrime(unsigned int src) {
  int n;
  for (n = 0; n < 20; ++n) {
    unsigned int witness = ((lrand48() % (src - 1)) + 1);
    if (isWitness(witness, src))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isMillerRabinPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    1187 <isMillerRabinPrime+0x67>
mov    $0x0,%al
call   1030 <lrand48@plt>
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
xor    %edx,%edx
div    %ecx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <isWitness@plt>
cmp    $0x0,%rax
je     1174 <isMillerRabinPrime+0x54>
movl   $0x0,-0x4(%rbp)
jmp    118e <isMillerRabinPrime+0x6e>
jmp    1179 <isMillerRabinPrime+0x59>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <isMillerRabinPrime+0x12>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isMillerRabinPrime>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
lea    -0x1(%r15),%r14d
mov    $0x14,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1030 <lrand48@plt>
xor    %edx,%edx
div    %r14d
lea    0x1(%rdx),%edi
mov    %r15d,%esi
call   1040 <isWitness@plt>
test   %rax,%rax
jne    1166 <isMillerRabinPrime+0x46>
add    $0xffffffff,%ebx
jne    1140 <isMillerRabinPrime+0x20>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isMillerRabinPrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %21, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = call i32 (...) @lrand48()
%11 = load i32, i32* %3
%12 = sub i32 %11, 1
%13 = urem i32 %10, %12
%14 = add i32 %13, 1
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = call i64 @isWitness(i32 %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %9
store i32 0, i32* %2
br label %25
20: ; preds = %9
br label %21
21: ; preds = %20
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %6
24: ; preds = %6
store i32 1, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
define i32 @isMillerRabinPrime(i32 %0) {
%2 = add i32 %0, -1
br label %6
3: ; preds = %6
%4 = add nuw nsw i32 %7, 1
%5 = icmp eq i32 %4, 20
br i1 %5, label %13, label %6
6: ; preds = %1, %3
%7 = phi i32 [ 0, %1 ], [ %4, %3 ]
%8 = tail call i32 (...) @lrand48()
%9 = urem i32 %8, %2
%10 = add nuw i32 %9, 1
%11 = tail call i64 @isWitness(i32 %10, i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %3, label %13
13: ; preds = %3, %6
%14 = phi i32 [ 0, %6 ], [ 1, %3 ]
ret i32 %14
}