user: Please show me the C implementation that matches the assembly code listed below:

```asm
<grib_get_reduced_row>:
  endbr64
  movapd %xmm0,%xmm2
  movapd %xmm1,%xmm0
  pxor   %xmm3,%xmm3
  mov    %rcx,%r8
  subsd  %xmm2,%xmm0
  comisd %xmm0,%xmm3
  movsd  D16(%rip),%xmm3
  jbe    L101
  addsd  %xmm3,%xmm0
  subsd  %xmm3,%xmm2
L101:
  pxor   %xmm4,%xmm4
  cvtsi2sd %rdi,%xmm4
  mulsd  %xmm4,%xmm0
  divsd  %xmm3,%xmm0
  addsd  D18(%rip),%xmm0
  cvttsd2si %xmm0,%rax
  movapd %xmm4,%xmm0
  mulsd  %xmm2,%xmm0
  mov    %rax,(%rsi)
  divsd  %xmm3,%xmm0
  cvttsd2si %xmm0,%rax
  movapd %xmm4,%xmm0
  mulsd  %xmm1,%xmm0
  mov    %rax,(%rdx)
  divsd  %xmm3,%xmm0
  cvttsd2si %xmm0,%rcx
  mov    %rcx,(%r8)
  mov    (%rdx),%rax
  mov    %rcx,%r9
  mov    (%rsi),%r10
  sub    %rax,%r9
  add    $0x1,%r9
  cmp    %r9,%r10
  je     L14
  jge    L30
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm0,%xmm2
  jbe    L70
  add    $0x1,%rax
  mov    %rax,(%rdx)
  mov    (%r8),%rcx
L70:
  pxor   %xmm0,%xmm0
  cvtsi2sd %rcx,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm1,%xmm0
  jbe    L86
  sub    $0x1,%rcx
  mov    %rcx,(%r8)
  mov    (%rdx),%rax
L86:
  test   %rax,%rax
  js     L9
L69:
  ret
  nopl   0x0(%rax)
L30:
  sub    $0x1,%rax
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm2,%xmm0
  jbe    L104
  mov    %rax,(%rdx)
  mov    (%r8),%rsi
  pxor   %xmm0,%xmm0
  lea    0x1(%rsi),%rcx
  cvtsi2sd %rcx,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm0,%xmm1
  jbe    L86
L33:
  mov    %rcx,(%r8)
  mov    (%rdx),%rax
  test   %rax,%rax
  jns    L69
L9:
  add    %rax,%rdi
  mov    %rdi,(%rdx)
  ret
  xchg   %ax,%ax
L14:
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm0,%xmm2
  jbe    L86
  add    $0x1,%rax
  mov    %rax,(%rdx)
  addq   $0x1,(%r8)
  mov    (%rdx),%rax
  test   %rax,%rax
  jns    L69
  jmp    L9
L104:
  add    $0x1,%rcx
  pxor   %xmm0,%xmm0
  cvtsi2sd %rcx,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm4,%xmm0
  comisd %xmm0,%xmm1
  ja     L33
  sub    $0x1,%r10
  mov    %r10,(%rsi)
  mov    (%rdx),%rax
  jmp    L86
```

tool_calls: name: retrieve_data
arguments: tag: D16
type: f64
name: retrieve_data
arguments: tag: D18
type: f32[2]

tool: D16: 360

tool: {"D18": [0.0,1.875]}

assistant: ```c
void grib_get_reduced_row(long pl, double lon_first, double lon_last, long *npoints, long *ilon_first, long *ilon_last) {
  double range = 0, dlon_first = 0, dlon_last = 0;
  long irange;
  range = lon_last - lon_first;
  if (range < 0) {
    range += 360;
    lon_first -= 360;
  }
  *npoints = (range * pl) / 360.0 + 1;
  *ilon_first = (lon_first * pl) / 360.0;
  *ilon_last = (lon_last * pl) / 360.0;
  irange = *ilon_last - *ilon_first + 1;
  if (irange != *npoints) {
    if (irange > *npoints) {
      dlon_first = ((*ilon_first) * 360.0) / pl;
      if (dlon_first < lon_first) {
        (*ilon_first)++;
        irange--;
      }
      dlon_last = ((*ilon_last) * 360.0) / pl;
      if (dlon_last > lon_last) {
        (*ilon_last)--;
        irange--;
      }
    } else {
      int ok = 0;
      dlon_first = ((*ilon_first - 1) * 360.0) / pl;
      if (dlon_first > lon_first) {
        (*ilon_first)--;
        irange++;
        ok = 1;
      }
      dlon_last = ((*ilon_last + 1) * 360.0) / pl;
      if (dlon_last < lon_last) {
        (*ilon_last)++;
        irange++;
        ok = 1;
      }
      if (!ok) {
        (*npoints)--;
      }
    }
  } else {
    dlon_first = ((*ilon_first) * 360.0) / pl;
    if (dlon_first < lon_first) {
      (*ilon_first)++;
      (*ilon_last)++;
    }
  }
  if (*ilon_first < 0)
    *ilon_first += pl;
  return;
}
```