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

```asm
<expectedmsgrcd>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %edx,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rdi
  mov    $0x4,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  cmp    $0xa0,%ebx
  jg     L24
  cmp    $0x7f,%ebx
  jg     L338
  cmp    $0x40,%ebx
  je     L292
  jle    L280
  cmp    $0x60,%ebx
  jne    L211
L169:
  mov    0x4(%rbp),%eax
  test   %eax,%eax
  je     L92
  cmp    $0x60,%eax
  jne    L13
  jmp    L92
L280:
  test   %ebx,%ebx
  je     L169
  cmp    $0x20,%ebx
  jne    L211
L292:
  mov    0x4(%rbp),%eax
  sub    $0x20,%eax
  test   $0xffffffdf,%eax
  jne    L13
L92:
  mov    0x28(%rbp),%esi
  mov    %esi,%eax
  cmp    %r12,%rax
  sete   %r13b
  movzbl %r13b,%r13d
  jne    L33
L140:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L235
  mov    %r13d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L338:
  lea    -0x80(%rbx),%eax
  movabs $0x100000101,%rdx
  bt     %rax,%rdx
  jb     L98
L211:
  mov    %ebx,%esi
  lea    D48(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L13:
  mov    0x4(%rbp),%esi
  cmp    $0xa0,%esi
  ja     L208
  cmp    $0x7f,%esi
  ja     L103
  cmp    $0x40,%esi
  je     L48
  jbe    L270
  cmp    $0x60,%esi
  jne    L339
L62:
  lea    0x4(%rsp),%rdi
  lea    D32(%rip),%rsi
  call   <strcat@plt>
  jmp    L251
L24:
  lea    -0xb8(%rbx),%eax
  cmp    $0x28,%eax
  ja     L211
  movabs $0x10001000101,%rdx
  bt     %rax,%rdx
  jae    L211
  mov    0x4(%rbp),%eax
  sub    $0xb8,%eax
  cmp    $0x28,%eax
  ja     L13
  movabs $0x10001000101,%rdx
  bt     %rax,%rdx
  jb     L92
  mov    0x4(%rbp),%esi
L208:
  lea    -0xb8(%rsi),%eax
  cmp    $0x28,%eax
  ja     L339
  movabs $0x10001000101,%rdx
  bt     %rax,%rdx
  jae    L339
  lea    0x4(%rsp),%rdi
  lea    D69(%rip),%rsi
  call   <strcat@plt>
L251:
  mov    0x28(%rbp),%esi
  mov    $0x0,%r13d
L33:
  mov    0x4(%rbp),%ecx
  mov    %ebx,%r8d
  mov    %r12,%rdx
  lea    D71(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D1(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L140
L98:
  mov    0x4(%rbp),%eax
  mov    %eax,%edx
  and    $0xfffffff7,%edx
  cmp    $0x80,%edx
  je     L92
  cmp    $0xa0,%eax
  je     L92
  jmp    L13
L270:
  test   %esi,%esi
  je     L62
  cmp    $0x20,%esi
  jne    L339
L48:
  lea    0x4(%rsp),%rdi
  lea    D56(%rip),%rsi
  call   <strcat@plt>
  jmp    L251
L103:
  lea    -0x80(%rsi),%eax
  movabs $0x100000101,%rdx
  bt     %rax,%rdx
  jb     L226
L339:
  lea    D18(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L251
L226:
  lea    0x4(%rsp),%rdi
  lea    D27(%rip),%rsi
  call   <strcat@plt>
  jmp    L251
L235:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D48
type: string
name: extract_symbolic_data
arguments: label: D32
type: string
name: extract_symbolic_data
arguments: label: D69
type: string
name: extract_symbolic_data
arguments: label: D71
type: string
name: extract_symbolic_data
arguments: label: D1
type: string
name: extract_symbolic_data
arguments: label: D56
type: string
name: extract_symbolic_data
arguments: label: D18
type: string
name: extract_symbolic_data
arguments: label: D27
type: string

tool: D48: 
expectedmsgrcd not know tos=0x%x


tool: D32: BE

tool: D69: VO

tool: D71: 
expectedmsgrcd no match: rmsg[10] %u expect type %lu rmsg[1] as tos 0x%x expect tos 0x%x


tool: D1: expectedmsgrcd::rcv %s as repeate pkt for previous state


tool: D56: BK

tool: D18: 
expectedmsgrcd check unexpected TOS:not know rmsg[1]=0x%x


tool: D27: VI

assistant: ```c
int expectedmsgrcd(unsigned int *rmsg, unsigned long type, int tos) {
  char type_ok = 0, acBuf[4];
  char tos_ok = 0;
  int r = 0;
  memset(acBuf, 0, 4);
  switch (tos) {
  case 0xE0:
  case 0xD0:
  case 0xC0:
  case 0xB8:
    if (rmsg[1] == 0xE0 || rmsg[1] == 0xD0 || rmsg[1] == 0xC0 || rmsg[1] == 0xB8) {
      tos_ok = 1;
    }
    break;
  case 0xA0:
  case 0x80:
  case 0x88:
    if (rmsg[1] == 0xA0 || rmsg[1] == 0x80 || rmsg[1] == 0x88) {
      tos_ok = 1;
    }
    break;
  case 0x00:
  case 0x60:
    if (rmsg[1] == 0x00 || rmsg[1] == 0x60) {
      tos_ok = 1;
    }
    break;
  case 0x20:
  case 0x40:
    if (rmsg[1] == 0x20 || rmsg[1] == 0x40) {
      tos_ok = 1;
    }
    break;
  default:
    printf("\nexpectedmsgrcd not know tos=0x%x\n", tos);
  }
  if (tos_ok == 0) {
    switch (rmsg[1]) {
    case 0xE0:
    case 0xD0:
    case 0xC0:
    case 0xB8:
      strcat(acBuf, "VO");
      break;
    case 0xA0:
    case 0x80:
    case 0x88:
      strcat(acBuf, "VI");
      break;
    case 0x00:
    case 0x60:
      strcat(acBuf, "BE");
      break;
    case 0x20:
    case 0x40:
      strcat(acBuf, "BK");
      break;
    default:
      printf("\nexpectedmsgrcd check unexpected TOS:not know rmsg[1]=0x%x\n", rmsg[1]);
    }
  }
  type_ok = ((rmsg[10] == type) ? 1 : 0);
  r = (type_ok && tos_ok);
  if (!r) {
    printf("\nexpectedmsgrcd no match: rmsg[10] %u expect type %lu rmsg[1] as tos 0x%x expect tos 0x%x\n", rmsg[10], type, rmsg[1], tos);
    printf("expectedmsgrcd::rcv %s as repeate pkt for previous state\n", acBuf);
  }
  return r;
}
```