// File: /workspace/github_c_makefile_star2_O0/AlxHnr[P]nano-backup/src/repository.c
// Function: repoWriterClose
void repoWriterClose(RepoWriter *writer_to_close)
{
  RepoWriter writer = *writer_to_close;
  free(writer_to_close);

  if(!fTodisk(writer.stream))
  {
    fDestroy(writer.stream);
    dieErrno("failed to flush/sync \"" PRI_STR "\" to \"" PRI_STR "\"",
             STR_FMT(writer.source_file_path), STR_FMT(writer.repo_path));
  }

  sFclose(writer.stream);

  if(writer.raw_mode)
  {
    sRename(writer.repo_tmp_file_path, writer.rename_to.path);
  }
  else
  {
    StringView repo_path = writer.repo_path;
    fillPathBufferWithInfo(repo_path, writer.rename_to.info);

    /* Ensure that the final paths parent directories exists. */
    path_buffer[repo_path.length + 5] = '\0';
    if(!sPathExists(str(path_buffer)))
    {
      path_buffer[repo_path.length + 2] = '\0';
      if(!sPathExists(str(path_buffer)))
      {
        sMkdir(str(path_buffer));
        fDatasync(writer.repo_path);
      }
      path_buffer[repo_path.length + 2] = '/';

      sMkdir(str(path_buffer));

      path_buffer[repo_path.length + 2] = '\0';
      fDatasync(str(path_buffer));
      path_buffer[repo_path.length + 2] = '/';
    }
    path_buffer[repo_path.length + 5] = '/';

    sRename(writer.repo_tmp_file_path, str(path_buffer));
    path_buffer[repo_path.length + 5] = '\0';
    fDatasync(str(path_buffer));
  }

  fDatasync(writer.repo_path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
movl $0x70, %edx
callq 0x2250
movq -0x8(%rbp), %rdi
callq 0x2040
movq -0x30(%rbp), %rdi
callq 0xbf40
testb $0x1, %al
jne 0xa1e2
movq -0x30(%rbp), %rdi
callq 0xc080
movq -0x40(%rbp), %rax
movl %eax, %esi
movq -0x48(%rbp), %rdx
movq -0x70(%rbp), %rax
movl %eax, %ecx
movq -0x78(%rbp), %r8
leaq 0x1a70b(%rip), %rdi     # 0x248e6
movb $0x0, %al
callq 0x4760
movq -0x30(%rbp), %rdi
callq 0xc020
testb $0x1, -0x28(%rbp)
je 0xa23e
leaq -0x78(%rbp), %rcx
addq $0x18, %rcx
leaq -0x78(%rbp), %rax
addq $0x58, %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0xc9c0
jmp 0xa4f0
movq -0x78(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x99c0
movq 0x1f014(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x0, 0x5(%rax,%rcx)
movq 0x1f001(%rip), %rsi     # 0x292a0
leaq -0xa8(%rbp), %rdi
callq 0xf100
leaq -0xa8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xc4d0
testb $0x1, %al
jne 0xa42a
movq 0x1efc1(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x0, 0x2(%rax,%rcx)
movq 0x1efae(%rip), %rsi     # 0x292a0
leaq -0xc0(%rbp), %rdi
callq 0xf100
leaq -0xc0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xc4d0
testb $0x1, %al
jne 0xa381
movq 0x1ef72(%rip), %rsi     # 0x292a0
leaq -0xd8(%rbp), %rdi
callq 0xf100
leaq -0xd8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xc6c0
leaq -0x78(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbfa0
movq 0x1ef18(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x2f, 0x2(%rax,%rcx)
movq 0x1ef05(%rip), %rsi     # 0x292a0
leaq -0xf0(%rbp), %rdi
callq 0xf100
leaq -0xf0(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xc6c0
movq 0x1eecd(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x0, 0x2(%rax,%rcx)
movq 0x1eeba(%rip), %rsi     # 0x292a0
leaq -0x108(%rbp), %rdi
callq 0xf100
leaq -0x108(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbfa0
movq 0x1ee82(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x2f, 0x2(%rax,%rcx)
movq 0x1ee6f(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x2f, 0x5(%rax,%rcx)
leaq -0x78(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x140(%rbp)
movq 0x1ee4d(%rip), %rsi     # 0x292a0
leaq -0x120(%rbp), %rdi
callq 0xf100
movq -0x140(%rbp), %rcx
leaq -0x120(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rsp)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rsp)
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
callq 0xc9c0
movq 0x1edf4(%rip), %rax     # 0x292a0
movq -0x88(%rbp), %rcx
movb $0x0, 0x5(%rax,%rcx)
movq 0x1ede1(%rip), %rsi     # 0x292a0
leaq -0x138(%rbp), %rdi
callq 0xf100
leaq -0x138(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbfa0
leaq -0x78(%rbp), %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0xbfa0
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopl (%rax,%rax)