// File: /workspace/github_cpp_makefile_star2_O1/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 0x44d3(%rip), %rsi      # 0xe414
leaq 0x44d3(%rip), %rdx      # 0xe41b
movq %rdi, -0x88(%rbp)
callq 0x713a
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 0xc369
movq 0xb041(%rip), %rax      # 0x14fc8
movq %rax, 0x80(%rbx)
movq 0xb05b(%rip), %rax      # 0x14ff0
movq %rax, 0x88(%rbx)
leaq 0x90(%rbx), %r12
leaq 0xa0(%rbx), %r14
movq %r14, 0x90(%rbx)
leaq 0x4464(%rip), %rsi      # 0xe41c
leaq 0x4460(%rip), %rdx      # 0xe41f
movq %r12, %rdi
callq 0x713a
leaq 0xb0(%rbx), %rdi
callq 0xc3d5
xorps %xmm0, %xmm0
movups %xmm0, 0xd9(%rbx)
movups %xmm0, 0xd0(%rbx)
movq %rbx, %rdi
callq 0xa33e
movq 0xafd5(%rip), %rdi      # 0x14fc8
leaq 0x4426(%rip), %rsi      # 0xe420
movl $0x17, %edx
callq 0x52a0
movq 0xb0(%rbx), %rsi
movq 0xb8(%rbx), %rdx
movq 0xafaf(%rip), %rdi      # 0x14fc8
callq 0x52a0
movq %rax, %r13
leaq 0x2ff1(%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 0xc235
testb %al, %al
jne 0xa0f5
leaq -0x60(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x43bc(%rip), %rsi      # 0xe438
leaq 0x43e1(%rip), %rdx      # 0xe464
leaq -0x70(%rbp), %rdi
callq 0x713a
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0xa434
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0xa0a6
callq 0x5230
leaq -0x70(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x43b1(%rip), %rsi      # 0xe465
leaq 0x43bc(%rip), %rdx      # 0xe477
callq 0x713a
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0xa434
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
je 0xa0da
callq 0x5230
movq 0x48(%rbx), %rdx
leaq 0x3022(%rip), %rcx      # 0xd107
movl $0x1, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x5380
leaq 0x437c(%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 0xbfc9
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x28(%rbx), %rax
movups 0x30(%rbx), %xmm0
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)
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
movq %rax, (%rdi)
movups %xmm0, 0x8(%rdi)
movq %rcx, (%r13)
movq %rdx, 0x8(%r13)
movq %rsi, 0x10(%r13)
callq 0x6c60
movq %r13, %rdi
callq 0x6c60
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x42e4(%rip), %rsi      # 0xe47d
leaq 0x42fa(%rip), %rdx      # 0xe49a
leaq -0x50(%rbp), %rdi
callq 0x713a
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9c10
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xa1c3
callq 0x5230
leaq -0x822(%rip), %rsi      # 0x99a8
movl $0x2, %edi
callq 0x52d0
cmpq $-0x1, %rax
je 0xa212
leaq -0x466(%rip), %rsi      # 0x9d7b
movl $0x14, %edi
callq 0x52d0
cmpq $-0x1, %rax
je 0xa238
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa203
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 0x427b(%rip), %rsi      # 0xe49b
leaq 0x42ac(%rip), %rdx      # 0xe4d3
callq 0x713a
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9ba4
leaq -0x50(%rbp), %rdi
movq %r13, (%rdi)
leaq 0x428e(%rip), %rsi      # 0xe4d4
leaq 0x42be(%rip), %rdx      # 0xe50b
callq 0x713a
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x9ba4
jmp 0xa27b
jmp 0xa291
jmp 0xa27b
jmp 0xa291
jmp 0xa26a
jmp 0xa2bd
movq %rax, -0x30(%rbp)
movq -0x70(%rbp), %rdi
cmpq %r13, %rdi
jne 0xa2a2
jmp 0xa2c1
jmp 0xa2bd
movq %rax, -0x30(%rbp)
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xa295
callq 0x5230
jmp 0xa295
jmp 0xa291
movq %rax, -0x30(%rbp)
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xa2c1
callq 0x5230
jmp 0xa2c1
jmp 0xa2bd
movq %rax, -0x30(%rbp)
jmp 0xa2e5
movq %rax, -0x30(%rbp)
jmp 0xa2f3
movq %rax, -0x30(%rbp)
jmp 0xa305
movq %rax, -0x30(%rbp)
leaq 0xd0(%rbx), %rdi
callq 0xb72a
movq 0xb0(%rbx), %rdi
leaq 0xc0(%rbx), %rax
cmpq %rax, %rdi
je 0xa2e5
callq 0x5230
movq (%r12), %rdi
cmpq %r14, %rdi
je 0xa2f3
callq 0x5230
movq 0x60(%rbx), %rdi
leaq 0x70(%rbx), %rax
cmpq %rax, %rdi
je 0xa305
callq 0x5230
addq $0x28, %rbx
movq (%r15), %rdi
cmpq -0x78(%rbp), %rdi
je 0xa317
callq 0x5230
movq %rbx, %rdi
callq 0x6c60
movq -0x88(%rbp), %rax
movq (%rax), %rdi
cmpq -0x80(%rbp), %rdi
je 0xa334
callq 0x5230
movq -0x30(%rbp), %rdi
callq 0x5400
nop