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

```asm
<fill_table_color>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdx,-0x10(%rsp)
  mov    %rcx,-0x8(%rsp)
  mov    %edi,%eax
  shl    $0x8,%eax
  mov    %eax,%eax
  lea    (%rsi,%rax,4),%rax
  movq   $0x0,-0x18(%rsp)
  mov    $0x1,%r12d
  mov    $0x8,%r14d
  mov    $0xffffff80,%r8d
  jmp    L170
L147:
  mov    (%r10),%ecx
  shr    $0xf,%ecx
  and    $0x7,%ecx
  jmp    L40
L81:
  mov    (%r10),%ecx
  shr    $0xc,%ecx
  and    $0x7,%ecx
  jmp    L40
L178:
  mov    (%r10),%ecx
  shr    $0x9,%ecx
  and    $0x7,%ecx
  jmp    L40
L107:
  mov    (%r10),%ecx
  shr    $0x6,%ecx
  and    $0x7,%ecx
  jmp    L40
L166:
  mov    (%r10),%ecx
  shr    $0x3,%ecx
  and    $0x7,%ecx
  jmp    L40
L27:
  add    $0x20,%r11
  add    $0x1,%r9d
  add    $0x4,%r10
  sub    $0xffffffffffffff80,%rbx
  cmp    $0x8,%r9d
  je     L193
L169:
  lea    0x1(%r11),%rdi
  mov    %rbx,%rdx
  mov    $0x0,%esi
  jmp    L118
L193:
  add    $0x20,%rbp
  add    $0x400,%r13
  addq   $0x100,-0x28(%rsp)
  cmp    -0x20(%rsp),%rbp
  je     L43
L86:
  mov    %r13,%rbx
  mov    -0x28(%rsp),%r11
  mov    %rbp,%r10
  mov    $0x0,%r9d
  jmp    L169
L43:
  addq   $0x1000,-0x18(%rsp)
  mov    -0x18(%rsp),%rax
  cmp    $0x2000,%rax
  je     L96
  mov    -0x20(%rsp),%rax
L170:
  mov    %rax,%rbp
  mov    -0x10(%rsp),%rdi
  mov    -0x18(%rsp),%rbx
  lea    (%rdi,%rbx,4),%r13
  mov    -0x8(%rsp),%rdi
  add    %rbx,%rdi
  mov    %rdi,-0x28(%rsp)
  add    $0x200,%rax
  mov    %rax,-0x20(%rsp)
  jmp    L86
L106:
  mov    %rdi,%r15
  mov    %r12d,%ecx
  mov    %r14d,%eax
L187:
  mov    %al,-0x1(%rdi)
  mov    %cl,(%r15)
  mov    %r12d,%eax
  shl    %cl,%eax
  lea    -0x80(%rax),%ecx
  mov    %cl,(%rdx)
  lea    -0x80(%rax,%rax,1),%ecx
  mov    %cl,0x10(%rdx)
  lea    (%rax,%rax,2),%r15d
  lea    -0x80(%r15),%ecx
  mov    %cl,0x20(%rdx)
  lea    -0x80(,%rax,4),%ecx
  mov    %cl,0x30(%rdx)
  mov    %r8d,%ecx
  sub    %eax,%ecx
  mov    %cl,0x40(%rdx)
  lea    -0x40(%rax),%ecx
  neg    %ecx
  add    %ecx,%ecx
  mov    %cl,0x50(%rdx)
  mov    %r8d,%ecx
  sub    %r15d,%ecx
  mov    %cl,0x60(%rdx)
  sub    $0x20,%eax
  neg    %eax
  shl    $0x2,%eax
  mov    %al,0x70(%rdx)
  add    $0x1,%esi
  add    $0x2,%rdi
  add    $0x1,%rdx
  cmp    $0x10,%esi
  je     L27
L118:
  test   %esi,%esi
  je     L106
  mov    %esi,%eax
  lea    -0x1(%rsi),%ecx
  cmp    $0x1,%ecx
  jbe    L147
  lea    -0x3(%rsi),%ecx
  cmp    $0x2,%ecx
  jbe    L81
  lea    -0x6(%rsi),%ecx
  cmp    $0x3,%ecx
  jbe    L178
  lea    -0xa(%rsi),%ecx
  cmp    $0x2,%ecx
  jbe    L107
  sub    $0xd,%eax
  cmp    $0x1,%eax
  jbe    L166
  mov    (%r10),%ecx
  and    $0x7,%ecx
L40:
  mov    %rdi,%r15
  mov    %r9d,%eax
  sub    %ecx,%eax
  jmp    L187
L96:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void fill_table_color(unsigned int version, const unsigned int *romtable, unsigned char *p0004, unsigned char *p8004) {
  const unsigned int *table;
  unsigned char *p0, *p8;
  int i, j, k;
  int dl, bit, pw;
  romtable += version * 256;
  for (i = 0; i < 2; i++) {
    table = romtable + i * 128;
    for (dl = 0; dl < 16; dl++) {
      p0 = p0004 + (i << 14) + (dl << 10);
      p8 = p8004 + (i << 12) + (dl << 8);
      for (j = 0; j < 8; j++, table++, p0 += 128) {
        for (k = 0; k < 16; k++) {
          if (k == 0)
            bit = 1;
          else if (k >= 1 && k < 3)
            bit = (table[0] >> 15) & 7;
          else if (k >= 3 && k < 6)
            bit = (table[0] >> 12) & 7;
          else if (k >= 6 && k < 10)
            bit = (table[0] >> 9) & 7;
          else if (k >= 10 && k < 13)
            bit = (table[0] >> 6) & 7;
          else if (k >= 13 && k < 15)
            bit = (table[0] >> 3) & 7;
          else
            bit = (table[0]) & 7;
          if (k == 0)
            *(unsigned char *)p8++ = 8;
          else
            *(unsigned char *)p8++ = j - bit;
          *(unsigned char *)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] = (-pw) + 0x80;
          p0[k + 0x50] = (2 * -pw) + 0x80;
          p0[k + 0x60] = (3 * -pw) + 0x80;
          p0[k + 0x70] = (4 * -pw) + 0x80;
        }
      }
    }
  }
}
```