// File: brandoncanaday[P]1730sh/1730sh.cpp
// Function: callBuiltIn(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, 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&, Input*)
void callBuiltIn(string & command, const vector<string>& args, Input * job) {
  if(command == "cd") { // changes current working dir
    last_exit_status = (cd_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "exit") { // exits shell with specified status
    int status;
    last_exit_status = ((status = exit_builtin(args)) != -1) ? status : EXIT_FAILURE;
    delete job;
    if(status != -1) {
      for(unsigned int i = 0, s = current_jobs.size(); i < s; i++) {
	if(current_jobs[i] != nullptr) delete current_jobs[i]; current_jobs[i] = nullptr;
      } // for
      exit(status);
    } // if
  } else if(command == "help") { // prints built-in command options
    last_exit_status = (help_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "bg") { // puts and resumes job in background
    last_exit_status = (bg_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "fg") { // puts and resumes job in foreground
    last_exit_status = (fg_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "export") { // changes env variables
    last_exit_status = (export_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "jobs") { // prints status of currently running jobs
    last_exit_status = (jobs_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } else if(command == "kill") { // sends specified signal to specified pid/pgid
    last_exit_status = (kill_builtin(args) == -1) ? EXIT_FAILURE : EXIT_SUCCESS;
  } // if/else
  delete job;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
leaq 0xdda5(%rip), %rsi      # 0x15144
callq 0xb390
testb $0x1, %al
jne 0x73aa
jmp 0x73cd
movq -0x10(%rbp), %rdi
callq 0x87b0
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14f8c(%rip)     # 0x1c354
jmp 0x7636
movq -0x8(%rbp), %rdi
leaq 0xdd6f(%rip), %rsi      # 0x15147
callq 0xb390
testb $0x1, %al
jne 0x73e6
jmp 0x74dd
movq -0x10(%rbp), %rdi
callq 0x8ea0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
je 0x73ff
movl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
jmp 0x7409
movl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x7409
movl -0x28(%rbp), %eax
movl %eax, 0x14f42(%rip)     # 0x1c354
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
je 0x7437
movq -0x30(%rbp), %rdi
callq 0xb3c0
movq -0x30(%rbp), %rdi
movl $0xe8, %esi
callq 0x3300
cmpl $-0x1, -0x1c(%rbp)
je 0x74d8
movl $0x0, -0x20(%rbp)
leaq 0x14f11(%rip), %rdi     # 0x1c360
callq 0xb910
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0x74d0
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq 0x14ef5(%rip), %rdi     # 0x1c360
callq 0xb930
cmpq $0x0, (%rax)
je 0x74ad
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq 0x14ede(%rip), %rdi     # 0x1c360
callq 0xb930
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
je 0x74ab
movq -0x38(%rbp), %rdi
callq 0xb3c0
movq -0x38(%rbp), %rdi
movl $0xe8, %esi
callq 0x3300
jmp 0x74ad
movl -0x20(%rbp), %eax
movl %eax, %esi
leaq 0x14ea7(%rip), %rdi     # 0x1c360
callq 0xb930
movq $0x0, (%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x7457
movl -0x1c(%rbp), %edi
callq 0x3390
jmp 0x7634
movq -0x8(%rbp), %rdi
leaq 0xdccb(%rip), %rsi      # 0x151b3
callq 0xb390
testb $0x1, %al
jne 0x74f3
jmp 0x7516
movq -0x10(%rbp), %rdi
callq 0x91c0
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14e43(%rip)     # 0x1c354
jmp 0x7632
movq -0x8(%rbp), %rdi
leaq 0xdc2b(%rip), %rsi      # 0x1514c
callq 0xb390
testb $0x1, %al
jne 0x752c
jmp 0x754f
movq -0x10(%rbp), %rdi
callq 0x9610
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14e0a(%rip)     # 0x1c354
jmp 0x7630
movq -0x8(%rbp), %rdi
leaq 0xdbf5(%rip), %rsi      # 0x1514f
callq 0xb390
testb $0x1, %al
jne 0x7565
jmp 0x7588
movq -0x10(%rbp), %rdi
callq 0x9910
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14dd1(%rip)     # 0x1c354
jmp 0x762e
movq -0x8(%rbp), %rdi
leaq 0xdbbf(%rip), %rsi      # 0x15152
callq 0xb390
testb $0x1, %al
jne 0x759e
jmp 0x75be
movq -0x10(%rbp), %rdi
callq 0x9c10
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14d98(%rip)     # 0x1c354
jmp 0x762c
movq -0x8(%rbp), %rdi
leaq 0xe3cb(%rip), %rsi      # 0x15994
callq 0xb390
testb $0x1, %al
jne 0x75d4
jmp 0x75f4
movq -0x10(%rbp), %rdi
callq 0xa110
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14d62(%rip)     # 0x1c354
jmp 0x762a
movq -0x8(%rbp), %rdi
leaq 0xdb5a(%rip), %rsi      # 0x15159
callq 0xb390
testb $0x1, %al
jne 0x760a
jmp 0x7628
movq -0x10(%rbp), %rdi
callq 0xa450
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $-0x1, %edx
cmovel %ecx, %eax
movl %eax, 0x14d2c(%rip)     # 0x1c354
jmp 0x762a
jmp 0x762c
jmp 0x762e
jmp 0x7630
jmp 0x7632
jmp 0x7634
jmp 0x7636
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x765b
movq -0x40(%rbp), %rdi
callq 0xb3c0
movq -0x40(%rbp), %rdi
movl $0xe8, %esi
callq 0x3300
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)