user: What is the c source code of the assembly code below?

```asm
<gen_wave>:
  endbr64
  push   %r15
  xor    %r15d,%r15d
  push   %r14
  mov    %ecx,%r14d
  push   %r13
  mov    %esi,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  jmp    L120
  nopl   0x0(%rax)
L37:
  cmp    $0x1,%r13d
  jne    L41
  addss  %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  cvttss2si %xmm1,%ecx
  and    $0x1,%ecx
  cvtsi2sd %ecx,%xmm0
L41:
  cmp    $0x2,%r14d
  je     L151
L163:
  cmp    $0x3,%r14d
  je     L145
  cmp    $0x1,%r14d
  je     L7
L122:
  movsd  D46(%rip),%xmm1
  add    %ebx,%r15d
  mulsd  %xmm0,%xmm1
  addsd  (%r12,%rbp,8),%xmm1
  movsd  %xmm1,(%r12,%rbp,8)
  add    $0x1,%rbp
  cmp    $0x400,%rbp
  je     L53
L120:
  pxor   %xmm1,%xmm1
  mov    %ebp,%eax
  mov    %ebp,%edx
  cvtsi2sd %r15d,%xmm1
  divsd  D41(%rip),%xmm1
  cvtsd2ss %xmm1,%xmm1
  cmp    $0x2,%r13d
  je     L2
  jg     L118
  test   %r13d,%r13d
  jne    L37
  addss  %xmm1,%xmm1
  cvttss2si %xmm1,%ecx
  and    $0x1,%ecx
  je     L110
  xorps  D4(%rip),%xmm1
L110:
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm1,%xmm0
  cmp    $0x2,%r14d
  jne    L163
  nop
L151:
  neg    %eax
  pxor   %xmm1,%xmm1
  movsd  %xmm0,(%rsp)
  cvtsi2sd %eax,%xmm1
  mulsd  D35(%rip),%xmm1
  jmp    L144
  nopl   0x0(%rax)
L118:
  cmp    $0x3,%r13d
  jne    L41
  addss  %xmm1,%xmm1
  movss  D22(%rip),%xmm0
  subss  %xmm1,%xmm0
  cvtss2sd %xmm0,%xmm0
  jmp    L41
  nopl   0x0(%rax,%rax,1)
L7:
  pxor   %xmm2,%xmm2
  movsd  D60(%rip),%xmm1
  cvtsi2sd %edx,%xmm2
  mulsd  D35(%rip),%xmm2
  subsd  %xmm2,%xmm1
  mulsd  %xmm1,%xmm0
  jmp    L122
  nopl   (%rax)
L145:
  pxor   %xmm1,%xmm1
  movsd  %xmm0,(%rsp)
  cvtsi2sd %edx,%xmm1
  mulsd  D88(%rip),%xmm1
L144:
  cvttsd2si %xmm1,%edi
  call   <sqrt@plt>
  pxor   %xmm1,%xmm1
  movsd  (%rsp),%xmm0
  mov    %eax,%r8d
  mov    $0x1,%eax
  sub    %r8d,%eax
  cvtsi2sd %eax,%xmm1
  mulsd  %xmm1,%xmm0
  jmp    L122
  nop
L2:
  pxor   %xmm0,%xmm0
  mov    %ebp,0xc(%rsp)
  cvtss2sd %xmm1,%xmm0
  mulsd  D3(%rip),%xmm0
  mov    %ebp,(%rsp)
  cvtsd2ss %xmm0,%xmm0
  call   <sin@plt>
  mov    (%rsp),%eax
  mov    0xc(%rsp),%edx
  jmp    L41
L53:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D46
data_type: byte[8]
name: parse_data
arguments: data_tag: D41
data_type: f64
name: parse_data
arguments: data_tag: D4
data_type: byte[16]
name: parse_data
arguments: data_tag: D35
data_type: byte[8]
name: parse_data
arguments: data_tag: D22
data_type: byte[4]
name: parse_data
arguments: data_tag: D60
data_type: byte[8]
name: parse_data
arguments: data_tag: D88
data_type: byte[8]
name: parse_data
arguments: data_tag: D3
data_type: f64

tool: {"D46": [0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x40]}

tool: D41: 8000

tool: {"D4": [0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]}

tool: {"D35": [0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x3f]}

tool: {"D22": [0x00,0x00,0x80,0x3f]}

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

tool: {"D88": [0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x40]}

tool: D3: 6.28

assistant: ```c
void gen_wave(int8_t *arr, uint8_t type, uint16_t freq, uint8_t lfo_type, uint8_t lfo_coef) {
  int i;
  float x;
  double cv;
  for (i = 0; i < 1024; i++) {
    x = i * freq / 8000.0;
    switch (type) {
    case 0:
      cv = (int)(x * 2) % 2 ? -2 * x : 2 * x;
      break;
    case 1:
      cv = (int)(x * 2) % 2 ? 1 : 0;
      break;
    case 2:
      cv = sin(x * 6.28);
      break;
    case 3:
      cv = 1 - 2 * x;
      break;
    }
    switch (lfo_type) {
    case 1:
      cv *= (1 - i / (double)1024);
      break;
    case 2:
      cv *= (1 - sqrt(-i / (double)1024));
      break;
    case 3:
      cv *= (1 - sqrt(i * (double)(1024)));
      break;
    }
    arr[i] += cv * 128;
  }
}
```