#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__ WITNESS(int, int);
int MILLER_RABIN(int n, int s) {
  int j, c[4] = {0, 2, 7, 61};
  for (j = 1; j <= 3; j++)
    if (c[j] < n && WITNESS(c[j], n))
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<MILLER_RABIN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jg     118f <MILLER_RABIN+0x7f>
movslq -0x10(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
cmp    -0x8(%rbp),%eax
jge    117c <MILLER_RABIN+0x6c>
movslq -0x10(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edi
mov    -0x8(%rbp),%esi
call   1030 <WITNESS@plt>
cmp    $0x0,%rax
je     117c <MILLER_RABIN+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    1196 <MILLER_RABIN+0x86>
jmp    1181 <MILLER_RABIN+0x71>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113b <MILLER_RABIN+0x2b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MILLER_RABIN>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     1159 <MILLER_RABIN+0x49>
mov    %edi,%ebp
mov    $0x2,%edi
mov    %ebp,%esi
call   1030 <WITNESS@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    115e <MILLER_RABIN+0x4e>
cmp    $0x8,%ebp
jb     1159 <MILLER_RABIN+0x49>
mov    $0x7,%edi
mov    %ebp,%esi
call   1030 <WITNESS@plt>
test   %rax,%rax
jne    115e <MILLER_RABIN+0x4e>
cmp    $0x3e,%ebp
jb     1159 <MILLER_RABIN+0x49>
mov    $0x3d,%edi
mov    %ebp,%esi
call   1030 <WITNESS@plt>
test   %rax,%rax
jne    115e <MILLER_RABIN+0x4e>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @MILLER_RABIN(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %17
4: ; preds = %2
%5 = tail call i64 @WITNESS(i32 2, i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = icmp ugt i32 %0, 7
br i1 %8, label %9, label %17
9: ; preds = %7
%10 = tail call i64 @WITNESS(i32 7, i32 %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = icmp ugt i32 %0, 61
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = tail call i64 @WITNESS(i32 61, i32 %0)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %2, %7, %14, %12
br label %18
18: ; preds = %17, %14, %9, %4
%19 = phi i32 [ 0, %4 ], [ 0, %9 ], [ 0, %14 ], [ 1, %17 ]
ret i32 %19
}