user: Translate the below assembly code into C programming language:

```asm
<strsplit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L68
  cmpq   $0x0,-0x40(%rbp)
  jne    L87
L68:
  mov    $0x0,%eax
  jmp    L141
L87:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L130
  mov    $0x0,%eax
  jmp    L141
L130:
  movl   $0x0,-0x2c(%rbp)
  movl   $0x1,-0x24(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L38
L160:
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L81
  mov    -0x20(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  movl   $0x1,-0x24(%rbp)
  jmp    L165
L81:
  cmpl   $0x1,-0x24(%rbp)
  jne    L165
  movl   $0x0,-0x24(%rbp)
  addl   $0x1,-0x2c(%rbp)
L165:
  addl   $0x1,-0x20(%rbp)
L38:
  mov    -0x20(%rbp),%eax
  cltq
  cmp    %rax,-0x18(%rbp)
  ja     L160
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L121
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L141
L121:
  movl   $0x0,-0x28(%rbp)
  movl   $0x1,-0x24(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L56
L163:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L114
  movl   $0x1,-0x24(%rbp)
  jmp    L147
L114:
  cmpl   $0x1,-0x24(%rbp)
  jne    L147
  movl   $0x0,-0x24(%rbp)
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x28(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  mov    %rdx,(%rax)
L147:
  addl   $0x1,-0x1c(%rbp)
L56:
  mov    -0x1c(%rbp),%eax
  cltq
  cmp    %rax,-0x18(%rbp)
  ja     L163
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movq   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
L141:
  leave
  ret
```

assistant: ```c
char **strsplit(const char *input, const char *delim) {
  char *str;
  size_t len;
  int token_count;
  int token;
  enum { TOKEN, DELIM } state;
  char **tokens;
  if (!input || !delim)
    return NULL;
  len = strlen(input);
  str = strdup(input);
  if (!str)
    return NULL;
  token_count = 0;
  state = DELIM;
  for (int i = 0; i < len; i++) {
    if (strchr(delim, str[i])) {
      str[i] = '\0';
      state = DELIM;
    } else if (state == DELIM) {
      state = TOKEN;
      token_count++;
    }
  }
  tokens = malloc((token_count + 1) * sizeof(char *));
  if (!tokens) {
    free(str);
    return NULL;
  }
  token = 0;
  state = DELIM;
  for (int i = 0; i < len; i++) {
    if (str[i] == '\0') {
      state = DELIM;
    } else if (state == DELIM) {
      state = TOKEN;
      tokens[token++] = &(str[i]);
    }
  }
  tokens[token_count] = NULL;
  return tokens;
}
```