// File: acherkaoui[P]HTOP/modules/CPU.cpp
// Function: ReadStatsCpu(std::vector<CPUData_s, std::allocator<CPUData_s>>&)
void ReadStatsCpu(std::vector<CPUData> &stat)
{
	std::ifstream fileStat("/proc/stat");
	std::string line;

	const std::string STR_CPU("cpu");
	const std::size_t LEN_STR_CPU = STR_CPU.size();
	const std::string STR_TOT("tot");

	while(std::getline(fileStat, line)) {
		if(!line.compare(0, LEN_STR_CPU, STR_CPU)) {
			std::istringstream stringstream(line);

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

			stringstream >> entry.cpu;
			if (entry.cpu.size() > LEN_STR_CPU)
				entry.cpu.erase(0, LEN_STR_CPU);
			else
				entry.cpu = STR_TOT;
			for (int i = 0; i < NUM_CPU_STATES; ++i)
				stringstream >> entry.times[i];
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4d0, %rsp            # imm = 0x4D0
movq %rdi, -0x8(%rbp)
leaq 0x838a(%rip), %rsi      # 0x14200
leaq -0x210(%rbp), %rdi
movl $0x8, %edx
callq 0x4720
leaq -0x230(%rbp), %rdi
callq 0x45b0
leaq -0x251(%rbp), %rdi
movq %rdi, -0x4a8(%rbp)
callq 0x4700
movq -0x4a8(%rbp), %rdx
leaq 0x8a5b(%rip), %rsi      # 0x1490f
leaq -0x250(%rbp), %rdi
callq 0x45a0
jmp 0xbec2
leaq -0x251(%rbp), %rdi
callq 0x44a0
leaq -0x250(%rbp), %rdi
callq 0x42e0
movq %rax, -0x270(%rbp)
leaq -0x291(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
callq 0x4700
movq -0x4b0(%rbp), %rdx
leaq 0x8309(%rip), %rsi      # 0x1420b
leaq -0x290(%rbp), %rdi
callq 0x45a0
jmp 0xbf10
leaq -0x291(%rbp), %rdi
callq 0x44a0
leaq -0x210(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x40e0
movq %rax, -0x4b8(%rbp)
jmp 0xbf38
movq -0x4b8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4530
movb %al, -0x4b9(%rbp)
jmp 0xbf56
movb -0x4b9(%rbp), %al
testb $0x1, %al
jne 0xbf65
jmp 0xc1a1
movq -0x270(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
leaq -0x230(%rbp), %rdi
leaq -0x250(%rbp), %rcx
callq 0x4570
movl %eax, -0x4c0(%rbp)
jmp 0xbf8b
movl -0x4c0(%rbp), %eax
cmpl $0x0, %eax
jne 0xc19c
leaq -0x418(%rbp), %rdi
leaq -0x230(%rbp), %rsi
movl $0x8, %edx
callq 0x4690
jmp 0xbfb4
movq -0x8(%rbp), %rax
movq %rax, -0x4d0(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x430(%rbp)
movaps %xmm0, -0x440(%rbp)
movaps %xmm0, -0x450(%rbp)
movaps %xmm0, -0x460(%rbp)
movaps %xmm0, -0x470(%rbp)
movaps %xmm0, -0x480(%rbp)
movaps %xmm0, -0x490(%rbp)
movq $0x0, -0x420(%rbp)
leaq -0x490(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
callq 0xc900
movq -0x4d0(%rbp), %rdi
movq -0x4c8(%rbp), %rsi
callq 0xc890
jmp 0xc026
leaq -0x490(%rbp), %rdi
callq 0xc920
movq -0x8(%rbp), %rdi
callq 0xc940
movq %rax, -0x498(%rbp)
movq -0x498(%rbp), %rsi
leaq -0x418(%rbp), %rdi
callq 0x4540
jmp 0xc057
movq -0x498(%rbp), %rdi
callq 0x42e0
cmpq -0x270(%rbp), %rax
jbe 0xc122
movq -0x498(%rbp), %rdi
movq -0x270(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x4100
jmp 0xc089
jmp 0xc139
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x251(%rbp), %rdi
callq 0x44a0
jmp 0xc1f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x291(%rbp), %rdi
callq 0x44a0
jmp 0xc1e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0xc1da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x490(%rbp), %rdi
callq 0xc920
jmp 0xc18e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0xc18e
movq -0x498(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x4050
jmp 0xc137
jmp 0xc139
movl $0x0, -0x49c(%rbp)
cmpl $0xa, -0x49c(%rbp)
jge 0xc180
movq -0x498(%rbp), %rax
movslq -0x49c(%rbp), %rcx
leaq 0x20(%rax,%rcx,8), %rsi
leaq -0x418(%rbp), %rdi
callq 0x45d0
jmp 0xc16d
jmp 0xc16f
movl -0x49c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x49c(%rbp)
jmp 0xc143
leaq -0x418(%rbp), %rdi
callq 0x4240
jmp 0xc19c
leaq -0x418(%rbp), %rdi
callq 0x4240
jmp 0xc1da
jmp 0xbf1c
leaq -0x290(%rbp), %rdi
callq 0x42a0
leaq -0x250(%rbp), %rdi
callq 0x42a0
leaq -0x230(%rbp), %rdi
callq 0x42a0
leaq -0x210(%rbp), %rdi
callq 0x4130
addq $0x4d0, %rsp            # imm = 0x4D0
popq %rbp
retq
leaq -0x290(%rbp), %rdi
callq 0x42a0
leaq -0x250(%rbp), %rdi
callq 0x42a0
leaq -0x230(%rbp), %rdi
callq 0x42a0
leaq -0x210(%rbp), %rdi
callq 0x4130
movq -0x260(%rbp), %rdi
callq 0x46f0
nopw %cs:(%rax,%rax)