#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_transformed_smeared(double, int, double, double, double, int);
double iq_smeared(double *pars, double d_max, int n_c, double height,
                  double width, double q, int npts) {
  double sum = 0.0;
  int i;
  for (i = 0; i < n_c; i++) {
    sum += pars[i] *
           ortho_transformed_smeared(d_max, i + 1, height, width, q, npts);
  }
  return sum;
}


x86 assembly (clang, -O0):
<iq_smeared>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
mov    %edx,-0x34(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ad <iq_smeared+0x9d>
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x44(%rbp),%edi
add    $0x1,%edi
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
mov    -0x34(%rbp),%esi
call   1030 <ortho_transformed_smeared@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1145 <iq_smeared+0x35>
movsd  -0x40(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iq_smeared>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
test   %esi,%esi
jle    119f <iq_smeared+0x8f>
mov    %edx,%r14d
mov    %rdi,%r15
mov    %esi,%ebx
xorpd  %xmm4,%xmm4
xor    %ebp,%ebp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
movsd  %xmm4,0x30(%rsp)
movsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,0x28(%rsp)
add    $0x1,%rbp
movsd  0x8(%rsp),%xmm0
mov    %ebp,%edi
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
mov    %r14d,%esi
call   1030 <ortho_transformed_smeared@plt>
movsd  0x30(%rsp),%xmm4
mulsd  0x28(%rsp),%xmm0
addsd  %xmm0,%xmm4
cmp    %rbp,%rbx
jne    1150 <iq_smeared+0x40>
jmp    11a3 <iq_smeared+0x93>
xorpd  %xmm4,%xmm4
movapd %xmm4,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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