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

```asm
<Rates4Sites>:
  endbr64
  push   %r15
  movapd %xmm0,%xmm1
  push   %r14
  mov    %esi,%r14d
  push   %r13
  mov    %r8,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x18,%rsp
  ucomisd D6(%rip),%xmm0
  jp     L112
  jne    L112
  test   %rdi,%rdi
  je     L76
  test   %edx,%edx
  jle    L76
  lea    -0x1(%rdx),%edx
  movsd  D29(%rip),%xmm0
  mov    %rdi,%rax
  lea    0x8(%rdi,%rdx,8),%rdx
  nopl   0x0(%rax)
L106:
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rax,%rdx
  jne    L106
L76:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L112:
  cmp    $0x1,%r14d
  jg     L26
  test   %r12d,%r12d
  jle    L138
  lea    -0x1(%r12),%eax
  mov    %rbp,%r13
  lea    0x8(%rbp,%rax,8),%r14
  nopl   0x0(%rax)
L157:
  movapd %xmm1,%xmm0
  movsd  %xmm1,(%rsp)
  add    $0x8,%r13
  call   <rndgamma@plt>
  movsd  (%rsp),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%r13)
  cmp    %r14,%r13
  jne    L157
L138:
  test   %ebx,%ebx
  je     L76
  cmp    $0x1,%r12d
  jle    L0
  lea    -0x2(%r12),%edx
  lea    0x8(%rbp),%rax
  lea    0x10(%rbp,%rdx,8),%rdx
  xchg   %ax,%ax
L45:
  movsd  (%rax),%xmm0
  addsd  -0x8(%rax),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rdx
  jne    L45
L0:
  movslq %r12d,%rax
  movsd  D29(%rip),%xmm0
  mov    %r12d,%edx
  mov    %rbp,%rsi
  divsd  -0x8(%rbp,%rax,8),%xmm0
  cvttsd2si %xmm0,%edi
  call   <abyx@plt>
  jmp    L76
  nopl   0x0(%rax)
L26:
  lea    (%r14,%r14,1),%r15d
  movslq %r14d,%rax
  xor    %ecx,%ecx
  mov    %r14d,%edx
  movslq %r15d,%r15
  shl    $0x3,%rax
  movapd %xmm1,%xmm0
  mov    %r13,%rsi
  lea    0x0(,%r15,8),%r8
  lea    0x0(%r13,%r8,1),%r15
  mov    %r8,0x8(%rsp)
  mov    %r15,%r10
  sub    %rax,%r10
  mov    %r10,%rdi
  mov    %r10,(%rsp)
  call   <DiscreteGamma@plt>
  mov    (%rsp),%r10
  mov    %r14d,%esi
  mov    %r15,%rcx
  mov    0x8(%rsp),%r8
  mov    %r12d,%edi
  mov    %r10,%rdx
  add    %r10,%r8
  call   <MultiNomial@plt>
  lea    -0x1(%r14),%eax
  mov    %r15,%r9
  mov    %r13,%r8
  lea    0x8(%r13,%rax,8),%r10
  xor    %esi,%esi
  lea    0x8(%rbp),%r11
L18:
  mov    (%r9),%ecx
  test   %ecx,%ecx
  jle    L65
  movslq %esi,%rdi
  lea    -0x1(%rcx),%edx
  add    %rdi,%rdx
  lea    0x0(%rbp,%rdi,8),%rax
  lea    (%r11,%rdx,8),%rdx
  nopl   0x0(%rax)
L10:
  movsd  (%r8),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rdx,%rax
  jne    L10
  add    %ecx,%esi
L65:
  add    $0x8,%r8
  add    $0x4,%r9
  cmp    %r10,%r8
  jne    L18
  jmp    L138
```

tool_calls: name: retrieve_data
arguments: data_tag: D6
type_guessed: byte[8]
name: retrieve_data
arguments: data_tag: D29
type_guessed: byte[8]

tool: {"D6": [0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D29": [0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f]}

assistant: ```c
int Rates4Sites(double rates[], double alpha, int ncatG, int ls, int cdf, double space[]) {
  int h, ir, j, *counts = (int *)(space + 2 * ncatG);
  double *rK = space, *freqK = space + ncatG;
  if (alpha == 0) {
    if (rates)
      for (h = 0; h < ls; h++)
        rates[h] = 1;
  } else {
    if (ncatG > 1) {
      DiscreteGamma(freqK, rK, alpha, alpha, ncatG, 0);
      MultiNomial(ls, ncatG, freqK, counts, space + 3 * ncatG);
      for (ir = 0, h = 0; ir < ncatG; ir++)
        for (j = 0; j < counts[ir]; j++)
          rates[h++] = rK[ir];
    } else
      for (h = 0; h < ls; h++)
        rates[h] = rndgamma(alpha) / alpha;
    if (cdf) {
      for (h = 1; h < ls; h++)
        rates[h] += rates[h - 1];
      abyx(1 / rates[ls - 1], rates, ls);
    }
  }
  return (0);
}
```