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

```asm
<NESConvertTileDataToComposite>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  lea    D32(%rip),%rsi
  push   %rbx
  mov    %edx,%ebx
  sub    $0x78,%rsp
  mov    %rdi,0x40(%rsp)
  mov    $0x3,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x68(%rsp)
  xor    %eax,%eax
  call   <v_printf@plt>
  test   %rbp,%rbp
  sete   %al
  test   %ebx,%ebx
  sete   %dl
  or     %dl,%al
  mov    $0x0,%eax
  jne    L27
  test   %r15,%r15
  je     L27
  test   $0xf,%bl
  je     L102
L27:
  mov    0x68(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L100
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L102:
  test   %ebx,%ebx
  lea    0xf(%rbx),%eax
  cmovns %ebx,%eax
  sar    $0x4,%eax
  mov    %eax,0x48(%rsp)
  shl    $0x6,%eax
  mov    %eax,%edi
  mov    %eax,0x4c(%rsp)
  call   <malloc@plt>
  mov    %rax,0x38(%rsp)
  cmp    $0xf,%ebx
  jle    L33
  lea    0x58(%rsp),%rax
  mov    %rbp,0x28(%rsp)
  lea    D30(%rip),%r15
  mov    %rax,0x18(%rsp)
  lea    0x60(%rsp),%rax
  movq   $0x0,0x30(%rsp)
  movl   $0x0,0x24(%rsp)
  mov    %rax,0x10(%rsp)
  nopl   (%rax)
L48:
  addl   $0x1,0x24(%rsp)
  mov    0x24(%rsp),%eax
  mov    $0x3,%edi
  xor    %ebx,%ebx
  mov    0x48(%rsp),%ecx
  lea    D2(%rip),%rsi
  mov    %eax,%edx
  xor    %eax,%eax
  call   <v_printf@plt>
  mov    0x28(%rsp),%r13
  mov    0x10(%rsp),%rbp
  mov    0x18(%rsp),%r12
  nopl   0x0(%rax,%rax,1)
L97:
  movzbl 0x0(%r13,%rbx,1),%edx
  movzbl 0x8(%r13,%rbx,1),%ecx
  lea    D7(%rip),%rsi
  xor    %eax,%eax
  mov    $0x4,%edi
  mov    %dl,(%r12,%rbx,1)
  mov    %cl,0x0(%rbp,%rbx,1)
  add    $0x1,%rbx
  call   <v_printf@plt>
  cmp    $0x8,%rbx
  jne    L97
  mov    0x30(%rsp),%rdi
  mov    0x38(%rsp),%rax
  movq   $0x0,(%rsp)
  add    %rdi,%rax
  mov    %rax,0x8(%rsp)
  mov    %edi,%eax
  nopl   (%rax)
L108:
  mov    (%rsp),%rcx
  mov    0x10(%rsp),%rsi
  add    $0x8,%eax
  mov    $0x7,%ebp
  mov    %eax,0x20(%rsp)
  mov    0x8(%rsp),%rbx
  movzbl (%rsi,%rcx,1),%r13d
  mov    0x18(%rsp),%rsi
  mov    %ecx,%r14d
  movzbl (%rsi,%rcx,1),%r12d
  nopl   0x0(%rax)
L8:
  mov    %ebp,%edx
  mov    %r13d,%esi
  mov    %r12d,%edi
  add    $0x1,%rbx
  call   <NESCombineBits@plt>
  mov    0x20(%rsp),%r8d
  mov    %ebp,%ecx
  mov    %r14d,%edx
  mov    %al,-0x1(%rbx)
  movsbl (%rbx),%r9d
  xor    %eax,%eax
  mov    %r15,%rsi
  sub    %ebp,%r8d
  mov    $0x4,%edi
  call   <v_printf@plt>
  sub    $0x1,%ebp
  jae    L8
  addq   $0x1,(%rsp)
  mov    (%rsp),%rax
  addq   $0x8,0x8(%rsp)
  cmp    $0x8,%rax
  je     L41
  mov    0x20(%rsp),%eax
  jmp    L108
  nop
L41:
  addq   $0x40,0x30(%rsp)
  mov    0x48(%rsp),%edi
  addq   $0x10,0x28(%rsp)
  cmp    %edi,0x24(%rsp)
  jl     L48
L33:
  mov    0x4c(%rsp),%edx
  mov    0x38(%rsp),%rsi
  mov    0x40(%rsp),%rdi
  call   <memcpy@plt>
  mov    $0x1,%eax
  jmp    L27
L100:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D32
type: string
name: extract_symbolic_data
arguments: data_label: D30
type: string
name: extract_symbolic_data
arguments: data_label: D2
type: string
name: extract_symbolic_data
arguments: data_label: D7
type: string

tool: D32: Start NESConvertTileDataToComposite()

tool: D30: Composite (%d,%d:%d): %d

tool: D2: curTile: %d/%d

tool: D7: Channels A/B: %d/%d

assistant: ```c
int NESConvertTileDataToComposite(char *buf, char *tileData, int size) {
  v_printf(3, "Start NESConvertTileDataToComposite()");
  if (!tileData || !size || !buf)
    return 0;
  if (size % 16)
    return 0;
  int tileCount = size / 16;
  unsigned char channel_a[8], channel_b[8];
  int i = 0;
  int j = 0;
  int curTile = 0;
  char *composite = (char *)malloc(64 * tileCount);
  for (curTile = 0; curTile < tileCount; curTile++) {
    v_printf(3, "curTile: %d/%d", curTile + 1, tileCount);
    for (i = 0; i < 8; i++) {
      channel_a[i] = tileData[16 * (curTile) + i];
      channel_b[i] = tileData[16 * (curTile) + i + 8];
      v_printf(4, "Channels A/B: %d/%d", channel_a[i], channel_b[i]);
    }
    for (i = 0; i < 8; i++) {
      for (j = 7; j >= 0; j--) {
        int pixel_offset = (i * 8) + (8 - j);
        composite[(pixel_offset + curTile * 64) - 1] = NESCombineBits(channel_a[i], channel_b[i], j);
        v_printf(4, "Composite (%d,%d:%d): %d", i, j, (pixel_offset + curTile * 64), composite[pixel_offset + curTile * 64]);
      }
    }
  }
  memcpy(buf, composite, 64 * tileCount);
  return 1;
}
```