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

```asm
<logtools_str_get_valstr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0xc(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L162
L221:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x7b,%al
  jne    L188
  mov    -0x18(%rbp),%rax
  mov    $0x7d,%esi
  mov    %rax,%rdi
  call   <rindex@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L151
  mov    $0x0,%eax
  jmp    L120
L151:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <logtools_str_get_valstr>
  jmp    L120
L188:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x28,%al
  jne    L199
  mov    -0x18(%rbp),%rax
  mov    $0x29,%esi
  mov    %rax,%rdi
  call   <rindex@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L61
  mov    $0x0,%eax
  jmp    L120
L61:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <logtools_str_get_valstr>
  jmp    L120
L199:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x5b,%al
  jne    L37
  mov    -0x18(%rbp),%rax
  mov    $0x5d,%esi
  mov    %rax,%rdi
  call   <rindex@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L62
  mov    $0x0,%eax
  jmp    L120
L62:
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <logtools_str_get_valstr>
  jmp    L120
L37:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L11
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x9,%al
  jne    L63
L11:
  addl   $0x1,-0xc(%rbp)
  jmp    L162
L63:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x10(%rbp)
  jmp    L72
L9:
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x20,%al
  je     L105
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x9,%al
  jne    L82
L105:
  subl   $0x1,-0x10(%rbp)
  jmp    L72
L82:
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  jmp    L120
L72:
  cmpl   $0x0,-0x10(%rbp)
  jns    L9
  mov    -0xc(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  jmp    L120
L162:
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L221
  mov    $0x0,%eax
L120:
  leave
  ret
```

assistant: ```c
char *logtools_str_get_valstr(char *str) {
  char *ptr;
  int n, i = 0;
  n = strlen(str);
  i = 0;
  while (i < n) {
    if (str[i] == '{') {
      ptr = rindex(str, '}');
      if (ptr == NULL) {
        return (NULL);
      } else {
        ptr[0] = '\0';
        return (logtools_str_get_valstr(&(str[i + 1])));
      }
    } else if (str[i] == '(') {
      ptr = rindex(str, ')');
      if (ptr == NULL) {
        return (NULL);
      } else {
        ptr[0] = '\0';
        return (logtools_str_get_valstr(&(str[i + 1])));
      }
    } else if (str[i] == '[') {
      ptr = rindex(str, ']');
      if (ptr == NULL) {
        return (NULL);
      } else {
        ptr[0] = '\0';
        return (logtools_str_get_valstr(&(str[i + 1])));
      }
    } else if (str[i] == ' ' || str[i] == '\t') {
      i++;
    } else {
      n = strlen(&(str[i]));
      while (n >= 0) {
        if (str[i + n - 1] == ' ' || str[i + n - 1] == '\t') {
          n--;
        } else {
          str[i + n] = '\0';
          return (&(str[i]));
        }
      }
      str[i + n] = '\0';
      return (&(str[i]));
    }
  }
  return (NULL);
}
```