#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 kahan_accum(double, double *, int /*<<< orphan*/);
int /*<<< orphan*/ log(double const);
int sequence_log_likelihood_nodisk(double *p, int nobs, const double *s_big) {
  double accum = 0.0;
  double compensation = 0.0;
  int i;
  for (i = 0; i < nobs; i++) {
    accum = kahan_accum(accum, &compensation, log(s_big[i]));
  }
  *p = accum;
  return 0;
}


x86 assembly (clang, -O0):
<sequence_log_likelihood_nodisk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1195 <sequence_log_likelihood_nodisk+0x75>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <log@plt>
movsd  -0x38(%rbp),%xmm0
mov    %eax,%esi
lea    -0x28(%rbp),%rdi
call   1030 <kahan_accum@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114a <sequence_log_likelihood_nodisk+0x2a>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequence_log_likelihood_nodisk>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
test   %esi,%esi
jle    117a <sequence_log_likelihood_nodisk+0x5a>
mov    %rdx,%r12
mov    %esi,%r13d
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
nopl   (%rax)
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbx,8),%xmm0
call   1040 <log@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <kahan_accum@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1150 <sequence_log_likelihood_nodisk+0x30>
jmp    117d <sequence_log_likelihood_nodisk+0x5d>
xorps  %xmm0,%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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