// File: jpcima[P]faustmd/main.cpp
// Function: do_cmdline(Cmd_Args&, int, char**)
static int do_cmdline(Cmd_Args &cmd, int argc, char *argv[])
{
    bool moreflags = true;
    unsigned extraindex = 0;

    for (int i = 1; i < argc; ++i) {
        gsl::string_span arg = argv[i];

        if (moreflags && arg == "--")
            moreflags = false;
        else if (moreflags && arg == "-I") {
            if (++i == argc) {
                errs() << "The flag `-I` requires an argument.\n";
                return -1;
            }
            cmd.faustargs.incdirs.push_back(argv[i]);
        }
        else if (moreflags && arg == "-cn") {
            if (++i == argc) {
                errs() << "The flag `-cn` requires an argument.\n";
                return -1;
            }
            cmd.faustargs.classname = argv[i];
        }
        else if (moreflags && arg == "-pn") {
            if (++i == argc) {
                errs() << "The flag `-pn` requires an argument.\n";
                return -1;
            }
            cmd.faustargs.processname = argv[i];
        }
        else if (moreflags && arg.subspan(0, 2) == "-X") {
            cmd.faustargs.miscargs.emplace_back(arg.begin() + 2, arg.end());
        }
        else if (moreflags && !arg.empty() && arg[0] == '-') {
            errs() << "Unrecognized flag `" << arg << "`\n";
            return -1;
        }
        else {
            switch (extraindex) {
            case 0:
                cmd.dspfile = gsl::to_string(arg);
                break;
            default:
                errs() << "Unrecognized positional argument `" << arg << "`\n";
                return -1;
            }
            ++extraindex;
        }
    }

    if (extraindex != 1) {
        errs() << "There must be exactly one positional argument.\n";
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movb $0x1, -0x21(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x84c0
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdi
callq 0x8ba0
testb $0x1, -0x21(%rbp)
je 0x7fee
leaq -0x40(%rbp), %rdi
leaq 0x5e0b8(%rip), %rsi     # 0x66092
callq 0x8be0
testb $0x1, %al
jne 0x7fe5
jmp 0x7fee
movb $0x0, -0x21(%rbp)
jmp 0x84b0
testb $0x1, -0x21(%rbp)
je 0x8118
leaq -0x40(%rbp), %rdi
leaq 0x5e092(%rip), %rsi     # 0x66095
callq 0x8be0
testb $0x1, %al
jne 0x8011
jmp 0x8118
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl -0x14(%rbp), %eax
jne 0x8073
leaq -0x41(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x86b0
movq -0xd8(%rbp), %rdi
leaq 0x5e05b(%rip), %rsi     # 0x66098
callq 0x8c80
jmp 0x8044
leaq -0x41(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x8720
jmp 0x8530
movq -0x10(%rbp), %rax
addq $0x60, %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe8(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x7a30
movq -0xe8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
leaq -0x78(%rbp), %rdi
callq 0x8cf0
jmp 0x80be
movq -0xf0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x8cc0
jmp 0x80d0
leaq -0x78(%rbp), %rdi
callq 0x7380
leaq -0x79(%rbp), %rdi
callq 0x75c0
jmp 0x84ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x810a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x7380
leaq -0x79(%rbp), %rdi
callq 0x75c0
jmp 0x8530
testb $0x1, -0x21(%rbp)
je 0x81bb
leaq -0x40(%rbp), %rdi
leaq 0x5df90(%rip), %rsi     # 0x660bd
callq 0x8da0
testb $0x1, %al
jne 0x813b
jmp 0x81bb
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl -0x14(%rbp), %eax
jne 0x819d
leaq -0x7a(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x86b0
movq -0xf8(%rbp), %rdi
leaq 0x5df5a(%rip), %rsi     # 0x660c1
callq 0x8750
jmp 0x816e
leaq -0x7a(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x7a(%rbp), %rdi
callq 0x8720
jmp 0x8530
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x77d0
jmp 0x84ac
testb $0x1, -0x21(%rbp)
je 0x8262
leaq -0x40(%rbp), %rdi
leaq 0x5df17(%rip), %rsi     # 0x660e7
callq 0x8da0
testb $0x1, %al
jne 0x81de
jmp 0x8262
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl -0x14(%rbp), %eax
jne 0x8240
leaq -0x7b(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x86b0
movq -0x100(%rbp), %rdi
leaq 0x5dee1(%rip), %rsi     # 0x660eb
callq 0x8750
jmp 0x8211
leaq -0x7b(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x7b(%rbp), %rdi
callq 0x8720
jmp 0x8530
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
addq $0x20, %rdi
callq 0x77d0
jmp 0x84aa
xorl %eax, %eax
testb $0x1, -0x21(%rbp)
movb %al, -0x101(%rbp)
je 0x82a9
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x8e40
movq %rax, -0x90(%rbp)
movq %rdx, -0x88(%rbp)
leaq -0x90(%rbp), %rdi
leaq 0x5de73(%rip), %rsi     # 0x66111
callq 0x8be0
movb %al, -0x101(%rbp)
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x82b5
jmp 0x830b
movq -0x10(%rbp), %rax
addq $0x20, %rax
addq $0x58, %rax
movq %rax, -0x110(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x8f10
addq $0x2, %rax
movq %rax, -0x98(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x8f30
movq -0x110(%rbp), %rdi
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x8e90
jmp 0x84a8
testb $0x1, -0x21(%rbp)
je 0x83d1
leaq -0x40(%rbp), %rdi
callq 0x8f50
testb $0x1, %al
jne 0x83d1
leaq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8f80
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x83d1
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x86b0
movq -0x120(%rbp), %rdi
leaq 0x5ddb4(%rip), %rsi     # 0x66114
callq 0x8fb0
movq %rax, -0x118(%rbp)
jmp 0x836e
movq -0x118(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x8ff0
movq %rax, -0x128(%rbp)
jmp 0x8387
movq -0x128(%rbp), %rdi
leaq 0x5dd93(%rip), %rsi     # 0x66128
callq 0x9030
jmp 0x839c
leaq -0xa1(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x8720
jmp 0x8530
movl -0x28(%rbp), %eax
testl %eax, %eax
jne 0x840b
jmp 0x83da
leaq -0xc8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9070
movq -0x10(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x76c0
leaq -0xc8(%rbp), %rdi
callq 0x7380
jmp 0x849d
leaq -0xc9(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x86b0
movq -0x138(%rbp), %rdi
leaq 0x5dcff(%rip), %rsi     # 0x6612b
callq 0x9100
movq %rax, -0x130(%rbp)
jmp 0x843a
movq -0x130(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x8ff0
movq %rax, -0x140(%rbp)
jmp 0x8453
movq -0x140(%rbp), %rdi
leaq 0x5dcc7(%rip), %rsi     # 0x66128
callq 0x9030
jmp 0x8468
leaq -0xc9(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc9(%rbp), %rdi
callq 0x8720
jmp 0x8530
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x84a8
jmp 0x84aa
jmp 0x84ac
jmp 0x84ae
jmp 0x84b0
jmp 0x84b2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x7fa8
cmpl $0x1, -0x28(%rbp)
je 0x851d
leaq -0xca(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x86b0
movq -0x148(%rbp), %rdi
leaq 0x5dc67(%rip), %rsi     # 0x6614e
callq 0x9140
jmp 0x84ee
leaq -0xca(%rbp), %rdi
callq 0x8720
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x8524
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xca(%rbp), %rdi
callq 0x8720
jmp 0x8530
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x7a20
nopl (%rax)