user: Converte this assembly snippet into its equivalent C code:

```asm
<_dtram_estimate_transition_matrix>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x20(%rsp)
  mov    %rcx,0x38(%rsp)
  mov    %r8d,0x2c(%rsp)
  mov    %r9,0x48(%rsp)
  test   %r8d,%r8d
  jle    L12
  lea    0x1(%r8),%eax
  mov    %eax,0x64(%rsp)
  movslq %r8d,%rax
  lea    0x0(,%rax,4),%rsi
  mov    %rsi,0x68(%rsp)
  shl    $0x3,%rax
  mov    %rax,0x70(%rsp)
  lea    -0x1(%r8),%eax
  mov    %rax,0x78(%rsp)
  mov    %r8d,%eax
  mov    %rax,0x30(%rsp)
  mov    0xc0(%rsp),%rax
  mov    %rax,0x50(%rsp)
  movl   $0x0,0x58(%rsp)
  movl   $0x0,0x60(%rsp)
  mov    $0x0,%r15d
  mov    %rcx,%r14
  mov    %rdi,%r12
  jmp    L83
L106:
  mov    (%r14,%rbx,4),%eax
  movsd  D15(%rip),%xmm0
  test   %eax,%eax
  jne    L16
L156:
  mov    0x14(%rsp),%ecx
  movslq %ecx,%rax
  mov    0x48(%rsp),%rdi
  lea    (%rdi,%rax,8),%rax
  movsd  %xmm0,(%rax)
  subsd  (%r12,%r15,8),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x1,%ecx
  mov    %ecx,0x14(%rsp)
  call   <exp@plt>
  mov    0x8(%rsp),%rax
  movsd  %xmm0,(%rax)
L46:
  add    $0x1,%rbx
  add    $0x8,%rbp
  add    0x2c(%rsp),%r13d
  cmp    0x30(%rsp),%rbx
  je     L126
L176:
  mov    %rbp,0x8(%rsp)
  movq   $0x0,0x0(%rbp)
  cmp    %r15d,%ebx
  je     L106
  movslq %r13d,%rax
  mov    (%r14,%rbx,4),%edx
  mov    0x38(%rsp),%rcx
  add    (%rcx,%rax,4),%edx
  mov    %edx,0x28(%rsp)
  je     L46
  movsd  (%r12,%r15,8),%xmm1
  mov    0x20(%rsp),%rax
  subsd  (%rax,%rbx,8),%xmm1
  movsd  (%r12,%rbx,8),%xmm0
  subsd  (%rax,%r15,8),%xmm0
  mov    0x18(%rsp),%rsi
  subsd  (%rsi,%r15,8),%xmm0
  subsd  (%rsi,%rbx,8),%xmm1
  call   <_logsumexp_pair@plt>
  movsd  %xmm0,0x40(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl 0x28(%rsp),%xmm0
  call   <log@plt>
  mov    0x20(%rsp),%rax
  subsd  (%rax,%rbx,8),%xmm0
  mov    0x18(%rsp),%rsi
  subsd  (%rsi,%rbx,8),%xmm0
  subsd  0x40(%rsp),%xmm0
  mov    0x14(%rsp),%edi
  movslq %edi,%rax
  mov    0x48(%rsp),%rcx
  movsd  %xmm0,(%rcx,%rax,8)
  add    $0x1,%edi
  mov    %edi,0x14(%rsp)
  call   <exp@plt>
  mov    0x8(%rsp),%rax
  movsd  %xmm0,(%rax)
  jmp    L46
L16:
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  addsd  D7(%rip),%xmm0
  call   <log@plt>
  jmp    L156
L126:
  mov    0x14(%rsp),%esi
  mov    0x48(%rsp),%rdi
  call   <_logsumexp_sort_kahan_inplace@plt>
  call   <exp@plt>
  pxor   %xmm3,%xmm3
  ucomisd %xmm3,%xmm0
  jp     L84
  je     L130
L84:
  ucomisd D11(%rip),%xmm0
  jp     L121
  jne    L121
L166:
  add    $0x1,%r15
  mov    0x64(%rsp),%esi
  add    %esi,0x60(%rsp)
  mov    0x2c(%rsp),%edi
  add    %edi,0x58(%rsp)
  add    0x68(%rsp),%r14
  mov    0x70(%rsp),%rsi
  add    %rsi,0x50(%rsp)
  cmp    0x30(%rsp),%r15
  je     L12
L83:
  mov    0x58(%rsp),%eax
  mov    %eax,0x5c(%rsp)
  mov    %r15d,%r13d
  mov    0x50(%rsp),%rbp
  mov    $0x0,%ebx
  movl   $0x0,0x14(%rsp)
  jmp    L176
L130:
  movslq 0x5c(%rsp),%rdx
  mov    0xc0(%rsp),%rax
  lea    (%rax,%rdx,8),%rax
  add    0x78(%rsp),%rdx
  mov    0xc0(%rsp),%rcx
  lea    0x8(%rcx,%rdx,8),%rdx
L48:
  movq   $0x0,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L48
  movslq 0x60(%rsp),%rax
  mov    0xc0(%rsp),%rcx
  mov    D11(%rip),%rsi
  mov    %rsi,(%rcx,%rax,8)
  jmp    L166
L121:
  movslq 0x5c(%rsp),%rdx
  mov    0xc0(%rsp),%rax
  lea    (%rax,%rdx,8),%rax
  add    0x78(%rsp),%rdx
  mov    0xc0(%rsp),%rcx
  lea    0x8(%rcx,%rdx,8),%rdx
L139:
  movsd  (%rax),%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax)
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L139
  jmp    L166
L12:
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D15
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D7
type_guessed: byte[8]
name: retrieve_data
arguments: tag: D11
type_guessed: f64

tool: {"D15": [0x5b,0xaa,0xa2,0x2a,0x9e,0x06,0x37,0xc0]}

tool: {"D7": [0xbb,0xbd,0xd7,0xd9,0xdf,0x7c,0xdb,0x3d]}

tool: D11: 1

assistant: ```c
extern void _dtram_estimate_transition_matrix(double *log_lagrangian_mult, double *bias_energies, double *conf_energies, int *count_matrix, int n_conf_states, double *scratch_M, double *transition_matrix) {
  int i, j, o;
  int ij, ji;
  int C;
  double divisor, sum;
  for (i = 0; i < n_conf_states; ++i) {
    o = 0;
    for (j = 0; j < n_conf_states; ++j) {
      ij = i * n_conf_states + j;
      transition_matrix[ij] = 0.0;
      if (i == j) {
        scratch_M[o] = (0 == count_matrix[ij]) ? -23.025850929940457 : log(1.0E-10 + (double)count_matrix[ij]);
        scratch_M[o] -= log_lagrangian_mult[i];
        transition_matrix[ij] = exp(scratch_M[o++]);
        continue;
      }
      ji = j * n_conf_states + i;
      C = count_matrix[ij] + count_matrix[ji];
      if (0 == C)
        continue;
      divisor = _logsumexp_pair(log_lagrangian_mult[j] - conf_energies[i] - bias_energies[i], log_lagrangian_mult[i] - conf_energies[j] - bias_energies[j]);
      scratch_M[o] = log((double)C) - conf_energies[j] - bias_energies[j] - divisor;
      transition_matrix[ij] = exp(scratch_M[o++]);
    }
    sum = exp(_logsumexp_sort_kahan_inplace(scratch_M, o));
    if (0.0 == sum) {
      for (j = 0; j < n_conf_states; ++j)
        transition_matrix[i * n_conf_states + j] = 0.0;
      transition_matrix[i * n_conf_states + i] = 1.0;
    } else if (1.0 != sum) {
      for (j = 0; j < n_conf_states; ++j)
        transition_matrix[i * n_conf_states + j] /= sum;
    }
  }
}
```