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

```asm
<phi_gradient>:
  endbr64
  movapd %xmm0,%xmm6
  movapd %xmm2,%xmm7
  movsd  D36(%rip),%xmm2
  subsd  %xmm5,%xmm6
  comisd %xmm2,%xmm6
  jbe    L38
  subsd  D122(%rip),%xmm6
L8:
  subsd  %xmm5,%xmm1
  comisd %xmm2,%xmm1
  jbe    L77
  subsd  D122(%rip),%xmm1
L88:
  movapd %xmm1,%xmm0
  subsd  %xmm6,%xmm0
  comisd %xmm0,%xmm2
  jbe    L37
  comisd D86(%rip),%xmm0
  jbe    L37
  mulsd  %xmm3,%xmm6
  mulsd  %xmm1,%xmm4
  movapd %xmm6,%xmm0
  addsd  %xmm4,%xmm0
  mulsd  %xmm7,%xmm0
  ret
  nopl   (%rax)
L37:
  comisd D11(%rip),%xmm6
  movsd  D0(%rip),%xmm8
  jbe    L1
L80:
  movsd  D66(%rip),%xmm5
  movapd %xmm6,%xmm0
  movapd %xmm6,%xmm9
  andpd  D28(%rip),%xmm7
  subsd  %xmm2,%xmm9
  mulsd  %xmm5,%xmm0
  mulsd  %xmm1,%xmm5
  mulsd  %xmm9,%xmm0
  movapd %xmm2,%xmm9
  subsd  %xmm6,%xmm2
  addsd  %xmm1,%xmm9
  addsd  %xmm1,%xmm6
  mulsd  %xmm9,%xmm5
  mulsd  %xmm8,%xmm6
  mulsd  %xmm3,%xmm0
  mulsd  %xmm4,%xmm5
  subsd  %xmm3,%xmm4
  mulsd  %xmm4,%xmm2
  subsd  %xmm5,%xmm0
  divsd  %xmm7,%xmm2
  addsd  %xmm3,%xmm2
  mulsd  %xmm6,%xmm2
  addsd  %xmm2,%xmm0
  ret
  nopl   0x0(%rax,%rax,1)
L77:
  movsd  D86(%rip),%xmm0
  comisd %xmm1,%xmm0
  jbe    L88
  addsd  D122(%rip),%xmm1
  jmp    L88
  nopw   0x0(%rax,%rax,1)
L38:
  movsd  D86(%rip),%xmm0
  comisd %xmm6,%xmm0
  jbe    L8
  addsd  D122(%rip),%xmm6
  jmp    L8
  nop
L1:
  movsd  D133(%rip),%xmm8
  movsd  D86(%rip),%xmm2
  jmp    L80
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D36
type_infered: f64
name: extract_symbolic_data
arguments: data_label: D122
type_infered: byte[8]
name: extract_symbolic_data
arguments: data_label: D86
type_infered: byte[16]
name: extract_symbolic_data
arguments: data_label: D11
type_infered: f64
name: extract_symbolic_data
arguments: data_label: D0
type_infered: byte[8]
name: extract_symbolic_data
arguments: data_label: D66
type_infered: f64
name: extract_symbolic_data
arguments: data_label: D28
type_infered: qword[2]
name: extract_symbolic_data
arguments: data_label: D133
type_infered: byte[8]

tool: D36: 3.141592653589793

tool: {"D122": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: {"D86": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x09,0xc0,0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: D11: 0

tool: {"D0": [0x18,0x2d,0x44,0x54,0xfb,0x21,0xf9,0x3f]}

tool: D66: 0.5

tool: {"D28": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D133": [0x18,0x2d,0x44,0x54,0xfb,0x21,0xf9,0xbf]}

assistant: ```c
double phi_gradient(double in_phi1, double in_phi2, double dphi, double f1, double f2, double grid_lon) {
  double fint, fac;
  double weight;
  double phi1, phi2;
  phi1 = in_phi1 - grid_lon;
  if (phi1 > 3.14159265358979323846)
    phi1 -= (2.0 * 3.14159265358979323846);
  else if (phi1 < -3.14159265358979323846)
    phi1 += (2.0 * 3.14159265358979323846);
  phi2 = in_phi2 - grid_lon;
  if (phi2 > 3.14159265358979323846)
    phi2 -= (2.0 * 3.14159265358979323846);
  else if (phi2 < -3.14159265358979323846)
    phi2 += (2.0 * 3.14159265358979323846);
  if ((phi2 - phi1) < 3.14159265358979323846 && (phi2 - phi1) > -3.14159265358979323846)
    weight = dphi * (phi1 * f1 + phi2 * f2);
  else {
    if (phi1 > 0.0)
      fac = 3.14159265358979323846;
    else
      fac = -3.14159265358979323846;
    fint = f1 + (f2 - f1) * (fac - phi1) / fabs(dphi);
    weight = 0.5 * phi1 * (phi1 - fac) * f1 - 0.5 * phi2 * (phi2 + fac) * f2 + 0.5 * fac * (phi1 + phi2) * fint;
  }
  return weight;
}
```