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

```asm
<write_profile_string>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x8000(%rsp),%r11
L92:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L92
  sub    $0x48,%rsp
  mov    %rdi,%r13
  mov    %rsi,%rbx
  mov    %rdx,%rbp
  mov    %rcx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x8038(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  lea    0x40(%rsp),%rdi
  mov    $0x3ff0,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  movq   $0x0,0x4030(%rsp)
  movq   $0x0,0x4038(%rsp)
  lea    0x4040(%rsp),%rdi
  mov    $0x3ff0,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r14d
  mov    $0x0,%edi
  test   %r13,%r13
  je     L129
  mov    %r13,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  setne  %dil
  movzbl %dil,%edi
L129:
  call   <assert@plt>
  mov    $0x0,%edi
  test   %rbx,%rbx
  je     L111
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  setne  %dil
  movzbl %dil,%edi
L111:
  call   <assert@plt>
  test   %rbp,%rbp
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x0,%edi
  test   %r12,%r12
  je     L49
  mov    %rbx,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  setne  %dil
  movzbl %dil,%edi
L49:
  call   <assert@plt>
  lea    0x2c(%rsp),%rdx
  lea    0x30(%rsp),%rsi
  mov    %r12,%rdi
  call   <load_ini_file@plt>
  test   %eax,%eax
  jne    L116
  movl   $0xffffffff,0x14(%rsp)
L26:
  mov    0x2c(%rsp),%edx
  test   %edx,%edx
  jne    L124
  lea    0x4030(%rsp),%rdi
  mov    %rbp,%r8
  mov    %rbx,%rcx
  mov    %r13,%rdx
  lea    D10(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L113
L116:
  lea    0x14(%rsp),%rcx
  lea    0x30(%rsp),%rdx
  sub    $0x8,%rsp
  lea    0x30(%rsp),%rax
  push   %rax
  lea    0x34(%rsp),%rax
  push   %rax
  lea    0x38(%rsp),%rax
  push   %rax
  lea    0x3c(%rsp),%r9
  lea    0x38(%rsp),%r8
  mov    %rbx,%rsi
  mov    %r13,%rdi
  call   <parse_file@plt>
  add    $0x20,%rsp
  cmpl   $0xffffffff,0x14(%rsp)
  je     L26
  cmpl   $0xffffffff,0x1c(%rsp)
  je     L31
  lea    0x30(%rsp),%r13
  lea    0x4030(%rsp),%rbx
  mov    0x24(%rsp),%edx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  movslq 0x24(%rsp),%rdi
  add    %rbx,%rdi
  mov    %r14d,%edx
  mov    %rbp,%rsi
  call   <memcpy@plt>
  mov    0x28(%rsp),%eax
  mov    0x2c(%rsp),%edx
  sub    %eax,%edx
  cltq
  lea    0x0(%r13,%rax,1),%rsi
  movslq 0x24(%rsp),%rax
  movslq %r14d,%r14
  add    %r14,%rax
  lea    (%rbx,%rax,1),%rdi
  call   <memcpy@plt>
L113:
  lea    D19(%rip),%rsi
  mov    %r12,%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  mov    $0x0,%eax
  test   %rbx,%rbx
  je     L24
  lea    0x4030(%rsp),%rdi
  mov    %rbx,%rsi
  call   <fputs@plt>
  cmp    $0xffffffff,%eax
  je     L135
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L24:
  mov    0x8038(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L54
  add    $0x8048,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L124:
  lea    0x30(%rsp),%rsi
  lea    0x4030(%rsp),%r14
  mov    %r14,%rdi
  call   <memcpy@plt>
  movslq 0x2c(%rsp),%rax
  lea    (%r14,%rax,1),%rdi
  mov    %rbp,%r8
  mov    %rbx,%rcx
  mov    %r13,%rdx
  lea    D32(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L113
L31:
  lea    0x30(%rsp),%r15
  lea    0x4030(%rsp),%r13
  mov    0x18(%rsp),%edx
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq 0x18(%rsp),%rdi
  add    %r13,%rdi
  mov    %rbp,%rcx
  mov    %rbx,%rdx
  lea    D6(%rip),%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    0x18(%rsp),%r14d
  mov    0x2c(%rsp),%eax
  sub    %r14d,%eax
  mov    %eax,0xc(%rsp)
  movslq %r14d,%r14
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    (%r15,%r14,1),%rsi
  movslq %ebx,%rbx
  lea    0x2(%r14,%rbx,1),%rdx
  cltq
  add    %rax,%rdx
  lea    0x0(%r13,%rdx,1),%rdi
  mov    0xc(%rsp),%edx
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L113
L135:
  mov    %rbx,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  jmp    L24
L54:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D10
type_guessed: string
name: disassemble_data
arguments: label: D19
type_guessed: string
name: disassemble_data
arguments: label: D32
type_guessed: string
name: disassemble_data
arguments: label: D6
type_guessed: string

tool: D10: [%s]
%s=%s


tool: D19: w

tool: D32: 
[%s]
%s=%s


tool: D6: %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;
}
```