#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 error_ten(double mean, double(*obs_ptr), unsigned long numberofframes) {
  double *means;
  means = calloc(10, sizeof(double));
  double error = 0.0;
  unsigned long decade = numberofframes / 10;
  for (int dim1 = 0; dim1 < 10; ++dim1) {
    means[dim1] = obs_ptr[dim1] / (double)decade;
    error += ((means[dim1] - mean) * (means[dim1] - mean));
  }
  error /= 10.0;
  error = sqrt(error);
  free(means);
  return error;
}


x86 assembly (clang, -O0):
<error_ten>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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)
mov    -0x18(%rbp),%rax
mov    $0xa,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    120c <error_ten+0xdc>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe79(%rip),%xmm2
movq   -0x30(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xe78(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x8(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%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    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1179 <error_ten+0x49>
movsd  -0x28(%rbp),%xmm0
movsd  0xde7(%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    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_ten>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
shr    $0x3,%rdx
cvtsi2sd %rdx,%xmm2
movupd (%r15),%xmm0
unpcklpd %xmm2,%xmm2
divpd  %xmm2,%xmm0
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm5
subsd  %xmm5,%xmm3
mulsd  %xmm3,%xmm3
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm3
movupd %xmm0,(%r14)
unpckhpd %xmm0,%xmm0
subsd  %xmm5,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm3,%xmm0
movupd 0x10(%r15),%xmm3
divpd  %xmm2,%xmm3
movapd %xmm3,%xmm4
subsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm0,%xmm4
movupd %xmm3,0x10(%r14)
unpckhpd %xmm3,%xmm3
subsd  %xmm5,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm4,%xmm3
movupd 0x20(%r15),%xmm0
divpd  %xmm2,%xmm0
movapd %xmm0,%xmm4
subsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm3,%xmm4
movupd %xmm0,0x20(%r14)
unpckhpd %xmm0,%xmm0
subsd  %xmm5,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm4,%xmm0
movupd 0x30(%r15),%xmm3
divpd  %xmm2,%xmm3
movapd %xmm3,%xmm4
subsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm4
addsd  %xmm0,%xmm4
movupd %xmm3,0x30(%r14)
unpckhpd %xmm3,%xmm3
subsd  %xmm5,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm4,%xmm3
movupd 0x40(%r15),%xmm0
divpd  %xmm2,%xmm0
movapd %xmm0,%xmm2
subsd  %xmm5,%xmm2
mulsd  %xmm2,%xmm2
addsd  %xmm3,%xmm2
movupd %xmm0,0x40(%r14)
unpckhpd %xmm0,%xmm0
subsd  %xmm5,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
divsd  0xd8c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1280 <error_ten+0x150>
sqrtsd %xmm0,%xmm0
jmp    1285 <error_ten+0x155>
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 @error_ten(double %0, double* %1, i64 %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i64
%7 = alloca double*
%8 = alloca double
%9 = alloca i64
%10 = alloca i32
store double %0, double* %4
store double* %1, double** %5
store i64 %2, i64* %6
%11 = call double* @calloc(i32 10, i32 8)
store double* %11, double** %7
store double 0.000000e+00, double* %8
%12 = load i64, i64* %6
%13 = udiv i64 %12, 10
store i64 %13, i64* %9
store i32 0, i32* %10
br label %14
14: ; preds = %46, %3
%15 = load i32, i32* %10
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %49
17: ; preds = %14
%18 = load double*, double** %5
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load i64, i64* %9
%24 = uitofp i64 %23 to double
%25 = fdiv double %22, %24
%26 = load double*, double** %7
%27 = load i32, i32* %10
%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* %10
%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* %10
%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 = %17
%47 = load i32, i32* %10
%48 = add nsw i32 %47, 1
store i32 %48, i32* %10
br label %14
49: ; preds = %14
%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 @error_ten(double %0, double* nocapture %1, i64 %2) {
%4 = tail call double* @calloc(i32 10, i32 8)
%5 = udiv i64 %2, 10
%6 = uitofp i64 %5 to double
%7 = bitcast double* %1 to <2 x double>*
%8 = load <2 x double>, <2 x double>* %7
%9 = insertelement <2 x double> poison, double %6, i64 0
%10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> zeroinitializer
%11 = fdiv <2 x double> %8, %10
%12 = extractelement <2 x double> %11, i64 0
%13 = fsub double %12, %0
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double 0.000000e+00)
%15 = bitcast double* %4 to <2 x double>*
store <2 x double> %11, <2 x double>* %15
%16 = extractelement <2 x double> %11, i64 1
%17 = fsub double %16, %0
%18 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %14)
%19 = getelementptr inbounds double, double* %1, i64 2
%20 = getelementptr inbounds double, double* %4, i64 2
%21 = bitcast double* %19 to <2 x double>*
%22 = load <2 x double>, <2 x double>* %21
%23 = fdiv <2 x double> %22, %10
%24 = extractelement <2 x double> %23, i64 0
%25 = fsub double %24, %0
%26 = tail call double @llvm.fmuladd.f64(double %25, double %25, double %18)
%27 = bitcast double* %20 to <2 x double>*
store <2 x double> %23, <2 x double>* %27
%28 = extractelement <2 x double> %23, i64 1
%29 = fsub double %28, %0
%30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %26)
%31 = getelementptr inbounds double, double* %1, i64 4
%32 = getelementptr inbounds double, double* %4, i64 4
%33 = bitcast double* %31 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = fdiv <2 x double> %34, %10
%36 = extractelement <2 x double> %35, i64 0
%37 = fsub double %36, %0
%38 = tail call double @llvm.fmuladd.f64(double %37, double %37, double %30)
%39 = bitcast double* %32 to <2 x double>*
store <2 x double> %35, <2 x double>* %39
%40 = extractelement <2 x double> %35, i64 1
%41 = fsub double %40, %0
%42 = tail call double @llvm.fmuladd.f64(double %41, double %41, double %38)
%43 = getelementptr inbounds double, double* %1, i64 6
%44 = getelementptr inbounds double, double* %4, i64 6
%45 = bitcast double* %43 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = fdiv <2 x double> %46, %10
%48 = extractelement <2 x double> %47, i64 0
%49 = fsub double %48, %0
%50 = tail call double @llvm.fmuladd.f64(double %49, double %49, double %42)
%51 = bitcast double* %44 to <2 x double>*
store <2 x double> %47, <2 x double>* %51
%52 = extractelement <2 x double> %47, i64 1
%53 = fsub double %52, %0
%54 = tail call double @llvm.fmuladd.f64(double %53, double %53, double %50)
%55 = getelementptr inbounds double, double* %1, i64 8
%56 = getelementptr inbounds double, double* %4, i64 8
%57 = bitcast double* %55 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fdiv <2 x double> %58, %10
%60 = extractelement <2 x double> %59, i64 0
%61 = fsub double %60, %0
%62 = tail call double @llvm.fmuladd.f64(double %61, double %61, double %54)
%63 = bitcast double* %56 to <2 x double>*
store <2 x double> %59, <2 x double>* %63
%64 = extractelement <2 x double> %59, i64 1
%65 = fsub double %64, %0
%66 = tail call double @llvm.fmuladd.f64(double %65, double %65, double %62)
%67 = fdiv double %66, 1.000000e+01
%68 = tail call double @sqrt(double %67)
%69 = tail call i32 @free(double* %4)
ret double %68
}