// File: acherkaoui[P]HTOP/modules/CPU.cpp
// Function: Cpu::getStats()
std::vector<CPUData> Cpu::getStats()
{
	std::vector<CPUData> stat1;
	std::vector<CPUData> stat2;
	std::vector<CPUData> cpu;

	this->updateCpu(stat1, stat2);
	const size_t NUM_STAT = stat1.size();

	for(size_t i = 0; i < NUM_STAT; ++i) {
		const float ACTIVE_TIME	= static_cast<float>(
			GetActiveTime(stat2[i]) -
				GetActiveTime(stat1[i]));
		const float IDLE_TIME	= static_cast<float>(
			GetIdleTime(stat2[i]) - GetIdleTime(stat1[i]));
		const float TOTAL_TIME	= ACTIVE_TIME + IDLE_TIME;

		cpu.emplace_back(CPUData());
		CPUData &entry = cpu.back();

		entry.cpu = stat1[i].cpu;
		entry.active = 100.f * ACTIVE_TIME / TOTAL_TIME;
		entry.idle = 100.f * IDLE_TIME / TOTAL_TIME;
	}
	return (cpu);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x118(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x28(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0xca50
leaq -0x40(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0xca50
movq -0x118(%rbp), %rdi
movb $0x0, -0x41(%rbp)
callq 0xca50
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x100(%rbp), %rdx
callq 0xc220
jmp 0xc2eb
leaq -0x28(%rbp), %rdi
callq 0xca70
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x60(%rbp), %rax
jae 0xc56d
movq -0x68(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xcaa0
movq %rax, %rdi
callq 0xc5d0
movq %rax, -0x128(%rbp)
jmp 0xc32c
movq -0x68(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xcaa0
movq %rax, %rdi
callq 0xc5d0
movq %rax, -0x130(%rbp)
jmp 0xc34a
movq -0x130(%rbp), %rcx
movq -0x128(%rbp), %rax
subq %rcx, %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x138(%rbp)
testq %rax, %rax
movss %xmm0, -0x134(%rbp)
js 0xc39c
movss -0x138(%rbp), %xmm0
movss %xmm0, -0x134(%rbp)
movss -0x134(%rbp), %xmm0
movss %xmm0, -0x6c(%rbp)
movq -0x68(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xcaa0
movq %rax, %rdi
callq 0xc620
movq %rax, -0x140(%rbp)
jmp 0xc3c7
movq -0x68(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xcaa0
movq %rax, %rdi
callq 0xc620
movq %rax, -0x148(%rbp)
jmp 0xc3e5
movq -0x148(%rbp), %rcx
movq -0x140(%rbp), %rax
subq %rcx, %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x150(%rbp)
testq %rax, %rax
movss %xmm0, -0x14c(%rbp)
js 0xc437
movss -0x150(%rbp), %xmm0
movss %xmm0, -0x14c(%rbp)
movss -0x14c(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x6c(%rbp), %xmm0
movss -0x70(%rbp), %xmm1
addss %xmm1, %xmm0
movss %xmm0, -0x74(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps %xmm0, -0xf0(%rbp)
movq $0x0, -0x80(%rbp)
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0xc900
movq -0x118(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0xc890
jmp 0xc4bb
leaq -0xf0(%rbp), %rdi
callq 0xc920
movq -0x118(%rbp), %rdi
callq 0xc940
movq %rax, -0xf8(%rbp)
movq -0x68(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xcaa0
movq %rax, %rsi
movq -0xf8(%rbp), %rdi
callq 0x4050
jmp 0xc4f8
movss 0x7cf8(%rip), %xmm0     # 0x141f8
mulss -0x6c(%rbp), %xmm0
divss -0x74(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movss %xmm0, 0x70(%rax)
movss 0x7cda(%rip), %xmm0     # 0x141f8
mulss -0x70(%rbp), %xmm0
divss -0x74(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movss %xmm0, 0x74(%rax)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0xc300
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0xc5a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0xc920
jmp 0xc5a5
movb $0x1, -0x41(%rbp)
testb $0x1, -0x41(%rbp)
jne 0xc583
movq -0x118(%rbp), %rdi
callq 0xcac0
leaq -0x40(%rbp), %rdi
callq 0xcac0
leaq -0x28(%rbp), %rdi
callq 0xcac0
movq -0x120(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x118(%rbp), %rdi
callq 0xcac0
leaq -0x40(%rbp), %rdi
callq 0xcac0
leaq -0x28(%rbp), %rdi
callq 0xcac0
movq -0x50(%rbp), %rdi
callq 0x46f0
nopl (%rax)