// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/tools/gt_mmapandread.c
// Function: gt_mmapandread_runner
static int gt_mmapandread_runner(int argc, const char **argv, int parsed_args,
                                 GT_UNUSED void *tool_arguments,
                                 GT_UNUSED GtError *err)
{
  int i, fd;
  void *map;
  struct stat sb;
  GtUint64 j;
  unsigned int byte = 0;
  gt_error_check(err);

  /* iterate over all files */
  for (i = parsed_args; i < argc; i++) {
    /* open file */
    fd = gt_xopen(argv[i], O_RDONLY, 0);

    /* get file statistics */
    gt_xfstat(fd, &sb);

    if (sb.st_size == 0)
      printf("file \"%s\" is empty\n", argv[i]);
    else if (!(sb.st_mode & S_IFREG))
      printf("\"%s\" is not a regular file\n", argv[i]);
    else {
      /* map file */
#ifndef _WIN32
      map = gt_xmmap(0, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
#else
      /* XXX */
      fprintf(stderr, "mmapandread not implemented\n");
      exit(EXIT_FAILURE);
#endif

      /* read file */
      printf("reading file \"%s\"\n", argv[i]);
      j = 0;
      gt_progressbar_start(&j, (GtUint64) sb.st_size);
      for (; j < (GtUint64) sb.st_size; j++)
        byte |= (unsigned int) ((char*) map)[j];
      gt_progressbar_stop();

      /* unmap file */
#ifndef _WIN32
      gt_xmunmap(map, sb.st_size);
#else
      /* XXX */
#endif
    }

    /* close file */
    gt_xclose(fd);
  }

  if (!byte)
    printf("all read files contained only null characters\n");

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
testq %r8, %r8
je 0x34ada
movq %r8, %rdi
callq 0x89eb7
testb %al, %al
jne 0x34bf2
movslq %ebp, %rbp
movslq %r14d, %r15
leaq 0x18(%rsp), %r12
xorl %r14d, %r14d
movq %r15, 0x10(%rsp)
cmpq %r15, %rbp
jge 0x34bcd
movq (%rbx,%rbp,8), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xb354e
movl %eax, %r13d
movl %eax, %edi
movq %r12, %rsi
callq 0xb3449
movq 0x48(%rsp), %rsi
testq %rsi, %rsi
je 0x34b2e
testb $-0x80, 0x31(%rsp)
jne 0x34b42
movq (%rbx,%rbp,8), %rsi
leaq 0x2bc6ad(%rip), %rdi    # 0x2f11d9
jmp 0x34b39
movq (%rbx,%rbp,8), %rsi
leaq 0x2bc68c(%rip), %rdi    # 0x2f11c5
xorl %eax, %eax
callq 0x17070
jmp 0x34bbd
movq %r12, %r15
xorl %edi, %edi
pushq $0x1
popq %rdx
pushq $0x2
popq %rcx
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0xb3611
movq %rax, %r12
movq (%rbx,%rbp,8), %rsi
leaq 0x2bc68f(%rip), %rdi    # 0x2f11f5
xorl %eax, %eax
callq 0x17070
andq $0x0, 0x8(%rsp)
movq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x9c79c
movq 0x48(%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rax, %rcx
jae 0x34ba3
movsbl (%r12,%rcx), %edx
orl %edx, %r14d
incq %rcx
movq %rcx, 0x8(%rsp)
jmp 0x34b8c
callq 0x9cce9
movq 0x48(%rsp), %rsi
movq %r12, %rdi
callq 0xb3633
movq %r15, %r12
movq 0x10(%rsp), %r15
movl %r13d, %edi
callq 0xb3408
incq %rbp
jmp 0x34aed
testl %r14d, %r14d
jne 0x34bde
leaq 0x2bc62f(%rip), %rdi    # 0x2f1208
callq 0x17b60
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40336f(%rip), %rax    # 0x437f68
movq (%rax), %rdi
leaq 0x2b0410(%rip), %rsi    # 0x2e5013
leaq 0x2b05b5(%rip), %rdx    # 0x2e51bf
leaq 0x2bc583(%rip), %rcx    # 0x2f1194
leaq 0x2bc592(%rip), %r8     # 0x2f11aa
pushq $0x32
popq %r9
xorl %eax, %eax
callq 0x17a50
callq 0x17390