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

```asm
<getPhase>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    %rdi,%r15
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  lea    0x60(%rdi),%rdx
  mov    %rdi,%rax
  movsd  D15(%rip),%xmm2
  movsd  D42(%rip),%xmm1
L94:
  movsd  (%rax),%xmm0
  movapd %xmm0,%xmm3
  maxsd  %xmm1,%xmm3
  movapd %xmm3,%xmm1
  minsd  %xmm2,%xmm0
  movapd %xmm0,%xmm2
  add    $0x8,%rax
  cmp    %rdx,%rax
  jne    L94
  subsd  %xmm0,%xmm3
  movsd  D10(%rip),%xmm0
  mulsd  %xmm0,%xmm3
  movsd  %xmm3,0x18(%rsp)
  addsd  %xmm2,%xmm1
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,0x20(%rsp)
  movl   $0x0,0x3c(%rsp)
  pxor   %xmm1,%xmm1
  movsd  %xmm1,0x10(%rsp)
  jmp    L102
L75:
  add    $0x1,%rax
  cmp    $0xc,%rax
  je     L97
L48:
  movsd  0x40(%rsp,%rax,8),%xmm0
  movsd  0x28(%rsp),%xmm3
  comisd %xmm0,%xmm3
  jbe    L75
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  mulsd  0x30(%rsp),%xmm1
  movsd  %xmm0,0x28(%rsp)
  jmp    L75
L97:
  addsd  0x10(%rsp),%xmm1
  movsd  %xmm1,0x10(%rsp)
  addl   $0x1,0x3c(%rsp)
  mov    0x3c(%rsp),%eax
  cmp    $0x3,%eax
  je     L52
L102:
  movsd  D1(%rip),%xmm1
  movsd  %xmm1,0x30(%rsp)
  mov    $0x0,%eax
  mov    0x3c(%rsp),%ecx
  lea    0x1(%rcx),%edx
  test   %ecx,%ecx
  js     L37
L41:
  movsd  0x30(%rsp),%xmm1
  divsd  D36(%rip),%xmm1
  movsd  %xmm1,0x30(%rsp)
  add    $0x1,%eax
  cmp    %edx,%eax
  jne    L41
L37:
  lea    0x40(%rsp),%r14
  pxor   %xmm1,%xmm1
  movsd  %xmm1,0x28(%rsp)
  mov    $0x0,%r13d
L115:
  mov    %r14,%r12
  movq   $0x0,(%r14)
  pxor   %xmm0,%xmm0
  cvtsi2sd %r13d,%xmm0
  mulsd  0x30(%rsp),%xmm0
  movsd  %xmm0,0x8(%rsp)
  mov    %r15,%rbp
  mov    $0x0,%ebx
L103:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  addsd  0x8(%rsp),%xmm0
  addsd  0x10(%rsp),%xmm0
  mulsd  D33(%rip),%xmm0
  divsd  D34(%rip),%xmm0
  cvttsd2si %xmm0,%edi
  call   <sin@plt>
  mulsd  0x18(%rsp),%xmm0
  addsd  0x20(%rsp),%xmm0
  subsd  0x0(%rbp),%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  (%r12),%xmm0
  movsd  %xmm0,(%r12)
  add    $0x1e,%ebx
  add    $0x8,%rbp
  cmp    $0x168,%ebx
  jne    L103
  addsd  0x28(%rsp),%xmm0
  movsd  %xmm0,0x28(%rsp)
  add    $0x1,%r13d
  add    $0x8,%r14
  cmp    $0xc,%r13d
  jne    L115
  mov    $0x0,%eax
  pxor   %xmm1,%xmm1
  jmp    L48
L52:
  cvttsd2si 0x10(%rsp),%eax
  mov    0xa8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L8
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L8:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D15
data_type: f64
name: disassemble_data
arguments: data_label: D42
data_type: f32[2]
name: disassemble_data
arguments: data_label: D10
data_type: f32[2]
name: disassemble_data
arguments: data_label: D1
data_type: f64
name: disassemble_data
arguments: data_label: D36
data_type: f64
name: disassemble_data
arguments: data_label: D33
data_type: f32[2]
name: disassemble_data
arguments: data_label: D34
data_type: f64

tool: D15: 999

tool: {"D42": [0.0,-4.4755859375]}

tool: {"D10": [0.0,1.75]}

tool: D1: 360

tool: D36: 12

tool: {"D33": [0.0,2.1426987648010254]}

tool: D34: 180

assistant: ```c
int getPhase(double *wave) {
  double max = -999, min = 999;
  double amp, offset;
  double angle = 0, base;
  int i, j, k;
  for (i = 0; i < 12; i++) {
    if (wave[i] > max)
      max = wave[i];
    if (wave[i] < min)
      min = wave[i];
  }
  amp = (max - min) / 2;
  offset = (max + min) / 2;
  for (k = 0; k < 3; k++) {
    double error[12], curerror = 0;
    double segsize = 360;
    for (i = 0; i <= k; i++)
      segsize /= 12.0;
    for (j = 0; j < 12; j++) {
      error[j] = 0;
      for (i = 0; i < 12; i++)
        error[j] += fabs((amp * sin((i * 30 + j * segsize + angle) * 3.14159f / 180.0) + offset) - wave[i]);
      curerror += error[j];
    }
    base = 0;
    for (j = 0; j < 12; j++) {
      if (error[j] < curerror) {
        base = j * segsize;
        curerror = error[j];
      }
    }
    angle += base;
  }
  return (int)angle;
}
```