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

```asm
<add_to_string_array>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %esi,%r14d
  mov    %rdx,%rbp
  mov    %ecx,%r15d
  test   %r8d,%r8d
  je     L27
  test   %esi,%esi
  jle    L27
  mov    %esi,%r13d
  shl    $0x3,%r13
  mov    $0x0,%ebx
  jmp    L153
L123:
  or     %rbp,%rsi
  jne    L154
L151:
  add    $0x8,%rbx
  cmp    %rbx,%r13
  je     L27
L153:
  mov    (%r12),%rax
  mov    (%rax,%rbx,1),%rsi
  test   %rbp,%rbp
  je     L123
  test   %rsi,%rsi
  je     L123
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L151
  mov    $0x1,%eax
  jmp    L9
L27:
  test   %rbp,%rbp
  je     L22
  cmp    $0xffffffff,%r15d
  je     L86
L165:
  lea    0x8(,%r14,8),%esi
  mov    (%r12),%rdi
  call   <realloc@plt>
  test   %rax,%rax
  je     L44
  mov    %rax,(%r12)
  add    $0x1,%r15d
  mov    %r15d,%edi
  call   <malloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L161
  mov    %rbp,%rcx
  lea    D26(%rip),%rdx
  mov    %r15d,%esi
  mov    %rbx,%rdi
  call   <snprintf@plt>
  movslq %r14d,%r14
  mov    (%r12),%rax
  mov    %rbx,(%rax,%r14,8)
  mov    $0x0,%eax
  jmp    L9
L86:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r15d
  jmp    L165
L44:
  lea    D3(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L9
L161:
  lea    D27(%rip),%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L9
L154:
  mov    $0x1,%eax
  jmp    L9
L22:
  lea    0x8(,%r14,8),%esi
  mov    (%r12),%rdi
  call   <realloc@plt>
  test   %rax,%rax
  je     L44
  mov    %rax,(%r12)
  movslq %r14d,%r14
  movq   $0x0,(%rax,%r14,8)
  mov    $0x0,%eax
L9:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: label: D26
datatype: string
name: parse_data
arguments: label: D3
datatype: string
name: parse_data
arguments: label: D27
datatype: string

tool: D26: %s

tool: D3: BCA: realloc()

tool: D27: BCA: malloc()

assistant: ```c
int add_to_string_array(char ***array, int array_size, char *string, int string_length, int prevent_duplicates) {
  char **new_ptr, *new_string;
  int allocation_size, i;
  if (prevent_duplicates) {
    i = 0;
    while (i < array_size) {
      if (((*array)[i] == NULL) || (string == NULL)) {
        if ((*array)[i] != NULL)
          return 1;
        if (string != NULL)
          return 1;
      } else {
        if (strcmp(string, (*array)[i]) == 0)
          return 1;
      }
      i++;
    }
  }
  if (string == NULL) {
    string_length = 0;
  } else {
    if (string_length == -1)
      string_length = strlen(string);
  }
  allocation_size = (array_size + 1) * sizeof(char *);
  if ((new_ptr = (char **)realloc(*array, allocation_size)) == NULL) {
    perror("BCA: realloc()");
    return -1;
  }
  *array = new_ptr;
  if (string != NULL) {
    allocation_size = string_length + 1;
    if ((new_string = (char *)malloc(allocation_size)) == NULL) {
      perror("BCA: malloc()");
      return -1;
    }
    snprintf(new_string, allocation_size, "%s", string);
    (*array)[array_size] = new_string;
  } else {
    (*array)[array_size] = NULL;
  }
  return 0;
}
```