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

```asm
<string_join>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  mov    %rsi,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  xor    %edi,%edi
  test   %r15,%r15
  setne  %dil
  call   <assert@plt>
  cmpq   $0x0,(%rbx)
  je     L92
  xor    %r15d,%r15d
  nopl   0x0(%rax)
L0:
  mov    %r15,%r14
  add    $0x1,%r15
  cmpq   $0x0,(%rbx,%r15,8)
  lea    0x0(,%r15,8),%rax
  jne    L0
  add    $0xf,%rax
  mov    %rsp,%rsi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rdx
  cmp    %rsi,%rsp
  je     L3
L82:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L82
L3:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L34
L59:
  mov    -0x50(%rbp),%rdi
  mov    %rsp,%r12
  call   <strlen@plt>
  mov    %rax,-0x58(%rbp)
  test   %r14,%r14
  jne    10e0 <string_join.cold>
  xor    %edx,%edx
  xor    %r13d,%r13d
  nopw   0x0(%rax,%rax,1)
L144:
  mov    (%rbx,%rdx,8),%rdi
  test   %rdi,%rdi
  je     L138
  mov    %rdx,-0x48(%rbp)
  call   <strlen@plt>
  mov    -0x48(%rbp),%rdx
  add    %rax,%r13
  mov    %rax,(%r12,%rdx,8)
L138:
  add    $0x1,%rdx
  cmp    %rdx,%r15
  ja     L144
  lea    0x1(%r13),%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L92
  movb   $0x0,(%rax,%r13,1)
  mov    %rax,-0x60(%rbp)
  test   %r14,%r14
  je     L44
  cmp    %r15,%r14
  cmova  %r15,%r14
  mov    %r14,-0x48(%rbp)
  xor    %r14d,%r14d
  nopw   0x0(%rax,%rax,1)
L115:
  mov    (%rbx,%r14,8),%rsi
  test   %rsi,%rsi
  je     L17
  mov    (%r12,%r14,8),%r13
  mov    %r13,%rdx
  call   <strncpy@plt>
  mov    -0x50(%rbp),%rsi
  mov    %rax,%rdi
  add    %r13,%rdi
  mov    -0x58(%rbp),%r13
  mov    %r13,%rdx
  call   <strncpy@plt>
  lea    (%rax,%r13,1),%rdi
L17:
  add    $0x1,%r14
  cmp    -0x48(%rbp),%r14
  jb     L115
  cmp    %r15,%r14
  jae    L69
  xchg   %ax,%ax
L44:
  mov    (%rbx,%r14,8),%rsi
  test   %rsi,%rsi
  je     L14
  mov    (%r12,%r14,8),%r13
  mov    %r13,%rdx
  call   <strncpy@plt>
  mov    %rax,%rdi
  add    %r13,%rdi
L14:
  add    $0x1,%r14
  cmp    %r14,%r15
  ja     L44
L69:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L103
  mov    -0x60(%rbp),%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  cs nopw 0x0(%rax,%rax,1)
L34:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L59
  nopl   0x0(%rax,%rax,1)
L92:
  movq   $0x0,-0x60(%rbp)
  jmp    L69
L103:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *string_join(const char **strings, const char *sep) {
  assert(strings != NULL);
  assert(sep != NULL);
  size_t strings_count;
  for (strings_count = 0; strings[strings_count]; strings_count++)
    ;
  if (strings_count == 0)
    return NULL;
  size_t lengths[strings_count];
  size_t sep_len = strlen(sep);
  size_t len = 0;
  for (size_t i = 0; i < strings_count; i++) {
    if (!strings[i])
      continue;
    lengths[i] = strlen(strings[i]);
    len += lengths[i];
    if (i < strings_count - 1)
      len += sep_len;
  }
  char *result = malloc(len + 1);
  if (!result)
    return NULL;
  result[len] = 0;
  char *dst = result;
  for (size_t i = 0; i < strings_count; i++) {
    if (!strings[i])
      continue;
    strncpy(dst, strings[i], lengths[i]);
    dst += lengths[i];
    if (i < strings_count - 1) {
      dst = strncpy(dst, sep, sep_len);
      dst += sep_len;
    }
  }
  return result;
}
```