#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 */
typedef int uint64_t;
struct stddev {
  int dummy;
};

/* Variables and functions */
double abs(double);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ stddev_add(struct stddev *, int);
int /*<<< orphan*/ stddev_get(struct stddev *, int *, double *, double *);
struct stddev *stddev_new();
int /*<<< orphan*/ stddev_remove(struct stddev *, int);
int main() {
  uint64_t cnt;
  double avg, dev;
  struct stddev *sd = stddev_new();
  stddev_add(sd, 1);
  stddev_add(sd, 2);
  stddev_add(sd, 3);
  stddev_get(sd, &cnt, &avg, &dev);
  assert(cnt == 3);
  assert(avg == 2.0);
  assert(abs(dev - 0.18) < 0.001);
  stddev_remove(sd, 3);
  stddev_get(sd, &cnt, &avg, &dev);
  assert(cnt == 2);
  assert(avg == 1.5);
  assert(dev == 0.5);
  stddev_remove(sd, 2);
  stddev_get(sd, NULL, &avg, &dev);
  assert(avg == 1);
  assert(dev == 0.0);
  stddev_get(sd, NULL, NULL, &dev);
  assert(dev == 0.0);
  stddev_get(sd, NULL, NULL, NULL);
  stddev_remove(sd, 1);
  stddev_get(sd, NULL, &avg, NULL);
  assert(avg == 0.0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <stddev_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1050 <stddev_add@plt>
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1050 <stddev_add@plt>
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1050 <stddev_add@plt>
mov    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <stddev_get@plt>
cmpl   $0x3,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe26(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <abs@plt>
movaps %xmm0,%xmm1
movsd  0xe0a(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1080 <stddev_remove@plt>
mov    -0x20(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <stddev_get@plt>
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xdb0(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xd85(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
mov    $0x2,%esi
call   1080 <stddev_remove@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <stddev_get@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xd37(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x18(%rbp),%rcx
mov    %rdx,%rsi
call   1040 <stddev_get@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rsi
mov    %rcx,%rdx
call   1040 <stddev_get@plt>
mov    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1080 <stddev_remove@plt>
mov    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%rdx
mov    %rcx,%rsi
call   1040 <stddev_get@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1070 <stddev_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1050 <stddev_add@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <stddev_add@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1050 <stddev_add@plt>
lea    0x4(%rsp),%r12
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <stddev_get@plt>
xor    %edi,%edi
cmpl   $0x3,0x4(%rsp)
sete   %dil
call   1060 <assert@plt>
movsd  0xe2c(%rip),%xmm0
cmpeqsd 0x10(%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xe12(%rip),%xmm0
call   1030 <abs@plt>
movsd  0xe0d(%rip),%xmm1
xor    %edi,%edi
ucomisd %xmm0,%xmm1
seta   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1080 <stddev_remove@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <stddev_get@plt>
xor    %edi,%edi
cmpl   $0x2,0x4(%rsp)
sete   %dil
call   1060 <assert@plt>
movsd  0xdd0(%rip),%xmm0
cmpeqsd 0x10(%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
movsd  0xdbc(%rip),%xmm0
cmpeqsd 0x8(%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1080 <stddev_remove@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1040 <stddev_get@plt>
movsd  0xd8b(%rip),%xmm0
cmpeqsd 0x10(%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
cmpeqsd %xmm1,%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %r15,%rcx
call   1040 <stddev_get@plt>
movsd  0x8(%rsp),%xmm0
cmpeqsd 0xd45(%rip),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <stddev_get@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1080 <stddev_remove@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <stddev_get@plt>
xorpd  %xmm0,%xmm0
cmpeqsd 0x10(%rsp),%xmm0
movq   %xmm0,%rdi
and    $0x1,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stddev = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca %struct.stddev*
store i32 0, i32* %1
%6 = call %struct.stddev* (...) @stddev_new()
store %struct.stddev* %6, %struct.stddev** %5
%7 = load %struct.stddev*, %struct.stddev** %5
%8 = call i32 @stddev_add(%struct.stddev* %7, i32 1)
%9 = load %struct.stddev*, %struct.stddev** %5
%10 = call i32 @stddev_add(%struct.stddev* %9, i32 2)
%11 = load %struct.stddev*, %struct.stddev** %5
%12 = call i32 @stddev_add(%struct.stddev* %11, i32 3)
%13 = load %struct.stddev*, %struct.stddev** %5
%14 = call i32 @stddev_get(%struct.stddev* %13, i32* %2, double* %3, double* %4)
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 3
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load double, double* %3
%20 = fcmp oeq double %19, 2.000000e+00
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load double, double* %4
%24 = fsub double %23, 1.800000e-01
%25 = call double @abs(double %24)
%26 = fcmp olt double %25, 1.000000e-03
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load %struct.stddev*, %struct.stddev** %5
%30 = call i32 @stddev_remove(%struct.stddev* %29, i32 3)
%31 = load %struct.stddev*, %struct.stddev** %5
%32 = call i32 @stddev_get(%struct.stddev* %31, i32* %2, double* %3, double* %4)
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 2
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load double, double* %3
%38 = fcmp oeq double %37, 1.500000e+00
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = load double, double* %4
%42 = fcmp oeq double %41, 5.000000e-01
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load %struct.stddev*, %struct.stddev** %5
%46 = call i32 @stddev_remove(%struct.stddev* %45, i32 2)
%47 = load %struct.stddev*, %struct.stddev** %5
%48 = call i32 @stddev_get(%struct.stddev* %47, i32* null, double* %3, double* %4)
%49 = load double, double* %3
%50 = fcmp oeq double %49, 1.000000e+00
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load double, double* %4
%54 = fcmp oeq double %53, 0.000000e+00
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load %struct.stddev*, %struct.stddev** %5
%58 = call i32 @stddev_get(%struct.stddev* %57, i32* null, double* null, double* %4)
%59 = load double, double* %4
%60 = fcmp oeq double %59, 0.000000e+00
%61 = zext i1 %60 to i32
%62 = call i32 @assert(i32 %61)
%63 = load %struct.stddev*, %struct.stddev** %5
%64 = call i32 @stddev_get(%struct.stddev* %63, i32* null, double* null, double* null)
%65 = load %struct.stddev*, %struct.stddev** %5
%66 = call i32 @stddev_remove(%struct.stddev* %65, i32 1)
%67 = load %struct.stddev*, %struct.stddev** %5
%68 = call i32 @stddev_get(%struct.stddev* %67, i32* null, double* %3, double* null)
%69 = load double, double* %3
%70 = fcmp oeq double %69, 0.000000e+00
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
ret i32 0
}

LLVM IR (-O2):
%struct.stddev = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call %struct.stddev* (...) @stddev_new()
%8 = tail call i32 @stddev_add(%struct.stddev* %7, i32 1)
%9 = tail call i32 @stddev_add(%struct.stddev* %7, i32 2)
%10 = tail call i32 @stddev_add(%struct.stddev* %7, i32 3)
%11 = call i32 @stddev_get(%struct.stddev* %7, i32* %1, double* %2, double* %3)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 3
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load double, double* %2
%17 = fcmp oeq double %16, 2.000000e+00
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load double, double* %3
%21 = fadd double %20, -1.800000e-01
%22 = call double @abs(double %21)
%23 = fcmp olt double %22, 1.000000e-03
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @stddev_remove(%struct.stddev* %7, i32 3)
%27 = call i32 @stddev_get(%struct.stddev* %7, i32* %1, double* %2, double* %3)
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, 2
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load double, double* %2
%33 = fcmp oeq double %32, 1.500000e+00
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load double, double* %3
%37 = fcmp oeq double %36, 5.000000e-01
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 @stddev_remove(%struct.stddev* %7, i32 2)
%41 = call i32 @stddev_get(%struct.stddev* %7, i32* null, double* %2, double* %3)
%42 = load double, double* %2
%43 = fcmp oeq double %42, 1.000000e+00
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
%46 = load double, double* %3
%47 = fcmp oeq double %46, 0.000000e+00
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = call i32 @stddev_get(%struct.stddev* %7, i32* null, double* null, double* %3)
%51 = load double, double* %3
%52 = fcmp oeq double %51, 0.000000e+00
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32 @stddev_get(%struct.stddev* %7, i32* null, double* null, double* null)
%56 = call i32 @stddev_remove(%struct.stddev* %7, i32 1)
%57 = call i32 @stddev_get(%struct.stddev* %7, i32* null, double* %2, double* null)
%58 = load double, double* %2
%59 = fcmp oeq double %58, 0.000000e+00
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
ret i32 0
}