// File: aalto-speech[P]ftk/util/conf.cc
// Function: conf::Config::operator()(unsigned char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Config&
Config::operator()(unsigned char short_name, std::string long_name,
                   std::string type, std::string default_value,
                   std::string help)
{
    // Initialize new option
    Option o;
    o.short_name = short_name;
    o.long_name = long_name;
    o.value = default_value;
    o.required = false;
    o.needs_argument = false;
    o.help = help;

    // Remove the possible equal sign part from the long name used as
    // a map key.
    std::string long_name_map_key(long_name);
    int equal_pos = long_name_map_key.find('=');
    if (equal_pos >= 0)
        long_name_map_key.erase(equal_pos);

    // Parse the type string
    std::vector<std::string> types = str::split(type, " \t", true);
    for (int i = 0; i < (int)types.size(); i++) {
        if (types[i] == "arg")
            o.needs_argument = true;
        else if (types[i] == "must")
            o.required = true;
        else {
            fprintf(stderr, "invalid option type %s for option -%c --%s\n",
                    types[i].c_str(), short_name, long_name.c_str());
            abort();
        }
    }

    // Add structure to configuration
    if (short_name != 0) {
        if (short_map.find(short_name) != short_map.end()) {
            fprintf(stderr, "trying to add option -%c twice\n", short_name);
            exit(1);
        }
        short_map[short_name] = options.size();
        o.name.append("-");
        o.name.append(1, short_name);
    }
    if (long_name_map_key != "") {
        if (long_map.find(long_name_map_key) != long_map.end()) {
            fprintf(stderr, "trying to add option --%s twice\n",
                    long_name_map_key.c_str());
            exit(1);
        }
        long_map[long_name_map_key] = options.size();
        if ((int)long_name.length() > longest_name_length)
            longest_name_length = long_name.length();
        if (o.name.length() > 0)
            o.name.append(" --");
        else
            o.name.append("--");
        o.name.append(long_name_map_key);
    }
    options.push_back(o);

    return *this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %r9, -0x160(%rbp)
movq %r8, -0x158(%rbp)
movq %rcx, -0x150(%rbp)
movq %rdx, -0x140(%rbp)
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xa180
movq -0x140(%rbp), %rsi
movb -0x9(%rbp), %al
movb %al, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4040
jmp 0x8a56
movq -0x158(%rbp), %rsi
leaq -0x98(%rbp), %rdi
callq 0x4040
jmp 0x8a6b
movq -0x160(%rbp), %rsi
movb $0x0, -0x78(%rbp)
movb $0x0, -0x77(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4040
jmp 0x8a85
movq -0x140(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x41a0
jmp 0x8a9a
leaq -0xf0(%rbp), %rdi
movl $0x3d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4500
movl %eax, -0xf4(%rbp)
cmpl $0x0, -0xf4(%rbp)
jl 0x8b0a
movslq -0xf4(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
movq $-0x1, %rdx
callq 0x40e0
jmp 0x8ada
jmp 0x8b0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x8f70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
jmp 0x8f64
movq -0x150(%rbp), %rsi
leaq 0x5d758(%rip), %rdx     # 0x66270
leaq -0x110(%rbp), %rdi
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0xa1e0
jmp 0x8b2e
movl $0x0, -0x114(%rbp)
movl -0x114(%rbp), %eax
movl %eax, -0x164(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x5f70
movq %rax, %rcx
movl -0x164(%rbp), %eax
cmpl %ecx, %eax
jge 0x8c8a
movslq -0x114(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5f90
movq %rax, %rdi
leaq 0x5d6f5(%rip), %rsi     # 0x66273
callq 0xa530
movb %al, -0x165(%rbp)
jmp 0x8b8b
movb -0x165(%rbp), %al
testb $0x1, %al
jne 0x8b97
jmp 0x8bc3
movb $0x1, -0x77(%rbp)
jmp 0x8c74
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc8(%rbp)
movl %eax, -0xcc(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x6970
jmp 0x8f64
movslq -0x114(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5f90
movq %rax, %rdi
leaq 0x5d697(%rip), %rsi     # 0x66277
callq 0xa530
movb %al, -0x166(%rbp)
jmp 0x8bed
movb -0x166(%rbp), %al
testb $0x1, %al
jne 0x8bf9
jmp 0x8bff
movb $0x1, -0x78(%rbp)
jmp 0x8c72
movq 0x8b3ba(%rip), %rax     # 0x93fc0
movq (%rax), %rax
movq %rax, -0x180(%rbp)
movslq -0x114(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x5f90
movq %rax, %rdi
callq 0x4190
movq -0x140(%rbp), %rdi
movq %rax, -0x178(%rbp)
movzbl -0x9(%rbp), %eax
movl %eax, -0x16c(%rbp)
callq 0x4190
movq -0x180(%rbp), %rdi
movq -0x178(%rbp), %rdx
movl -0x16c(%rbp), %ecx
movq %rax, %r8
leaq 0x5d616(%rip), %rsi     # 0x6627c
movb $0x0, %al
callq 0x4580
callq 0x4220
jmp 0x8c74
jmp 0x8c76
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x8b38
movzbl -0x9(%rbp), %eax
cmpl $0x0, %eax
je 0x8d82
movq -0x148(%rbp), %rdi
addq $0x38, %rdi
leaq -0x9(%rbp), %rsi
callq 0xa590
movq %rax, -0x188(%rbp)
jmp 0x8cb4
movq -0x148(%rbp), %rdi
movq -0x188(%rbp), %rax
movq %rax, -0x120(%rbp)
addq $0x38, %rdi
callq 0xa5c0
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0xa560
testb $0x1, %al
jne 0x8cf2
jmp 0x8d18
movq 0x8b2c7(%rip), %rax     # 0x93fc0
movq (%rax), %rdi
movzbl -0x9(%rbp), %edx
leaq 0x5d5a1(%rip), %rsi     # 0x662a8
movb $0x0, %al
callq 0x4580
movl $0x1, %edi
callq 0x4470
movq -0x148(%rbp), %rdi
addq $0x20, %rdi
callq 0xa5f0
movq -0x148(%rbp), %rdi
movl %eax, -0x194(%rbp)
addq $0x38, %rdi
leaq -0x9(%rbp), %rsi
callq 0xa620
movq %rax, -0x190(%rbp)
jmp 0x8d4b
movq -0x190(%rbp), %rax
movl -0x194(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x50(%rbp), %rdi
leaq 0x5d5b2(%rip), %rsi     # 0x66317
callq 0x4790
jmp 0x8d6c
leaq -0x50(%rbp), %rdi
movsbl -0x9(%rbp), %edx
movl $0x1, %esi
callq 0x4410
jmp 0x8d80
jmp 0x8d82
leaq 0x5d76e(%rip), %rsi     # 0x664f7
leaq -0xf0(%rbp), %rdi
callq 0xa700
movb %al, -0x195(%rbp)
jmp 0x8d9d
movb -0x195(%rbp), %al
testb $0x1, %al
jne 0x8dac
jmp 0x8f17
movq -0x148(%rbp), %rdi
addq $0x68, %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa760
movq %rax, -0x1a0(%rbp)
jmp 0x8dcc
movq -0x148(%rbp), %rdi
movq -0x1a0(%rbp), %rax
movq %rax, -0x130(%rbp)
addq $0x68, %rdi
callq 0xa790
movq %rax, -0x138(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xa730
testb $0x1, %al
jne 0x8e0a
jmp 0x8e49
movq 0x8b1af(%rip), %rax     # 0x93fc0
movq (%rax), %rax
movq %rax, -0x1a8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x4190
movq -0x1a8(%rbp), %rdi
movq %rax, %rdx
leaq 0x5d490(%rip), %rsi     # 0x662c8
movb $0x0, %al
callq 0x4580
movl $0x1, %edi
callq 0x4470
movq -0x148(%rbp), %rdi
addq $0x20, %rdi
callq 0xa5f0
movq -0x148(%rbp), %rdi
movl %eax, -0x1b4(%rbp)
addq $0x68, %rdi
leaq -0xf0(%rbp), %rsi
callq 0xa7c0
movq %rax, -0x1b0(%rbp)
jmp 0x8e7f
movq -0x140(%rbp), %rdi
movq -0x1b0(%rbp), %rax
movl -0x1b4(%rbp), %ecx
movl %ecx, (%rax)
callq 0x45e0
movq -0x148(%rbp), %rcx
cmpl 0xb0(%rcx), %eax
jle 0x8ec5
movq -0x140(%rbp), %rdi
callq 0x45e0
movq %rax, %rcx
movq -0x148(%rbp), %rax
movl %ecx, 0xb0(%rax)
leaq -0xc0(%rbp), %rdi
addq $0x70, %rdi
callq 0x45e0
cmpq $0x0, %rax
jbe 0x8eef
leaq -0x50(%rbp), %rdi
leaq 0x5d403(%rip), %rsi     # 0x662e9
callq 0x4790
jmp 0x8eed
jmp 0x8f03
leaq -0x50(%rbp), %rdi
leaq 0x5d3f0(%rip), %rsi     # 0x662ea
callq 0x4790
jmp 0x8f01
jmp 0x8f03
leaq -0x50(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x47c0
jmp 0x8f15
jmp 0x8f17
movq -0x148(%rbp), %rdi
addq $0x20, %rdi
leaq -0xc0(%rbp), %rsi
callq 0xa8a0
jmp 0x8f30
leaq -0x110(%rbp), %rdi
callq 0x6970
leaq -0xf0(%rbp), %rdi
callq 0x4828
leaq -0xc0(%rbp), %rdi
callq 0x7440
movq -0x148(%rbp), %rax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0xf0(%rbp), %rdi
callq 0x4828
leaq -0xc0(%rbp), %rdi
callq 0x7440
movq -0xc8(%rbp), %rdi
callq 0x46e0
nopl (%rax,%rax)