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

```asm
<replace_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%r12
  mov    -0x3c(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x30(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  movslq %eax,%rdx
  mov    %rdx,%r8
  mov    $0x0,%r9d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%ebx
  mov    $0x0,%edx
  div    %rbx
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L24:
  cmp    %rdx,%rsp
  je     L25
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L24
L25:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L88
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L88:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x48(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L85
  mov    $0x0,%eax
  jmp    L21
L85:
  mov    -0x20(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x3c(%rbp),%eax
  cltq
  cmp    %rax,%rdx
  jl     L13
  mov    $0xffffffff,%eax
  jmp    L21
L13:
  mov    -0x20(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    %eax,%edx
  mov    -0x38(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x20(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    -0x28(%rbp),%rdx
  movb   $0x0,(%rdx,%rax,1)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    -0x20(%rbp),%rdx
  sub    -0x38(%rbp),%rdx
  sub    %rdx,%rax
  mov    %rax,%rbx
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %rax,%rbx
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    (%rbx,%rax,1),%rdx
  mov    -0x3c(%rbp),%eax
  cltq
  cmp    %rax,%rdx
  jl     L72
  mov    $0xffffffff,%eax
  jmp    L21
L72:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    %rax,%rcx
  mov    -0x28(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x50(%rbp),%rax
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D8(%rip),%rax
  mov    %rax,%rsi
  call   <sprintf@plt>
  mov    -0x28(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    $0x1,%eax
L21:
  mov    %r12,%rsp
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L51
  call   <__stack_chk_fail@plt>
L51:
  lea    -0x10(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D8
datatype: string

tool: D8: %s%s

assistant: ```c
int replace_string(char *str, int str_length, const char *original, const char *replacement) {
  char buffer[str_length];
  char *found;
  if (!(found = strstr(str, original)))
    return 0;
  if (found - str >= str_length)
    return -1;
  strncpy(buffer, str, found - str);
  buffer[found - str] = '\0';
  if (strlen(buffer) - (found - str) + strlen(replacement) + strlen(found + strlen(original)) >= str_length)
    return -1;
  sprintf(buffer + (found - str), "%s%s", replacement, found + strlen(original));
  strcpy(str, buffer);
  return 1;
}
```