// File: /workspace/github_cpp_makefile_star2_O3/AndreiBarsan[P]uShell/shell.cc
// Function: microshell::core::Shell::Shell(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
Shell::Shell(const vector<string> &) :
    exit_requested(false),
    home_directory(util::get_current_home()),
    standard_output(cout),
    error_output(cerr),
    name("ush"),
    username(util::get_current_user()),
    waiting_for_child(false) {
  this->load_default_modules();
  cout << "Welcome to microshell, " << username << "!" << endl;
  if(!util::getcwd(&this->working_directory)) {
    eout("Failed to get the current working directory.");
    // TODO(andrei) Display what `~' resolves to between parentheses.  If it
    // can't be resolved, use `/' instead.
    eout("Defaulting to `~'.");
    // TODO(andrei) Use setter and actually resolve $HOME.
    this->working_directory = "~";
  }

  string envpath = getenv("PATH");
  this->path = util::split(envpath, ':');

  this->info("Setting up signal handlers...");
  if(SIG_ERR == signal(SIGINT, handle_sigint)) {
    this->fatal("Could not set up SIGINT handler (C-c terminate support).");
  }
  if(SIG_ERR == signal(SIGTSTP, handle_sigtstp)) {
    this->fatal("Could not set up SIGTSTP handler (C-z suspend support).");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
xorl %r14d, %r14d
movb %r14b, (%rdi)
addq $0x8, %rdi
leaq 0x18(%rbx), %rax
movq %rax, -0x80(%rbp)
movq %rax, 0x8(%rbx)
leaq 0x4567(%rip), %rsi      # 0xe414
leaq 0x4567(%rip), %rdx      # 0xe41b
movq %rdi, -0x88(%rbp)
callq 0x7140
movq %r14, 0x38(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rbx)
leaq 0x40(%rbx), %r15
leaq 0x50(%rbx), %rax
movq %rax, -0x78(%rbp)
movq %rax, 0x40(%rbx)
movq %r14, 0x48(%rbx)
movb %r14b, 0x50(%rbx)
leaq 0x60(%rbx), %rdi
callq 0xc28d
movq 0xb0d5(%rip), %rax      # 0x14fc8
movq %rax, 0x80(%rbx)
movq 0xb0ef(%rip), %rax      # 0x14ff0
movq %rax, 0x88(%rbx)
leaq 0x90(%rbx), %r12
leaq 0xa0(%rbx), %r14
movq %r14, 0x90(%rbx)
leaq 0x44f8(%rip), %rsi      # 0xe41c
leaq 0x44f4(%rip), %rdx      # 0xe41f
movq %r12, %rdi
callq 0x7140
leaq 0xb0(%rbx), %rdi
callq 0xc2f9
xorps %xmm0, %xmm0
movups %xmm0, 0xd9(%rbx)
movups %xmm0, 0xd0(%rbx)
movq %rbx, %rdi
callq 0xa294
movq 0xb069(%rip), %rdi      # 0x14fc8
leaq 0x44ba(%rip), %rsi      # 0xe420
movl $0x17, %edx
callq 0x52a0
movq 0xb0(%rbx), %rsi
movq 0xb8(%rbx), %rdx
movq 0xb043(%rip), %rdi      # 0x14fc8
callq 0x52a0
movq %rax, %r13
leaq 0x3085(%rip), %rsi      # 0xd019
movl $0x1, %edx
movq %rax, %rdi
callq 0x52a0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x5240
movsbl %al, %esi
movq %r13, %rdi
callq 0x5040
movq %rax, %rdi
callq 0x5180
movq %r15, %rdi
callq 0xc159
testb %al, %al
jne 0xa061
leaq -0x60(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x4450(%rip), %rsi      # 0xe438
leaq 0x4475(%rip), %rdx      # 0xe464
leaq -0x70(%rbp), %rdi
callq 0x7140
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0xa372
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0xa012
callq 0x5230
leaq -0x70(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x4445(%rip), %rsi      # 0xe465
leaq 0x4450(%rip), %rdx      # 0xe477
callq 0x7140
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0xa372
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0xa046
callq 0x5230
movq 0x48(%rbx), %rdx
leaq 0x30b6(%rip), %rcx      # 0xd107
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
leaq 0x4410(%rip), %rdi      # 0xe478
callq 0x52f0
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
movq %rax, %rsi
callq 0x50f0
leaq -0xa0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movl $0x3a, %edx
callq 0xbeed
movups 0x28(%rbx), %xmm0
movq 0x38(%rbx), %rax
leaq -0xa0(%rbp), %r13
movq (%r13), %rcx
movq %rcx, 0x28(%rbx)
movq 0x8(%r13), %rcx
movq %rcx, 0x30(%rbx)
movq 0x10(%r13), %rcx
movq %rcx, 0x38(%rbx)
leaq -0x50(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r13)
movq $0x0, 0x10(%r13)
callq 0x6c6c
movq %r13, %rdi
callq 0x6c6c
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x438d(%rip), %rsi      # 0xe47d
leaq 0x43a3(%rip), %rdx      # 0xe49a
leaq -0x50(%rbp), %rdi
callq 0x7140
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9b7c
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xa11a
callq 0x5230
leaq -0x80d(%rip), %rsi      # 0x9914
movl $0x2, %edi
callq 0x52d0
cmpq $-0x1, %rax
je 0xa169
leaq -0x451(%rip), %rsi      # 0x9ce7
movl $0x14, %edi
callq 0x52d0
cmpq $-0x1, %rax
je 0xa18f
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa15a
callq 0x5230
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x50(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x4324(%rip), %rsi      # 0xe49b
leaq 0x4355(%rip), %rdx      # 0xe4d3
callq 0x7140
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9b10
leaq -0x50(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x4337(%rip), %rsi      # 0xe4d4
leaq 0x4367(%rip), %rdx      # 0xe50b
callq 0x7140
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9b10
jmp 0xa1d2
jmp 0xa1e8
jmp 0xa1d2
jmp 0xa1e8
jmp 0xa1c1
jmp 0xa214
movq %rax, -0x30(%rbp)
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
jne 0xa1f9
jmp 0xa218
jmp 0xa214
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xa1ec
callq 0x5230
jmp 0xa1ec
jmp 0xa1e8
movq %rax, -0x30(%rbp)
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa218
callq 0x5230
jmp 0xa218
jmp 0xa214
movq %rax, -0x30(%rbp)
jmp 0xa23c
movq %rax, -0x30(%rbp)
jmp 0xa24a
movq %rax, -0x30(%rbp)
jmp 0xa25c
movq %rax, -0x30(%rbp)
leaq 0xd0(%rbx), %rdi
callq 0xb654
movq 0xb0(%rbx), %rdi
leaq 0xc0(%rbx), %rax
cmpq %rax, %rdi
je 0xa23c
callq 0x5230
movq (%r12), %rdi
cmpq %r14, %rdi
je 0xa24a
callq 0x5230
movq 0x60(%rbx), %rdi
leaq 0x70(%rbx), %rax
cmpq %rax, %rdi
je 0xa25c
callq 0x5230
addq $0x28, %rbx
movq (%r15), %rdi
cmpq -0x78(%rbp), %rdi
je 0xa26e
callq 0x5230
movq %rbx, %rdi
callq 0x6c6c
movq -0x88(%rbp), %rax
movq (%rax), %rdi
cmpq -0x80(%rbp), %rdi
je 0xa28b
callq 0x5230
movq -0x30(%rbp), %rdi
callq 0x5400