user: 请从给定的汇编指令推导出C源代码:

```asm
<area_calc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L53
L107:
  subl   $0x1,-0x24(%rbp)
L65:
  cmpl   $0x0,-0x24(%rbp)
  jle    L33
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L107
L33:
  cmpl   $0x0,-0x24(%rbp)
  je     L123
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  jmp    L121
L123:
  mov    $0xffffffff,%eax
L121:
  mov    -0x28(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  mov    %eax,(%rdx)
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x28(%rbp)
L53:
  mov    -0x28(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L65
  movl   $0x0,-0x24(%rbp)
  mov    -0x3c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L18
L73:
  subl   $0x1,-0x24(%rbp)
L89:
  cmpl   $0x0,-0x24(%rbp)
  jle    L102
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L73
L102:
  cmpl   $0x0,-0x24(%rbp)
  je     L92
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  jmp    L138
L92:
  mov    -0x3c(%rbp),%eax
L138:
  mov    -0x28(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    %eax,(%rdx)
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x28(%rbp)
L18:
  cmpl   $0x0,-0x28(%rbp)
  jns    L89
  movl   $0x0,-0x20(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L1
L55:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x28(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%edx
  mov    -0x28(%rbp),%ecx
  movslq %ecx,%rcx
  lea    0x0(,%rcx,4),%rsi
  mov    -0x10(%rbp),%rcx
  add    %rsi,%rcx
  mov    (%rcx),%ecx
  sub    %ecx,%edx
  sub    $0x1,%edx
  imul   %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <max@plt>
  mov    %eax,-0x20(%rbp)
  addl   $0x1,-0x28(%rbp)
L1:
  mov    -0x28(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L55
  mov    -0x20(%rbp),%eax
  leave
  ret
```

assistant: ```c
int area_calc(int *heights, int size) {
  int *indexes = malloc(size * sizeof(int));
  int *lhist = malloc(size * sizeof(int));
  int *rhist = malloc(size * sizeof(int));
  int i, pos = 0;
  for (i = 0; i < size; i++) {
    while (pos > 0 && heights[indexes[pos - 1]] >= heights[i]) {
      pos--;
    }
    lhist[i] = pos == 0 ? -1 : indexes[pos - 1];
    indexes[pos++] = i;
  }
  pos = 0;
  for (i = size - 1; i >= 0; i--) {
    while (pos > 0 && heights[indexes[pos - 1]] >= heights[i]) {
      pos--;
    }
    rhist[i] = pos == 0 ? size : indexes[pos - 1];
    indexes[pos++] = i;
  }
  int max_area = 0;
  for (i = 0; i < size; i++) {
    int area = heights[i] * (rhist[i] - lhist[i] - 1);
    max_area = max(area, max_area);
  }
  return max_area;
}
```