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

```asm
<_upse_psf_get_tag>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L31
L59:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jle    L31
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x1f,%al
  jg     L31
  mov    -0x8(%rbp),%rax
  movb   $0x20,(%rax)
L31:
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl (%rax),%eax
  test   %al,%al
  jne    L59
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  jmp    L232
L172:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  jne    L80
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  subq   $0x1,-0x8(%rbp)
L232:
  mov    -0x8(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L172
  jmp    L147
L80:
  nop
  jmp    L147
L47:
  addq   $0x1,-0x18(%rbp)
L147:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L47
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L50
L266:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L89
  mov    $0x0,%eax
  jmp    L30
L89:
  addq   $0x1,-0x18(%rbp)
L50:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L122
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  jne    L266
L122:
  mov    -0x18(%rbp),%rax
  sub    -0x8(%rbp),%rax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x20(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L29
  mov    $0x0,%eax
  jmp    L30
L29:
  mov    -0x18(%rbp),%rax
  sub    -0x8(%rbp),%rax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x8(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  sub    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  jmp    L132
L146:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L41
  mov    $0x0,%eax
  jmp    L30
L41:
  addq   $0x1,-0x18(%rbp)
L132:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  jne    L146
  addq   $0x1,-0x18(%rbp)
  jmp    L252
L242:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L201
  mov    $0x0,%eax
  jmp    L30
L201:
  addq   $0x1,-0x18(%rbp)
L252:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L242
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x28(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L112
  mov    $0x0,%eax
  jmp    L30
L112:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    $0x1,%eax
L30:
  leave
  ret
```

assistant: ```c
int _upse_psf_get_tag(char *buf, char **key, char **val) {
  char *tmp;
  tmp = buf;
  while (*tmp++)
    if (*tmp > 0 && *tmp < 0x20)
      *tmp = 0x20;
  for (tmp = buf + strlen(buf) - 1; tmp >= buf; tmp--) {
    if (*tmp != 0x20)
      break;
    *tmp = 0;
  }
  while (*buf == 0x20)
    buf++;
  tmp = buf;
  while ((*buf != 0x20) && (*buf != '=')) {
    if (!*buf)
      return (0);
    buf++;
  }
  if (!(*key = malloc(buf - tmp + 1)))
    return (0);
  strncpy(*key, tmp, buf - tmp);
  (*key)[(buf - tmp)] = 0;
  while (*buf != '=') {
    if (!*buf)
      return (0);
    buf++;
  }
  buf++;
  while (*buf == 0x20) {
    if (!*buf)
      return (0);
    buf++;
  }
  if (!(*val = malloc(strlen(buf) + 1)))
    return (0);
  strcpy(*val, buf);
  return (1);
}
```