// File: aalto-speech[P]ftk/util/conf.cc
// Function: conf::Config::parse_aux(std::deque<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, bool)
void
Config::parse_aux(std::deque<std::string> &argument_queue, bool override)
{
    bool options_allowed = true; // Have not seen "--" yet.
    std::deque<int> options_pending; // Options waiting for parameter

    while (!argument_queue.empty()) {
        std::string arg(argument_queue.front());
        argument_queue.pop_front();

        // Check if the argument is an option at all
        if (options_allowed && options_pending.empty() &&
                arg.length() > 1 && arg[0] == '-')
        {

            // End of options "--"
            if (arg == "--") {
                options_allowed = false;
                continue;
            }

            // Short option?
            if (arg[1] != '-') {

                // Parse grouped short options
                for (int c = 1; c < (int)arg.length(); c++) {

                    // Check if the option is valid
                    unsigned char short_name = arg[c];
                    ShortMap::iterator it = short_map.find(short_name);
                    if (it == short_map.end()) {
                        fprintf(stderr, "invalid option -%c\n", short_name);
                        exit(1);
                    }

                    Option &option = options[it->second];
                    if (option.needs_argument)
                        options_pending.push_back(it->second);
                    else
                        option.specified = true;
                }
            }

            // Long option?
            else {

                std::string long_name(arg.substr(2));
                std::string parameter;
                int equal_pos = long_name.find('=');
                if (equal_pos >= 0) {
                    parameter = long_name.substr(equal_pos + 1);
                    argument_queue.push_front(parameter);
                    long_name.erase(equal_pos);
                }
                LongMap::iterator it = long_map.find(long_name);
                if (it == long_map.end()) {
                    fprintf(stderr, "invalid option --%s\n", long_name.c_str());
                    exit(1);
                }

                Option &option = options[it->second];
                if (option.needs_argument)
                    options_pending.push_back(it->second);
                else
                    option.specified = true;
            }

        }

        // Otherwise just a parameter (possibly for a previous option)
        else {

            // Just an ordinary command line parameter
            if (options_pending.empty())
                arguments.push_back(arg);

            // Parameter for an option
            else {
                Option &option = options[options_pending.front()];
                options_pending.pop_front();
                if (!option.specified || override)
                    option.value = arg;
                option.specified = true;
            }
        }
    }

    // Check if the last option is missing arguments
    if (!options_pending.empty()) {
        std::string option_name;
        Option &option = options[options_pending.front()];
        if (option.short_name != 0) {
            option_name.append(" -");
            option_name.append(1, option.short_name);
        }
        if (option.long_name != "") {
            option_name.append(" --");
            option_name.append(option.long_name);
        }
        fprintf(stderr, "option%s lacks an argument\n", option_name.c_str());
        exit(1);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x170(%rbp)
movb $0x1, -0x12(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xa910
movq -0x10(%rbp), %rdi
callq 0xa930
xorb $-0x1, %al
testb $0x1, %al
jne 0x8fd6
jmp 0x9567
movq -0x10(%rbp), %rdi
callq 0xa960
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x41a0
jmp 0x8ff0
movq -0x10(%rbp), %rdi
callq 0xa990
testb $0x1, -0x12(%rbp)
je 0x9488
leaq -0x68(%rbp), %rdi
callq 0xaa00
testb $0x1, %al
jne 0x9015
jmp 0x9488
leaq -0x88(%rbp), %rdi
callq 0x45e0
cmpq $0x1, %rax
jbe 0x9488
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0x47f0
movq %rax, -0x178(%rbp)
jmp 0x9044
movq -0x178(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x9488
leaq 0x5d28c(%rip), %rsi     # 0x662ea
leaq -0x88(%rbp), %rdi
callq 0xa530
movb %al, -0x179(%rbp)
jmp 0x9072
movb -0x179(%rbp), %al
testb $0x1, %al
jne 0x907e
jmp 0x90bf
movb $0x0, -0x12(%rbp)
movl $0x2, -0x98(%rbp)
jmp 0x9534
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x96c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x9556
leaq -0x88(%rbp), %rdi
movl $0x1, %esi
callq 0x47f0
movq %rax, -0x188(%rbp)
jmp 0x90d9
movq -0x188(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x9259
movl $0x1, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movl %eax, -0x18c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x45e0
movq %rax, %rcx
movl -0x18c(%rbp), %eax
cmpl %ecx, %eax
jge 0x9254
movslq -0x9c(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0x47f0
movq %rax, -0x198(%rbp)
jmp 0x913b
movq -0x170(%rbp), %rdi
movq -0x198(%rbp), %rax
movb (%rax), %al
movb %al, -0x9d(%rbp)
addq $0x38, %rdi
leaq -0x9d(%rbp), %rsi
callq 0xa590
movq %rax, -0x1a0(%rbp)
jmp 0x916a
movq -0x170(%rbp), %rdi
movq -0x1a0(%rbp), %rax
movq %rax, -0xa8(%rbp)
addq $0x38, %rdi
callq 0xa5c0
movq %rax, -0xb0(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xaa30
testb $0x1, %al
jne 0x91a8
jmp 0x91d1
movq 0x8ae11(%rip), %rax     # 0x93fc0
movq (%rax), %rdi
movzbl -0x9d(%rbp), %edx
leaq 0x5d12d(%rip), %rsi     # 0x662ed
movb $0x0, %al
callq 0x4580
movl $0x1, %edi
callq 0x4470
movq -0x170(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x1a8(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xaa80
movq -0x1a8(%rbp), %rdi
movslq 0x4(%rax), %rsi
callq 0xaa60
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
testb $0x1, 0x49(%rax)
je 0x9233
leaq -0xa8(%rbp), %rdi
callq 0xaa80
movq %rax, %rsi
addq $0x4, %rsi
leaq -0x68(%rbp), %rdi
callq 0xaaa0
jmp 0x9231
jmp 0x923e
movq -0xb8(%rbp), %rax
movb $0x1, 0x4a(%rax)
jmp 0x9240
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x90f6
jmp 0x9483
leaq -0xd8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0x2, %edx
movq $-0x1, %rcx
callq 0x43e0
jmp 0x927a
leaq -0xf8(%rbp), %rdi
callq 0x4560
leaq -0xd8(%rbp), %rdi
movl $0x3d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4500
movl %eax, -0xfc(%rbp)
cmpl $0x0, -0xfc(%rbp)
jl 0x9361
movl -0xfc(%rbp), %eax
incl %eax
movslq %eax, %rdx
leaq -0x120(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movq $-0x1, %rcx
callq 0x43e0
jmp 0x92d5
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
leaq -0x120(%rbp), %rsi
movq %rsi, -0x1b8(%rbp)
callq 0x4480
movq -0x1b8(%rbp), %rdi
callq 0x4828
movq -0x1b0(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0xab00
jmp 0x9314
movslq -0xfc(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
movq $-0x1, %rdx
callq 0x40e0
jmp 0x9330
jmp 0x9361
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x4828
leaq -0xd8(%rbp), %rdi
callq 0x4828
jmp 0x9556
movq -0x170(%rbp), %rdi
addq $0x68, %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa760
movq %rax, -0x1c0(%rbp)
jmp 0x9381
movq -0x170(%rbp), %rdi
movq -0x1c0(%rbp), %rax
movq %rax, -0x128(%rbp)
addq $0x68, %rdi
callq 0xa790
movq %rax, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0xab60
testb $0x1, %al
jne 0x93bf
jmp 0x93fe
movq 0x8abfa(%rip), %rax     # 0x93fc0
movq (%rax), %rax
movq %rax, -0x1c8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4190
movq -0x1c8(%rbp), %rdi
movq %rax, %rdx
leaq 0x5cf14(%rip), %rsi     # 0x66301
movb $0x0, %al
callq 0x4580
movl $0x1, %edi
callq 0x4470
movq -0x170(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x1d0(%rbp)
leaq -0x128(%rbp), %rdi
callq 0xab90
movq -0x1d0(%rbp), %rdi
movslq 0x20(%rax), %rsi
callq 0xaa60
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
testb $0x1, 0x49(%rax)
je 0x9460
leaq -0x128(%rbp), %rdi
callq 0xab90
movq %rax, %rsi
addq $0x20, %rsi
leaq -0x68(%rbp), %rdi
callq 0xaaa0
jmp 0x945e
jmp 0x946b
movq -0x138(%rbp), %rax
movb $0x1, 0x4a(%rax)
leaq -0xf8(%rbp), %rdi
callq 0x4828
leaq -0xd8(%rbp), %rdi
callq 0x4828
jmp 0x952a
leaq -0x68(%rbp), %rdi
callq 0xaa00
testb $0x1, %al
jne 0x9497
jmp 0x94b5
movq -0x170(%rbp), %rdi
addq $0x98, %rdi
leaq -0x88(%rbp), %rsi
callq 0xabb0
jmp 0x94b3
jmp 0x9528
movq -0x170(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x1d8(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xac20
movq -0x1d8(%rbp), %rdi
movslq (%rax), %rsi
callq 0xaa60
movq %rax, -0x140(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xac50
movq -0x140(%rbp), %rax
testb $0x1, 0x4a(%rax)
je 0x9502
testb $0x1, -0x11(%rbp)
je 0x951d
movq -0x140(%rbp), %rdi
addq $0x28, %rdi
leaq -0x88(%rbp), %rsi
callq 0x4040
jmp 0x951b
jmp 0x951d
movq -0x140(%rbp), %rax
movb $0x1, 0x4a(%rax)
jmp 0x952a
movl $0x0, -0x98(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x4828
movl -0x98(%rbp), %eax
testl %eax, %eax
je 0x9551
jmp 0x954c
jmp 0x8fc2
jmp 0x8fc2
leaq -0x88(%rbp), %rdi
callq 0x4828
jmp 0x96c7
leaq -0x68(%rbp), %rdi
callq 0xaa00
testb $0x1, %al
jne 0x96b5
leaq -0x160(%rbp), %rdi
callq 0x4560
movq -0x170(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x1e0(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xac20
movq -0x1e0(%rbp), %rdi
movslq (%rax), %rsi
callq 0xaa60
movq %rax, -0x168(%rbp)
movq -0x168(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x961b
leaq 0x5cd4b(%rip), %rsi     # 0x66316
leaq -0x160(%rbp), %rdi
callq 0x4790
jmp 0x95d9
movq -0x168(%rbp), %rax
movsbl (%rax), %edx
leaq -0x160(%rbp), %rdi
movl $0x1, %esi
callq 0x4410
jmp 0x95f6
jmp 0x961b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x4828
jmp 0x96c7
movq -0x168(%rbp), %rdi
addq $0x8, %rdi
leaq 0x5ceca(%rip), %rsi     # 0x664f7
callq 0xa700
movb %al, -0x1e1(%rbp)
jmp 0x963a
movb -0x1e1(%rbp), %al
testb $0x1, %al
jne 0x9646
jmp 0x9676
leaq 0x5cc9c(%rip), %rsi     # 0x662e9
leaq -0x160(%rbp), %rdi
callq 0x4790
jmp 0x965b
movq -0x168(%rbp), %rsi
addq $0x8, %rsi
leaq -0x160(%rbp), %rdi
callq 0x47c0
jmp 0x9674
jmp 0x9676
movq 0x8a943(%rip), %rax     # 0x93fc0
movq (%rax), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x4190
movq -0x1f0(%rbp), %rdi
movq %rax, %rdx
leaq 0x5cc75(%rip), %rsi     # 0x66319
movb $0x0, %al
callq 0x4580
movl $0x1, %edi
callq 0x4470
leaq -0x68(%rbp), %rdi
callq 0xacc0
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0xacc0
movq -0x90(%rbp), %rdi
callq 0x46e0
nopl (%rax)