#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 ortho(double, int, double);
double sqrt(double);
void pr_err(double *pars, double *err, double d_max, int n_c, double r,
            double *pr_value, double *pr_value_err) {
  double sum = 0.0;
  double sum_err = 0.0;
  double func_value;
  int i;
  for (i = 0; i < n_c; i++) {
    func_value = ortho(d_max, i + 1, r);
    sum += pars[i] * func_value;
    sum_err += err[i * n_c + i] * func_value * func_value;
  }
  *pr_value = sum;
  if (sum_err > 0) {
    *pr_value_err = sqrt(sum_err);
  } else {
    *pr_value_err = sum;
  }
}


x86 assembly (clang, -O0):
<pr_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11e6 <pr_err+0xc6>
movsd  -0x18(%rbp),%xmm0
mov    -0x54(%rbp),%edi
add    $0x1,%edi
movsd  -0x28(%rbp),%xmm1
call   1030 <ortho@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115c <pr_err+0x3c>
movsd  -0x40(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    121c <pr_err+0xfc>
movsd  -0x48(%rbp),%xmm0
call   1040 <sqrt@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1229 <pr_err+0x109>
movsd  -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_err>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%rbx
mov    %edx,0x4(%rsp)
test   %edx,%edx
jle    11fa <pr_err+0xda>
mov    %rsi,%rbp
mov    %rdi,%r14
mov    %rcx,0x10(%rsp)
mov    %rbx,0x8(%rsp)
mov    0x4(%rsp),%eax
mov    %rax,0x18(%rsp)
xorpd  %xmm2,%xmm2
xor    %r15d,%r15d
xor    %ebx,%ebx
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
nopl   0x0(%rax,%rax,1)
movapd %xmm2,0x30(%rsp)
movslq %r15d,%r15
lea    (%rbx,%r15,1),%r13
lea    0x1(%rbx),%r12
movsd  0x20(%rsp),%xmm0
mov    %r12d,%edi
movsd  0x28(%rsp),%xmm1
call   1030 <ortho@plt>
movsd  0x0(%rbp,%r13,8),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%r14,%rbx,8),%xmm2
unpcklpd %xmm1,%xmm2
unpcklpd %xmm0,%xmm0
mulpd  %xmm2,%xmm0
movapd 0x30(%rsp),%xmm2
addpd  %xmm0,%xmm2
add    0x4(%rsp),%r15d
mov    %r12,%rbx
cmp    %r12,0x18(%rsp)
jne    1170 <pr_err+0x50>
mov    0x10(%rsp),%rax
movlpd %xmm2,(%rax)
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1207 <pr_err+0xe7>
ucomisd %xmm1,%xmm0
mov    0x8(%rsp),%rbx
jb     120e <pr_err+0xee>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    1217 <pr_err+0xf7>
movq   $0x0,(%rcx)
xorpd  %xmm2,%xmm2
jmp    1217 <pr_err+0xf7>
mov    0x8(%rsp),%rbx
jmp    1217 <pr_err+0xf7>
call   1040 <sqrt@plt>
movapd %xmm0,%xmm2
movsd  %xmm2,(%rbx)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @pr_err(double* %0, double* %1, double %2, i32 %3, double %4, double* %5, double* %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
store double* %0, double** %8
store double* %1, double** %9
store double %2, double* %10
store i32 %3, i32* %11
store double %4, double* %12
store double* %5, double** %13
store double* %6, double** %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %16
store i32 0, i32* %18
br label %19
19: ; preds = %51, %7
%20 = load i32, i32* %18
%21 = load i32, i32* %11
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %54
23: ; preds = %19
%24 = load double, double* %10
%25 = load i32, i32* %18
%26 = add nsw i32 %25, 1
%27 = load double, double* %12
%28 = call double @ortho(double %24, i32 %26, double %27)
store double %28, double* %17
%29 = load double*, double** %8
%30 = load i32, i32* %18
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double, double* %17
%35 = load double, double* %15
%36 = call double @llvm.fmuladd.f64(double %33, double %34, double %35)
store double %36, double* %15
%37 = load double*, double** %9
%38 = load i32, i32* %18
%39 = load i32, i32* %11
%40 = mul nsw i32 %38, %39
%41 = load i32, i32* %18
%42 = add nsw i32 %40, %41
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %37, i64 %43
%45 = load double, double* %44
%46 = load double, double* %17
%47 = fmul double %45, %46
%48 = load double, double* %17
%49 = load double, double* %16
%50 = call double @llvm.fmuladd.f64(double %47, double %48, double %49)
store double %50, double* %16
br label %51
51: ; preds = %23
%52 = load i32, i32* %18
%53 = add nsw i32 %52, 1
store i32 %53, i32* %18
br label %19
54: ; preds = %19
%55 = load double, double* %15
%56 = load double*, double** %13
store double %55, double* %56
%57 = load double, double* %16
%58 = fcmp ogt double %57, 0.000000e+00
br i1 %58, label %59, label %63
59: ; preds = %54
%60 = load double, double* %16
%61 = call double @sqrt(double %60)
%62 = load double*, double** %14
store double %61, double* %62
br label %66
63: ; preds = %54
%64 = load double, double* %15
%65 = load double*, double** %14
store double %64, double* %65
br label %66
66: ; preds = %63, %59
ret void
}

LLVM IR (-O2):
define void @pr_err(double* nocapture %0, double* nocapture %1, double %2, i32 %3, double %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = icmp sgt i32 %3, 0
br i1 %8, label %10, label %9
9: ; preds = %7
store double 0.000000e+00, double* %5
br label %39
10: ; preds = %7
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %16, %12 ]
%14 = phi <2 x double> [ zeroinitializer, %10 ], [ %31, %12 ]
%15 = trunc i64 %13 to i32
%16 = add nuw nsw i64 %13, 1
%17 = trunc i64 %16 to i32
%18 = tail call double @ortho(double %2, i32 %17, double %4)
%19 = getelementptr inbounds double, double* %0, i64 %13
%20 = load double, double* %19
%21 = mul nsw i32 %15, %3
%22 = sext i32 %21 to i64
%23 = add nsw i64 %13, %22
%24 = getelementptr inbounds double, double* %1, i64 %23
%25 = load double, double* %24
%26 = fmul double %18, %25
%27 = insertelement <2 x double> poison, double %20, i64 0
%28 = insertelement <2 x double> %27, double %26, i64 1
%29 = insertelement <2 x double> poison, double %18, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %30, <2 x double> %14)
%32 = icmp eq i64 %16, %11
br i1 %32, label %33, label %12
33: ; preds = %12
%34 = extractelement <2 x double> %31, i64 0
store double %34, double* %5
%35 = extractelement <2 x double> %31, i64 1
%36 = fcmp ogt double %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = tail call double @sqrt(double %35)
br label %39
39: ; preds = %9, %33, %37
%40 = phi double [ %38, %37 ], [ %34, %33 ], [ 0.000000e+00, %9 ]
store double %40, double* %6
ret void
}