// File: /workspace/github_cpp_makefile_star2_O2/hanhwi[P]SimPoint/analysiscode/CmdLineParser.cpp
// Function: CmdLineParser::printExplanationPretty(CmdLineOption const*, unsigned int, std::ostream&, unsigned int)
void CmdLineParser::printExplanationPretty(const CmdLineOption *option,
        unsigned int prefixWidth, ostream &os, unsigned int lineWidth) {
    prefixWidth += 3;  // to account for the string " : " below
    string nameAndArg = prettyOptionNameAndArg(option);
    os << nameAndArg;
    if (nameAndArg.size() < prefixWidth - 3) { os << ' '; }
    for (unsigned int i = nameAndArg.size() + 1; i < prefixWidth - 3; i++) {
        os << '.';
    }
    os << " : ";

    // strip the explanation of leading, trailing, and duplicate spaces
    string expl, explanation = option->getExplanation();
    unsigned int start = 0, end = explanation.size() - 1;
    while ((start < end) && (explanation[start] == ' ')) { start++; }
    while ((start < end) && (explanation[end] == ' ')) { end--; }
    for (unsigned int i = start; i <= end; i++) {
        expl += explanation[i];
        if (explanation[i] == ' ') {
            while ((i <= end) && (explanation[i+1] == ' ')) {
                i++;
            }
        }
    }

    unsigned int position = 0;
    bool firstLine = true;
    while (expl.size() - position > lineWidth - prefixWidth) {
        if (! firstLine) {
            for (unsigned int i = 0; i < prefixWidth; i++) {
                os << ' ';
            }
        }

        // find the first index of a space that is earlier than the limit of the
        // line width
        unsigned long searchStart = min((unsigned long)position + lineWidth - prefixWidth, 
                                        (unsigned long)expl.size() - 1);
        unsigned long spaceNdx = expl.rfind(' ', searchStart);
        if ((spaceNdx == string::npos) || (spaceNdx <= position)) {
            spaceNdx = expl.find(' ', searchStart);
            if (spaceNdx == string::npos) {
                spaceNdx = expl.size();
            }
        }
        os << expl.substr(position, spaceNdx - position) << endl;
        position = spaceNdx + 1;
        firstLine = false;
    }

    if (position < expl.size()) {
        if (! firstLine) {
            for (unsigned int i = 0; i < prefixWidth; i++) {
                os << ' ';
            }
        }
        os << expl.substr(position) << endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %ecx, %r13d
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x5070
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4270
movq 0x80(%rsp), %r12
movl %r14d, %eax
cmpq %rax, %r12
jae 0x4de5
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x4310
movq 0x80(%rsp), %r12
leal 0x3(%r14), %eax
movl %eax, 0x4(%rsp)
pushq $0x2e
popq %rbp
incl %r12d
cmpl %r14d, %r12d
jae 0x4e04
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4310
jmp 0x4df0
leaq 0x1029c(%rip), %rsi     # 0x150a7
movq %rbx, %rdi
callq 0x4290
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
addq $0x48, %r15
leaq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x43e0
movl 0x60(%rsp), %ecx
decl %ecx
movq 0x58(%rsp), %rax
xorl %r15d, %r15d
cmpq %r15, %rcx
je 0x4e54
cmpb $0x20, (%rax,%r15)
jne 0x4e57
incq %r15
jmp 0x4e43
movl %ecx, %r15d
cmpl %ecx, %r15d
movl %ecx, %ebp
cmovbl %r15d, %ebp
cmpl %ecx, %r15d
jae 0x4e73
movl %ecx, %edx
cmpb $0x20, (%rax,%rdx)
jne 0x4e71
decl %ecx
jmp 0x4e60
movl %ecx, %ebp
leaq 0x8(%rsp), %r14
cmpl %ebp, %r15d
ja 0x4eb8
movl %r15d, %r12d
movsbl (%rax,%r12), %esi
movq %r14, %rdi
callq 0x4250
movq 0x58(%rsp), %rax
cmpb $0x20, (%rax,%r12)
jne 0x4eae
movl %r15d, %ecx
cmpl %ebp, %r15d
ja 0x4eb1
leal 0x1(%rcx), %r15d
cmpb $0x20, (%rax,%r15)
je 0x4e99
jmp 0x4eb1
movl %r15d, %ecx
incl %ecx
movl %ecx, %r15d
jmp 0x4e78
movl %r13d, %ecx
movl 0x4(%rsp), %eax
subl %eax, %r13d
movq %r13, 0x30(%rsp)
movl %eax, %eax
subq %rax, %rcx
movq %rcx, 0x28(%rsp)
movb $0x1, %al
xorl %r14d, %r14d
pushq $0x20
popq %rbp
leaq 0x38(%rsp), %r12
movq 0x10(%rsp), %r15
movl %r14d, %r13d
movq %r15, %rcx
subq %r13, %rcx
cmpq 0x30(%rsp), %rcx
jbe 0x4f9e
testb $0x1, %al
jne 0x4f17
movl 0x4(%rsp), %r14d
subl $0x1, %r14d
jb 0x4f12
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4310
jmp 0x4f00
movq 0x10(%rsp), %r15
movq 0x28(%rsp), %rax
addq %r13, %rax
decq %r15
cmpq %rax, %r15
cmovaeq %rax, %r15
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x45c0
cmpq $-0x1, %rax
je 0x4f46
movq %rax, %r14
cmpq %r13, %rax
ja 0x4f63
leaq 0x8(%rsp), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x43b0
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x4f63
movq 0x10(%rsp), %r14
movq %r14, %rcx
subq %r13, %rcx
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x42d0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4270
movq %rax, %rdi
callq 0x4180
movq %r12, %rdi
callq 0x45e8
incq %r14
xorl %eax, %eax
jmp 0x4ede
cmpq %r13, %r15
jbe 0x4fdb
testb $0x1, %al
je 0x500b
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $-0x1
popq %rcx
movq %r13, %rdx
callq 0x42d0
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x4180
leaq 0x38(%rsp), %rdi
callq 0x45e8
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rbp
subl $0x1, 0x4(%rsp)
jb 0x4fa7
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4310
jmp 0x500e
jmp 0x5046
jmp 0x5037
movq %rax, %rbx
jmp 0x5053
jmp 0x5032
jmp 0x5046
jmp 0x5046
jmp 0x5046
movq %rax, %rbx
jmp 0x505d
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x45e8
jmp 0x5049
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x45e8
leaq 0x8(%rsp), %rdi
callq 0x45e8
leaq 0x78(%rsp), %rdi
callq 0x45e8
movq %rbx, %rdi
callq 0x4530
nop