// File: /workspace/github_c_makefile_star2_O2/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
pushq %r14
pushq %rbx
subq $0x150, %rsp            # imm = 0x150
movq %rdi, %rax
pushq $0xe
popq %rcx
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
callq 0x2040
movq 0x48(%rbx), %rbx
movq %rbx, %rdi
callq 0x84f9
movq %rbx, %rdi
testb %al, %al
je 0x76f3
callq 0x859c
cmpb $0x1, 0x88(%rsp)
jne 0x7513
movq 0xa0(%rsp), %rax
movq %rax, 0x28(%rsp)
movups 0x90(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8b5c
jmp 0x76cf
movq 0x40(%rsp), %r14
movq 0x90(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x6f94
movq 0xcd11(%rip), %rsi      # 0x14250
movb $0x0, 0x5(%rsi,%r14)
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x886e
movq 0xccdf(%rip), %rsi      # 0x14250
testb %al, %al
jne 0x765e
movb $0x0, 0x2(%rsi,%r14)
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x886e
testb %al, %al
jne 0x75ec
movq 0xcca1(%rip), %rsi      # 0x14250
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x89a6
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8535
movq 0xcc5d(%rip), %rsi      # 0x14250
movb $0x2f, %bpl
movb %bpl, 0x2(%rsi,%r14)
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x89a6
movq 0xcc29(%rip), %rsi      # 0x14250
movb $0x0, 0x2(%rsi,%r14)
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8535
movq 0xcbf7(%rip), %rsi      # 0x14250
movb %bpl, 0x2(%rsi,%r14)
movb $0x2f, 0x5(%rsi,%r14)
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8b5c
movq 0xcbac(%rip), %rsi      # 0x14250
movb $0x0, 0x5(%rsi,%r14)
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0xa3d0
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8535
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8535
addq $0x150, %rsp            # imm = 0x150
popq %rbx
popq %r14
popq %rbp
retq
callq 0x85d6
movl 0x70(%rsp), %esi
movq 0x68(%rsp), %rdx
movl 0x40(%rsp), %ecx
movq 0x38(%rsp), %r8
leaq 0x71c9(%rip), %rdi      # 0xe8da
xorl %eax, %eax
callq 0x39d8