// File: misohena[P]drawstars/drawstars.cpp
// Function: parseCommandLine(Options&, int, char**)
bool parseCommandLine(Options &options, int argc, char *argv[])
{
    const Option *unresolvedOpt = nullptr;
    std::string_view unresolvedName;
    for(int ai = 1; ai < argc; ++ai){
        const char * const arg = argv[ai];
        if(unresolvedOpt){
            emitOption(options, unresolvedOpt, unresolvedName, std::string_view(arg));
            unresolvedOpt = nullptr;
            unresolvedName = "";
        }
        else if(arg[0] == '-'){
            const char *p = arg + 1;
            for(;!(*p == '=' || *p == '\0'); ++p);
            const std::string_view name = std::string_view(arg, p - arg);
            const Option * const opt = findOption(name);
            if(!opt){
                error("Unknown option %s", std::string(name).c_str());
                return false;
            }
            if(opt->needsValue()){
                if(*p == '='){
                    emitOption(options, opt, name, std::string_view(p+1));
                }
                else{
                    unresolvedOpt = opt;
                    unresolvedName = name;
                }
            }
            else{
                emitOption(options, opt, name, std::string_view());
            }
        }
        else{
            //files_.push_back(arg);
        }
    }
    return true;
}

// Assembly:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x158(%rsp)
movl %esi, 0x154(%rsp)
movq %rdx, 0x148(%rsp)
movq $0x0, 0x140(%rsp)
leaq 0x130(%rsp), %rdi
callq 0x10750
movl $0x1, 0x12c(%rsp)
movl 0x12c(%rsp), %eax
cmpl 0x154(%rsp), %eax
jge 0x9457
movq 0x148(%rsp), %rax
movslq 0x12c(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x120(%rsp)
cmpq $0x0, 0x140(%rsp)
je 0x9164
movq 0x158(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x130(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x120(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0xfad0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x110(%rsp), %rdx
movq 0x118(%rsp), %rcx
movq 0x100(%rsp), %r8
movq 0x108(%rsp), %r9
callq 0x8e00
movq $0x0, 0x140(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0x15340(%rip), %rsi     # 0x1e47a
callq 0xfad0
movq 0xf0(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x138(%rsp)
jmp 0x943f
movq 0x120(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x943b
movq 0x120(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x3d, %ecx
movb %al, 0x37(%rsp)
je 0x91b7
movq 0xe8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
sete %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x91c3
jmp 0x91db
jmp 0x91c5
movq 0xe8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xe8(%rsp)
jmp 0x918c
movq 0x120(%rsp), %rsi
movq 0xe8(%rsp), %rdx
movq 0x120(%rsp), %rax
subq %rax, %rdx
leaq 0xd8(%rsp), %rdi
callq 0x10770
movq 0xd8(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
callq 0x8cb0
movq %rax, 0xd0(%rsp)
cmpq $0x0, 0xd0(%rsp)
jne 0x930b
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x4600
movq 0x28(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0xf890
jmp 0x927d
leaq 0xa0(%rsp), %rdi
callq 0x4150
movq %rax, %rsi
leaq 0x15177(%rip), %rdi     # 0x1e40b
callq 0x107a0
jmp 0x929b
leaq 0xa0(%rsp), %rdi
callq 0x4240
leaq 0x9f(%rsp), %rdi
callq 0x43e0
movb $0x0, 0x167(%rsp)
jmp 0x945f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x92f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x4240
leaq 0x9f(%rsp), %rdi
callq 0x43e0
jmp 0x9470
movq 0xd0(%rsp), %rdi
callq 0x10800
testb $0x1, %al
jne 0x9321
jmp 0x93d8
movq 0xe8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x93a6
movq 0x158(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xe8(%rsp), %rsi
addq $0x1, %rsi
leaq 0x68(%rsp), %rdi
callq 0xfad0
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0x68(%rsp), %r8
movq 0x70(%rsp), %r9
callq 0x8e00
jmp 0x93d6
movq 0xd0(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x138(%rsp)
jmp 0x9439
movq 0x158(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x10750
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
movq 0x48(%rsp), %r8
movq 0x50(%rsp), %r9
callq 0x8e00
jmp 0x943d
jmp 0x943d
jmp 0x943f
jmp 0x9441
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0x9062
movb $0x1, 0x167(%rsp)
movb 0x167(%rsp), %al
andb $0x1, %al
addq $0x168, %rsp            # imm = 0x168
retq
movq 0x90(%rsp), %rdi
callq 0x45f0
nopl (%rax)