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

```asm
<gen_signal_double>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x40,%rsp
  movsd  %xmm0,0x38(%rsp)
  cmp    $0x1,%esi
  je     L38
  test   %edx,%edx
  jle    L39
  movsd  D197(%rip),%xmm7
  pxor   %xmm3,%xmm3
  xor    %eax,%eax
  movsd  D177(%rip),%xmm0
  movsd  D23(%rip),%xmm2
  movsd  D209(%rip),%xmm1
  lea    -0x3e8(%rdx),%ebp
  movsd  %xmm7,0x28(%rsp)
  movsd  D114(%rip),%xmm7
  movsd  %xmm7,0x30(%rsp)
  jmp    L60
  nopl   0x0(%rax)
L34:
  cmp    %eax,%ebp
  jge    L74
  mov    %ebx,%edx
  pxor   %xmm3,%xmm3
  sub    %eax,%edx
  cvtsi2sd %edx,%xmm3
  mulsd  0x38(%rsp),%xmm3
  divsd  D102(%rip),%xmm3
L74:
  movsd  0x28(%rsp),%xmm5
  mulsd  0x30(%rsp),%xmm2
  lea    0x1(%rax),%r13d
  movsd  %xmm3,0x10(%rsp)
  add    $0x10,%r12
  mulsd  %xmm5,%xmm1
  mulsd  %xmm5,%xmm0
  addsd  %xmm2,%xmm1
  addsd  %xmm2,%xmm0
  mulsd  %xmm3,%xmm1
  mulsd  %xmm3,%xmm0
  movsd  %xmm1,-0x10(%r12)
  movsd  %xmm0,-0x8(%r12)
  cmp    %ebx,%r13d
  je     L39
  add    $0x2,%eax
  pxor   %xmm4,%xmm4
  movsd  D135(%rip),%xmm0
  cvtsi2sd %eax,%xmm4
  mulsd  %xmm4,%xmm0
  movsd  %xmm4,0x8(%rsp)
  divsd  D21(%rip),%xmm0
  call   <sin@plt>
  movsd  %xmm0,0x20(%rsp)
  movsd  D165(%rip),%xmm0
  mulsd  0x8(%rsp),%xmm0
  divsd  D21(%rip),%xmm0
  call   <cos@plt>
  movsd  %xmm0,0x18(%rsp)
  movsd  D217(%rip),%xmm0
  mulsd  0x8(%rsp),%xmm0
  divsd  D21(%rip),%xmm0
  call   <sin@plt>
  mov    %r13d,%eax
  movsd  0x18(%rsp),%xmm2
  movsd  0x20(%rsp),%xmm1
  movsd  0x10(%rsp),%xmm3
L60:
  cmp    $0x3e8,%eax
  jg     L34
  pxor   %xmm3,%xmm3
  cvtsi2sd %eax,%xmm3
  mulsd  0x38(%rsp),%xmm3
  divsd  D102(%rip),%xmm3
  jmp    L74
  cs nopw 0x0(%rax,%rax,1)
L39:
  add    $0x40,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L38:
  test   %edx,%edx
  jle    L39
  pxor   %xmm6,%xmm6
  movslq %edx,%rbp
  xor    %r14d,%r14d
  movsd  D114(%rip),%xmm7
  movsd  %xmm6,0x8(%rsp)
  movsd  D197(%rip),%xmm6
  movsd  D23(%rip),%xmm0
  lea    -0x3e8(%rdx),%r13d
  movsd  D209(%rip),%xmm1
  movsd  %xmm7,0x30(%rsp)
  movsd  %xmm6,0x28(%rsp)
  jmp    L104
  nopl   0x0(%rax)
L75:
  cmp    %r14d,%r13d
  jge    L33
  mov    %ebx,%edx
  pxor   %xmm2,%xmm2
  sub    %r14d,%edx
  cvtsi2sd %edx,%xmm2
  mulsd  0x38(%rsp),%xmm2
  divsd  D102(%rip),%xmm2
  movsd  %xmm2,0x8(%rsp)
L33:
  mulsd  0x28(%rsp),%xmm1
  mulsd  0x30(%rsp),%xmm0
  addsd  %xmm0,%xmm1
  mulsd  0x8(%rsp),%xmm1
  movsd  %xmm1,(%r12,%r14,8)
  add    $0x1,%r14
  cmp    %rbp,%r14
  je     L39
  lea    0x1(%r14),%eax
  pxor   %xmm2,%xmm2
  movsd  D135(%rip),%xmm0
  cvtsi2sd %eax,%xmm2
  mulsd  %xmm2,%xmm0
  movsd  %xmm2,0x18(%rsp)
  divsd  D21(%rip),%xmm0
  call   <sin@plt>
  movsd  0x18(%rsp),%xmm2
  mulsd  D165(%rip),%xmm2
  movsd  %xmm0,0x10(%rsp)
  divsd  D21(%rip),%xmm2
  movapd %xmm2,%xmm0
  call   <cos@plt>
  movsd  0x10(%rsp),%xmm1
L104:
  cmp    $0x3e8,%r14
  ja     L75
  pxor   %xmm2,%xmm2
  cvtsi2sd %r14d,%xmm2
  mulsd  0x38(%rsp),%xmm2
  divsd  D102(%rip),%xmm2
  movsd  %xmm2,0x8(%rsp)
  jmp    L33
```

tool_calls: name: retrieve_data
arguments: data_label: D197
type_infered: f64
name: retrieve_data
arguments: data_label: D177
type_infered: byte[8]
name: retrieve_data
arguments: data_label: D23
type_infered: byte[8]
name: retrieve_data
arguments: data_label: D209
type_infered: byte[8]
name: retrieve_data
arguments: data_label: D114
type_infered: f64
name: retrieve_data
arguments: data_label: D102
type_infered: f32[2]
name: retrieve_data
arguments: data_label: D135
type_infered: byte[8]
name: retrieve_data
arguments: data_label: D21
type_infered: f32[2]
name: retrieve_data
arguments: data_label: D165
type_infered: byte[8]
name: retrieve_data
arguments: data_label: D217
type_infered: byte[8]

tool: D197: 0.4

tool: {"D177": [0xcb,0x0b,0x62,0xa9,0x11,0x31,0xa0,0x3f]}

tool: {"D23": [0x3a,0x5f,0x7e,0x21,0x42,0xca,0xef,0x3f]}

tool: {"D209": [0x13,0x68,0x8c,0x17,0x9d,0x6e,0x93,0x3f]}

tool: D114: 0.3

tool: {"D102": [0.0,4.4765625]}

tool: {"D135": [0x53,0x25,0x4a,0xbd,0x5c,0x27,0x6a,0x40]}

tool: {"D21": [0.0,6.17291259765625]}

tool: {"D165": [0x06,0x5b,0x18,0xbb,0x31,0xbe,0x93,0x40]}

tool: {"D217": [0x1b,0x1f,0x13,0xf3,0x77,0xcb,0x75,0x40]}

assistant: ```c
void gen_signal_double(double *data, double scale, int channels, int datalen) {
  int k, ramplen;
  double amp = 0.0;
  ramplen = 1000;
  if (channels == 1) {
    for (k = 0; k < datalen; k++) {
      if (k <= ramplen)
        amp = scale * k / ((double)ramplen);
      else if (k > datalen - ramplen)
        amp = scale * (datalen - k) / ((double)ramplen);
      data[k] = amp * (0.4 * sin(33.3 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)) + 0.3 * cos(201.1 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)));
    };
  } else {
    for (k = 0; k < datalen; k++) {
      if (k <= ramplen)
        amp = scale * k / ((double)ramplen);
      else if (k > datalen - ramplen)
        amp = scale * (datalen - k) / ((double)ramplen);
      data[2 * k] = amp * (0.4 * sin(33.3 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)) + 0.3 * cos(201.1 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)));
      data[2 * k + 1] = amp * (0.4 * sin(55.5 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)) + 0.3 * cos(201.1 * 2.0 * 3.14159265358979323846264338 * ((double)(k + 1)) / ((double)11025)));
    };
  };
  return;
}
```