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

```asm
<_fff_pth_element>:
  endbr64
  push   %r14
  lea    0x0(,%rdx,8),%r9
  lea    -0x1(%rcx),%r11
  xor    %r14d,%r14d
  push   %r13
  mov    %r9,%r8
  xor    %r13d,%r13d
  push   %r12
  neg    %r8
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  nopw   0x0(%rax,%rax,1)
L138:
  mov    %r9,%r10
  mov    %r9,%rax
  imul   %r13,%r10
  imul   %r11,%rax
  add    %rbp,%r10
  add    %rbp,%rax
  movsd  (%r10),%xmm0
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L133
  movsd  %xmm1,(%r10)
  xor    %ebx,%ebx
  movapd %xmm0,%xmm1
  movsd  %xmm0,(%rax)
  movsd  (%r10),%xmm2
L119:
  cmp    %r11,%r13
  je     L159
  lea    0x1(%r13),%rdi
  lea    (%r10,%r9,1),%rdx
  mov    %r11,%rsi
  lea    0x2(%r13),%rcx
  jmp    L121
  nopl   (%rax)
L143:
  add    %r9,%rdx
  add    $0x1,%rcx
  add    $0x1,%rdi
L121:
  movsd  (%rdx),%xmm0
  comisd %xmm0,%xmm2
  ja     L143
  comisd %xmm2,%xmm1
  jbe    L156
  nopl   0x0(%rax,%rax,1)
L168:
  add    %r8,%rax
  sub    $0x1,%rsi
  movsd  (%rax),%xmm1
  comisd %xmm2,%xmm1
  ja     L168
L156:
  cmp    %rdi,%rsi
  jbe    L123
  sub    $0x1,%rsi
  movsd  %xmm1,(%rdx)
  movsd  %xmm0,(%rax)
  add    %r8,%rax
  cmp    %r11,%rsi
  jne    L67
  test   %bl,%bl
  jne    L161
L67:
  movsd  (%rax),%xmm1
  jmp    L143
  nopl   0x0(%rax)
L123:
  cmp    %r11,%rsi
  jne    L140
  test   %bl,%bl
  je     L140
L163:
  add    %r8,%rax
  movsd  (%r10),%xmm0
  sub    $0x1,%rsi
  movsd  (%rax),%xmm1
  movsd  %xmm1,(%r10)
  movsd  %xmm0,(%rax)
L140:
  cmp    %rsi,%r12
  jb     L13
  ja     L76
L159:
  pop    %rbx
  movapd %xmm2,%xmm0
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L133:
  ucomisd %xmm1,%xmm0
  movapd %xmm0,%xmm2
  setnp  %bl
  cmovne %r14d,%ebx
  jmp    L119
L13:
  mov    %rsi,%r11
  jmp    L138
L76:
  mov    %rdi,%r13
  jmp    L138
L161:
  mov    %rcx,%rdi
  jmp    L163
```

assistant: ```c
double _fff_pth_element(double *x, size_t p, size_t stride, size_t n) {
  double a, tmp;
  double *bufl, *bufr;
  size_t i, j, il, jr, stop1, stop2;
  int same_extremities;
  stop1 = 0;
  il = 0;
  jr = n - 1;
  while (stop1 == 0) {
    same_extremities = 0;
    bufl = x + stride * il;
    bufr = x + stride * jr;
    if (*bufl > *bufr) {
      tmp = (*bufl);
      (*bufl) = (*bufr);
      (*bufr) = tmp;
    } else if (*bufl == *bufr)
      same_extremities = 1;
    a = *bufl;
    if (il == jr)
      return a;
    bufl += stride;
    i = il + 1;
    j = jr;
    stop2 = 0;
    while (stop2 == 0) {
      while (*bufl < a) {
        i++;
        bufl += stride;
      }
      while (*bufr > a) {
        j--;
        bufr -= stride;
      }
      if (j <= i)
        stop2 = 1;
      else {
        {
          tmp = (*bufl);
          (*bufl) = (*bufr);
          (*bufr) = tmp;
        }
        j--;
        bufr -= stride;
        i++;
        bufl += stride;
      }
      if ((same_extremities) && (j == jr)) {
        j--;
        bufr -= stride;
        {
          tmp = (x[il * stride]);
          (x[il * stride]) = (*bufr);
          (*bufr) = tmp;
        }
        stop2 = 1;
      }
    }
    if (j > p)
      jr = j;
    else if (j < p)
      il = i;
    else
      stop1 = 1;
  }
  return a;
}
```