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

```asm
<cheleg>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %edi,%r15d
  mov    %esi,%ebx
  mov    %esi,0x4(%rsp)
  mov    %edx,%ebp
  mov    %edx,0x18(%rsp)
  mov    %rcx,0x28(%rsp)
  mov    %r8,0x30(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x58(%rsp)
  xor    %eax,%eax
  cmp    %esi,%edx
  mov    %esi,%r14d
  cmovge %edx,%r14d
  mov    %r14d,(%rsp)
  lea    0x3(%r14,%r14,2),%edi
  mov    $0x8,%esi
  call   <calloc@plt>
  mov    %rax,%rsi
  mov    %rax,0x8(%rsp)
  mov    %rax,0x40(%rsp)
  movslq %r14d,%rdx
  add    $0x1,%rdx
  lea    0x0(,%rdx,8),%rax
  add    %rax,%rsi
  mov    %rsi,0x10(%rsp)
  mov    %rsi,0x48(%rsp)
  add    %rsi,%rax
  mov    %rax,0x50(%rsp)
  test   %r14d,%r14d
  js     L6
  lea    0x0(,%rdx,8),%edi
  mov    %edi,0x1c(%rsp)
  lea    0x8(,%rbx,8),%edi
  mov    %edi,0x38(%rsp)
  lea    0x8(,%rbp,8),%edi
  mov    %edi,0x3c(%rsp)
  lea    -0x1(%r14),%eax
  lea    0x8(,%rax,8),%rax
  mov    %rax,0x20(%rsp)
  mov    $0x0,%ebp
  jmp    L151
L146:
  mov    0x8(%rsp),%rax
  movsd  D26(%rip),%xmm4
  movsd  %xmm4,(%rax)
L132:
  cmp    %ebp,0x4(%rsp)
  je     L107
L30:
  cmp    %ebp,0x18(%rsp)
  je     L0
L111:
  add    $0x1,%ebp
  cmp    %ebp,(%rsp)
  jl     L6
L151:
  movslq %ebp,%rbx
  imul   $0x55555556,%rbx,%rbx
  shr    $0x20,%rbx
  mov    %ebp,%eax
  sar    $0x1f,%eax
  sub    %eax,%ebx
  lea    (%rbx,%rbx,2),%eax
  mov    %ebp,%ebx
  sub    %eax,%ebx
  test   %ebp,%ebp
  je     L146
  cmp    $0x1,%ebp
  jne    L103
  mov    0x10(%rsp),%rax
  movsd  D26(%rip),%xmm3
  movsd  %xmm3,0x8(%rax)
  jmp    L132
L103:
  lea    -0x1(%rbp),%eax
  movslq %eax,%r14
  imul   $0x55555556,%r14,%r14
  shr    $0x20,%r14
  cltd
  sub    %edx,%r14d
  lea    (%r14,%r14,2),%edx
  sub    %edx,%eax
  mov    %eax,%r14d
  lea    -0x2(%rbp),%eax
  movslq %eax,%r13
  imul   $0x55555556,%r13,%r13
  shr    $0x20,%r13
  cltd
  sub    %edx,%r13d
  lea    0x0(%r13,%r13,2),%edx
  sub    %edx,%eax
  mov    %eax,%r13d
  movslq %ebx,%rax
  mov    0x40(%rsp,%rax,8),%r12
  mov    0x1c(%rsp),%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %ebp,%xmm1
  cmpl   $0x0,(%rsp)
  jle    L132
  mov    $0x0,%eax
  movslq %r14d,%r14
  movslq %r13d,%r13
  mov    0x20(%rsp),%rdx
  jmp    L123
L35:
  mov    0x40(%rsp,%r14,8),%rcx
  movsd  (%rcx,%rax,1),%xmm0
  addsd  %xmm0,%xmm0
  movsd  %xmm0,0x8(%r12)
  mov    0x40(%rsp,%r13,8),%rcx
  movsd  (%r12),%xmm0
  subsd  (%rcx,%rax,1),%xmm0
  movsd  %xmm0,(%r12)
L44:
  add    $0x8,%rax
  add    $0x8,%r12
  cmp    %rdx,%rax
  je     L132
L123:
  cmp    $0x1,%r15d
  je     L35
  cmp    $0x2,%r15d
  jne    L44
  mov    0x40(%rsp,%r14,8),%rcx
  movapd %xmm1,%xmm0
  addsd  %xmm1,%xmm0
  subsd  D26(%rip),%xmm0
  mulsd  (%rcx,%rax,1),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%r12)
  mov    0x40(%rsp,%r13,8),%rcx
  movapd %xmm1,%xmm0
  subsd  D26(%rip),%xmm0
  mulsd  (%rcx,%rax,1),%xmm0
  divsd  %xmm1,%xmm0
  movsd  (%r12),%xmm2
  subsd  %xmm0,%xmm2
  movsd  %xmm2,(%r12)
  jmp    L44
L107:
  movslq %ebx,%rax
  mov    0x40(%rsp,%rax,8),%rsi
  mov    0x38(%rsp),%edx
  mov    0x28(%rsp),%rdi
  call   <memcpy@plt>
  jmp    L30
L0:
  movslq %ebx,%rbx
  mov    0x40(%rsp,%rbx,8),%rsi
  mov    0x3c(%rsp),%edx
  mov    0x30(%rsp),%rdi
  call   <memcpy@plt>
  jmp    L111
L6:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x58(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L129
  mov    $0x0,%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L129:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D26
datatype: f64

tool: D26: 1

assistant: ```c
int cheleg(int kind, int m, int n, double coeffm[], double coeffn[]) {
  int j, j0, j1, j2, k, N;
  double *coeff[3], d;
  N = (m > n) ? m : n;
  coeff[0] = calloc(3 * (N + 1), sizeof(double));
  coeff[1] = coeff[0] + (N + 1);
  coeff[2] = coeff[1] + (N + 1);
  for (j = 0; j <= N; j++) {
    j0 = j % 3;
    if (j == 0) {
      coeff[0][0] = 1.0;
    } else if (j == 1) {
      coeff[1][1] = 1.0;
    } else {
      j1 = (j - 1) % 3;
      j2 = (j - 2) % 3;
      memset(coeff[j0], 0, (N + 1) * sizeof(double));
      d = (double)j;
      for (k = 0; k < N; k++) {
        if (kind == 1) {
          coeff[j0][k + 1] = 2.0 * coeff[j1][k];
          coeff[j0][k] -= coeff[j2][k];
        } else if (kind == 2) {
          coeff[j0][k + 1] = ((2.0 * d - 1.0) * coeff[j1][k]) / d;
          coeff[j0][k] -= ((d - 1.0) * coeff[j2][k]) / d;
        }
      }
    }
    if (j == m)
      memcpy(coeffm, coeff[j0], (m + 1) * sizeof(double));
    if (j == n)
      memcpy(coeffn, coeff[j0], (n + 1) * sizeof(double));
  }
  free(coeff[0]);
  return 0;
}
```