// File: frainfreeze[P]tss/main.cpp
// Function: main_loop()
void main_loop(){
    //clean whoami and hostname strings
    if (!whoami.empty() && whoami[whoami.length()-1] == '\n') { 
        whoami.erase(whoami.length()-1);
    }
    if (!hostname.empty() && hostname[hostname.length()-1] == '\n') { 
        hostname.erase(hostname.length()-1);
    }

    std::string line;
    std::string args;
    int status;

    do {
        std::string pwd = shell::exec("pwd");
        //clean pwd string
        if (!pwd.empty() && pwd[pwd.length()-1] == '\n') { 
            pwd.erase(pwd.length()-1);
        }

        std::cout << Color::FG_RED << whoami << "@" << hostname << ":" << Color::FG_DEFAULT 
                  << Color::FG_BLUE << pwd << Color::FG_DEFAULT << "$ ";

        std::getline(std::cin, line);
        status = shell::parse(line);
        
        line.clear();
        args.clear();
    } while (status);    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq 0x8116(%rip), %rdi      # 0xc288
callq 0x33b0
testb $0x1, %al
jne 0x41c8
leaq 0x8106(%rip), %rdi      # 0xc288
callq 0x3350
movq %rax, %rsi
subq $0x1, %rsi
leaq 0x80f3(%rip), %rdi      # 0xc288
callq 0x3450
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x41c8
leaq 0x80df(%rip), %rdi      # 0xc288
callq 0x3350
movq %rax, %rsi
subq $0x1, %rsi
leaq 0x80cc(%rip), %rdi      # 0xc288
movq $-0x1, %rdx
callq 0x3080
leaq 0x80d9(%rip), %rdi      # 0xc2a8
callq 0x33b0
testb $0x1, %al
jne 0x4225
leaq 0x80c9(%rip), %rdi      # 0xc2a8
callq 0x3350
movq %rax, %rsi
subq $0x1, %rsi
leaq 0x80b6(%rip), %rdi      # 0xc2a8
callq 0x3450
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x4225
leaq 0x80a2(%rip), %rdi      # 0xc2a8
callq 0x3350
movq %rax, %rsi
subq $0x1, %rsi
leaq 0x808f(%rip), %rdi      # 0xc2a8
movq $-0x1, %rdx
callq 0x3080
leaq -0x20(%rbp), %rdi
callq 0x3310
leaq -0x40(%rbp), %rdi
callq 0x3310
leaq -0x89(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3400
movq -0xc8(%rbp), %rdx
leaq 0x3eb6(%rip), %rsi      # 0x810e
leaq -0x88(%rbp), %rdi
callq 0x4a40
jmp 0x4266
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x3c00
jmp 0x4278
leaq -0x88(%rbp), %rdi
callq 0x3468
leaq -0x89(%rbp), %rdi
callq 0x32b0
leaq -0x68(%rbp), %rdi
callq 0x33b0
testb $0x1, %al
jne 0x4366
leaq -0x68(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x3350
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3450
movq %rax, -0xd0(%rbp)
jmp 0x42cc
movq -0xd0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x4366
leaq -0x68(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x3350
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
movq $-0x1, %rdx
callq 0x3080
jmp 0x430a
jmp 0x4366
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x433e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3468
leaq -0x89(%rbp), %rdi
callq 0x32b0
jmp 0x4520
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
jmp 0x4517
movq 0x7c53(%rip), %rdi      # 0xbfc0
movl $0x1f, %esi
callq 0x3900
movq %rax, -0xe8(%rbp)
jmp 0x4380
movq -0xe8(%rbp), %rdi
leaq 0x7efa(%rip), %rsi      # 0xc288
callq 0x3220
movq %rax, -0xf0(%rbp)
jmp 0x439c
movq -0xf0(%rbp), %rdi
leaq 0x3d68(%rip), %rsi      # 0x8112
callq 0x3240
movq %rax, -0xf8(%rbp)
jmp 0x43b8
movq -0xf8(%rbp), %rdi
leaq 0x7ee2(%rip), %rsi      # 0xc2a8
callq 0x3220
movq %rax, -0x100(%rbp)
jmp 0x43d4
movq -0x100(%rbp), %rdi
leaq 0x3d32(%rip), %rsi      # 0x8114
callq 0x3240
movq %rax, -0x108(%rbp)
jmp 0x43f0
movq -0x108(%rbp), %rdi
movl $0x27, %esi
callq 0x3900
movq %rax, -0x110(%rbp)
jmp 0x440a
movq -0x110(%rbp), %rdi
movl $0x22, %esi
callq 0x3900
movq %rax, -0x118(%rbp)
jmp 0x4424
movq -0x118(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x3220
movq %rax, -0x120(%rbp)
jmp 0x443d
movq -0x120(%rbp), %rdi
movl $0x27, %esi
callq 0x3900
movq %rax, -0x128(%rbp)
jmp 0x4457
movq -0x128(%rbp), %rdi
leaq 0x3cb1(%rip), %rsi      # 0x8116
callq 0x3240
jmp 0x446c
movq 0x7b65(%rip), %rdi      # 0xbfd8
leaq -0x20(%rbp), %rsi
callq 0x3070
jmp 0x447e
leaq -0xc0(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3120
jmp 0x4490
leaq -0xc0(%rbp), %rdi
callq 0x3e20
movl %eax, -0x12c(%rbp)
jmp 0x44a4
movl -0x12c(%rbp), %eax
movl %eax, -0x44(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3468
leaq -0x20(%rbp), %rdi
callq 0x3300
leaq -0x40(%rbp), %rdi
callq 0x3300
leaq -0x68(%rbp), %rdi
callq 0x3468
cmpl $0x0, -0x44(%rbp)
jne 0x4237
leaq -0x40(%rbp), %rdi
callq 0x3468
leaq -0x20(%rbp), %rdi
callq 0x3468
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x3468
leaq -0x68(%rbp), %rdi
callq 0x3468
leaq -0x40(%rbp), %rdi
callq 0x3468
leaq -0x20(%rbp), %rdi
callq 0x3468
movq -0x98(%rbp), %rdi
callq 0x33f0
nop