// File: /workspace/github_cpp_makefile_star2_O3/yaansz[P]just-a-terminal/terminal.cpp
// Function: main
int main(int argc, char **argv) {
    Color::Modifier red(Color::FG_RED);
    Color::Modifier green(Color::FG_GREEN);
    Color::Modifier def(Color::FG_DEFAULT);

    cout << red << "*********************" << def << endl;
    cout << "Terminal initialized" << endl;
    cout << "Welcome " << green << getenv("USER") << def << endl;
    cout << "Type 'help' to know more about this shell" << endl;
    cout << red << "*********************" << def << endl;

    BuiltInCommands bic;
    int exec_return;

    while(1) {
        string command;

        // Input
        cout << green << getenv("USER") << def << ":";
        cout << red << std::filesystem::current_path() << def; 
        cout << ">>>";

        getline(cin, command);
        
        if(command.empty() || blank(command)) continue;

        // Filter
        vector<string> raw_text = split(command, " ");
        vector<char*> pointerVec(raw_text.size() + 1);
        for(unsigned i = 0; i < raw_text.size(); ++i) {
            pointerVec[i] = raw_text[i].data();
        }
        pointerVec[raw_text.size()] = NULL;
        char** args = pointerVec.data();

        exec_return = execute(bic, raw_text[0], args);

        if(exec_return == -1) break;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq -0x34(%rbp), %rsi
movl $0x1f, (%rsi)
leaq -0x38(%rbp), %r14
movl $0x20, (%r14)
leaq -0x2c(%rbp), %r15
movl $0x27, (%r15)
movq 0x556e(%rip), %rbx      # 0x7fd0
movq %rbx, %rdi
callq 0x3319
movq %rax, %r12
leaq 0x2611(%rip), %rsi      # 0x5085
movl $0x15, %edx
movq %rax, %rdi
callq 0x21f0
movq %r12, %rdi
movq %r15, %rsi
callq 0x3319
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x25de(%rip), %rsi      # 0x509b
movl $0x14, %edx
movq %rbx, %rdi
callq 0x21f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x25b8(%rip), %rsi      # 0x50b0
movl $0x8, %edx
movq %rbx, %rdi
callq 0x21f0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3319
movq %rax, %r15
leaq 0x259f(%rip), %rdi      # 0x50b9
callq 0x2210
testq %rax, %rax
je 0x2b3f
movq %rax, %r14
movq %rax, %rdi
callq 0x20d0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x2b59
movq (%r15), %rax
movq -0x18(%rax), %rax
movq %r15, %rdi
addq %rax, %rdi
movl 0x20(%r15,%rax), %esi
orl $0x1, %esi
callq 0x22b0
leaq -0x2c(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x3319
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0x2525(%rip), %rsi      # 0x50be
movl $0x29, %edx
movq 0x542b(%rip), %rbx      # 0x7fd0
movq %rbx, %rdi
callq 0x21f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq -0x34(%rbp), %rsi
movq %rbx, %rdi
callq 0x3319
movq %rax, %r14
leaq 0x249b(%rip), %rsi      # 0x5085
movl $0x15, %edx
movq %rax, %rdi
callq 0x21f0
movq %r14, %rdi
movq %r12, %rsi
callq 0x3319
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq -0x138(%rbp), %rdi
callq 0x24ac
leaq -0x80(%rbp), %r13
movq 0x539d(%rip), %r15      # 0x7fe0
leaq -0xb8(%rbp), %r12
movq %r12, %rbx
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
movq 0x5368(%rip), %rdi      # 0x7fd0
leaq -0x38(%rbp), %rsi
callq 0x3319
movq %rax, %r12
leaq 0x243e(%rip), %rdi      # 0x50b9
callq 0x2210
testq %rax, %rax
je 0x2ca0
movq %rax, %r14
movq %rax, %rdi
callq 0x20d0
movq %r12, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21f0
jmp 0x2cbb
movq (%r12), %rax
movq -0x18(%rax), %rax
movq %r12, %rdi
addq %rax, %rdi
movl 0x20(%r12,%rax), %esi
orl $0x1, %esi
callq 0x22b0
movq %r12, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3319
movl $0x1, %edx
movq %rax, %rdi
leaq 0x2412(%rip), %rsi      # 0x50e8
callq 0x21f0
movq 0x52ee(%rip), %rdi      # 0x7fd0
leaq -0x34(%rbp), %rsi
callq 0x3319
movq %rax, %r12
movq %r13, %rdi
callq 0x2280
movq %r12, %rdi
movq %r13, %rsi
callq 0x3360
movq %rax, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3319
movq %r13, %rdi
callq 0x33ea
movl $0x3, %edx
movq 0x52af(%rip), %rdi      # 0x7fd0
leaq 0x23c2(%rip), %rsi      # 0x50ea
callq 0x21f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r15, %rdi
leaq -0x58(%rbp), %rsi
callq 0x2300
movq -0x50(%rbp), %rdx
testq %rdx, %rdx
je 0x2db5
leaq -0xc8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x58(%rbp), %rsi
addq %rsi, %rdx
leaq -0xd8(%rbp), %rdi
callq 0x3914
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rax
testq %rax, %rax
je 0x2dbd
cmpb $0x20, (%rdi)
jne 0x2deb
movq %rbx, %r12
movl $0x1, %edx
movq %rdx, %rcx
cmpq %rdx, %rax
je 0x2dac
leaq 0x1(%rcx), %rdx
cmpb $0x20, (%rdi,%rcx)
je 0x2d9a
cmpq %rcx, %rax
setbe %r14b
jmp 0x2dc3
xorl %r14d, %r14d
jmp 0x2f7b
movb $0x1, %r14b
movq %rbx, %r12
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x2dde
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21c0
testb %r14b, %r14b
je 0x2e06
xorl %r14d, %r14d
jmp 0x2f7e
leaq -0xc8(%rbp), %rax
cmpq %rax, %rdi
je 0x2e06
movq -0xc8(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %r13, %rdi
leaq 0x229f(%rip), %rsi      # 0x50b7
leaq 0x2299(%rip), %rdx      # 0x50b8
callq 0x39b2
leaq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movq %r13, %rdx
callq 0x293e
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x2e50
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21c0
movq -0x90(%rbp), %rsi
subq -0x98(%rbp), %rsi
sarq $0x5, %rsi
incq %rsi
movq %r13, %rdi
leaq -0x2d(%rbp), %rdx
callq 0x3432
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rsi
subq %rax, %rsi
je 0x2ebe
movl $0x1, %ecx
xorl %edx, %edx
movq %rdx, %rsi
shlq $0x5, %rsi
movq (%rax,%rsi), %rax
movq -0x80(%rbp), %rsi
movq %rax, (%rsi,%rdx,8)
movl %ecx, %edx
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rsi
subq %rax, %rsi
sarq $0x5, %rsi
incl %ecx
cmpq %rdx, %rsi
ja 0x2e8b
jmp 0x2ec2
sarq $0x5, %rsi
movq -0x80(%rbp), %rax
movq $0x0, (%rax,%rsi,8)
movq -0x80(%rbp), %r12
leaq -0x108(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x363e
movq -0x98(%rbp), %rax
leaq -0xa8(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %rbx, %r14
movq %rbx, %rdi
callq 0x3914
leaq -0x108(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x27ea
movl %eax, %r12d
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x2f46
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x108(%rbp), %rdi
callq 0x3588
cmpl $-0x1, %r12d
sete %r14b
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x2f6f
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x21c0
leaq -0x98(%rbp), %rdi
callq 0x32ac
movq %rbx, %r12
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x2f97
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21c0
testb %r14b, %r14b
je 0x2c4a
leaq -0x138(%rbp), %rdi
callq 0x3588
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x3005
jmp 0x3056
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x2ff9
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x2ff9
movq %rax, %rbx
jmp 0x301a
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x3588
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x301a
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x21c0
leaq -0x98(%rbp), %rdi
callq 0x32ac
jmp 0x3059
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3059
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21c0
jmp 0x3059
jmp 0x3056
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x33ea
jmp 0x3059
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3072
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21c0
leaq -0x138(%rbp), %rdi
callq 0x3588
movq %rbx, %rdi
callq 0x22e0