// File: /workspace/github_cpp_makefile_star2_O2/princelab[P]emass/getopt.cpp
// Function: getopt(int, char**, char const*)
int getopt(int argc, char *argv[], const char *opts) {

    static int sp = 1;      // initialize and preserve from call to call

    if (sp == 1) {
        if ( 
               optind >= argc              // end of argv array
               || argv[optind][0] != '-'   // not an option
               || argv[optind][1] == '\0'  // - followed by whitespace
            )
            return -1;                     // argument processing done
        else if (strcmp(argv[optind], "--") == 0) {
            optind++;       // -- is end of options flag, go to next argv
            return -1;
        }
    }

    char c = (unsigned char) argv[optind][sp];   // char after -
    optopt = c;
    const char *cp;
    if (c == ':' || (cp = strchr(opts, c)) == NULL) {
        if (opterr) {
            cerr << argv[0] << error2 << c << endl;
        }
        if (argv[optind][++sp] == '\0') {
            optind++;
            sp = 1;
        }
        return '?';         // conventional return value for unknown option
    }

    if (*++cp == ':') {     // option which requires a value to follow
        if (argv[optind][sp+1] != '\0')    // value follows without whitespace
            optarg = &argv[optind++][sp+1];
        else if (++optind >= argc) {
            if (opterr) {
                cerr << argv[0] << error1 << c << endl;
            }
            sp = 1;
            return '?';
        } else
            optarg = argv[optind++];    // set next argv as option value
        sp = 1;
    } else {                // option which requires no value
        if (argv[optind][++sp] == '\0') {
            sp = 1;
            optind++;
        }
        optarg = NULL;      // set null pointer as option value
    }
    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movslq 0x4723(%rip), %r13      # 0xb298
movl 0x4714(%rip), %r15d     # 0xb290
movslq %r15d, %rbp
cmpq $0x1, %r13
jne 0x6bca
pushq $-0x1
popq %rbx
cmpl %edi, %r15d
jge 0x6ce9
movq (%r14,%rbp,8), %r12
cmpb $0x2d, (%r12)
jne 0x6ce9
movzbl 0x1(%r12), %eax
testl %eax, %eax
je 0x6ce9
cmpl $0x2d, %eax
jne 0x6bce
cmpb $0x0, 0x2(%r12)
jne 0x6bce
incl %r15d
movl %r15d, 0x46cb(%rip)     # 0xb290
jmp 0x6ce9
movq (%r14,%rbp,8), %r12
movsbl (%r12,%r13), %ebx
movl %ebx, 0x478b(%rip)      # 0xb364
cmpl $0x3a, %ebx
je 0x6c25
movq %r14, (%rsp)
movl %edi, %r14d
movq %rdx, %rdi
movl %ebx, %esi
callq 0x30b0
movl %r14d, %ecx
movq (%rsp), %r14
testq %rax, %rax
je 0x6c25
cmpb $0x3a, 0x1(%rax)
jne 0x6c94
addq %r13, %r12
leal 0x1(%rbp), %eax
cmpb $0x0, 0x1(%r12)
movl %eax, 0x4679(%rip)      # 0xb290
je 0x6cc4
incq %r12
jmp 0x6cd8
cmpl $0x0, 0x4668(%rip)      # 0xb294
je 0x6c70
movq (%r14), %rsi
movq 0x43b8(%rip), %rdi      # 0xaff0
callq 0x3280
leaq 0x465c(%rip), %rsi      # 0xb2a0
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movl %ebx, %esi
callq 0x32f0
movq %rax, %rdi
callq 0x3100
movslq 0x462b(%rip), %r15      # 0xb290
movq (%r14,%r15,8), %r12
movl 0x4628(%rip), %r13d     # 0xb298
movslq %r13d, %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x461b(%rip)      # 0xb298
pushq $0x3f
popq %rbx
cmpb $0x0, 0x1(%r12,%rax)
jne 0x6ce9
incl %r15d
movl %r15d, 0x45fe(%rip)     # 0xb290
jmp 0x6cdf
leaq 0x1(%r13), %rax
movl %eax, 0x45fa(%rip)      # 0xb298
cmpb $0x0, 0x1(%r12,%r13)
jne 0x6cba
movl $0x1, 0x45e8(%rip)      # 0xb298
incl %r15d
movl %r15d, 0x45d6(%rip)     # 0xb290
andq $0x0, 0x46a6(%rip)      # 0xb368
jmp 0x6ce9
cmpl %ecx, %eax
jge 0x6cfa
addl $0x2, %r15d
movl %r15d, 0x45bd(%rip)     # 0xb290
movq 0x8(%r14,%rbp,8), %r12
movq %r12, 0x4689(%rip)      # 0xb368
movl $0x1, 0x45af(%rip)      # 0xb298
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x4593(%rip)      # 0xb294
je 0x6d33
movq (%r14), %rsi
movq 0x42e3(%rip), %rdi      # 0xaff0
callq 0x3280
leaq 0x45a7(%rip), %rsi      # 0xb2c0
movq %rax, %rdi
callq 0x3280
movq %rax, %rdi
movl %ebx, %esi
callq 0x32f0
movq %rax, %rdi
callq 0x3100
movl $0x1, 0x455b(%rip)      # 0xb298
pushq $0x3f
popq %rbx
jmp 0x6ce9