// File: sharmaeklavya2[P]ddos-on-anycast/src/simulate.cpp
// Function: print_stats(char const*, int, std::vector<double, std::allocator<double>>&, bool)
void print_stats(const char* name, int n_victims, vector<double>& xs, bool csvout) {
    std::sort(xs.begin(), xs.end());
    double xsum = 0;
    double xsum2 = 0;
    for(double x: xs) {
        xsum += x;
        xsum2 += x * x;
    }
    int n = xs.size();
    double mean = xsum / n;
    double variance = (xsum2 - xsum*xsum/n)/(n-1);
    double stddev = std::sqrt(variance);
    double q3 = xs[(3*n)/4];
    double q1 = xs[n/4];

    if(csvout) {
        printf("%d,%lg,%lg,%lg,%lg,%lg,%lg,%lg\n", n_victims, mean, xs.back(),
            xs[int(0.9*n)], q3, xs[n/2], stddev, q3-q1);
    }
    else {
        printf("%3d %11s: mean: %lf, max: %lf, 90p: %lf, 75p: %lf, 50p: %lf, stddev: %lf, iqd: %lf\n",
            n_victims, name, mean, xs.back(), xs[int(0.9*n)], q3, xs[n/2], stddev, q3 - q1);
    }
}

// Assembly:
subq $0xe8, %rsp
movb %cl, %al
movq %rdi, 0xe0(%rsp)
movl %esi, 0xdc(%rsp)
movq %rdx, 0xd0(%rsp)
andb $0x1, %al
movb %al, 0xcf(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x124c0
movq %rax, 0xc0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x12330
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0x22ed0
xorps %xmm0, %xmm0
movsd %xmm0, 0xb0(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x124c0
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x12330
movq %rax, 0x90(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x1a8a0
testb $0x1, %al
jne 0x21055
jmp 0x210c8
leaq 0x98(%rsp), %rdi
callq 0x1a8e0
movsd (%rax), %xmm0
movsd %xmm0, 0x88(%rsp)
movsd 0x88(%rsp), %xmm0
addsd 0xb0(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
movsd 0x88(%rsp), %xmm0
movsd 0x88(%rsp), %xmm2
movsd 0xa8(%rsp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xa8(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x1a8f0
jmp 0x2103a
movq 0xd0(%rsp), %rdi
callq 0x11de0
movl %eax, 0x84(%rsp)
movsd 0xb0(%rsp), %xmm0
cvtsi2sdl 0x84(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x78(%rsp)
movsd 0xa8(%rsp), %xmm0
movsd 0xb0(%rsp), %xmm1
mulsd 0xb0(%rsp), %xmm1
cvtsi2sdl 0x84(%rsp), %xmm2
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movl 0x84(%rsp), %eax
subl $0x1, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x70(%rsp)
movsd 0x70(%rsp), %xmm0
callq 0x2120
movsd %xmm0, 0x68(%rsp)
movq 0xd0(%rsp), %rdi
imull $0x3, 0x84(%rsp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
callq 0xd540
movsd (%rax), %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0xd0(%rsp), %rdi
movl 0x84(%rsp), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
callq 0xd540
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
testb $0x1, 0xcf(%rsp)
je 0x2127f
movl 0xdc(%rsp), %eax
movl %eax, 0x34(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x38(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x22f10
movsd (%rax), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0xd0(%rsp), %rdi
cvtsi2sdl 0x84(%rsp), %xmm1
movsd 0x84e3(%rip), %xmm0     # 0x296d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
callq 0xd540
movsd (%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0xd0(%rsp), %rdi
movl 0x84(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
callq 0xd540
movl 0x34(%rsp), %esi
movsd 0x38(%rsp), %xmm0
movsd 0x40(%rsp), %xmm1
movsd 0x48(%rsp), %xmm2
movsd 0x50(%rsp), %xmm3
movsd (%rax), %xmm4
movsd 0x68(%rsp), %xmm5
movsd 0x60(%rsp), %xmm6
subsd 0x58(%rsp), %xmm6
leaq 0x87db(%rip), %rdi      # 0x29a4e
movb $0x7, %al
callq 0x2040
jmp 0x2135d
movl 0xdc(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movsd 0x78(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x22f10
movsd (%rax), %xmm0
movsd %xmm0, 0x18(%rsp)
movq 0xd0(%rsp), %rdi
cvtsi2sdl 0x84(%rsp), %xmm1
movsd 0x8405(%rip), %xmm0     # 0x296d8
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movslq %eax, %rsi
callq 0xd540
movsd (%rax), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movq 0xd0(%rsp), %rdi
movl 0x84(%rsp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movslq %eax, %rsi
callq 0xd540
movl 0x4(%rsp), %esi
movq 0x8(%rsp), %rdx
movsd 0x10(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x28(%rsp), %xmm3
movsd (%rax), %xmm4
movsd 0x68(%rsp), %xmm5
movsd 0x60(%rsp), %xmm6
subsd 0x58(%rsp), %xmm6
leaq 0x8718(%rip), %rdi      # 0x29a6e
movb $0x7, %al
callq 0x2040
addq $0xe8, %rsp
retq
nopw %cs:(%rax,%rax)