user: 请从给定的汇编指令推导出C源代码：

```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    L116
  nopl   0x0(%rax)
L64:
  cmp    $0x1,%r13d
  jne    L109
  addss  %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  cvttss2si %xmm1,%ecx
  and    $0x1,%ecx
  cvtsi2sd %ecx,%xmm0
L109:
  cmp    $0x2,%r14d
  je     L83
L137:
  cmp    $0x3,%r14d
  je     L50
  cmp    $0x1,%r14d
  je     L111
L67:
  movsd  D51(%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     L35
L116:
  pxor   %xmm1,%xmm1
  mov    %ebp,%eax
  mov    %ebp,%edx
  cvtsi2sd %r15d,%xmm1
  divsd  D87(%rip),%xmm1
  cvtsd2ss %xmm1,%xmm1
  cmp    $0x2,%r13d
  je     L12
  jg     L112
  test   %r13d,%r13d
  jne    L64
  addss  %xmm1,%xmm1
  cvttss2si %xmm1,%ecx
  and    $0x1,%ecx
  je     L56
  xorps  D65(%rip),%xmm1
L56:
  pxor   %xmm0,%xmm0
  cvtss2sd %xmm1,%xmm0
  cmp    $0x2,%r14d
  jne    L137
  nop
L83:
  neg    %eax
  pxor   %xmm1,%xmm1
  movsd  %xmm0,(%rsp)
  cvtsi2sd %eax,%xmm1
  mulsd  D58(%rip),%xmm1
  jmp    L65
  nopl   0x0(%rax)
L112:
  cmp    $0x3,%r13d
  jne    L109
  addss  %xmm1,%xmm1
  movss  D18(%rip),%xmm0
  subss  %xmm1,%xmm0
  cvtss2sd %xmm0,%xmm0
  jmp    L109
  nopl   0x0(%rax,%rax,1)
L111:
  pxor   %xmm2,%xmm2
  movsd  D36(%rip),%xmm1
  cvtsi2sd %edx,%xmm2
  mulsd  D58(%rip),%xmm2
  subsd  %xmm2,%xmm1
  mulsd  %xmm1,%xmm0
  jmp    L67
  nopl   (%rax)
L50:
  pxor   %xmm1,%xmm1
  movsd  %xmm0,(%rsp)
  cvtsi2sd %edx,%xmm1
  mulsd  D76(%rip),%xmm1
L65:
  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    L67
  nop
L12:
  pxor   %xmm0,%xmm0
  mov    %ebp,0xc(%rsp)
  cvtss2sd %xmm1,%xmm0
  mulsd  D63(%rip),%xmm0
  mov    %ebp,(%rsp)
  cvtsd2ss %xmm0,%xmm0
  call   <sin@plt>
  mov    (%rsp),%edx
  mov    0xc(%rsp),%eax
  jmp    L109
L35:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: label: D51
type_infered: byte[8]
name: disassemble_data
arguments: label: D87
type_infered: f64
name: disassemble_data
arguments: label: D65
type_infered: byte[16]
name: disassemble_data
arguments: label: D58
type_infered: byte[8]
name: disassemble_data
arguments: label: D18
type_infered: byte[4]
name: disassemble_data
arguments: label: D36
type_infered: byte[8]
name: disassemble_data
arguments: label: D76
type_infered: byte[8]
name: disassemble_data
arguments: label: D63
type_infered: f64

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

tool: D87: 8000

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

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

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

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

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

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