user: 请从给定的汇编指令推导出C源代码:

```asm
<match_colors_block>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xf0,%rsp
  mov    %rdi,-0xd8(%rbp)
  mov    %rsi,-0xe0(%rbp)
  mov    %edx,-0xe4(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0xd0(%rbp)
  mov    -0xe0(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    -0xe0(%rbp),%rdx
  add    $0x3,%rdx
  movzbl (%rdx),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0xc0(%rbp)
  mov    -0xe0(%rbp),%rax
  movzbl 0x1(%rax),%eax
  movzbl %al,%eax
  mov    -0xe0(%rbp),%rdx
  add    $0x3,%rdx
  movzbl 0x1(%rdx),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0xbc(%rbp)
  mov    -0xe0(%rbp),%rax
  movzbl 0x2(%rax),%eax
  movzbl %al,%eax
  mov    -0xe0(%rbp),%rdx
  add    $0x3,%rdx
  movzbl 0x2(%rdx),%edx
  movzbl %dl,%edx
  sub    %edx,%eax
  mov    %eax,-0xb8(%rbp)
  movl   $0x0,-0xcc(%rbp)
  jmp    L80
L151:
  mov    -0xcc(%rbp),%eax
  shl    $0x2,%eax
  movslq %eax,%rdx
  mov    -0xd8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  imul   -0xc0(%rbp),%eax
  mov    %eax,%edx
  mov    -0xcc(%rbp),%eax
  shl    $0x2,%eax
  cltq
  lea    0x1(%rax),%rcx
  mov    -0xd8(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  imul   -0xbc(%rbp),%eax
  add    %eax,%edx
  mov    -0xcc(%rbp),%eax
  shl    $0x2,%eax
  cltq
  lea    0x2(%rax),%rcx
  mov    -0xd8(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  imul   -0xb8(%rbp),%eax
  add    %eax,%edx
  mov    -0xcc(%rbp),%eax
  cltq
  mov    %edx,-0x50(%rbp,%rax,4)
  addl   $0x1,-0xcc(%rbp)
L80:
  cmpl   $0xf,-0xcc(%rbp)
  jle    L151
  movl   $0x0,-0xcc(%rbp)
  jmp    L186
L117:
  mov    -0xcc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0xe0(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  imul   -0xc0(%rbp),%eax
  mov    %eax,%ecx
  mov    -0xcc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0xe0(%rbp),%rax
  add    %rdx,%rax
  movzbl 0x1(%rax),%eax
  movzbl %al,%eax
  imul   -0xbc(%rbp),%eax
  add    %eax,%ecx
  mov    -0xcc(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  add    %rax,%rax
  add    %rax,%rdx
  mov    -0xe0(%rbp),%rax
  add    %rdx,%rax
  movzbl 0x2(%rax),%eax
  movzbl %al,%eax
  imul   -0xb8(%rbp),%eax
  lea    (%rcx,%rax,1),%edx
  mov    -0xcc(%rbp),%eax
  cltq
  mov    %edx,-0x80(%rbp,%rax,4)
  addl   $0x1,-0xcc(%rbp)
L186:
  cmpl   $0x3,-0xcc(%rbp)
  jle    L117
  mov    -0x7c(%rbp),%edx
  mov    -0x74(%rbp),%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xb4(%rbp)
  mov    -0x74(%rbp),%edx
  mov    -0x78(%rbp),%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xb0(%rbp)
  mov    -0x78(%rbp),%edx
  mov    -0x80(%rbp),%eax
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0xac(%rbp)
  cmpl   $0x0,-0xe4(%rbp)
  jne    L95
  movl   $0xf,-0xcc(%rbp)
  jmp    L123
L219:
  shll   $0x2,-0xd0(%rbp)
  mov    -0xcc(%rbp),%eax
  cltq
  mov    -0x50(%rbp,%rax,4),%eax
  mov    %eax,-0xa8(%rbp)
  mov    -0xa8(%rbp),%eax
  cmp    -0xb0(%rbp),%eax
  jge    L409
  mov    -0xa8(%rbp),%eax
  cmp    -0xb4(%rbp),%eax
  jge    L379
  mov    $0x1,%eax
  jmp    L2
L379:
  mov    $0x3,%eax
L2:
  or     %eax,-0xd0(%rbp)
  jmp    L97
L409:
  mov    -0xa8(%rbp),%eax
  cmp    -0xac(%rbp),%eax
  jge    L188
  mov    $0x2,%eax
  jmp    L288
L188:
  mov    $0x0,%eax
L288:
  or     %eax,-0xd0(%rbp)
L97:
  subl   $0x1,-0xcc(%rbp)
L123:
  cmpl   $0x0,-0xcc(%rbp)
  jns    L219
  jmp    L149
L95:
  lea    -0x70(%rbp),%rax
  mov    %rax,-0xa0(%rbp)
  lea    -0x70(%rbp),%rax
  add    $0x10,%rax
  mov    %rax,-0x98(%rbp)
  lea    -0x50(%rbp),%rax
  mov    %rax,-0x90(%rbp)
  shll   $0x4,-0xb4(%rbp)
  shll   $0x4,-0xb0(%rbp)
  shll   $0x4,-0xac(%rbp)
  lea    -0x70(%rbp),%rax
  mov    $0x20,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0xc8(%rbp)
  jmp    L318
L40:
  mov    -0x90(%rbp),%rax
  mov    (%rax),%eax
  shl    $0x4,%eax
  mov    %eax,%ecx
  mov    -0x98(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  lea    (%rax,%rdx,1),%esi
  mov    -0x98(%rbp),%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %esi,%eax
  add    %ecx,%eax
  mov    %eax,-0xa8(%rbp)
  mov    -0xa8(%rbp),%eax
  cmp    -0xb0(%rbp),%eax
  jge    L108
  mov    -0xa8(%rbp),%eax
  cmp    -0xb4(%rbp),%eax
  jge    L121
  mov    $0x1,%eax
  jmp    L387
L121:
  mov    $0x3,%eax
L387:
  mov    %eax,-0xc4(%rbp)
  jmp    L28
L108:
  mov    -0xa8(%rbp),%eax
  cmp    -0xac(%rbp),%eax
  jge    L234
  mov    $0x2,%eax
  jmp    L85
L234:
  mov    $0x0,%eax
L85:
  mov    %eax,-0xc4(%rbp)
L28:
  mov    -0x90(%rbp),%rax
  mov    (%rax),%edx
  mov    -0xc4(%rbp),%eax
  cltq
  mov    -0x80(%rbp,%rax,4),%eax
  sub    %eax,%edx
  mov    -0xa0(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0xc4(%rbp),%eax
  mov    %eax,-0xa4(%rbp)
  mov    -0x90(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  shl    $0x4,%eax
  mov    %eax,%ecx
  mov    -0xa0(%rbp),%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x3,%eax
  sub    %edx,%eax
  mov    %eax,%esi
  mov    -0x98(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,%esi
  mov    -0x98(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  lea    (%rsi,%rax,1),%edx
  mov    -0x98(%rbp),%rax
  mov    (%rax),%eax
  add    %edx,%eax
  add    %ecx,%eax
  mov    %eax,-0xa8(%rbp)
  mov    -0xa8(%rbp),%eax
  cmp    -0xb0(%rbp),%eax
  jge    L37
  mov    -0xa8(%rbp),%eax
  cmp    -0xb4(%rbp),%eax
  jge    L96
  mov    $0x1,%eax
  jmp    L184
L96:
  mov    $0x3,%eax
L184:
  mov    %eax,-0xc4(%rbp)
  jmp    L348
L37:
  mov    -0xa8(%rbp),%eax
  cmp    -0xac(%rbp),%eax
  jge    L388
  mov    $0x2,%eax
  jmp    L139
L388:
  mov    $0x0,%eax
L139:
  mov    %eax,-0xc4(%rbp)
L348:
  mov    -0x90(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  mov    -0xc4(%rbp),%eax
  cltq
  mov    -0x80(%rbp,%rax,4),%ecx
  mov    -0xa0(%rbp),%rax
  add    $0x4,%rax
  sub    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0xc4(%rbp),%eax
  shl    $0x2,%eax
  or     %eax,-0xa4(%rbp)
  mov    -0x90(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  shl    $0x4,%eax
  mov    %eax,%ecx
  mov    -0xa0(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x3,%eax
  sub    %edx,%eax
  mov    %eax,%esi
  mov    -0x98(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,%esi
  mov    -0x98(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  lea    (%rsi,%rax,1),%edx
  mov    -0x98(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  add    %ecx,%eax
  mov    %eax,-0xa8(%rbp)
  mov    -0xa8(%rbp),%eax
  cmp    -0xb0(%rbp),%eax
  jge    L408
  mov    -0xa8(%rbp),%eax
  cmp    -0xb4(%rbp),%eax
  jge    L100
  mov    $0x1,%eax
  jmp    L166
L100:
  mov    $0x3,%eax
L166:
  mov    %eax,-0xc4(%rbp)
  jmp    L27
L408:
  mov    -0xa8(%rbp),%eax
  cmp    -0xac(%rbp),%eax
  jge    L361
  mov    $0x2,%eax
  jmp    L54
L361:
  mov    $0x0,%eax
L54:
  mov    %eax,-0xc4(%rbp)
L27:
  mov    -0x90(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    -0xc4(%rbp),%eax
  cltq
  mov    -0x80(%rbp,%rax,4),%ecx
  mov    -0xa0(%rbp),%rax
  add    $0x8,%rax
  sub    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0xc4(%rbp),%eax
  shl    $0x4,%eax
  or     %eax,-0xa4(%rbp)
  mov    -0x90(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  shl    $0x4,%eax
  mov    %eax,%ecx
  mov    -0xa0(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x3,%eax
  sub    %edx,%eax
  mov    %eax,%esi
  mov    -0x98(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  lea    (%rsi,%rax,1),%edx
  mov    -0x98(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  add    %ecx,%eax
  mov    %eax,-0xa8(%rbp)
  mov    -0xa8(%rbp),%eax
  cmp    -0xb0(%rbp),%eax
  jge    L98
  mov    -0xa8(%rbp),%eax
  cmp    -0xb4(%rbp),%eax
  jge    L213
  mov    $0x1,%eax
  jmp    L380
L213:
  mov    $0x3,%eax
L380:
  mov    %eax,-0xc4(%rbp)
  jmp    L26
L98:
  mov    -0xa8(%rbp),%eax
  cmp    -0xac(%rbp),%eax
  jge    L64
  mov    $0x2,%eax
  jmp    L92
L64:
  mov    $0x0,%eax
L92:
  mov    %eax,-0xc4(%rbp)
L26:
  mov    -0x90(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%edx
  mov    -0xc4(%rbp),%eax
  cltq
  mov    -0x80(%rbp,%rax,4),%ecx
  mov    -0xa0(%rbp),%rax
  add    $0xc,%rax
  sub    %ecx,%edx
  mov    %edx,(%rax)
  mov    -0xc4(%rbp),%eax
  shl    $0x6,%eax
  or     %eax,-0xa4(%rbp)
  mov    -0xa0(%rbp),%rax
  mov    %rax,-0x88(%rbp)
  mov    -0x98(%rbp),%rax
  mov    %rax,-0xa0(%rbp)
  mov    -0x88(%rbp),%rax
  mov    %rax,-0x98(%rbp)
  addq   $0x10,-0x90(%rbp)
  mov    -0xc8(%rbp),%eax
  shl    $0x3,%eax
  mov    -0xa4(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  or     %eax,-0xd0(%rbp)
  addl   $0x1,-0xc8(%rbp)
L318:
  cmpl   $0x3,-0xc8(%rbp)
  jle    L40
L149:
  mov    -0xd0(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L279
  call   <__stack_chk_fail@plt>
L279:
  leave
  ret
```

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);
}
```