// File: /workspace/github_cpp_makefile_star2_O2/brandoncanaday[P]1730sh/1730sh.cpp
// Function: exit_builtin(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&)
int exit_builtin(const vector<string> & args) {
  int status = -1;
  if(args.size() == 1) { // 'exit'
    status = last_exit_status;
    cout << "1730sh: Exited with status: " << status << endl;
    return status;
  } else if(args.size() == 2) { // 'exit [int]'
    bool isNumber = true;
    for(int i = 0, size = args[1].size(); i < size; i++) {
      if(!isdigit(args[1][i])) { // if (number[i] > '9' || number[i] < '0')
	isNumber = false;
	break;
      } // if
    } // for
    if(isNumber) {
      try {
	status = stoi(args[1],0,10);
	cout << "1730sh: Exited with status: " << status << endl;
      } catch(invalid_argument invalidargument) {
	cout << "1730sh: exit: Invalid exit value" << endl;
	status = -1;
      } catch(out_of_range outofrange) {
	cout << "1730sh: exit: Invalid exit value" << endl;
	status = -1;
      } // try/catch
      return status;
    } else {
      cout << "1730sh: exit: Invalid exit value" << endl;
      status = -1;
    } // if/else
    return status;
  } else { // invalid syntax
    cout << "Usage: exit [N]" << endl;
    status = -1;
    return status;
  } // if/else
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rax
movq (%rdi), %rdi
movq 0x8(%rax), %rax
subq %rdi, %rax
sarq $0x5, %rax
cmpq $0x2, %rax
je 0x6395
cmpq $0x1, %rax
jne 0x63ca
movl 0x9f71(%rip), %ebx      # 0x102dc
movq 0x9c56(%rip), %rdi      # 0xffc8
leaq 0x4de5(%rip), %rsi      # 0xb15e
callq 0x3280
movq %rax, %rdi
movl %ebx, %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3130
jmp 0x641b
movl 0x28(%rdi), %eax
addq $0x20, %rdi
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
cmpq %rcx, %rax
je 0x63ea
movq (%rdi), %rdx
movsbl (%rdx,%rcx), %edx
addl $-0x30, %edx
incq %rcx
cmpl $0xa, %edx
jb 0x63a3
movq 0x9c07(%rip), %rdi      # 0xffc8
leaq 0x4db3(%rip), %rsi      # 0xb17b
jmp 0x63d8
movq 0x9bf7(%rip), %rdi      # 0xffc8
leaq 0x4dc4(%rip), %rsi      # 0xb19c
callq 0x3280
movq %rax, %rdi
callq 0x3130
pushq $-0x1
popq %rbx
jmp 0x641b
pushq $0xa
popq %rdx
xorl %esi, %esi
callq 0x7802
movl %eax, %ebx
movq 0x9bcb(%rip), %rdi      # 0xffc8
leaq 0x4d5a(%rip), %rsi      # 0xb15e
callq 0x3280
movq %rax, %rdi
movl %ebx, %esi
callq 0x34a0
movq %rax, %rdi
callq 0x3130
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rbx
cmpl $0x2, %edx
jne 0x646e
movq %rbx, %rdi
callq 0x3320
leaq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x7856
movq %rbx, %rdi
callq 0x3110
movq 0x9b79(%rip), %rdi      # 0xffc8
leaq 0x4d25(%rip), %rsi      # 0xb17b
callq 0x3280
movq %rax, %rdi
callq 0x3130
leaq -0x18(%rbp), %rdi
callq 0x3480
jmp 0x64b3
cmpl $0x1, %edx
jne 0x64e1
movq %rbx, %rdi
callq 0x3320
leaq -0x18(%rbp), %rdi
movq %rax, %rsi
callq 0x7824
movq %rbx, %rdi
callq 0x3110
movq 0x9b32(%rip), %rdi      # 0xffc8
leaq 0x4cde(%rip), %rsi      # 0xb17b
callq 0x3280
movq %rax, %rdi
callq 0x3130
leaq -0x18(%rbp), %rdi
callq 0x33b0
callq 0x3450
jmp 0x63e5
movq %rax, %rbx
leaq -0x18(%rbp), %rdi
callq 0x33b0
callq 0x3450
jmp 0x64e1
movq %rax, %rbx
leaq -0x18(%rbp), %rdi
callq 0x3480
callq 0x3450
movq %rbx, %rdi
callq 0x34b0
movq %rax, %rdi
callq 0x7847