user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<cpu_percentages>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rsi
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  movslq %eax,%rdx
  mov    %rdx,%r8
  mov    $0x0,%r9d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L58:
  cmp    %rdx,%rsp
  je     L136
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L58
L136:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L0
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L0:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L119
L62:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jae    L29
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  mov    %ecx,(%rax,%rdx,4)
  jmp    L60
L29:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    -0x10(%rbp),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  mov    %ecx,(%rax,%rdx,4)
L60:
  mov    -0x10(%rbp),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  add    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x20(%rbp)
L119:
  mov    -0x20(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L62
  cmpl   $0x0,-0x1c(%rbp)
  jne    L92
  movl   $0x1,-0x1c(%rbp)
L92:
  movl   $0x0,-0x20(%rbp)
  jmp    L54
L77:
  mov    -0x10(%rbp),%rax
  mov    -0x20(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  mov    %eax,%eax
  test   %rax,%rax
  js     L105
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  jmp    L100
L105:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rdx,%xmm0
  addsd  %xmm0,%xmm0
L100:
  mov    -0x1c(%rbp),%eax
  test   %rax,%rax
  js     L4
  pxor   %xmm1,%xmm1
  cvtsi2sd %rax,%xmm1
  jmp    L81
L4:
  mov    %rax,%rdx
  shr    %rdx
  and    $0x1,%eax
  or     %rax,%rdx
  pxor   %xmm1,%xmm1
  cvtsi2sd %rdx,%xmm1
  addsd  %xmm1,%xmm1
L81:
  movapd %xmm0,%xmm2
  divsd  %xmm1,%xmm2
  movsd  D2(%rip),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  cvttsd2si %xmm0,%rdx
  mov    %edx,(%rax)
  addl   $0x1,-0x20(%rbp)
L54:
  mov    -0x20(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L77
  mov    -0x1c(%rbp),%eax
  mov    %rsi,%rsp
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L122
  call   <__stack_chk_fail@plt>
L122:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D2
type_infered: byte[8]

tool: {"D2": [0x00,0x00,0x00,0x00,0x00,0x40,0x8f,0x40]}

assistant: ```c
unsigned int cpu_percentages(int cnt, unsigned int *percent, unsigned int *new, unsigned int *old) {
  int i;
  unsigned int diff[cnt];
  unsigned int total;
  total = 0;
  for (i = 0; i < cnt; i++) {
    if (new[i] < old[i]) {
      diff[i] = old[i] - new[i];
    } else {
      diff[i] = new[i] - old[i];
    }
    total += diff[i];
    old[i] = new[i];
  }
  if (0 == total) {
    total = 1;
  }
  for (i = 0; i < cnt; i++) {
    percent[i] = (unsigned)((double)diff[i] / total * 1000);
  }
  return total;
}
```