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

```asm
<write_profile_string>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x8000(%rsp),%r11
L51:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L51
  sub    $0x48,%rsp
  pxor   %xmm0,%xmm0
  mov    %rdx,%rbp
  mov    %rdi,%r14
  mov    $0x3ff0,%edx
  mov    %rsi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x8038(%rsp)
  xor    %eax,%eax
  lea    0x40(%rsp),%rdi
  xor    %esi,%esi
  mov    %rcx,%r13
  movaps %xmm0,0x30(%rsp)
  call   <memset@plt>
  pxor   %xmm0,%xmm0
  mov    $0x3ff0,%edx
  xor    %esi,%esi
  lea    0x4040(%rsp),%rdi
  movaps %xmm0,0x4030(%rsp)
  call   <memset@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  xor    %edi,%edi
  mov    %eax,0xc(%rsp)
  test   %r14,%r14
  je     L50
  mov    %r14,%rdi
  call   <strlen@plt>
  xor    %edi,%edi
  test   %eax,%eax
  setne  %dil
L50:
  call   <assert@plt>
  xor    %edi,%edi
  test   %r12,%r12
  je     L14
  mov    %r12,%rdi
  call   <strlen@plt>
  xor    %edi,%edi
  test   %eax,%eax
  setne  %dil
L14:
  call   <assert@plt>
  xor    %edi,%edi
  test   %rbp,%rbp
  setne  %dil
  call   <assert@plt>
  xor    %edi,%edi
  test   %r13,%r13
  je     L87
  mov    %r12,%rdi
  call   <strlen@plt>
  xor    %edi,%edi
  test   %eax,%eax
  setne  %dil
L87:
  call   <assert@plt>
  lea    0x30(%rsp),%rbx
  lea    0x2c(%rsp),%rdx
  mov    %r13,%rdi
  mov    %rbx,%rsi
  call   <load_ini_file@plt>
  test   %eax,%eax
  jne    L68
  movl   $0xffffffff,0x14(%rsp)
L110:
  mov    0x2c(%rsp),%edx
  lea    0x4030(%rsp),%r15
  test   %edx,%edx
  jne    L45
  mov    %rbp,%r8
  mov    %r12,%rcx
  mov    %r14,%rdx
  mov    %r15,%rdi
  lea    D20(%rip),%rsi
  xor    %eax,%eax
  call   <sprintf@plt>
  jmp    L115
  cs nopw 0x0(%rax,%rax,1)
L68:
  lea    0x14(%rsp),%rcx
  sub    $0x8,%rsp
  mov    %rbx,%rdx
  mov    %r12,%rsi
  lea    0x30(%rsp),%rax
  mov    %r14,%rdi
  push   %rax
  lea    0x34(%rsp),%rax
  push   %rax
  lea    0x38(%rsp),%rax
  push   %rax
  lea    0x3c(%rsp),%r9
  lea    0x38(%rsp),%r8
  call   <parse_file@plt>
  add    $0x20,%rsp
  cmpl   $0xffffffff,0x14(%rsp)
  je     L110
  cmpl   $0xffffffff,0x1c(%rsp)
  lea    0x4030(%rsp),%r15
  je     L97
  mov    0x24(%rsp),%edx
  mov    %rbx,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  mov    0xc(%rsp),%r14d
  movslq 0x24(%rsp),%rdi
  mov    %rbp,%rsi
  add    %r15,%rdi
  mov    %r14d,%edx
  call   <memcpy@plt>
  movslq 0x28(%rsp),%rax
  mov    0x2c(%rsp),%ecx
  movslq 0x24(%rsp),%rdi
  lea    (%rbx,%rax,1),%rsi
  movslq %r14d,%rbx
  sub    %eax,%ecx
  add    %rbx,%rdi
  mov    %ecx,%edx
  add    %r15,%rdi
  call   <memcpy@plt>
L115:
  lea    D21(%rip),%rsi
  mov    %r13,%rdi
  xor    %r12d,%r12d
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L112
  mov    %r15,%rdi
  mov    %rax,%rsi
  call   <fputs@plt>
  mov    %rbp,%rdi
  cmp    $0xffffffff,%eax
  je     L8
  call   <fclose@plt>
  mov    $0x1,%r12d
L112:
  mov    0x8038(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L141
  add    $0x8048,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L97:
  mov    0x18(%rsp),%edx
  mov    %rbx,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq 0x18(%rsp),%rdi
  mov    %rbp,%rcx
  mov    %r12,%rdx
  lea    D2(%rip),%rsi
  xor    %eax,%eax
  add    %r15,%rdi
  call   <sprintf@plt>
  movslq 0x18(%rsp),%r14
  mov    0x2c(%rsp),%edx
  mov    %r12,%rdi
  sub    %r14d,%edx
  mov    %edx,0xc(%rsp)
  call   <strlen@plt>
  mov    %rbp,%rdi
  mov    %eax,%r12d
  call   <strlen@plt>
  lea    (%rbx,%r14,1),%rsi
  movslq %r12d,%rbx
  mov    0xc(%rsp),%edx
  lea    0x2(%r14,%rbx,1),%rdi
  cltq
  add    %rax,%rdi
  xor    %eax,%eax
  add    %r15,%rdi
  call   <sprintf@plt>
  jmp    L115
  nopw   0x0(%rax,%rax,1)
L45:
  mov    %rbx,%rsi
  mov    %r15,%rdi
  call   <memcpy@plt>
  movslq 0x2c(%rsp),%rdi
  mov    %rbp,%r8
  mov    %r12,%rcx
  mov    %r14,%rdx
  lea    D0(%rip),%rsi
  xor    %eax,%eax
  add    %r15,%rdi
  call   <sprintf@plt>
  jmp    L115
  nop
L8:
  call   <fclose@plt>
  jmp    L112
L141:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D20
type_infered: string
name: disassemble_data
arguments: data_tag: D21
type_infered: string
name: disassemble_data
arguments: data_tag: D2
type_infered: string
name: disassemble_data
arguments: data_tag: D0
type_infered: string

tool: D20: [%s]
%s=%s


tool: D21: w

tool: D2: %s=%s


tool: D0: 
[%s]
%s=%s


assistant: ```c
int write_profile_string(const char *section, const char *key, const char *value, const char *file) {
  char buf[1024 * 16] = {0};
  char w_buf[1024 * 16] = {0};
  int sec_s, sec_e, key_s, key_e, value_s, value_e;
  int value_len = (int)strlen(value);
  int file_size;
  FILE *out;
  assert(section != NULL && strlen(section));
  assert(key != NULL && strlen(key));
  assert(value != NULL);
  assert(file != NULL && strlen(key));
  if (!load_ini_file(file, buf, &file_size)) {
    sec_s = -1;
  } else {
    parse_file(section, key, buf, &sec_s, &sec_e, &key_s, &key_e, &value_s, &value_e);
  }
  if (-1 == sec_s) {
    if (0 == file_size) {
      sprintf(w_buf + file_size, "[%s]\n%s=%s\n", section, key, value);
    } else {
      memcpy(w_buf, buf, file_size);
      sprintf(w_buf + file_size, "\n[%s]\n%s=%s\n", section, key, value);
    }
  } else if (-1 == key_s) {
    memcpy(w_buf, buf, sec_e);
    sprintf(w_buf + sec_e, "%s=%s\n", key, value);
    sprintf(w_buf + sec_e + strlen(key) + strlen(value) + 2, buf + sec_e, file_size - sec_e);
  } else {
    memcpy(w_buf, buf, value_s);
    memcpy(w_buf + value_s, value, value_len);
    memcpy(w_buf + value_s + value_len, buf + value_e, file_size - value_e);
  }
  out = fopen(file, "w");
  if (NULL == out) {
    return 0;
  }
  if (-1 == fputs(w_buf, out)) {
    fclose(out);
    return 0;
  }
  fclose(out);
  return 1;
}
```