user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<getPhase>:
  endbr64
  push   %r15
  lea    0x60(%rdi),%rdx
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0xb8,%rsp
  movsd  D36(%rip),%xmm2
  movsd  D75(%rip),%xmm1
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  mov    %rdi,%rax
  nopw   0x0(%rax,%rax,1)
L70:
  movsd  (%rax),%xmm0
  add    $0x8,%rax
  movapd %xmm0,%xmm3
  minsd  %xmm2,%xmm0
  maxsd  %xmm1,%xmm3
  movapd %xmm0,%xmm2
  movapd %xmm3,%xmm1
  cmp    %rax,%rdx
  jne    L70
  addsd  %xmm2,%xmm1
  subsd  %xmm0,%xmm3
  movsd  D34(%rip),%xmm0
  movl   $0x0,0x3c(%rsp)
  movq   $0x0,0x10(%rsp)
  lea    0x40(%rsp),%r13
  mulsd  %xmm0,%xmm1
  mulsd  %xmm0,%xmm3
  movsd  %xmm1,0x20(%rsp)
  movsd  D30(%rip),%xmm1
  movsd  %xmm3,0x18(%rsp)
  movsd  %xmm1,0x30(%rsp)
L68:
  movq   $0x0,0x28(%rsp)
  mov    %r13,%r14
  xor    %ebp,%ebp
  nop
L39:
  pxor   %xmm0,%xmm0
  movq   $0x0,(%r14)
  mov    %r12,%rbx
  xor    %r15d,%r15d
  cvtsi2sd %ebp,%xmm0
  mulsd  0x30(%rsp),%xmm0
  movsd  %xmm0,0x8(%rsp)
  nopl   0x0(%rax)
L86:
  pxor   %xmm0,%xmm0
  add    $0x8,%rbx
  cvtsi2sd %r15d,%xmm0
  addsd  0x8(%rsp),%xmm0
  add    $0x1e,%r15d
  addsd  0x10(%rsp),%xmm0
  mulsd  D69(%rip),%xmm0
  divsd  D21(%rip),%xmm0
  cvttsd2si %xmm0,%edi
  call   <sin@plt>
  mulsd  0x18(%rsp),%xmm0
  addsd  0x20(%rsp),%xmm0
  subsd  -0x8(%rbx),%xmm0
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  addsd  (%r14),%xmm0
  movsd  %xmm0,(%r14)
  cmp    $0x168,%r15d
  jne    L86
  addsd  0x28(%rsp),%xmm0
  add    $0x1,%ebp
  add    $0x8,%r14
  movsd  %xmm0,0x28(%rsp)
  cmp    $0xc,%ebp
  jne    L39
  xor    %eax,%eax
  pxor   %xmm1,%xmm1
  nopw   0x0(%rax,%rax,1)
L35:
  movsd  0x0(%r13,%rax,8),%xmm0
  movsd  0x28(%rsp),%xmm3
  comisd %xmm0,%xmm3
  jbe    L37
  pxor   %xmm1,%xmm1
  movsd  %xmm0,0x28(%rsp)
  cvtsi2sd %eax,%xmm1
  mulsd  0x30(%rsp),%xmm1
L37:
  add    $0x1,%rax
  cmp    $0xc,%rax
  jne    L35
  addsd  0x10(%rsp),%xmm1
  addl   $0x1,0x3c(%rsp)
  mov    0x3c(%rsp),%eax
  movsd  %xmm1,0x10(%rsp)
  cmp    $0x3,%eax
  je     L8
  mov    D23(%rip),%rcx
  mov    %rcx,0x30(%rsp)
  cmp    $0x2,%eax
  je     L68
  mov    D6(%rip),%rax
  mov    %rax,0x30(%rsp)
  jmp    L68
L8:
  cvttsd2si 0x10(%rsp),%eax
  mov    0xa8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L16
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L16:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D36
type_guessed: f64
name: unpack_data
arguments: tag: D75
type_guessed: f32[2]
name: unpack_data
arguments: tag: D34
type_guessed: f32[2]
name: unpack_data
arguments: tag: D30
type_guessed: f32[2]
name: unpack_data
arguments: tag: D69
type_guessed: f32[2]
name: unpack_data
arguments: tag: D21
type_guessed: f64
name: unpack_data
arguments: tag: D23
type_guessed: byte[8]
name: unpack_data
arguments: tag: D6
type_guessed: f32[2]

tool: D36: 999

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

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

tool: {"D30": [0.0,2.96875]}

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

tool: D21: 180

tool: {"D23": [0xab,0xaa,0xaa,0xaa,0xaa,0xaa,0xca,0x3f]}

tool: {"D6": [0.0,2.0625]}

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;
}
```