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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%ebp
  mov    %rsi,%r12
  mov    $0x0,%edi
  call   <time@plt>
  mov    %eax,%edi
  call   <srand@plt>
  test   %ebp,%ebp
  jle    L154
  mov    %ebp,%ebp
  mov    $0x0,%ebx
  lea    D48(%rip),%r13
L14:
  mov    (%r12,%rbx,8),%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L14
L154:
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    D58(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%r12),%rdi
  call   <atoi@plt>
  mov    %eax,%ebp
  mov    0x10(%r12),%rdi
  call   <atoi@plt>
  mov    %eax,%ebx
  mov    %eax,%edx
  mov    %ebp,%esi
  lea    D3(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %ebx,%edx
  mov    %ebp,%esi
  mov    $0xa,%edi
  call   <vrandi@plt>
  mov    %rax,%r12
  test   %ebx,%ebx
  jle    L198
  mov    %rax,%rbp
  lea    -0x1(%rbx),%eax
  lea    0x4(%r12,%rax,4),%r14
  lea    D49(%rip),%r13
L167:
  mov    0x0(%rbp),%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x4,%rbp
  cmp    %r14,%rbp
  jne    L167
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    0x0(,%rbx,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %rax,%rdx
  mov    $0x0,%eax
L107:
  mov    %eax,(%rdx)
  add    $0x1,%eax
  add    $0x4,%rdx
  cmp    %eax,%ebx
  jne    L107
  mov    %ebx,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <iquicksort_I@plt>
  lea    0x0(,%rbx,8),%r14d
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  mov    %rax,%r13
  mov    %r14d,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,%r11
  mov    (%r12),%ecx
  cmp    $0x1,%ebx
  jle    L192
  mov    %ebx,%r10d
  mov    $0x1,%eax
  mov    $0x0,%esi
  mov    $0x0,%edx
  movsd  D51(%rip),%xmm1
  lea    0x8(%rdi),%r15
  jmp    L39
L68:
  lea    0x2(%rdx,%rsi,1),%ecx
  pxor   %xmm0,%xmm0
  cvtsi2sd %ecx,%xmm0
  mulsd  %xmm1,%xmm0
  cmp    %eax,%edx
  jge    L73
  movslq %edx,%r14
  lea    (%rdi,%r14,8),%rcx
  sub    %edx,%r9d
  lea    -0x1(%r9),%edx
  add    %r14,%rdx
  lea    (%r15,%rdx,8),%rdx
L111:
  movsd  %xmm0,(%rcx)
  add    $0x8,%rcx
  cmp    %rdx,%rcx
  jne    L111
L73:
  mov    (%r12,%rax,4),%ecx
  mov    %r8d,%edx
L36:
  add    $0x1,%esi
  add    $0x1,%rax
  cmp    %r10,%rax
  je     L23
L39:
  mov    %eax,%r9d
  mov    %eax,%r8d
  cmp    %ecx,(%r12,%rax,4)
  je     L36
  cmp    %edx,%esi
  jg     L68
  movslq %edx,%rcx
  add    $0x1,%edx
  pxor   %xmm0,%xmm0
  cvtsi2sd %edx,%xmm0
  movsd  %xmm0,(%r11,%rcx,8)
  jmp    L73
L23:
  lea    -0x1(%rbx),%esi
  mov    %ebx,%eax
  cmp    %esi,%edx
  je     L177
  lea    0x2(%rdx,%rsi,1),%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  D51(%rip),%xmm0
  cmp    %ebx,%edx
  jge    L58
  movslq %edx,%rax
  lea    (%rdi,%rax,8),%rax
L171:
  movsd  %xmm0,(%rax)
  mov    %edx,%ecx
  add    $0x1,%edx
  add    $0x8,%rax
  cmp    %ecx,%esi
  jg     L171
L58:
  mov    %rdi,%rax
  mov    %ebx,%ebx
  shl    $0x3,%rbx
  add    %rbx,%rdi
L187:
  movsd  (%rax),%xmm0
  movslq 0x0(%rbp),%rdx
  movsd  %xmm0,0x0(%r13,%rdx,8)
  add    $0x4,%rbp
  add    $0x8,%rax
  cmp    %rax,%rdi
  jne    L187
  lea    D7(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%rsp),%rax
  mov    %rax,%rbp
  add    %rax,%rbx
  lea    D85(%rip),%r12
L194:
  movsd  0x0(%rbp),%xmm0
  mov    %r12,%rdi
  mov    $0x1,%eax
  call   <printf@plt>
  add    $0x8,%rbp
  cmp    %rbp,%rbx
  jne    L194
L162:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L192:
  mov    $0x1,%eax
  mov    $0x0,%esi
  jmp    L177
L198:
  mov    $0xa,%edi
  call   <putchar@plt>
  lea    0x0(,%rbx,4),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %ebx,%edx
  mov    %rax,%rsi
  mov    %r12,%rdi
  call   <iquicksort_I@plt>
  lea    0x0(,%rbx,8),%r12d
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  mov    %rax,%r13
  mov    %r12d,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,%r11
  mov    $0x1,%eax
  mov    $0x0,%esi
L177:
  movslq %esi,%rsi
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  %xmm0,(%r11,%rsi,8)
  test   %ebx,%ebx
  jg     L58
  lea    D7(%rip),%rdi
  call   <puts@plt>
  jmp    L162
```

tool_calls: name: retrieve_data
arguments: tag: D48
datatype: string
name: retrieve_data
arguments: tag: D58
datatype: string
name: retrieve_data
arguments: tag: D3
datatype: string
name: retrieve_data
arguments: tag: D49
datatype: string
name: retrieve_data
arguments: tag: D51
datatype: byte[8]
name: retrieve_data
arguments: tag: D7
datatype: string
name: retrieve_data
arguments: tag: D85
datatype: string

tool: D48: argv[%d]: %s   

tool: D58: breaking ties with average rank

tool: D3: random vector:  max: %d   n: %d


tool: D49: %d    

tool: {"D51": [0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f]}

tool: D7: reorder ranks into original order of vector:

tool: D85: %.1f   

assistant: ```c
int main(int argc, char *argv[]) {
  srand(time(NULL));
  for (int i = 0; i < argc; ++i)
    printf("argv[%d]: %s   ", i, argv[i]);
  putchar('\n');
  printf("breaking ties with average rank\n");
  int max = atoi(argv[1]);
  int n = atoi(argv[2]);
  printf("random vector:  max: %d   n: %d\n", max, n);
  int *x = vrandi(10, max, n);
  for (int i = 0; i < n; ++i)
    printf("%d    ", x[i]);
  putchar('\n');
  int *indx = (int *)malloc(n * sizeof(int));
  for (int i = 0; i < n; ++i)
    indx[i] = i;
  iquicksort_I(x, indx, n);
  double *result = (double *)malloc(n * sizeof(double));
  double *ranks = (double *)malloc(n * sizeof(double));
  int b = x[0];
  int ib = 0;
  int i;
  for (i = 1; i < n; ++i) {
    if (x[i] != b) {
      if (ib < i - 1) {
        double rnk = (i - 1 + ib + 2) / 2.0;
        for (int j = ib; j <= i - 1; ++j)
          ranks[j] = rnk;
      } else {
        ranks[ib] = ib + 1;
      }
      b = x[i];
      ib = i;
    }
  }
  if (ib == i - 1)
    ranks[ib] = i;
  else {
    double rnk = (i - 1 + ib + 2) / 2.0;
    for (int j = ib; j <= i - 1; ++j)
      ranks[j] = rnk;
  }
  for (int i = 0; i < n; ++i)
    result[indx[i]] = ranks[i];
  printf("reorder ranks into original order of vector:\n");
  for (int i = 0; i < n; ++i)
    printf("%.1f   ", result[i]);
  putchar('\n');
}
```