// File: ashlall[P]StreamStats/Test/BasicStats_test.cpp
// Function: test_Average()
void test_Average()
{
  BasicStats a;
  a.insert(50);
  assert(a.Average()==50); //tests when there is only one number in the stream.       
        
  BasicStats b;
  for (int i=1;i<=100;i++) //tests for ascending number from 1 to 100. 
    b.insert(i);
  assert(b.Average()==50.5);
  
  BasicStats c; // tests with one million items in the stream in descending order 
  for (int i=1000000;i>=1;i--)
    c.insert(i);
  assert(c.Average()==500000.5);
  
  BasicStats d;
  double sum=0;
  int random_num;
  for(int i=0;i<100000;i++)
  {
     random_num=(rand()%1000+250);
     d.insert(random_num); //tests for a randomly generated stream
     sum=sum+random_num;
  }
   assert(d.Average()==sum/100000);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
leaq -0x28(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x11d0
movq -0xd8(%rbp), %rdi
movsd 0x1326(%rip), %xmm0     # 0x3040
callq 0x12d0
jmp 0x1d21
leaq -0x28(%rbp), %rdi
callq 0x1430
movsd 0x130e(%rip), %xmm1     # 0x3040
ucomisd %xmm1, %xmm0
jne 0x1d3c
jp 0x1d3c
jmp 0x1d6c
leaq 0x1408(%rip), %rdi      # 0x314b
leaq 0x1359(%rip), %rsi      # 0x30a3
movl $0x4b, %edx
leaq 0x1405(%rip), %rcx      # 0x315b
callq 0x1040
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1fdf
leaq -0x60(%rbp), %rdi
callq 0x11d0
jmp 0x1d77
movl $0x1, -0x64(%rbp)
cmpl $0x64, -0x64(%rbp)
jg 0x1db2
cvtsi2sdl -0x64(%rbp), %xmm0
leaq -0x60(%rbp), %rdi
callq 0x12d0
jmp 0x1d94
jmp 0x1d96
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x1d7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1fd6
leaq -0x60(%rbp), %rdi
callq 0x1430
movsd 0x1285(%rip), %xmm1     # 0x3048
ucomisd %xmm1, %xmm0
jne 0x1dcd
jp 0x1dcd
jmp 0x1dec
leaq 0x139b(%rip), %rdi      # 0x316f
leaq 0x12c8(%rip), %rsi      # 0x30a3
movl $0x50, %edx
leaq 0x1374(%rip), %rcx      # 0x315b
callq 0x1040
leaq -0x90(%rbp), %rdi
callq 0x11d0
jmp 0x1dfa
movl $0xf4240, -0x94(%rbp)   # imm = 0xF4240
cmpl $0x1, -0x94(%rbp)
jl 0x1e47
cvtsi2sdl -0x94(%rbp), %xmm0
leaq -0x90(%rbp), %rdi
callq 0x12d0
jmp 0x1e23
jmp 0x1e25
movl -0x94(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1e04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1fca
leaq -0x90(%rbp), %rdi
callq 0x1430
movsd 0x11f5(%rip), %xmm1     # 0x3050
ucomisd %xmm1, %xmm0
jne 0x1e65
jp 0x1e65
jmp 0x1e84
leaq 0x1315(%rip), %rdi      # 0x3181
leaq 0x1230(%rip), %rsi      # 0x30a3
movl $0x55, %edx
leaq 0x12dc(%rip), %rcx      # 0x315b
callq 0x1040
leaq -0xc0(%rbp), %rdi
callq 0x11d0
jmp 0x1e92
xorps %xmm0, %xmm0
movsd %xmm0, -0xc8(%rbp)
movl $0x0, -0xd0(%rbp)
cmpl $0x186a0, -0xd0(%rbp)   # imm = 0x186A0
jge 0x1f4e
callq 0x1030
movl %eax, %ecx
movslq %ecx, %rax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x26, %rax
addl %edx, %eax
imull $0x3e8, %eax, %edx      # imm = 0x3E8
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0xfa(%rax,%rcx), %eax
movl %eax, -0xcc(%rbp)
cvtsi2sdl -0xcc(%rbp), %xmm0
leaq -0xc0(%rbp), %rdi
callq 0x12d0
jmp 0x1f04
movsd -0xc8(%rbp), %xmm0
cvtsi2sdl -0xcc(%rbp), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movl -0xd0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd0(%rbp)
jmp 0x1ea7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x22f0
jmp 0x1fca
leaq -0xc0(%rbp), %rdi
callq 0x1430
movsd -0xc8(%rbp), %xmm1
movsd 0x10ee(%rip), %xmm2     # 0x3058
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1f78
jp 0x1f78
jmp 0x1f97
leaq 0x1218(%rip), %rdi      # 0x3197
leaq 0x111d(%rip), %rsi      # 0x30a3
movl $0x60, %edx
leaq 0x11c9(%rip), %rcx      # 0x315b
callq 0x1040
leaq -0xc0(%rbp), %rdi
callq 0x22f0
leaq -0x90(%rbp), %rdi
callq 0x22f0
leaq -0x60(%rbp), %rdi
callq 0x22f0
leaq -0x28(%rbp), %rdi
callq 0x22f0
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x90(%rbp), %rdi
callq 0x22f0
leaq -0x60(%rbp), %rdi
callq 0x22f0
leaq -0x28(%rbp), %rdi
callq 0x22f0
movq -0x30(%rbp), %rdi
callq 0x1080
nopw %cs:(%rax,%rax)