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

```asm
<simultaneous_sort>:
  endbr64
  cmp    $0x1,%edx
  jle    L97
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  cmp    $0x2,%edx
  je     L188
L43:
  cmp    $0x3,%r13d
  je     L194
  movslq %r13d,%rax
  movsd  0x0(%rbp),%xmm0
  mov    %r13d,%r12d
  lea    -0x1(%r13),%r14d
  lea    -0x8(%rbp,%rax,8),%rbx
  sar    %r12d
  movsd  (%rbx),%xmm1
  comisd %xmm1,%xmm0
  ja     L89
L48:
  movslq %r12d,%rax
  comisd 0x0(%rbp,%rax,8),%xmm1
  ja     L136
L153:
  movsd  0x0(%rbp),%xmm0
L88:
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  jmp    L101
  nopw   0x0(%rax,%rax,1)
L73:
  add    $0x1,%rbx
  cmp    %ebx,%r14d
  jle    L92
L79:
  movsd  0x0(%rbp,%rbx,8),%xmm0
L101:
  comisd %xmm0,%xmm1
  mov    %ebx,%edx
  jbe    L73
  mov    %r12d,%ecx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  add    $0x1,%rbx
  movsd  %xmm1,0x8(%rsp)
  add    $0x1,%r12d
  call   <dual_swap@plt>
  movsd  0x8(%rsp),%xmm1
  cmp    %ebx,%r14d
  jg     L79
L92:
  mov    %r14d,%ecx
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  cmp    $0x1,%r12d
  jg     L208
L103:
  lea    (%r12,%r12,1),%eax
  cmp    %r13d,%eax
  jge    L187
  sub    %r12d,%r13d
  movslq %r12d,%r12
  add    $0x1,%r12
  sub    $0x1,%r13d
  lea    (%r15,%r12,4),%r15
  lea    0x0(%rbp,%r12,8),%rbp
  cmp    $0x1,%r13d
  jle    L187
  cmp    $0x2,%r13d
  jne    L43
L188:
  movsd  0x0(%rbp),%xmm0
  comisd 0x8(%rbp),%xmm0
  ja     L52
L187:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L136:
  mov    %r12d,%ecx
  mov    %r14d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  movsd  0x0(%rbp),%xmm0
  movsd  (%rbx),%xmm1
  comisd %xmm1,%xmm0
  jbe    L88
  mov    %r14d,%ecx
  xor    %edx,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  movsd  (%rbx),%xmm1
  jmp    L153
  nopl   (%rax)
L89:
  mov    %r14d,%ecx
  xor    %edx,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  movsd  (%rbx),%xmm1
  jmp    L48
  nopl   0x0(%rax)
L208:
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <simultaneous_sort>
  jmp    L103
L194:
  movsd  0x8(%rbp),%xmm0
  movsd  0x0(%rbp),%xmm1
  comisd %xmm0,%xmm1
  ja     L7
L47:
  comisd 0x10(%rbp),%xmm0
  jbe    L187
  mov    $0x2,%ecx
  mov    $0x1,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  jmp    L188
L52:
  add    $0x18,%rsp
  mov    %r15,%rsi
  mov    %rbp,%rdi
  mov    $0x1,%ecx
  pop    %rbx
  xor    %edx,%edx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1050 <dual_swap@plt>
L7:
  mov    $0x1,%ecx
  xor    %edx,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <dual_swap@plt>
  movsd  0x8(%rbp),%xmm0
  jmp    L47
L97:
  ret
```

assistant: ```c
void simultaneous_sort(double *dist, int *idx, int size) {
  int pivot_idx, i, store_idx;
  double pivot_val;
  if (size <= 1)
    ;
  else if (size == 2) {
    if (dist[0] > dist[1])
      dual_swap(dist, idx, 0, 1);
  } else if (size == 3) {
    if (dist[0] > dist[1])
      dual_swap(dist, idx, 0, 1);
    if (dist[1] > dist[2]) {
      dual_swap(dist, idx, 1, 2);
      if (dist[0] > dist[1])
        dual_swap(dist, idx, 0, 1);
    }
  } else {
    pivot_idx = size / 2;
    if (dist[0] > dist[size - 1])
      dual_swap(dist, idx, 0, size - 1);
    if (dist[size - 1] > dist[pivot_idx]) {
      dual_swap(dist, idx, size - 1, pivot_idx);
      if (dist[0] > dist[size - 1])
        dual_swap(dist, idx, 0, size - 1);
    }
    pivot_val = dist[size - 1];
    store_idx = 0;
    for (i = 0; i < size - 1; i++) {
      if (dist[i] < pivot_val) {
        dual_swap(dist, idx, i, store_idx);
        store_idx++;
      }
    }
    dual_swap(dist, idx, store_idx, size - 1);
    pivot_idx = store_idx;
    if (pivot_idx > 1)
      simultaneous_sort(dist, idx, pivot_idx);
    if (pivot_idx * 2 < size)
      simultaneous_sort(dist + pivot_idx + 1, idx + pivot_idx + 1, size - pivot_idx - 1);
  }
}
```