// File: /workspace/github_cpp_makefile_star2_O2/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 $0x68, %rsp
movq %rdi, %r13
xorl %ebx, %ebx
movb %bl, (%rdi)
leaq 0x8(%rdi), %r12
leaq 0x3d97(%rip), %rsi      # 0xe3f4
leaq -0x70(%rbp), %rdx
movq %r12, %rdi
callq 0x50d0
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%r13)
andq $0x0, 0x38(%r13)
leaq 0x50(%r13), %rax
movq %rax, 0x40(%r13)
andq $0x0, 0x48(%r13)
leaq 0x28(%r13), %rax
movq %rax, -0x78(%rbp)
leaq 0x40(%r13), %r15
movb %bl, 0x50(%r13)
leaq 0x60(%r13), %rbx
movq %rbx, %rdi
movq %r12, -0x88(%rbp)
callq 0xc541
movq %rbx, -0x80(%rbp)
movq 0xc917(%rip), %rax      # 0x16fc8
movq %rax, 0x80(%r13)
movq 0xc931(%rip), %rax      # 0x16ff0
movq %rax, 0x88(%r13)
leaq 0x90(%r13), %rbx
leaq 0x3d28(%rip), %rsi      # 0xe3fc
leaq -0x70(%rbp), %rdx
movq %rbx, %rdi
callq 0x50d0
leaq 0xb0(%r13), %r14
movq %r14, %rdi
callq 0xc58d
xorps %xmm0, %xmm0
movups %xmm0, 0xd9(%r13)
movups %xmm0, 0xd0(%r13)
movq %r13, %rdi
callq 0xa92a
movq 0xc8b7(%rip), %rdi      # 0x16fc8
leaq 0x3ce8(%rip), %rsi      # 0xe400
callq 0x5200
movq %rax, %rdi
movq %r14, %rsi
callq 0x51c0
leaq 0x28ea(%rip), %rsi      # 0xd019
movq %rax, %rdi
callq 0x5200
movq %rax, %rdi
callq 0x5110
movq %r15, %rdi
callq 0xc42a
testb %al, %al
jne 0xa7ac
leaq 0x3cc6(%rip), %rsi      # 0xe418
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x50d0
leaq -0x70(%rbp), %rsi
movq %r13, %rdi
callq 0xa9c4
leaq -0x70(%rbp), %rdi
callq 0x5100
leaq 0x3cca(%rip), %rsi      # 0xe445
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x50d0
leaq -0x70(%rbp), %rsi
movq %r13, %rdi
callq 0xa9c4
leaq -0x70(%rbp), %rdi
callq 0x5100
leaq 0x2968(%rip), %rsi      # 0xd10c
movq %r15, %rdi
callq 0x53f0
leaq 0x3ca5(%rip), %rdi      # 0xe458
callq 0x5280
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rdx
movq %rax, %rsi
callq 0x50d0
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
pushq $0x3a
popq %rdx
callq 0xc248
leaq -0x50(%rbp), %r12
movq -0x78(%rbp), %rdi
movq %r12, %rsi
callq 0xb916
movq %r12, %rdi
callq 0x678c
leaq 0x3c66(%rip), %rsi      # 0xe45d
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x50d0
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0xa478
leaq -0x50(%rbp), %rdi
callq 0x5100
leaq -0x4f8(%rip), %rsi      # 0xa328
pushq $0x2
popq %rdi
callq 0x5260
cmpq $-0x1, %rax
je 0xa85b
leaq -0x2de(%rip), %rsi      # 0xa557
pushq $0x14
popq %rdi
callq 0x5260
cmpq $-0x1, %rax
je 0xa87b
leaq -0x70(%rbp), %rdi
callq 0x5100
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c19(%rip), %rsi      # 0xe47b
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x50d0
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0xa418
leaq 0x3c32(%rip), %rsi      # 0xe4b4
leaq -0x50(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x50d0
leaq -0x50(%rbp), %rsi
movq %r13, %rdi
callq 0xa418
jmp 0xa8ab
jmp 0xa8bb
jmp 0xa8ab
jmp 0xa8bb
jmp 0xa8bb
jmp 0xa8da
jmp 0xa8bb
jmp 0xa8da
movq %rax, %r12
leaq -0x50(%rbp), %rdi
callq 0x5100
jmp 0xa8be
jmp 0xa8bb
movq %rax, %r12
leaq -0x70(%rbp), %rdi
callq 0x5100
jmp 0xa8dd
jmp 0xa8da
movq %rax, %r12
jmp 0xa8f4
movq %rax, %r12
jmp 0xa8fc
movq %rax, %r12
jmp 0xa905
movq %rax, %r12
addq $0xd0, %r13
movq %r13, %rdi
callq 0xb552
movq %r14, %rdi
callq 0x5100
movq %rbx, %rdi
callq 0x5100
movq -0x80(%rbp), %rdi
callq 0x5100
movq %r15, %rdi
callq 0x5100
movq -0x78(%rbp), %rdi
callq 0x678c
movq -0x88(%rbp), %rdi
callq 0x5100
movq %r12, %rdi
callq 0x53a0