#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 */
typedef int uint_fast64_t;
typedef int uint_fast32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
uint_fast32_t mod_mac4(uint_fast32_t sum, uint_fast32_t a, uint_fast32_t b,
                       uint_fast32_t c, uint_fast32_t d, uint_fast32_t e,
                       uint_fast32_t f, uint_fast32_t g, uint_fast32_t h) {
  assert(sum <= 0x7FFFFFFE);
  assert(a <= 0x7FFFFFFE);
  assert(b <= 0x7FFFFFFE);
  assert(c <= 0x7FFFFFFE);
  assert(d <= 0x7FFFFFFE);
  assert(e <= 0x7FFFFFFE);
  assert(f <= 0x7FFFFFFE);
  assert(g <= 0x7FFFFFFE);
  assert(h <= 0x7FFFFFFE);
  return (uint_fast32_t)(((uint_fast64_t)a * b + (uint_fast64_t)c * d +
                          (uint_fast64_t)e * f + (uint_fast64_t)g * h + sum) %
                         0x7FFFFFFF);
}


x86 assembly (clang, -O0):
<mod_mac4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
cmpl   $0x7ffffffe,-0x4(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,-0x8(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,-0xc(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,-0x10(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,-0x14(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,-0x18(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,0x10(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,0x18(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x7ffffffe,0x20(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%ecx
imul   0x10(%rbp),%ecx
add    %ecx,%eax
mov    0x18(%rbp),%ecx
imul   0x20(%rbp),%ecx
add    %ecx,%eax
add    -0x4(%rbp),%eax
mov    $0x7fffffff,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod_mac4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %ecx,0x10(%rsp)
mov    %edx,%ebx
mov    %esi,%r12d
mov    %edi,%eax
mov    %edi,0x14(%rsp)
mov    0x50(%rsp),%r15d
xor    %edi,%edi
cmp    $0x7fffffff,%eax
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%r12d
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%ebx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%ebp
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%r14d
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x7fffffff,0xc(%rsp)
7f
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%r15d
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
mov    0x58(%rsp),%r13d
cmp    $0x7fffffff,%r13d
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
mov    0x60(%rsp),%ebp
cmp    $0x7fffffff,%ebp
setne  %dil
call   1030 <assert@plt>
imul   %r12d,%ebx
imul   0x10(%rsp),%r14d
imul   0xc(%rsp),%r15d
imul   %r13d,%ebp
add    0x14(%rsp),%ebx
add    %r14d,%ebx
add    %r15d,%ebx
add    %ebp,%ebx
movslq %ebx,%rax
mov    %rax,%rcx
shl    $0x1e,%rcx
add    %rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x3d,%rcx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x1f,%edx
sub    %edx,%ecx
add    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mod_mac4(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store i32 %7, i32* %17
store i32 %8, i32* %18
%19 = load i32, i32* %10
%20 = icmp sle i32 %19, 2147483646
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %11
%24 = icmp sle i32 %23, 2147483646
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %12
%28 = icmp sle i32 %27, 2147483646
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %13
%32 = icmp sle i32 %31, 2147483646
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i32, i32* %14
%36 = icmp sle i32 %35, 2147483646
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i32, i32* %15
%40 = icmp sle i32 %39, 2147483646
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i32, i32* %16
%44 = icmp sle i32 %43, 2147483646
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
%47 = load i32, i32* %17
%48 = icmp sle i32 %47, 2147483646
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = load i32, i32* %18
%52 = icmp sle i32 %51, 2147483646
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = load i32, i32* %11
%56 = load i32, i32* %12
%57 = mul nsw i32 %55, %56
%58 = load i32, i32* %13
%59 = load i32, i32* %14
%60 = mul nsw i32 %58, %59
%61 = add nsw i32 %57, %60
%62 = load i32, i32* %15
%63 = load i32, i32* %16
%64 = mul nsw i32 %62, %63
%65 = add nsw i32 %61, %64
%66 = load i32, i32* %17
%67 = load i32, i32* %18
%68 = mul nsw i32 %66, %67
%69 = add nsw i32 %65, %68
%70 = load i32, i32* %10
%71 = add nsw i32 %69, %70
%72 = srem i32 %71, 2147483647
ret i32 %72
}

LLVM IR (-O2):
define i32 @mod_mac4(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8) {
%10 = icmp ne i32 %0, 2147483647
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp ne i32 %1, 2147483647
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = icmp ne i32 %2, 2147483647
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = icmp ne i32 %3, 2147483647
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = icmp ne i32 %4, 2147483647
%23 = zext i1 %22 to i32
%24 = tail call i32 @assert(i32 %23)
%25 = icmp ne i32 %5, 2147483647
%26 = zext i1 %25 to i32
%27 = tail call i32 @assert(i32 %26)
%28 = icmp ne i32 %6, 2147483647
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = icmp ne i32 %7, 2147483647
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = icmp ne i32 %8, 2147483647
%35 = zext i1 %34 to i32
%36 = tail call i32 @assert(i32 %35)
%37 = mul nsw i32 %2, %1
%38 = mul nsw i32 %4, %3
%39 = mul nsw i32 %6, %5
%40 = mul nsw i32 %8, %7
%41 = add i32 %37, %0
%42 = add i32 %41, %38
%43 = add i32 %42, %39
%44 = add i32 %43, %40
%45 = srem i32 %44, 2147483647
ret i32 %45
}