#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 */
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ log_likelihood(int, double *, double, double, double, double,
                                  double, double, double, double, double *);
scalar_t__ malloc(int);
double sum_log_likelihood(int N, double *d, double ep1, double ep2,
                          double sigma1, double sigma2, double k1, double k2,
                          double tau, double epsilon) {
  int i = 0;
  double sum = 0.;
  double *ll;
  ll = (double *)malloc(N * sizeof(double));
  log_likelihood(N, d, ep1, ep2, sigma1, sigma2, k1, k2, tau, epsilon, ll);
  for (i = 0; i < N; i++) {
    sum += ll[i];
  }
  free(ll);
  return sum;
}


x86 assembly (clang, -O0):
<sum_log_likelihood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
movsd  %xmm5,-0x40(%rbp)
movsd  %xmm6,-0x48(%rbp)
movsd  %xmm7,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x68(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
movsd  -0x48(%rbp),%xmm6
movsd  -0x50(%rbp),%xmm7
mov    -0x68(%rbp),%rdx
call   1040 <log_likelihood@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f9 <sum_log_likelihood+0xc9>
mov    -0x68(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c8 <sum_log_likelihood+0x98>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x60(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_log_likelihood>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movsd  %xmm7,(%rsp)
movsd  %xmm6,0x38(%rsp)
movsd  %xmm5,0x30(%rsp)
movsd  %xmm4,0x28(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r15
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r14d,%edi
mov    %r15,%rsi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
movsd  0x30(%rsp),%xmm5
movsd  0x38(%rsp),%xmm6
movsd  (%rsp),%xmm7
mov    %rax,%rdx
call   1040 <log_likelihood@plt>
test   %r14d,%r14d
jle    11da <sum_log_likelihood+0xaa>
mov    %r14d,%ecx
lea    -0x1(%rcx),%rdx
mov    %ecx,%eax
and    $0x7,%eax
cmp    $0x7,%rdx
jae    11e0 <sum_log_likelihood+0xb0>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
jmp    1228 <sum_log_likelihood+0xf8>
xorpd  %xmm0,%xmm0
jmp    124e <sum_log_likelihood+0x11e>
and    $0xfffffff8,%ecx
xorpd  %xmm0,%xmm0
xor    %edx,%edx
nopl   0x0(%rax)
addsd  (%rbx,%rdx,8),%xmm0
addsd  0x8(%rbx,%rdx,8),%xmm0
addsd  0x10(%rbx,%rdx,8),%xmm0
addsd  0x18(%rbx,%rdx,8),%xmm0
addsd  0x20(%rbx,%rdx,8),%xmm0
addsd  0x28(%rbx,%rdx,8),%xmm0
addsd  0x30(%rbx,%rdx,8),%xmm0
addsd  0x38(%rbx,%rdx,8),%xmm0
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    11f0 <sum_log_likelihood+0xc0>
test   %rax,%rax
je     124e <sum_log_likelihood+0x11e>
lea    (%rbx,%rdx,8),%rcx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  (%rcx,%rdx,8),%xmm0
add    $0x1,%rdx
cmp    %rdx,%rax
jne    1240 <sum_log_likelihood+0x110>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @sum_log_likelihood(i32 %0, double* %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9) {
%11 = shl i32 %0, 3
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double*
%14 = tail call i32 @log_likelihood(i32 %0, double* %1, double %2, double %3, double %4, double %5, double %6, double %7, double %8, double %9, double* %13)
%15 = icmp sgt i32 %0, 0
br i1 %15, label %16, label %76
16: ; preds = %10
%17 = zext i32 %0 to i64
%18 = add nsw i64 %17, -1
%19 = and i64 %17, 7
%20 = icmp ult i64 %18, 7
br i1 %20, label %61, label %21
21: ; preds = %16
%22 = and i64 %17, 4294967288
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %58, %23 ]
%25 = phi double [ 0.000000e+00, %21 ], [ %57, %23 ]
%26 = phi i64 [ 0, %21 ], [ %59, %23 ]
%27 = getelementptr inbounds double, double* %13, i64 %24
%28 = load double, double* %27
%29 = fadd double %25, %28
%30 = or i64 %24, 1
%31 = getelementptr inbounds double, double* %13, i64 %30
%32 = load double, double* %31
%33 = fadd double %29, %32
%34 = or i64 %24, 2
%35 = getelementptr inbounds double, double* %13, i64 %34
%36 = load double, double* %35
%37 = fadd double %33, %36
%38 = or i64 %24, 3
%39 = getelementptr inbounds double, double* %13, i64 %38
%40 = load double, double* %39
%41 = fadd double %37, %40
%42 = or i64 %24, 4
%43 = getelementptr inbounds double, double* %13, i64 %42
%44 = load double, double* %43
%45 = fadd double %41, %44
%46 = or i64 %24, 5
%47 = getelementptr inbounds double, double* %13, i64 %46
%48 = load double, double* %47
%49 = fadd double %45, %48
%50 = or i64 %24, 6
%51 = getelementptr inbounds double, double* %13, i64 %50
%52 = load double, double* %51
%53 = fadd double %49, %52
%54 = or i64 %24, 7
%55 = getelementptr inbounds double, double* %13, i64 %54
%56 = load double, double* %55
%57 = fadd double %53, %56
%58 = add nuw nsw i64 %24, 8
%59 = add i64 %26, 8
%60 = icmp eq i64 %59, %22
br i1 %60, label %61, label %23
61: ; preds = %23, %16
%62 = phi double [ undef, %16 ], [ %57, %23 ]
%63 = phi i64 [ 0, %16 ], [ %58, %23 ]
%64 = phi double [ 0.000000e+00, %16 ], [ %57, %23 ]
%65 = icmp eq i64 %19, 0
br i1 %65, label %76, label %66
66: ; preds = %61, %66
%67 = phi i64 [ %73, %66 ], [ %63, %61 ]
%68 = phi double [ %72, %66 ], [ %64, %61 ]
%69 = phi i64 [ %74, %66 ], [ 0, %61 ]
%70 = getelementptr inbounds double, double* %13, i64 %67
%71 = load double, double* %70
%72 = fadd double %68, %71
%73 = add nuw nsw i64 %67, 1
%74 = add i64 %69, 1
%75 = icmp eq i64 %74, %19
br i1 %75, label %76, label %66
76: ; preds = %61, %66, %10
%77 = phi double [ 0.000000e+00, %10 ], [ %62, %61 ], [ %72, %66 ]
%78 = tail call i32 @free(double* %13)
ret double %77
}