#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 pr(double *pars, double d_max, int n_c, double r) {
  double sum = 0.0;
  int i;
  for (i = 0; i < n_c; i++) {
    sum += pars[i] * ortho(d_max, i + 1, r);
  }
  return sum;
}


x86 assembly (clang, -O0):
<pr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <pr+0x83>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
movsd  -0x20(%rbp),%xmm1
call   1030 <ortho@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1138 <pr+0x28>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %esi,%esi
jle    117f <pr+0x6f>
mov    %rdi,%r14
mov    %esi,%r15d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm2,0x18(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%rbx
movsd  (%rsp),%xmm0
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm1
call   1030 <ortho@plt>
movsd  0x18(%rsp),%xmm2
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm2
cmp    %rbx,%r15
jne    1140 <pr+0x30>
jmp    1183 <pr+0x73>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @pr(double* %0, double %1, i32 %2, double %3) {
%5 = alloca double*
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double* %0, double** %5
store double %1, double* %6
store i32 %2, i32* %7
store double %3, double* %8
store double 0.000000e+00, double* %9
store i32 0, i32* %10
br label %11
11: ; preds = %28, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load double*, double** %5
%17 = load i32, i32* %10
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
%20 = load double, double* %19
%21 = load double, double* %6
%22 = load i32, i32* %10
%23 = add nsw i32 %22, 1
%24 = load double, double* %8
%25 = call double @ortho(double %21, i32 %23, double %24)
%26 = load double, double* %9
%27 = call double @llvm.fmuladd.f64(double %20, double %25, double %26)
store double %27, double* %9
br label %28
28: ; preds = %15
%29 = load i32, i32* %10
%30 = add nsw i32 %29, 1
store i32 %30, i32* %10
br label %11
31: ; preds = %11
%32 = load double, double* %9
ret double %32
}

LLVM IR (-O2):
define double @pr(double* nocapture %0, double %1, i32 %2, double %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %18
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %13, %8 ]
%10 = phi double [ 0.000000e+00, %6 ], [ %16, %8 ]
%11 = getelementptr inbounds double, double* %0, i64 %9
%12 = load double, double* %11
%13 = add nuw nsw i64 %9, 1
%14 = trunc i64 %13 to i32
%15 = tail call double @ortho(double %1, i32 %14, double %3)
%16 = tail call double @llvm.fmuladd.f64(double %12, double %15, double %10)
%17 = icmp eq i64 %13, %7
br i1 %17, label %18, label %8
18: ; preds = %8, %4
%19 = phi double [ 0.000000e+00, %4 ], [ %16, %8 ]
ret double %19
}