// File: pokorj54[P]Pathfinder-utilities/src/CommandLine.cpp
// Function: CommandLine::HandleCommands()
void CommandLine::HandleCommands()
{
    while(!input->eof() && !input->fail())
    {
        string fullCommand;
        getline(*input, fullCommand);
        if(fullCommand.find_first_not_of(" \t") == string::npos)
        {
            continue; //no command given
        }
        else if(count(fullCommand.begin(), fullCommand.end(), '"') % 2 == 1)
        {
            *output << "Invalid command - odd number of \"" << endl;
            continue;
        }

        Arguments arguments;
        string cmdName = _GetCommandAndArgument(fullCommand, arguments);
        transform(cmdName.begin(), cmdName.end(), cmdName.begin(), ::tolower);

        if(cmdName == "exit") //it's the only command that can affect the command cycle 
        {
            break;
        }

        HandleCmd method;
        if(cmdTranslation.count(cmdName) > 0)
        {
            method = cmdTranslation.at(cmdName).first;
        }
        else if (aliases.count(cmdName) > 0)
        {
            method = cmdTranslation.at(aliases.at(cmdName)).first;
        }
        else
        {
            *output << "Unknown command" << endl;
            continue;
        }

        try
        {
            ((*this).*method)(arguments);
        }
        catch(const Exception & e)
        {
            e.Message(*output);
        }
    }
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x180(%rsp)
movq 0x180(%rsp), %rax
movq %rax, 0x98(%rsp)
movq 0x98(%rsp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x34b0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x97(%rsp)
jne 0x8d16
movq 0x98(%rsp), %rax
movq (%rax), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x3030
xorb $-0x1, %al
movb %al, 0x97(%rsp)
movb 0x97(%rsp), %al
testb $0x1, %al
jne 0x8d26
jmp 0x9238
leaq 0x160(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x3390
movq 0x98(%rsp), %rax
movq 0x88(%rsp), %rsi
movq (%rax), %rdi
callq 0x30b0
jmp 0x8d55
leaq 0x160(%rsp), %rdi
leaq 0x8658(%rip), %rsi      # 0x113bc
xorl %eax, %eax
movl %eax, %edx
callq 0x31a0
cmpq $-0x1, %rax
jne 0x8d9c
movl $0x2, 0x150(%rsp)
jmp 0x91be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x9229
leaq 0x160(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x3270
movq 0x78(%rsp), %rdi
movq %rax, 0x148(%rsp)
callq 0x31b0
movq %rax, 0x140(%rsp)
movb $0x22, 0x13f(%rsp)
movq 0x148(%rsp), %rdi
movq 0x140(%rsp), %rsi
leaq 0x13f(%rsp), %rdx
callq 0x9d90
movq %rax, 0x80(%rsp)
jmp 0x8df7
movq 0x80(%rsp), %rax
movl $0x2, %ecx
cqto
idivq %rcx
cmpq $0x1, %rdx
jne 0x8e51
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x859d(%rip), %rsi      # 0x113bf
callq 0x32e0
movq %rax, 0x70(%rsp)
jmp 0x8e2e
movq 0x70(%rsp), %rdi
movq 0xf16e(%rip), %rsi      # 0x17fa8
callq 0x3310
jmp 0x8e41
movl $0x2, 0x150(%rsp)
jmp 0x91be
jmp 0x8e53
leaq 0x118(%rsp), %rdi
callq 0x82c0
jmp 0x8e62
leaq 0xd8(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x3130
jmp 0x8e79
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0x118(%rsp), %rdx
callq 0x8700
jmp 0x8e98
leaq 0xd8(%rsp), %rdi
callq 0x31f0
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x3270
movq 0x60(%rsp), %rdi
movq %rax, 0xd0(%rsp)
callq 0x31b0
movq 0x60(%rsp), %rdi
movq %rax, 0xc8(%rsp)
callq 0x3270
movq %rax, 0xc0(%rsp)
movq 0xd0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq 0xf0ce(%rip), %rcx      # 0x17fd0
callq 0x9de0
movq %rax, 0x68(%rsp)
jmp 0x8f0e
movq 0x68(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x84bf(%rip), %rsi      # 0x113e1
leaq 0xf8(%rsp), %rdi
callq 0x7700
movb %al, 0x5f(%rsp)
jmp 0x8f35
movb 0x5f(%rsp), %al
testb $0x1, %al
jne 0x8f3f
jmp 0x8fa7
movl $0x3, 0x150(%rsp)
jmp 0x91a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x921c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x31f0
jmp 0x921c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
jmp 0x920f
leaq 0xf322(%rip), %rdi      # 0x182d0
leaq 0xf8(%rsp), %rsi
callq 0x9e70
movq %rax, 0x50(%rsp)
jmp 0x8fc2
movq 0x50(%rsp), %rax
cmpq $0x0, %rax
jbe 0x9009
leaq 0xf2fc(%rip), %rdi      # 0x182d0
leaq 0xf8(%rsp), %rsi
callq 0x9ea0
movq %rax, 0x48(%rsp)
jmp 0x8fe8
movq 0x48(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rcx, 0xb0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0x90c4
leaq 0xf2f8(%rip), %rdi      # 0x18308
leaq 0xf8(%rsp), %rsi
callq 0x9ed0
movq %rax, 0x40(%rsp)
jmp 0x9024
movq 0x40(%rsp), %rax
cmpq $0x0, %rax
jbe 0x9080
leaq 0xf2d2(%rip), %rdi      # 0x18308
leaq 0xf8(%rsp), %rsi
callq 0x9f00
movq %rax, 0x38(%rsp)
jmp 0x904a
movq 0x38(%rsp), %rsi
leaq 0xf27a(%rip), %rdi      # 0x182d0
callq 0x9ea0
movq %rax, 0x30(%rsp)
jmp 0x9062
movq 0x30(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movq %rcx, 0xb0(%rsp)
movq %rax, 0xa8(%rsp)
jmp 0x90c2
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rdi
leaq 0x8353(%rip), %rsi      # 0x113e6
callq 0x32e0
movq %rax, 0x28(%rsp)
jmp 0x909f
movq 0x28(%rsp), %rdi
movq 0xeefd(%rip), %rsi      # 0x17fa8
callq 0x3310
jmp 0x90b2
movl $0x2, 0x150(%rsp)
jmp 0x91a4
jmp 0x90c4
movq 0x98(%rsp), %rcx
movq 0xa8(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xb0(%rsp), %rdx
addq %rdx, %rcx
movq %rcx, 0x20(%rsp)
andq $0x1, %rax
cmpq $0x0, %rax
je 0x910f
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rax
movq (%rax), %rax
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, 0x10(%rsp)
jmp 0x9119
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rax
leaq 0x118(%rsp), %rsi
callq *%rax
jmp 0x912f
jmp 0x9199
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
movl 0x154(%rsp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x920f
movq 0x158(%rsp), %rdi
callq 0x3110
movq %rax, %rcx
movq 0x98(%rsp), %rax
movq %rcx, 0xa0(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x8(%rax), %rsi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0x9190
callq 0x3430
jmp 0x9197
jmp 0x9199
movl $0x0, 0x150(%rsp)
leaq 0xf8(%rsp), %rdi
callq 0x31f0
leaq 0x118(%rsp), %rdi
callq 0x9f30
leaq 0x160(%rsp), %rdi
callq 0x31f0
movl 0x150(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x91ed
jmp 0x91dc
movl 0xc(%rsp), %eax
subl $0x2, %eax
je 0x8ccf
jmp 0x91eb
jmp 0x9238
jmp 0x8ccf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x158(%rsp)
movl %eax, 0x154(%rsp)
callq 0x3430
jmp 0x920d
jmp 0x920f
leaq 0xf8(%rsp), %rdi
callq 0x31f0
leaq 0x118(%rsp), %rdi
callq 0x9f30
leaq 0x160(%rsp), %rdi
callq 0x31f0
jmp 0x9240
addq $0x188, %rsp            # imm = 0x188
retq
movq 0x158(%rsp), %rdi
callq 0x3490
movq %rax, %rdi
callq 0x5240
nopw %cs:(%rax,%rax)
nop