// File: /workspace/github_cpp_makefile_star2_O1/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 0x8842
movq 0x28(%rax), %rcx
testl %ecx, %ecx
jle 0x8799
movq 0x20(%rax), %rdx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %esi, %esi
movsbl (%rdx,%rsi), %edi
addl $-0x30, %edi
cmpl $0xa, %edi
jae 0x8857
incq %rsi
cmpq %rsi, %rcx
jne 0x8781
movq 0x20(%rax), %rbx
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 0x88be
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x88ca
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x88ca
testl %ecx, %ecx
jne 0x87ea
movl %r12d, (%r14)
movq 0x9b27(%rip), %rdx      # 0x12318
movq 0x9b18(%rip), %rcx      # 0x12310
subq %rcx, %rdx
shrq $0x3, %rdx
testl %edx, %edx
setne %bl
je 0x8899
movl %edx, %edx
movq %rdx, %rsi
negq %rsi
movl $0x1, %r8d
movq -0x8(%rcx,%r8,8), %rdi
testq %rdi, %rdi
je 0x882a
cmpl %eax, (%rdi)
je 0x88ab
cmpq %rdx, %r8
setb %bl
leaq (%rsi,%r8), %rdi
incq %rdi
incq %r8
cmpq $0x1, %rdi
jne 0x8818
jmp 0x8899
movq 0x9787(%rip), %rbx      # 0x11fd0
leaq 0x60d9(%rip), %rsi      # 0xe929
movl $0x15, %edx
jmp 0x886a
movq 0x9772(%rip), %rbx      # 0x11fd0
leaq 0x60da(%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, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %esi
callq 0x6dc8
xorl %eax, %eax
testb $0x1, %bl
je 0x8899
jmp 0x889e
leaq 0x6196(%rip), %rdi      # 0xea5b
callq 0x3190
leaq 0x618a(%rip), %rdi      # 0xea5b
callq 0x33f0
movq %rax, %rbx
jmp 0x88e7
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x88e7
movl %r12d, (%r14)
cmpl $0x2, %edx
jne 0x8948
movq %rbx, %rdi
callq 0x3360
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x34e0
movq 0x96b6(%rip), %rax      # 0x11fc0
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x3120
movq 0x96b0(%rip), %rdi      # 0x11fd0
leaq 0x6018(%rip), %rsi      # 0xe93f
movl $0x17, %edx
callq 0x3300
movq 0x9698(%rip), %rdi      # 0x11fd0
callq 0x3140
leaq -0x30(%rbp), %rdi
callq 0x34d0
jmp 0x89ab
cmpl $0x1, %edx
jne 0x89d9
movq %rbx, %rdi
callq 0x3360
leaq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x34e0
movq 0x9659(%rip), %rax      # 0x11fc8
addq $0x10, %rax
movq %rax, (%r14)
movq %rbx, %rdi
callq 0x3120
movq 0x964b(%rip), %rdi      # 0x11fd0
leaq 0x5fb3(%rip), %rsi      # 0xe93f
movl $0x17, %edx
callq 0x3300
movq 0x9633(%rip), %rdi      # 0x11fd0
callq 0x3140
leaq -0x30(%rbp), %rdi
callq 0x33e0
callq 0x34a0
jmp 0x8899
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x33e0
callq 0x34a0
jmp 0x89d9
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x34d0
callq 0x34a0
movq %rbx, %rdi
callq 0x3530
movq %rax, %rdi
callq 0x9dcc