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

```asm
<listen_parse>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  mov    %rsi,(%rsp)
  mov    %rdx,0x8(%rsp)
  mov    %rcx,%r15
  movl   $0xffffffff,(%rcx)
  movl   $0xffffffff,(%rdx)
  movq   $0x0,(%rsi)
  call   <strlen@plt>
  mov    %eax,%ebx
  lea    D5(%rip),%rdi
  call   <strlen@plt>
  cmp    %eax,%ebx
  jg     L252
L28:
  mov    %r12,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%r12,%rax,1),%rbx
  mov    $0x0,%ebp
  mov    $0x0,%r13d
  mov    $0x0,%r14d
  mov    $0x0,%eax
  cmp    %rbx,%r12
  jbe    L207
L198:
  test   %al,%al
  je     L71
  jmp    L63
L252:
  lea    D5(%rip),%rbx
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <memcmp@plt>
  test   %rax,%rax
  jne    L28
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%r12
  jmp    L28
L101:
  movsbl %dil,%edi
  call   <isdigit@plt>
  test   %eax,%eax
  je     L224
  cmpb   $0x2d,(%rbx)
  je     L331
  test   %ebp,%ebp
  je     L204
  add    $0x1,%r14d
L248:
  sub    $0x1,%rbx
  cmp    %rbx,%r12
  ja     L224
L207:
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L224
  movsbl %dil,%edi
  call   <isspace@plt>
  test   %rax,%rax
  je     L73
  mov    %r13d,%eax
  or     %ebp,%eax
  je     L181
L73:
  movzbl (%rbx),%edi
  cmp    $0x2d,%dil
  jne    L101
L331:
  test   %ebp,%ebp
  jne    L327
  mov    $0x1,%ebp
  test   %r13d,%r13d
  jle    L248
  lea    0x1(%rbx),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  mov    %eax,(%r15)
  jmp    L248
L204:
  add    $0x1,%r13d
  jmp    L248
L181:
  mov    %eax,%ebp
  mov    %eax,%r13d
  jmp    L248
L224:
  test   %ebp,%ebp
  setne  %al
  test   %r14d,%r14d
  je     L7
  test   %al,%al
  je     L7
  lea    0x1(%rbx),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  mov    0x8(%rsp),%rcx
  mov    %eax,(%rcx)
L63:
  test   %r14d,%r14d
  je     L219
  test   %r13d,%r13d
  je     L219
L71:
  or     %r14d,%r13d
  je     L292
  cmp    %rbx,%r12
  jb     L78
L292:
  cmp    %rbx,%r12
  jb     L68
L166:
  sub    %r12,%rbx
  lea    0x1(%rbx),%ebp
  mov    $0x0,%eax
  test   %ebp,%ebp
  jle    L288
  lea    0x2(%rbx),%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,%rdi
  mov    (%rsp),%rax
  mov    %rdi,(%rax)
  mov    %ebp,%edx
  mov    %r12,%rsi
  call   <memcpy@plt>
  mov    $0x0,%eax
  jmp    L288
L7:
  test   %r13d,%r13d
  je     L198
  test   %ebp,%ebp
  jne    L198
  lea    0x1(%rbx),%rdi
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <strtol@plt>
  mov    %eax,(%r15)
  jmp    L71
L78:
  mov    $0x8,%eax
  cmpb   $0x3a,(%rbx)
  jne    L288
L313:
  sub    $0x1,%rbx
  jmp    L166
L68:
  cmpb   $0x3a,(%rbx)
  jne    L166
  jmp    L313
L327:
  mov    $0x8,%eax
L288:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L219:
  mov    $0x8,%eax
  jmp    L288
```

tool_calls: name: disassemble_data
arguments: data_tag: D5
type_infered: string

tool: D5: spice://

assistant: ```c
int listen_parse(const char *listen_spec, char **addr, int *port_start, int *port_end) {
  int leading = 0;
  int trailing = 0;
  int hyphen = 0;
  const char *p;
  int len;
  *port_start = *port_end = -1;
  *addr = NULL;
  if (strlen(listen_spec) > strlen("spice://"))
    if (memcmp(listen_spec, "spice://", strlen("spice://")) == 0)
      listen_spec += strlen("spice://");
  p = listen_spec + strlen(listen_spec) - 1;
  for (; p >= listen_spec && *p; p--) {
    if (isspace(*p) && !hyphen && !trailing)
      continue;
    if (*p != '-' && !isdigit(*p))
      break;
    if (*p == '-') {
      if (hyphen)
        return 8;
      hyphen++;
      if (trailing > 0)
        *port_end = strtol(p + 1, NULL, 0);
      continue;
    }
    if (hyphen)
      leading++;
    else
      trailing++;
  }
  if (leading && hyphen)
    *port_start = strtol(p + 1, NULL, 0);
  if (trailing && !hyphen)
    *port_end = strtol(p + 1, NULL, 0);
  if (hyphen && (!leading || !trailing))
    return 8;
  if (leading || trailing)
    if (p > listen_spec && *p != ':')
      return 8;
  if (p > listen_spec && *p == ':')
    p--;
  len = p - listen_spec + 1;
  if (len > 0) {
    *addr = calloc(1, len + 1);
    memcpy(*addr, listen_spec, len);
  }
  return 0;
}
```