user: Converte this assembly snippet into its equivalent C code:

```asm
<smtp_chunk_split>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  test   %rsi,%rsi
  je     L159
  mov    %rdx,%r13
  mov    %rdi,%r12
  mov    %rsi,%rbp
  call   <strlen@plt>
  mov    %r13,%rdi
  mov    %rax,%r14
  call   <strlen@plt>
  mov    %rax,%rbx
  mov    %rax,%r15
  test   %r14,%r14
  je     L111
  lea    0x38(%rsp),%rdx
  mov    $0x1,%esi
  mov    %rax,%rdi
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L179
  lea    0x30(%rsp),%rdx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L179
  mov    %r14,%rax
  xor    %edx,%edx
  lea    0x40(%rsp),%r14
  mov    0x38(%rsp),%rdi
  div    %rbp
  mov    %r14,%rdx
  lea    0x1(%rax),%rsi
  mov    %rax,0x18(%rsp)
  call   <smtp_si_mul_size_t@plt>
  test   %rax,%rax
  jne    L179
  mov    0x30(%rsp),%rsi
  mov    0x40(%rsp),%rdi
  mov    %r14,%rdx
  call   <smtp_si_add_size_t@plt>
  test   %rax,%rax
  jne    L179
  mov    0x40(%rsp),%rsi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L179
  test   %rbx,%rbx
  jne    L134
  movq   $0x0,0x8(%rsp)
  xor    %r15d,%r15d
  jmp    L114
  xchg   %ax,%ax
L158:
  lea    (%r14,%rbx,1),%rdi
  mov    %r13,%rsi
  mov    %rax,0x10(%rsp)
  call   <memcpy@plt>
  mov    0x10(%rsp),%rdx
  cmpb   $0x1,0x0(%r13)
  lea    0x1(%r15),%rax
  adc    %rdx,%rbx
  add    %rdx,0x8(%rsp)
  cmp    %r15,0x18(%rsp)
  je     L133
  mov    %rax,%r15
L114:
  mov    0x8(%rsp),%rax
  mov    %rbp,%rsi
  lea    (%r12,%rax,1),%r13
  mov    %r13,%rdi
  call   <smtp_strnlen_utf8@plt>
  mov    %rax,%rdx
  cmp    $0xffffffffffffffff,%rax
  jne    L158
L96:
  mov    %r14,%rdi
  xor    %r14d,%r14d
  call   <free@plt>
  jmp    L133
  nopl   0x0(%rax,%rax,1)
L179:
  xor    %r14d,%r14d
L133:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0x58,%rsp
  mov    %r14,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L111:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0x58,%rsp
  mov    %r13,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1150 <smtp_strdup@plt>
  nopw   0x0(%rax,%rax,1)
L159:
  mov    D4(%rip),%rax
  xor    %r14d,%r14d
  mov    (%rax),%edx
  mov    D5(%rip),%rax
  mov    %edx,(%rax)
  jmp    L133
  nopw   0x0(%rax,%rax,1)
L134:
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x20(%rsp)
  jmp    L35
  nopl   (%rax)
L187:
  mov    0x8(%rsp),%rcx
  mov    %rbx,%rsi
  mov    %rax,0x28(%rsp)
  lea    (%r14,%rcx,1),%rdi
  call   <memcpy@plt>
  mov    0x28(%rsp),%rdx
  cmpb   $0x1,(%rbx)
  mov    %r13,%rsi
  mov    0x8(%rsp),%rcx
  adc    %rdx,%rcx
  add    %rdx,0x10(%rsp)
  mov    %r15,%rdx
  lea    (%r14,%rcx,1),%rdi
  mov    %rcx,0x8(%rsp)
  call   <memcpy@plt>
  mov    0x8(%rsp),%rcx
  lea    (%rcx,%r15,1),%rax
  mov    0x20(%rsp),%rcx
  mov    %rax,0x8(%rsp)
  lea    0x1(%rcx),%rax
  cmp    %rcx,0x18(%rsp)
  je     L133
  mov    %rax,0x20(%rsp)
L35:
  mov    0x10(%rsp),%rax
  mov    %rbp,%rsi
  lea    (%r12,%rax,1),%rbx
  mov    %rbx,%rdi
  call   <smtp_strnlen_utf8@plt>
  mov    %rax,%rdx
  cmp    $0xffffffffffffffff,%rax
  jne    L187
  jmp    L96
L54:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *smtp_chunk_split(const char *const s, size_t chunklen, const char *const end) {
  char *snew;
  size_t bodylen;
  size_t bodylen_inc;
  size_t endlen;
  size_t endlen_inc;
  size_t snewlen;
  size_t chunk_i;
  size_t snew_i;
  size_t body_i;
  size_t body_copy_len;
  if (chunklen < 1) {
    errno = EINVAL;
    return NULL;
  }
  bodylen = strlen(s);
  endlen = strlen(end);
  if (bodylen < 1) {
    return smtp_strdup(end);
  }
  if (smtp_si_add_size_t(endlen, 1, &endlen_inc) || smtp_si_add_size_t(bodylen, 1, &bodylen_inc) || smtp_si_mul_size_t(endlen_inc, bodylen / chunklen + 1, &snewlen) || smtp_si_add_size_t(snewlen, bodylen_inc, &snewlen) || (snew = calloc(1, snewlen)) == NULL) {
    return NULL;
  }
  body_i = 0;
  snew_i = 0;
  for (chunk_i = 0; chunk_i < bodylen / chunklen + 1; chunk_i++) {
    body_copy_len = smtp_strnlen_utf8(&s[body_i], chunklen);
    if (body_copy_len == ((size_t)(-1))) {
      free(snew);
      return NULL;
    }
    memcpy(&snew[snew_i], &s[body_i], body_copy_len);
    snew_i += body_copy_len;
    if (s[body_i] == '\0') {
      snew_i += 1;
    }
    body_i += body_copy_len;
    if (endlen > 0) {
      memcpy(&snew[snew_i], end, endlen);
    }
    snew_i += endlen;
  }
  return snew;
}
```