#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_mac2(uint_fast32_t sum, uint_fast32_t a, uint_fast32_t b,
                       uint_fast32_t c, uint_fast32_t d) {
  assert(sum <= 0x7FFFFFFE);
  assert(a <= 0x7FFFFFFE);
  assert(b <= 0x7FFFFFFE);
  assert(c <= 0x7FFFFFFE);
  assert(d <= 0x7FFFFFFE);
  return (uint_fast32_t)(((uint_fast64_t)a * b + (uint_fast64_t)c * d + sum) %
                         0x7FFFFFFF);
}


x86 assembly (clang, -O0):
<mod_mac2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%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>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x14(%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_mac2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %edi,%r15d
xor    %edi,%edi
cmp    $0x7fffffff,%r15d
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmp    $0x7fffffff,%r12d
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
cmp    $0x7fffffff,%ebx
setne  %dil
call   1030 <assert@plt>
imul   %r12d,%ebp
imul   %r14d,%ebx
add    %r15d,%ebp
add    %ebx,%ebp
movslq %ebp,%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
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mod_mac2(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %6
%12 = icmp sle i32 %11, 2147483646
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %7
%16 = icmp sle i32 %15, 2147483646
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* %8
%20 = icmp sle i32 %19, 2147483646
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %9
%24 = icmp sle i32 %23, 2147483646
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %10
%28 = icmp sle i32 %27, 2147483646
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = mul nsw i32 %31, %32
%34 = load i32, i32* %9
%35 = load i32, i32* %10
%36 = mul nsw i32 %34, %35
%37 = add nsw i32 %33, %36
%38 = load i32, i32* %6
%39 = add nsw i32 %37, %38
%40 = srem i32 %39, 2147483647
ret i32 %40
}

LLVM IR (-O2):
define i32 @mod_mac2(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp ne i32 %0, 2147483647
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp ne i32 %1, 2147483647
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp ne i32 %2, 2147483647
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = icmp ne i32 %3, 2147483647
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = icmp ne i32 %4, 2147483647
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = mul nsw i32 %2, %1
%22 = mul nsw i32 %4, %3
%23 = add i32 %21, %0
%24 = add i32 %23, %22
%25 = srem i32 %24, 2147483647
ret i32 %25
}