LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/nb.c
// Function: printProgress
static void printProgress(const bool assume_is_finished,
                          const uint64_t processed_amount,
                          const uint64_t total_amount,
                          const uint64_t amount_to_format,
                          const char *info_text,
                          const char *formatted_action_suffix)
{
  startOverprintingPreviousLine();
  printf("%s... ", info_text);

  if(assume_is_finished)
  {
    colorPrintf(stdout, TC_bold, "100.0%%");
    printf(" (");
    printHumanReadableSize(amount_to_format);
    printf(" %s)\n", formatted_action_suffix);
  }
  else if(processed_amount >= total_amount)
  {
    printf("99.9%% (");
    printHumanReadableSize(amount_to_format);
    printf(" %s)\n", formatted_action_suffix);
  }
  else if(processed_amount > 0)
  {
    const size_t permille =
      sUint64Mul(processed_amount, 1000) / total_amount;
    printf("%3zu.%zu%% (", permille / 10, permille % 10);
    printHumanReadableSize(amount_to_format);
    printf(" %s)\n", formatted_action_suffix);
  }
  else
  {
    printf("\n");
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, (%rsp)
movq %r8, %r13
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movl %edi, %ebp
movq 0xd1c1(%rip), %rbx      # 0x13fd0
movq (%rbx), %rdi
callq 0x90d1
testb %al, %al
je 0x6e29
leaq 0x7925(%rip), %rdi      # 0xe747
xorl %eax, %eax
callq 0x2150
leaq 0x78ec(%rip), %rdi      # 0xe71c
movq %r13, %rsi
xorl %eax, %eax
callq 0x2150
testb %bpl, %bpl
je 0x6e5c
movq (%rbx), %rdi
leaq 0x78da(%rip), %rdx      # 0xe723
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x3830
leaq 0x78dd(%rip), %rdi      # 0xe737
jmp 0x6e9a
cmpq %r15, %r12
jae 0x6e93
testq %r12, %r12
je 0x6ec9
movl $0x3e8, %esi            # imm = 0x3E8
movq %r12, %rdi
callq 0x81dc
xorl %edx, %edx
divq %r15
pushq $0xa
popq %rcx
xorl %edx, %edx
divq %rcx
leaq 0x78b3(%rip), %rdi      # 0xe73a
movq %rax, %rsi
xorl %eax, %eax
callq 0x2150
jmp 0x6ea1
leaq 0x7897(%rip), %rdi      # 0xe731
xorl %eax, %eax
callq 0x2150
movq %r14, %rdi
callq 0x3f84
leaq 0x787b(%rip), %rdi      # 0xe72b
movq (%rsp), %rsi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2150
pushq $0xa
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/nb.c
// Function: integrityProgressCallback
static void
integrityProgressCallback(const uint64_t processed_block_size,
                          const uint64_t total_bytes_to_process,
                          void *user_data)
{
  IntegrityProgressContext *ctx = user_data;

  ctx->bytes_processed =
    sUint64Add(ctx->bytes_processed, processed_block_size);
  if(sIsTTY(stdout) &&
     shouldUpdateProgressLine(&ctx->last_print_timestamp))
  {
    printIntegrityProgress(false, ctx->bytes_processed,
                           total_bytes_to_process);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %rsi
movq (%rdx), %rdi
callq 0x81c4
movq %rax, (%r14)
movq 0xd0bc(%rip), %rax      # 0x13fd0
movq (%rax), %rdi
callq 0x90d1
testb %al, %al
je 0x6f3e
leaq 0x8(%r14), %rdi
callq 0x6db9
testb %al, %al
je 0x6f3e
movq (%r14), %rsi
xorl %edi, %edi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x6edf
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: fillPathBufferWithInfo
static void fillPathBufferWithInfo(StringView repo_path,
                                   const RegularFileInfo *info)
{
  /* The +1 is for the slash after the repo path. */
  size_t required_capacity = getFilePathRequiredCapacity(info) + 1;
  required_capacity = sSizeAdd(required_capacity, repo_path.length);
  path_buffer = CR_EnsureCapacity(path_buffer, required_capacity);

  memcpy(path_buffer, repo_path.content, repo_path.length);
  path_buffer[repo_path.length] = '/';

  char *hash_buffer = &path_buffer[repo_path.length + 1];
  buildFilePath(hash_buffer, info);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x701f
leaq 0x1(%rax), %rdi
movq 0x28(%rsp), %r14
movq %r14, %rsi
callq 0x8188
movq 0xd297(%rip), %rdi      # 0x14250
movq %rax, %rsi
callq 0xce02
movq %rax, %r15
movq %rax, 0xd285(%rip)      # 0x14250
movq 0x20(%rsp), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x2280
leaq (%r15,%r14), %rdi
incq %rdi
movb $0x2f, -0x1(%rdi)
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x7062
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: buildFilePath
static void buildFilePath(char *buffer, const RegularFileInfo *info)
{
  sprintf(buffer, "%02x", info->hash[0]);
  sprintf(&buffer[3], "%02x", info->hash[1]);
  buffer[2] = buffer[1];
  buffer[1] = '/';
  buffer[5] = buffer[4];
  buffer[4] = '/';
  buffer += 2;

  for(size_t index = 2; index < FILE_HASH_SIZE; index++)
  {
    sprintf(&buffer[index * 2], "%02x", info->hash[index]);
  }

  char *suffix_buffer = &buffer[FILE_HASH_SIZE * 2];
  sprintf(suffix_buffer, "x%" PRIx64 "x%x", info->size, info->slot);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl 0x18(%rsi), %edx
leaq 0x78fc(%rip), %r15      # 0xe978
movq %r15, %rsi
xorl %eax, %eax
callq 0x23b0
leaq 0x3(%rbx), %rdi
movzbl 0x19(%r14), %edx
movq %r15, %rsi
xorl %eax, %eax
callq 0x23b0
movb 0x1(%rbx), %al
movb 0x4(%rbx), %cl
movb %al, 0x2(%rbx)
movb $0x2f, %al
movb %al, 0x1(%rbx)
movb %cl, 0x5(%rbx)
movb %al, 0x4(%rbx)
leaq 0x6(%rbx), %r12
pushq $-0x12
popq %r13
testq %r13, %r13
je 0x70d6
movzbl 0x2c(%r14,%r13), %edx
movq %r12, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x23b0
incq %r13
addq $0x2, %r12
jmp 0x70b5
addq $0x2a, %rbx
movq 0x10(%r14), %rdx
movzbl 0x2c(%r14), %ecx
leaq 0x7893(%rip), %rsi      # 0xe97d
movq %rbx, %rdi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x23b0
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: repoReaderOpenFile
RepoReader *repoReaderOpenFile(StringView repo_path,
                               StringView source_file_path,
                               const RegularFileInfo *info)
{
  fillPathBufferWithInfo(repo_path, info);
  FILE *stream = fopen(path_buffer, "rb");
  if(stream == NULL)
  {
    dieErrno("failed to open \"" PRI_STR "\" in \"" PRI_STR "\"",
             STR_FMT(source_file_path), STR_FMT(repo_path));
  }

  RepoReader *reader = sMalloc(sizeof *reader);
  strSet(&reader->repo_path, repo_path);
  strSet(&reader->source_file_path, source_file_path);
  reader->stream = stream;

  return reader;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x58(%rsp), %r15
leaq 0x40(%rsp), %r12
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movaps (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x6f94
movq 0xd11f(%rip), %rdi      # 0x14250
leaq 0x76cf(%rip), %rsi      # 0xe807
callq 0x2370
testq %rax, %rax
je 0x7198
movq %rax, %rbx
pushq $0x38
popq %rdi
callq 0x8214
movq %rax, %r14
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
movq %r14, %rdi
callq 0xa454
leaq 0x18(%r14), %rdi
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0xa454
movq %rbx, 0x30(%r14)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl 0x8(%r15), %esi
movq (%r15), %rdx
movl 0x8(%r12), %ecx
movq (%r12), %r8
leaq 0x765b(%rip), %rdi      # 0xe80a
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: repoReaderRead
void repoReaderRead(void *data, const size_t size, RepoReader *reader)
{
  if(fread(data, 1, size, reader->stream) != size)
  {
    StringView repo_path = reader->repo_path;
    StringView source_file_path = reader->source_file_path;
    const bool reached_end_of_file = feof(reader->stream);

    const int old_errno = errno;
    fclose(reader->stream);
    errno = old_errno;

    free(reader);

    if(reached_end_of_file)
    {
      die("reading \"" PRI_STR "\" from \"" PRI_STR
          "\": reached end of file unexpectedly",
          STR_FMT(source_file_path), STR_FMT(repo_path));
    }
    else
    {
      dieErrno("IO error while reading \"" PRI_STR "\" from \"" PRI_STR
               "\"",
               STR_FMT(source_file_path), STR_FMT(repo_path));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq 0x30(%rdx), %rcx
pushq $0x1
popq %rsi
movq %rbx, %rdx
callq 0x20c0
cmpq %rbx, %rax
jne 0x71ed
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r15), %rax
movq %rax, 0x10(%rsp)
movl 0x8(%r15), %eax
movl %eax, 0xc(%rsp)
movq 0x18(%r15), %r14
movl 0x20(%r15), %r12d
movq 0x30(%r15), %rdi
callq 0x2260
movl %eax, %r13d
callq 0x2060
movq %rax, %rbx
movl (%rax), %ebp
movq 0x30(%r15), %rdi
callq 0x2100
movl %ebp, (%rbx)
movq %r15, %rdi
callq 0x2040
testl %r13d, %r13d
jne 0x7250
leaq 0x762d(%rip), %rdi      # 0xe867
movl %r12d, %esi
movq %r14, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x39d8
leaq 0x75d3(%rip), %rdi      # 0xe82a
movl %r12d, %esi
movq %r14, %rdx
movl 0xc(%rsp), %ecx
movq 0x10(%rsp), %r8
xorl %eax, %eax
callq 0x3918
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: repoReaderClose
void repoReaderClose(RepoReader *reader_to_close)
{
  RepoReader reader = *reader_to_close;
  free(reader_to_close);

  if(fclose(reader.stream) != 0)
  {
    dieErrno("failed to close \"" PRI_STR "\" in \"" PRI_STR "\"",
             STR_FMT(reader.source_file_path), STR_FMT(reader.repo_path));
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq (%rdi), %rbx
movq 0x8(%rdi), %r14
movq 0x18(%rdi), %r15
movq 0x20(%rdi), %r12
movq 0x30(%rdi), %r13
callq 0x2040
movq %r13, %rdi
callq 0x2100
testl %eax, %eax
jne 0x72a4
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x75e6(%rip), %rdi      # 0xe891
movl %r12d, %esi
movq %r15, %rdx
movl %r14d, %ecx
movq %rbx, %r8
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: createRepoWriter
static RepoWriter *createRepoWriter(StringView repo_path,
                                    StringView repo_tmp_file_path,
                                    StringView source_file_path,
                                    const bool raw_mode)
{
  FileStream *stream = sFopenWrite(repo_tmp_file_path);
  RepoWriter *writer = sMalloc(sizeof *writer);

  strSet(&writer->repo_path, repo_path);
  strSet(&writer->repo_tmp_file_path, repo_tmp_file_path);
  strSet(&writer->source_file_path, source_file_path);
  writer->stream = stream;
  writer->raw_mode = raw_mode;

  return writer;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %edi, %ebx
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x837a
movq %rax, %r14
pushq $0x70
popq %rdi
callq 0x8214
movq %rax, %r15
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x40(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0xa454
leaq 0x18(%r15), %rdi
movq 0x68(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x58(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xa454
leaq 0x30(%r15), %rdi
movq 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x70(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xa454
movq %r14, 0x48(%r15)
movb %bl, 0x50(%r15)
movq %r15, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: repoWriterWrite
void repoWriterWrite(const void *data, const size_t size,
                     RepoWriter *writer)
{
  if(!fWrite(data, size, writer->stream))
  {
    StringView repo_path = writer->repo_path;
    StringView source_file_path = writer->source_file_path;

    fDestroy(writer->stream);
    free(writer);

    dieErrno("IO error while writing \"" PRI_STR "\" to \"" PRI_STR "\"",
             STR_FMT(source_file_path), STR_FMT(repo_path));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq 0x48(%rdx), %rdx
callq 0x84de
testb %al, %al
je 0x7457
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %r14
movl 0x8(%rbx), %ebp
movq 0x30(%rbx), %r15
movl 0x38(%rbx), %r12d
movq 0x48(%rbx), %rdi
callq 0x85d6
movq %rbx, %rdi
callq 0x2040
leaq 0x7435(%rip), %rdi      # 0xe8b2
movl %r12d, %esi
movq %r15, %rdx
movl %ebp, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: repoLock
void repoLock(CR_Region *r, StringView repo_path,
              const RepoLockHint lock_hint)
{
  const int old_errno = errno;
  Allocator *a = allocatorWrapRegion(r);

  LockfileInfo *lockfile_info = CR_RegionAlloc(r, sizeof *lockfile_info);
  lockfile_info->is_locked = false;
  lockfile_info->file_path =
    strGetContent(strAppendPath(repo_path, str("lockfile"), a), a);
  lockfile_info->file_descriptor =
    open(lockfile_info->file_path, O_CREAT | O_WRONLY, S_IWUSR | S_IWGRP);

  if(lockfile_info->file_descriptor == -1)
  {
    if(errno == EROFS && lock_hint == RLH_readonly)
    {
      errno = old_errno;
      return;
    }
    dieErrno("failed to create lockfile: \"%s\"",
             lockfile_info->file_path);
  }
  CR_RegionAttach(r, cleanupLockfile, lockfile_info);

  if(lockf(lockfile_info->file_descriptor, F_TLOCK, 0) == 0)
  {
    lockfile_info->is_locked = true;
  }
  else if(errno == EACCES || errno == EAGAIN)
  {
    die("repository is already being used by another process");
  }
  else
  {
    dieErrno("failed to lock repository: \"%s\"",
             lockfile_info->file_path);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, 0x34(%rsp)
movq %rdi, %r15
callq 0x2060
movq %rax, %rbx
movl (%rax), %ebp
movq %r15, %rdi
callq 0x2578
movq %rax, %r12
pushq $0x10
popq %rsi
movq %r15, %rdi
callq 0xd104
movq %rax, %r14
movb $0x0, (%rax)
leaq 0x6a98(%rip), %rsi      # 0xe1f2
leaq 0x38(%rsp), %r13
movq %r13, %rdi
callq 0xa3d0
movq 0x10(%r13), %rax
movq %rax, 0x28(%rsp)
movups (%r13), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0xa0(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0xa6c6
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0xa3fb
movq %rax, 0x8(%r14)
pushq $0x41
popq %rsi
movq %rax, %rdi
movl $0x90, %edx
xorl %eax, %eax
callq 0x2360
movl %eax, 0x4(%r14)
cmpl $-0x1, %eax
je 0x7806
leaq 0x79(%rip), %rsi        # 0x785c
movq %r15, %rdi
movq %r14, %rdx
callq 0xd1db
movl 0x4(%r14), %edi
pushq $0x2
popq %rsi
xorl %edx, %edx
callq 0x2180
testl %eax, %eax
jne 0x7823
movb $0x1, (%r14)
jmp 0x7814
cmpl $0x1, 0x34(%rsp)
jne 0x783d
cmpl $0x1e, (%rbx)
jne 0x783d
movl %ebp, (%rbx)
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %eax
cmpl $0xd, %eax
je 0x782f
cmpl $0xb, %eax
jne 0x784a
leaq 0x70ea(%rip), %rdi      # 0xe920
xorl %eax, %eax
callq 0x3918
movq 0x8(%r14), %rsi
leaq 0x70b8(%rip), %rdi      # 0xe900
jmp 0x7855
movq 0x8(%r14), %rsi
leaq 0x70ff(%rip), %rdi      # 0xe954
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/repository.c
// Function: cleanupLockfile
static void cleanupLockfile(void *lockfile_info_ptr)
{
  const LockfileInfo *info = lockfile_info_ptr;

  const int old_errno = errno;
  if(info->is_locked)
  {
    (void)lockf(info->file_descriptor, F_ULOCK, 0);
    (void)close(info->file_descriptor);
    (void)remove(info->file_path);
  }
  else
  {
    (void)close(info->file_descriptor);
  }
  errno = old_errno;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %r14
callq 0x2060
movq %rax, %rbx
movl (%rax), %ebp
movl 0x4(%r14), %edi
cmpb $0x1, (%r14)
jne 0x7894
xorl %esi, %esi
xorl %edx, %edx
callq 0x2180
movl 0x4(%r14), %edi
callq 0x21c0
movq 0x8(%r14), %rdi
callq 0x2080
jmp 0x7899
callq 0x21c0
movl %ebp, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: initiateRestore
void initiateRestore(Metadata *metadata, const size_t id, StringView path)
{
  AllocatorPair allocator_pair = {
    .a = allocatorWrapRegion(metadata->r),
    .reusable_buffer = allocatorWrapOneSingleGrowableBuffer(metadata->r),
  };

  if(strIsEmpty(path))
  {
    for(PathNode *node = metadata->paths; node != NULL; node = node->next)
    {
      const PathState *state = searchExistingPathState(node, id);
      if(state != NULL)
      {
        checkAndHandleChangesRecursively(&allocator_pair, node, state, id,
                                         true);
      }
    }
  }
  else
  {
    initiateRestoreRecursively(&allocator_pair, metadata->paths, id, path,
                               true);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x2578
movq %rax, 0x18(%rsp)
movq (%r14), %rdi
callq 0x2590
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xa55a
addq $0x48, %r14
testb %al, %al
je 0x7924
leaq 0x18(%rsp), %r15
pushq $0x1
popq %rbp
movq (%r14), %r14
testq %r14, %r14
je 0x794c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7957
testq %rax, %rax
je 0x791e
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x798b
addq $0x30, %r14
jmp 0x78f2
leaq 0x50(%rsp), %rax
movq (%r14), %rsi
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rdi
pushq $0x1
popq %rcx
movq %rbx, %rdx
callq 0x7a08
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: searchExistingPathState
static const PathState *searchPathState(const PathNode *node,
                                        const size_t id)
{
  if(node->policy != BPOL_track)
  {
    return &node->history->state;
  }

  for(PathHistory *point = node->history; point != NULL;
      point = point->next)
  {
    if(point->backup->id >= id)
    {
      return &point->state;
    }
  }

  return NULL;
}

// Assembly:
leaq 0x20(%rdi), %rcx
cmpl $0x3, 0x1c(%rdi)
jne 0x7979
xorl %eax, %eax
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x798a
movq (%rcx), %rdx
cmpq %rsi, (%rdx)
jae 0x797c
addq $0x48, %rcx
jmp 0x7963
movq (%rcx), %rcx
leaq 0x8(%rcx), %rdx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
cmovneq %rdx, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: checkAndHandleChangesRecursively
static void checkAndHandleChangesRecursively(AllocatorPair *allocator_pair,
                                             PathNode *node,
                                             const PathState *state,
                                             const size_t id,
                                             bool could_exist)
{
  checkAndHandleChanges(allocator_pair, node, state, could_exist);
  if(state->type != PST_directory)
  {
    return;
  }
  if(backupHintNoPol(node->hint) >= BH_added &&
     backupHintNoPol(node->hint) <= BH_other_to_directory)
  {
    could_exist = false;
  }

  for(PathNode *subnode = node->subnodes; subnode != NULL;
      subnode = subnode->next)
  {
    const PathState *subnode_state = searchExistingPathState(subnode, id);
    if(subnode_state != NULL)
    {
      checkAndHandleChangesRecursively(allocator_pair, subnode,
                                       subnode_state, id, could_exist);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %r8d, %ebp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r15
movl %r8d, %ecx
callq 0x7ede
cmpl $0x3, (%r12)
jne 0x79ff
movl $0x1fe, %eax            # imm = 0x1FE
andl 0x18(%r14), %eax
addl $-0xe, %eax
cmpl $-0xc, %eax
setb %al
andb %bpl, %al
addq $0x28, %r14
movzbl %al, %ebp
movq (%r14), %r14
testq %r14, %r14
je 0x79ff
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7957
testq %rax, %rax
je 0x79f9
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %rbx, %rcx
movl %ebp, %r8d
callq 0x798b
addq $0x30, %r14
jmp 0x79cd
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: restoreFile
void restoreFile(StringView path, const RegularFileInfo *info,
                 StringView repo_path)
{
  if(info->size > FILE_HASH_SIZE)
  {
    RepoReader *reader = repoReaderOpenFile(repo_path, path, info);
    FileStream *writer = sFopenWrite(path);
    uint64_t bytes_left = info->size;
    char buffer[4096];

    while(bytes_left > 0)
    {
      const size_t bytes_to_read =
        bytes_left > sizeof(buffer) ? sizeof(buffer) : bytes_left;

      repoReaderRead(buffer, bytes_to_read, reader);
      sFwrite(buffer, bytes_to_read, writer);

      bytes_left -= bytes_to_read;
    }

    repoReaderClose(reader);
    sFclose(writer);
  }
  else
  {
    FileStream *writer = sFopenWrite(path);
    sFwrite(info->hash, info->size, writer);
    sFclose(writer);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1038, %rsp           # imm = 0x1038
movq %rdi, %rbx
leaq 0x1070(%rsp), %r15
cmpq $0x15, 0x10(%rdi)
jb 0x7c1a
leaq 0x1088(%rsp), %rax
movq 0x10(%r15), %rcx
movq %rcx, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movups (%rax), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0x70fd
movq %rax, %r14
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x837a
movq %rax, %r15
movq 0x10(%rbx), %r13
movl $0x1000, %ebp           # imm = 0x1000
leaq 0x30(%rsp), %rbx
testq %r13, %r13
je 0x7c5f
cmpq %rbp, %r13
movl $0x1000, %r12d          # imm = 0x1000
cmovbq %r13, %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x71b6
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x849f
subq %r12, %r13
jmp 0x7be7
movq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movups (%r15), %xmm0
movups %xmm0, (%rsp)
callq 0x837a
movq %rax, %r14
movq 0x10(%rbx), %rsi
addq $0x18, %rbx
movq %rbx, %rdi
movq %rax, %rdx
callq 0x849f
movq %r14, %rdi
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x859c
movq %r14, %rdi
callq 0x726d
movq %r15, %rdi
callq 0x859c
addq $0x1038, %rsp           # imm = 0x1038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: checkAndHandleChanges
static void checkAndHandleChanges(AllocatorPair *allocator_pair,
                                  PathNode *node, const PathState *state,
                                  const bool could_exist)
{
  if(could_exist && sPathExists(node->path))
  {
    const struct stat stats =
      state->type == PST_symlink ? sLStat(node->path) : sStat(node->path);

    handleFiletypeChanges(node, state, stats);
    if(backupHintNoPol(node->hint) == BH_none)
    {
      PathState dummy_state = *state;
      applyNodeChanges(allocator_pair, node, &dummy_state, stats);
    }
  }
  else
  {
    backupHintSet(node->hint, BH_added);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x160, %rsp            # imm = 0x160
movq %rsi, %rbx
testl %ecx, %ecx
je 0x7f35
movq %rdx, %r15
movq %rdi, %r14
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x886e
testb %al, %al
je 0x7f35
cmpl $0x2, (%r15)
jne 0x7f50
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
leaq 0x90(%rsp), %rdi
callq 0x8947
jmp 0x7f6d
movl $0xfffffe00, %eax       # imm = 0xFFFFFE00
andl 0x18(%rbx), %eax
orl $0x2, %eax
movl %eax, 0x18(%rbx)
addq $0x160, %rsp            # imm = 0x160
popq %rbx
popq %r14
popq %r15
retq
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
leaq 0x90(%rsp), %rdi
callq 0x88e8
movl 0xa8(%rsp), %eax
movl (%r15), %ecx
cmpl $0x3, %ecx
je 0x7fc0
cmpl $0x2, %ecx
je 0x7fa3
cmpl $0x1, %ecx
jne 0x8001
andl $0xf000, %eax           # imm = 0xF000
cmpw $0xa000, %ax            # imm = 0xA000
je 0x7fe9
cmpl $0x8000, %eax           # imm = 0x8000
je 0x8001
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x7ff1
pushq $0x9
jmp 0x7ff3
andl $0xf000, %eax           # imm = 0xF000
cmpw $0xa000, %ax            # imm = 0xA000
je 0x8001
cmpl $0x8000, %eax           # imm = 0x8000
je 0x7fdd
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x7fe5
pushq $0xa
jmp 0x7ff3
andl $0xf000, %eax           # imm = 0xF000
cmpw $0x4000, %ax            # imm = 0x4000
je 0x8001
cmpl $0x8000, %eax           # imm = 0x8000
je 0x7fe1
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x7fed
pushq $0x8
jmp 0x7ff3
pushq $0x5
jmp 0x7ff3
pushq $0x6
jmp 0x7ff3
pushq $0xc
jmp 0x7ff3
pushq $0x7
jmp 0x7ff3
pushq $0xd
jmp 0x7ff3
pushq $0xb
popq %rax
movl $0xfffffe00, %ecx       # imm = 0xFFFFFE00
andl 0x18(%rbx), %ecx
orl %eax, %ecx
movl %ecx, 0x18(%rbx)
movzwl 0x18(%rbx), %eax
testw $0x1ff, %ax             # imm = 0x1FF
jne 0x7f43
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups 0x30(%r15), %xmm3
leaq 0x120(%rsp), %rdx
movaps %xmm3, 0x30(%rdx)
movaps %xmm2, 0x20(%rdx)
movaps %xmm1, 0x10(%rdx)
movaps %xmm0, (%rdx)
pushq $0x12
popq %rcx
leaq 0x90(%rsp), %rsi
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x25cc
jmp 0x7f43
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: findExistingPathState
static const PathState *findExistingPathState(const PathNode *node,
                                              const size_t id)
{
  const PathState *state = searchExistingPathState(node, id);

  if(state == NULL)
  {
    die("path didn't exist at the specified time: \"" PRI_STR "\"",
        STR_FMT(node->path));
  }

  return state;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x7957
testq %rax, %rax
je 0x806a
popq %rbx
retq
movl 0x8(%rbx), %esi
movq (%rbx), %rdx
leaq 0x696e(%rip), %rdi      # 0xe9e5
xorl %eax, %eax
callq 0x3918
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/restore.c
// Function: restorePath
static void restorePath(const PathNode *node, const PathState *state,
                        StringView repo_path)
{
  if(state->type == PST_regular_file)
  {
    restoreFile(node->path, &state->metadata.file_info, repo_path);
    sChown(node->path, state->uid, state->gid);
    sChmod(node->path, state->metadata.file_info.permission_bits);
    sUtime(node->path, state->metadata.file_info.modification_time);
  }
  else if(state->type == PST_symlink)
  {
    sSymlink(state->metadata.symlink_target, node->path);
    sLChown(node->path, state->uid, state->gid);
  }
  else if(state->type == PST_directory)
  {
    sMkdir(node->path);
    sChown(node->path, state->uid, state->gid);
    sChmod(node->path, state->metadata.directory_info.permission_bits);
    sUtime(node->path, state->metadata.directory_info.modification_time);
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
cmpl $0x3, %eax
je 0x811c
cmpl $0x2, %eax
je 0x80d5
cmpl $0x1, %eax
jne 0x8180
leaq 0x50(%rsp), %rax
leaq 0x10(%r14), %rdi
movq 0x10(%rax), %rcx
movq %rcx, 0x28(%rsp)
movups (%rax), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x7b64
jmp 0x8131
movq 0x10(%rbx), %rax
movq %rax, 0x28(%rsp)
movups (%rbx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x20(%r14), %rax
movq %rax, 0x10(%rsp)
movups 0x10(%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x89f1
movl 0x4(%r14), %edi
movl 0x8(%r14), %esi
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8c6b
jmp 0x8180
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x89a6
movl 0x4(%r14), %edi
movl 0x8(%r14), %esi
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8c19
movl 0x10(%r14), %edi
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8bcd
movq 0x18(%r14), %rdi
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
callq 0x8cbd
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sFopenRead
FileStream *sFopenRead(StringView path)
{
  FileStream *result = newFileStream(path);
  result->handle = fopen(nullTerminate(path), "rb");
  if(result->handle == NULL)
  {
    CR_RegionRelease(result->r);
    dieErrno("failed to open \"" PRI_STR "\" for reading", STR_FMT(path));
  }
  CR_RegionAttach(result->r, closeFileHandle, result);

  return result;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x82cc
movq %rax, %rbx
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
leaq 0x6585(%rip), %rsi      # 0xe807
movq %rax, %rdi
callq 0x2370
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
testq %rax, %rax
je 0x82ae
leaq 0xb6(%rip), %rsi        # 0x8353
movq %rbx, %rdx
callq 0xd1db
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
retq
leaq 0x30(%rsp), %rbx
callq 0xd21a
movl 0x8(%rbx), %esi
movq (%rbx), %rdx
leaq 0x67c4(%rip), %rdi      # 0xea89
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: newFileStream
static FileStream *newFileStream(StringView path)
{
  CR_Region *r = CR_RegionNew();

  FileStream *stream = CR_RegionAlloc(r, sizeof *stream);
  stream->r = r;
  strSet(&stream->path, strCopy(path, allocatorWrapRegion(r)));
  return stream;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
callq 0xd040
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %rax, %rdi
callq 0xd104
movq %rax, %r14
movq %rbx, (%rax)
leaq 0x8(%rax), %r15
movq %rbx, %rdi
callq 0x2578
movq 0x60(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa466
movq 0x10(%rbx), %rax
movq %rax, 0x10(%rsp)
movups (%rbx), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0xa454
movq %r14, %rax
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: closeFileHandle
static void closeFileHandle(void *data)
{
  FileStream *stream = data;
  if(stream->handle == NULL) return;

  const int old_errno = errno;
  (void)fclose(stream->handle);
  errno = old_errno;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x20(%rdi), %rbx
testq %rbx, %rbx
je 0x8375
callq 0x2060
movq %rax, %r14
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x2100
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sFopenWrite
FileStream *sFopenWrite(StringView path)
{
  FileStream *result = newFileStream(path);
  result->handle = fopen(nullTerminate(path), "wb");
  if(result->handle == NULL)
  {
    CR_RegionRelease(result->r);
    dieErrno("failed to open \"" PRI_STR "\" for writing", STR_FMT(path));
  }
  CR_RegionAttach(result->r, closeFileHandle, result);

  return result;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x82cc
movq %rax, %rbx
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
leaq 0x66f2(%rip), %rsi      # 0xeaab
movq %rax, %rdi
callq 0x2370
movq %rax, 0x20(%rbx)
movq (%rbx), %rdi
testq %rax, %rax
je 0x83e5
leaq -0x81(%rip), %rsi       # 0x8353
movq %rbx, %rdx
callq 0xd1db
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
retq
leaq 0x30(%rsp), %rbx
callq 0xd21a
movl 0x8(%rbx), %esi
movq (%rbx), %rdx
leaq 0x66b2(%rip), %rdi      # 0xeaae
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sFread
void sFread(void *ptr, const size_t size, FileStream *stream)
{
  if(fread(ptr, 1, size, stream->handle) != size)
  {
    if(feof(stream->handle))
    {
      die("reading \"%s\": reached end of file unexpectedly",
          internalFDestroy(stream));
    }
    else
    {
      dieErrno("IO error while reading \"%s\"", internalFDestroy(stream));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq 0x20(%rdx), %rcx
pushq $0x1
popq %rsi
movq %r14, %rdx
callq 0x20c0
cmpq %r14, %rax
jne 0x8426
popq %rbx
popq %r14
popq %rbp
retq
movq 0x20(%rbx), %rdi
callq 0x2260
movl %eax, %ebp
movq %rbx, %rdi
callq 0x845f
testl %ebp, %ebp
jne 0x844e
leaq 0x66bb(%rip), %rdi      # 0xeaff
movq %rax, %rsi
xorl %eax, %eax
callq 0x39d8
leaq 0x667b(%rip), %rdi      # 0xead0
movq %rax, %rsi
xorl %eax, %eax
callq 0x3918
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: fDatasync
void fDatasync(StringView path)
{
  const int dir_descriptor = open(nullTerminate(path), O_RDONLY, 0);
  if(dir_descriptor == -1 || fdatasync(dir_descriptor) != 0 ||
     close(dir_descriptor) != 0)
  {
    dieErrno("failed to sync path to device: \"" PRI_STR "\"",
             STR_FMT(path));
  }
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2360
cmpl $-0x1, %eax
je 0x8583
movl %eax, %ebx
movl %eax, %edi
callq 0x2070
testl %eax, %eax
jne 0x8583
movl %ebx, %edi
callq 0x21c0
testl %eax, %eax
jne 0x8583
addq $0x20, %rsp
popq %rbx
retq
leaq 0x30(%rsp), %rax
movl 0x8(%rax), %esi
movq (%rax), %rdx
leaq 0x659e(%rip), %rdi      # 0xeb33
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sFclose
void sFclose(FileStream *stream)
{
  FILE *handle = stream->handle;
  stream->handle = NULL;
  const char *path = internalFDestroy(stream);

  if(fclose(handle) != 0)
  {
    dieErrno("failed to close \"%s\"", path);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x20(%rdi), %r14
andq $0x0, 0x20(%rdi)
callq 0x845f
movq %rax, %rbx
movq %r14, %rdi
callq 0x2100
testl %eax, %eax
jne 0x85c5
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x658d(%rip), %rdi      # 0xeb59
movq %rbx, %rsi
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: closeDirHandle
void closeDirHandle(void *data)
{
  DirIterator *dir = data;
  if(dir->handle == NULL) return;

  const int old_errno = errno;
  (void)closedir(dir->handle);
  errno = old_errno;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq 0x28(%rdi), %rbx
testq %rbx, %rbx
je 0x85fd
callq 0x2060
movq %rax, %r14
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x21d0
movl %ebp, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sDirOpen
DirIterator *sDirOpen(StringView path)
{
  CR_Region *r = CR_RegionNew();
  DirIterator *dir = CR_RegionAlloc(r, sizeof *dir);

  dir->r = r;
  strSet(&dir->directory_path, strCopy(path, allocatorWrapRegion(r)));
  dir->returned_result_buffer = allocatorWrapOneSingleGrowableBuffer(r);
  dir->handle = opendir(nullTerminate(path));

  if(dir->handle == NULL)
  {
    CR_RegionRelease(r);
    dieErrno("failed to open directory \"" PRI_STR "\"", STR_FMT(path));
  }
  CR_RegionAttach(r, closeDirHandle, dir);

  return dir;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x38, %rsp
callq 0xd040
movq %rax, %rbx
pushq $0x30
popq %rsi
movq %rax, %rdi
callq 0xd104
movq %rax, %r14
movq %rbx, (%rax)
leaq 0x8(%rax), %r15
movq %rbx, %rdi
callq 0x2578
movq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0xa466
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
movq %r15, %rdi
callq 0xa454
movq %rbx, %rdi
callq 0x2590
movq %rax, 0x20(%r14)
movq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x60(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
movq %rax, %rdi
callq 0x2110
movq %rax, 0x28(%r14)
testq %rax, %rax
je 0x86c6
leaq -0xd1(%rip), %rsi       # 0x85db
movq %rbx, %rdi
movq %r14, %rdx
callq 0xd1db
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x60(%rsp), %r14
movq %rbx, %rdi
callq 0xd21a
movl 0x8(%r14), %esi
movq (%r14), %rdx
leaq 0x648d(%rip), %rdi      # 0xeb6e
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sDirGetNext
StringView sDirGetNext(DirIterator *dir)
{
  struct dirent *dir_entry;
  const int old_errno = errno;
  errno = 0;

  do
  {
    dir_entry = readdir(dir->handle);

    if(dir_entry == NULL && errno != 0)
    {
      dieErrno("failed to read directory \"" PRI_STR "\"",
               STR_FMT(dir->directory_path));
    }
  } while(dir_entry != NULL && dir_entry->d_name[0] == '.' &&
          (dir_entry->d_name[1] == '\0' ||
           (dir_entry->d_name[1] == '.' && dir_entry->d_name[2] == '\0')));

  errno = old_errno;
  if(dir_entry == NULL)
  {
    return str("");
  }

  return strAppendPath(dir->directory_path, str(dir_entry->d_name),
                       dir->returned_result_buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x2060
movq %rax, %r15
movl (%rax), %ebp
andl $0x0, (%rax)
movq 0x28(%r14), %rdi
callq 0x22c0
testq %rax, %rax
je 0x8775
cmpb $0x2e, 0x13(%rax)
jne 0x872c
movzbl 0x14(%rax), %ecx
testl %ecx, %ecx
je 0x8705
cmpl $0x2e, %ecx
jne 0x872c
cmpb $0x0, 0x15(%rax)
je 0x8705
addq $0x13, %rax
movl %ebp, (%r15)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
callq 0xa3d0
movq 0x20(%r14), %rsi
movq 0x10(%r15), %rax
movq %rax, 0x28(%rsp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x10(%rsp)
movups 0x8(%r14), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
callq 0xa6c6
jmp 0x878d
cmpl $0x0, (%r15)
jne 0x879b
movl %ebp, (%r15)
leaq 0x601a(%rip), %rsi      # 0xe79f
movq %rbx, %rdi
callq 0xa3d0
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl 0x10(%r14), %esi
movq 0x8(%r14), %rdx
leaq 0x63e4(%rip), %rdi      # 0xeb8e
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sDirClose
void sDirClose(DirIterator *dir)
{
  DIR *handle = dir->handle;
  dir->handle = NULL;

  if(closedir(handle) != 0)
  {
    dieErrno("failed to close directory \"" PRI_STR "\"",
             STR_FMT(dir->directory_path));
  }
  CR_RegionRelease(dir->r);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
andq $0x0, 0x28(%rbx)
callq 0x21d0
testl %eax, %eax
jne 0x87d0
movq (%rbx), %rdi
popq %rbx
jmp 0xd21a
movl 0x10(%rbx), %esi
movq 0x8(%rbx), %rdx
leaq 0x63d0(%rip), %rdi      # 0xebae
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sFbytesLeft
bool sFbytesLeft(FileStream *stream)
{
  const int old_errno = errno;
  errno = 0;

  const int character = fgetc(stream->handle);
  if(character == EOF && errno != 0 && errno != EBADF)
  {
    dieErrno("failed to check for remaining bytes in \"%s\"",
             internalFDestroy(stream));
  }
  errno = old_errno;

  if(ungetc(character, stream->handle) != character)
  {
    die("failed to check for remaining bytes in \"%s\"",
        internalFDestroy(stream));
  }

  return character != EOF;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2060
movq %rax, %r14
movl (%rax), %r15d
andl $0x0, (%rax)
movq 0x20(%rbx), %rdi
callq 0x21b0
movl %eax, %ebp
cmpl $-0x1, %eax
jne 0x8819
movl (%r14), %eax
testl %eax, %eax
je 0x8819
cmpl $0x9, %eax
jne 0x8855
movl %r15d, (%r14)
movq 0x20(%rbx), %rsi
movl %ebp, %edi
callq 0x22f0
cmpl %ebp, %eax
jne 0x883c
cmpl $-0x1, %ebp
setne %al
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x845f
leaq 0x6384(%rip), %rdi      # 0xebcf
movq %rax, %rsi
xorl %eax, %eax
callq 0x3918
movq %rbx, %rdi
callq 0x845f
leaq 0x636b(%rip), %rdi      # 0xebcf
movq %rax, %rsi
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sPathExists
bool sPathExists(StringView path)
{
  const int old_errno = errno;
  bool exists = true;
  struct stat stats;
  errno = 0;

  if(lstat(nullTerminate(path), &stats) != 0)
  {
    if(errno != 0 && errno != ENOENT)
    {
      dieErrno("failed to check existence of \"" PRI_STR "\"",
               STR_FMT(path));
    }

    exists = false;
  }

  errno = old_errno;
  return exists;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0xa8, %rsp
callq 0x2060
movq %rax, %rbx
movl (%rax), %ebp
andl $0x0, (%rax)
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0xc0(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x2210
testl %eax, %eax
je 0x88bb
testl $0xfffffffd, (%rbx)     # imm = 0xFFFFFFFD
jne 0x88cc
testl %eax, %eax
sete %al
movl %ebp, (%rbx)
addq $0xa8, %rsp
popq %rbx
popq %rbp
retq
leaq 0xc0(%rsp), %rax
movl 0x8(%rax), %esi
movq (%rax), %rdx
leaq 0x631a(%rip), %rdi      # 0xebfb
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sSymlinkReadTarget
StringView sSymlinkReadTarget(StringView path, Allocator *a)
{
  const struct stat stats = sLStat(path);

  const uint64_t buffer_length = sUint64Add(stats.st_size, 1);
  if(buffer_length > SIZE_MAX)
  {
    die("symlink does not fit in memory: \"" PRI_STR "\"", STR_FMT(path));
  }
  else if(buffer_length > SSIZE_MAX)
  {
    /* In this case the behaviour of readlink() is implementation
       dependent and not portable. */
    die("symlink is too large: \"" PRI_STR "\"", STR_FMT(path));
  }

  char *buffer = allocate(a, buffer_length);

  /* Although st_size bytes are enough to store the symlinks target path,
     the full buffer is used. This allows to detect whether the symlink
     has increased in size while reading. */
  const ssize_t read_bytes =
    readlink(nullTerminate(path), buffer, buffer_length);
  if(read_bytes == -1)
  {
    dieErrno("failed to read symlink: \"" PRI_STR "\"", STR_FMT(path));
  }
  else if(read_bytes != stats.st_size)
  {
    die("symlink changed while reading: \"" PRI_STR "\"", STR_FMT(path));
  }
  buffer[read_bytes] = '\0';

  return str(buffer);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb0, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xe0(%rsp), %r13
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movaps (%r13), %xmm0
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x8947
movq 0x30(%r14), %r14
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x81c4
testq %rax, %rax
js 0x8b1f
movq %rax, %r12
movq %r15, %rdi
movq %rax, %rsi
callq 0x24fc
movq %rax, %r15
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x20d0
cmpq $-0x1, %rax
je 0x8b30
cmpq %r14, %rax
jne 0x8b46
movb $0x0, (%r15,%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa3d0
movq %rbx, %rax
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movl 0x8(%r13), %esi
movq (%r13), %rdx
leaq 0x6135(%rip), %rdi      # 0xec63
jmp 0x8b55
movl 0x8(%r13), %esi
movq (%r13), %rdx
leaq 0x6141(%rip), %rdi      # 0xec80
xorl %eax, %eax
callq 0x39d8
movl 0x8(%r13), %esi
movq (%r13), %rdx
leaq 0x54f6(%rip), %rdi      # 0xe04b
xorl %eax, %eax
callq 0x3918
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: sRemove
void sRemove(StringView path)
{
  const int old_errno = errno;
  if(remove(nullTerminate(path)) != 0)
  {
    dieErrno("failed to remove \"" PRI_STR "\"", STR_FMT(path));
  }
  errno = old_errno;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x18, %rsp
callq 0x2060
movq %rax, %rbx
movl (%rax), %ebp
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0x8342
movq %rax, %rdi
callq 0x2080
testl %eax, %eax
jne 0x8d51
movl %ebp, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x30(%rsp), %rax
movl 0x8(%rax), %esi
movq (%rax), %rdx
leaq 0x5fc8(%rip), %rdi      # 0xed2b
xorl %eax, %eax
callq 0x39d8
// File: /workspace/github_c_makefile_star2_O2/AlxHnr[P]nano-backup/src/safe-wrappers.c
// Function: removeRecursivelyIf
static bool removeRecursivelyIf(StringView path,
                                ShouldRemoveCallback should_remove,
                                void *user_data)
{
  bool current_path_is_needed = false;

  const struct stat stats = sLStat(path);
  if(S_ISDIR(stats.st_mode))
  {
    DirIterator *dir = sDirOpen(path);
    for(StringView subpath = sDirGetNext(dir); !strIsEmpty(subpath);
        strSet(&subpath, sDirGetNext(dir)))
    {
      if(!removeRecursivelyIf(subpath, should_remove, user_data))
      {
        current_path_is_needed = true;
      }
    }
    sDirClose(dir);
  }

  if(!current_path_is_needed && should_remove(path, &stats, user_data))
  {
    sRemove(path);
    return true;
  }
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x110(%rsp), %r12
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movaps (%r12), %xmm0
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x8947
movl $0xf000, %eax           # imm = 0xF000
andl 0x18(%r15), %eax
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x8e7c
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x8602
movq %rax, %r15
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x86e8
xorl %ebp, %ebp
leaq 0x30(%rsp), %r13
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
callq 0xa55a
testb %al, %al
jne 0x8e66
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8d7a
xorb $0x1, %al
orb %al, %bpl
movq %r13, %rdi
movq %r15, %rsi
callq 0x86e8
movq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0x30(%rsp), %xmm0
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0xa454
jmp 0x8dff
movq %r15, %rdi
callq 0x87b1
testb $0x1, %bpl
leaq 0x110(%rsp), %r12
jne 0x8eb9
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
callq *%rbx
testb %al, %al
je 0x8eb9
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movups (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x8d14
movb $0x1, %al
jmp 0x8ebb
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq