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

```asm
<mat_d>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    %ecx,%eax
  mov    %r8,-0x50(%rbp)
  mov    %r9,-0x58(%rbp)
  mov    %ax,-0x44(%rbp)
  movw   $0x0,-0x22(%rbp)
  movw   $0x0,-0x20(%rbp)
  movw   $0x0,-0x1e(%rbp)
  movw   $0x0,-0x1c(%rbp)
  movw   $0x0,-0x1a(%rbp)
  movw   $0x0,-0x18(%rbp)
  movw   $0x0,-0x16(%rbp)
  movw   $0x0,-0x14(%rbp)
  movw   $0xff,-0x12(%rbp)
  movw   $0xff,-0x10(%rbp)
  movw   $0x0,-0xe(%rbp)
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L561
L575:
  subl   $0x1,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  js     L455
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L427
  movzwl -0x22(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x22(%rbp)
  jmp    L561
L427:
  movl   $0x0,-0x4(%rbp)
  jmp    L561
L455:
  movl   $0x0,-0x4(%rbp)
L561:
  cmpl   $0x0,-0x4(%rbp)
  jne    L575
  movzwl -0x22(%rbp),%eax
  mov    %ax,-0xe(%rbp)
  movzwl -0x22(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L303
L645:
  addl   $0x1,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  cmp    %rax,-0x50(%rbp)
  jle    L24
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L130
  movzwl -0x20(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x20(%rbp)
  jmp    L303
L130:
  movl   $0x0,-0x4(%rbp)
  jmp    L303
L24:
  movl   $0x0,-0x4(%rbp)
L303:
  cmpl   $0x0,-0x4(%rbp)
  jne    L645
  movzwl -0x20(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L664
  movzwl -0x20(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L664:
  movzwl -0x20(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L517
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x20(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L366
L517:
  movzwl -0x20(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L366
  movzwl -0x20(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L366:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L258
L722:
  subl   $0x1,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  js     L199
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L261
  movzwl -0x1e(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x1e(%rbp)
  jmp    L258
L261:
  movl   $0x0,-0x4(%rbp)
  jmp    L258
L199:
  movl   $0x0,-0x4(%rbp)
L258:
  cmpl   $0x0,-0x4(%rbp)
  jne    L722
  movzwl -0x1e(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L446
  movzwl -0x1e(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L446:
  movzwl -0x1e(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L113
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x1e(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L64
L113:
  movzwl -0x1e(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L64
  movzwl -0x1e(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L64:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L309
L817:
  addl   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  cmp    %rax,-0x58(%rbp)
  jle    L703
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L724
  movzwl -0x1c(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x1c(%rbp)
  jmp    L309
L724:
  movl   $0x0,-0x4(%rbp)
  jmp    L309
L703:
  movl   $0x0,-0x4(%rbp)
L309:
  cmpl   $0x0,-0x4(%rbp)
  jne    L817
  movzwl -0x1c(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L265
  movzwl -0x1c(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L265:
  movzwl -0x1c(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L286
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x1c(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L360
L286:
  movzwl -0x1c(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L360
  movzwl -0x1c(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L360:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L70
L582:
  subl   $0x1,-0x8(%rbp)
  subl   $0x1,-0xc(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  js     L532
  cmpl   $0x0,-0xc(%rbp)
  js     L532
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L275
  movzwl -0x1a(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x1a(%rbp)
  jmp    L70
L275:
  movl   $0x0,-0x4(%rbp)
  jmp    L70
L532:
  movl   $0x0,-0x4(%rbp)
L70:
  cmpl   $0x0,-0x4(%rbp)
  jne    L582
  movswl -0x1a(%rbp),%eax
  imul   $0xe,%eax,%eax
  add    $0x7,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %ax,-0x1a(%rbp)
  movzwl -0x1a(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L413
  movzwl -0x1a(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L413:
  movzwl -0x1a(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L423
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x1a(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L700
L423:
  movzwl -0x1a(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L700
  movzwl -0x1a(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L700:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L18
L288:
  addl   $0x1,-0x8(%rbp)
  subl   $0x1,-0xc(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  cmp    %rax,-0x58(%rbp)
  jle    L813
  cmpl   $0x0,-0xc(%rbp)
  js     L813
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L462
  movzwl -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x18(%rbp)
  jmp    L18
L462:
  movl   $0x0,-0x4(%rbp)
  jmp    L18
L813:
  movl   $0x0,-0x4(%rbp)
L18:
  cmpl   $0x0,-0x4(%rbp)
  jne    L288
  movswl -0x18(%rbp),%eax
  imul   $0xe,%eax,%eax
  add    $0x7,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %ax,-0x18(%rbp)
  movzwl -0x18(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L525
  movzwl -0x18(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L525:
  movzwl -0x18(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L620
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x18(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L523
L620:
  movzwl -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L523
  movzwl -0x18(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L523:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L431
L243:
  addl   $0x1,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  cmp    %rax,-0x58(%rbp)
  jle    L292
  mov    -0xc(%rbp),%eax
  cltq
  cmp    %rax,-0x50(%rbp)
  jle    L292
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L782
  movzwl -0x16(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x16(%rbp)
  jmp    L431
L782:
  movl   $0x0,-0x4(%rbp)
  jmp    L431
L292:
  movl   $0x0,-0x4(%rbp)
L431:
  cmpl   $0x0,-0x4(%rbp)
  jne    L243
  movswl -0x16(%rbp),%eax
  imul   $0xe,%eax,%eax
  add    $0x7,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %ax,-0x16(%rbp)
  movzwl -0x16(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L276
  movzwl -0x16(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L276:
  movzwl -0x16(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L391
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x16(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L652
L391:
  movzwl -0x16(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L652
  movzwl -0x16(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L652:
  movl   $0x1,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x40(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L440
L425:
  subl   $0x1,-0x8(%rbp)
  addl   $0x1,-0xc(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  js     L174
  mov    -0xc(%rbp),%eax
  cltq
  cmp    %rax,-0x50(%rbp)
  jle    L174
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rax,%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cmp    %ax,-0x44(%rbp)
  jne    L785
  movzwl -0x14(%rbp),%eax
  add    $0x1,%eax
  mov    %ax,-0x14(%rbp)
  jmp    L440
L785:
  movl   $0x0,-0x4(%rbp)
  jmp    L440
L174:
  movl   $0x0,-0x4(%rbp)
L440:
  cmpl   $0x0,-0x4(%rbp)
  jne    L425
  movswl -0x14(%rbp),%eax
  imul   $0xe,%eax,%eax
  add    $0x7,%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %ax,-0x14(%rbp)
  movzwl -0x14(%rbp),%eax
  cmp    -0xe(%rbp),%ax
  jg     L478
  movzwl -0x14(%rbp),%eax
  mov    %ax,-0xe(%rbp)
L478:
  movzwl -0x14(%rbp),%eax
  cmp    -0x12(%rbp),%ax
  jge    L683
  movzwl -0x12(%rbp),%eax
  mov    %ax,-0x10(%rbp)
  movzwl -0x14(%rbp),%eax
  mov    %ax,-0x12(%rbp)
  jmp    L223
L683:
  movzwl -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jge    L223
  movzwl -0x14(%rbp),%eax
  mov    %ax,-0x10(%rbp)
L223:
  movzwl -0x12(%rbp),%eax
  cmp    -0x10(%rbp),%ax
  jne    L422
  movzwl -0x44(%rbp),%eax
  mov    %ax,-0xe(%rbp)
  jmp    L609
L422:
  movw   $0x0,-0xe(%rbp)
L609:
  cmpw   $0x0,-0x12(%rbp)
  jne    L704
  movw   $0x0,-0xe(%rbp)
L704:
  movswl -0xe(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int mat_d(the_image, a, b, value, rows, cols)
int a, b;
short **the_image, value;
long cols, rows;
{
  int i, j, measuring;
  short dist1 = 0, dist2 = 0, dist3 = 0, dist4 = 0, dist5 = 0, dist6 = 0, dist7 = 0, dist8 = 0, min1 = 255, min2 = 255, result = 0;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    i--;
    if (i >= 0) {
      if (the_image[i][j] == value)
        dist1++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  result = dist1;
  min1 = dist1;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    i++;
    if (i <= rows - 1) {
      if (the_image[i][j] == value)
        dist2++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  if (dist2 <= result)
    result = dist2;
  if (dist2 < min1) {
    min2 = min1;
    min1 = dist2;
  } else if (dist2 < min2)
    min2 = dist2;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j--;
    if (j >= 0) {
      if (the_image[i][j] == value)
        dist3++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  if (dist3 <= result)
    result = dist3;
  if (dist3 < min1) {
    min2 = min1;
    min1 = dist3;
  } else if (dist3 < min2)
    min2 = dist3;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j++;
    if (j <= cols - 1) {
      if (the_image[i][j] == value)
        dist4++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  if (dist4 <= result)
    result = dist4;
  if (dist4 < min1) {
    min2 = min1;
    min1 = dist4;
  } else if (dist4 < min2)
    min2 = dist4;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j--;
    i--;
    if (j >= 0 && i >= 0) {
      if (the_image[i][j] == value)
        dist5++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  dist5 = ((dist5 * 14) + 7) / 10;
  if (dist5 <= result)
    result = dist5;
  if (dist5 < min1) {
    min2 = min1;
    min1 = dist5;
  } else if (dist5 < min2)
    min2 = dist5;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j++;
    i--;
    if (j <= cols - 1 && i >= 0) {
      if (the_image[i][j] == value)
        dist6++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  dist6 = ((dist6 * 14) + 7) / 10;
  if (dist6 <= result)
    result = dist6;
  if (dist6 < min1) {
    min2 = min1;
    min1 = dist6;
  } else if (dist6 < min2)
    min2 = dist6;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j++;
    i++;
    if (j <= cols - 1 && i <= rows - 1) {
      if (the_image[i][j] == value)
        dist7++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  dist7 = ((dist7 * 14) + 7) / 10;
  if (dist7 <= result)
    result = dist7;
  if (dist7 < min1) {
    min2 = min1;
    min1 = dist7;
  } else if (dist7 < min2)
    min2 = dist7;
  measuring = 1;
  i = a;
  j = b;
  while (measuring) {
    j--;
    i++;
    if (j >= 0 && i <= rows - 1) {
      if (the_image[i][j] == value)
        dist8++;
      else
        measuring = 0;
    } else
      measuring = 0;
  }
  dist8 = ((dist8 * 14) + 7) / 10;
  if (dist8 <= result)
    result = dist8;
  if (dist8 < min1) {
    min2 = min1;
    min1 = dist8;
  } else if (dist8 < min2)
    min2 = dist8;
  if (min1 == min2)
    result = value;
  else
    result = 0;
  if (min1 == 0)
    result = 0;
  return (result);
}
```