user: Please show me the C implementation that matches the assembly code listed below:

```asm
<write_profile_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  lea    -0x8000(%rsp),%r11
L81:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L81
  sub    $0x68,%rsp
  mov    %rdi,-0x8068(%rbp)
  mov    %rsi,-0x8070(%rbp)
  mov    %rdx,-0x8078(%rbp)
  mov    %rcx,-0x8080(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x8030(%rbp)
  movq   $0x0,-0x8028(%rbp)
  lea    -0x8020(%rbp),%rax
  mov    $0x3ff0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movq   $0x0,-0x4030(%rbp)
  movq   $0x0,-0x4028(%rbp)
  lea    -0x4020(%rbp),%rax
  mov    $0x3ff0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x8078(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x803c(%rbp)
  cmpq   $0x0,-0x8068(%rbp)
  je     L212
  mov    -0x8068(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L212
  mov    $0x1,%eax
  jmp    L2
L212:
  mov    $0x0,%eax
L2:
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x0,-0x8070(%rbp)
  je     L155
  mov    -0x8070(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L155
  mov    $0x1,%eax
  jmp    L132
L155:
  mov    $0x0,%eax
L132:
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x0,-0x8078(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x0,-0x8080(%rbp)
  je     L167
  mov    -0x8070(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  je     L167
  mov    $0x1,%eax
  jmp    L170
L167:
  mov    $0x0,%eax
L170:
  mov    %eax,%edi
  call   <assert@plt>
  lea    -0x8040(%rbp),%rdx
  lea    -0x8030(%rbp),%rcx
  mov    -0x8080(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <load_ini_file@plt>
  test   %eax,%eax
  jne    L54
  movl   $0xffffffff,-0x8058(%rbp)
  jmp    L173
L54:
  lea    -0x8050(%rbp),%r9
  lea    -0x8054(%rbp),%r8
  lea    -0x8058(%rbp),%rcx
  lea    -0x8030(%rbp),%rdx
  mov    -0x8070(%rbp),%rsi
  mov    -0x8068(%rbp),%rax
  sub    $0x8,%rsp
  lea    -0x8044(%rbp),%rdi
  push   %rdi
  lea    -0x8048(%rbp),%rdi
  push   %rdi
  lea    -0x804c(%rbp),%rdi
  push   %rdi
  mov    %rax,%rdi
  call   <parse_file@plt>
  add    $0x20,%rsp
L173:
  mov    -0x8058(%rbp),%eax
  cmp    $0xffffffff,%eax
  jne    L14
  mov    -0x8040(%rbp),%eax
  test   %eax,%eax
  jne    L174
  mov    -0x8040(%rbp),%eax
  cltq
  lea    -0x4030(%rbp),%rdx
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8078(%rbp),%rcx
  mov    -0x8070(%rbp),%rdx
  mov    -0x8068(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D9(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L161
L174:
  mov    -0x8040(%rbp),%edx
  lea    -0x8030(%rbp),%rcx
  lea    -0x4030(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x8040(%rbp),%eax
  cltq
  lea    -0x4030(%rbp),%rdx
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8078(%rbp),%rcx
  mov    -0x8070(%rbp),%rdx
  mov    -0x8068(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D8(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L161
L14:
  mov    -0x8050(%rbp),%eax
  cmp    $0xffffffff,%eax
  jne    L9
  mov    -0x8054(%rbp),%edx
  lea    -0x8030(%rbp),%rcx
  lea    -0x4030(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x8054(%rbp),%eax
  cltq
  lea    -0x4030(%rbp),%rdx
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8078(%rbp),%rdx
  mov    -0x8070(%rbp),%rax
  mov    %rdx,%rcx
  mov    %rax,%rdx
  lea    D34(%rip),%rax
  mov    %rax,%rsi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x8040(%rbp),%eax
  mov    -0x8054(%rbp),%edx
  sub    %edx,%eax
  mov    %eax,%r12d
  mov    -0x8054(%rbp),%eax
  cltq
  lea    -0x8030(%rbp),%rdx
  lea    (%rdx,%rax,1),%rbx
  mov    -0x8054(%rbp),%eax
  movslq %eax,%r13
  mov    -0x8070(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%r13
  mov    -0x8078(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  add    %r13,%rax
  lea    0x2(%rax),%rdx
  lea    -0x4030(%rbp),%rax
  add    %rdx,%rax
  mov    %r12d,%edx
  mov    %rbx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L161
L9:
  mov    -0x8048(%rbp),%edx
  lea    -0x8030(%rbp),%rcx
  lea    -0x4030(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x8048(%rbp),%eax
  cltq
  lea    -0x4030(%rbp),%rdx
  lea    (%rdx,%rax,1),%rcx
  mov    -0x803c(%rbp),%edx
  mov    -0x8078(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x8040(%rbp),%eax
  mov    -0x8044(%rbp),%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x8044(%rbp),%eax
  cltq
  lea    -0x8030(%rbp),%rcx
  add    %rax,%rcx
  mov    -0x8048(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x803c(%rbp),%eax
  cltq
  add    %rax,%rsi
  lea    -0x4030(%rbp),%rax
  add    %rsi,%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L161:
  mov    -0x8080(%rbp),%rax
  lea    D4(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8038(%rbp)
  cmpq   $0x0,-0x8038(%rbp)
  jne    L91
  mov    $0x0,%eax
  jmp    L90
L91:
  mov    -0x8038(%rbp),%rdx
  lea    -0x4030(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fputs@plt>
  cmp    $0xffffffff,%eax
  jne    L18
  mov    -0x8038(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  jmp    L90
L18:
  mov    -0x8038(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L90:
  mov    -0x28(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L143
  call   <__stack_chk_fail@plt>
L143:
  lea    -0x18(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D9
type_infered: string
name: disassemble_data
arguments: data_label: D8
type_infered: string
name: disassemble_data
arguments: data_label: D34
type_infered: string
name: disassemble_data
arguments: data_label: D4
type_infered: string

tool: D9: [%s]
%s=%s


tool: D8: 
[%s]
%s=%s


tool: D34: %s=%s


tool: D4: w

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;
}
```