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

```asm
<valid_port>:
  endbr64
  push   %rbp
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L223
  movb   $0x0,0x7(%rsp)
  mov    %rdi,%rbp
  call   <strlen@plt>
  cmp    $0x8,%eax
  je     L94
  cmp    $0x9,%eax
  je     L155
L223:
  xor    %eax,%eax
L153:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L15
  add    $0x20,%rsp
  pop    %rbp
  ret
  nopl   (%rax)
L155:
  movzbl 0x0(%rbp),%eax
  cmp    $0x41,%al
  je     L187
  cmp    $0x42,%al
  je     L111
  cmp    $0x30,%al
  jne    L223
  cmpb   $0x32,0x1(%rbp)
  jne    L223
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  sub    $0x8,%rsp
  lea    0xf(%rsp),%rax
  lea    0x2(%rbp),%rdi
  push   %rax
  lea    D24(%rip),%rsi
  xor    %eax,%eax
  lea    0x24(%rsp),%r9
  lea    0x18(%rsp),%r8
  call   <sscanf@plt>
  pop    %rdx
  pop    %rcx
  cmp    $0x4,%eax
  jne    L223
  mov    0xc(%rsp),%eax
  sub    $0x1,%eax
  cmp    $0x31,%eax
  jbe    L139
  jmp    L223
  nopw   0x0(%rax,%rax,1)
L94:
  lea    0xc(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  sub    $0x8,%rsp
  mov    %rbp,%rdi
  lea    0xf(%rsp),%rax
  lea    D23(%rip),%rsi
  push   %rax
  xor    %eax,%eax
  lea    0x24(%rsp),%r9
  lea    0x20(%rsp),%r8
  call   <sscanf@plt>
  pop    %r9
  pop    %r10
  cmp    $0x4,%eax
  jne    L223
  cmpl   $0x2,0x8(%rsp)
  jne    L223
  mov    0xc(%rsp),%eax
  cmp    $0x27,%eax
  ja     L223
  movabs $0xffffff7df7dfffff,%rdx
  bt     %rax,%rdx
  jb     L223
  mov    0x10(%rsp),%eax
  sub    $0x1,%eax
  cmp    $0x8,%eax
  ja     L223
  mov    0x14(%rsp),%r8d
  xor    %eax,%eax
  test   %r8d,%r8d
  setne  %al
  jmp    L153
  nopw   0x0(%rax,%rax,1)
L187:
  cmpb   $0x42,0x1(%rbp)
  jne    L223
L72:
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  sub    $0x8,%rsp
  lea    0xf(%rsp),%rax
  lea    0x2(%rbp),%rdi
  push   %rax
  lea    D24(%rip),%rsi
  xor    %eax,%eax
  lea    0x24(%rsp),%r9
  lea    0x18(%rsp),%r8
  call   <sscanf@plt>
  pop    %rsi
  pop    %rdi
  cmp    $0x4,%eax
  jne    L223
  mov    0xc(%rsp),%eax
  sub    $0x1,%eax
  cmp    $0x2,%eax
  ja     L223
L139:
  mov    0x10(%rsp),%eax
  sub    $0x1,%eax
  cmp    $0x13,%eax
  ja     L223
  mov    0x14(%rsp),%eax
  sub    $0x1,%eax
  cmp    $0x1f,%eax
  setbe  %al
  movzbl %al,%eax
  jmp    L153
  nopw   0x0(%rax,%rax,1)
L111:
  movzbl 0x1(%rbp),%eax
  sub    $0x41,%eax
  cmp    $0x19,%al
  ja     L223
  jmp    L72
L15:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D24
datatype: string
name: unpack_data
arguments: data_tag: D23
datatype: string

tool: D24: %2u%2u%c%2u%c

tool: D23: %2u%2u%2u%2u%c

assistant: ```c
int valid_port(const char *port) {
  unsigned int h, r, p, o;
  char c, t;
  if (!port)
    return 0;
  c = 0;
  switch (strlen(port)) {
  case 8:
    if (sscanf(port, "%2u%2u%2u%2u%c", &h, &r, &p, &o, &c) != 4)
      return 0;
    if (h != 2)
      return 0;
    if (!(r == 21 || r == 27 || r == 33 || r == 39))
      return 0;
    if (p < 1 || p > 9)
      return 0;
    if (o < 1 || p > 32)
      return 0;
    return 1;
  case 9:
    if ((port[0] == 'A' && port[1] == 'B') || (port[0] == 'B' && (port[1] >= 'A' && port[1] <= 'Z'))) {
      if (sscanf(port + 2, "%2u%2u%c%2u%c", &r, &p, &t, &o, &c) != 4)
        return 0;
      if (r < 1 || r > 3)
        return 0;
      if (p < 1 || p > 20)
        return 0;
      if (o < 1 || o > 32)
        return 0;
      return 1;
    } else if (port[0] == '0' && port[1] == '2') {
      if (sscanf(port + 2, "%2u%2u%c%2u%c", &r, &p, &t, &o, &c) != 4)
        return 0;
      if (r < 1 || r > 50)
        return 0;
      if (p < 1 || p > 20)
        return 0;
      if (o < 1 || o > 32)
        return 0;
      return 1;
    } else
      return 0;
  }
  return 0;
}
```