// File: /workspace/github_c_makefile_star2_O3/zpole[P]IICV/vl/getopt_long.c
// Function: getopt_long
VL_EXPORT int
getopt_long(int argc, char *const argv[],
            const char *optstring,
            const struct option * longopts,
            int *longindex)
{
  static char *place = EMSG;	/* option letter processing */
  static int   optbegin  = 0 ;
  static int   optend    = 0 ;
  char        *oli;		/* option letter list index */
  int          has_colon = 0 ;
  int          ret_val   = 0 ;

  /*
     A semicolon at the beginning of optstring has a special meaning.
     If we find one, we annote and remove it.
  */
  has_colon = optstring && optstring[0] == ':' ;
  if (has_colon) ++ optstring ;

  /*
   Here we are either processing a short option sequence or
   we start processing a new option. This is indicated by optreset.
  */

  if (optreset || *place == '\0') {

    /* ---------------------------------------------------------------
     *                                 Look for next short/long option
     * ------------------------------------------------------------ */
    optreset = 0 ;

    /* no more arguments ? */
    if (optind >= argc) {
      place = EMSG ;
      return -1 ;
    }

    /* next argument that may hold an option */
    optbegin = optind ;

    /* ---------------------------------------------------------------
     *                                     Look for an option to parse
     * ------------------------------------------------------------ */

  parse_option_at_optbegin :

    /* place points to the candidate option */
    place = argv [optbegin] ;

    /* an option is introduced by '-' */
    if (place [0] != '-') {
      /* this argument is not an option: try next argument */
      ++ optbegin ;
      if (optbegin >= argc) {
        /* no more arguments to look for options */
        place = EMSG ;
        return -1 ;
      }
      goto parse_option_at_optbegin ;
    }

    /* consume leading `-' */
    ++ place ;

    /* assume the option is composed of one argument only */
    optend = optbegin + 1 ;

    /* assume no argument */
    optarg = 0 ;

    /* ---------------------------------------------------------------
     *                                                     option `--'
     * ------------------------------------------------------------ */

    /* this special option (void long option) ends the option processing */
    if (place[0]        &&
        place[0] == '-' &&
        place[1] == '\0') {

      optind  = optend ;
      place   = EMSG ;
      ret_val = -1 ;
      goto done_option ;
    }

    /* ---------------------------------------------------------------
     *                                                     long option
     * ------------------------------------------------------------ */

    if (place[0]        &&
        place[0] == '-' &&
        place[1] ) {

      size_t namelen ;
      int i ;

      /* consume second `-' */
      ++ place ;

      /* count characters before `=' */
      namelen = strcspn(place, "=") ;

      /* scan longopts for this option */
      for (i = 0 ; longopts[i].name != NULL ; ++ i) {

        if (strlen  (       longopts[i].name) == namelen &&
            strncmp (place, longopts[i].name, namelen) == 0 ) {

          /* save back long option index */
          if (longindex) *longindex = i ;

          /* process long option argument */
          if (longopts[i].has_arg == required_argument ||
              longopts[i].has_arg == optional_argument) {

            /* --option=value style */
            if (place[namelen] == '=') {
              optarg = place + namelen + 1 ;
            }

            /* --option value style (only required_argument) */
            else if (longopts[i].has_arg == required_argument) {
              /* missing argument ? */
              if (optbegin >= argc - 1) {
                if (! has_colon && opterr)
                  fprintf(stderr,
                          "%s: option requires an argument -- %s\n",
                          argv[0], place);
                place   = EMSG ;
                ret_val = has_colon ? BADARG : BADCH ;
                goto done_option ;
              }
              optarg = argv [optend] ;
              ++ optend ;
            }
          }

          /* determine return value */
          if (longopts[i].flag == NULL) {
            ret_val = longopts[i].val ;
          }
          else {
            *longopts[i].flag = longopts[i].val;
            ret_val = 0 ;
          }

          /* mark sequence closed */
          place = EMSG ;
          goto done_option ;
        } /* if match */

      } /* scan longoptions */

      /* no matching option found */
      if (! has_colon && opterr)
        fprintf(stderr,
                "%s: illegal option -- %s\n", argv[0], place) ;
      place   = EMSG ;
      ret_val = BADCH ;
      goto done_option ;
    }
  } /* end new option */

  /* -----------------------------------------------------------------
   *                                      Finish short option sequence
   * -------------------------------------------------------------- */
  optopt = (int) *place++ ;

  /* search charcater in option list */
  oli = strchr(optstring, optopt);

  /* short option not found */
  if (!oli) {

    if (! has_colon && opterr)
      fprintf(stderr,
              "%s: illegal option -- %c\n",
              argv[0], optopt);

    if (*place) {
      /* more short options in the list */
      return BADCH ;
    }

    else {
      /* error occured as last option in the list */
      place   = EMSG ;
      ret_val = BADCH ;
      goto done_option ;
    }
  } /* end short option not found */

  if (oli[1] != ':') {
    /* short option with no argument */

    if (*place) {
      /* more short options in the list */
      return optopt ;
    }
    else {
      /* last option in the list */
      place   = EMSG ;
      ret_val = optopt ;
      goto done_option ;
    }

  } else {
    /* short option with argument */

    /* -ovalue style */
    if (*place) {
      optarg  = place ;
      place   = EMSG ;
      ret_val = optopt ;
      goto done_option ;
    }
    /* -o value style: missing argument */
    else if (optbegin >= argc - 1) {
      if (! has_colon && opterr)
        fprintf(stderr,
                "%s: option requires an argument -- %c\n",
                argv[0], optopt);
      place   = EMSG ;
      ret_val = has_colon ? BADARG : BADCH ;
      goto done_option ;
    }

    /* -o value style: process argument */
    optarg = argv [optend] ;
    ++ optend ;
    place   = EMSG ;
    ret_val = optopt ;
    goto done_option ;
  } /* short with argument */

 done_option :
  {
    int pos = optend - optbegin ;  /* n of circular shifts */
    int c   = pos ;

    while (c --) {
      int i ;
      char *tmp = argv [optend - 1] ;
      for (i = optend - 1 ; i > optind ; -- i) {
        ((char**)argv) [i] = argv [i-1] ;
      }
      ((char**)argv) [optind] = tmp ;
    }
    optind += pos ;
  }

  return ret_val ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %esi, %esi
testq %rdx, %rdx
je 0x11175
cmpb $0x3a, (%rdx)
sete %sil
movq %rsi, %rdi
addq %rdx, %rdi
jmp 0x11177
xorl %edi, %edi
movq 0x29db2(%rip), %rax     # 0x3af30
cmpl $0x0, (%rax)
je 0x111dc
movl $0x0, (%rax)
movq 0x29e00(%rip), %rax     # 0x3af90
movl (%rax), %r13d
cmpl %ebp, %r13d
jge 0x111c3
movslq %r13d, %rdx
movl %r13d, 0x2a556(%rip)    # 0x3b6f8
leaq (%rbx,%rdx,8), %rdx
movq (%rdx), %r12
cmpb $0x2d, (%r12)
je 0x111f0
incl %r13d
movl %r13d, 0x2a53e(%rip)    # 0x3b6f8
addq $0x8, %rdx
cmpl %r13d, %ebp
jne 0x111a6
leaq 0x2163e(%rip), %rax     # 0x32808
movq %rax, 0x2a427(%rip)     # 0x3b5f8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x114e7
movq 0x2a415(%rip), %r15     # 0x3b5f8
movb (%r15), %dl
testb %dl, %dl
jne 0x112e9
jmp 0x11183
leaq 0x1(%r12), %r15
movq %r15, 0x2a3fc(%rip)     # 0x3b5f8
leal 0x1(%r13), %r9d
movl %r9d, 0x2a4f5(%rip)     # 0x3b6fc
movq 0x29de2(%rip), %rdx     # 0x3aff0
movq $0x0, (%rdx)
movb 0x1(%r12), %dl
cmpb $0x2d, %dl
jne 0x112e9
cmpb $0x0, 0x2(%r12)
je 0x11391
movl %ebp, 0xc(%rsp)
movl %r9d, 0x8(%rsp)
movq %r8, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
addq $0x2, %r12
movq %r12, 0x2a3ab(%rip)     # 0x3b5f8
leaq 0x211f1(%rip), %rsi     # 0x32445
movq %r12, %rdi
movq %rcx, %r14
callq 0x9460
movq (%r14), %r15
testq %r15, %r15
je 0x112b6
movq %r14, %rcx
movq %rax, %rdx
addq $0x20, %rcx
xorl %r14d, %r14d
movq %rcx, 0x18(%rsp)
movq %r15, %rdi
movq %rdx, %rbp
callq 0x9310
movq %rbp, %rdx
cmpq %rbp, %rax
jne 0x112a2
movq %r12, %rdi
movq %r15, %rsi
callq 0x90e0
movq %rbp, %rdx
testl %eax, %eax
je 0x113e6
movq 0x18(%rsp), %rcx
movq (%rcx), %r15
addq $0x20, %rcx
incl %r14d
testq %r15, %r15
jne 0x11274
movq 0x29c8b(%rip), %rax     # 0x3af48
cmpl $0x0, (%rax)
sete %al
movq 0x10(%rsp), %rcx
orb %al, %cl
je 0x114f9
leaq 0x21531(%rip), %rax     # 0x32808
movq %rax, 0x2a31a(%rip)     # 0x3b5f8
movl $0x3f, %r14d
jmp 0x11499
movq %rsi, %r12
incq %r15
movq %r15, 0x2a302(%rip)     # 0x3b5f8
movsbl %dl, %r14d
movq 0x29c9f(%rip), %rax     # 0x3afa0
movl %r14d, (%rax)
movl %r14d, %esi
callq 0x9370
testq %rax, %rax
je 0x1132d
cmpb $0x3a, 0x1(%rax)
movb (%r15), %al
jne 0x11358
testb %al, %al
je 0x11365
movq 0x29ccb(%rip), %rax     # 0x3aff0
movq %r15, (%rax)
jmp 0x1148b
movq 0x29c14(%rip), %rax     # 0x3af48
cmpl $0x0, (%rax)
sete %al
orb %al, %r12b
je 0x11420
movl $0x3f, %r14d
cmpb $0x0, (%r15)
jne 0x114e7
jmp 0x1148b
testb %al, %al
jne 0x114e7
jmp 0x1148b
decl %ebp
cmpl %ebp, 0x2a38b(%rip)     # 0x3b6f8
jge 0x113ad
movslq 0x2a386(%rip), %rax     # 0x3b6fc
movq (%rbx,%rax,8), %rcx
movq 0x29c6f(%rip), %rdx     # 0x3aff0
movq %rcx, (%rdx)
incl %eax
movl %eax, 0x2a370(%rip)     # 0x3b6fc
jmp 0x1148b
movl %r9d, (%rax)
leaq 0x2146d(%rip), %rax     # 0x32808
movq %rax, 0x2a256(%rip)     # 0x3b5f8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x11499
movq 0x29b94(%rip), %rax     # 0x3af48
cmpl $0x0, (%rax)
sete %al
orb %r12b, %al
je 0x1151c
leaq 0x2143e(%rip), %rax     # 0x32808
movq %rax, 0x2a227(%rip)     # 0x3b5f8
xorb $0x1, %r12b
movzbl %r12b, %eax
leal (%rax,%rax,4), %r14d
addl $0x3a, %r14d
jmp 0x11499
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x113f3
movl %r14d, (%rax)
movq 0x18(%rsp), %rsi
movl -0x18(%rsi), %eax
leal -0x1(%rax), %ecx
cmpl $0x1, %ecx
movl 0xc(%rsp), %ecx
ja 0x11478
cmpb $0x3d, (%r12,%rdx)
jne 0x1144a
addq %rdx, %r12
incq %r12
movq 0x29bd5(%rip), %rax     # 0x3aff0
movq %r12, (%rax)
jmp 0x11478
movq 0x29bd1(%rip), %rax     # 0x3aff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x21054(%rip), %rsi     # 0x32488
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9550
movq 0x2a1b3(%rip), %r15     # 0x3b5f8
jmp 0x11343
cmpl $0x1, %eax
jne 0x11478
decl %ecx
cmpl %r13d, %ecx
jle 0x1153f
movslq 0x8(%rsp), %rax
movq (%rbx,%rax,8), %rax
movq 0x29b86(%rip), %rcx     # 0x3aff0
movq %rax, (%rcx)
addl $0x2, %r13d
movl %r13d, 0x2a284(%rip)    # 0x3b6fc
movq -0x10(%rsi), %rax
movl -0x8(%rsi), %r14d
testq %rax, %rax
je 0x1148b
movl %r14d, (%rax)
xorl %r14d, %r14d
leaq 0x21376(%rip), %rax     # 0x32808
movq %rax, 0x2a15f(%rip)     # 0x3b5f8
movslq 0x2a25c(%rip), %rcx     # 0x3b6fc
movl 0x2a252(%rip), %edi     # 0x3b6f8
movl %ecx, %eax
movq 0x29ae1(%rip), %rdx     # 0x3af90
movslq (%rdx), %rsi
subl %edi, %eax
je 0x114e3
leaq -0x1(%rcx), %rdi
movl %eax, %r8d
movq -0x8(%rbx,%rcx,8), %r9
cmpl %esi, %edi
jle 0x114da
movq %rdi, %r10
movq -0x8(%rbx,%r10,8), %r11
movq %r11, (%rbx,%r10,8)
decq %r10
cmpq %rsi, %r10
jg 0x114c9
movq %r9, (%rbx,%rsi,8)
decl %r8d
jne 0x114bd
addl %eax, %esi
movl %esi, (%rdx)
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x29af8(%rip), %rax     # 0x3aff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x20f61(%rip), %rsi     # 0x3246e
movq %r12, %rcx
xorl %eax, %eax
callq 0x9550
jmp 0x112d0
movq 0x29ad5(%rip), %rax     # 0x3aff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x20f72(%rip), %rsi     # 0x324a2
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9550
jmp 0x113c3
movq 0x29a02(%rip), %rax     # 0x3af48
cmpl $0x0, (%rax)
sete %al
movq 0x10(%rsp), %r14
orb %r14b, %al
je 0x11571
leaq 0x212ab(%rip), %rax     # 0x32808
movq %rax, 0x2a094(%rip)     # 0x3b5f8
xorb $0x1, %r14b
movzbl %r14b, %eax
jmp 0x113d9
movq 0x29a80(%rip), %rax     # 0x3aff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x20ec2(%rip), %rsi     # 0x32447
movq %r12, %rcx
xorl %eax, %eax
callq 0x9550
jmp 0x11556
nopl (%rax)