user: Please show me the C implementation that matches the assembly code listed below:

```asm
<parse_ttx_pes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%ecx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L1
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L1
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  je     L46
L1:
  mov    -0x18(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edi
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  mov    -0x10(%rbp),%rcx
  mov    (%rcx),%ecx
  lea    -0x1(%rcx),%esi
  mov    %edi,%r8d
  mov    %edx,%ecx
  mov    %eax,%edx
  lea    D38(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L46:
  mov    -0x18(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  cmp    $0xbd,%eax
  je     L20
  mov    -0x18(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%eax
  mov    -0x10(%rbp),%rdx
  mov    (%rdx),%edx
  lea    -0x1(%rdx),%ecx
  mov    %eax,%edx
  mov    %ecx,%esi
  lea    D68(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L20:
  mov    -0x18(%rbp),%rax
  add    $0x10,%rax
  mov    %rax,%rdi
  call   <read_be16@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x20(%rbp),%rax
  sub    $0x6,%rax
  cmp    %rax,-0x8(%rbp)
  je     L12
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%ecx
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L12:
  mov    -0x8(%rbp),%rax
  lea    0x6(%rax),%rcx
  mov    %rcx,%rax
  shr    $0x3,%rax
  movabs $0x1642c8590b21642d,%rdx
  mul    %rdx
  mov    %rdx,%rax
  shr    %rax
  imul   $0xb8,%rax,%rdx
  mov    %rcx,%rax
  sub    %rdx,%rax
  test   %rax,%rax
  je     L29
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,%esi
  lea    D0(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L29:
  mov    -0x18(%rbp),%rax
  add    $0x18,%rax
  mov    (%rax),%eax
  and    $0x4,%eax
  test   %eax,%eax
  jne    L86
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,%esi
  lea    D40(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L86:
  mov    -0x18(%rbp),%rax
  add    $0x20,%rax
  mov    (%rax),%eax
  cmp    $0x24,%eax
  je     L131
  mov    -0x18(%rbp),%rax
  add    $0x20,%rax
  mov    (%rax),%eax
  mov    -0x10(%rbp),%rdx
  mov    (%rdx),%edx
  lea    -0x1(%rdx),%esi
  mov    $0x24,%ecx
  mov    %eax,%edx
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L112
L131:
  mov    -0x20(%rbp),%rax
  lea    -0x2d(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    $0xb4,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <parse_ttx@plt>
  mov    -0x10(%rbp),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,%esi
  lea    D63(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L112:
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D15
type_infered: string
name: retrieve_data
arguments: tag: D38
type_infered: string
name: retrieve_data
arguments: tag: D68
type_infered: string
name: retrieve_data
arguments: tag: D31
type_infered: string
name: retrieve_data
arguments: tag: D0
type_infered: string
name: retrieve_data
arguments: tag: D40
type_infered: string
name: retrieve_data
arguments: tag: D23
type_infered: string
name: retrieve_data
arguments: tag: D63
type_infered: string

tool: D15: TTX_PES[%u] : Received PES packet of size %zu.


tool: D38: TTX_PES[%u] : PES magic number incorrect : %hhx%hhx%hhx.


tool: D68: TTX_PES[%u] : PES stream ID incorrect : %hhx.


tool: D31: TTX_PES[%u] : PES packet length mismatch : %hu.


tool: D0: TTX_PES[%u] : Declared PES packet length incorrect.


tool: D40: TTX_PES[%u] : Data alignment indicator set to zero.


tool: D23: TTX_PES[%u] : Header length %hhu different from expected (%hhu).


tool: D63: TTX_PES[%u] : Finished.


assistant: ```c
void parse_ttx_pes(const uint8_t *pes, size_t size, void *user_data) {
  unsigned int *ttx_pes_pkt_no = user_data;
  ++(*ttx_pes_pkt_no);
  do {
    printf("TTX_PES[%u] : "
           "Received PES packet of size %zu.\n",
           *ttx_pes_pkt_no - 1, size);
  } while (0);
  if (pes[0] != 0x00 || pes[1] != 0x00 || pes[2] != 0x01) {
    do {
      printf("TTX_PES[%u] : "
             "PES magic number incorrect : %hhx%hhx%hhx.\n",
             *ttx_pes_pkt_no - 1, pes[0], pes[1], pes[2]);
    } while (0);
    return;
  }
  if (pes[3] != 0xBD) {
    do {
      printf("TTX_PES[%u] : "
             "PES stream ID incorrect : %hhx.\n",
             *ttx_pes_pkt_no - 1, pes[3]);
    } while (0);
    return;
  }
  uint16_t pes_pkt_len = read_be16(pes + 4);
  if (pes_pkt_len != size - 6) {
    do {
      printf("TTX_PES[%u] : "
             "PES packet length mismatch : %hu.\n",
             *ttx_pes_pkt_no - 1, pes_pkt_len);
    } while (0);
    return;
  }
  if (((pes_pkt_len + 6) % 184) != 0) {
    do {
      printf("TTX_PES[%u] : "
             "Declared PES packet length incorrect.\n",
             *ttx_pes_pkt_no - 1);
    } while (0);
    return;
  }
  if (!(pes[6] & 0x04)) {
    do {
      printf("TTX_PES[%u] : "
             "Data alignment indicator set to zero.\n",
             *ttx_pes_pkt_no - 1);
    } while (0);
    return;
  }
  if (pes[8] != 0x24) {
    do {
      printf("TTX_PES[%u] : "
             "Header length %hhu different from expected (%hhu).\n",
             *ttx_pes_pkt_no - 1, pes[8], 0x24);
    } while (0);
    return;
  }
  parse_ttx(pes + 9 + 0x24, size - 9 - 0x24);
  do {
    printf("TTX_PES[%u] : "
           "Finished.\n",
           *ttx_pes_pkt_no - 1);
  } while (0);
}
```