// File: /workspace/github_c_makefile_star2_O1/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
leaq 0x38(%rsp), %rbx
movl $0xe, %ecx
movq %rbx, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
callq 0x2040
movq 0x48(%rbx), %rdi
callq 0x8cc8
movq 0x48(%rbx), %rdi
testb %al, %al
je 0x7e6c
callq 0x8d89
cmpb $0x1, 0x88(%rsp)
jne 0x7c85
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 0x9461
jmp 0x7e48
movq 0x40(%rsp), %r14
movq 0x90(%rsp), %rdi
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x7700
movq 0xb59f(%rip), %rsi      # 0x13250
movb $0x0, 0x5(%rsi,%r14)
leaq 0x138(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x90a4
testb %al, %al
jne 0x7dd0
movq 0xb565(%rip), %rsi      # 0x13250
movb $0x0, 0x2(%rsi,%r14)
leaq 0x120(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x90a4
testb %al, %al
jne 0x7d5e
movq 0xb52f(%rip), %rsi      # 0x13250
leaq 0x108(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x923c
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8d04
movq 0xb4eb(%rip), %rsi      # 0x13250
movb $0x2f, %bpl
movb %bpl, 0x2(%rsi,%r14)
leaq 0xf0(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x923c
movq 0xb4b7(%rip), %rsi      # 0x13250
movb $0x0, 0x2(%rsi,%r14)
leaq 0xd8(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8d04
movq 0xb485(%rip), %rax      # 0x13250
movb %bpl, 0x2(%rax,%r14)
movq 0xb479(%rip), %rsi      # 0x13250
movb $0x2f, 0x5(%rsi,%r14)
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
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 0x9461
movq 0xb433(%rip), %rsi      # 0x13250
movb $0x0, 0x5(%rsi,%r14)
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0xaf28
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8d04
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8d04
addq $0x150, %rsp            # imm = 0x150
popq %rbx
popq %r14
popq %rbp
retq
callq 0x8dc6
movl 0x70(%rsp), %esi
movq 0x68(%rsp), %rdx
movl 0x40(%rsp), %ecx
movq 0x38(%rsp), %r8
leaq 0x6a53(%rip), %rdi      # 0xe8dd
xorl %eax, %eax
callq 0x3e8c