// File: brandoncanaday[P]1730sh/1730sh.cpp
// Function: bg_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 bg_builtin(const vector<string> & args) {
  if(args.size() != 2) {
    cout << "1730sh: Usage: bg 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_background(current_jobs[i],true);
	      return 0;
	    } // if
	  } // if
	} // for	
      } catch(invalid_argument invalidargument) {
	cout << "1730sh: bg: Invalid JID" << endl;
      } catch(out_of_range outofrange) {
	cout << "1730sh: bg: Invalid JID" << endl;
      } // try/catch
    } else {
      cout << "1730sh: bg: 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 0x9655
movq 0x12993(%rip), %rdi     # 0x1bfc8
leaq 0xc31b(%rip), %rsi      # 0x15957
callq 0x32e0
movq %rax, %rdi
movq 0x1295d(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x98e7
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 0x96bb
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 0x96ae
movb $0x0, -0x15(%rbp)
jmp 0x96bb
jmp 0x96b0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x9679
testb $0x1, -0x15(%rbp)
je 0x98c3
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 0x96e9
movl -0x5c(%rbp), %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x30(%rbp)
leaq 0x12c63(%rip), %rdi     # 0x1c360
callq 0xb910
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x34(%rbp), %eax
jae 0x9882
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x12c43(%rip), %rdi     # 0x1c360
callq 0xb930
cmpq $0x0, (%rax)
je 0x9872
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x12c28(%rip), %rdi     # 0x1c360
callq 0xb930
movq (%rax), %rdi
callq 0xb500
movl %eax, -0x60(%rbp)
jmp 0x974a
movl -0x60(%rbp), %eax
cmpl -0x14(%rbp), %eax
jne 0x9870
movl -0x30(%rbp), %eax
movl %eax, %esi
leaq 0x12bfe(%rip), %rdi     # 0x1c360
callq 0xb930
movq (%rax), %rdi
movl $0x1, %esi
callq 0x80d0
jmp 0x9776
movl $0x0, -0x4(%rbp)
jmp 0x98ee
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 0x97fd
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 0x12802(%rip), %rdi     # 0x1bfc8
leaq 0xc1a0(%rip), %rsi      # 0x1596d
callq 0x32e0
movq %rax, -0x70(%rbp)
jmp 0x97d8
movq -0x70(%rbp), %rdi
movq 0x127c5(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x97ea
leaq -0x58(%rbp), %rdi
callq 0x3550
callq 0x3530
jmp 0x98e5
movl -0x64(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x98fa
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 0x1278c(%rip), %rdi     # 0x1bfc8
leaq 0xc12a(%rip), %rsi      # 0x1596d
callq 0x32e0
movq %rax, -0x80(%rbp)
jmp 0x984e
movq -0x80(%rbp), %rdi
movq 0x1274f(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x9860
leaq -0x48(%rbp), %rdi
callq 0x3480
callq 0x3530
jmp 0x97f8
jmp 0x9872
jmp 0x9874
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x9705
jmp 0x97f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3480
callq 0x3530
jmp 0x98a3
jmp 0x98fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3550
callq 0x3530
jmp 0x98c1
jmp 0x98fa
movq 0x126fe(%rip), %rdi     # 0x1bfc8
leaq 0xc09c(%rip), %rsi      # 0x1596d
callq 0x32e0
movq %rax, %rdi
movq 0x126c8(%rip), %rsi     # 0x1bfa8
callq 0x3330
jmp 0x98e7
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)