// File: /workspace/github_c_makefile_star2_O3/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), %rbx
movq %rbx, %rdi
callq 0x8b1c
movq %rbx, %rdi
testb %al, %al
je 0x7c8d
callq 0x8bc9
cmpb $0x1, 0x88(%rsp)
jne 0x7ab7
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 0x9200
jmp 0x7c69
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rbx
movq 0x90(%rsp), %rdx
movq %rbx, %rsi
callq 0x7526
movq 0xb778(%rip), %rsi      # 0x13250
movb $0x0, 0x5(%rsi,%rbx)
leaq 0x138(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x8ed6
movq 0xb746(%rip), %rsi      # 0x13250
testb %al, %al
jne 0x7bf9
movb $0x0, 0x2(%rsi,%rbx)
leaq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x8ed6
testb %al, %al
jne 0x7b86
movq 0xb708(%rip), %rsi      # 0x13250
leaq 0x108(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x902f
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8b58
movq 0xb6c3(%rip), %rsi      # 0x13250
movb $0x2f, %bpl
movb %bpl, 0x2(%rsi,%rbx)
leaq 0xf0(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x902f
movq 0xb68e(%rip), %rsi      # 0x13250
movb $0x0, 0x2(%rsi,%rbx)
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movups (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x8b58
movq 0xb65c(%rip), %rsi      # 0x13250
movb %bpl, 0x2(%rsi,%rbx)
movb $0x2f, 0x5(%rsi,%rbx)
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0xab5c
movq 0x10(%r14), %rax
movq %rax, 0x28(%rsp)
movups (%r14), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x9200
movq 0xb611(%rip), %rsi      # 0x13250
movb $0x0, 0x5(%rsi,%rbx)
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0xab5c
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8b58
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8b58
addq $0x150, %rsp            # imm = 0x150
popq %rbx
popq %r14
popq %rbp
retq
callq 0x8c06
movl 0x70(%rsp), %esi
movq 0x68(%rsp), %rdx
movl 0x40(%rsp), %ecx
movq 0x38(%rsp), %r8
leaq 0x6c2f(%rip), %rdi      # 0xe8da
xorl %eax, %eax
callq 0x3d70