#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 */
float sqrt(float);
void sumtomean(float *sum, float *err, int length) {
  *sum /= length;
  if (length > 1) {
    *err = (*err - *sum * *sum * length) / (length - 1);
    *err = *err <= 0 ? 0 : sqrt(*err);
  } else {
    *err = 0;
  }
}


x86 assembly (clang, -O0):
<sumtomean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,(%rax)
cmpl   $0x1,-0x14(%rbp)
jle    11cb <sumtomean+0xbb>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  (%rax),%xmm0
cvtsi2ssl -0x14(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomiss (%rax),%xmm0
jb     11a7 <sumtomean+0x97>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11b9 <sumtomean+0xa9>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
call   1030 <sqrt@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
jmp    11d6 <sumtomean+0xc6>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumtomean>:
push   %rbx
mov    %rsi,%rbx
cvtsi2ss %edx,%xmm3
movss  (%rdi),%xmm2
divss  %xmm3,%xmm2
movss  %xmm2,(%rdi)
xorps  %xmm1,%xmm1
cmp    $0x2,%edx
jl     116b <sumtomean+0x5b>
movss  (%rbx),%xmm0
mulss  %xmm2,%xmm2
mulss  %xmm3,%xmm2
subss  %xmm2,%xmm0
add    $0xffffffff,%edx
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
divss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
jae    116b <sumtomean+0x5b>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1163 <sumtomean+0x53>
xorps  %xmm1,%xmm1
sqrtss %xmm0,%xmm1
jmp    116b <sumtomean+0x5b>
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movss  %xmm1,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @sumtomean(float* %0, float* %1, i32 %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = sitofp i32 %7 to float
%9 = load float*, float** %4
%10 = load float, float* %9
%11 = fdiv float %10, %8
store float %11, float* %9
%12 = load i32, i32* %6
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %42
14: ; preds = %3
%15 = load float*, float** %5
%16 = load float, float* %15
%17 = load float*, float** %4
%18 = load float, float* %17
%19 = load float*, float** %4
%20 = load float, float* %19
%21 = fmul float %18, %20
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to float
%24 = fneg float %21
%25 = call float @llvm.fmuladd.f32(float %24, float %23, float %16)
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = sitofp i32 %27 to float
%29 = fdiv float %25, %28
%30 = load float*, float** %5
store float %29, float* %30
%31 = load float*, float** %5
%32 = load float, float* %31
%33 = fcmp ole float %32, 0.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %14
br label %39
35: ; preds = %14
%36 = load float*, float** %5
%37 = load float, float* %36
%38 = call float @sqrt(float %37)
br label %39
39: ; preds = %35, %34
%40 = phi float [ 0.000000e+00, %34 ], [ %38, %35 ]
%41 = load float*, float** %5
store float %40, float* %41
br label %44
42: ; preds = %3
%43 = load float*, float** %5
store float 0.000000e+00, float* %43
br label %44
44: ; preds = %42, %39
ret void
}

LLVM IR (-O2):
define void @sumtomean(float* nocapture %0, float* nocapture %1, i32 %2) {
%4 = sitofp i32 %2 to float
%5 = load float, float* %0
%6 = fdiv float %5, %4
store float %6, float* %0
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %19
8: ; preds = %3
%9 = load float, float* %1
%10 = fneg float %6
%11 = fmul float %6, %10
%12 = tail call float @llvm.fmuladd.f32(float %11, float %4, float %9)
%13 = add nsw i32 %2, -1
%14 = sitofp i32 %13 to float
%15 = fdiv float %12, %14
%16 = fcmp ugt float %15, 0.000000e+00
br i1 %16, label %17, label %19
17: ; preds = %8
%18 = tail call float @sqrt(float %15)
br label %19
19: ; preds = %3, %17, %8
%20 = phi float [ %18, %17 ], [ 0.000000e+00, %8 ], [ 0.000000e+00, %3 ]
store float %20, float* %1
ret void
}