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

```asm
<dist_4v_allt_v4>:
  endbr64
  push   %r15
  mov    %rsi,%r10
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    0x8(%rdi),%rax
  mov    0x4(%rsi),%esi
  mov    0xc0(%rsp),%r11d
  mov    0xa0(%rsp),%ebx
  mov    %rdx,0x18(%rsp)
  mov    0x4(%rax),%edi
  mov    0xa0(%rsp),%eax
  mov    %rcx,0x20(%rsp)
  add    $0x1,%eax
  test   %r11d,%r11d
  cmovns 0xc0(%rsp),%eax
  mov    %eax,0xc0(%rsp)
  test   %ebx,%ebx
  jle    L192
  mov    0xc0(%rsp),%eax
  test   %eax,%eax
  js     L192
  movl   $0x0,0x38(%rsp)
  mov    %r8d,%r12d
  mov    %r9d,%r11d
  xor    %ebx,%ebx
  movl   $0x0,0x8(%rsp)
  mov    $0x1,%r13d
  mov    $0x1,%ebp
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  nopl   0x0(%rax)
L319:
  mov    %edi,%eax
  or     %esi,%eax
  jns    L315
  mov    0xa0(%rsp),%eax
  xor    %r15d,%r15d
  lea    0x1(%rax),%ebx
L27:
  mov    %edi,%eax
  not    %eax
  shr    $0x1f,%eax
  cmp    %ebp,%r12d
  setg   %dl
  test   %al,%dl
  je     L86
  cmp    %edi,%ebx
  lea    0x1(%rbp),%eax
  setg   %dl
  cltq
  test   %dl,%dl
  je     L86
  xchg   %ax,%ax
L346:
  mov    (%r14,%rax,8),%rdx
  mov    %eax,%ebp
  mov    0x4(%rdx),%edi
  mov    %edi,%ecx
  cmp    %ebx,%edi
  not    %ecx
  setl   %dl
  shr    $0x1f,%ecx
  and    %ecx,%edx
  cmp    %eax,%r12d
  setg   %cl
  add    $0x1,%rax
  test   %cl,%dl
  jne    L346
L86:
  cmp    %edi,%ebx
  je     L367
L138:
  mov    0x8(%rsp),%eax
  cmp    0xc0(%rsp),%eax
  jg     L33
  test   %r15b,%r15b
  jne    L319
L33:
  mov    0xc(%rsp),%esi
  movd   0x8(%rsp),%xmm1
  mov    0x88(%rsp),%rax
  movd   %esi,%xmm0
  punpckldq %xmm1,%xmm0
  mov    %rax,%rbx
  movq   %xmm0,(%rax)
  mov    0x10(%rsp),%eax
  mov    %eax,0x8(%rbx)
  test   %eax,%eax
  js     L353
L5:
  mov    0x88(%rsp),%rax
  mov    0xc(%rsp),%esi
  mov    %esi,0xc(%rax)
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L315:
  add    $0x1,%ebx
  cmp    %ebx,0xa0(%rsp)
  setg   %r15b
  jmp    L27
  nopl   0x0(%rax,%rax,1)
L367:
  cmp    %ebp,%r12d
  jl     L360
  movslq %ebp,%rax
  mov    %ebp,%r8d
  mov    $0x1,%edi
  lea    (%r14,%rax,8),%r9
L229:
  mov    -0x8(%r9,%rdi,8),%rcx
  mov    0xe8(%rsp),%rax
  mov    %edi,%edx
  mov    0x8(%rcx),%ebp
  mov    (%rax,%rdi,8),%rax
  mov    %ebp,0x4(%rax)
  mov    0xc(%rcx),%ebp
  mov    %ebp,0x8(%rax)
  mov    0x10(%rcx),%ebp
  mov    %ebp,0xc(%rax)
  mov    0x14(%rcx),%ebp
  mov    %ebp,0x10(%rax)
  mov    0x18(%rcx),%ebp
  mov    %ebp,0x14(%rax)
  mov    0x1c(%rcx),%ebp
  mov    %ebp,0x18(%rax)
  mov    0x20(%rcx),%ebp
  mov    %ebp,0x1c(%rax)
  mov    0x24(%rcx),%ebp
  mov    %ebp,0x20(%rax)
  mov    0x28(%rcx),%ecx
  mov    %r8d,%ebp
  add    $0x1,%r8d
  mov    %ecx,0x24(%rax)
  cmp    %r8d,%r12d
  jge    L210
L91:
  mov    %esi,%eax
  not    %eax
  shr    $0x1f,%eax
  cmp    %r13d,%r11d
  setg   %cl
  test   %al,%cl
  je     L14
  cmp    %esi,%ebx
  jle    L14
  lea    0x1(%r13),%eax
  cltq
  nopl   0x0(%rax)
L253:
  mov    (%r10,%rax,4),%esi
  mov    %eax,%r13d
  mov    %esi,%edi
  cmp    %ebx,%esi
  not    %edi
  setl   %cl
  shr    $0x1f,%edi
  and    %edi,%ecx
  cmp    %eax,%r11d
  setg   %dil
  add    $0x1,%rax
  test   %dil,%cl
  jne    L253
L14:
  mov    %ebx,%edi
  cmp    %esi,%ebx
  jne    L138
  cmp    %r13d,%r11d
  jl     L188
  mov    0x18(%rsp),%rax
  movslq %r13d,%rsi
  mov    0x20(%rsp),%r8
  mov    %r13d,%ecx
  lea    0x0(,%rsi,4),%rdi
  lea    (%rax,%rdi,1),%r9
  add    %rsi,%r8
  add    %r10,%rdi
  mov    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L85:
  mov    -0x4(%r9,%rax,4),%esi
  mov    0x100(%rsp),%r13
  mov    %eax,0x14(%rsp)
  mov    %esi,0x0(%r13,%rax,4)
  mov    0x108(%rsp),%r13
  movzbl -0x1(%r8,%rax,1),%esi
  mov    %sil,0x0(%r13,%rax,1)
  mov    %ecx,%r13d
  add    $0x1,%ecx
  cmp    %ecx,%r11d
  jge    L265
L136:
  mov    0x120(%rsp),%esi
  test   %esi,%esi
  jne    L314
L3:
  mov    0xb8(%rsp),%ecx
  mov    %r11d,0x30(%rsp)
  mov    %r10,0x28(%rsp)
  test   %ecx,%ecx
  js     L387
  jne    L245
  sub    $0x8,%rsp
  mov    %edx,%ecx
  push   0xe8(%rsp)
  mov    0xc0(%rsp),%eax
  push   %rax
  push   0xc0(%rsp)
  push   $0xc350
  mov    0xc0(%rsp),%eax
  push   %rax
  mov    0xc0(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  push   0xc0(%rsp)
  mov    0x118(%rsp),%r9
  mov    0x54(%rsp),%r8d
  mov    0x148(%rsp),%rdx
  mov    0x140(%rsp),%rsi
  mov    0x128(%rsp),%rdi
  call   <dist_4v_unordered_v4@plt>
  mov    0x68(%rsp),%r10
  mov    0x70(%rsp),%r11d
  add    $0x40,%rsp
L285:
  mov    0x88(%rsp),%rax
  mov    (%rax),%ecx
  mov    0x4(%rax),%esi
  xor    %eax,%eax
  add    %esi,0x10(%rsp)
  test   %ecx,%ecx
  setg   %al
  add    %eax,0x8(%rsp)
  mov    0xc(%rsp),%eax
  add    %ecx,%eax
  cmpl   $0x1,0xb0(%rsp)
  je     L294
  mov    %eax,0xc(%rsp)
  mov    %ebx,%esi
  mov    %ebx,%edi
  jmp    L138
  nopl   (%rax)
L210:
  mov    (%r9,%rdi,8),%rax
  cmp    %ebx,0x4(%rax)
  sete   %al
  add    $0x1,%rdi
  test   %al,%al
  jne    L229
  jmp    L91
  nopl   0x0(%rax,%rax,1)
L353:
  mov    0x38(%rsp),%eax
  test   %eax,%eax
  cmovg  %eax,%esi
  mov    %esi,0xc(%rsp)
  jmp    L5
  nopw   0x0(%rax,%rax,1)
L265:
  cmp    %ebx,(%rdi,%rax,4)
  sete   %sil
  add    $0x1,%rax
  test   %sil,%sil
  jne    L85
  jmp    L136
  nopl   0x0(%rax)
L360:
  sub    $0x1,%ebp
  xor    %edx,%edx
  jmp    L91
L192:
  mov    0x88(%rsp),%rax
  movl   $0x0,0xc(%rsp)
  movq   $0x0,(%rax)
  movl   $0x0,0x8(%rax)
  jmp    L5
L245:
  push   0xf8(%rsp)
  mov    %edx,%ecx
  push   0xe8(%rsp)
  push   0x100(%rsp)
  push   0x130(%rsp)
  push   0x130(%rsp)
  mov    0xf8(%rsp),%eax
  push   %rax
  mov    0xe0(%rsp),%eax
  push   %rax
  push   0xe0(%rsp)
  push   $0xc350
  mov    0xe0(%rsp),%eax
  push   %rax
  mov    0xe0(%rsp),%eax
  push   %rax
  xor    %eax,%eax
  push   0xe0(%rsp)
  mov    0x138(%rsp),%r9
  mov    0x74(%rsp),%r8d
  mov    0x168(%rsp),%rdx
  mov    0x160(%rsp),%rsi
  mov    0x148(%rsp),%rdi
  call   <dist_4v_ordered_v4@plt>
  add    $0x60,%rsp
  mov    0x30(%rsp),%r11d
  mov    0x28(%rsp),%r10
  jmp    L285
L314:
  mov    %ebx,%esi
  lea    D12(%rip),%rdi
  xor    %eax,%eax
  mov    %r11d,0x3c(%rsp)
  mov    %r10,0x30(%rsp)
  mov    %edx,0x28(%rsp)
  call   <printf@plt>
  mov    0x3c(%rsp),%r11d
  mov    0x30(%rsp),%r10
  mov    0x28(%rsp),%edx
  jmp    L3
L387:
  sub    $0x8,%rsp
  mov    0x128(%rsp),%eax
  push   %rax
  push   0xf0(%rsp)
  mov    0xc8(%rsp),%eax
  push   %rax
  push   0xc8(%rsp)
  push   $0xc350
  mov    0xc8(%rsp),%eax
  push   %rax
  mov    0xc8(%rsp),%eax
  push   %rax
  mov    0xc8(%rsp),%r9
  xor    %eax,%eax
  mov    0x118(%rsp),%r8
  mov    0x54(%rsp),%ecx
  mov    0x140(%rsp),%rsi
  mov    0x128(%rsp),%rdi
  call   <dist_4v_unordered_nostrand_v2@plt>
  add    $0x40,%rsp
  mov    0x28(%rsp),%r10
  mov    0x30(%rsp),%r11d
  jmp    L285
L188:
  movl   $0x0,0x14(%rsp)
  sub    $0x1,%r13d
  jmp    L136
L294:
  cmp    %eax,0xc8(%rsp)
  jl     L209
L371:
  mov    0xc(%rsp),%eax
  cmp    %eax,0xc8(%rsp)
  jle    L198
  test   %ecx,%ecx
  jle    L198
  add    $0x1,%eax
  mov    $0x1,%edi
  movslq %eax,%rsi
L343:
  mov    0x80(%rsp),%rax
  mov    0xd8(%rsp),%rdx
  cmp    %edi,%ecx
  mov    %esi,%r8d
  mov    (%rdx,%rdi,8),%rdx
  mov    (%rax,%rsi,8),%rax
  mov    %ebx,0x4(%rax)
  mov    0x4(%rdx),%r9d
  mov    %r9d,0x8(%rax)
  mov    0x8(%rdx),%r9d
  mov    %r9d,0xc(%rax)
  mov    0xc(%rdx),%r9d
  mov    %r9d,0x10(%rax)
  mov    0x10(%rdx),%r9d
  mov    %r9d,0x14(%rax)
  mov    0x14(%rdx),%r9d
  mov    %r9d,0x18(%rax)
  mov    0x18(%rdx),%r9d
  mov    %r9d,0x1c(%rax)
  mov    0x1c(%rdx),%r9d
  mov    %r9d,0x20(%rax)
  mov    0x20(%rdx),%r9d
  mov    %r9d,0x24(%rax)
  mov    0x24(%rdx),%r9d
  mov    %r9d,0x28(%rax)
  mov    0x28(%rdx),%r9d
  mov    %r9d,0x2c(%rax)
  mov    0x2c(%rdx),%r9d
  mov    %r9d,0x30(%rax)
  mov    0x30(%rdx),%edx
  mov    %edx,0x34(%rax)
  setg   %dl
  cmp    %esi,0xc8(%rsp)
  setg   %al
  add    $0x1,%rdi
  add    $0x1,%rsi
  test   %al,%dl
  jne    L343
  mov    %r8d,0xc(%rsp)
  mov    %ebx,%esi
  mov    %ebx,%edi
  jmp    L138
L209:
  lea    D40(%rip),%rdi
  mov    %r11d,0x30(%rsp)
  mov    %r10,0x28(%rsp)
  mov    %ecx,0x14(%rsp)
  subl   $0x1,0x10(%rsp)
  call   <puts@plt>
  mov    0xa0(%rsp),%edx
  mov    %ebx,%esi
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  call   <printf@plt>
  mov    0xc(%rsp),%esi
  lea    D43(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x14(%rsp),%esi
  lea    D31(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D24(%rip),%rdi
  call   <puts@plt>
  mov    0xc(%rsp),%eax
  mov    0x30(%rsp),%r11d
  movl   $0x0,0xb0(%rsp)
  mov    0x28(%rsp),%r10
  mov    0x14(%rsp),%ecx
  mov    %eax,0x38(%rsp)
  jmp    L371
L198:
  mov    %ebx,%esi
  mov    %ebx,%edi
  jmp    L138
```

tool_calls: name: retrieve_data
arguments: data_label: D12
data_type: string
name: retrieve_data
arguments: data_label: D40
data_type: string
name: retrieve_data
arguments: data_label: D9
data_type: string
name: retrieve_data
arguments: data_label: D43
data_type: string
name: retrieve_data
arguments: data_label: D31
data_type: string
name: retrieve_data
arguments: data_label: D24
data_type: string

tool: D12: dist_4v_allt_v3	transcript=%d


tool: D40: dist_4v_allt_v4

tool: D9: transcript=%d (n_transcripts=%d)


tool: D43: running_entries=%d


tool: D31: n1234=%d


tool: D24: setting get_positions to 0

assistant: ```c
void dist_4v_allt_v4(int **ovdi123, int *m4_t, int *m4_p, char *m4_s, int n123, int n4, int **ovdi, int *n, int min_dist, int max_dist, int n_transcripts, int *ml, int get_positions, int order_constraint, int max_n_transcripts, int max_n_ovdi, int pos_format, int **ovdi_single_transcript, int **temp_ovdi, int **ovdi123_p, int **ovdi1234, int **all_ovdi, int *m4p, char *m4s, int *m123_p, char *m123_s, int verbose) {
  int i123, i4;
  int running_entries = 0;
  int errorcode = 0;
  int n1234_tr = 0;
  int transcript = 0;
  int curr_tr123, curr_tr4;
  int max_n_ovdi_single_transcript = 50000;
  int n1234;
  int n1234_stop = 0;
  int i, j;
  int curr_n123, curr_n4;
  i123 = 1;
  curr_tr123 = ovdi123[i123][1];
  i4 = 1;
  curr_tr4 = m4_t[i4];
  if (max_n_transcripts < 0)
    max_n_transcripts = n_transcripts + 1;
  while ((transcript < n_transcripts) & (n1234_tr <= max_n_transcripts)) {
    transcript++;
    if ((curr_tr123 < 0) | (curr_tr4 < 0))
      transcript = n_transcripts + 1;
    while ((curr_tr123 < transcript) & (curr_tr123 >= 0) & (i123 < n123)) {
      i123++;
      curr_tr123 = ovdi123[i123][1];
    }
    if (curr_tr123 == transcript) {
      curr_n123 = 0;
      while ((curr_tr123 == transcript) & (i123 <= n123)) {
        curr_n123++;
        ovdi123_p[curr_n123][1] = ovdi123[i123][2];
        ovdi123_p[curr_n123][2] = ovdi123[i123][3];
        ovdi123_p[curr_n123][3] = ovdi123[i123][4];
        ovdi123_p[curr_n123][4] = ovdi123[i123][5];
        ovdi123_p[curr_n123][5] = ovdi123[i123][6];
        ovdi123_p[curr_n123][6] = ovdi123[i123][7];
        ovdi123_p[curr_n123][7] = ovdi123[i123][8];
        ovdi123_p[curr_n123][8] = ovdi123[i123][9];
        ovdi123_p[curr_n123][9] = ovdi123[i123][10];
        i123++;
        if (i123 <= n123)
          curr_tr123 = ovdi123[i123][1];
      }
      i123--;
      curr_tr123 = transcript;
      while ((curr_tr4 < transcript) & (curr_tr4 >= 0) & (i4 < n4)) {
        i4++;
        curr_tr4 = m4_t[i4];
      }
      if (curr_tr4 == transcript) {
        curr_n4 = 0;
        while ((curr_tr4 == transcript) & (i4 <= n4)) {
          curr_n4++;
          m4p[curr_n4] = m4_p[i4];
          m4s[curr_n4] = m4_s[i4];
          i4++;
          if (i4 <= n4)
            curr_tr4 = m4_t[i4];
        }
        i4--;
        curr_tr4 = transcript;
        if (verbose)
          printf("dist_4v_allt_v3\ttranscript=%d\n", transcript);
        if (order_constraint < 0) {
          dist_4v_unordered_nostrand_v2(ovdi123_p, m4p, curr_n123, curr_n4, ovdi_single_transcript, n, min_dist, max_dist, max_n_ovdi_single_transcript, ml, get_positions, temp_ovdi, verbose);
        } else {
          if (order_constraint == 0) {
            dist_4v_unordered_v4(ovdi123_p, m4p, m4s, curr_n123, curr_n4, ovdi_single_transcript, n, min_dist, max_dist, max_n_ovdi_single_transcript, ml, get_positions, temp_ovdi);
          } else {
            dist_4v_ordered_v4(ovdi123_p, m4p, m4s, curr_n123, curr_n4, ovdi_single_transcript, n, min_dist, max_dist, max_n_ovdi_single_transcript, ml, get_positions, pos_format, m123_p, m123_s, ovdi1234, temp_ovdi, all_ovdi);
          }
        }
        n1234 = n[0];
        errorcode += n[1];
        if (n1234 > 0)
          n1234_tr++;
        if (get_positions == 1) {
          if ((running_entries + n1234) > max_n_ovdi) {
            get_positions = 0;
            errorcode--;
            printf("dist_4v_allt_v4\n");
            printf("transcript=%d (n_transcripts=%d)\n", transcript, n_transcripts);
            printf("running_entries=%d\n", running_entries);
            printf("n1234=%d\n", n1234);
            printf("setting get_positions to 0\n");
            n1234_stop = running_entries;
          }
          i = 0;
          while ((i < n1234) & (running_entries < max_n_ovdi)) {
            i++;
            running_entries++;
            ovdi[running_entries][1] = transcript;
            ovdi[running_entries][2] = ovdi_single_transcript[i][1];
            ovdi[running_entries][3] = ovdi_single_transcript[i][2];
            ovdi[running_entries][4] = ovdi_single_transcript[i][3];
            ovdi[running_entries][5] = ovdi_single_transcript[i][4];
            ovdi[running_entries][6] = ovdi_single_transcript[i][5];
            ovdi[running_entries][7] = ovdi_single_transcript[i][6];
            ovdi[running_entries][8] = ovdi_single_transcript[i][7];
            ovdi[running_entries][9] = ovdi_single_transcript[i][8];
            ovdi[running_entries][10] = ovdi_single_transcript[i][9];
            ovdi[running_entries][11] = ovdi_single_transcript[i][10];
            ovdi[running_entries][12] = ovdi_single_transcript[i][11];
            ovdi[running_entries][13] = ovdi_single_transcript[i][12];
          }
        } else {
          running_entries += n1234;
        }
      }
    }
  }
  n[0] = running_entries;
  n[1] = n1234_tr;
  n[2] = errorcode;
  if (errorcode < 0) {
    if (n1234_stop <= 0)
      n1234_stop = running_entries;
    n[3] = n1234_stop;
  } else {
    n[3] = running_entries;
  }
}
```