// File: /workspace/github_cpp_makefile_star2_O2/brandoncanaday[P]1730sh/1730sh.cpp
// Function: main
int main(int argc, char * argv[]) {

  // prints shell logo
  print_logo();

  // set job control signal dispositions to SIG_IGN
  parent_signals();

  cout.setf(std::ios::unitbuf);
  cin.setf(std::ios::unitbuf);

  // changes to user's home dir upon shell init
  chdir_home();

  string input = "";
  bool hangingPipe = false;
  bool hangingQuote = false;
  
  // begin REPL loop
  while(1) { // exits when ^C

    // polls all of the currently running jobs for status changes
    check_current_jobs();
    
    // prompt
    if(!hangingPipe && !hangingQuote) {
      prompt();
    } else {
      cout << "> ";
    } // if/else

    // only reset input if not waiting on more (due to hanging pipe OR hanging quote). otherwise, append to it.
    if(!hangingPipe && !hangingQuote) {
      input = "";
      getline(cin,input);
      input = trim(input);
    } else {
      string tmp = "";
      getline(cin,tmp);
      tmp = trim(tmp);
      if(hangingQuote) {
	input = input + tmp;
      } else if(hangingPipe) {
	input = input + " " + tmp;
      } // if/else
    } // if/else

    // user just hit [enter]
    if(input == "") continue;

    // if user input actually contains something, check if valid
    if(isValidInput(input)) {
      if(hasQuotes(input) && !hasEvenQuotes(input)) {
	hangingQuote = true;
	continue;
      } // if
      hangingQuote = false;
      if(input[input.length()-1] == '|') {
	hangingPipe = true;
	continue;
      } // if
      hangingPipe = false;

      // if finally have valid input AND no hanging pipes/quotes, make Input obj and do stuff
      Input * job = new Input(input);
      int ** pipes = makePipes(job->getNumPipes());
      int fd_STDIN = STDIN_FILENO;
      int fd_STDOUT = STDOUT_FILENO;
      int fd_STDERR = STDERR_FILENO;
      int pid; 
      
      // sets and/or creates the destinations for any i/o redirection. default is STD[IN/OUT/ERR]_FILENO
      if(set_redirects(job,fd_STDIN,fd_STDOUT,fd_STDERR) == -1) { delete job; continue; } // if

      // command is either built-in || has no pipes
      if(job->getProcesses().size() == 1) {
	string command = job->getProcesses()[0].args[0];
	if(isBuiltIn(command)) { // does not involve fork/exec
	  do_redirects(fd_STDIN,fd_STDOUT,fd_STDERR);
	  close_redirects(fd_STDIN,fd_STDOUT,fd_STDERR);
	  callBuiltIn(command, job->getProcesses()[0].args, job);
	  continue;
	} else { // involves fork/exec
	  if((pid = fork()) == -1) {
	    nope_out("fork");
	  } else if(pid == 0) { // in child
	    child_signals(); // resets signal dispositions back to default
	    job->getProcesses()[0].PID = getpid(); // sets pid for bookkeeping
	    job->setJID(getpid()); // sets JID/PGID of current Input obj/Processes for bookkeeping
	    if(setpgid(getpid(),job->getJID()) == -1) { nope_out("setpgid"); } // sets pgid of process in system
	    if(job->isForeground()) {
	      if(tcsetpgrp(shell_terminal, job->getJID()) == -1) { nope_out("tcsetpgrp"); } // makes JID the foreground pgrp of the terminal
	    } // if
	    do_redirects(fd_STDIN,fd_STDOUT,fd_STDERR);
	    close_redirects(fd_STDIN,fd_STDOUT,fd_STDERR);
	    nice_exec(job->getProcesses()[0].args, pipes, job->getNumPipes());
	  } else { // in parent
	    job->getProcesses()[0].PID = pid; // sets pid for bookkeeping
	    job->setJID(pid); // sets JID/PGID of current Input obj/Processes for bookkeeping
	    if(setpgid(pid,job->getJID()) == -1) { nope_out("setpgid"); } // sets pgid of process in system
	  } // if/else
	  // after job has been launched
	  current_jobs.push_back(job); // add to vector of currently running jobs
	} // if/else
      } else { // command is a pipelined job
	for(unsigned int i = 0, size = job->getProcesses().size(); i < size; i++) {
	  if(i != size-1) { // not last process
	    if(pipe(pipes[i]) == -1) { nope_out("pipe"); } // if
	  } // if
	  if((pid = fork()) == -1) {
	    nope_out("fork");
	  } else if(pid == 0) { // in child
	    job->getProcesses()[i].PID = getpid(); // sets pid for bookkeeping
	    if(i == 0) { job->setJID(getpid()); } // sets JID/PGID of current Input obj/Processes for bookkeeping
	    if(setpgid(getpid(),job->getJID()) == -1) { nope_out("setpgid"); } // sets pgid of process in system
	    if(job->isForeground()) {
	      if(tcsetpgrp(shell_terminal, job->getJID()) == -1) { nope_out("tcsetpgrp"); } // makes JID the foreground pgrp of the terminal
	    } // if
	    child_signals(); // reset signal dispositions back to default
	    if(i == 0) { // first process
	      do_redirects(fd_STDIN,pipes[i][1],-1);
	      close_pipe(pipes[i],true);
	    } else if(i != size-1) { // some middle process
	      do_redirects(pipes[i-1][0],pipes[i][1],-1);
	      close_pipe(pipes[i-1],true);
	      close_pipe(pipes[i],true);
	    } else if(i == size-1) { // last process
	      do_redirects(pipes[i-1][0],fd_STDOUT,fd_STDERR);
	      close_pipe(pipes[i-1],true);
	    } // if/else
	    close_redirects(fd_STDIN,fd_STDOUT,fd_STDERR);
	    nice_exec(job->getProcesses()[i].args, pipes, job->getNumPipes());
	  } else { // in parent
	    job->getProcesses()[i].PID = pid; // sets pid for bookkeeping
	    if(i == 0) { job->setJID(pid); } // sets JID/PGID of current Input obj/Processes
	    if(setpgid(pid,job->getJID()) == -1) { nope_out("setpgid"); } // sets pgid of process in system
	    if(i != 0) {
	      close_pipe(pipes[i-1],true);
	    } // if
	  } // if/else	
	} // for	
	// after job has been launched
	current_jobs.push_back(job); // add to vector of currently running jobs
      } // if/else
      
      close_redirects(fd_STDIN,fd_STDOUT,fd_STDERR); // close i/o redirect fd's
      deletePipes(pipes,job->getNumPipes()); // delete dynamically-allocated pipefd[2] array

      // waits on last child of job if in foreground. if in background, it doesnt.
      if(job->isForeground()) {
	put_job_in_foreground(job,false);
      } else {
	put_job_in_background(job,false);
      } // if/else
    } else { // invalid syntax
      cout << "./1730sh: Invalid command syntax" << endl;
    } // if/else
  } // while
  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
callq 0x409b
callq 0x456f
movq 0xc8c7(%rip), %rdx      # 0xffc8
movq (%rdx), %rax
movq -0x18(%rax), %rax
movl $0x2000, %ecx           # imm = 0x2000
orl %ecx, 0x18(%rdx,%rax)
movq 0xc8c8(%rip), %rdx      # 0xffe0
movq (%rdx), %rax
movq -0x18(%rax), %rax
orl %ecx, 0x18(%rdx,%rax)
callq 0x46f6
leaq 0x83b3(%rip), %rsi      # 0xbae2
leaq -0x138(%rbp), %r12
leaq -0xc0(%rbp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x3100
movq $0x0, -0xa0(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
movq -0xa0(%rbp), %rax
movl %eax, %r14d
movl %ecx, -0x38(%rbp)
orb %cl, %r14b
callq 0x4797
testb $0x1, %r14b
je 0x3817
movq 0xc845(%rip), %rdi      # 0xffc8
leaq 0x687a(%rip), %rsi      # 0xa004
callq 0x3280
movq %r13, %rdi
leaq 0x8349(%rip), %rsi      # 0xbae2
leaq -0x90(%rbp), %rdx
callq 0x3100
movq 0xc834(%rip), %rdi      # 0xffe0
movq %r13, %rsi
callq 0x3070
leaq -0x1b8(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3380
leaq -0x90(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x9983
movq %r13, %rdi
movq %r15, %rsi
callq 0x3310
movq %r15, %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x3120
testb $0x1, -0x38(%rbp)
je 0x386f
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x75ba
movq %r12, %rdi
movq %r15, %rsi
callq 0x3310
jmp 0x38b6
callq 0x49d3
movq %r12, %rdi
leaq 0x82bc(%rip), %rsi      # 0xbae2
callq 0x34f0
movq 0xc7ae(%rip), %rdi      # 0xffe0
movq %r12, %rsi
callq 0x3070
leaq -0x1d8(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3380
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9983
movq %r12, %rdi
movq %r13, %rsi
callq 0x3310
movq %r13, %rdi
callq 0x3120
movq %rbx, %rdi
jmp 0x38c1
testb $0x1, -0xa0(%rbp)
je 0x38be
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
leaq 0x6e99(%rip), %rdx      # 0xa722
callq 0x761b
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x75f2
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3310
movq %rbx, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x3120
movq %r13, %rdi
callq 0x3120
movq %r12, %rdi
leaq 0x8212(%rip), %rsi      # 0xbae2
callq 0x7653
testb %al, %al
jne 0x376d
leaq -0x158(%rbp), %rdi
movq %r12, %rsi
callq 0x3380
leaq -0x158(%rbp), %rbx
movq %rbx, %rdi
callq 0x4baf
movl %eax, %r14d
movq %rbx, %rdi
callq 0x3120
testb %r14b, %r14b
je 0x396c
leaq -0xe8(%rbp), %rdi
movq %r12, %rsi
callq 0x3380
leaq -0xe8(%rbp), %rdi
callq 0x9ab9
testb %al, %al
je 0x398c
leaq -0x198(%rbp), %rdi
movq %r12, %rsi
callq 0x3380
leaq -0x198(%rbp), %rbx
movq %rbx, %rdi
callq 0x4d8c
movl %eax, %r14d
movq %rbx, %rdi
callq 0x3120
leaq -0xe8(%rbp), %rdi
callq 0x3120
movb $0x1, %cl
testb %r14b, %r14b
je 0x375d
jmp 0x3998
movq 0xc655(%rip), %rdi      # 0xffc8
leaq 0x66a9(%rip), %rsi      # 0xa023
callq 0x3280
movq %rax, %rdi
callq 0x3130
jmp 0x375a
leaq -0xe8(%rbp), %rdi
callq 0x3120
movq -0x138(%rbp), %rax
movq -0x130(%rbp), %rcx
cmpb $0x7c, -0x1(%rax,%rcx)
sete %al
movq %rax, -0xa0(%rbp)
je 0x3753
movl $0xe8, %edi
callq 0x3290
movq %rax, %r14
leaq -0x178(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x3380
movq %r14, %rdi
movq %rbx, %rsi
callq 0x85e4
movq %rbx, %rdi
callq 0x3120
movq %r14, -0x68(%rbp)
movq %r14, %rdi
callq 0x96a2
leaq -0x90(%rbp), %rbx
movl %eax, %edi
callq 0x4ddd
movq %rax, %r14
andl $0x0, -0x44(%rbp)
movl $0x1, -0x40(%rbp)
movl $0x2, -0x3c(%rbp)
movq -0x68(%rbp), %rdi
leaq -0x44(%rbp), %rsi
leaq -0x40(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0x4e35
movq -0x68(%rbp), %r15
cmpl $-0x1, %eax
je 0x3aa7
movq 0x30(%r15), %rcx
movq 0x38(%r15), %rax
subq %rcx, %rax
cmpq $0x28, %rax
jne 0x3ac6
movq 0x10(%rcx), %rsi
movq %r13, %rdi
callq 0x3380
movq %r13, %rdi
callq 0x522c
testb %al, %al
movb %al, -0x38(%rbp)
je 0x3c17
movl -0x44(%rbp), %ebx
movl -0x40(%rbp), %r15d
movl -0x3c(%rbp), %edx
movl %ebx, %edi
movl %r15d, %esi
movl %edx, -0x70(%rbp)
callq 0x52d5
movl %ebx, %edi
movl %r15d, %esi
movl -0x70(%rbp), %edx
callq 0x53b9
movq -0x68(%rbp), %rdx
movq 0x30(%rdx), %rsi
addq $0x10, %rsi
movq %r13, %rdi
callq 0x5497
jmp 0x3ca0
testq %r15, %r15
je 0x3ab4
movq %r15, %rdi
callq 0x7664
movl $0xe8, %esi
movq %r15, %rdi
callq 0x32a0
jmp 0x3753
cqto
pushq $0x28
popq %rcx
idivq %rcx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %eax, %ecx
movl %eax, %eax
imulq $0x28, %rax, %r15
imulq $0x28, %rcx, %rax
movq %rax, -0x70(%rbp)
movq %r14, -0x98(%rbp)
movq %r14, -0x38(%rbp)
xorl %r14d, %r14d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0xc8(%rbp)
cmpq %r14, %r15
je 0x3bfb
cmpq %r14, -0x70(%rbp)
je 0x3b43
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x3370
cmpl $-0x1, %eax
jne 0x3b43
movq %r13, %rdi
leaq 0x64f7(%rip), %rsi      # 0xa01e
leaq -0x90(%rbp), %rdx
callq 0x3100
movq %r13, %rdi
callq 0x76be
movq %r13, %rdi
callq 0x3120
callq 0x3090
cmpl $-0x1, %eax
je 0x3bc0
testl %eax, %eax
je 0x3ced
movq -0x68(%rbp), %rdi
movq 0x30(%rdi), %rcx
movl %eax, (%rcx,%r14)
testq %r14, %r14
jne 0x3b75
movl %eax, %ebx
movl %eax, %esi
callq 0x9666
movq -0x68(%rbp), %rdi
movl %ebx, %eax
movl (%rdi), %esi
movl %eax, %edi
callq 0x3470
cmpl $-0x1, %eax
jne 0x3ba9
movq %r13, %rdi
leaq 0x647f(%rip), %rsi      # 0xa00c
leaq -0x90(%rbp), %rdx
callq 0x3100
movq %r13, %rdi
callq 0x76be
movq %r13, %rdi
callq 0x3120
testq %r14, %r14
je 0x3be6
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rdi
pushq $0x1
popq %rsi
callq 0x5954
jmp 0x3be6
movq %r13, %rdi
leaq 0x643d(%rip), %rsi      # 0xa007
leaq -0x90(%rbp), %rdx
callq 0x3100
movq %r13, %rdi
callq 0x76be
movq %r13, %rdi
callq 0x3120
incq -0xc8(%rbp)
addq $0x28, %r14
addq $0x8, -0x38(%rbp)
jmp 0x3afd
leaq 0xc6e6(%rip), %rdi      # 0x102e8
leaq -0x68(%rbp), %rsi
callq 0x7752
movq -0x98(%rbp), %r14
jmp 0x3cb2
callq 0x3090
cmpl $-0x1, %eax
je 0x3c6d
testl %eax, %eax
je 0x3e6c
movq -0x68(%rbp), %rdi
movq 0x30(%rdi), %rcx
movl %eax, (%rcx)
movl %eax, %r15d
movl %eax, %esi
callq 0x9666
movq -0x68(%rbp), %rax
movl (%rax), %esi
movl %r15d, %edi
callq 0x3470
cmpl $-0x1, %eax
jne 0x3c90
movq %rbx, %rdi
leaq 0x63b2(%rip), %rsi      # 0xa00c
leaq -0x29(%rbp), %rdx
callq 0x3100
movq %rbx, %rdi
callq 0x76be
jmp 0x3c88
movq %rbx, %rdi
leaq 0x6390(%rip), %rsi      # 0xa007
leaq -0x29(%rbp), %rdx
callq 0x3100
movq %rbx, %rdi
callq 0x76be
movq %rbx, %rdi
callq 0x3120
leaq 0xc651(%rip), %rdi      # 0x102e8
leaq -0x68(%rbp), %rsi
callq 0x7752
movq %r13, %rdi
callq 0x3120
cmpb $0x0, -0x38(%rbp)
jne 0x3753
movl -0x44(%rbp), %edi
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x53b9
movq -0x68(%rbp), %rdi
callq 0x96a2
movq %r14, %rdi
movl %eax, %esi
callq 0x59fd
movq -0x68(%rbp), %rdi
cmpb $0x1, 0x4(%rdi)
jne 0x3753
xorl %esi, %esi
callq 0x5a46
jmp 0x3753
callq 0x33e0
movq -0x68(%rbp), %r15
movq 0x30(%r15), %rcx
movl %eax, (%rcx,%r14)
testq %r14, %r14
jne 0x3d12
callq 0x33e0
movq %r15, %rdi
movl %eax, %esi
callq 0x9666
callq 0x33e0
movq -0x68(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x3470
cmpl $-0x1, %eax
jne 0x3d5b
leaq 0x62dc(%rip), %rsi      # 0xa00c
leaq -0xc0(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x3100
leaq -0xc0(%rbp), %rdi
callq 0x76be
leaq -0xc0(%rbp), %rdi
callq 0x3120
movq -0x68(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x3da9
movl 0xc575(%rip), %edi      # 0x102e0
movl (%rax), %esi
callq 0x3390
cmpl $-0x1, %eax
jne 0x3da9
leaq 0x6296(%rip), %rsi      # 0xa014
leaq -0xc0(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x3100
leaq -0xc0(%rbp), %rdi
callq 0x76be
leaq -0xc0(%rbp), %rdi
callq 0x3120
callq 0x5666
testq %r14, %r14
jne 0x3dca
movl -0x44(%rbp), %edi
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
pushq $-0x1
popq %rdx
callq 0x52d5
jmp 0x3e15
movl -0xc8(%rbp), %eax
movq -0x98(%rbp), %rcx
leaq (%rcx,%rax,8), %r15
movq (%rcx,%rax,8), %rax
movl (%rax), %edi
cmpq %r14, -0x70(%rbp)
jne 0x3df8
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x52d5
movq %r15, -0x38(%rbp)
jmp 0x3e15
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
pushq $-0x1
popq %rdx
callq 0x52d5
movq (%r15), %rdi
pushq $0x1
popq %rsi
callq 0x5954
movq -0x38(%rbp), %rax
movq (%rax), %rdi
pushq $0x1
popq %rsi
callq 0x5954
movl -0x44(%rbp), %edi
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x53b9
movq -0x68(%rbp), %rax
movq 0x30(%rax), %rax
leaq (%rax,%r14), %rsi
addq $0x10, %rsi
leaq -0x100(%rbp), %rdi
callq 0x76d2
movq -0x68(%rbp), %rdi
callq 0x96a2
leaq -0x100(%rbp), %rdi
movq -0x98(%rbp), %rsi
movl %eax, %edx
callq 0x5821
movq %r14, %r12
callq 0x5666
callq 0x33e0
movq -0x68(%rbp), %rbx
movq 0x30(%rbx), %rcx
movl %eax, (%rcx)
callq 0x33e0
movq %rbx, %rdi
movl %eax, %esi
callq 0x9666
callq 0x33e0
movq -0x68(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x3470
cmpl $-0x1, %eax
jne 0x3ed8
leaq 0x615c(%rip), %rsi      # 0xa00c
leaq -0x90(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3100
leaq -0x90(%rbp), %rdi
callq 0x76be
leaq -0x90(%rbp), %rdi
callq 0x3120
movq -0x68(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x3f23
movl 0xc3f8(%rip), %edi      # 0x102e0
movl (%rax), %esi
callq 0x3390
cmpl $-0x1, %eax
jne 0x3f23
leaq 0x6119(%rip), %rsi      # 0xa014
leaq -0x90(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3100
leaq -0x90(%rbp), %rdi
callq 0x76be
leaq -0x90(%rbp), %rdi
callq 0x3120
movl -0x44(%rbp), %ebx
movl -0x40(%rbp), %r14d
movl -0x3c(%rbp), %r15d
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x52d5
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x53b9
movq -0x68(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x10, %rsi
leaq -0x118(%rbp), %rdi
callq 0x76d2
movq -0x68(%rbp), %rdi
callq 0x96a2
leaq -0x118(%rbp), %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x5821
jmp 0x3fbc
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x7726
jmp 0x4076
jmp 0x4073
jmp 0x3fbc
jmp 0x4073
jmp 0x3fbc
jmp 0x4073
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x7726
jmp 0x4087
jmp 0x4073
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
jmp 0x405a
jmp 0x4073
jmp 0x4073
jmp 0x4084
jmp 0x4084
jmp 0x4073
jmp 0x4073
jmp 0x4084
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
callq 0x3120
jmp 0x4002
movq %rax, %rbx
movl $0xe8, %esi
movq %r14, %rdi
callq 0x32a0
jmp 0x4087
jmp 0x4084
jmp 0x4073
jmp 0x4084
jmp 0x4073
jmp 0x4084
jmp 0x4084
jmp 0x4084
jmp 0x4084
jmp 0x4084
jmp 0x4084
jmp 0x4084
jmp 0x4073
movq %rax, %rbx
leaq -0x158(%rbp), %rdi
jmp 0x407d
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x407d
jmp 0x4084
jmp 0x4073
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
jmp 0x405a
jmp 0x4073
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x3120
jmp 0x4076
jmp 0x4073
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
jmp 0x407d
jmp 0x4084
jmp 0x4084
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x3120
jmp 0x4087
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34b0