#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, a, 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    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jg     118f <MILLER_RABIN+0x7f>
movslq -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x8(%rbp),%eax
jge    117c <MILLER_RABIN+0x6c>
movslq -0x10(%rbp),%rax
mov    -0x30(%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    $0x30,%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 i32
%8 = alloca [4 x i32]
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = bitcast [4 x i32]* %8 to i8*
store i32 1, i32* %6
br label %10
10: ; preds = %30, %2
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 3
br i1 %12, label %13, label %33
13: ; preds = %10
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = load i32, i32* %4
%26 = call i64 @WITNESS(i32 %24, i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %20
store i32 0, i32* %3
br label %34
29: ; preds = %20, %13
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %10
33: ; preds = %10
store i32 1, i32* %3
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %3
ret i32 %35
}

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
}