// File: /workspace/github_c_makefile_star2_O2/ramirezsebas[P]TP-LISTINGS/./src/capitulo_2/2.2/getopt_long.c
// Function: main
int main (int argc, char* argv[])
{
  int next_option;
  /* A string listing valid short options letters.*/
  const char* const short_options = "ho:v";
     /* An array describing valid long options. */
  const struct option long_options[] = {
    { "help",   0, NULL,'h' },
    { "output", 1, NULL,'o' },
    { "verbose",0, NULL,'v' },
    { NULL,     0, NULL, 0  }    /* Required at end of array.*/
  };
  
  /* The name of the file to receive program output, or NULL for
     standard output. */
  const char* output_filename = NULL;
  /* Whether to display verbose messages. */
  int verbose = 0;

  /* Remember the name of the program, to incorporate in messages.
     The name is stored in argv[0]. */
  program_name = argv[0];
  
  do {
     next_option = getopt_long (argc, argv, short_options,
    			       long_options, NULL);
    switch (next_option)
      {
      case 'h':  /* -h or --help */
	/* User has requested usage information. Print it to standard
	   output, and exit with exit code zero (normal termination). */
		print_usage (stdout, 0);

      case 'o':    /* -o or --output */
	/* This option takes an argument, the name of the output file.*/
	   output_filename = optarg;
	   break;

      case 'v':   /* -v or --verbose */
		verbose = 1;
		break;
      
      case '?':
	/* The user specified an invalid option. */
	/* Print usage information to standard error, and exit with exit
	   code one (indicating abnormal termination). */
		print_usage (stderr, 1);

      case -1:
		break;
	/* Done with options. */

      default:
	/* Something else: unexpected.*/
		abort ();
      }
  }
  while (next_option != -1);
  
  /* Done with options. OPTIND points to first nonoption argument.
     For demonstration purposes, print them if the verbose option was
     specified. */
  if (verbose) {
    int i;
    for (i = optind; i < argc; ++i)
      printf ("Argument: %s\n", argv[i]);
  }
  
  /* The main program goes here. */
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x2b44(%rip), %rsi      # 0x3d30
pushq $0x10
popq %rcx
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq (%rbx), %rax
movq %rax, 0x2e5a(%rip)      # 0x4060
movb $0x1, %r13b
leaq 0xea1(%rip), %r12       # 0x20b1
movl %r14d, %edi
movq %rbx, %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1070
cmpl $0x6f, %eax
je 0x1210
cmpl $-0x1, %eax
je 0x1238
cmpl $0x76, %eax
jne 0x127e
xorl %r13d, %r13d
jmp 0x1210
testb $0x1, %r13b
je 0x1252
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2d87(%rip), %rax      # 0x3fe0
movslq (%rax), %r15
movslq %r14d, %r12
leaq 0xe64(%rip), %r14       # 0x20ca
cmpq %r12, %r15
jge 0x123e
movq (%rbx,%r15,8), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1030
incq %r15
jmp 0x1266
cmpl $0x3f, %eax
je 0x1299
cmpl $0x68, %eax
jne 0x12ab
movq 0x2d31(%rip), %rax      # 0x3fc0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x118c
movq 0x2d38(%rip), %rax      # 0x3fd8
movq (%rax), %rdi
pushq $0x1
popq %rsi
callq 0x118c
callq 0x1040