// File: /workspace/github_c_makefile_star2_O1/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
testq %rdx, %rdx
je 0x11085
cmpb $0x3a, (%rdx)
sete %r13b
jmp 0x11088
xorl %r13d, %r13d
movq 0x2aea1(%rip), %rax     # 0x3bf30
cmpl $0x0, (%rax)
je 0x110ec
movl $0x0, (%rax)
movq 0x2aeef(%rip), %rax     # 0x3bf90
movl (%rax), %r12d
cmpl %ebp, %r12d
jge 0x110d3
movslq %r12d, %rsi
movl %r12d, 0x2b645(%rip)    # 0x3c6f8
leaq (%rbx,%rsi,8), %rsi
movq (%rsi), %r15
cmpb $0x2d, (%r15)
je 0x110fe
incl %r12d
movl %r12d, 0x2b62e(%rip)    # 0x3c6f8
addq $0x8, %rsi
cmpl %r12d, %ebp
jne 0x110b7
leaq 0x2272e(%rip), %rax     # 0x33808
movq %rax, 0x2b517(%rip)     # 0x3c5f8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x1131d
movq 0x2b505(%rip), %rsi     # 0x3c5f8
cmpb $0x0, (%rsi)
jne 0x11207
jmp 0x11094
leaq 0x1(%r15), %rsi
movq %rsi, 0x2b4ef(%rip)     # 0x3c5f8
leal 0x1(%r12), %edi
movl %edi, 0x2b5e8(%rip)     # 0x3c6fc
movq 0x2aed5(%rip), %rsi     # 0x3bff0
movq $0x0, (%rsi)
movb 0x1(%r15), %sil
cmpb $0x2d, %sil
jne 0x11207
cmpb $0x0, 0x2(%r15)
je 0x1132f
cmpb $0x2d, %sil
jne 0x11207
cmpb $0x0, 0x2(%r15)
je 0x11207
movl %edi, 0xc(%rsp)
movq %r8, 0x20(%rsp)
movl %r13d, 0x8(%rsp)
addq $0x2, %r15
movq %r15, 0x2b48f(%rip)     # 0x3c5f8
leaq 0x222c5(%rip), %rsi     # 0x33435
movq %r15, %rdi
movq %rcx, %r14
callq 0x9460
movq (%r14), %r13
testq %r13, %r13
je 0x111d5
movq %r14, %rcx
addq $0x20, %rcx
xorl %r14d, %r14d
movq %rax, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movq %r13, %rdi
callq 0x9310
movq 0x10(%rsp), %rdx
cmpq %rdx, %rax
jne 0x111c1
movq %r15, %rdi
movq %r13, %rsi
callq 0x90e0
movq 0x10(%rsp), %rdx
testl %eax, %eax
je 0x113a3
movq 0x18(%rsp), %rcx
movq (%rcx), %r13
incl %r14d
addq $0x20, %rcx
testq %r13, %r13
jne 0x11192
movq 0x2ad6c(%rip), %rax     # 0x3bf48
cmpl $0x0, (%rax)
sete %al
movl 0x8(%rsp), %ecx
orb %al, %cl
je 0x11447
leaq 0x22613(%rip), %rax     # 0x33808
movq %rax, 0x2b3fc(%rip)     # 0x3c5f8
movl $0x3f, %r14d
jmp 0x112c8
movzbl %r13b, %eax
addq %rax, %rdx
movq 0x2b3e3(%rip), %rax     # 0x3c5f8
leaq 0x1(%rax), %r15
movq %r15, 0x2b3d8(%rip)     # 0x3c5f8
movsbl (%rax), %r14d
movq 0x2ad75(%rip), %rax     # 0x3bfa0
movl %r14d, (%rax)
movq %rdx, %rdi
movl %r14d, %esi
callq 0x9370
testq %rax, %rax
je 0x11257
cmpb $0x3a, 0x1(%rax)
movb (%r15), %al
jne 0x11285
testb %al, %al
je 0x1128f
movq 0x2ad9e(%rip), %rax     # 0x3bff0
movq %r15, (%rax)
jmp 0x112ba
movq 0x2acea(%rip), %rax     # 0x3bf48
cmpl $0x0, (%rax)
sete %al
orb %al, %r13b
je 0x11380
movq 0x2b384(%rip), %rax     # 0x3c5f8
movl $0x3f, %r14d
cmpb $0x0, (%rax)
jne 0x1131d
jmp 0x112ba
testb %al, %al
jne 0x1131d
jmp 0x112ba
decl %ebp
cmpl %ebp, 0x2b461(%rip)     # 0x3c6f8
jge 0x11347
movslq 0x2b458(%rip), %rax     # 0x3c6fc
movq (%rbx,%rax,8), %rcx
movq 0x2ad41(%rip), %rdx     # 0x3bff0
movq %rcx, (%rdx)
incl %eax
movl %eax, 0x2b442(%rip)     # 0x3c6fc
leaq 0x22547(%rip), %rax     # 0x33808
movq %rax, 0x2b330(%rip)     # 0x3c5f8
movslq 0x2b42d(%rip), %rax     # 0x3c6fc
movl 0x2b423(%rip), %edx     # 0x3c6f8
movl %eax, %ecx
subl %edx, %ecx
je 0x11314
leal -0x1(%rax), %edx
movq 0x2acab(%rip), %rsi     # 0x3bf90
movslq (%rsi), %rsi
movslq %edx, %rdi
movl %ecx, %r8d
movq -0x8(%rbx,%rax,8), %r9
cmpl %esi, %edx
jle 0x1130b
movq %rdi, %r10
movq -0x8(%rbx,%r10,8), %r11
movq %r11, (%rbx,%r10,8)
decq %r10
cmpq %rsi, %r10
jg 0x112fa
movq %r9, (%rbx,%rsi,8)
decl %r8d
jne 0x112ee
movq 0x2ac75(%rip), %rax     # 0x3bf90
addl %ecx, (%rax)
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, (%rax)
leaq 0x224d0(%rip), %rax     # 0x33808
movq %rax, 0x2b2b9(%rip)     # 0x3c5f8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x112c8
movq 0x2abfa(%rip), %rax     # 0x3bf48
cmpl $0x0, (%rax)
sete %al
orb %r13b, %al
je 0x113de
leaq 0x224a4(%rip), %rax     # 0x33808
movq %rax, 0x2b28d(%rip)     # 0x3c5f8
xorb $0x1, %r13b
movzbl %r13b, %eax
leal (%rax,%rax,4), %r14d
addl $0x3a, %r14d
jmp 0x112c8
movq 0x2ac71(%rip), %rax     # 0x3bff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x220e4(%rip), %rsi     # 0x33478
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9550
jmp 0x1126d
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x113b0
movl %r14d, (%rax)
movq 0x18(%rsp), %rsi
movl -0x18(%rsi), %eax
leal -0x1(%rax), %ecx
cmpl $0x1, %ecx
movl 0x8(%rsp), %r14d
ja 0x1142b
cmpb $0x3d, (%r15,%rdx)
jne 0x11401
addq %rdx, %r15
incq %r15
movq 0x2ac17(%rip), %rax     # 0x3bff0
movq %r15, (%rax)
jmp 0x1142b
movq 0x2ac13(%rip), %rax     # 0x3bff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x220a0(%rip), %rsi     # 0x33492
movl %r14d, %ecx
xorl %eax, %eax
callq 0x9550
jmp 0x1135d
cmpl $0x1, %eax
jne 0x1142b
decl %ebp
cmpl %r12d, %ebp
jle 0x1146a
movslq 0xc(%rsp), %rax
movq (%rbx,%rax,8), %rax
movq 0x2abd3(%rip), %rcx     # 0x3bff0
movq %rax, (%rcx)
addl $0x2, %r12d
movl %r12d, 0x2b2d1(%rip)    # 0x3c6fc
movq -0x10(%rsi), %rax
movl -0x8(%rsi), %r14d
testq %rax, %rax
je 0x112ba
movl %r14d, (%rax)
xorl %r14d, %r14d
jmp 0x112ba
movq 0x2abaa(%rip), %rax     # 0x3bff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x22003(%rip), %rsi     # 0x3345e
movq %r15, %rcx
xorl %eax, %eax
callq 0x9550
jmp 0x111ee
movq 0x2aad7(%rip), %rax     # 0x3bf48
cmpl $0x0, (%rax)
sete %al
orb %r14b, %al
je 0x11497
leaq 0x22385(%rip), %rax     # 0x33808
movq %rax, 0x2b16e(%rip)     # 0x3c5f8
xorb $0x1, %r14b
movzbl %r14b, %eax
jmp 0x11373
movq 0x2ab5a(%rip), %rax     # 0x3bff8
movq (%rax), %rdi
movq (%rbx), %rdx
leaq 0x21f8c(%rip), %rsi     # 0x33437
movq %r15, %rcx
xorl %eax, %eax
callq 0x9550
jmp 0x1147c
nop