// File: brandoncanaday[P]1730sh/1730sh.cpp
// Function: fg_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 fg_builtin(const vector<string> & args) {
  if(args.size() != 2) {
    cout << "1730sh: Usage: fg JID" << endl;
  } else {
    pid_t JID;
    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 {
	JID = stoi(args[1],0,10);
	for(unsigned int i = 0, s = current_jobs.size(); i < s; i++) {
	  if(current_jobs[i] != nullptr) {
	    if(current_jobs[i]->getJID() == JID) {
	      put_job_in_foreground(current_jobs[i],true);
	      return 0;
	    } // if
	  } // if
	} // for	
      } catch(invalid_argument invalidargument) {
	cout << "1730sh: fg: Invalid JID" << endl;
      } catch(out_of_range outofrange) {
	cout << "1730sh: fg: Invalid JID" << endl;
      } // try/catch
    } else {
      cout << "1730sh: fg: Invalid JID" << endl;
    } // if/else
  } // if/else
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb7a0
cmpq $0x2, %rax
je 0x9955
movq 0x12693(%rip), %rdi     # 0x1bfc8
leaq 0xbfed(%rip), %rsi      # 0x15929
callq 0x32e0
movq %rax, %rdi
movq 0x1265d(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x9be7
movb $0x1, -0x15(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xbb00
movq %rax, %rdi
callq 0x3210
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x99bb
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xbb00
movq %rax, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x3350
movsbl (%rax), %edi
callq 0x32b0
cmpl $0x0, %eax
jne 0x99ae
movb $0x0, -0x15(%rbp)
jmp 0x99bb
jmp 0x99b0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9979
testb $0x1, -0x15(%rbp)
je 0x9bc3
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0xbb00
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xbb20
movl %eax, -0x5c(%rbp)
jmp 0x99e9
movl -0x5c(%rbp), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x30(%rbp)
leaq 0x12963(%rip), %rdi     # 0x1c360
callq 0xb910
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x9b82
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x12943(%rip), %rdi     # 0x1c360
callq 0xb930
cmpq $0x0, (%rax)
je 0x9b72
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x12928(%rip), %rdi     # 0x1c360
callq 0xb930
movq (%rax), %rdi
callq 0xb500
movl %eax, -0x60(%rbp)
jmp 0x9a4a
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x9b70
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x128fe(%rip), %rdi     # 0x1c360
callq 0xb930
movq (%rax), %rdi
movl $0x1, %esi
callq 0x7ea0
jmp 0x9a76
movl $0x0, -0x4(%rbp)
jmp 0x9bee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x64(%rbp)
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x9afd
movq -0x28(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x33c0
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xbbb0
movq -0x78(%rbp), %rdi
callq 0x3120
movq 0x12502(%rip), %rdi     # 0x1bfc8
leaq 0xbe72(%rip), %rsi      # 0x1593f
callq 0x32e0
movq %rax, -0x70(%rbp)
jmp 0x9ad8
movq -0x70(%rbp), %rdi
movq 0x124c5(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x9aea
leaq -0x58(%rbp), %rdi
callq 0x3550
callq 0x3530
jmp 0x9be5
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x9bfa
movq -0x28(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x33c0
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xbb60
movq -0x88(%rbp), %rdi
callq 0x3120
movq 0x1248c(%rip), %rdi     # 0x1bfc8
leaq 0xbdfc(%rip), %rsi      # 0x1593f
callq 0x32e0
movq %rax, -0x80(%rbp)
jmp 0x9b4e
movq -0x80(%rbp), %rdi
movq 0x1244f(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x9b60
leaq -0x48(%rbp), %rdi
callq 0x3480
callq 0x3530
jmp 0x9af8
jmp 0x9b72
jmp 0x9b74
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9a05
jmp 0x9af8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3480
callq 0x3530
jmp 0x9ba3
jmp 0x9bfa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3550
callq 0x3530
jmp 0x9bc1
jmp 0x9bfa
movq 0x123fe(%rip), %rdi     # 0x1bfc8
leaq 0xbd6e(%rip), %rsi      # 0x1593f
callq 0x32e0
movq %rax, %rdi
movq 0x123c8(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x9be7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x3580
movq %rax, %rdi
callq 0xbba0
nopl (%rax,%rax)