// File: /workspace/github_c_makefile_star2_O0/albinoloverats[P]hide/common/src/cli.c
// Function: cli_calc_bps
extern double cli_calc_bps(cli_bps_s *bps)
{
	CLI_DO_INIT;

	cli_bps_s *copy = m_calloc(BPS, sizeof( cli_bps_s ));
	for (int i = 0; i < BPS; i++)
	{
		copy[i].time  = bps[i].time;
		copy[i].bytes = bps[i].bytes;
	}
	qsort(copy, BPS, sizeof( cli_bps_s ), cli_bps_sort);
	double avg[BPS - 1] = { 0.0f };
	for (int i = 0; i < BPS - 1; i++)
		/*
		 * requires scale factor of MILLION as time is in microseconds
		 * not seconds (millions of bytes / micros of seconds, so to
		 * speak)
		 */
		avg[i] = MILLION * (double)(copy[i + 1].bytes - copy[i].bytes) / (double)(copy[i + 1].time - copy[i].time);
	double val = 0.0;
	for (int i = 0; i < BPS - 1; i++)
		val += avg[i];
	free(copy);
	return val /= (BPS - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x8(%rbp)
cmpl $0x1, 0x3962(%rip)      # 0x81e8
je 0x488d
callq 0x4200
leaq 0x1ae1(%rip), %rdi      # 0x6375
movl $0xbd, %esi
leaq 0x1ae6(%rip), %rdx      # 0x6386
movl $0x80, %ecx
movl $0x10, %r8d
callq 0x5560
movq %rax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x80, -0x14(%rbp)
jge 0x4919
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movslq -0x14(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x48bb
movq -0x10(%rbp), %rdi
movl $0x80, %esi
movl $0x10, %edx
leaq 0x152(%rip), %rcx       # 0x4a80
callq 0x20b0
leaq -0x410(%rbp), %rdi
xorl %esi, %esi
movl $0x3f8, %edx            # imm = 0x3F8
callq 0x2170
movl $0x0, -0x414(%rbp)
cmpl $0x7f, -0x414(%rbp)
jge 0x49f8
movq -0x10(%rbp), %rax
movslq -0x414(%rbp), %rdx
shlq $0x4, %rdx
movq 0x18(%rax,%rdx), %rsi
movq (%rax,%rdx), %rcx
movq 0x8(%rax,%rdx), %rdi
subq %rdi, %rsi
movq %rsi, %xmm0
movaps 0x19a7(%rip), %xmm3     # 0x6330
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
movapd 0x19ab(%rip), %xmm2     # 0x6340
subpd %xmm2, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x191c(%rip), %xmm1     # 0x62c8
mulsd %xmm1, %xmm0
movq 0x10(%rax,%rdx), %rax
subq %rcx, %rax
movq %rax, %xmm1
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
movslq -0x414(%rbp), %rax
movsd %xmm0, -0x410(%rbp,%rax,8)
movl -0x414(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x414(%rbp)
jmp 0x4950
xorps %xmm0, %xmm0
movsd %xmm0, -0x420(%rbp)
movl $0x0, -0x424(%rbp)
cmpl $0x7f, -0x424(%rbp)
jge 0x4a47
movslq -0x424(%rbp), %rax
movsd -0x410(%rbp,%rax,8), %xmm0
addsd -0x420(%rbp), %xmm0
movsd %xmm0, -0x420(%rbp)
movl -0x424(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x424(%rbp)
jmp 0x4a0d
movq -0x10(%rbp), %rdi
callq 0x2050
movsd -0x420(%rbp), %xmm0
movsd 0x1860(%rip), %xmm1     # 0x62c0
divsd %xmm1, %xmm0
movsd %xmm0, -0x420(%rbp)
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
nopw %cs:(%rax,%rax)