user: Translate the below assembly code into C programming language:

```asm
<confctl_save_atomic>:
  endbr64
  push   %r14
  mov    %rsi,%rdx
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  lea    D57(%rip),%rsi
  push   %rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  movq   $0x0,(%rsp)
  call   <asprintf@plt>
  test   %eax,%eax
  js     L69
L33:
  mov    (%rsp),%rdi
  call   <mkstemp@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  js     L81
L103:
  lea    D43(%rip),%rsi
  mov    %r13d,%edi
  call   <fdopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L27
L64:
  mov    %r14,%rdi
  mov    %rbp,%rsi
  call   <confctl_write@plt>
  mov    %rbp,%rdi
  call   <fflush@plt>
  test   %eax,%eax
  jne    L13
  mov    %r13d,%edi
  call   <fsync@plt>
  test   %eax,%eax
  jne    L55
L88:
  mov    %rbp,%rdi
  call   <fclose@plt>
  test   %eax,%eax
  jne    L112
L118:
  mov    (%rsp),%rdi
  mov    %r12,%rsi
  call   <rename@plt>
  test   %eax,%eax
  jne    L122
L84:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L45
  add    $0x18,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L13:
  mov    (%rsp),%rdi
  call   <remove_tmpfile@plt>
  mov    $0x1,%edi
  xor    %eax,%eax
  lea    D72(%rip),%rsi
  call   <err@plt>
  mov    %r13d,%edi
  call   <fsync@plt>
  test   %eax,%eax
  je     L88
L55:
  mov    (%rsp),%rdi
  call   <remove_tmpfile@plt>
  mov    $0x1,%edi
  xor    %eax,%eax
  lea    D48(%rip),%rsi
  call   <err@plt>
  mov    %rbp,%rdi
  call   <fclose@plt>
  test   %eax,%eax
  je     L118
L112:
  mov    (%rsp),%rdi
  call   <remove_tmpfile@plt>
  lea    D66(%rip),%rsi
  mov    $0x1,%edi
  xor    %eax,%eax
  call   <err@plt>
  mov    (%rsp),%rdi
  mov    %r12,%rsi
  call   <rename@plt>
  test   %eax,%eax
  je     L84
L122:
  mov    (%rsp),%rdi
  call   <remove_tmpfile@plt>
  mov    %r12,%rdx
  mov    $0x1,%edi
  xor    %eax,%eax
  lea    D47(%rip),%rsi
  call   <err@plt>
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L81:
  mov    (%rsp),%rdx
  lea    D88(%rip),%rsi
  mov    $0x1,%edi
  xor    %eax,%eax
  call   <err@plt>
  jmp    L103
  nopl   0x0(%rax)
L69:
  lea    D12(%rip),%rsi
  mov    $0x1,%edi
  xor    %eax,%eax
  call   <err@plt>
  jmp    L33
  nopl   0x0(%rax,%rax,1)
L27:
  mov    (%rsp),%rdi
  call   <remove_tmpfile@plt>
  lea    D79(%rip),%rsi
  mov    $0x1,%edi
  xor    %eax,%eax
  call   <err@plt>
  jmp    L64
L45:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D57
type_infered: string
name: unpack_data
arguments: label: D43
type_infered: string
name: unpack_data
arguments: label: D72
type_infered: string
name: unpack_data
arguments: label: D48
type_infered: string
name: unpack_data
arguments: label: D66
type_infered: string
name: unpack_data
arguments: label: D47
type_infered: string
name: unpack_data
arguments: label: D88
type_infered: string
name: unpack_data
arguments: label: D12
type_infered: string
name: unpack_data
arguments: label: D79
type_infered: string

tool: D57: %s.XXXXXXXXX

tool: D43: w

tool: D72: fflush

tool: D48: fsync

tool: D66: fclose

tool: D47: cannot replace %s; use -I to rewrite file in place

tool: D88: cannot create temporary file %s; use -I to rewrite file in place

tool: D12: asprintf

tool: D79: fdopen

assistant: ```c
void confctl_save_atomic(struct confctl *cc, const char *path) {
  FILE *fp;
  int error, fd, written;
  char *tmppath = NULL;
  written = asprintf(&tmppath, "%s.XXXXXXXXX", path);
  if (written < 0)
    err(1, "asprintf");
  fd = mkstemp(tmppath);
  if (fd < 0)
    err(1, "cannot create temporary file %s; use -I to rewrite file in place", tmppath);
  fp = fdopen(fd, "w");
  if (fp == NULL) {
    remove_tmpfile(tmppath);
    err(1, "fdopen");
  }
  confctl_write(cc, fp);
  error = fflush(fp);
  if (error != 0) {
    remove_tmpfile(tmppath);
    err(1, "fflush");
  }
  error = fsync(fd);
  if (error != 0) {
    remove_tmpfile(tmppath);
    err(1, "fsync");
  }
  error = fclose(fp);
  if (error != 0) {
    remove_tmpfile(tmppath);
    err(1, "fclose");
  }
  error = rename(tmppath, path);
  if (error != 0) {
    remove_tmpfile(tmppath);
    err(1, "cannot replace %s; use -I to rewrite file in place", path);
  }
}
```