#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_product_size_t_unsafe(size_t, size_t, size_t);
size_t modular_power_size_t_unsafe(size_t x, size_t y, size_t m) {
  size_t z = 1;
  if (m <= 1) {
    return 0;
  }
  while (y > 0) {
    if (y & 1) {
      z = modular_product_size_t_unsafe(z, x, m);
    }
    y = y >> 1;
    x = modular_product_size_t_unsafe(x, x, m);
  }
  return z;
}


x86 assembly (clang, -O0):
<modular_power_size_t_unsafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
cmpq   $0x1,-0x20(%rbp)
ja     1144 <modular_power_size_t_unsafe+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <modular_power_size_t_unsafe+0x99>
jmp    1149 <modular_power_size_t_unsafe+0x39>
cmpq   $0x0,-0x18(%rbp)
jbe    11a1 <modular_power_size_t_unsafe+0x91>
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     117b <modular_power_size_t_unsafe+0x6b>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <modular_product_size_t_unsafe@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <modular_product_size_t_unsafe@plt>
mov    %rax,-0x10(%rbp)
jmp    1149 <modular_power_size_t_unsafe+0x39>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modular_power_size_t_unsafe>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    $0x2,%rdx
jae    1124 <modular_power_size_t_unsafe+0x14>
xor    %r15d,%r15d
jmp    117f <modular_power_size_t_unsafe+0x6f>
mov    %rsi,%r13
test   %rsi,%rsi
je     1179 <modular_power_size_t_unsafe+0x69>
mov    %rdx,%r14
mov    %rdi,%r12
mov    $0x1,%r15d
jmp    1160 <modular_power_size_t_unsafe+0x50>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rbx
shr    %rbx
mov    %r12,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <modular_product_size_t_unsafe@plt>
mov    %rax,%r12
cmp    $0x1,%r13
mov    %rbx,%r13
jbe    117f <modular_power_size_t_unsafe+0x6f>
test   $0x1,%r13b
je     1140 <modular_power_size_t_unsafe+0x30>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <modular_product_size_t_unsafe@plt>
mov    %rax,%r15
jmp    1140 <modular_power_size_t_unsafe+0x30>
mov    $0x1,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @modular_power_size_t_unsafe(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 1, i64* %8
%9 = load i64, i64* %7
%10 = icmp ule i64 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %3
store i64 0, i64* %4
br label %34
12: ; preds = %3
br label %13
13: ; preds = %25, %12
%14 = load i64, i64* %6
%15 = icmp ugt i64 %14, 0
br i1 %15, label %16, label %32
16: ; preds = %13
%17 = load i64, i64* %6
%18 = and i64 %17, 1
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i64, i64* %8
%22 = load i64, i64* %5
%23 = load i64, i64* %7
%24 = call i64 @modular_product_size_t_unsafe(i64 %21, i64 %22, i64 %23)
store i64 %24, i64* %8
br label %25
25: ; preds = %20, %16
%26 = load i64, i64* %6
%27 = lshr i64 %26, 1
store i64 %27, i64* %6
%28 = load i64, i64* %5
%29 = load i64, i64* %5
%30 = load i64, i64* %7
%31 = call i64 @modular_product_size_t_unsafe(i64 %28, i64 %29, i64 %30)
store i64 %31, i64* %5
br label %13
32: ; preds = %13
%33 = load i64, i64* %8
store i64 %33, i64* %4
br label %34
34: ; preds = %32, %11
%35 = load i64, i64* %4
ret i64 %35
}

LLVM IR (-O2):
define i64 @modular_power_size_t_unsafe(i64 %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %2, 2
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = icmp eq i64 %1, 0
br i1 %6, label %20, label %7
7: ; preds = %5, %15
%8 = phi i64 [ %16, %15 ], [ 1, %5 ]
%9 = phi i64 [ %17, %15 ], [ %1, %5 ]
%10 = phi i64 [ %18, %15 ], [ %0, %5 ]
%11 = and i64 %9, 1
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %7
%14 = tail call i64 @modular_product_size_t_unsafe(i64 %8, i64 %10, i64 %2)
br label %15
15: ; preds = %13, %7
%16 = phi i64 [ %14, %13 ], [ %8, %7 ]
%17 = lshr i64 %9, 1
%18 = tail call i64 @modular_product_size_t_unsafe(i64 %10, i64 %10, i64 %2)
%19 = icmp ult i64 %9, 2
br i1 %19, label %20, label %7
20: ; preds = %15, %5, %3
%21 = phi i64 [ 0, %3 ], [ 1, %5 ], [ %16, %15 ]
ret i64 %21
}