// File: ef-gy[P]libefgy/src/test-case/statistics.cpp
// Function: testStatistics(std::ostream&)
bool testStatistics(std::ostream &log) {
  std::vector<int> v;
  std::optional<int> avg = average<int>(v);
  if (avg) {
    log << "average of an empty set is not defined";
    return false;
  }

  std::vector<int> v2{1, 3, -10};

  std::optional<int> avg2 = average<int>(v2);
  if ((*avg2) != -2) {
    log << "average of {1, 3, -10} expected to be -2";
    return false;
  }

  std::vector<int> v3{-10, 1, 3};
  std::optional<int> avg3 = average<int>(v3);
  if ((*avg2) != (*avg3)) {
    log << "averages of {1, 3, -10} and {-10, 1, 3} expected to be equal";
    return false;
  }

  std::vector<double> v4;
  auto var0 = variance<double>(v4);
  if (var0) {
    log << "variance of an empty list is not defined.";
    return false;
  }

  std::vector<double> v5 = {1, 1, 1, 1};
  auto var1 = variance<double>(v5.begin(), v5.end());
  if (*var1 != 0.0) {
    log << "variance of equal values (1) differs from zero.\n";
    return false;
  }

  std::vector<double> v6 = {1, 2, 3, 4};
  auto var2 = variance<double>(v6.begin(), v6.end());

  if (fabs(*var2 - 1.25) >= 1e-14) {
    log << "variance of descending values (1...4) differs from expected "
           "value.\n";
    return false;
  }

  std::vector<double> v7 = {1, 2, 3, 4};
  auto var3 = variance(v7);

  if (fabs(*var3 - 1.25) >= 1e-14) {
    log << "variance of a vector (1...4) without iterators differs from "
           "expected value.\n";
    return false;
  }

  std::vector<double> v1111{0.0, 2.0, 4.0};

  std::vector<double> v8_measurement;
  std::vector<double> v8;
  auto chi0 = chi_square(v8, v8_measurement);
  if (chi0) {
    log << "chi_square of no measurements is not defined\n";
    return false;
  }

  std::vector<double> v10_measurement{0.0, 2.0, 4.0};
  std::vector<double> v10{0.0, 1.0, 2.0};
  auto chi2 = chi_square(v10, v10_measurement);
  if (fabs(*chi2 - (45.0 / 64.0)) > 1e-14) {
    log << "chi_square of descending values is not the expected value\n";
    return false;
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x75a0
movq -0x3d8(%rbp), %rdi
callq 0x67e0
movq %rax, -0x3d0(%rbp)
jmp 0x5bd4
movq -0x3d0(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x75c0
testb $0x1, %al
jne 0x5bee
jmp 0x5c21
movq -0x10(%rbp), %rdi
leaq 0x306a1(%rip), %rsi     # 0x3629a
callq 0x5350
jmp 0x5c00
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x67af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x67c6
movl $0x1, -0x74(%rbp)
movl $0x3, -0x70(%rbp)
movl $0xfffffff6, -0x6c(%rbp) # imm = 0xFFFFFFF6
leaq -0x74(%rbp), %rax
movq %rax, -0x68(%rbp)
movq $0x3, -0x60(%rbp)
leaq -0x75(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x75e0
movq -0x3e0(%rbp), %rcx
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0x7600
jmp 0x5c70
leaq -0x75(%rbp), %rdi
callq 0x7680
leaq -0x58(%rbp), %rdi
callq 0x67e0
movq %rax, -0x3e8(%rbp)
jmp 0x5c8b
movq -0x3e8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x76a0
cmpl $-0x2, (%rax)
je 0x5cf1
movq -0x10(%rbp), %rdi
leaq 0x30612(%rip), %rsi     # 0x362c1
callq 0x5350
jmp 0x5cb6
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x6799
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x75(%rbp), %rdi
callq 0x7680
jmp 0x67c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x67a4
movl $0xfffffff6, -0xb4(%rbp) # imm = 0xFFFFFFF6
movl $0x1, -0xb0(%rbp)
movl $0x3, -0xac(%rbp)
leaq -0xb4(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq $0x3, -0xa0(%rbp)
leaq -0xb5(%rbp), %rdi
movq %rdi, -0x3f0(%rbp)
callq 0x75e0
movq -0x3f0(%rbp), %rcx
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x7600
jmp 0x5d5e
leaq -0xb5(%rbp), %rdi
callq 0x7680
leaq -0x98(%rbp), %rdi
callq 0x67e0
movq %rax, -0x3f8(%rbp)
jmp 0x5d7f
movq -0x3f8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x76a0
movl (%rax), %eax
movl %eax, -0x3fc(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x76a0
movq %rax, %rcx
movl -0x3fc(%rbp), %eax
cmpl (%rcx), %eax
je 0x5e07
movq -0x10(%rbp), %rdi
leaq 0x30528(%rip), %rsi     # 0x362ea
callq 0x5350
jmp 0x5dc9
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x677d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xb5(%rbp), %rdi
callq 0x7680
jmp 0x67a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x678b
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x418(%rbp)
callq 0x76c0
movq -0x418(%rbp), %rdi
callq 0x68a0
movb %al, -0x409(%rbp)
movsd %xmm0, -0x408(%rbp)
jmp 0x5e36
movb -0x409(%rbp), %al
movsd -0x408(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movb %al, -0xe0(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x76e0
testb $0x1, %al
jne 0x5e64
jmp 0x5e97
movq -0x10(%rbp), %rdi
leaq 0x304b8(%rip), %rsi     # 0x36327
callq 0x5350
jmp 0x5e76
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x6761
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x676f
movups 0x302c2(%rip), %xmm0    # 0x36160
movaps %xmm0, -0x120(%rbp)
movups 0x302a4(%rip), %xmm0    # 0x36150
movaps %xmm0, -0x130(%rbp)
leaq -0x130(%rbp), %rax
movq %rax, -0x110(%rbp)
movq $0x4, -0x108(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x7700
movq -0x420(%rbp), %rcx
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x7720
jmp 0x5f02
leaq -0x131(%rbp), %rdi
callq 0x77a0
leaq -0x100(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x77c0
movq -0x438(%rbp), %rdi
movq %rax, -0x150(%rbp)
callq 0x77f0
movq %rax, -0x158(%rbp)
movq -0x150(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x68f0
movb %al, -0x429(%rbp)
movsd %xmm0, -0x428(%rbp)
jmp 0x5f5e
movb -0x429(%rbp), %al
movsd -0x428(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movb %al, -0x140(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x7820
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x5f97
jp 0x5f97
jmp 0x5fe7
movq -0x10(%rbp), %rdi
leaq 0x303af(%rip), %rsi     # 0x36351
callq 0x5350
jmp 0x5fa9
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x6745
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x131(%rbp), %rdi
callq 0x77a0
jmp 0x676f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6753
movups 0x30192(%rip), %xmm0    # 0x36180
movaps %xmm0, -0x190(%rbp)
movups 0x30174(%rip), %xmm0    # 0x36170
movaps %xmm0, -0x1a0(%rbp)
leaq -0x1a0(%rbp), %rax
movq %rax, -0x180(%rbp)
movq $0x4, -0x178(%rbp)
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0x7700
movq -0x440(%rbp), %rcx
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
leaq -0x170(%rbp), %rdi
callq 0x7720
jmp 0x6052
leaq -0x1a1(%rbp), %rdi
callq 0x77a0
leaq -0x170(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x77c0
movq -0x458(%rbp), %rdi
movq %rax, -0x1c0(%rbp)
callq 0x77f0
movq %rax, -0x1c8(%rbp)
movq -0x1c0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x68f0
movb %al, -0x449(%rbp)
movsd %xmm0, -0x448(%rbp)
jmp 0x60ae
movb -0x449(%rbp), %al
movsd -0x448(%rbp), %xmm0
movsd %xmm0, -0x1b8(%rbp)
movb %al, -0x1b0(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x7820
movsd (%rax), %xmm0
movsd 0x2ff2e(%rip), %xmm1    # 0x36010
subsd %xmm1, %xmm0
movaps 0x2ff33(%rip), %xmm1    # 0x36020
pand %xmm1, %xmm0
movsd 0x2ff0f(%rip), %xmm1    # 0x36008
ucomisd %xmm1, %xmm0
jb 0x614f
movq -0x10(%rbp), %rdi
leaq 0x30278(%rip), %rsi     # 0x36382
callq 0x5350
jmp 0x6111
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x6729
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x1a1(%rbp), %rdi
callq 0x77a0
jmp 0x6753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6737
movups 0x3004a(%rip), %xmm0    # 0x361a0
movaps %xmm0, -0x200(%rbp)
movups 0x3002c(%rip), %xmm0    # 0x36190
movaps %xmm0, -0x210(%rbp)
leaq -0x210(%rbp), %rax
movq %rax, -0x1f0(%rbp)
movq $0x4, -0x1e8(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x7700
movq -0x460(%rbp), %rcx
movq -0x1f0(%rbp), %rsi
movq -0x1e8(%rbp), %rdx
leaq -0x1e0(%rbp), %rdi
callq 0x7720
jmp 0x61ba
leaq -0x211(%rbp), %rdi
callq 0x77a0
leaq -0x1e0(%rbp), %rdi
callq 0x68a0
movb %al, -0x469(%rbp)
movsd %xmm0, -0x468(%rbp)
jmp 0x61e2
movb -0x469(%rbp), %al
movsd -0x468(%rbp), %xmm0
movsd %xmm0, -0x228(%rbp)
movb %al, -0x220(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x7820
movsd (%rax), %xmm0
movsd 0x2fdfa(%rip), %xmm1    # 0x36010
subsd %xmm1, %xmm0
movaps 0x2fdff(%rip), %xmm1    # 0x36020
pand %xmm1, %xmm0
movsd 0x2fddb(%rip), %xmm1    # 0x36008
ucomisd %xmm1, %xmm0
jb 0x6283
movq -0x10(%rbp), %rdi
leaq 0x30188(%rip), %rsi     # 0x363c6
callq 0x5350
jmp 0x6245
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x670d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x211(%rbp), %rdi
callq 0x77a0
jmp 0x6737
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x671b
movups 0x2ff26(%rip), %xmm0    # 0x361b0
movaps %xmm0, -0x270(%rbp)
movabsq $0x4010000000000000, %rax # imm = 0x4010000000000000
movq %rax, -0x260(%rbp)
leaq -0x270(%rbp), %rax
movq %rax, -0x250(%rbp)
movq $0x3, -0x248(%rbp)
leaq -0x271(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x7700
movq -0x478(%rbp), %rcx
movq -0x250(%rbp), %rsi
movq -0x248(%rbp), %rdx
leaq -0x240(%rbp), %rdi
callq 0x7720
jmp 0x62f1
leaq -0x271(%rbp), %rdi
callq 0x77a0
leaq -0x290(%rbp), %rdi
callq 0x76c0
leaq -0x2a8(%rbp), %rdi
movq %rdi, -0x480(%rbp)
callq 0x76c0
movq -0x480(%rbp), %rsi
leaq -0x2d0(%rbp), %rdi
callq 0x7840
jmp 0x6331
leaq -0x2e8(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x7840
jmp 0x6346
leaq -0x2d0(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x69d0
movb %al, -0x489(%rbp)
movsd %xmm0, -0x488(%rbp)
jmp 0x6369
movb -0x489(%rbp), %al
movsd -0x488(%rbp), %xmm0
movsd %xmm0, -0x2b8(%rbp)
movb %al, -0x2b0(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x7930
leaq -0x2d0(%rbp), %rdi
callq 0x7930
leaq -0x2b8(%rbp), %rdi
callq 0x76e0
testb $0x1, %al
jne 0x63b2
jmp 0x6439
movq -0x10(%rbp), %rdi
leaq 0x30056(%rip), %rsi     # 0x36413
callq 0x5350
jmp 0x63c4
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x66c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x271(%rbp), %rdi
callq 0x77a0
jmp 0x671b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x66e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6428
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x7930
leaq -0x2d0(%rbp), %rdi
callq 0x7930
jmp 0x66e7
movups 0x2fd88(%rip), %xmm0    # 0x361c8
movaps %xmm0, -0x330(%rbp)
movabsq $0x4010000000000000, %rax # imm = 0x4010000000000000
movq %rax, -0x320(%rbp)
leaq -0x330(%rbp), %rax
movq %rax, -0x310(%rbp)
movq $0x3, -0x308(%rbp)
leaq -0x331(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x7700
movq -0x498(%rbp), %rcx
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rdx
leaq -0x300(%rbp), %rdi
callq 0x7720
jmp 0x64a7
leaq -0x331(%rbp), %rdi
callq 0x77a0
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, -0x370(%rbp)
movups 0x2fd15(%rip), %xmm0    # 0x361e0
movaps %xmm0, -0x380(%rbp)
leaq -0x380(%rbp), %rax
movq %rax, -0x360(%rbp)
movq $0x3, -0x358(%rbp)
leaq -0x381(%rbp), %rdi
movq %rdi, -0x4a0(%rbp)
callq 0x7700
movq -0x4a0(%rbp), %rcx
movq -0x360(%rbp), %rsi
movq -0x358(%rbp), %rdx
leaq -0x350(%rbp), %rdi
callq 0x7720
jmp 0x6521
leaq -0x381(%rbp), %rdi
callq 0x77a0
leaq -0x3b0(%rbp), %rdi
leaq -0x350(%rbp), %rsi
callq 0x7840
jmp 0x6542
leaq -0x3c8(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x7840
jmp 0x6557
leaq -0x3b0(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0x69d0
movb %al, -0x4a9(%rbp)
movsd %xmm0, -0x4a8(%rbp)
jmp 0x657a
movb -0x4a9(%rbp), %al
movsd -0x4a8(%rbp), %xmm0
movsd %xmm0, -0x398(%rbp)
movb %al, -0x390(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x7930
leaq -0x3b0(%rbp), %rdi
callq 0x7930
leaq -0x398(%rbp), %rdi
callq 0x7820
movsd (%rax), %xmm0
movsd 0x2fa52(%rip), %xmm1    # 0x36018
subsd %xmm1, %xmm0
movaps 0x2fa4f(%rip), %xmm1    # 0x36020
pand %xmm1, %xmm0
movsd 0x2fa2b(%rip), %xmm1    # 0x36008
ucomisd %xmm1, %xmm0
jbe 0x6682
movq -0x10(%rbp), %rdi
leaq 0x2fe4f(%rip), %rsi     # 0x36441
callq 0x5350
jmp 0x65f9
movb $0x0, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
jmp 0x668d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x331(%rbp), %rdi
callq 0x77a0
jmp 0x66e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x381(%rbp), %rdi
callq 0x77a0
jmp 0x66b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x66a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x6674
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x3c8(%rbp), %rdi
callq 0x7930
leaq -0x3b0(%rbp), %rdi
callq 0x7930
jmp 0x66a7
movb $0x1, -0x1(%rbp)
movl $0x1, -0x40(%rbp)
leaq -0x350(%rbp), %rdi
callq 0x7930
leaq -0x300(%rbp), %rdi
callq 0x7930
jmp 0x66c1
leaq -0x350(%rbp), %rdi
callq 0x7930
leaq -0x300(%rbp), %rdi
callq 0x7930
jmp 0x66e7
leaq -0x2a8(%rbp), %rdi
callq 0x7930
leaq -0x290(%rbp), %rdi
callq 0x7930
leaq -0x240(%rbp), %rdi
callq 0x7930
jmp 0x670d
leaq -0x2a8(%rbp), %rdi
callq 0x7930
leaq -0x290(%rbp), %rdi
callq 0x7930
leaq -0x240(%rbp), %rdi
callq 0x7930
jmp 0x671b
leaq -0x1e0(%rbp), %rdi
callq 0x7930
jmp 0x6729
leaq -0x1e0(%rbp), %rdi
callq 0x7930
jmp 0x6737
leaq -0x170(%rbp), %rdi
callq 0x7930
jmp 0x6745
leaq -0x170(%rbp), %rdi
callq 0x7930
jmp 0x6753
leaq -0x100(%rbp), %rdi
callq 0x7930
jmp 0x6761
leaq -0x100(%rbp), %rdi
callq 0x7930
jmp 0x676f
leaq -0xd8(%rbp), %rdi
callq 0x7930
jmp 0x677d
leaq -0xd8(%rbp), %rdi
callq 0x7930
jmp 0x678b
leaq -0x98(%rbp), %rdi
callq 0x7990
jmp 0x6799
leaq -0x98(%rbp), %rdi
callq 0x7990
jmp 0x67a4
leaq -0x58(%rbp), %rdi
callq 0x7990
jmp 0x67af
leaq -0x58(%rbp), %rdi
callq 0x7990
jmp 0x67c6
leaq -0x28(%rbp), %rdi
callq 0x7990
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x7990
movq -0x38(%rbp), %rdi
callq 0x55a0
nopl (%rax,%rax)