#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 *calloc(int, int);
int /*<<< orphan*/ free(double *);
double sqrt(double);
double weighted_error_ten(double mean, double(*means_ptr),
                          double(*weights_ptr)) {
  double *means;
  means = calloc(10, sizeof(double));
  double error = 0.0;
  for (int dim1 = 0; dim1 < 10; dim1++) {
    means[dim1] = (means_ptr[dim1] / weights_ptr[dim1]);
    error += ((means[dim1] - mean) * (means[dim1] - mean));
  }
  error /= 10.0;
  error = sqrt(error);
  free(means);
  return error;
}


x86 assembly (clang, -O0):
<weighted_error_ten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    11dc <weighted_error_ten+0xac>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
subsd  -0x8(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1167 <weighted_error_ten+0x37>
movsd  -0x28(%rbp),%xmm0
movsd  0xe17(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weighted_error_ten>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
movupd (%rbx),%xmm0
movupd (%r15),%xmm1
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm4
subsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm2
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm2
movupd %xmm0,(%rax)
unpckhpd %xmm0,%xmm0
subsd  %xmm4,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
movupd 0x10(%rbx),%xmm2
movupd 0x10(%r15),%xmm3
divpd  %xmm3,%xmm2
movapd %xmm2,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm0,%xmm3
movupd %xmm2,0x10(%rax)
unpckhpd %xmm2,%xmm2
subsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
movupd 0x20(%rbx),%xmm0
movupd 0x20(%r15),%xmm3
divpd  %xmm3,%xmm0
movapd %xmm0,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm2,%xmm3
movupd %xmm0,0x20(%rax)
unpckhpd %xmm0,%xmm0
subsd  %xmm4,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
movupd 0x30(%rbx),%xmm2
movupd 0x30(%r15),%xmm3
divpd  %xmm3,%xmm2
movapd %xmm2,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm0,%xmm3
movupd %xmm2,0x30(%rax)
unpckhpd %xmm2,%xmm2
subsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
movupd 0x40(%rbx),%xmm0
movupd 0x40(%r15),%xmm3
divpd  %xmm3,%xmm0
movapd %xmm0,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm2,%xmm3
movupd %xmm0,0x40(%rax)
unpckhpd %xmm0,%xmm0
subsd  %xmm4,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
divsd  0xd96(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1276 <weighted_error_ten+0x146>
sqrtsd %xmm0,%xmm0
jmp    127b <weighted_error_ten+0x14b>
call   1050 <sqrt@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double @weighted_error_ten(double %0, double* nocapture %1, double* nocapture %2) {
%4 = tail call double* @calloc(i32 10, i32 8)
%5 = bitcast double* %1 to <2 x double>*
%6 = load <2 x double>, <2 x double>* %5
%7 = bitcast double* %2 to <2 x double>*
%8 = load <2 x double>, <2 x double>* %7
%9 = fdiv <2 x double> %6, %8
%10 = extractelement <2 x double> %9, i64 0
%11 = fsub double %10, %0
%12 = tail call double @llvm.fmuladd.f64(double %11, double %11, double 0.000000e+00)
%13 = bitcast double* %4 to <2 x double>*
store <2 x double> %9, <2 x double>* %13
%14 = extractelement <2 x double> %9, i64 1
%15 = fsub double %14, %0
%16 = tail call double @llvm.fmuladd.f64(double %15, double %15, double %12)
%17 = getelementptr inbounds double, double* %1, i64 2
%18 = getelementptr inbounds double, double* %2, i64 2
%19 = getelementptr inbounds double, double* %4, i64 2
%20 = bitcast double* %17 to <2 x double>*
%21 = load <2 x double>, <2 x double>* %20
%22 = bitcast double* %18 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = fdiv <2 x double> %21, %23
%25 = extractelement <2 x double> %24, i64 0
%26 = fsub double %25, %0
%27 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %16)
%28 = bitcast double* %19 to <2 x double>*
store <2 x double> %24, <2 x double>* %28
%29 = extractelement <2 x double> %24, i64 1
%30 = fsub double %29, %0
%31 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %27)
%32 = getelementptr inbounds double, double* %1, i64 4
%33 = getelementptr inbounds double, double* %2, i64 4
%34 = getelementptr inbounds double, double* %4, i64 4
%35 = bitcast double* %32 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = bitcast double* %33 to <2 x double>*
%38 = load <2 x double>, <2 x double>* %37
%39 = fdiv <2 x double> %36, %38
%40 = extractelement <2 x double> %39, i64 0
%41 = fsub double %40, %0
%42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %31)
%43 = bitcast double* %34 to <2 x double>*
store <2 x double> %39, <2 x double>* %43
%44 = extractelement <2 x double> %39, i64 1
%45 = fsub double %44, %0
%46 = tail call double @llvm.fmuladd.f64(double %45, double %45, double %42)
%47 = getelementptr inbounds double, double* %1, i64 6
%48 = getelementptr inbounds double, double* %2, i64 6
%49 = getelementptr inbounds double, double* %4, i64 6
%50 = bitcast double* %47 to <2 x double>*
%51 = load <2 x double>, <2 x double>* %50
%52 = bitcast double* %48 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = fdiv <2 x double> %51, %53
%55 = extractelement <2 x double> %54, i64 0
%56 = fsub double %55, %0
%57 = tail call double @llvm.fmuladd.f64(double %56, double %56, double %46)
%58 = bitcast double* %49 to <2 x double>*
store <2 x double> %54, <2 x double>* %58
%59 = extractelement <2 x double> %54, i64 1
%60 = fsub double %59, %0
%61 = tail call double @llvm.fmuladd.f64(double %60, double %60, double %57)
%62 = getelementptr inbounds double, double* %1, i64 8
%63 = getelementptr inbounds double, double* %2, i64 8
%64 = getelementptr inbounds double, double* %4, i64 8
%65 = bitcast double* %62 to <2 x double>*
%66 = load <2 x double>, <2 x double>* %65
%67 = bitcast double* %63 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = fdiv <2 x double> %66, %68
%70 = extractelement <2 x double> %69, i64 0
%71 = fsub double %70, %0
%72 = tail call double @llvm.fmuladd.f64(double %71, double %71, double %61)
%73 = bitcast double* %64 to <2 x double>*
store <2 x double> %69, <2 x double>* %73
%74 = extractelement <2 x double> %69, i64 1
%75 = fsub double %74, %0
%76 = tail call double @llvm.fmuladd.f64(double %75, double %75, double %72)
%77 = fdiv double %76, 1.000000e+01
%78 = tail call double @sqrt(double %77)
%79 = tail call i32 @free(double* %4)
ret double %78
}