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

```asm
<ArraySort_Mix>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %rsi,%rbx
  mov    %rdx,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0xe8(%rsp)
  xor    %eax,%eax
  lea    -0x1(%rdi),%r15d
  movl   $0x0,0x18(%rsp)
  mov    $0x0,%r12d
  jmp    L39
L48:
  movslq %ecx,%rcx
  add    $0x1,%rcx
  mov    %rsi,(%rbx,%rcx,8)
  mov    %r9d,0x0(%rbp,%rcx,4)
  add    $0x1,%rdi
  add    $0x1,%r8d
  cmp    %edi,%r15d
  jl     L15
L138:
  mov    (%rbx,%rdi,8),%rsi
  mov    0x0(%rbp,%rdi,4),%r9d
  mov    %r8d,%ecx
  cmp    %r8d,%r12d
  jg     L48
  movslq %r8d,%rax
L151:
  mov    %eax,%ecx
  mov    (%rbx,%rax,8),%rdx
  cmp    %rsi,%rdx
  jle    L48
  mov    %rdx,0x8(%rbx,%rax,8)
  mov    0x0(%rbp,%rax,4),%edx
  mov    %edx,0x4(%rbp,%rax,4)
  lea    -0x1(%rax),%ecx
  sub    $0x1,%rax
  cmp    %eax,%r12d
  jle    L151
  jmp    L48
L15:
  mov    0x18(%rsp),%edi
  test   %edi,%edi
  je     L180
  lea    -0x1(%rdi),%eax
  movslq %edi,%rdx
  mov    0x20(%rsp,%rdx,4),%r15d
  sub    $0x2,%edi
  mov    %edi,0x18(%rsp)
  cltq
  mov    0x20(%rsp,%rax,4),%r12d
L39:
  mov    %r15d,%eax
  sub    %r12d,%eax
  cmp    $0x6,%eax
  jg     L60
  lea    0x1(%r12),%edi
  cmp    %edi,%r15d
  jl     L15
  movslq %edi,%rdi
  mov    %r12d,%r8d
  jmp    L138
L60:
  lea    (%r15,%r12,1),%edx
  sar    %edx
  movslq %edx,%rdx
  lea    (%rbx,%rdx,8),%rsi
  mov    (%rsi),%rdi
  movslq %r12d,%rax
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rcx
  lea    (%rbx,%rcx,1),%r11
  mov    (%r11),%r8
  mov    %r8,(%rsi)
  mov    %rdi,(%r11)
  lea    0x0(%rbp,%rdx,4),%rdx
  mov    (%rdx),%esi
  shl    $0x2,%rax
  lea    0x0(%rbp,%rax,1),%r10
  mov    %r10,0x10(%rsp)
  mov    (%r10),%edi
  mov    %edi,(%rdx)
  mov    %esi,(%r10)
  lea    -0x8(%rbx,%rcx,1),%rdx
  mov    (%rdx),%rdi
  movslq %r15d,%rsi
  lea    (%rbx,%rsi,8),%rcx
  mov    (%rcx),%r8
  cmp    %r8,%rdi
  jle    L238
  mov    %r8,(%rdx)
  mov    %rdi,(%rcx)
  lea    -0x4(%rbp,%rax,1),%r8
  mov    (%r8),%r9d
  lea    0x0(%rbp,%rsi,4),%rdi
  mov    (%rdi),%r10d
  mov    %r10d,(%r8)
  mov    %r9d,(%rdi)
L238:
  mov    (%r11),%rdi
  mov    (%rcx),%r8
  cmp    %r8,%rdi
  jle    L153
  mov    %r8,(%r11)
  mov    %rdi,(%rcx)
  mov    0x10(%rsp),%r10
  mov    (%r10),%edi
  lea    0x0(%rbp,%rsi,4),%rcx
  mov    (%rcx),%esi
  mov    %esi,(%r10)
  mov    %edi,(%rcx)
L153:
  mov    (%rdx),%rcx
  mov    (%r11),%rsi
  cmp    %rsi,%rcx
  jle    L9
  mov    %rsi,(%rdx)
  mov    %rcx,(%r11)
  lea    -0x4(%rbp,%rax,1),%rax
  mov    (%rax),%edx
  mov    0x10(%rsp),%rdi
  mov    (%rdi),%ecx
  mov    %ecx,(%rax)
  mov    %edx,(%rdi)
L9:
  mov    (%r11),%rdi
  mov    0x10(%rsp),%rax
  mov    (%rax),%eax
  mov    %eax,0x1c(%rsp)
  lea    0x2(%r12),%esi
  movslq %esi,%rsi
  mov    %r15d,%r13d
  jmp    L164
L87:
  add    $0x1,%rsi
L164:
  mov    %esi,0xc(%rsp)
  mov    (%rbx,%rsi,8),%r10
  cmp    %rdi,%r10
  jl     L87
  lea    -0x1(%r13),%eax
  cltq
  movslq %r13d,%r13
  lea    -0x8(%rbx,%r13,8),%rdx
L113:
  mov    %eax,%r14d
  mov    %eax,%r13d
  mov    %rdx,%r9
  mov    (%rdx),%rcx
  mov    %rax,%r8
  sub    $0x1,%rax
  sub    $0x8,%rdx
  cmp    %rdi,%rcx
  jg     L113
  cmp    %esi,%r14d
  jl     L189
  mov    %rcx,(%rbx,%rsi,8)
  mov    %r10,(%r9)
  mov    0x0(%rbp,%rsi,4),%edx
  lea    0x0(%rbp,%r8,4),%rax
  mov    (%rax),%ecx
  mov    %ecx,0x0(%rbp,%rsi,4)
  mov    %edx,(%rax)
  jmp    L87
L189:
  mov    %rcx,(%r11)
  mov    %rdi,(%r9)
  lea    0x0(%rbp,%r8,4),%rax
  mov    (%rax),%edx
  mov    0x10(%rsp),%rdi
  mov    %edx,(%rdi)
  mov    0x1c(%rsp),%edi
  mov    %edi,(%rax)
  mov    0x18(%rsp),%eax
  add    $0x2,%eax
  mov    %eax,0x10(%rsp)
  cmp    $0x32,%eax
  jg     L219
L109:
  mov    %r15d,%eax
  mov    0xc(%rsp),%edi
  sub    %edi,%eax
  add    $0x1,%eax
  sub    %r12d,%r13d
  cmp    %r13d,%eax
  jl     L47
  mov    0x10(%rsp),%esi
  movslq %esi,%rax
  mov    %r15d,0x20(%rsp,%rax,4)
  mov    0x18(%rsp),%eax
  add    $0x1,%eax
  cltq
  mov    %edi,0x20(%rsp,%rax,4)
  lea    -0x1(%r14),%r15d
  mov    %esi,0x18(%rsp)
  jmp    L39
L219:
  lea    D0(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  jmp    L109
L47:
  mov    0x10(%rsp),%edi
  movslq %edi,%rdx
  lea    -0x1(%r14),%eax
  mov    %eax,0x20(%rsp,%rdx,4)
  mov    0x18(%rsp),%eax
  add    $0x1,%eax
  cltq
  mov    %r12d,0x20(%rsp,%rax,4)
  mov    %edi,0x18(%rsp)
  mov    0xc(%rsp),%r12d
  jmp    L39
L180:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L85
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L85:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D0
datatype: string

tool: D0: Stack error: NSTACK too small


assistant: ```c
void ArraySort_Mix(int n, long *arr, int *brr) {
  int i, ir = n - 1, j, k, m = 0, jstack = 0, b, NSTACK = 50, istack[NSTACK];
  long a, temp, MIN = 7;
  for (;;) {
    if (ir - m < MIN) {
      for (j = m + 1; j <= ir; j++) {
        a = arr[j];
        b = brr[j];
        for (i = j - 1; i >= m; i--) {
          if (arr[i] <= a)
            break;
          arr[i + 1] = arr[i];
          brr[i + 1] = brr[i];
        }
        arr[i + 1] = a;
        brr[i + 1] = b;
      }
      if (!jstack)
        return;
      ir = istack[jstack--];
      m = istack[jstack--];
    } else {
      k = (m + ir) >> 1;
      temp = (arr[k]);
      (arr[k]) = arr[m + 1];
      (arr[m + 1]) = temp;
      ;
      temp = (brr[k]);
      (brr[k]) = brr[m + 1];
      (brr[m + 1]) = temp;
      ;
      if (arr[m] > arr[ir]) {
        temp = (arr[m]);
        (arr[m]) = arr[ir];
        (arr[ir]) = temp;
        ;
        temp = (brr[m]);
        (brr[m]) = brr[ir];
        (brr[ir]) = temp;
        ;
      }
      if (arr[m + 1] > arr[ir]) {
        temp = (arr[m + 1]);
        (arr[m + 1]) = arr[ir];
        (arr[ir]) = temp;
        ;
        temp = (brr[m + 1]);
        (brr[m + 1]) = brr[ir];
        (brr[ir]) = temp;
        ;
      }
      if (arr[m] > arr[m + 1]) {
        temp = (arr[m]);
        (arr[m]) = arr[m + 1];
        (arr[m + 1]) = temp;
        ;
        temp = (brr[m]);
        (brr[m]) = brr[m + 1];
        (brr[m + 1]) = temp;
        ;
      }
      i = m + 1;
      j = ir;
      a = arr[m + 1];
      b = brr[m + 1];
      for (;;) {
        do
          i++;
        while (arr[i] < a);
        do
          j--;
        while (arr[j] > a);
        if (j < i)
          break;
        temp = (arr[i]);
        (arr[i]) = arr[j];
        (arr[j]) = temp;
        ;
        temp = (brr[i]);
        (brr[i]) = brr[j];
        (brr[j]) = temp;
        ;
      }
      arr[m + 1] = arr[j];
      arr[j] = a;
      brr[m + 1] = brr[j];
      brr[j] = b;
      jstack += 2;
      if (jstack > NSTACK) {
        printf("Stack error: NSTACK too small\n");
        exit(0);
      }
      if (ir - i + 1 >= j - m) {
        istack[jstack] = ir;
        istack[jstack - 1] = i;
        ir = j - 1;
      } else {
        istack[jstack] = j - 1;
        istack[jstack - 1] = m;
        m = i;
      }
    }
  }
}
```