// File: mgo1977[P]c---parsing-argument-options/./Parser.h
// Function: Parser::usage(char const*)
void
Parser::usage(const char* text) {

    if ( strcmp(text, "") != 0 ) {
        std::cerr << text << std::endl;
    }

    // add the options
    std::cerr << "Usage: ";
    std::cerr << programName << " ";

    std::stringstream optionsSummary;
    std::stringstream fullDescription;

    int maxWidth = 30;


    for(std::vector<BaseOption*>::iterator iter = options.begin();
        iter != options.end();
        ++iter
    ) {

        BaseOption* option = *iter;

        // this is the syntax:
        //   [ ] => optional
        //   short|long
        std::string summaryOptionBase = getSummaryOptionText(option);
        std::string fullOptionBase    = getFullOptionText(option);

        if ( option->needArgument() ) {
            summaryOptionBase += " value";
            fullOptionBase    += " value";
        }

        // summary 
        if ( ! option->isMandatory() ) {
            optionsSummary << "[" << summaryOptionBase << "]";
        }
        else {
            optionsSummary << summaryOptionBase;
        }

        optionsSummary << " ";

        // full description
        fullDescription << " " << std::setw(maxWidth) << std::left << fullOptionBase << "\t\t" << option->getDescription() << std::endl;

    }

    std::cerr << optionsSummary.str() << std::endl;
    std::cerr << "Options:" << std::endl;
    std::cerr << fullDescription.str();

    // end
    exit(1);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7afc(%rip), %rsi      # 0xc0b5
callq 0x33b0
cmpl $0x0, %eax
je 0x45e2
movq -0x10(%rbp), %rsi
movq 0xda22(%rip), %rdi      # 0x11ff0
callq 0x3260
movq %rax, %rdi
movq 0xd9e3(%rip), %rsi      # 0x11fc0
callq 0x32a0
movq 0xda07(%rip), %rdi      # 0x11ff0
movq %rdi, -0x400(%rbp)
leaq 0x7aa9(%rip), %rsi      # 0xc0a0
callq 0x3260
movq -0x3f8(%rbp), %rsi
movq -0x400(%rbp), %rdi
addq $0x78, %rsi
callq 0x3230
movq %rax, %rdi
leaq 0x7a59(%rip), %rsi      # 0xc076
callq 0x3260
leaq -0x198(%rbp), %rdi
callq 0x31a0
leaq -0x320(%rbp), %rdi
callq 0x31a0
jmp 0x463c
movq -0x3f8(%rbp), %rdi
movl $0x1e, -0x330(%rbp)
addq $0x60, %rdi
callq 0x5850
movq %rax, -0x338(%rbp)
movq -0x3f8(%rbp), %rdi
addq $0x60, %rdi
callq 0x58c0
movq %rax, -0x340(%rbp)
leaq -0x338(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x5880
testb $0x1, %al
jne 0x4690
jmp 0x4984
leaq -0x338(%rbp), %rdi
callq 0x58f0
movq -0x3f8(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x348(%rbp)
movq -0x348(%rbp), %rdx
leaq -0x368(%rbp), %rdi
callq 0x5930
jmp 0x46c2
movq -0x3f8(%rbp), %rsi
movq -0x348(%rbp), %rdx
leaq -0x388(%rbp), %rdi
callq 0x5b00
jmp 0x46de
movq -0x348(%rbp), %rdi
callq 0x57f0
movb %al, -0x401(%rbp)
jmp 0x46f2
movb -0x401(%rbp), %al
testb $0x1, %al
jne 0x4701
jmp 0x4789
leaq 0x79a0(%rip), %rsi      # 0xc0a8
leaq -0x368(%rbp), %rdi
callq 0x3240
jmp 0x4716
leaq 0x798b(%rip), %rsi      # 0xc0a8
leaq -0x388(%rbp), %rdi
callq 0x3240
jmp 0x472b
jmp 0x4789
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x4a91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x4a85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x4973
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x4967
movq -0x348(%rbp), %rdi
callq 0x5910
movb %al, -0x402(%rbp)
jmp 0x479d
movb -0x402(%rbp), %al
testb $0x1, %al
jne 0x47f8
jmp 0x47a9
leaq -0x188(%rbp), %rdi
leaq 0x78f8(%rip), %rsi      # 0xc0af
callq 0x3260
movq %rax, -0x410(%rbp)
jmp 0x47c5
movq -0x410(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x3230
movq %rax, -0x418(%rbp)
jmp 0x47e1
movq -0x418(%rbp), %rdi
leaq 0x78c2(%rip), %rsi      # 0xc0b1
callq 0x3260
jmp 0x47f6
jmp 0x480f
leaq -0x188(%rbp), %rdi
leaq -0x368(%rbp), %rsi
callq 0x3230
jmp 0x480d
jmp 0x480f
leaq -0x188(%rbp), %rdi
leaq 0x7859(%rip), %rsi      # 0xc076
callq 0x3260
jmp 0x4824
leaq -0x310(%rbp), %rdi
leaq 0x7844(%rip), %rsi      # 0xc076
callq 0x3260
movq %rax, -0x420(%rbp)
jmp 0x4840
movl -0x330(%rbp), %edi
callq 0x5b40
movl %eax, -0x424(%rbp)
jmp 0x4853
movq -0x420(%rbp), %rdi
movl -0x424(%rbp), %eax
movl %eax, -0x38c(%rbp)
movl -0x38c(%rbp), %esi
callq 0x3300
movq %rax, -0x430(%rbp)
jmp 0x487a
movq -0x430(%rbp), %rdi
leaq 0x12d8(%rip), %rsi      # 0x5b60
callq 0x30a0
movq %rax, -0x438(%rbp)
jmp 0x4896
movq -0x438(%rbp), %rdi
leaq -0x388(%rbp), %rsi
callq 0x3230
movq %rax, -0x440(%rbp)
jmp 0x48b2
movq -0x440(%rbp), %rdi
leaq 0x77f3(%rip), %rsi      # 0xc0b3
callq 0x3260
movq %rax, -0x448(%rbp)
jmp 0x48ce
movq -0x348(%rbp), %rsi
leaq -0x3b0(%rbp), %rdi
callq 0x5b90
jmp 0x48e3
movq -0x448(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
callq 0x3230
movq %rax, -0x450(%rbp)
jmp 0x48ff
movq -0x450(%rbp), %rdi
movq 0xd6b3(%rip), %rsi      # 0x11fc0
callq 0x32a0
jmp 0x4914
leaq -0x3b0(%rbp), %rdi
callq 0x3160
leaq -0x388(%rbp), %rdi
callq 0x3160
leaq -0x368(%rbp), %rdi
callq 0x3160
leaq -0x338(%rbp), %rdi
callq 0x5970
jmp 0x465d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x3160
leaq -0x388(%rbp), %rdi
callq 0x3160
leaq -0x368(%rbp), %rdi
callq 0x3160
jmp 0x4a85
leaq -0x3d0(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x3250
jmp 0x4999
movq 0xd650(%rip), %rdi      # 0x11ff0
leaq -0x3d0(%rbp), %rsi
callq 0x3230
movq %rax, -0x458(%rbp)
jmp 0x49b5
movq -0x458(%rbp), %rdi
movq 0xd5fd(%rip), %rsi      # 0x11fc0
callq 0x32a0
jmp 0x49ca
leaq -0x3d0(%rbp), %rdi
callq 0x3160
movq 0xd613(%rip), %rdi      # 0x11ff0
leaq 0x76d2(%rip), %rsi      # 0xc0b6
callq 0x3260
movq %rax, -0x460(%rbp)
jmp 0x49f2
movq -0x460(%rbp), %rdi
movq 0xd5c0(%rip), %rsi      # 0x11fc0
callq 0x32a0
jmp 0x4a07
leaq -0x3f0(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x3250
jmp 0x4a1c
movq 0xd5cd(%rip), %rdi      # 0x11ff0
leaq -0x3f0(%rbp), %rsi
callq 0x3230
jmp 0x4a31
leaq -0x3f0(%rbp), %rdi
callq 0x3160
movl $0x1, %edi
callq 0x3310
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x3160
jmp 0x4a85
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3160
leaq -0x320(%rbp), %rdi
callq 0x31d0
leaq -0x198(%rbp), %rdi
callq 0x31d0
movq -0x328(%rbp), %rdi
callq 0x3480
nopl (%rax)