user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %r15
  xor    %edi,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  call   <time@plt>
  lea    D193(%rip),%rdi
  movslq %eax,%rbp
  cltd
  imul   $0x10624dd3,%rbp,%rbp
  sar    $0x26,%rbp
  sub    %edx,%ebp
  imul   $0x3e8,%ebp,%edx
  sub    %edx,%eax
  mov    %eax,%esi
  mov    %eax,%ebp
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebp,%edi
  call   <srand@plt>
  mov    $0x78,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  lea    0x78(%rax),%rbx
  mov    %rax,%r12
  nop
L423:
  xor    %eax,%eax
  add    $0x4,%r12
  call   <rand@plt>
  movslq %eax,%rdx
  mov    %eax,%ecx
  imul   $0x51eb851f,%rdx,%rdx
  sar    $0x1f,%ecx
  sar    $0x25,%rdx
  sub    %ecx,%edx
  imul   $0x64,%edx,%edx
  sub    %edx,%eax
  mov    %eax,-0x4(%r12)
  cmp    %r12,%rbx
  jne    L423
  lea    0x4(%rbp),%rax
  mov    $0x1d,%r13d
  movl   $0xe,0x28(%rsp)
  mov    $0x1,%r14d
  movl   $0x0,0x4(%rsp)
  lea    D8(%rip),%r12
  movq   $0x0,0x18(%rsp)
  mov    %rax,0x20(%rsp)
  nopl   0x0(%rax)
L67:
  mov    0x4(%rsp),%esi
  mov    %r13d,%ecx
  lea    D192(%rip),%rdi
  xor    %eax,%eax
  lea    0x0(%r13,%rsi,1),%ebx
  sar    %ebx
  mov    %ebx,%edx
  call   <printf@plt>
  mov    0x28(%rsp),%esi
  lea    D68(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  movslq %r13d,%rcx
  movslq %ebx,%rax
  lea    0x0(%rbp,%rax,4),%rax
  lea    0x0(%rbp,%rcx,4),%rdi
  mov    (%rax),%edx
  mov    (%rdi),%ecx
  cmp    %r13d,%ebx
  je     L227
  cmp    %ecx,%edx
  jle    L227
  mov    %ecx,(%rax)
  mov    %edx,%ecx
  mov    %edx,(%rdi)
L227:
  mov    0x18(%rsp),%rdx
  lea    0x0(,%rdx,4),%rsi
  lea    0x0(%rbp,%rsi,1),%r11
  mov    (%r11),%edx
  mov    %r11,0x10(%rsp)
  cmp    %ecx,%edx
  jle    L837
  cmp    0x4(%rsp),%r13d
  je     L837
  mov    %ecx,(%r11)
  mov    %edx,(%rdi)
  mov    (%r11),%edx
L837:
  mov    (%rax),%ecx
  cmp    0x4(%rsp),%ebx
  je     L513
  cmp    %edx,%ecx
  jle    L513
  mov    %edx,(%rax)
  mov    0x10(%rsp),%rdx
  mov    %ecx,(%rdx)
L513:
  cmp    %r14d,%ebx
  je     L703
  lea    0x4(%rbp,%rsi,1),%rdx
  mov    (%rax),%ecx
  mov    (%rdx),%esi
  mov    %esi,(%rax)
  mov    %ecx,(%rdx)
L703:
  mov    0x10(%rsp),%rax
  lea    D72(%rip),%rdi
  xor    %r15d,%r15d
  mov    (%rax),%ebx
  xor    %eax,%eax
  mov    %ebx,%esi
  call   <printf@plt>
  lea    D118(%rip),%rdi
  call   <puts@plt>
  mov    %ebx,0xc(%rsp)
  mov    %r15,%rbx
  mov    0x4(%rsp),%r15d
  mov    %r14d,0x8(%rsp)
  jmp    L61
  nopl   0x0(%rax,%rax,1)
L381:
  mov    0x0(%rbp,%rbx,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r13d,%r14d
  je     L136
  add    $0x1,%rbx
  cmp    $0x1e,%rbx
  je     L419
L61:
  mov    %ebx,%r14d
  cmp    %r15d,%ebx
  jne    L381
  lea    D6(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L381
  nopl   (%rax)
L136:
  lea    D180(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x1e,%rbx
  jne    L61
L419:
  mov    $0xa,%edi
  mov    0x8(%rsp),%r14d
  mov    0xc(%rsp),%ebx
  call   <putchar@plt>
  mov    0x4(%rsp),%ecx
  mov    0x10(%rsp),%rax
  cmp    %ecx,%r13d
  jl     L29
  mov    %r13d,%edx
  xor    %esi,%esi
  sub    %ecx,%edx
  mov    0x20(%rsp),%rcx
  add    0x18(%rsp),%rdx
  lea    (%rcx,%rdx,4),%rcx
  xor    %edx,%edx
  jmp    L536
  xchg   %ax,%ax
L154:
  add    $0x4,%rax
  add    $0x1,%edx
  cmp    %rax,%rcx
  je     L798
L536:
  cmp    %ebx,(%rax)
  jl     L154
  sete   %dil
  add    $0x4,%rax
  movzbl %dil,%edi
  add    %edi,%esi
  cmp    %rax,%rcx
  jne    L536
L798:
  mov    0x4(%rsp),%eax
  mov    %esi,0x2c(%rsp)
  add    %edx,%eax
  add    %eax,%esi
  mov    %eax,0xc(%rsp)
  cltq
  lea    0x0(%rbp,%rax,4),%rax
  mov    %esi,0x8(%rsp)
  mov    %rax,0x30(%rsp)
L792:
  movslq %r14d,%r10
  mov    %r13d,%r15d
  movslq %r13d,%rax
  mov    0x0(%rbp,%r10,4),%edi
  nopl   0x0(%rax)
L108:
  lea    0x0(%rbp,%rax,4),%rsi
  mov    (%rsi),%ecx
  cmp    %r15d,%r14d
  jg     L413
  cmp    %edi,%ebx
  jg     L645
L413:
  cmp    %ecx,%ebx
  jg     L641
  cmp    %r15d,%r14d
  jg     L657
  lea    -0x4(%rbp,%rax,4),%rax
  jmp    L463
  nopl   0x0(%rax,%rax,1)
L678:
  sub    $0x4,%rax
  cmp    %r15d,%r14d
  jg     L657
L463:
  mov    (%rax),%ecx
  sub    $0x1,%r15d
  mov    %rax,%rsi
  cmp    %ebx,%ecx
  jge    L678
L641:
  cmp    %r15d,%r14d
  jg     L657
  movslq %r15d,%rax
  je     L108
  lea    0x0(%rbp,%r10,4),%rdx
  mov    %ecx,(%rdx)
  mov    %edi,(%rsi)
  mov    (%rdx),%edi
  jmp    L108
  nopl   (%rax)
L645:
  add    $0x1,%r14d
  movslq %r14d,%r10
  mov    0x0(%rbp,%r10,4),%edi
  jmp    L108
  xchg   %ax,%ax
L657:
  cmp    0x4(%rsp),%r15d
  je     L45
  mov    0x10(%rsp),%rdx
  mov    (%rdx),%eax
  mov    %ecx,(%rdx)
  mov    %eax,(%rsi)
L45:
  lea    D65(%rip),%rdi
  xor    %r14d,%r14d
  call   <puts@plt>
  mov    %ebx,0x38(%rsp)
  mov    %r14,%rbx
  jmp    L466
  nopw   0x0(%rax,%rax,1)
L292:
  cmp    %r15d,%r14d
  je     L684
L283:
  mov    0x0(%rbp,%rbx,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r13d,%r14d
  je     L386
  add    $0x1,%rbx
  cmp    $0x1e,%rbx
  je     L199
L466:
  mov    %ebx,%r14d
  cmp    0x4(%rsp),%ebx
  jne    L292
  xor    %eax,%eax
  lea    D6(%rip),%rdi
  call   <printf@plt>
  cmp    %r15d,%r14d
  jne    L283
  xchg   %ax,%ax
L684:
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L283
  nopl   0x0(%rax)
L386:
  lea    D180(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x1e,%rbx
  jne    L466
  nopl   0x0(%rax,%rax,1)
L199:
  mov    $0xa,%edi
  mov    0x38(%rsp),%ebx
  call   <putchar@plt>
  mov    0xc(%rsp),%edx
  cmp    %edx,0x4(%rsp)
  jge    L602
  mov    0xc(%rsp),%eax
  mov    0x20(%rsp),%rdx
  mov    %rbp,0x38(%rsp)
  sub    0x4(%rsp),%eax
  mov    0x10(%rsp),%r14
  sub    $0x1,%eax
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%rax
  mov    %r14,%rbp
  mov    %rax,%r14
  nopl   0x0(%rax)
L607:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp)
  setl   %dil
  add    $0x4,%rbp
  call   <assert@plt>
  cmp    %rbp,%r14
  jne    L607
  mov    0x38(%rsp),%rbp
L602:
  movslq 0xc(%rsp),%r14
  cmp    %r14d,%r13d
  jl     L823
  xchg   %ax,%ax
L260:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp,%r14,4)
  setge  %dil
  add    $0x1,%r14
  call   <assert@plt>
  cmp    %r14d,%r13d
  jge    L260
L823:
  mov    0x30(%rsp),%rax
  mov    0xc(%rsp),%edi
  mov    %r13d,%ecx
  mov    (%rax),%r9d
  movslq %r13d,%rax
  nopl   0x0(%rax,%rax,1)
L237:
  lea    0x0(%rbp,%rax,4),%rsi
  mov    (%rsi),%edx
  cmp    %r9d,%ebx
  jne    L454
  cmp    0x8(%rsp),%edi
  jl     L541
L454:
  cmp    %edx,%ebx
  jge    L43
  cmp    %ecx,%edi
  jg     L523
  lea    -0x4(%rbp,%rax,4),%rax
  jmp    L887
  nopl   0x0(%rax)
L808:
  sub    $0x4,%rax
  cmp    %ecx,%edi
  jg     L523
L887:
  mov    (%rax),%edx
  sub    $0x1,%ecx
  mov    %rax,%rsi
  cmp    %ebx,%edx
  jg     L808
L43:
  cmp    %ecx,%edi
  jg     L523
  movslq %ecx,%rax
  je     L237
  movslq %edi,%r8
  lea    0x0(%rbp,%r8,4),%r8
  mov    %edx,(%r8)
  mov    %r9d,(%rsi)
  mov    (%r8),%r9d
  jmp    L237
  nopl   0x0(%rax,%rax,1)
L541:
  add    $0x1,%edi
  movslq %edi,%rdx
  mov    0x0(%rbp,%rdx,4),%r9d
  jmp    L237
  nopl   (%rax)
L523:
  lea    D208(%rip),%rdi
  xor    %r14d,%r14d
  call   <puts@plt>
  mov    %ebx,0x30(%rsp)
  mov    %r14,%rbx
  jmp    L464
  nopl   0x0(%rax,%rax,1)
L273:
  cmp    %r14d,%r15d
  je     L554
L185:
  mov    0x0(%rbp,%rbx,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r13d,%r14d
  je     L149
  add    $0x1,%rbx
  cmp    $0x1e,%rbx
  je     L426
L464:
  mov    %ebx,%r14d
  cmp    0x4(%rsp),%ebx
  jne    L273
  xor    %eax,%eax
  lea    D6(%rip),%rdi
  call   <printf@plt>
  cmp    %r14d,%r15d
  jne    L185
  xchg   %ax,%ax
L554:
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L185
  nopl   0x0(%rax)
L149:
  lea    D180(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x1e,%rbx
  jne    L464
  nopl   0x0(%rax,%rax,1)
L426:
  mov    $0xa,%edi
  mov    0x30(%rsp),%ebx
  call   <putchar@plt>
  mov    0xc(%rsp),%edx
  cmp    %edx,0x4(%rsp)
  jge    L860
  mov    0xc(%rsp),%eax
  mov    0x20(%rsp),%rdx
  sub    0x4(%rsp),%eax
  mov    0x10(%rsp),%r14
  sub    $0x1,%eax
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%r15
  cs nopw 0x0(%rax,%rax,1)
L621:
  xor    %edi,%edi
  cmp    %ebx,(%r14)
  setl   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r14,%r15
  jne    L621
L860:
  mov    0x8(%rsp),%edx
  cmp    %edx,0xc(%rsp)
  jge    L640
  mov    0x8(%rsp),%eax
  movslq 0xc(%rsp),%rcx
  mov    0x20(%rsp),%rdx
  sub    $0x1,%eax
  lea    0x0(%rbp,%rcx,4),%r14
  sub    %ecx,%eax
  add    %rcx,%rax
  lea    (%rdx,%rax,4),%r15
L590:
  xor    %edi,%edi
  cmp    %ebx,(%r14)
  sete   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r14,%r15
  jne    L590
L640:
  movslq 0x8(%rsp),%rdx
  mov    $0x1e,%r15d
  mov    %rdx,0x30(%rsp)
  sub    %edx,%r15d
  mov    %rdx,%r14
  cmp    %edx,%r13d
  jl     L11
  cs nopw 0x0(%rax,%rax,1)
L184:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp,%r14,4)
  setg   %dil
  add    $0x1,%r14
  call   <assert@plt>
  cmp    %r14d,%r13d
  jge    L184
  mov    0xc(%rsp),%r14d
  mov    0x2c(%rsp),%edx
  xor    %eax,%eax
  mov    %r15d,%ecx
  lea    D131(%rip),%rdi
  mov    %r14d,%esi
  call   <printf@plt>
  mov    0x8(%rsp),%ebx
  xor    %eax,%eax
  mov    %r13d,%edx
  lea    D39(%rip),%rdi
  mov    %ebx,%esi
  call   <printf@plt>
  cmp    %r15d,%ebx
  jl     L827
  cmp    %r15d,%r14d
  jl     L714
L827:
  mov    0xc(%rsp),%edx
  cmp    %edx,0x28(%rsp)
  jl     L662
  mov    0x8(%rsp),%edx
  cmp    %edx,0x28(%rsp)
  jl     L751
  lea    D156(%rip),%rdi
  call   <puts@plt>
  movslq 0x8(%rsp),%rax
  lea    0x0(%rbp,%rax,4),%rcx
  mov    %eax,0x4(%rsp)
  mov    %rcx,0x10(%rsp)
  mov    %rax,0x18(%rsp)
L153:
  mov    0x4(%rsp),%eax
  lea    0x1(%rax),%r14d
  cmp    %r13d,%r14d
  jl     L67
  mov    %r13d,%eax
  je     L706
L457:
  mov    0x18(%rsp),%rax
  lea    D89(%rip),%rdi
  xor    %r13d,%r13d
  lea    0x0(%rbp,%rax,4),%rbx
  mov    (%rbx),%r15d
  call   <puts@plt>
  mov    0x4(%rsp),%r14d
  jmp    L478
  nopl   0x0(%rax,%rax,1)
L801:
  mov    0x0(%rbp,%r13,4),%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%r13
  call   <printf@plt>
  cmp    $0x1e,%r13
  je     L493
L478:
  cmp    %r13d,%r14d
  jne    L801
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L801
L662:
  mov    %edx,%r13d
  lea    D30(%rip),%rdi
  sub    $0x1,%r13d
  call   <puts@plt>
  jmp    L153
L11:
  mov    0x2c(%rsp),%edx
  mov    0xc(%rsp),%esi
  mov    %r15d,%ecx
  xor    %eax,%eax
  lea    D131(%rip),%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%esi
  mov    %r13d,%edx
  xor    %eax,%eax
  lea    D39(%rip),%rdi
  call   <printf@plt>
  jmp    L827
L29:
  mov    %rax,0x30(%rsp)
  mov    0x4(%rsp),%eax
  movl   $0x0,0x2c(%rsp)
  mov    %eax,0x8(%rsp)
  mov    %eax,0xc(%rsp)
  jmp    L792
L493:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L637
  mov    0x4(%rsp),%eax
  mov    0x20(%rsp),%rdx
  mov    %rbp,%r14
  sub    $0x1,%eax
  lea    (%rdx,%rax,4),%r13
L512:
  xor    %edi,%edi
  cmp    %r15d,(%r14)
  setl   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r14,%r13
  jne    L512
  cmpl   $0x1d,0x4(%rsp)
  jg     L224
L637:
  mov    0x20(%rsp),%rdx
  mov    $0x1d,%eax
  sub    0x4(%rsp),%eax
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%r13
L848:
  xor    %edi,%edi
  cmp    %r15d,(%rbx)
  setge  %dil
  add    $0x4,%rbx
  call   <assert@plt>
  cmp    %rbx,%r13
  jne    L848
L224:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x48,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L714:
  mov    0x8(%rsp),%ebx
  lea    D147(%rip),%rdi
  xor    %eax,%eax
  mov    %ebx,%esi
  call   <printf@plt>
  mov    0x30(%rsp),%rax
  mov    %ebx,0x28(%rsp)
  mov    %ebx,0x4(%rsp)
  lea    0x0(%rbp,%rax,4),%rax
  mov    %rax,0x10(%rsp)
  movslq %ebx,%rax
  mov    %rax,0x18(%rsp)
  jmp    L153
L706:
  cltq
  mov    0x10(%rsp),%rdi
  mov    %rax,%rsi
  lea    0x0(%rbp,%rax,4),%rax
  mov    (%rdi),%edx
  mov    (%rax),%ecx
  cmp    %edx,%ecx
  jge    L457
  mov    0x4(%rsp),%ebx
  cmp    %ebx,%esi
  je     L457
  mov    %ecx,(%rdi)
  mov    %edx,(%rax)
  jmp    L457
L751:
  lea    D34(%rip),%rdi
  call   <puts@plt>
  movslq 0xc(%rsp),%rax
  mov    %eax,0x4(%rsp)
  mov    %rax,0x18(%rsp)
  jmp    L457
```

tool_calls: name: disassemble_data
arguments: tag: D193
type: string
name: disassemble_data
arguments: tag: D8
type: string
name: disassemble_data
arguments: tag: D192
type: string
name: disassemble_data
arguments: tag: D68
type: string
name: disassemble_data
arguments: tag: D72
type: string
name: disassemble_data
arguments: tag: D118
type: string
name: disassemble_data
arguments: tag: D6
type: string
name: disassemble_data
arguments: tag: D180
type: string
name: disassemble_data
arguments: tag: D65
type: string
name: disassemble_data
arguments: tag: D208
type: string
name: disassemble_data
arguments: tag: D131
type: string
name: disassemble_data
arguments: tag: D39
type: string
name: disassemble_data
arguments: tag: D156
type: string
name: disassemble_data
arguments: tag: D89
type: string
name: disassemble_data
arguments: tag: D30
type: string
name: disassemble_data
arguments: tag: D147
type: string
name: disassemble_data
arguments: tag: D34
type: string

tool: D193: t=%i


tool: D8: %i 

tool: D192: low=%i, middle=%i, high=%i.


tool: D68: median=%i


tool: D72: middle value: %i


tool: D118: beginning:

tool: D6: ( 

tool: D180: ) 

tool: D65: after swapping middle value back into place:

tool: D208: after collecting equal items:

tool: D131: nl=%i, ne=%i, nh=%i.


tool: D39: greater=%i, high=%i.


tool: D156: median is in high partition.

tool: D89: end:

tool: D30: median is in low partition.

tool: D147: Changed "median" to %i.


tool: D34: median is in middle partition.

assistant: ```c
int main() {
  int *arr;
  int N = 30;
  int mx = 100;
  int i;
  int L = 0;
  int R = N - 1;
  time_t t;
  t = time(NULL);
  t = t % 1000;
  printf("t=%i\n", (int)t);
  srand(t);
  arr = malloc(N * sizeof(int));
  for (i = 0; i < N; i++)
    arr[i] = rand() % mx;
  {
    int low, high, median, middle, ll, hh;
    int nless, nequal;
    int equal, greater;
    int midval;
    int midpos;
    low = L;
    high = R;
    median = (low + high) / 2;
    while (1) {
      if (high <= (low + 1))
        break;
      middle = (low + high) / 2;
      printf("low=%i, middle=%i, high=%i.\n", low, middle, high);
      printf("median=%i\n", median);
      if ((arr[(middle)]) > (arr[(high)])) {
        if ((middle) != (high)) {
          int tmp = arr[(middle)];
          arr[(middle)] = arr[(high)];
          arr[(high)] = tmp;
        }
      };
      if ((arr[(low)]) > (arr[(high)])) {
        if ((low) != (high)) {
          int tmp = arr[(low)];
          arr[(low)] = arr[(high)];
          arr[(high)] = tmp;
        }
      };
      if ((arr[(middle)]) > (arr[(low)])) {
        if ((middle) != (low)) {
          int tmp = arr[(middle)];
          arr[(middle)] = arr[(low)];
          arr[(low)] = tmp;
        }
      };
      {
        if ((middle) != (low + 1)) {
          int tmp = arr[(middle)];
          arr[(middle)] = arr[(low + 1)];
          arr[(low + 1)] = tmp;
        }
      };
      midval = (arr[(low)]);
      printf("middle value: %i\n", midval);
      printf("beginning:\n");
      for (i = L; i <= R; i++) {
        if (i == low)
          printf("( ");
        printf("%i ", (arr[(i)]));
        if (i == high)
          printf(") ");
      }
      printf("\n");
      nless = nequal = 0;
      for (i = low; i <= high; i++) {
        if ((arr[(i)]) < midval)
          nless++;
        else if ((arr[(i)]) == midval)
          nequal++;
      }
      equal = low + nless;
      greater = equal + nequal;
      ll = low + 1;
      hh = high;
      for (;;) {
        while (((arr[(ll)]) < midval) && (ll <= hh))
          ll++;
        while (((arr[(hh)]) >= midval) && (ll <= hh))
          hh--;
        if (hh < ll)
          break;
        {
          if ((ll) != (hh)) {
            int tmp = arr[(ll)];
            arr[(ll)] = arr[(hh)];
            arr[(hh)] = tmp;
          }
        };
      }
      {
        if ((low) != (hh)) {
          int tmp = arr[(low)];
          arr[(low)] = arr[(hh)];
          arr[(hh)] = tmp;
        }
      };
      midpos = hh;
      printf("after swapping middle value back into place:\n");
      for (i = L; i <= R; i++) {
        if (i == low)
          printf("( ");
        if (i == midpos)
          printf("*");
        printf("%i ", (arr[(i)]));
        if (i == high)
          printf(") ");
      }
      printf("\n");
      for (i = low; i < equal; i++)
        assert((arr[(i)]) < midval);
      for (i = equal; i <= high; i++)
        assert((arr[(i)]) >= midval);
      ll = equal;
      hh = high;
      for (;;) {
        while (((arr[(ll)]) == midval) && (ll < greater))
          ll++;
        while (((arr[(hh)]) > midval) && (hh >= ll))
          hh--;
        if (hh < ll)
          break;
        {
          if ((ll) != (hh)) {
            int tmp = arr[(ll)];
            arr[(ll)] = arr[(hh)];
            arr[(hh)] = tmp;
          }
        };
      }
      printf("after collecting equal items:\n");
      for (i = L; i <= R; i++) {
        if (i == low)
          printf("( ");
        if (i == midpos)
          printf("*");
        printf("%i ", (arr[(i)]));
        if (i == high)
          printf(") ");
      }
      printf("\n");
      for (i = low; i < equal; i++)
        assert((arr[(i)]) < midval);
      for (i = equal; i < greater; i++)
        assert((arr[(i)]) == midval);
      for (i = greater; i <= high; i++)
        assert((arr[(i)]) > midval);
      {
        int nl = equal - L;
        int nh = R + 1 - greater;
        printf("nl=%i, ne=%i, nh=%i.\n", nl, nequal, nh);
        printf("greater=%i, high=%i.\n", greater, high);
        if ((greater <= high) && (nh > nl) && (nl + nequal >= nh)) {
          median = greater;
          printf("Changed \"median\" to %i.\n", median);
          low = greater;
          continue;
        }
      }
      if (median < equal) {
        high = equal - 1;
        printf("median is in low partition.\n");
      } else if (median < greater) {
        low = high = equal;
        printf("median is in middle partition.\n");
        break;
      } else {
        low = greater;
        printf("median is in high partition.\n");
      }
    }
    if (high == low + 1) {
      if ((arr[(low)]) > (arr[(high)])) {
        if ((low) != (high)) {
          int tmp = arr[(low)];
          arr[(low)] = arr[(high)];
          arr[(high)] = tmp;
        }
      };
    }
    median = low;
    midval = (arr[(median)]);
    printf("end:\n");
    for (i = L; i <= R; i++) {
      if (i == median)
        printf("*");
      printf("%i ", (arr[(i)]));
    }
    printf("\n");
    for (i = L; i < median; i++) {
      assert((arr[(i)]) < midval);
    }
    for (i = median; i <= R; i++) {
      assert((arr[(i)]) >= midval);
    }
  }
  free(arr);
  return 0;
}
```