user: 请将以下的汇编代码转换成C语言代码:

```asm
<match_colors_block>:
  endbr64
  push   %r15
  mov    %edx,%r11d
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  mov    %rsi,%rdi
  push   %rbp
  mov    %r12,%rdx
  push   %rbx
  sub    $0x98,%rsp
  movzbl (%rsi),%esi
  movzbl 0x1(%rdi),%r8d
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  movzbl 0x3(%rdi),%eax
  movzbl 0x2(%rdi),%r9d
  lea    0x40(%rsp),%r14
  mov    %esi,%r10d
  mov    %r8d,%ebx
  lea    0x80(%rsp),%r12
  mov    %r14,%rcx
  sub    %eax,%r10d
  movzbl 0x4(%rdi),%eax
  mov    %r9d,%ebp
  sub    %eax,%ebx
  movzbl 0x5(%rdi),%eax
  sub    %eax,%ebp
  nopl   (%rax)
L185:
  movzbl (%rdx),%eax
  movzbl 0x1(%rdx),%r13d
  add    $0x4,%rcx
  add    $0x4,%rdx
  imul   %ebx,%r13d
  imul   %r10d,%eax
  add    %r13d,%eax
  movzbl -0x2(%rdx),%r13d
  imul   %ebp,%r13d
  add    %r13d,%eax
  mov    %eax,-0x4(%rcx)
  cmp    %rcx,%r12
  jne    L185
  lea    0x10(%rsp),%rax
  add    $0x3,%rdi
  lea    0x20(%rsp),%r15
L236:
  imul   %r10d,%esi
  add    $0x4,%rax
  imul   %ebx,%r8d
  imul   %ebp,%r9d
  add    %esi,%r8d
  add    %r8d,%r9d
  mov    %r9d,-0x4(%rax)
  cmp    %rax,%r15
  je     L103
  movzbl (%rdi),%esi
  movzbl 0x1(%rdi),%r8d
  add    $0x3,%rdi
  movzbl -0x1(%rdi),%r9d
  jmp    L236
  nop
L103:
  mov    0x1c(%rsp),%ebp
  mov    0x18(%rsp),%esi
  mov    0x14(%rsp),%r12d
  lea    0x0(%rbp,%rsi,1),%ebx
  add    0x10(%rsp),%esi
  lea    (%r12,%rbp,1),%edi
  sar    %ebx
  sar    %esi
  sar    %edi
  test   %r11d,%r11d
  jne    L141
  lea    0x7c(%rsp),%rdx
  xor    %eax,%eax
  jmp    L125
  nopl   (%rax)
L52:
  cmp    %ecx,%edi
  setle  %cl
  movzbl %cl,%ecx
  lea    0x1(%rcx,%rcx,1),%ecx
  or     %ecx,%eax
  lea    -0x4(%rdx),%rcx
  cmp    %rdx,%r14
  je     L261
L190:
  mov    %rcx,%rdx
L125:
  mov    (%rdx),%ecx
  shl    $0x2,%eax
  cmp    %ecx,%ebx
  jg     L52
  cmp    %ecx,%esi
  setg   %cl
  movzbl %cl,%ecx
  add    %ecx,%ecx
  or     %ecx,%eax
  lea    -0x4(%rdx),%rcx
  cmp    %rdx,%r14
  jne    L190
L261:
  mov    0x88(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L155
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L141:
  shl    $0x4,%edi
  shl    $0x4,%esi
  mov    $0x20,%edx
  mov    %edi,0x8(%rsp)
  mov    %r15,%rdi
  shl    $0x4,%ebx
  mov    %esi,0xc(%rsp)
  xor    %esi,%esi
  call   <memset@plt>
  mov    %r12d,(%rsp)
  mov    0x34(%rsp),%r9d
  xor    %ecx,%ecx
  mov    %ebp,0x4(%rsp)
  mov    0x30(%rsp),%r13d
  mov    %r14,%rdx
  mov    %r15,%rdi
  mov    0x8(%rsp),%ebp
  mov    0xc(%rsp),%r12d
  lea    0x30(%rsp),%r8
  xor    %eax,%eax
L46:
  mov    (%rdx),%r10d
  lea    (%r9,%r9,2),%esi
  lea    0x0(%r13,%r13,4),%r9d
  add    %r9d,%esi
  mov    %r10d,%r9d
  shl    $0x4,%r9d
  add    %r9d,%esi
  cmp    %esi,%ebx
  jle    L153
  cmp    %esi,%ebp
  jg     L188
  mov    0x4(%rsp),%r9d
  mov    $0x3,%esi
L39:
  sub    %r9d,%r10d
  mov    0x4(%rdx),%r9d
  mov    %r10d,(%rdi)
  mov    %r10d,%r13d
  mov    0x8(%r8),%r10d
  lea    (%r10,%r10,2),%r11d
  lea    0x0(,%r13,8),%r10d
  sub    %r13d,%r10d
  add    %r11d,%r10d
  mov    0x4(%r8),%r11d
  lea    (%r11,%r11,4),%r11d
  add    %r11d,%r10d
  mov    %r9d,%r11d
  add    (%r8),%r10d
  shl    $0x4,%r11d
  add    %r11d,%r10d
  cmp    %r10d,%ebx
  jle    L76
  cmp    %r10d,%ebp
  jg     L254
  mov    0x4(%rsp),%r11d
  mov    $0xc,%r10d
L135:
  sub    %r11d,%r9d
  or     %r10d,%esi
  mov    0x8(%rdx),%r11d
  mov    %r9d,0x4(%rdi)
  mov    0xc(%r8),%r10d
  lea    (%r10,%r10,2),%r14d
  lea    0x0(,%r9,8),%r10d
  sub    %r9d,%r10d
  add    %r14d,%r10d
  mov    0x8(%r8),%r14d
  lea    (%r14,%r14,4),%r14d
  add    %r14d,%r10d
  mov    %r11d,%r14d
  add    0x4(%r8),%r10d
  shl    $0x4,%r14d
  add    %r14d,%r10d
  cmp    %r10d,%ebx
  jle    L0
  cmp    %r10d,%ebp
  jg     L87
  mov    0x4(%rsp),%r14d
  mov    $0x30,%r10d
L126:
  sub    %r14d,%r11d
  or     %r10d,%esi
  mov    0xc(%rdx),%r14d
  mov    %r11d,0x8(%rdi)
  mov    0xc(%r8),%r10d
  lea    0x0(,%r11,8),%r15d
  sub    %r11d,%r15d
  mov    %r14d,%r11d
  lea    (%r10,%r10,4),%r10d
  shl    $0x4,%r11d
  add    %r15d,%r10d
  add    0x8(%r8),%r10d
  add    %r11d,%r10d
  cmp    %r10d,%ebx
  jle    L171
  cmp    %r10d,%ebp
  jg     L197
  mov    0x4(%rsp),%r11d
  mov    $0xc0,%r10d
L107:
  or     %r10d,%esi
  sub    %r11d,%r14d
  add    $0x10,%rdx
  shl    %cl,%esi
  add    $0x8,%ecx
  mov    %r14d,0xc(%rdi)
  or     %esi,%eax
  mov    %r8,%rsi
  mov    %rdi,%r8
  cmp    $0x20,%ecx
  je     L261
  mov    %rsi,%rdi
  jmp    L46
  xchg   %ax,%ax
L153:
  cmp    %esi,%r12d
  setg   %sil
  movzbl %sil,%esi
  add    %esi,%esi
  movslq %esi,%r9
  mov    0x10(%rsp,%r9,4),%r9d
  jmp    L39
  nopw   0x0(%rax,%rax,1)
L171:
  cmp    %r10d,%r12d
  setg   %r10b
  movzbl %r10b,%r10d
  lea    (%r10,%r10,1),%r11d
  shl    $0x7,%r10d
  movslq %r11d,%r11
  mov    0x10(%rsp,%r11,4),%r11d
  jmp    L107
  nopl   (%rax)
L0:
  cmp    %r10d,%r12d
  setg   %r10b
  movzbl %r10b,%r10d
  lea    (%r10,%r10,1),%r14d
  shl    $0x5,%r10d
  movslq %r14d,%r14
  mov    0x10(%rsp,%r14,4),%r14d
  jmp    L126
L76:
  cmp    %r10d,%r12d
  setg   %r10b
  movzbl %r10b,%r10d
  lea    (%r10,%r10,1),%r11d
  shl    $0x3,%r10d
  movslq %r11d,%r11
  mov    0x10(%rsp,%r11,4),%r11d
  jmp    L135
L188:
  mov    (%rsp),%r9d
  mov    $0x1,%esi
  jmp    L39
  xchg   %ax,%ax
L197:
  mov    (%rsp),%r11d
  mov    $0x40,%r10d
  jmp    L107
  nop
L87:
  mov    (%rsp),%r14d
  mov    $0x10,%r10d
  jmp    L126
  nop
L254:
  mov    (%rsp),%r11d
  mov    $0x4,%r10d
  jmp    L135
L155:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned int match_colors_block(const unsigned char *block, unsigned char color[4][3], int dither) {
  unsigned int mask = 0;
  int dirb = color[0][0] - color[1][0];
  int dirg = color[0][1] - color[1][1];
  int dirr = color[0][2] - color[1][2];
  int dots[16], stops[4];
  int c0pt, halfpt, c3pt, dot;
  int i;
  for (i = 0; i < 16; ++i)
    dots[i] = block[4 * i] * dirb + block[4 * i + 1] * dirg + block[4 * i + 2] * dirr;
  for (i = 0; i < 4; ++i)
    stops[i] = color[i][0] * dirb + color[i][1] * dirg + color[i][2] * dirr;
  c0pt = (stops[1] + stops[3]) >> 1;
  halfpt = (stops[3] + stops[2]) >> 1;
  c3pt = (stops[2] + stops[0]) >> 1;
  if (!dither) {
    for (i = 15; i >= 0; --i) {
      mask <<= 2;
      dot = dots[i];
      if (dot < halfpt)
        mask |= (dot < c0pt) ? 1 : 3;
      else
        mask |= (dot < c3pt) ? 2 : 0;
    }
  } else {
    int err[8], *ep1 = err, *ep2 = err + 4, *tmp;
    int *dp = dots, y, lmask, step;
    c0pt <<= 4;
    halfpt <<= 4;
    c3pt <<= 4;
    memset(err, 0, sizeof(err));
    for (y = 0; y < 4; ++y) {
      dot = (dp[0] << 4) + (3 * ep2[1] + 5 * ep2[0]);
      if (dot < halfpt)
        step = (dot < c0pt) ? 1 : 3;
      else
        step = (dot < c3pt) ? 2 : 0;
      ep1[0] = dp[0] - stops[step];
      lmask = step;
      dot = (dp[1] << 4) + (7 * ep1[0] + 3 * ep2[2] + 5 * ep2[1] + ep2[0]);
      if (dot < halfpt)
        step = (dot < c0pt) ? 1 : 3;
      else
        step = (dot < c3pt) ? 2 : 0;
      ep1[1] = dp[1] - stops[step];
      lmask |= step << 2;
      dot = (dp[2] << 4) + (7 * ep1[1] + 3 * ep2[3] + 5 * ep2[2] + ep2[1]);
      if (dot < halfpt)
        step = (dot < c0pt) ? 1 : 3;
      else
        step = (dot < c3pt) ? 2 : 0;
      ep1[2] = dp[2] - stops[step];
      lmask |= step << 4;
      dot = (dp[3] << 4) + (7 * ep1[2] + 5 * ep2[3] + ep2[2]);
      if (dot < halfpt)
        step = (dot < c0pt) ? 1 : 3;
      else
        step = (dot < c3pt) ? 2 : 0;
      ep1[3] = dp[3] - stops[step];
      lmask |= step << 6;
      tmp = ep1;
      ep1 = ep2;
      ep2 = tmp;
      dp += 4;
      mask |= lmask << (y * 8);
    }
  }
  return (mask);
}
```