#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 */
size_t modular_power_size_t_unsafe(size_t, size_t, size_t);
size_t modular_product_size_t_unsafe(size_t, size_t, size_t);
int miller_rabin_pass_size_t(size_t x, size_t b) {
  size_t y, z;
  int i;
  if (b < 2) {
    return 1;
  }
  i = -1;
  y = x - 1;
  while ((y & 1) == 0) {
    y = y >> 1;
    i++;
  }
  z = modular_power_size_t_unsafe(b, y, x);
  y = x - 1;
  if ((z == 1) || (z == y)) {
    return 1;
  }
  for (; i > 0; i--) {
    z = modular_product_size_t_unsafe(z, z, x);
    if (z == 1) {
      return 0;
    } else if (z == y) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<miller_rabin_pass_size_t>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    1147 <miller_rabin_pass_size_t+0x27>
movl   $0x1,-0x4(%rbp)
jmp    1240 <miller_rabin_pass_size_t+0x120>
movl   $0xffffffff,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    1186 <miller_rabin_pass_size_t+0x66>
mov    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    115a <miller_rabin_pass_size_t+0x3a>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <modular_power_size_t_unsafe@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x28(%rbp)
je     11c0 <miller_rabin_pass_size_t+0xa0>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    11cc <miller_rabin_pass_size_t+0xac>
movl   $0x1,-0x4(%rbp)
jmp    1240 <miller_rabin_pass_size_t+0x120>
jmp    11d1 <miller_rabin_pass_size_t+0xb1>
cmpl   $0x0,-0x2c(%rbp)
jle    1239 <miller_rabin_pass_size_t+0x119>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <modular_product_size_t_unsafe@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x1,-0x28(%rbp)
jne    1207 <miller_rabin_pass_size_t+0xe7>
movl   $0x0,-0x4(%rbp)
jmp    1240 <miller_rabin_pass_size_t+0x120>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    1221 <miller_rabin_pass_size_t+0x101>
movl   $0x1,-0x4(%rbp)
jmp    1240 <miller_rabin_pass_size_t+0x120>
jmp    1226 <miller_rabin_pass_size_t+0x106>
jmp    122b <miller_rabin_pass_size_t+0x10b>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d1 <miller_rabin_pass_size_t+0xb1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<miller_rabin_pass_size_t>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
cmp    $0x2,%rsi
jb     11b4 <miller_rabin_pass_size_t+0x94>
mov    %rdi,%r15
lea    -0x1(%rdi),%rbp
mov    $0xffffffff,%ebx
mov    %rbp,%rax
test   $0x1,%bpl
jne    116e <miller_rabin_pass_size_t+0x4e>
mov    $0xffffffff,%ebx
mov    %rbp,%rcx
mov    %rbp,%rax
nopw   0x0(%rax,%rax,1)
shr    %rax
add    $0x1,%ebx
test   $0x2,%cl
mov    %rax,%rcx
je     1160 <miller_rabin_pass_size_t+0x40>
mov    %rsi,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1030 <modular_power_size_t_unsafe@plt>
cmp    $0x1,%rax
je     11b4 <miller_rabin_pass_size_t+0x94>
cmp    %rbp,%rax
je     11b4 <miller_rabin_pass_size_t+0x94>
test   %ebx,%ebx
jle    11b1 <miller_rabin_pass_size_t+0x91>
add    $0x1,%ebx
xchg   %ax,%ax
mov    %rax,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1040 <modular_product_size_t_unsafe@plt>
cmp    $0x1,%rax
je     11b1 <miller_rabin_pass_size_t+0x91>
cmp    %rbp,%rax
je     11b4 <miller_rabin_pass_size_t+0x94>
add    $0xffffffff,%ebx
cmp    $0x2,%ebx
jge    1190 <miller_rabin_pass_size_t+0x70>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @miller_rabin_pass_size_t(i64 %0, i64 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i64 %0, i64* %4
store i64 %1, i64* %5
%9 = load i64, i64* %5
%10 = icmp ult i64 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %61
12: ; preds = %2
store i32 -1, i32* %8
%13 = load i64, i64* %4
%14 = sub i64 %13, 1
store i64 %14, i64* %6
br label %15
15: ; preds = %19, %12
%16 = load i64, i64* %6
%17 = and i64 %16, 1
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i64, i64* %6
%21 = lshr i64 %20, 1
store i64 %21, i64* %6
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
store i32 %23, i32* %8
br label %15
24: ; preds = %15
%25 = load i64, i64* %5
%26 = load i64, i64* %6
%27 = load i64, i64* %4
%28 = call i64 @modular_power_size_t_unsafe(i64 %25, i64 %26, i64 %27)
store i64 %28, i64* %7
%29 = load i64, i64* %4
%30 = sub i64 %29, 1
store i64 %30, i64* %6
%31 = load i64, i64* %7
%32 = icmp eq i64 %31, 1
br i1 %32, label %37, label %33
33: ; preds = %24
%34 = load i64, i64* %7
%35 = load i64, i64* %6
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %38
37: ; preds = %33, %24
store i32 1, i32* %3
br label %61
38: ; preds = %33
br label %39
39: ; preds = %57, %38
%40 = load i32, i32* %8
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %60
42: ; preds = %39
%43 = load i64, i64* %7
%44 = load i64, i64* %7
%45 = load i64, i64* %4
%46 = call i64 @modular_product_size_t_unsafe(i64 %43, i64 %44, i64 %45)
store i64 %46, i64* %7
%47 = load i64, i64* %7
%48 = icmp eq i64 %47, 1
br i1 %48, label %49, label %50
49: ; preds = %42
store i32 0, i32* %3
br label %61
50: ; preds = %42
%51 = load i64, i64* %7
%52 = load i64, i64* %6
%53 = icmp eq i64 %51, %52
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 1, i32* %3
br label %61
55: ; preds = %50
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56
%58 = load i32, i32* %8
%59 = add nsw i32 %58, -1
store i32 %59, i32* %8
br label %39
60: ; preds = %39
store i32 0, i32* %3
br label %61
61: ; preds = %60, %54, %49, %37, %11
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
define i32 @miller_rabin_pass_size_t(i64 %0, i64 %1) {
%3 = icmp ult i64 %1, 2
br i1 %3, label %34, label %4
4: ; preds = %2
%5 = add i64 %0, -1
%6 = and i64 %5, 1
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4, %8
%9 = phi i32 [ %12, %8 ], [ -1, %4 ]
%10 = phi i64 [ %11, %8 ], [ %5, %4 ]
%11 = lshr i64 %10, 1
%12 = add nsw i32 %9, 1
%13 = and i64 %10, 2
%14 = icmp eq i64 %13, 0
br i1 %14, label %8, label %15
15: ; preds = %8, %4
%16 = phi i64 [ %5, %4 ], [ %11, %8 ]
%17 = phi i32 [ -1, %4 ], [ %12, %8 ]
%18 = tail call i64 @modular_power_size_t_unsafe(i64 %1, i64 %16, i64 %0)
%19 = icmp eq i64 %18, 1
%20 = icmp eq i64 %18, %5
%21 = or i1 %19, %20
br i1 %21, label %34, label %22
22: ; preds = %15
%23 = icmp sgt i32 %17, 0
br i1 %23, label %27, label %34
24: ; preds = %32
%25 = add nsw i32 %28, -1
%26 = icmp sgt i32 %28, 1
br i1 %26, label %27, label %34
27: ; preds = %22, %24
%28 = phi i32 [ %25, %24 ], [ %17, %22 ]
%29 = phi i64 [ %30, %24 ], [ %18, %22 ]
%30 = tail call i64 @modular_product_size_t_unsafe(i64 %29, i64 %29, i64 %0)
%31 = icmp eq i64 %30, 1
br i1 %31, label %34, label %32
32: ; preds = %27
%33 = icmp eq i64 %30, %5
br i1 %33, label %34, label %24
34: ; preds = %27, %32, %24, %22, %15, %2
%35 = phi i32 [ 1, %2 ], [ 1, %15 ], [ 0, %22 ], [ 0, %27 ], [ 1, %32 ], [ 0, %24 ]
ret i32 %35
}