#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 */
double fabs(double);
double errorcheck(int nini, int nend, double scale, double *a) {
  int j, seed = 0;
  double err = 0, e;
  for (j = nini; j <= nend; j++) {
    e = ((*(&seed) = (*(&seed) * 7141 + 54773) % 259200) * (1.0 / 259200.0)) -
        a[j] * scale;
    err = ((err) > (fabs(e)) ? (err) : (fabs(e)));
  }
  return err;
}


x86 assembly (clang, -O0):
<errorcheck>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11e8 <errorcheck+0xe8>
imul   $0x1be5,-0x20(%rbp),%eax
add    $0xd5f5,%eax
mov    $0x3f480,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
cvtsi2sd %edx,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  -0x10(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe90(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movaps 0xe62(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11bb <errorcheck+0xbb>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11d0 <errorcheck+0xd0>
movsd  -0x30(%rbp),%xmm0
movaps 0xe39(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1128 <errorcheck+0x28>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<errorcheck>:
xorpd  %xmm1,%xmm1
cmp    %esi,%edi
jg     118e <errorcheck+0x8e>
movslq %edi,%rax
lea    (%rdx,%rax,8),%r8
sub    %edi,%esi
add    $0x1,%esi
xor    %ecx,%ecx
xorpd  %xmm1,%xmm1
movsd  0xeda(%rip),%xmm2
movapd 0xee2(%rip),%xmm3
xor    %edx,%edx
imul   $0x1be5,%edx,%edi
mov    %edi,%edx
add    $0xd5f5,%edx
movslq %edx,%rdx
imul   $0xffffffff81742e05,%rdx,%rax
shr    $0x20,%rax
add    %edi,%eax
add    $0xd5f5,%eax
mov    %eax,%edi
shr    $0x1f,%edi
sar    $0x11,%eax
add    %edi,%eax
imul   $0x3f480,%eax,%eax
sub    %eax,%edx
xorps  %xmm4,%xmm4
cvtsi2sd %edx,%xmm4
movsd  (%r8,%rcx,8),%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm2,%xmm4
subsd  %xmm5,%xmm4
andpd  %xmm3,%xmm4
maxsd  %xmm4,%xmm1
add    $0x1,%rcx
cmp    %ecx,%esi
jne    1130 <errorcheck+0x30>
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @errorcheck(i32 %0, i32 %1, double %2, double* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store double %2, double* %7
store double* %3, double** %8
store i32 0, i32* %10
store double 0.000000e+00, double* %11
%13 = load i32, i32* %5
store i32 %13, i32* %9
br label %14
14: ; preds = %44, %4
%15 = load i32, i32* %9
%16 = load i32, i32* %6
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %47
18: ; preds = %14
%19 = load i32, i32* %10
%20 = mul nsw i32 %19, 7141
%21 = add nsw i32 %20, 54773
%22 = srem i32 %21, 259200
store i32 %22, i32* %10
%23 = sitofp i32 %22 to double
%24 = load double*, double** %8
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double, double* %7
%30 = fmul double %28, %29
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %23, double 0x3ED02E85C0898B71, double %31)
store double %32, double* %12
%33 = load double, double* %11
%34 = load double, double* %12
%35 = call double @llvm.fabs.f64(double %34)
%36 = fcmp ogt double %33, %35
br i1 %36, label %37, label %39
37: ; preds = %18
%38 = load double, double* %11
br label %42
39: ; preds = %18
%40 = load double, double* %12
%41 = call double @llvm.fabs.f64(double %40)
br label %42
42: ; preds = %39, %37
%43 = phi double [ %38, %37 ], [ %41, %39 ]
store double %43, double* %11
br label %44
44: ; preds = %42
%45 = load i32, i32* %9
%46 = add nsw i32 %45, 1
store i32 %46, i32* %9
br label %14
47: ; preds = %14
%48 = load double, double* %11
ret double %48
}

LLVM IR (-O2):
define double @errorcheck(i32 %0, i32 %1, double %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, %1
br i1 %5, label %28, label %6
6: ; preds = %4
%7 = sext i32 %0 to i64
%8 = add i32 %1, 1
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ %7, %6 ], [ %25, %9 ]
%11 = phi double [ 0.000000e+00, %6 ], [ %24, %9 ]
%12 = phi i32 [ 0, %6 ], [ %15, %9 ]
%13 = mul nsw i32 %12, 7141
%14 = add nsw i32 %13, 54773
%15 = srem i32 %14, 259200
%16 = sitofp i32 %15 to double
%17 = getelementptr inbounds double, double* %3, i64 %10
%18 = load double, double* %17
%19 = fneg double %18
%20 = fmul double %19, %2
%21 = tail call double @llvm.fmuladd.f64(double %16, double 0x3ED02E85C0898B71, double %20)
%22 = tail call double @llvm.fabs.f64(double %21)
%23 = fcmp ogt double %11, %22
%24 = select i1 %23, double %11, double %22
%25 = add nsw i64 %10, 1
%26 = trunc i64 %25 to i32
%27 = icmp eq i32 %8, %26
br i1 %27, label %28, label %9
28: ; preds = %9, %4
%29 = phi double [ 0.000000e+00, %4 ], [ %24, %9 ]
ret double %29
}