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


x86 assembly (clang, -O0):
<modular_product_size_t_unsafe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    114a <modular_product_size_t_unsafe+0x3a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11aa <modular_product_size_t_unsafe+0x9a>
mov    -0x10(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1184 <modular_product_size_t_unsafe+0x74>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <modular_addition_size_t_unsafe@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <modular_addition_size_t_unsafe@plt>
mov    %rax,-0x8(%rbp)
jmp    1152 <modular_product_size_t_unsafe+0x42>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<modular_product_size_t_unsafe>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    %rsi,%rdi
mov    %rsi,%r13
cmovb  %rdi,%r13
test   %r13,%r13
je     1179 <modular_product_size_t_unsafe+0x69>
mov    %rdx,%r14
mov    %rdi,%r12
cmp    %rsi,%rdi
cmovb  %rsi,%r12
xor    %r15d,%r15d
jmp    1160 <modular_product_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_addition_size_t_unsafe@plt>
mov    %rax,%r12
cmp    $0x1,%r13
mov    %rbx,%r13
jbe    117c <modular_product_size_t_unsafe+0x6c>
test   $0x1,%r13b
je     1140 <modular_product_size_t_unsafe+0x30>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1030 <modular_addition_size_t_unsafe@plt>
mov    %rax,%r15
jmp    1140 <modular_product_size_t_unsafe+0x30>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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