user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<Parser_SectionBAT>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  je     L172
  mov    %rdi,%r12
  movzbl (%rdi),%eax
  cmp    $0x4a,%al
  jne    L83
  movzbl 0x1(%rdi),%eax
  shl    $0x8,%eax
  and    $0xf00,%ax
  movzbl 0x2(%rdi),%edx
  or     %edx,%eax
  mov    %eax,%ebx
  lea    D169(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl (%r12),%edx
  lea    D113(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x1(%r12),%edx
  shr    $0x7,%dl
  movzbl %dl,%edx
  lea    D124(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzwl %bx,%edx
  lea    D144(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x3(%r12),%edx
  shl    $0x8,%edx
  movzbl 0x4(%r12),%eax
  or     %eax,%edx
  lea    D142(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x5(%r12),%edx
  sar    %edx
  and    $0x1f,%edx
  lea    D162(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x5(%r12),%edx
  and    $0x1,%edx
  lea    D83(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x6(%r12),%edx
  lea    D139(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x7(%r12),%edx
  lea    D22(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x8(%r12),%edx
  shl    $0x8,%edx
  and    $0xf00,%edx
  movzbl 0x9(%r12),%eax
  or     %eax,%edx
  lea    D170(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzwl %bx,%eax
  movzbl (%r12,%rax,1),%edx
  shl    $0x10,%edx
  movzbl 0x2(%r12,%rax,1),%ecx
  or     %ecx,%edx
  movzbl -0x1(%r12,%rax,1),%ecx
  shl    $0x18,%ecx
  or     %ecx,%edx
  movzbl 0x1(%r12,%rax,1),%eax
  shl    $0x8,%eax
  or     %eax,%edx
  lea    D19(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  movzbl 0x8(%r12),%r13d
  shl    $0x8,%r13d
  and    $0xf00,%r13w
  movzbl 0x9(%r12),%eax
  or     %eax,%r13d
  movzwl %r13w,%r13d
  test   %r13d,%r13d
  je     L20
  mov    $0xa,%ebx
  mov    $0x0,%ebp
  jmp    L38
L172:
  lea    D107(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  mov    $0xffffffff,%eax
  jmp    L84
L83:
  movzbl %al,%edx
  lea    D94(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  mov    $0xffffffff,%eax
  jmp    L84
L115:
  mov    $0x20,%edi
  call   <x47_Tag_DescriptorParser@plt>
L103:
  add    $0x2,%eax
  add    %eax,%ebx
  add    %eax,%ebp
  cmp    %r13d,%ebp
  jae    L131
L38:
  mov    %ebx,%esi
  add    %r12,%rsi
  movzbl (%rsi),%eax
  cmp    $0x4a,%al
  je     L25
  cmp    $0x5f,%al
  je     L202
  cmp    $0x47,%al
  je     L115
  mov    $0x20,%edi
  call   <x00_Tag_DescriptorParser@plt>
  jmp    L103
L25:
  mov    $0x20,%edi
  call   <x4A_Tag_DescriptorParser@plt>
  jmp    L103
L202:
  mov    $0x20,%edi
  call   <x5F_Tag_DescriptorParser@plt>
  jmp    L103
L20:
  mov    $0xa,%ebx
L131:
  mov    %ebx,%eax
  movzbl (%r12,%rax,1),%eax
  shl    $0x8,%eax
  and    $0xf00,%ax
  lea    0x1(%rbx),%edx
  movzbl (%r12,%rdx,1),%edx
  or     %edx,%eax
  movzwl %ax,%r15d
  mov    %r15d,0xc(%rsp)
  mov    %r15d,%edx
  lea    D166(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  add    $0x2,%ebx
  test   %r15d,%r15d
  je     L164
  mov    $0x0,%r15d
  jmp    L17
L180:
  mov    $0x20,%edi
  call   <x00_Tag_DescriptorParser@plt>
L152:
  add    $0x2,%eax
  add    %eax,%ebx
  add    %eax,%ebp
  cmp    %r14d,%ebp
  jae    L119
L166:
  mov    %ebx,%esi
  add    %r12,%rsi
  cmpb   $0x41,(%rsi)
  jne    L180
  mov    $0x20,%edi
  call   <x41_Tag_DescriptorParser@plt>
  jmp    L152
L119:
  add    $0x6,%r13d
  movzwl %r13w,%r13d
  add    %r13d,%r15d
  cmp    0xc(%rsp),%r15d
  jae    L164
L17:
  mov    %ebx,%eax
  movzbl (%r12,%rax,1),%edx
  shl    $0x8,%edx
  lea    0x1(%rbx),%eax
  movzbl (%r12,%rax,1),%eax
  or     %eax,%edx
  lea    D116(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  lea    0x2(%rbx),%eax
  movzbl (%r12,%rax,1),%edx
  shl    $0x8,%edx
  lea    0x3(%rbx),%eax
  movzbl (%r12,%rax,1),%eax
  or     %eax,%edx
  lea    D126(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  lea    0x4(%rbx),%eax
  movzbl (%r12,%rax,1),%r13d
  shl    $0x8,%r13d
  and    $0xf00,%r13w
  lea    0x5(%rbx),%eax
  movzbl (%r12,%rax,1),%eax
  or     %eax,%r13d
  movzwl %r13w,%r14d
  mov    %r14d,%edx
  lea    D154(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  add    $0x6,%ebx
  test   %r14d,%r14d
  je     L119
  mov    $0x0,%ebp
  jmp    L166
L164:
  lea    D100(%rip),%rsi
  mov    $0x20,%edi
  mov    $0x0,%eax
  call   <Parser_TsPacketLog@plt>
  mov    $0x0,%eax
L84:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D169
type: string
name: retrieve_data
arguments: data_tag: D113
type: string
name: retrieve_data
arguments: data_tag: D124
type: string
name: retrieve_data
arguments: data_tag: D144
type: string
name: retrieve_data
arguments: data_tag: D142
type: string
name: retrieve_data
arguments: data_tag: D162
type: string
name: retrieve_data
arguments: data_tag: D83
type: string
name: retrieve_data
arguments: data_tag: D139
type: string
name: retrieve_data
arguments: data_tag: D22
type: string
name: retrieve_data
arguments: data_tag: D170
type: string
name: retrieve_data
arguments: data_tag: D19
type: string
name: retrieve_data
arguments: data_tag: D107
type: string
name: retrieve_data
arguments: data_tag: D94
type: string
name: retrieve_data
arguments: data_tag: D166
type: string
name: retrieve_data
arguments: data_tag: D116
type: string
name: retrieve_data
arguments: data_tag: D126
type: string
name: retrieve_data
arguments: data_tag: D154
type: string
name: retrieve_data
arguments: data_tag: D100
type: string

tool: D169: ****************BAT Info****************


tool: D113: BAT table id = 0x%x


tool: D124: BAT section_syntax_indicator = 0x%x


tool: D144: BAT section_length = 0x%x


tool: D142: BAT bouquet_id = 0x%x


tool: D162: BAT version_number = 0x%x


tool: D83: BAT current_next_indicator = 0x%x


tool: D139: BAT section_number = 0x%x


tool: D22: BAT last_section_number = 0x%x


tool: D170: BAT bouquet_descriptors_length = 0x%x


tool: D19: BAT crc = 0x%08x


tool: D107: BAT error: section is NULL !


tool: D94: BAT table id is error : %x


tool: D166: BAT transport_stream_loop_length = 0x%x


tool: D116: BAT transport_stream_id = 0x%x


tool: D126: BAT original_network_id = 0x%x


tool: D154: BAT transport_descriptors_length = 0x%x


tool: D100: ****************************************


assistant: ```c
int Parser_SectionBAT(unsigned char *section) {
  unsigned short section_len = 0;
  unsigned short descriptor_loop_len = 0;
  unsigned short transport_stream_loop_len = 0;
  unsigned short transport_stream_offset = 0;
  unsigned int i = 0, j = 0;
  unsigned int data_offset = 0;
  int descriptor_offset = 0;
  int ret = -1;
  if (NULL == section) {
    Parser_TsPacketLog((0x00000020), "BAT error: section is NULL !\n");
    return -1;
  }
  if (0x4A != section[0]) {
    Parser_TsPacketLog((0x00000020), "BAT table id is error : %x\n", section[0]);
    return -1;
  }
  section_len = ((section[1] & 0x0F) << 8) | (section[2] & 0xFF);
  Parser_TsPacketLog((0x00000020), "****************BAT Info****************\n");
  Parser_TsPacketLog((0x00000020), "BAT table id = 0x%x\n", section[0]);
  Parser_TsPacketLog((0x00000020), "BAT section_syntax_indicator = 0x%x\n", (section[1] & 0x80) >> 7);
  Parser_TsPacketLog((0x00000020), "BAT section_length = 0x%x\n", section_len);
  Parser_TsPacketLog((0x00000020), "BAT bouquet_id = 0x%x\n", ((section[3] & 0xFF) << 8) | (section[4] & 0xFF));
  Parser_TsPacketLog((0x00000020), "BAT version_number = 0x%x\n", (section[5] & 0x3E) >> 1);
  Parser_TsPacketLog((0x00000020), "BAT current_next_indicator = 0x%x\n", section[5] & 0x01);
  Parser_TsPacketLog((0x00000020), "BAT section_number = 0x%x\n", section[6]);
  Parser_TsPacketLog((0x00000020), "BAT last_section_number = 0x%x\n", section[7]);
  Parser_TsPacketLog((0x00000020), "BAT bouquet_descriptors_length = 0x%x\n", ((section[8] & 0x0F) << 8) | (section[9] & 0xFF));
  Parser_TsPacketLog((0x00000020), "BAT crc = 0x%08x\n", (section[section_len - 1] << 24) | ((section[section_len] & 0xFF) << 16) | ((section[section_len + 1] & 0xFF) << 8) | (section[section_len + 2] & 0xFF));
  descriptor_loop_len = ((section[8] & 0x0F) << 8) | (section[9] & 0xFF);
  data_offset += 10;
  for (i = 0; i < descriptor_loop_len; i += descriptor_offset) {
    switch (section[data_offset]) {
    case 0x47:
      descriptor_offset = x47_Tag_DescriptorParser((0x00000020), section + data_offset);
      break;
    case 0x4A:
      descriptor_offset = x4A_Tag_DescriptorParser((0x00000020), section + data_offset);
      break;
    case 0x5F:
      descriptor_offset = x5F_Tag_DescriptorParser((0x00000020), section + data_offset);
      break;
    default:
      descriptor_offset = x00_Tag_DescriptorParser((0x00000020), section + data_offset);
      break;
    }
    descriptor_offset += 2;
    data_offset += descriptor_offset;
  }
  transport_stream_loop_len = ((section[data_offset] & 0x0F) << 8) | (section[data_offset + 1] & 0xFF);
  Parser_TsPacketLog((0x00000020), "BAT transport_stream_loop_length = 0x%x\n", transport_stream_loop_len);
  data_offset += 2;
  descriptor_offset = 0;
  for (i = 0; i < transport_stream_loop_len; i += transport_stream_offset) {
    Parser_TsPacketLog((0x00000020), "BAT transport_stream_id = 0x%x\n", ((section[data_offset] & 0xFF) << 8) | (section[data_offset + 1] & 0xFF));
    Parser_TsPacketLog((0x00000020), "BAT original_network_id = 0x%x\n", ((section[data_offset + 2] & 0xFF) << 8) | (section[data_offset + 3] & 0xFF));
    descriptor_loop_len = ((section[data_offset + 4] & 0x0F) << 8) | (section[data_offset + 5] & 0xFF);
    Parser_TsPacketLog((0x00000020), "BAT transport_descriptors_length = 0x%x\n", descriptor_loop_len);
    data_offset += 6;
    for (j = 0; j < descriptor_loop_len; j += descriptor_offset) {
      switch (section[data_offset]) {
      case 0x41:
        descriptor_offset = x41_Tag_DescriptorParser((0x00000020), section + data_offset);
        break;
      default:
        descriptor_offset = x00_Tag_DescriptorParser((0x00000020), section + data_offset);
        break;
      }
      descriptor_offset += 2;
      data_offset += descriptor_offset;
    }
    transport_stream_offset = descriptor_loop_len;
    transport_stream_offset += 6;
  }
  Parser_TsPacketLog((0x00000020), "****************************************\n");
  ret = 0;
  return ret;
}
```