#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_eval_polynomial(int, long *, long, long);
int /*<<< orphan*/ printf(char *, long, long);
long mod_eval_polynomial_test(int degree, long coeffs[], long mod, long x,
                              long val) {
  long eval = mod_eval_polynomial(degree, coeffs, mod, x);
  if (eval != val) {
    printf("Incorrect evaliation of polynomial: %d instead of %d\n", eval, val);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<mod_eval_polynomial_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <mod_eval_polynomial@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1182 <mod_eval_polynomial_test+0x62>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
movq   $0x1,-0x8(%rbp)
jmp    118a <mod_eval_polynomial_test+0x6a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_eval_polynomial_test>:
push   %rbx
mov    %r8,%rbx
call   1040 <mod_eval_polynomial@plt>
cmp    %rbx,%rax
jne    1132 <mod_eval_polynomial_test+0x12>
xor    %eax,%eax
pop    %rbx
ret
lea    0xec7(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [54 x i8] c"Incorrect evaliation of polynomial: %d instead of %d\0A\00"
define i64 @mod_eval_polynomial_test(i32 %0, i64* %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store i32 %0, i32* %7
store i64* %1, i64** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
%13 = load i32, i32* %7
%14 = load i64*, i64** %8
%15 = load i64, i64* %9
%16 = load i64, i64* %10
%17 = call i64 @mod_eval_polynomial(i32 %13, i64* %14, i64 %15, i64 %16)
store i64 %17, i64* %12
%18 = load i64, i64* %12
%19 = load i64, i64* %11
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %5
%22 = load i64, i64* %12
%23 = load i64, i64* %11
%24 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %22, i64 %23)
store i64 1, i64* %6
br label %26
25: ; preds = %5
store i64 0, i64* %6
br label %26
26: ; preds = %25, %21
%27 = load i64, i64* %6
ret i64 %27
}

LLVM IR (-O2):
@.str = [54 x i8] c"Incorrect evaliation of polynomial: %d instead of %d\0A\00"
define i64 @mod_eval_polynomial_test(i32 %0, i64* %1, i64 %2, i64 %3, i64 %4) {
%6 = tail call i64 @mod_eval_polynomial(i32 %0, i64* %1, i64 %2, i64 %3)
%7 = icmp eq i64 %6, %4
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i64 %6, i64 %4)
br label %10
10: ; preds = %5, %8
%11 = phi i64 [ 1, %8 ], [ 0, %5 ]
ret i64 %11
}