#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 log10(double);
double log10_add_pow10(double, double const);
double *yyx_calc_likelihood(int depth, const double *beta_log10_val,
                            const double *real_log10prob_vec,
                            double *tmp_four_double_vec) {
  tmp_four_double_vec[2] = real_log10prob_vec[depth];
  tmp_four_double_vec[0] = real_log10prob_vec[0];
  double het_log10_likelihood = -1e100;
  double mosaic_log10_likelihood = -1e100;
  int i;
  for (i = 0; i <= depth; i++) {
    het_log10_likelihood =
        log10_add_pow10(het_log10_likelihood, real_log10prob_vec[i]);
    mosaic_log10_likelihood = log10_add_pow10(
        mosaic_log10_likelihood, real_log10prob_vec[i] + beta_log10_val[i]);
  }
  tmp_four_double_vec[1] = het_log10_likelihood + depth * log10(0.5);
  tmp_four_double_vec[3] = mosaic_log10_likelihood;
  return tmp_four_double_vec;
}


x86 assembly (clang, -O0):
<yyx_calc_likelihood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xe9b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe8e(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11dd <yyx_calc_likelihood+0xbd>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1030 <log10_add_pow10@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm1
call   1030 <log10_add_pow10@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117e <yyx_calc_likelihood+0x5e>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  0xe13(%rip),%xmm0
call   1040 <log10@plt>
movsd  -0x40(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<yyx_calc_likelihood>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
mov    %edi,%r14d
movslq %edi,%rax
movsd  (%rdx,%rax,8),%xmm0
movsd  %xmm0,0x10(%rcx)
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rcx)
test   %eax,%eax
js     11ad <yyx_calc_likelihood+0x8d>
mov    %rdx,%rbx
mov    %rsi,%r12
lea    0x1(%r14),%r13d
movsd  0xea1(%rip),%xmm0
xor    %ebp,%ebp
movsd  %xmm0,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
nopl   (%rax)
movsd  (%rbx,%rbp,8),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <log10_add_pow10@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm1
addsd  (%r12,%rbp,8),%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <log10_add_pow10@plt>
movsd  %xmm0,0x10(%rsp)
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1170 <yyx_calc_likelihood+0x50>
jmp    11c1 <yyx_calc_likelihood+0xa1>
movsd  0xe4b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movsd  0xe3f(%rip),%xmm0
call   1040 <log10@plt>
imul   %r14d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r15)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x18(%r15)
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double* @yyx_calc_likelihood(i32 %0, double* nocapture %1, double* nocapture %2, double* returned writeonly %3) {
%5 = sext i32 %0 to i64
%6 = getelementptr inbounds double, double* %2, i64 %5
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %3, i64 2
store double %7, double* %8
%9 = load double, double* %2
store double %9, double* %3
%10 = icmp slt i32 %0, 0
br i1 %10, label %28, label %11
11: ; preds = %4
%12 = add nuw i32 %0, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %14
%15 = phi i64 [ 0, %11 ], [ %26, %14 ]
%16 = phi double [ -1.000000e+100, %11 ], [ %25, %14 ]
%17 = phi double [ -1.000000e+100, %11 ], [ %20, %14 ]
%18 = getelementptr inbounds double, double* %2, i64 %15
%19 = load double, double* %18
%20 = tail call double @log10_add_pow10(double %17, double %19)
%21 = load double, double* %18
%22 = getelementptr inbounds double, double* %1, i64 %15
%23 = load double, double* %22
%24 = fadd double %21, %23
%25 = tail call double @log10_add_pow10(double %16, double %24)
%26 = add nuw nsw i64 %15, 1
%27 = icmp eq i64 %26, %13
br i1 %27, label %28, label %14
28: ; preds = %14, %4
%29 = phi double [ -1.000000e+100, %4 ], [ %20, %14 ]
%30 = phi double [ -1.000000e+100, %4 ], [ %25, %14 ]
%31 = tail call i32 @log10(double 5.000000e-01)
%32 = mul nsw i32 %31, %0
%33 = sitofp i32 %32 to double
%34 = fadd double %29, %33
%35 = getelementptr inbounds double, double* %3, i64 1
store double %34, double* %35
%36 = getelementptr inbounds double, double* %3, i64 3
store double %30, double* %36
ret double* %3
}