// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x40, %rcx
jne 0x880d
movq 0x20(%rax), %rbx
movq 0x28(%rax), %rax
testl %eax, %eax
jle 0x8787
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movsbl (%rbx,%rcx), %edx
addl $-0x30, %edx
cmpl $0xa, %edx
jae 0x8822
incq %rcx
cmpq %rcx, %rax
jne 0x876f
callq 0x3060
movq %rax, %r14
movl (%rax), %r12d
movl $0x0, (%rax)
leaq -0x30(%rbp), %r15
movq %rbx, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x33b0
cmpq %rbx, (%r15)
je 0x8886
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x8892
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x8892
testl %ecx, %ecx
jne 0x87d4
movl %r12d, (%r14)
movq 0x9b3d(%rip), %rdx      # 0x12318
movq 0x9b2e(%rip), %rcx      # 0x12310
subq %rcx, %rdx
shrq $0x3, %rdx
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %edx, %edx
je 0x8869
movl %edx, %edx
xorl %esi, %esi
movq (%rcx,%rsi,8), %rdi
testq %rdi, %rdi
je 0x8803
cmpl %eax, (%rdi)
je 0x8878
incq %rsi
cmpq %rsi, %rdx
jne 0x87f6
jmp 0x8869
movq 0x97bc(%rip), %rbx      # 0x11fd0
leaq 0x610e(%rip), %rsi      # 0xe929
movl $0x15, %edx
jmp 0x8835
movq 0x97a7(%rip), %rbx      # 0x11fd0
leaq 0x610f(%rip), %rsi      # 0xe93f
movl $0x17, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
movl $0x1, %esi
callq 0x6dcb
jmp 0x8869
leaq 0x61ce(%rip), %rdi      # 0xea5b
callq 0x3190
leaq 0x61c2(%rip), %rdi      # 0xea5b
callq 0x33f0
movq %rax, %rbx
jmp 0x88af
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x88af
movl %r12d, (%r14)
cmpl $0x2, %edx
jne 0x8910
movq %rbx, %rdi
callq 0x3360
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x34e0
movq 0x96ee(%rip), %rax      # 0x11fc0
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x3120
movq 0x96e8(%rip), %rdi      # 0x11fd0
leaq 0x6050(%rip), %rsi      # 0xe93f
movl $0x17, %edx
callq 0x3300
movq 0x96d0(%rip), %rdi      # 0x11fd0
callq 0x3140
leaq -0x30(%rbp), %rdi
callq 0x34d0
jmp 0x8973
cmpl $0x1, %edx
jne 0x89a1
movq %rbx, %rdi
callq 0x3360
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x34e0
movq 0x9691(%rip), %rax      # 0x11fc8
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x3120
movq 0x9683(%rip), %rdi      # 0x11fd0
leaq 0x5feb(%rip), %rsi      # 0xe93f
movl $0x17, %edx
callq 0x3300
movq 0x966b(%rip), %rdi      # 0x11fd0
callq 0x3140
leaq -0x30(%rbp), %rdi
callq 0x33e0
callq 0x34a0
jmp 0x8864
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x33e0
callq 0x34a0
jmp 0x89a1
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x34d0
callq 0x34a0
movq %rbx, %rdi
callq 0x3530
movq %rax, %rdi
callq 0x9d7a