#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 xpect(double, double, double);
double ind_expected(double x, double *rtng, double *weig, int n, double beta) {
  int i;
  double cume = 0;
  for (i = 0; i < n; i++) {
    cume += weig[i] * xpect(x, rtng[i], beta);
  }
  return cume;
}


x86 assembly (clang, -O0):
<ind_expected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm1,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    119e <ind_expected+0x8e>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x28(%rbp),%xmm2
call   1030 <xpect@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113c <ind_expected+0x2c>
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ind_expected>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edx,%edx
jle    1184 <ind_expected+0x74>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xorpd  %xmm2,%xmm2
xor    %ebx,%ebx
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x20(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%r15,%rbx,8),%xmm1
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
call   1030 <xpect@plt>
movsd  0x20(%rsp),%xmm2
mulsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm2
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <ind_expected+0x30>
jmp    1188 <ind_expected+0x78>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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