user: What would the C source look like for the assembly code provided here:

```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    D94(%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
L969:
  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    L969
  lea    0x4(%rbp),%rax
  mov    $0x1d,%r13d
  movl   $0xe,0x2c(%rsp)
  mov    $0x1,%r14d
  movl   $0x0,0x4(%rsp)
  lea    D122(%rip),%r12
  movq   $0x0,0x18(%rsp)
  mov    %rax,0x20(%rsp)
  nopl   0x0(%rax)
L663:
  mov    0x4(%rsp),%esi
  mov    %r13d,%ecx
  lea    D215(%rip),%rdi
  lea    0x0(%r13,%rsi,1),%eax
  sar    %eax
  mov    %eax,%edx
  mov    %eax,%r15d
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x2c(%rsp),%esi
  lea    D116(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  movslq %r13d,%rdx
  movslq %r15d,%rax
  lea    0x0(%rbp,%rax,4),%rax
  lea    0x0(%rbp,%rdx,4),%rsi
  mov    (%rax),%ecx
  mov    (%rsi),%edx
  cmp    %r13d,%r15d
  je     L692
  cmp    %edx,%ecx
  jle    L692
  mov    %edx,(%rax)
  mov    %ecx,%edx
  mov    %ecx,(%rsi)
L692:
  mov    0x18(%rsp),%rcx
  shl    $0x2,%rcx
  lea    0x0(%rbp,%rcx,1),%rdi
  mov    (%rdi),%ebx
  mov    %rdi,0x10(%rsp)
  cmp    %edx,%ebx
  jle    L708
  cmp    0x4(%rsp),%r13d
  je     L708
  mov    %edx,(%rdi)
  mov    %ebx,(%rsi)
  mov    (%rdi),%ebx
L708:
  mov    (%rax),%edx
  cmp    0x4(%rsp),%r15d
  je     L951
  cmp    %ebx,%edx
  jle    L951
  mov    0x10(%rsp),%rdi
  mov    %ebx,(%rax)
  mov    %edx,%ebx
  mov    %edx,(%rdi)
L951:
  cmp    %r14d,%r15d
  je     L825
  lea    0x4(%rbp,%rcx,1),%rdx
  mov    (%rax),%esi
  mov    (%rdx),%ecx
  mov    %ecx,(%rax)
  mov    0x10(%rsp),%rax
  mov    %esi,(%rdx)
  mov    (%rax),%ebx
L825:
  mov    %ebx,%esi
  lea    D229(%rip),%rdi
  xor    %eax,%eax
  xor    %r15d,%r15d
  call   <printf@plt>
  lea    D4(%rip),%rdi
  call   <puts@plt>
  mov    %r14d,0xc(%rsp)
  mov    %r15,%r14
  mov    0x4(%rsp),%r15d
  mov    %ebx,0x8(%rsp)
  jmp    L152
  nopw   0x0(%rax,%rax,1)
L630:
  mov    0x0(%rbp,%r14,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r13d,%ebx
  je     L267
  add    $0x1,%r14
  cmp    $0x1e,%r14
  je     L857
L152:
  mov    %r14d,%ebx
  cmp    %r15d,%r14d
  jne    L630
  lea    D32(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L630
  cs nopw 0x0(%rax,%rax,1)
L267:
  lea    D92(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%r14
  call   <printf@plt>
  cmp    $0x1e,%r14
  jne    L152
  nopl   0x0(%rax,%rax,1)
L857:
  mov    $0xa,%edi
  mov    0x8(%rsp),%ebx
  mov    0xc(%rsp),%r14d
  call   <putchar@plt>
  mov    0x4(%rsp),%edx
  cmp    %edx,%r13d
  jl     L493
  mov    %r13d,%eax
  sub    %edx,%eax
  lea    0x1(%rax),%ecx
  cmp    $0x2,%eax
  jbe    L291
  mov    %ecx,%edx
  mov    0x10(%rsp),%rdi
  pxor   %xmm3,%xmm3
  movd   %ebx,%xmm7
  pshufd $0x0,%xmm7,%xmm4
  shr    $0x2,%edx
  movdqa %xmm3,%xmm2
  movdqa %xmm3,%xmm5
  sub    $0x1,%edx
  mov    %rdi,%rax
  shl    $0x4,%rdx
  lea    0x10(%rdi,%rdx,1),%rdx
  nop
L115:
  movdqu (%rax),%xmm6
  movdqa %xmm4,%xmm1
  add    $0x10,%rax
  pcmpgtd %xmm6,%xmm1
  movdqa %xmm6,%xmm0
  pcmpeqd %xmm4,%xmm0
  psubd  %xmm1,%xmm2
  pcmpeqd %xmm5,%xmm1
  pand   %xmm1,%xmm0
  psubd  %xmm0,%xmm3
  cmp    %rax,%rdx
  jne    L115
  movdqa %xmm3,%xmm0
  mov    0x4(%rsp),%edx
  mov    %ecx,%esi
  psrldq $0x8,%xmm0
  and    $0xfffffffc,%esi
  paddd  %xmm0,%xmm3
  add    %esi,%edx
  movdqa %xmm3,%xmm0
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm3
  movdqa %xmm2,%xmm0
  psrldq $0x8,%xmm0
  movd   %xmm3,0x28(%rsp)
  paddd  %xmm0,%xmm2
  movdqa %xmm2,%xmm0
  psrldq $0x4,%xmm0
  paddd  %xmm0,%xmm2
  movd   %xmm2,%eax
  cmp    %esi,%ecx
  je     L295
L57:
  movslq %edx,%rcx
  lea    0x0(,%rcx,4),%rsi
  cmp    %ebx,0x0(%rbp,%rcx,4)
  jge    L450
  add    $0x1,%eax
L315:
  lea    0x1(%rdx),%ecx
  cmp    %ecx,%r13d
  jl     L295
  cmp    0x4(%rbp,%rsi,1),%ebx
  jle    L518
  add    $0x1,%eax
L190:
  add    $0x2,%edx
  cmp    %r13d,%edx
  jg     L295
  cmp    0x8(%rbp,%rsi,1),%ebx
  jg     L806
  sete   %dl
  movzbl %dl,%edx
  add    %edx,0x28(%rsp)
L295:
  mov    0x28(%rsp),%edx
  add    0x4(%rsp),%eax
  mov    %eax,0xc(%rsp)
  add    %eax,%edx
  cltq
  lea    0x0(%rbp,%rax,4),%rax
  mov    %edx,0x8(%rsp)
  mov    %rax,0x30(%rsp)
L532:
  movslq %r14d,%r10
  mov    %r13d,%r15d
  movslq %r13d,%rax
  mov    0x0(%rbp,%r10,4),%edi
  nop
L85:
  lea    0x0(%rbp,%rax,4),%rsi
  mov    (%rsi),%ecx
  cmp    %r15d,%r14d
  jg     L541
  cmp    %edi,%ebx
  jg     L832
L541:
  cmp    %ecx,%ebx
  jg     L334
  cmp    %r15d,%r14d
  jg     L788
  lea    -0x4(%rbp,%rax,4),%rax
  jmp    L377
L113:
  sub    $0x4,%rax
  cmp    %r15d,%r14d
  jg     L788
L377:
  mov    (%rax),%ecx
  sub    $0x1,%r15d
  mov    %rax,%rsi
  cmp    %ebx,%ecx
  jge    L113
L334:
  cmp    %r15d,%r14d
  jg     L788
  movslq %r15d,%rax
  je     L85
  lea    0x0(%rbp,%r10,4),%rdx
  mov    %ecx,(%rdx)
  mov    %edi,(%rsi)
  mov    (%rdx),%edi
  jmp    L85
  nopl   (%rax)
L832:
  add    $0x1,%r14d
  movslq %r14d,%r10
  mov    0x0(%rbp,%r10,4),%edi
  jmp    L85
  xchg   %ax,%ax
L788:
  cmp    0x4(%rsp),%r15d
  je     L141
  mov    0x10(%rsp),%rdx
  mov    (%rdx),%eax
  mov    %ecx,(%rdx)
  mov    %eax,(%rsi)
L141:
  lea    D129(%rip),%rdi
  xor    %r14d,%r14d
  call   <puts@plt>
  mov    %ebx,0x38(%rsp)
  mov    %r14,%rbx
  jmp    L269
  nopw   0x0(%rax,%rax,1)
L842:
  cmp    %r14d,%r15d
  je     L177
L919:
  mov    0x0(%rbp,%rbx,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r13d,%r14d
  je     L119
  add    $0x1,%rbx
  cmp    $0x1e,%rbx
  je     L751
L269:
  mov    %ebx,%r14d
  cmp    0x4(%rsp),%ebx
  jne    L842
  xor    %eax,%eax
  lea    D32(%rip),%rdi
  call   <printf@plt>
  cmp    %r14d,%r15d
  jne    L919
  xchg   %ax,%ax
L177:
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L919
  nopl   0x0(%rax)
L119:
  lea    D92(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x1e,%rbx
  jne    L269
  nopl   0x0(%rax,%rax,1)
L751:
  mov    $0xa,%edi
  mov    0x38(%rsp),%ebx
  call   <putchar@plt>
  mov    0xc(%rsp),%edx
  cmp    %edx,0x4(%rsp)
  jge    L855
  mov    %edx,%eax
  mov    0x20(%rsp),%rdx
  sub    0x4(%rsp),%eax
  mov    %rbp,0x38(%rsp)
  mov    0x10(%rsp),%r14
  sub    $0x1,%eax
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%rax
  mov    %r14,%rbp
  mov    %rax,%r14
  nop
L83:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp)
  setl   %dil
  add    $0x4,%rbp
  call   <assert@plt>
  cmp    %rbp,%r14
  jne    L83
  mov    0x38(%rsp),%rbp
L855:
  movslq 0xc(%rsp),%r14
  cmp    %r14d,%r13d
  jl     L282
  cs nopw 0x0(%rax,%rax,1)
L824:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp,%r14,4)
  setge  %dil
  add    $0x1,%r14
  call   <assert@plt>
  cmp    %r14d,%r13d
  jge    L824
L282:
  mov    0x30(%rsp),%rax
  mov    0xc(%rsp),%edi
  mov    %r13d,%ecx
  mov    (%rax),%r9d
  movslq %r13d,%rax
  nopl   0x0(%rax,%rax,1)
L112:
  lea    0x0(%rbp,%rax,4),%rsi
  mov    (%rsi),%edx
  cmp    %r9d,%ebx
  jne    L693
  cmp    0x8(%rsp),%edi
  jl     L33
L693:
  cmp    %edx,%ebx
  jge    L103
  cmp    %ecx,%edi
  jg     L850
  lea    -0x4(%rbp,%rax,4),%rax
  jmp    L42
  nopl   0x0(%rax)
L659:
  sub    $0x4,%rax
  cmp    %ecx,%edi
  jg     L850
L42:
  mov    (%rax),%edx
  sub    $0x1,%ecx
  mov    %rax,%rsi
  cmp    %ebx,%edx
  jg     L659
L103:
  cmp    %ecx,%edi
  jg     L850
  movslq %ecx,%rax
  je     L112
  movslq %edi,%r8
  lea    0x0(%rbp,%r8,4),%r8
  mov    %edx,(%r8)
  mov    %r9d,(%rsi)
  mov    (%r8),%r9d
  jmp    L112
  nopl   0x0(%rax,%rax,1)
L33:
  add    $0x1,%edi
  movslq %edi,%rdx
  mov    0x0(%rbp,%rdx,4),%r9d
  jmp    L112
  nopl   (%rax)
L850:
  lea    D182(%rip),%rdi
  xor    %r14d,%r14d
  call   <puts@plt>
  mov    %ebx,0x30(%rsp)
  mov    %r14,%rbx
  jmp    L575
  nopl   0x0(%rax,%rax,1)
L664:
  cmp    %r14d,%r15d
  je     L25
L328:
  mov    0x0(%rbp,%rbx,4),%esi
  xor    %eax,%eax
  mov    %r12,%rdi
  call   <printf@plt>
  cmp    %r14d,%r13d
  je     L165
  add    $0x1,%rbx
  cmp    $0x1e,%rbx
  je     L797
L575:
  mov    %ebx,%r14d
  cmp    0x4(%rsp),%ebx
  jne    L664
  xor    %eax,%eax
  lea    D32(%rip),%rdi
  call   <printf@plt>
  cmp    %r14d,%r15d
  jne    L328
  xchg   %ax,%ax
L25:
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L328
  nopl   0x0(%rax)
L165:
  lea    D92(%rip),%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x1e,%rbx
  jne    L575
  nopl   0x0(%rax,%rax,1)
L797:
  mov    $0xa,%edi
  mov    0x30(%rsp),%ebx
  call   <putchar@plt>
  mov    0xc(%rsp),%edx
  cmp    %edx,0x4(%rsp)
  jge    L552
  mov    %edx,%eax
  mov    0x20(%rsp),%rdx
  sub    0x4(%rsp),%eax
  sub    $0x1,%eax
  mov    0x10(%rsp),%r14
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%r15
  nopl   0x0(%rax)
L550:
  xor    %edi,%edi
  cmp    %ebx,(%r14)
  setl   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r14,%r15
  jne    L550
L552:
  mov    0x8(%rsp),%edx
  cmp    %edx,0xc(%rsp)
  jge    L629
  movslq 0xc(%rsp),%rcx
  mov    %edx,%eax
  mov    0x20(%rsp),%rdx
  sub    $0x1,%eax
  sub    %ecx,%eax
  lea    0x0(%rbp,%rcx,4),%r14
  add    %rcx,%rax
  lea    (%rdx,%rax,4),%r15
  cs nopw 0x0(%rax,%rax,1)
L311:
  xor    %edi,%edi
  cmp    %ebx,(%r14)
  sete   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r14,%r15
  jne    L311
L629:
  movslq 0x8(%rsp),%rdx
  mov    $0x1e,%r15d
  mov    %rdx,0x30(%rsp)
  sub    %edx,%r15d
  mov    %rdx,%r14
  cmp    %edx,%r13d
  jl     L486
  cs nopw 0x0(%rax,%rax,1)
L559:
  xor    %edi,%edi
  cmp    %ebx,0x0(%rbp,%r14,4)
  setg   %dil
  add    $0x1,%r14
  call   <assert@plt>
  cmp    %r14d,%r13d
  jge    L559
  mov    0xc(%rsp),%r14d
  mov    0x28(%rsp),%edx
  xor    %eax,%eax
  mov    %r15d,%ecx
  lea    D98(%rip),%rdi
  mov    %r14d,%esi
  call   <printf@plt>
  mov    0x8(%rsp),%ebx
  xor    %eax,%eax
  mov    %r13d,%edx
  lea    D213(%rip),%rdi
  mov    %ebx,%esi
  call   <printf@plt>
  cmp    %r15d,%ebx
  jl     L389
  cmp    %r15d,%r14d
  jl     L841
L389:
  mov    0xc(%rsp),%edx
  cmp    %edx,0x2c(%rsp)
  jl     L299
  mov    0x8(%rsp),%edx
  cmp    %edx,0x2c(%rsp)
  jl     L764
  lea    D62(%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)
L536:
  mov    0x4(%rsp),%eax
  lea    0x1(%rax),%r14d
  cmp    %r13d,%r14d
  jl     L663
  mov    %r13d,%eax
  je     L499
L304:
  mov    0x18(%rsp),%rax
  lea    D91(%rip),%rdi
  xor    %r13d,%r13d
  lea    0x0(%rbp,%rax,4),%rbx
  mov    (%rbx),%r15d
  call   <puts@plt>
  jmp    L611
  nopl   0x0(%rax,%rax,1)
L241:
  mov    0x0(%rbp,%r13,4),%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%r13
  call   <printf@plt>
  cmp    $0x1e,%r13
  je     L886
L611:
  cmp    %r13d,0x4(%rsp)
  jne    L241
  mov    $0x2a,%edi
  call   <putchar@plt>
  jmp    L241
L450:
  sete   %cl
  movzbl %cl,%ecx
  add    %ecx,0x28(%rsp)
  jmp    L315
L518:
  sete   %cl
  movzbl %cl,%ecx
  add    %ecx,0x28(%rsp)
  jmp    L190
L299:
  mov    %edx,%r13d
  lea    D61(%rip),%rdi
  sub    $0x1,%r13d
  call   <puts@plt>
  jmp    L536
L806:
  add    $0x1,%eax
  jmp    L295
L486:
  mov    0x28(%rsp),%edx
  mov    0xc(%rsp),%esi
  mov    %r15d,%ecx
  xor    %eax,%eax
  lea    D98(%rip),%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%esi
  mov    %r13d,%edx
  xor    %eax,%eax
  lea    D213(%rip),%rdi
  call   <printf@plt>
  jmp    L389
L493:
  mov    0x10(%rsp),%rax
  movl   $0x0,0x28(%rsp)
  mov    %rax,0x30(%rsp)
  mov    0x4(%rsp),%eax
  mov    %eax,0x8(%rsp)
  mov    %eax,0xc(%rsp)
  jmp    L532
L886:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L675
  mov    0x4(%rsp),%eax
  mov    0x20(%rsp),%rdx
  mov    %rbp,%r14
  sub    $0x1,%eax
  lea    (%rdx,%rax,4),%r13
L600:
  xor    %edi,%edi
  cmp    %r15d,(%r14)
  setl   %dil
  add    $0x4,%r14
  call   <assert@plt>
  cmp    %r13,%r14
  jne    L600
  cmpl   $0x1d,0x4(%rsp)
  jg     L186
L675:
  mov    0x20(%rsp),%rdx
  mov    $0x1d,%eax
  sub    0x4(%rsp),%eax
  add    0x18(%rsp),%rax
  lea    (%rdx,%rax,4),%r13
L836:
  xor    %edi,%edi
  cmp    %r15d,(%rbx)
  setge  %dil
  add    $0x4,%rbx
  call   <assert@plt>
  cmp    %rbx,%r13
  jne    L836
L186:
  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
L841:
  mov    0x8(%rsp),%ebx
  lea    D159(%rip),%rdi
  xor    %eax,%eax
  mov    %ebx,%esi
  call   <printf@plt>
  mov    0x30(%rsp),%rax
  mov    %ebx,0x2c(%rsp)
  mov    %ebx,0x4(%rsp)
  lea    0x0(%rbp,%rax,4),%rax
  mov    %rax,0x10(%rsp)
  movslq %ebx,%rax
  mov    %rax,0x18(%rsp)
  jmp    L536
L291:
  movl   $0x0,0x28(%rsp)
  xor    %eax,%eax
  jmp    L57
L499:
  cltq
  mov    0x10(%rsp),%rdi
  mov    %rax,%rsi
  lea    0x0(%rbp,%rax,4),%rax
  mov    (%rdi),%edx
  mov    (%rax),%ecx
  cmp    %edx,%ecx
  jge    L304
  mov    0x4(%rsp),%ebx
  cmp    %ebx,%esi
  je     L304
  mov    %ecx,(%rdi)
  mov    %edx,(%rax)
  jmp    L304
L764:
  lea    D42(%rip),%rdi
  call   <puts@plt>
  movslq 0xc(%rsp),%rax
  mov    %eax,0x4(%rsp)
  mov    %rax,0x18(%rsp)
  jmp    L304
```

tool_calls: name: parse_data
arguments: data_tag: D94
datatype: string
name: parse_data
arguments: data_tag: D122
datatype: string
name: parse_data
arguments: data_tag: D215
datatype: string
name: parse_data
arguments: data_tag: D116
datatype: string
name: parse_data
arguments: data_tag: D229
datatype: string
name: parse_data
arguments: data_tag: D4
datatype: string
name: parse_data
arguments: data_tag: D32
datatype: string
name: parse_data
arguments: data_tag: D92
datatype: string
name: parse_data
arguments: data_tag: D129
datatype: string
name: parse_data
arguments: data_tag: D182
datatype: string
name: parse_data
arguments: data_tag: D98
datatype: string
name: parse_data
arguments: data_tag: D213
datatype: string
name: parse_data
arguments: data_tag: D62
datatype: string
name: parse_data
arguments: data_tag: D91
datatype: string
name: parse_data
arguments: data_tag: D61
datatype: string
name: parse_data
arguments: data_tag: D159
datatype: string
name: parse_data
arguments: data_tag: D42
datatype: string

tool: D94: t=%i


tool: D122: %i 

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


tool: D116: median=%i


tool: D229: middle value: %i


tool: D4: beginning:

tool: D32: ( 

tool: D92: ) 

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

tool: D182: after collecting equal items:

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


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


tool: D62: median is in high partition.

tool: D91: end:

tool: D61: median is in low partition.

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


tool: D42: 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;
}
```