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

```asm
<_tram_get_conf_energies>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8d,-0x38(%rbp)
  mov    %r9d,-0x44(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L67
L54:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  js     L80
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L51
L62:
  mov    -0x18(%rbp),%eax
  imul   -0x44(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  D22(%rip),%xmm1
  pxor   %xmm2,%xmm2
  divsd  %xmm2,%xmm1
  movq   D13(%rip),%xmm2
  xorpd  %xmm2,%xmm1
  ucomisd %xmm1,%xmm0
  jp     L33
  ucomisd %xmm1,%xmm0
  je     L57
L33:
  mov    -0x18(%rbp),%eax
  imul   -0x44(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x14(%rbp),%eax
  imul   -0x38(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x10(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x10(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  jmp    L28
L57:
  nop
L28:
  addl   $0x1,-0x18(%rbp)
L51:
  mov    -0x18(%rbp),%eax
  cmp    -0x38(%rbp),%eax
  jl     L62
  mov    -0x10(%rbp),%eax
  mov    %eax,%esi
  mov    0x10(%rbp),%rdi
  call   <_logsumexp_sort_kahan_inplace@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movq   D13(%rip),%xmm1
  movapd %xmm0,%xmm2
  xorpd  %xmm1,%xmm2
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movq   D13(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movq   %xmm0,%rax
  movapd %xmm2,%xmm1
  movq   %rax,%xmm0
  call   <_logsumexp_pair@plt>
  movq   %xmm0,%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    0x18(%rbp),%rdx
  add    %rcx,%rdx
  movq   D13(%rip),%xmm0
  movq   %rax,%xmm3
  xorpd  %xmm0,%xmm3
  movapd %xmm3,%xmm0
  movsd  %xmm0,(%rdx)
  jmp    L31
L80:
  nop
L31:
  addl   $0x1,-0x14(%rbp)
L67:
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L54
  nop
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D22
type_guessed: f64
name: unpack_data
arguments: label: D13
type_guessed: f32[2]

tool: D22: 1

tool: {"D13": [0.0,-0.0]}

assistant: ```c
void _tram_get_conf_energies(double *bias_energy_sequence, int *state_sequence, int seq_length, double *log_R_K_i, int n_therm_states, int n_conf_states, double *scratch_T, double *conf_energies) {
  int i, K, x, o;
  double divisor;
  for (x = 0; x < seq_length; ++x) {
    i = state_sequence[x];
    if (i < 0)
      continue;
    o = 0;
    for (K = 0; K < n_therm_states; ++K) {
      if (-(1.0 / 0.0) == log_R_K_i[K * n_conf_states + i])
        continue;
      scratch_T[o++] = log_R_K_i[K * n_conf_states + i] - bias_energy_sequence[x * n_therm_states + K];
    }
    divisor = _logsumexp_sort_kahan_inplace(scratch_T, o);
    conf_energies[i] = -_logsumexp_pair(-conf_energies[i], -divisor);
  }
}
```