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

```asm
<traverse_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  jmp    L126
L70:
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x30(%rbp)
  jne    L115
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %rax,-0x10(%rbp)
  subl   $0x1,-0x2c(%rbp)
  jmp    L64
L115:
  mov    D12(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x30(%rbp)
  jne    L110
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  cltq
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  cmp    $0xd7ff,%rax
  jbe    L58
  mov    -0x10(%rbp),%rax
  cmp    $0xdfff,%rax
  ja     L58
  mov    $0xffffffff,%eax
  jmp    L189
L58:
  subl   $0x2,-0x2c(%rbp)
  jmp    L64
L110:
  mov    D5(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x30(%rbp)
  jne    L25
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x18,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x10,%rax
  mov    %rax,%rdx
  mov    -0x10(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x10(%rbp),%rax
  or     %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  cmp    $0x10ffff,%rax
  ja     L169
  mov    -0x10(%rbp),%rax
  cmp    $0xd7ff,%rax
  jbe    L145
  mov    -0x10(%rbp),%rax
  cmp    $0xdfff,%rax
  ja     L145
L169:
  mov    $0xffffffff,%eax
  jmp    L189
L145:
  subl   $0x4,-0x2c(%rbp)
  jmp    L64
L25:
  lea    -0x10(%rbp),%rdx
  mov    -0x2c(%rbp),%ecx
  mov    -0x28(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <UTF8_getc@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jns    L149
  mov    $0xffffffff,%eax
  jmp    L189
L149:
  mov    -0x14(%rbp),%eax
  sub    %eax,-0x2c(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  add    %rax,-0x28(%rbp)
L64:
  cmpq   $0x0,-0x38(%rbp)
  je     L126
  mov    -0x10(%rbp),%rax
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rcx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   *%rcx
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jg     L126
  mov    -0x14(%rbp),%eax
  jmp    L189
L126:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L70
  mov    $0x1,%eax
L189:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L29
  call   <__stack_chk_fail@plt>
L29:
  leave
  ret
```

assistant: ```c
int traverse_string(const unsigned char *p, int len, int inform, int (*rfunc)(unsigned long value, void *in), void *arg) {
  unsigned long value;
  int ret;
  while (len) {
    if (inform == MBSTRING_ASC) {
      value = *p++;
      len--;
    } else if (inform == MBSTRING_BMP) {
      value = *p++ << 8;
      value |= *p++;
      if (((value) >= 0x00D800 && (value) <= 0x00DFFF))
        return -1;
      len -= 2;
    } else if (inform == MBSTRING_UNIV) {
      value = ((unsigned long)*p++) << 24;
      value |= ((unsigned long)*p++) << 16;
      value |= *p++ << 8;
      value |= *p++;
      if (value > 0x10FFFF || ((value) >= 0x00D800 && (value) <= 0x00DFFF))
        return -1;
      len -= 4;
    } else {
      ret = UTF8_getc(p, len, &value);
      if (ret < 0)
        return -1;
      len -= ret;
      p += ret;
    }
    if (rfunc) {
      ret = rfunc(value, arg);
      if (ret <= 0)
        return ret;
    }
  }
  return 1;
}
```