user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<BbdBridge_OnPacketReceived>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,%eax
  mov    %ax,-0x2c(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  movzwl -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <BbdBridge_CheckPacketSanity@plt>
  test   %eax,%eax
  je     L28
  movzwl -0x2c(%rbp),%eax
  mov    %rax,-0x8(%rbp)
  jmp    L15
L77:
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %ax,-0x14(%rbp)
  subq   $0x1,-0x8(%rbp)
  movzwl -0x14(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L2
  andw   $0xff7f,-0x14(%rbp)
  shlw   $0x8,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %ax,-0x14(%rbp)
  subq   $0x1,-0x8(%rbp)
L2:
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %ax,-0x12(%rbp)
  subq   $0x1,-0x8(%rbp)
  movzwl -0x12(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L45
  andw   $0xff7f,-0x12(%rbp)
  shlw   $0x8,-0x12(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %ax,-0x12(%rbp)
  subq   $0x1,-0x8(%rbp)
L45:
  movzwl -0x12(%rbp),%edx
  movzwl -0x14(%rbp),%eax
  mov    -0x28(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <BbdBridge_OnRpcReceived@plt>
  test   %eax,%eax
  je     L55
  addl   $0x1,-0x10(%rbp)
  jmp    L78
L55:
  addl   $0x1,-0xc(%rbp)
L78:
  movzwl -0x12(%rbp),%eax
  add    %rax,-0x28(%rbp)
  movzwl -0x12(%rbp),%eax
  sub    %rax,-0x8(%rbp)
L15:
  cmpq   $0x0,-0x8(%rbp)
  jg     L77
  jmp    L10
L28:
  mov    $0x167,%edx
  lea    D3(%rip),%rax
  mov    %rax,%rsi
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L10:
  cmpl   $0x0,-0x10(%rbp)
  setg   %al
  movzbl %al,%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D3
type: string
name: read_data
arguments: data_label: D6
type: string

tool: D3: BbdBridge_OnPacketReceived

tool: D6: error in %s:%d


assistant: ```c
int BbdBridge_OnPacketReceived(unsigned char *pucData, unsigned short usSize) {
  int sensor = 0, gnss = 0;
  if (BbdBridge_CheckPacketSanity(pucData, usSize)) {
    long lSize = (long)usSize;
    while (lSize > 0) {
      unsigned short usRpcId = *pucData++;
      unsigned short usRpcLen;
      lSize--;
      if (usRpcId & 0x80) {
        usRpcId &= ~0x80;
        usRpcId <<= 8;
        usRpcId |= *pucData++;
        lSize--;
      }
      usRpcLen = *pucData++;
      lSize--;
      if (usRpcLen & 0x80) {
        usRpcLen &= ~0x80;
        usRpcLen <<= 8;
        usRpcLen |= *pucData++;
        lSize--;
      }
      if (BbdBridge_OnRpcReceived(usRpcId, pucData, usRpcLen))
        sensor++;
      else
        gnss++;
      pucData += usRpcLen;
      lSize -= usRpcLen;
    }
  } else {
    if (1)
      printf("error in %s:%d\n", __func__, 359);
  }
  return (sensor > 0);
}
```