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

```asm
<sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,-0x4c(%rbp)
  mov    %edx,%eax
  mov    %al,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpb   $0x78,-0x50(%rbp)
  jne    L38
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x30(%rbp)
  mov    -0x4c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movl   $0x0,-0x38(%rbp)
  jmp    L92
L38:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,-0x30(%rbp)
  mov    -0x4c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  movsd  0x8(%rax),%xmm0
  movsd  %xmm0,-0x28(%rbp)
  movl   $0x1,-0x38(%rbp)
L92:
  movsd  -0x28(%rbp),%xmm0
  comisd -0x30(%rbp),%xmm0
  jbe    L26
  movl   $0x1,-0x40(%rbp)
  jmp    L49
L61:
  movl   $0x1,-0x3c(%rbp)
  jmp    L47
L123:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jbe    L29
  movl   $0x0,-0x34(%rbp)
  jmp    L114
L183:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x34(%rbp),%eax
  cltq
  movsd  %xmm0,-0x20(%rbp,%rax,8)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  cltq
  movsd  -0x20(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rdx)
  addl   $0x1,-0x34(%rbp)
L114:
  cmpl   $0x2,-0x34(%rbp)
  jle    L183
L29:
  addl   $0x1,-0x3c(%rbp)
L47:
  mov    -0x4c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x3c(%rbp)
  jl     L123
  addl   $0x1,-0x40(%rbp)
L49:
  mov    -0x4c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x40(%rbp)
  jl     L61
  jmp    L102
L26:
  movl   $0x1,-0x40(%rbp)
  jmp    L33
L141:
  movl   $0x1,-0x3c(%rbp)
  jmp    L148
L20:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L10
  movl   $0x0,-0x34(%rbp)
  jmp    L48
L164:
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x34(%rbp),%eax
  cltq
  movsd  %xmm0,-0x20(%rbp,%rax,8)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rcx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x34(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    -0x34(%rbp),%eax
  cltq
  movsd  -0x20(%rbp,%rax,8),%xmm0
  movsd  %xmm0,(%rdx)
  addl   $0x1,-0x34(%rbp)
L48:
  cmpl   $0x2,-0x34(%rbp)
  jle    L164
L10:
  addl   $0x1,-0x3c(%rbp)
L148:
  mov    -0x4c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x3c(%rbp)
  jl     L20
  addl   $0x1,-0x40(%rbp)
L33:
  mov    -0x4c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x40(%rbp)
  jl     L141
L102:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L57
  call   <__stack_chk_fail@plt>
L57:
  leave
  ret
```

assistant: ```c
void sort(double **arr, int size, char u) {
  double temp[3];
  int i, j, k, l;
  double u0, u1;
  if (u == 'x') {
    u0 = arr[0][0];
    u1 = arr[size - 1][0];
    k = 0;
  } else {
    u0 = arr[0][1];
    u1 = arr[size - 1][1];
    k = 1;
  }
  if (u0 < u1) {
    for (i = 1; i < size - 1; ++i) {
      for (j = 1; j < size - 1; ++j) {
        if (arr[i][k] < arr[j][k]) {
          for (l = 0; l < 3; ++l) {
            temp[l] = arr[i][l];
            arr[i][l] = arr[j][l];
            arr[j][l] = temp[l];
          }
        }
      }
    }
  } else {
    for (i = 1; i < size - 1; ++i) {
      for (j = 1; j < size - 1; ++j) {
        if (arr[i][k] > arr[j][k]) {
          for (l = 0; l < 3; ++l) {
            temp[l] = arr[i][l];
            arr[i][l] = arr[j][l];
            arr[j][l] = temp[l];
          }
        }
      }
    }
  }
}
```