// File: /workspace/github_cpp_makefile_star2_O1/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 %rdx, %r15
movl %edi, %ebp
movslq 0x4325(%rip), %r12      # 0xb2c8
cmpq $0x1, %r12
jne 0x6fef
movslq 0x4310(%rip), %r14      # 0xb2c0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl %ebp, %r14d
jge 0x718a
movq (%rsi,%r14,8), %rdi
cmpb $0x2d, (%rdi)
jne 0x718a
cmpb $0x0, 0x1(%rdi)
je 0x718a
movq %rsi, %r13
leaq 0x1417(%rip), %rsi      # 0x83f6
callq 0x33a0
movq %r13, %rsi
testl %eax, %eax
je 0x719b
movslq 0x42ca(%rip), %r13      # 0xb2c0
movq (%rsi,%r13,8), %r14
movsbl (%r14,%r12), %ebx
movl %ebx, 0x438f(%rip)      # 0xb394
cmpl $0x3a, %ebx
je 0x7049
movq %r15, %rdi
movq %rsi, %r15
movl %ebx, %esi
callq 0x30d0
movq %r15, %rsi
testq %rax, %rax
je 0x7049
cmpb $0x3a, 0x1(%rax)
jne 0x7132
addq %r12, %r14
leal 0x1(%r13), %eax
cmpb $0x0, 0x1(%r14)
movl %eax, 0x4285(%rip)      # 0xb2c0
je 0x7166
incq %r14
jmp 0x7179
cmpl $0x0, 0x4274(%rip)      # 0xb2c4
je 0x7100
movq %rsi, %r14
movq (%rsi), %r15
testq %r15, %r15
je 0x707d
movq %r15, %rdi
callq 0x3110
movq 0x3f80(%rip), %rdi      # 0xaff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
jmp 0x709b
movq 0x3f6c(%rip), %rax      # 0xaff0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x3430
leaq 0x422e(%rip), %r15      # 0xb2d0
movq %r15, %rdi
callq 0x3110
movq 0x3f3f(%rip), %r12      # 0xaff0
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
leaq 0x6(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %r12, %rdi
callq 0x3330
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31a0
movq %r14, %rsi
movslq 0x41b9(%rip), %rax      # 0xb2c0
movq (%rsi,%rax,8), %rcx
movslq 0x41b6(%rip), %rdx      # 0xb2c8
leaq 0x1(%rdx), %rsi
movl %esi, 0x41ac(%rip)      # 0xb2c8
movl $0x3f, %ebx
cmpb $0x0, 0x1(%rcx,%rdx)
jne 0x718a
incl %eax
movl %eax, 0x4190(%rip)      # 0xb2c0
jmp 0x7180
leaq 0x1(%r12), %rax
movl %eax, 0x418b(%rip)      # 0xb2c8
cmpb $0x0, 0x1(%r14,%r12)
jne 0x7159
movl $0x1, 0x4179(%rip)      # 0xb2c8
incl %r13d
movl %r13d, 0x4167(%rip)     # 0xb2c0
movq $0x0, 0x4234(%rip) # 0xb398
jmp 0x718a
cmpl %ebp, %eax
jge 0x71a7
leal 0x2(%r13), %eax
movl %eax, 0x414c(%rip)      # 0xb2c0
movq 0x8(%rsi,%r13,8), %r14
movq %r14, 0x4218(%rip)      # 0xb398
movl $0x1, 0x413e(%rip)      # 0xb2c8
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %r14d
movl %r14d, 0x411b(%rip)     # 0xb2c0
jmp 0x718a
cmpl $0x0, 0x4116(%rip)      # 0xb2c4
je 0x71fb
movq (%rsi), %rsi
movq 0x3e36(%rip), %rdi      # 0xaff0
callq 0x32c0
movq %rax, %r14
leaq 0x4127(%rip), %r15      # 0xb2f0
movq %r15, %rdi
callq 0x3110
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
leaq 0x7(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0x3330
movq %rax, %rdi
callq 0x3120
movl $0x1, 0x40c3(%rip)      # 0xb2c8
movl $0x3f, %ebx
jmp 0x718a