user: Demonstrate the C code that generates the assembly output below:

```asm
<resample_post_theta>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %rdx,-0x30(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %r9,-0x48(%rbp)
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L36
L88:
  movl   $0x1,-0xc(%rbp)
  jmp    L108
L58:
  mov    -0xc(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0xc(%rbp)
L108:
  mov    -0xc(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jle    L58
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x28(%rbp),%xmm1
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  movl   $0x1,-0x14(%rbp)
  jmp    L28
L8:
  movl   $0x1,-0x10(%rbp)
  jmp    L48
L66:
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x28(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  D5(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x3,%rax
  sub    $0x8,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x3,%rax
  sub    $0x8,%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  D5(%rip),%xmm0
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x10(%rbp)
L48:
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x2,%rax
  sub    $0x4,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x10(%rbp)
  jle    L66
  addl   $0x1,-0x14(%rbp)
L28:
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x14(%rbp)
  jle    L8
  cmpq   $0x0,0x10(%rbp)
  je     L10
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    $0xffffffff,%eax
  jne    L56
L10:
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x28(%rbp),%edx
  mov    -0x8(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sample_Delta@plt>
  jmp    L39
L56:
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x28(%rbp),%edx
  mov    -0x8(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <add_dst@plt>
L39:
  addl   $0x1,-0x18(%rbp)
L36:
  mov    -0x18(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L88
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: label: D5
type: f64

tool: D5: 1

assistant: ```c
void resample_post_theta(int D, int K, int **M, int *N, double **post_theta, double **post_theta_train, int *entity_map, int ***z) {
  int d_9;
  double *tmpSP7;
  int n_3;
  int m_75;
  int dvv_loop_var_1;
  tmpSP7 = (double *)malloc(sizeof(double) * (1 + ((K) + (1)) - (1)));
  for (d_9 = 1; d_9 <= D; d_9++) {
    for (dvv_loop_var_1 = 1; dvv_loop_var_1 <= K; dvv_loop_var_1++) {
      tmpSP7[dvv_loop_var_1 - 1] = 0.0;
    }
    tmpSP7[(K) + (1) - 1] = (0.0) * (((1) + (K)) - (1));
    for (n_3 = 1; n_3 <= N[d_9 - 1]; n_3++) {
      for (m_75 = 1; m_75 <= M[d_9 - 1][n_3 - 1]; m_75++) {
        tmpSP7[(K) + (1) - 1] += 1.0;
        tmpSP7[z[d_9 - 1][n_3 - 1][m_75 - 1] - 1] += 1.0;
      }
    }
    if ((entity_map == NULL) || (entity_map[d_9 - 1] == -1)) {
      sample_Delta(post_theta[d_9 - 1], tmpSP7, K);
    } else {
      add_dst(post_theta_train[entity_map[d_9 - 1]], tmpSP7, K);
    }
  }
  free(tmpSP7);
}
```