#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 durchschnitt_double_array(double const *, int);
double pow(double const, int);
double stichprobenvarianz_double_array(const double array[], int laenge) {
  double stichprobenvarianz = 0.0;
  double durchschnitt = durchschnitt_double_array(array, laenge);
  if (laenge < 1)
    stichprobenvarianz = 0.0;
  else {
    for (int i = 0; i < laenge; i++) {
      stichprobenvarianz =
          stichprobenvarianz + (pow((array[i] - durchschnitt), 2));
    }
  }
  return stichprobenvarianz / (laenge - 1.0);
}


x86 assembly (clang, -O0):
<stichprobenvarianz_double_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <durchschnitt_double_array@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    115f <stichprobenvarianz_double_array+0x3f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11bc <stichprobenvarianz_double_array+0x9c>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <stichprobenvarianz_double_array+0x97>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1166 <stichprobenvarianz_double_array+0x46>
jmp    11bc <stichprobenvarianz_double_array+0x9c>
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe32(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stichprobenvarianz_double_array>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <durchschnitt_double_array@plt>
test   %r14d,%r14d
jle    1166 <stichprobenvarianz_double_array+0x46>
mov    %r14d,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
movsd  %xmm0,0x8(%rsp)
jae    116f <stichprobenvarianz_double_array+0x4f>
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
movapd %xmm0,%xmm1
jmp    1214 <stichprobenvarianz_double_array+0xf4>
xorpd  %xmm2,%xmm2
jmp    1250 <stichprobenvarianz_double_array+0x130>
and    $0xfffffffc,%r12d
xorpd  %xmm2,%xmm2
xor    %ebp,%ebp
movapd %xmm0,%xmm1
nopl   (%rax)
movsd  %xmm2,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rbx,%rbp,8),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
addsd  (%rsp),%xmm2
add    $0x4,%rbp
cmp    %rbp,%r12
jne    1180 <stichprobenvarianz_double_array+0x60>
test   %r15,%r15
je     1250 <stichprobenvarianz_double_array+0x130>
lea    (%rbx,%rbp,8),%rbx
xor    %ebp,%ebp
nop
movsd  %xmm2,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  %xmm1,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  (%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm2
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1220 <stichprobenvarianz_double_array+0x100>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
addsd  0xda0(%rip),%xmm0
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @stichprobenvarianz_double_array(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %5
%8 = load double*, double** %3
%9 = load i32, i32* %4
%10 = call double @durchschnitt_double_array(double* %8, i32 %9)
store double %10, double* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %2
store double 0.000000e+00, double* %5
br label %34
14: ; preds = %2
store i32 0, i32* %7
br label %15
15: ; preds = %30, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = load double, double* %5
%21 = load double*, double** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
%25 = load double, double* %24
%26 = load double, double* %6
%27 = fsub double %25, %26
%28 = call double @pow(double %27, i32 2)
%29 = fadd double %20, %28
store double %29, double* %5
br label %30
30: ; preds = %19
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %15
33: ; preds = %15
br label %34
34: ; preds = %33, %13
%35 = load double, double* %5
%36 = load i32, i32* %4
%37 = sitofp i32 %36 to double
%38 = fsub double %37, 1.000000e+00
%39 = fdiv double %35, %38
ret double %39
}

LLVM IR (-O2):
define double @stichprobenvarianz_double_array(double* %0, i32 %1) {
%3 = tail call double @durchschnitt_double_array(double* %0, i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %59
5: ; preds = %2
%6 = zext i32 %1 to i64
%7 = add nsw i64 %6, -1
%8 = and i64 %6, 3
%9 = icmp ult i64 %7, 3
br i1 %9, label %42, label %10
10: ; preds = %5
%11 = and i64 %6, 4294967292
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %39, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %38, %12 ]
%15 = phi i64 [ 0, %10 ], [ %40, %12 ]
%16 = getelementptr inbounds double, double* %0, i64 %13
%17 = load double, double* %16
%18 = fsub double %17, %3
%19 = tail call double @pow(double %18, i32 2)
%20 = fadd double %14, %19
%21 = or i64 %13, 1
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = fsub double %23, %3
%25 = tail call double @pow(double %24, i32 2)
%26 = fadd double %20, %25
%27 = or i64 %13, 2
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = load double, double* %28
%30 = fsub double %29, %3
%31 = tail call double @pow(double %30, i32 2)
%32 = fadd double %26, %31
%33 = or i64 %13, 3
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = fsub double %35, %3
%37 = tail call double @pow(double %36, i32 2)
%38 = fadd double %32, %37
%39 = add nuw nsw i64 %13, 4
%40 = add i64 %15, 4
%41 = icmp eq i64 %40, %11
br i1 %41, label %42, label %12
42: ; preds = %12, %5
%43 = phi double [ undef, %5 ], [ %38, %12 ]
%44 = phi i64 [ 0, %5 ], [ %39, %12 ]
%45 = phi double [ 0.000000e+00, %5 ], [ %38, %12 ]
%46 = icmp eq i64 %8, 0
br i1 %46, label %59, label %47
47: ; preds = %42, %47
%48 = phi i64 [ %56, %47 ], [ %44, %42 ]
%49 = phi double [ %55, %47 ], [ %45, %42 ]
%50 = phi i64 [ %57, %47 ], [ 0, %42 ]
%51 = getelementptr inbounds double, double* %0, i64 %48
%52 = load double, double* %51
%53 = fsub double %52, %3
%54 = tail call double @pow(double %53, i32 2)
%55 = fadd double %49, %54
%56 = add nuw nsw i64 %48, 1
%57 = add i64 %50, 1
%58 = icmp eq i64 %57, %8
br i1 %58, label %59, label %47
59: ; preds = %42, %47, %2
%60 = phi double [ 0.000000e+00, %2 ], [ %43, %42 ], [ %55, %47 ]
%61 = sitofp i32 %1 to double
%62 = fadd double %61, -1.000000e+00
%63 = fdiv double %60, %62
ret double %63
}