// File: /workspace/github_cpp_makefile_star2_O3/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
movslq 0x424a(%rip), %r13      # 0xb2c8
movl 0x423b(%rip), %r15d     # 0xb2c0
movslq %r15d, %rcx
cmpq $0x1, %r13
jne 0x70d5
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl %edi, %r15d
jge 0x7280
movq (%rsi,%rcx,8), %r12
cmpb $0x2d, (%r12)
jne 0x7280
movzbl 0x1(%r12), %eax
testl %eax, %eax
je 0x7280
cmpl $0x2d, %eax
jne 0x70d9
cmpb $0x0, 0x2(%r12)
jne 0x70d9
incl %r15d
movl %r15d, 0x41f0(%rip)     # 0xb2c0
jmp 0x7280
movq (%rsi,%rcx,8), %r12
movsbl (%r12,%r13), %ebx
movl %ebx, 0x42b0(%rip)      # 0xb394
cmpl $0x3a, %ebx
je 0x713c
movl %edi, 0x4(%rsp)
movq %rdx, %rdi
movq %rsi, %rbp
movl %ebx, %esi
movl %ebx, %r14d
movq %rcx, %rbx
callq 0x30d0
movq %rbx, %rdx
movl %r14d, %ebx
movl 0x4(%rsp), %ecx
movq %rbp, %rsi
testq %rax, %rax
je 0x713c
cmpb $0x3a, 0x1(%rax)
jne 0x7228
addq %r13, %r12
leal 0x1(%rdx), %eax
cmpb $0x0, 0x1(%r12)
movl %eax, 0x4192(%rip)      # 0xb2c0
je 0x725b
incq %r12
jmp 0x726f
cmpl $0x0, 0x4181(%rip)      # 0xb2c4
je 0x7202
movq %rsi, %r14
movq (%rsi), %r15
testq %r15, %r15
je 0x7170
movq %r15, %rdi
callq 0x3110
movq 0x3e8d(%rip), %rdi      # 0xaff0
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
jmp 0x718e
movq 0x3e79(%rip), %rax      # 0xaff0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x3420
leaq 0x413b(%rip), %r15      # 0xb2d0
movq %r15, %rdi
callq 0x3110
movq 0x3e4c(%rip), %r12      # 0xaff0
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
leaq 0x2(%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
movslq 0x40c9(%rip), %r15      # 0xb2c0
movq (%r14,%r15,8), %r12
movl 0x40c6(%rip), %r13d     # 0xb2c8
movslq %r13d, %rax
leaq 0x1(%rax), %rcx
movl %ecx, 0x40b9(%rip)      # 0xb2c8
movl $0x3f, %ebx
cmpb $0x0, 0x1(%r12,%rax)
jne 0x7280
incl %r15d
movl %r15d, 0x409a(%rip)     # 0xb2c0
jmp 0x7276
leaq 0x1(%r13), %rax
movl %eax, 0x4096(%rip)      # 0xb2c8
cmpb $0x0, 0x1(%r12,%r13)
jne 0x724e
movl $0x1, 0x4084(%rip)      # 0xb2c8
incl %r15d
movl %r15d, 0x4072(%rip)     # 0xb2c0
movq $0x0, 0x413f(%rip) # 0xb398
jmp 0x7280
cmpl %ecx, %eax
jge 0x7291
addl $0x2, %r15d
movl %r15d, 0x4056(%rip)     # 0xb2c0
movq 0x8(%rsi,%rdx,8), %r12
movq %r12, 0x4122(%rip)      # 0xb398
movl $0x1, 0x4048(%rip)      # 0xb2c8
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, 0x402c(%rip)      # 0xb2c4
je 0x72e5
movq (%rsi), %rsi
movq 0x3d4c(%rip), %rdi      # 0xaff0
callq 0x32c0
movq %rax, %r14
leaq 0x403d(%rip), %r15      # 0xb2f0
movq %r15, %rdi
callq 0x3110
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x3330
leaq 0x3(%rsp), %rsi
movb %bl, (%rsi)
movl $0x1, %edx
movq %r14, %rdi
callq 0x3330
movq %rax, %rdi
callq 0x3120
movl $0x1, 0x3fd9(%rip)      # 0xb2c8
movl $0x3f, %ebx
jmp 0x7280