// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xd8, %rsp
movl %edi, 0xd4(%rsp)
movq %rsi, 0xc8(%rsp)
movl %edx, 0xc4(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
movl $0x0, 0x4(%rsp)
cmpq $0x0, 0xb0(%rsp)
je 0x473db
movq 0xb0(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x473a3
jmp 0x473db
movq 0x5f4bf6(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4cec5f(%rip), %rsi    # 0x516013
leaq 0x4cee04(%rip), %rdx    # 0x5161bf
leaq 0x4dae3d(%rip), %rcx    # 0x5221ff
leaq 0x4dae4c(%rip), %r8     # 0x522215
movl $0x32, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x473dd
movl 0xc4(%rsp), %eax
movl %eax, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0xd4(%rsp), %eax
jge 0x4756e
movq 0xc8(%rsp), %rax
movslq 0xac(%rsp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x127650
movl %eax, 0xa8(%rsp)
movl 0xa8(%rsp), %edi
leaq 0x10(%rsp), %rsi
callq 0x1274a0
cmpq $0x0, 0x40(%rsp)
jne 0x47463
movq 0xc8(%rsp), %rax
movslq 0xac(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x4dadd9(%rip), %rdi    # 0x522230
movb $0x0, %al
callq 0x19070
jmp 0x4754c
movl 0x28(%rsp), %eax
andl $0x8000, %eax           # imm = 0x8000
cmpl $0x0, %eax
jne 0x47498
movq 0xc8(%rsp), %rax
movslq 0xac(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x4dadb8(%rip), %rdi    # 0x522244
movb $0x0, %al
callq 0x19070
jmp 0x4754a
movq 0x40(%rsp), %rsi
movl 0xa8(%rsp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %edx
movl $0x2, %ecx
movq %r9, %rdi
callq 0x127780
movq %rax, 0xa0(%rsp)
movq 0xc8(%rsp), %rax
movslq 0xac(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x4dad81(%rip), %rdi    # 0x522260
movb $0x0, %al
callq 0x19070
movq $0x0, 0x8(%rsp)
movq 0x40(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0xf9830
movq 0x8(%rsp), %rax
cmpq 0x40(%rsp), %rax
jae 0x47533
movq 0xa0(%rsp), %rax
movq 0x8(%rsp), %rcx
movsbl (%rax,%rcx), %eax
orl 0x4(%rsp), %eax
movl %eax, 0x4(%rsp)
movq 0x8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
jmp 0x474fe
callq 0xfa220
movq 0xa0(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x127800
jmp 0x4754c
movl 0xa8(%rsp), %edi
callq 0x127420
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x473eb
cmpl $0x0, 0x4(%rsp)
jne 0x47583
leaq 0x4dacf7(%rip), %rdi    # 0x522273
movb $0x0, %al
callq 0x19070
xorl %eax, %eax
addq $0xd8, %rsp
retq
nopl (%rax)