#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 sqrt(double);
double Stdev(double sum, double sum2, int n) {
  double term;
  double term1;
  double term2;
  double retval;
  if (n <= 2)
    return (0.0);
  term1 = sum2;
  term2 = (sum * sum) / (double)n;
  term = term1 - term2;
  term /= (double)(n - 1);
  retval = sqrt(term);
  return (retval);
}


x86 assembly (clang, -O0):
<Stdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jg     113c <Stdev+0x2c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119e <Stdev+0x8e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Stdev>:
xorpd  %xmm2,%xmm2
cmp    $0x3,%edi
jl     114b <Stdev+0x3b>
mulsd  %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %edi,%xmm2
divsd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
add    $0xffffffff,%edi
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
divsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1150 <Stdev+0x40>
xorps  %xmm2,%xmm2
sqrtsd %xmm1,%xmm2
movapd %xmm2,%xmm0
ret
movapd %xmm1,%xmm0
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @Stdev(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
%12 = load i32, i32* %7
%13 = icmp sle i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %3
store double 0.000000e+00, double* %4
br label %34
15: ; preds = %3
%16 = load double, double* %6
store double %16, double* %9
%17 = load double, double* %5
%18 = load double, double* %5
%19 = fmul double %17, %18
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
store double %22, double* %10
%23 = load double, double* %9
%24 = load double, double* %10
%25 = fsub double %23, %24
store double %25, double* %8
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = sitofp i32 %27 to double
%29 = load double, double* %8
%30 = fdiv double %29, %28
store double %30, double* %8
%31 = load double, double* %8
%32 = call double @sqrt(double %31)
store double %32, double* %11
%33 = load double, double* %11
store double %33, double* %4
br label %34
34: ; preds = %15, %14
%35 = load double, double* %4
ret double %35
}

LLVM IR (-O2):
define double @Stdev(double %0, double %1, i32 %2) {
%4 = icmp slt i32 %2, 3
br i1 %4, label %14, label %5
5: ; preds = %3
%6 = fmul double %0, %0
%7 = sitofp i32 %2 to double
%8 = fdiv double %6, %7
%9 = fsub double %1, %8
%10 = add nsw i32 %2, -1
%11 = sitofp i32 %10 to double
%12 = fdiv double %9, %11
%13 = tail call double @sqrt(double %12)
br label %14
14: ; preds = %3, %5
%15 = phi double [ %13, %5 ], [ 0.000000e+00, %3 ]
ret double %15
}