#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(double *);
double log(double);
double sqrt(double);
double intra_entropy_error_ten(double entropy, double(*boltz_ptr),
                               double(*boltzener_ptr), double(*logatt)) {
  double DS_err = 0.0;
  double *DS = (double *)calloc(10, sizeof(double));
  for (int dim1 = 0; dim1 < 10; ++dim1) {
    DS[dim1] = log(boltz_ptr[dim1]) - logatt[dim1] +
               boltzener_ptr[dim1] / boltz_ptr[dim1];
    DS_err += (entropy - DS[dim1]) * (entropy - DS[dim1]);
  }
  DS_err /= 10;
  DS_err = sqrt(DS_err);
  free(DS);
  return DS_err;
}


x86 assembly (clang, -O0):
<intra_entropy_error_ten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1213 <intra_entropy_error_ten+0xd3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <log@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm1
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x8(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  -0x8(%rbp),%xmm2
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117b <intra_entropy_error_ten+0x3b>
movsd  -0x28(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intra_entropy_error_ten>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm0,(%rsp)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1050 <log@plt>
subsd  (%r15,%rbx,8),%xmm0
movsd  (%r12,%rbx,8),%xmm1
divsd  0x0(%r13,%rbx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14,%rbx,8)
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
movsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%rbx
cmp    $0xa,%rbx
jne    1180 <intra_entropy_error_ten+0x40>
divsd  0xe29(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11e7 <intra_entropy_error_ten+0xa7>
sqrtsd %xmm0,%xmm0
jmp    11ec <intra_entropy_error_ten+0xac>
call   1060 <sqrt@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @intra_entropy_error_ten(double %0, double* %1, double* %2, double* %3) {
%5 = alloca double
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double*
%11 = alloca i32
store double %0, double* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store double 0.000000e+00, double* %9
%12 = call i64 @calloc(i32 10, i32 8)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %10
store i32 0, i32* %11
br label %14
14: ; preds = %62, %4
%15 = load i32, i32* %11
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %65
17: ; preds = %14
%18 = load double*, double** %6
%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 = call double @log(double %22)
%24 = load double*, double** %8
%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 = fsub double %23, %28
%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 = load double*, double** %6
%36 = load i32, i32* %11
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = fdiv double %34, %39
%41 = fadd double %29, %40
%42 = load double*, double** %10
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
store double %41, double* %45
%46 = load double, double* %5
%47 = load double*, double** %10
%48 = load i32, i32* %11
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fsub double %46, %51
%53 = load double, double* %5
%54 = load double*, double** %10
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = fsub double %53, %58
%60 = load double, double* %9
%61 = call double @llvm.fmuladd.f64(double %52, double %59, double %60)
store double %61, double* %9
br label %62
62: ; preds = %17
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
br label %14
65: ; preds = %14
%66 = load double, double* %9
%67 = fdiv double %66, 1.000000e+01
store double %67, double* %9
%68 = load double, double* %9
%69 = call double @sqrt(double %68)
store double %69, double* %9
%70 = load double*, double** %10
%71 = call i32 @free(double* %70)
%72 = load double, double* %9
ret double %72
}

LLVM IR (-O2):
define double @intra_entropy_error_ten(double %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = tail call i64 @calloc(i32 10, i32 8)
%6 = inttoptr i64 %5 to double*
br label %11
7: ; preds = %11
%8 = fdiv double %27, 1.000000e+01
%9 = tail call double @sqrt(double %8)
%10 = tail call i32 @free(double* %6)
ret double %9
11: ; preds = %4, %11
%12 = phi i64 [ 0, %4 ], [ %28, %11 ]
%13 = phi double [ 0.000000e+00, %4 ], [ %27, %11 ]
%14 = getelementptr inbounds double, double* %1, i64 %12
%15 = load double, double* %14
%16 = tail call double @log(double %15)
%17 = getelementptr inbounds double, double* %3, i64 %12
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = getelementptr inbounds double, double* %2, i64 %12
%21 = load double, double* %20
%22 = load double, double* %14
%23 = fdiv double %21, %22
%24 = fadd double %19, %23
%25 = getelementptr inbounds double, double* %6, i64 %12
store double %24, double* %25
%26 = fsub double %0, %24
%27 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %13)
%28 = add nuw nsw i64 %12, 1
%29 = icmp eq i64 %28, 10
br i1 %29, label %7, label %11
}