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

```asm
<build_table_color>:
  endbr64
  push   %r15
  lea    0x4000(%rsi),%rax
  mov    $0xffffff80,%r9d
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0x1,%ebx
  mov    %rdi,-0x10(%rsp)
  mov    %rax,-0x8(%rsp)
L108:
  mov    -0x10(%rsp),%r11
  mov    %r13,%r12
  mov    %r14,%rbp
  xor    %r10d,%r10d
  xchg   %ax,%ax
L50:
  lea    0x1(%rbp),%rdi
  mov    %r12,%rax
  xor    %esi,%esi
  nopl   0x0(%rax)
L32:
  test   %esi,%esi
  jne    L23
  movb   $0x1,(%rdi)
  add    $0x1,%rax
  add    $0x2,%rdi
  mov    $0x1,%esi
  movb   $0x8,-0x3(%rdi)
  movb   $0x82,-0x1(%rax)
  movb   $0x84,0xf(%rax)
  movb   $0x86,0x1f(%rax)
  movb   $0x88,0x2f(%rax)
  movb   $0x7e,0x3f(%rax)
  movb   $0x7c,0x4f(%rax)
  movb   $0x7a,0x5f(%rax)
  movb   $0x78,0x6f(%rax)
L23:
  lea    -0x1(%rsi),%edx
  mov    (%r11),%ecx
  cmp    $0x1,%edx
  jbe    L116
  lea    -0x3(%rsi),%edx
  cmp    $0x2,%edx
  jbe    L54
  lea    -0x6(%rsi),%edx
  cmp    $0x3,%edx
  jbe    L97
  lea    -0xa(%rsi),%edx
  cmp    $0x2,%edx
  jbe    L19
  mov    %ecx,%edx
  and    $0x7,%ecx
  shr    $0x3,%edx
  and    $0x7,%edx
  cmp    $0xf,%esi
  cmovne %edx,%ecx
L63:
  mov    %ebx,%edx
  mov    %r10d,%r15d
  mov    %cl,(%rdi)
  add    $0x1,%esi
  shl    %cl,%edx
  sub    %ecx,%r15d
  add    $0x2,%rdi
  add    $0x1,%rax
  lea    -0x80(%rdx),%ecx
  mov    %r15b,-0x3(%rdi)
  lea    (%rdx,%rdx,2),%r8d
  mov    %cl,-0x1(%rax)
  lea    -0x80(%rdx,%rdx,1),%ecx
  mov    %cl,0xf(%rax)
  lea    -0x80(%r8),%ecx
  mov    %cl,0x1f(%rax)
  lea    -0x80(,%rdx,4),%ecx
  mov    %cl,0x2f(%rax)
  mov    %r9d,%ecx
  sub    %edx,%ecx
  mov    %cl,0x3f(%rax)
  lea    -0x40(%rdx),%ecx
  sub    $0x20,%edx
  neg    %ecx
  neg    %edx
  add    %ecx,%ecx
  shl    $0x2,%edx
  mov    %cl,0x4f(%rax)
  mov    %r9d,%ecx
  sub    %r8d,%ecx
  mov    %dl,0x6f(%rax)
  mov    %cl,0x5f(%rax)
  cmp    $0x10,%esi
  jne    L32
  add    $0x1,%r10d
  add    $0x20,%rbp
  add    $0x4,%r11
  sub    $0xffffffffffffff80,%r12
  cmp    $0x8,%r10d
  jne    L50
  addq   $0x20,-0x10(%rsp)
  add    $0x400,%r13
  add    $0x100,%r14
  cmp    %r13,-0x8(%rsp)
  jne    L108
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L116:
  shr    $0xf,%ecx
  and    $0x7,%ecx
  jmp    L63
L19:
  shr    $0x6,%ecx
  and    $0x7,%ecx
  jmp    L63
L97:
  shr    $0x9,%ecx
  and    $0x7,%ecx
  jmp    L63
L54:
  shr    $0xc,%ecx
  and    $0x7,%ecx
  jmp    L63
```

assistant: ```c
void build_table_color(const unsigned int romtable[16][8], unsigned char p0004[16][1024], unsigned char p8004[16][256]) {
  int compression_mode, j, k, bit, pw;
  unsigned char *p0, *p8;
  const unsigned int *r;
  for (compression_mode = 0; compression_mode < 16; compression_mode++) {
    p0 = p0004[compression_mode];
    p8 = p8004[compression_mode];
    r = romtable[compression_mode];
    for (j = 0; j < 8; j++, r++, p0 += 128) {
      for (k = 0; k < 16; k++) {
        if (k == 0)
          bit = 1;
        else if (k >= 1 && k < 3)
          bit = (r[0] >> 15) & 7;
        else if (k >= 3 && k < 6)
          bit = (r[0] >> 12) & 7;
        else if (k >= 6 && k < 10)
          bit = (r[0] >> 9) & 7;
        else if (k >= 10 && k < 13)
          bit = (r[0] >> 6) & 7;
        else if (k >= 13 && k < 15)
          bit = (r[0] >> 3) & 7;
        else
          bit = (r[0]) & 7;
        if (k == 0)
          *p8++ = 8;
        else
          *p8++ = j - bit;
        *p8++ = bit;
        pw = 1 << bit;
        p0[k + 0x00] = (1 * pw) + 0x80;
        p0[k + 0x10] = (2 * pw) + 0x80;
        p0[k + 0x20] = (3 * pw) + 0x80;
        p0[k + 0x30] = (4 * pw) + 0x80;
        p0[k + 0x40] = (-1 * pw) + 0x80;
        p0[k + 0x50] = (-2 * pw) + 0x80;
        p0[k + 0x60] = (-3 * pw) + 0x80;
        p0[k + 0x70] = (-4 * pw) + 0x80;
      }
    }
  }
}
```