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

```asm
<cheleg>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %r8,0x40(%rsp)
  mov    %esi,%r8d
  mov    %rcx,0x38(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  cmp    %esi,%edx
  mov    %esi,0x20(%rsp)
  mov    $0x8,%esi
  cmovge %edx,%r8d
  mov    %edx,0x28(%rsp)
  lea    0x3(%r8,%r8,2),%edi
  mov    %r8d,0xc(%rsp)
  call   <calloc@plt>
  movslq 0xc(%rsp),%rdx
  mov    0x28(%rsp),%r9d
  mov    %rax,%rsi
  mov    %rax,0x10(%rsp)
  mov    0x20(%rsp),%r10d
  mov    %rdx,%r8
  add    $0x1,%rdx
  mov    %rax,0x50(%rsp)
  lea    0x0(,%rdx,8),%rax
  lea    (%rsi,%rax,1),%rdi
  add    %rdi,%rax
  test   %r8d,%r8d
  mov    %rdi,0x18(%rsp)
  mov    %rdi,0x58(%rsp)
  mov    %rax,0x60(%rsp)
  js     L53
  mov    %r12d,%r14d
  lea    0x0(,%rdx,8),%eax
  xor    %ebx,%ebx
  mov    %r8d,%r12d
  mov    %eax,0x34(%rsp)
  lea    0x8(,%r10,8),%eax
  movsd  D1(%rip),%xmm3
  mov    $0xaaaaaaab,%r15d
  mov    %eax,0x48(%rsp)
  lea    0x8(,%r9,8),%eax
  mov    %eax,0x4c(%rsp)
  lea    -0x1(%r8),%eax
  lea    0x8(,%rax,8),%rcx
  mov    %r10d,0xc(%rsp)
  mov    %r9d,0x28(%rsp)
  mov    %rcx,%r13
  jmp    L150
  nopw   0x0(%rax,%rax,1)
L134:
  cmp    $0x1,%ebx
  jne    L129
  mov    0x18(%rsp),%rax
  movsd  %xmm3,0x8(%rax)
L35:
  cmp    %ebx,0xc(%rsp)
  je     L93
L137:
  cmp    %ebx,0x28(%rsp)
  je     L21
L51:
  add    $0x1,%ebx
  cmp    %ebx,%r12d
  jl     L53
L150:
  mov    %ebx,%ebp
  imul   %r15,%rbp
  shr    $0x21,%rbp
  lea    0x0(%rbp,%rbp,2),%eax
  mov    %ebx,%ebp
  sub    %eax,%ebp
  test   %ebx,%ebx
  jne    L134
  mov    0x10(%rsp),%rax
  mov    D1(%rip),%rsi
  mov    %rsi,(%rax)
  cmp    %ebx,0xc(%rsp)
  jne    L137
L93:
  movslq %ebp,%rax
  mov    0x48(%rsp),%edx
  mov    0x38(%rsp),%rdi
  mov    0x50(%rsp,%rax,8),%rsi
  call   <memcpy@plt>
  mov    D1(%rip),%rax
  movq   %rax,%xmm3
  cmp    %ebx,0x28(%rsp)
  jne    L51
  cs nopw 0x0(%rax,%rax,1)
L21:
  movslq %ebp,%rbp
  mov    0x4c(%rsp),%edx
  mov    0x40(%rsp),%rdi
  add    $0x1,%ebx
  mov    0x50(%rsp,%rbp,8),%rsi
  call   <memcpy@plt>
  mov    D1(%rip),%rax
  movq   %rax,%xmm3
  cmp    %ebx,%r12d
  jge    L150
  xchg   %ax,%ax
L53:
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    0x68(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L41
  add    $0x78,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L129:
  lea    -0x1(%rbx),%r10d
  lea    -0x2(%rbx),%r9d
  xor    %esi,%esi
  mov    %r10,%rax
  imul   %r15,%r10
  shr    $0x21,%r10
  lea    (%r10,%r10,2),%edx
  sub    %edx,%eax
  mov    %eax,0x30(%rsp)
  mov    %r9,%rax
  imul   %r15,%r9
  shr    $0x21,%r9
  lea    (%r9,%r9,2),%edx
  sub    %edx,%eax
  mov    0x34(%rsp),%edx
  mov    %eax,0x2c(%rsp)
  movslq %ebp,%rax
  mov    0x50(%rsp,%rax,8),%rdi
  mov    %rdi,0x20(%rsp)
  call   <memset@plt>
  pxor   %xmm1,%xmm1
  xor    %eax,%eax
  test   %r12d,%r12d
  mov    D1(%rip),%rsi
  cvtsi2sd %ebx,%xmm1
  mov    0x20(%rsp),%rdx
  movslq 0x30(%rsp),%r10
  movslq 0x2c(%rsp),%r9
  movq   %rsi,%xmm3
  jne    L140
  jmp    L35
  nopl   0x0(%rax)
L80:
  cmp    $0x2,%r14d
  jne    L38
  movapd %xmm1,%xmm0
  mov    0x50(%rsp,%r10,8),%rcx
  movsd  (%rdx),%xmm2
  addsd  %xmm1,%xmm0
  subsd  %xmm3,%xmm0
  mulsd  (%rcx,%rax,1),%xmm0
  mov    0x50(%rsp,%r9,8),%rcx
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%rdx)
  movapd %xmm1,%xmm0
  subsd  %xmm3,%xmm0
  mulsd  (%rcx,%rax,1),%xmm0
  divsd  %xmm1,%xmm0
  subsd  %xmm0,%xmm2
  movsd  %xmm2,(%rdx)
L38:
  add    $0x8,%rax
  add    $0x8,%rdx
  cmp    %r13,%rax
  je     L35
L140:
  cmp    $0x1,%r14d
  jne    L80
  mov    0x50(%rsp,%r10,8),%rcx
  movsd  (%rcx,%rax,1),%xmm0
  mov    0x50(%rsp,%r9,8),%rcx
  addsd  %xmm0,%xmm0
  movsd  %xmm0,0x8(%rdx)
  movsd  (%rdx),%xmm0
  subsd  (%rcx,%rax,1),%xmm0
  movsd  %xmm0,(%rdx)
  jmp    L38
L41:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D1
type_infered: f64

tool: D1: 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;
}
```