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

```asm
<nth>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  movss  %xmm0,-0x28(%rbp)
  mov    -0x24(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  -0x28(%rbp),%xmm0
  comiss %xmm1,%xmm0
  jb     L238
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  jmp    L175
L238:
  cmpl   $0x1,-0x24(%rbp)
  je     L28
  pxor   %xmm0,%xmm0
  comiss -0x28(%rbp),%xmm0
  jbe    L194
L28:
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  jmp    L175
L194:
  cmpl   $0x2,-0x24(%rbp)
  jg     L4
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x4,%rax
  movss  (%rax),%xmm0
  comiss %xmm1,%xmm0
  jbe    L209
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd %xmm0,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x28(%rbp),%xmm2
  movsd  D41(%rip),%xmm0
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x30(%rbp),%rax
  add    $0x4,%rax
  movss  (%rax),%xmm0
  mulss  -0x28(%rbp),%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm3,%xmm3
  cvtsd2ss %xmm0,%xmm3
  movd   %xmm3,%eax
  jmp    L175
L209:
  mov    -0x30(%rbp),%rax
  add    $0x4,%rax
  movss  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd %xmm0,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x28(%rbp),%xmm2
  movsd  D41(%rip),%xmm0
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  mulss  -0x28(%rbp),%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm4,%xmm4
  cvtsd2ss %xmm0,%xmm4
  movd   %xmm4,%eax
  jmp    L175
L4:
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0xc(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x1,-0x10(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L29
L87:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  comiss -0xc(%rbp),%xmm0
  jbe    L179
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  -0x4(%rbp),%xmm0
  movss  %xmm0,(%rax)
  subl   $0x1,-0x14(%rbp)
  subl   $0x1,-0x18(%rbp)
  jmp    L1
L179:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  ucomiss -0xc(%rbp),%xmm0
  jp     L1
  ucomiss -0xc(%rbp),%xmm0
  jne    L1
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  (%rax),%xmm0
  movss  %xmm0,-0x4(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movss  -0x4(%rbp),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x10(%rbp)
L1:
  addl   $0x1,-0x18(%rbp)
L29:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L87
  mov    -0x14(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jne    L204
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  -0x28(%rbp),%xmm0
  comiss %xmm1,%xmm0
  jb     L193
  mov    -0xc(%rbp),%eax
  jmp    L175
L193:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  comiss -0x28(%rbp),%xmm0
  jbe    L173
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  mov    -0x28(%rbp),%edx
  movd   %edx,%xmm0
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <nth>
  movd   %xmm0,%eax
  jmp    L175
L173:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  -0x28(%rbp),%xmm0
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <floatmax@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x8(%rbp),%xmm2
  movsd  D41(%rip),%xmm0
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  mulss  -0x8(%rbp),%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm5,%xmm5
  cvtsd2ss %xmm0,%xmm5
  movd   %xmm5,%eax
  jmp    L175
L204:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  comiss -0x28(%rbp),%xmm0
  jbe    L107
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  mov    -0x28(%rbp),%edx
  movd   %edx,%xmm0
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <nth>
  movd   %xmm0,%eax
  jmp    L175
L107:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  comiss -0x28(%rbp),%xmm0
  jbe    L156
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  -0x28(%rbp),%xmm0
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <floatmax@plt>
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x8(%rbp),%xmm2
  movsd  D41(%rip),%xmm0
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  mulss  -0x8(%rbp),%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  pxor   %xmm6,%xmm6
  cvtsd2ss %xmm0,%xmm6
  movd   %xmm6,%eax
  jmp    L175
L156:
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  comiss -0x28(%rbp),%xmm0
  jb     L149
  mov    -0xc(%rbp),%eax
  jmp    L175
L149:
  pxor   %xmm0,%xmm0
  cvtsi2ssl -0x14(%rbp),%xmm0
  comiss -0x28(%rbp),%xmm0
  jbe    L96
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  -0x28(%rbp),%xmm0
  subss  %xmm1,%xmm0
  movss  %xmm0,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  movss  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  cvtss2sd %xmm0,%xmm1
  pxor   %xmm2,%xmm2
  cvtss2sd -0x8(%rbp),%xmm2
  movsd  D41(%rip),%xmm0
  subsd  %xmm2,%xmm0
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,-0x38(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <floatmin@plt>
  movd   %xmm0,%eax
  movd   %eax,%xmm0
  mulss  -0x8(%rbp),%xmm0
  cvtss2sd %xmm0,%xmm0
  addsd  -0x38(%rbp),%xmm0
  pxor   %xmm7,%xmm7
  cvtsd2ss %xmm0,%xmm7
  movd   %xmm7,%eax
  jmp    L175
L96:
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x14(%rbp),%xmm1
  movss  -0x28(%rbp),%xmm0
  subss  %xmm1,%xmm0
  movd   %xmm0,%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x30(%rbp),%rax
  add    %rax,%rcx
  mov    -0x24(%rbp),%eax
  sub    -0x14(%rbp),%eax
  movd   %edx,%xmm0
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <nth>
  movd   %xmm0,%eax
L175:
  movd   %eax,%xmm0
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D41
datatype: f64

tool: D41: 1

assistant: ```c
float nth(int ndat, float *dat, float n) {
  float a, temp;
  int i, nmax;
  float s;
  int nsame;
  if (n >= ndat - 1)
    return dat[ndat - 1];
  if (ndat == 1 || n < 0)
    return dat[0];
  if (ndat <= 2) {
    if (dat[0] < dat[1])
      return (dat[0] * (1. - n) + n * dat[1]);
    else
      return (dat[1] * (1. - n) + n * dat[0]);
  }
  a = dat[0];
  nmax = ndat;
  nsame = 1;
  for (i = 1; i < nmax; i++) {
    if (dat[i] > a) {
      temp = dat[i];
      dat[i] = dat[nmax - 1];
      dat[nmax - 1] = temp;
      nmax--;
      i--;
    } else if (dat[i] == a) {
      temp = dat[i];
      dat[i] = dat[nsame];
      dat[nsame] = temp;
      nsame++;
    }
  }
  if (nmax == ndat) {
    if (nmax - nsame <= n) {
      return a;
    } else if (nmax - nsame - 1 > n) {
      return nth(nmax - nsame, dat + nsame, n);
    } else {
      s = n - (nmax - nsame - 1);
      return (floatmax(nmax - nsame, dat + nsame) * (1. - s) + s * dat[0]);
    }
  }
  if (n < nmax - nsame - 1) {
    return nth(nmax - nsame, dat + nsame, n);
  } else if (n < nmax - nsame) {
    s = n - (nmax - nsame - 1);
    return (floatmax(nmax - nsame, dat + nsame) * (1. - s) + s * dat[0]);
  } else if (n <= nmax - 1) {
    return a;
  } else if (n < nmax) {
    s = n - (nmax - 1);
    return (dat[0] * (1. - s) + s * floatmin(ndat - nmax, dat + nmax));
  } else {
    return nth(ndat - nmax, dat + nmax, n - nmax);
  }
}
```