user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  lea    -0x58(%rbp),%rdx
  lea    -0x5c(%rbp),%rax
  mov    %rax,%rsi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    -0x5c(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x48(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L58:
  cmp    %rdx,%rsp
  je     L44
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L58
L44:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L5
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L5:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x40(%rbp)
  movl   $0x0,-0x54(%rbp)
  jmp    L52
L83:
  mov    -0x54(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rsi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  addl   $0x1,-0x54(%rbp)
L52:
  mov    -0x5c(%rbp),%eax
  cmp    %eax,-0x54(%rbp)
  jl     L83
  mov    -0x5c(%rbp),%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <ms@plt>
  mov    -0x5c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x54(%rbp)
  movl   $0x1,-0x50(%rbp)
  movl   $0x0,-0x4c(%rbp)
  jmp    L59
L47:
  mov    -0x40(%rbp),%rax
  mov    -0x54(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  imul   -0x50(%rbp),%eax
  add    %eax,-0x4c(%rbp)
  mov    -0x5c(%rbp),%eax
  sub    -0x54(%rbp),%eax
  mov    -0x58(%rbp),%ecx
  cltd
  idiv   %ecx
  mov    %edx,%eax
  test   %eax,%eax
  jne    L40
  addl   $0x1,-0x50(%rbp)
L40:
  subl   $0x1,-0x54(%rbp)
L59:
  cmpl   $0x0,-0x54(%rbp)
  jns    L47
  mov    -0x4c(%rbp),%eax
  mov    %eax,%esi
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  mov    %rbx,%rsp
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L1
  call   <__stack_chk_fail@plt>
L1:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

tool_calls: name: disassemble_data
arguments: label: D19
type: string
name: disassemble_data
arguments: label: D0
type: string
name: disassemble_data
arguments: label: D15
type: string

tool: D19: %d%d

tool: D0: %d

tool: D15: %d


assistant: ```c
int main() {
  int n, k, i, j, s;
  scanf("%d%d", &n, &k);
  int c[n];
  for (i = 0; i < n; ++i)
    scanf("%d", &c[i]);
  ms(c, n);
  for (i = n - 1, j = 1, s = 0; i >= 0; --i) {
    s += j * c[i];
    if ((n - i) % k == 0)
      j++;
  }
  printf("%d\n", s);
  return 0;
}
```