#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fread(double *, int, int, int /*<<< orphan*/ *);
double kahan_accum(double, double *, int /*<<< orphan*/);
int /*<<< orphan*/ log(double);
int sequence_log_likelihood_alldisk(double *p, FILE *fi_s) {
  double accum = 0.0;
  double compensation = 0.0;
  double s;
  while (fread(&s, sizeof(double), 1, fi_s)) {
    accum = kahan_accum(accum, &compensation, log(s));
  }
  *p = accum;
  return 0;
}


x86 assembly (clang, -O0):
<sequence_log_likelihood_alldisk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
je     119f <sequence_log_likelihood_alldisk+0x6f>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%esi
lea    -0x20(%rbp),%rdi
call   1040 <kahan_accum@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1150 <sequence_log_likelihood_alldisk+0x20>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequence_log_likelihood_alldisk>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xorps  %xmm0,%xmm0
test   %rax,%rax
je     11bb <sequence_log_likelihood_alldisk+0x8b>
movsd  %xmm0,(%rsp)
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm0
call   1050 <log@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rdi
mov    %eax,%esi
call   1040 <kahan_accum@plt>
movsd  %xmm0,(%rsp)
mov    %r12,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1180 <sequence_log_likelihood_alldisk+0x50>
jmp    11c0 <sequence_log_likelihood_alldisk+0x90>
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @sequence_log_likelihood_alldisk(double* %0, i32* %1) {
%3 = alloca double*
%4 = alloca i32*
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double* %0, double** %3
store i32* %1, i32** %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
br label %8
8: ; preds = %12, %2
%9 = load i32*, i32** %4
%10 = call i64 @fread(double* %7, i32 8, i32 1, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load double, double* %5
%14 = load double, double* %7
%15 = call i32 @log(double %14)
%16 = call double @kahan_accum(double %13, double* %6, i32 %15)
store double %16, double* %5
br label %8
17: ; preds = %8
%18 = load double, double* %5
%19 = load double*, double** %3
store double %18, double* %19
ret i32 0
}

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