#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 */
long mod_product(long, long, long);
int /*<<< orphan*/ printf(char *, long, long, long, long, long);
long mod_product_test(long *pair, long mod, long product) {
  long prod = mod_product(pair[0], pair[1], mod);
  if (prod != product) {
    printf("Incorrect evaluation of %d*%d mod %d: %d instead of %d.\n", pair[0],
           pair[1], mod, prod, product);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mod_product_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <mod_product@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     1192 <mod_product_test+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x20(%rbp),%r9
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
movq   $0x1,-0x8(%rbp)
jmp    119a <mod_product_test+0x7a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_product_test>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    0x8(%rbx),%rsi
mov    %r15,%rdx
call   1030 <mod_product@plt>
cmp    %r14,%rax
jne    1146 <mod_product_test+0x26>
xor    %eax,%eax
jmp    1167 <mod_product_test+0x47>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
lea    0xeac(%rip),%rdi
mov    %r15,%rcx
mov    %rax,%r8
mov    %r14,%r9
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [57 x i8] c"Incorrect evaluation of %d*%d mod %d: %d instead of %d.\0A\00"
define i64 @mod_product_test(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
%9 = load i64*, i64** %5
%10 = getelementptr inbounds i64, i64* %9, i64 0
%11 = load i64, i64* %10
%12 = load i64*, i64** %5
%13 = getelementptr inbounds i64, i64* %12, i64 1
%14 = load i64, i64* %13
%15 = load i64, i64* %6
%16 = call i64 @mod_product(i64 %11, i64 %14, i64 %15)
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = load i64, i64* %7
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %3
%21 = load i64*, i64** %5
%22 = getelementptr inbounds i64, i64* %21, i64 0
%23 = load i64, i64* %22
%24 = load i64*, i64** %5
%25 = getelementptr inbounds i64, i64* %24, i64 1
%26 = load i64, i64* %25
%27 = load i64, i64* %6
%28 = load i64, i64* %8
%29 = load i64, i64* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 %23, i64 %26, i64 %27, i64 %28, i64 %29)
store i64 1, i64* %4
br label %32
31: ; preds = %3
store i64 0, i64* %4
br label %32
32: ; preds = %31, %20
%33 = load i64, i64* %4
ret i64 %33
}

LLVM IR (-O2):
@.str = [57 x i8] c"Incorrect evaluation of %d*%d mod %d: %d instead of %d.\0A\00"
define i64 @mod_product_test(i64* nocapture %0, i64 %1, i64 %2) {
%4 = load i64, i64* %0
%5 = getelementptr inbounds i64, i64* %0, i64 1
%6 = load i64, i64* %5
%7 = tail call i64 @mod_product(i64 %4, i64 %6, i64 %1)
%8 = icmp eq i64 %7, %2
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i64, i64* %0
%11 = load i64, i64* %5
%12 = tail call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0), i64 %10, i64 %11, i64 %1, i64 %7, i64 %2)
br label %13
13: ; preds = %3, %9
%14 = phi i64 [ 1, %9 ], [ 0, %3 ]
ret i64 %14
}