// File: /workspace/github_cpp_makefile_star2_O1/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 0x4a84
callq 0x56c9
movq 0xe2cf(%rip), %rdx      # 0x11fd0
movq (%rdx), %rax
movq -0x18(%rax), %rax
movl $0x2000, %ecx           # imm = 0x2000
orl %ecx, 0x18(%rdx,%rax)
movq 0xe2c8(%rip), %r14      # 0x11fe0
movq (%r14), %rax
movq -0x18(%rax), %rax
orl %ecx, 0x18(%r14,%rax)
callq 0x578b
leaq -0xb0(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xadd7(%rip), %rdx      # 0xeb12
leaq -0xc0(%rbp), %r12
movq %r12, %rdi
movq %rdx, %rsi
callq 0xa038
movq $0x0, -0xc8(%rbp)
xorl %ebx, %ebx
movq -0xc8(%rbp), %rax
movl %eax, %r15d
movl %ebx, -0x30(%rbp)
orb %bl, %r15b
callq 0x5859
testb $0x1, %r15b
je 0x3d8f
movl $0x2, %edx
movq 0xe24f(%rip), %rdi      # 0x11fd0
leaq 0x927c(%rip), %rsi      # 0xd004
callq 0x3300
jmp 0x3d94
callq 0x5b6f
testb $0x1, %r15b
je 0x3eb4
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0xad61(%rip), %rdx      # 0xeb12
movq %rdx, %rsi
callq 0xa038
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
callq 0x3560
leaq -0x150(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
addq %rsi, %rdx
leaq -0x160(%rbp), %r13
movq %r13, %rdi
callq 0x9f9e
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc4f9
leaq -0x60(%rbp), %rdi
movq %rbx, %rsi
callq 0x3350
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3e44
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x3e66
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x32c0
testb $0x1, -0x30(%rbp)
je 0x3f75
leaq -0xa0(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
leaq -0x60(%rbp), %rdx
callq 0x9b5c
movq %r12, %rdi
movq %r13, %rsi
callq 0x3350
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x405b
movq -0x90(%rbp), %rsi
jmp 0x4053
movq -0xb8(%rbp), %rdx
movq %r12, %rdi
xorl %esi, %esi
leaq 0xac4b(%rip), %rcx      # 0xeb12
xorl %r8d, %r8d
callq 0x3460
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3560
leaq -0x170(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x180(%rbp), %r13
movq %r13, %rdi
callq 0x9f9e
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc4f9
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3350
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x3f52
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x4074
movq -0x170(%rbp), %rsi
jmp 0x406c
testb $0x1, -0xc8(%rbp)
je 0x405b
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x9f9e
movq %rbx, %rdi
leaq 0x9771(%rip), %rsi      # 0xd722
callq 0x3570
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %rbx, %rdi
callq 0x30c0
leaq -0x90(%rbp), %r13
movq %r13, -0xa0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3ff6
movq %rdx, -0xa0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
jmp 0x3ffe
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, -0x98(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r12, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3350
movq -0xa0(%rbp), %rdi
cmpq %r13, %rdi
je 0x4042
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x405b
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4074
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %r12, %rdi
leaq 0xaa94(%rip), %rsi      # 0xeb12
callq 0x30b0
testl %eax, %eax
je 0x3d6a
leaq -0x110(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %rdi
callq 0x9f9e
leaq -0x120(%rbp), %rdi
callq 0x5e0e
movl %eax, %r15d
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x40e7
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x32c0
testb %r15b, %r15b
je 0x41c7
leaq -0xf0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x100(%rbp), %rdi
callq 0x9f9e
leaq -0x100(%rbp), %rdi
callq 0xc6d1
movl %eax, %r15d
testb %al, %al
je 0x416e
leaq -0x198(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x9f9e
leaq -0x1a8(%rbp), %rdi
callq 0x6030
movl %eax, %r13d
xorb $0x1, %r13b
jmp 0x4171
xorl %r13d, %r13d
testb %r15b, %r15b
je 0x4198
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x4198
movq -0x198(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x41ba
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x32c0
movb $0x1, %bl
testb %r13b, %r13b
jne 0x3d5a
jmp 0x4219
movl $0x20, %edx
movq 0xddfd(%rip), %rdi      # 0x11fd0
leaq 0x8e49(%rip), %rsi      # 0xd023
callq 0x3300
movl -0x30(%rbp), %ebx
movq 0xdde7(%rip), %rcx      # 0x11fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0xddc9(%rip), %rdi      # 0x11fd0
callq 0x3040
movq %rax, %rdi
callq 0x31b0
jmp 0x3d5a
movq -0xc0(%rbp), %r15
movq -0xb8(%rbp), %r13
cmpb $0x7c, -0x1(%r15,%r13)
sete %al
movq %rax, -0xc8(%rbp)
je 0x3d58
movl $0xe8, %edi
callq 0x32b0
movq %rax, -0x30(%rbp)
leaq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
addq %r15, %r13
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9f9e
movq -0x30(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xa998
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x42a2
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %r15, -0x80(%rbp)
movq %r15, %rdi
callq 0xc0d0
movl %eax, %edi
callq 0x6090
movq %rax, %rbx
movl $0x0, -0x3c(%rbp)
movl $0x1, -0x38(%rbp)
movl $0x2, -0x34(%rbp)
movq -0x80(%rbp), %rdi
leaq -0x3c(%rbp), %rsi
leaq -0x38(%rbp), %rdx
leaq -0x34(%rbp), %rcx
callq 0x60f0
movq -0x80(%rbp), %r15
cmpl $-0x1, %eax
je 0x437f
movq 0x30(%r15), %rcx
movq 0x38(%r15), %rax
subq %rcx, %rax
cmpq $0x28, %rax
jne 0x43a2
movq %rbx, -0xd0(%rbp)
movq 0x10(%rcx), %rax
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rbx
movq %rbx, %rdi
callq 0x9f9e
movq %rbx, %rdi
callq 0x676a
testb %al, %al
movb %al, -0x30(%rbp)
je 0x44b5
movl -0x3c(%rbp), %r15d
movl -0x38(%rbp), %r13d
movl -0x34(%rbp), %edx
movl %r15d, %edi
movl %r13d, %esi
movl %edx, %ebx
callq 0x6817
movl %r15d, %edi
movl %r13d, %esi
movl %ebx, %edx
callq 0x6887
movq -0x80(%rbp), %rdx
movq 0x30(%rdx), %rsi
addq $0x10, %rsi
leaq -0x60(%rbp), %rdi
callq 0x68ed
jmp 0x453b
testq %r15, %r15
je 0x3d58
movq %r15, %rdi
callq 0x9bc0
movl $0xe8, %esi
movq %r15, %rdi
callq 0x32c0
jmp 0x3d58
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
testl %eax, %eax
je 0x4491
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addl %eax, %ecx
movl %eax, %eax
shlq $0x3, %rcx
leaq (%rcx,%rcx,4), %rcx
movq %rcx, -0xe0(%rbp)
shlq $0x3, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x188(%rbp)
movq %rbx, -0x30(%rbp)
xorl %r13d, %r13d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0xd8(%rbp)
cmpq %r13, -0xe0(%rbp)
je 0x4414
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
cmpl $-0x1, %eax
je 0x4643
callq 0x3090
testl %eax, %eax
je 0x45a0
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x4603
movq -0x80(%rbp), %rdi
movq 0x30(%rdi), %rax
movl %r15d, (%rax,%r13)
testq %r13, %r13
jne 0x4446
movl %r15d, %esi
callq 0xc092
movq -0x80(%rbp), %rax
movl (%rax), %esi
movl %r15d, %edi
callq 0x34c0
cmpl $-0x1, %eax
je 0x4623
testq %r13, %r13
je 0x4474
movq -0x30(%rbp), %rax
movq -0x8(%rax), %rdi
movl $0x1, %esi
callq 0x6d31
incq -0xd8(%rbp)
addq $0x28, %r13
addq $0x8, -0x30(%rbp)
cmpq %r13, -0x188(%rbp)
jne 0x43f6
movq 0xde80(%rip), %rsi      # 0x12318
cmpq 0xde81(%rip), %rsi      # 0x12320
je 0x4519
movq -0x80(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xde68(%rip)      # 0x12318
jmp 0x4565
callq 0x3090
testl %eax, %eax
je 0x4773
movl %eax, %r15d
cmpl $-0x1, %eax
je 0x47d3
movq -0x80(%rbp), %rdi
movq 0x30(%rdi), %rax
movl %r15d, (%rax)
movl %r15d, %esi
callq 0xc092
movq -0x80(%rbp), %rax
movl (%rax), %esi
movl %r15d, %edi
callq 0x34c0
cmpl $-0x1, %eax
je 0x47f9
movq 0xde19(%rip), %rsi      # 0x12318
cmpq 0xde1a(%rip), %rsi      # 0x12320
je 0x452b
movq -0x80(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xde01(%rip)      # 0x12318
jmp 0x453b
leaq 0xddf0(%rip), %rdi      # 0x12310
leaq -0x80(%rbp), %rdx
callq 0xa1b4
jmp 0x4565
leaq 0xddde(%rip), %rdi      # 0x12310
leaq -0x80(%rbp), %rdx
callq 0xa1b4
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4554
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
cmpb $0x0, -0x30(%rbp)
movq -0xd0(%rbp), %rbx
jne 0x3d58
movl -0x3c(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6887
movq -0x80(%rbp), %rdi
callq 0xc0d0
movq %rbx, %rdi
movl %eax, %esi
callq 0x6d83
movq -0x80(%rbp), %rdi
cmpb $0x1, 0x4(%rdi)
jne 0x3d58
xorl %esi, %esi
callq 0x6dc8
jmp 0x3d58
movq %rbx, %r14
callq 0x3410
movq -0x80(%rbp), %rbx
movq 0x30(%rbx), %rcx
movl %eax, (%rcx,%r13)
testq %r13, %r13
jne 0x45c8
callq 0x3410
movq %rbx, %rdi
movl %eax, %esi
callq 0xc092
callq 0x3410
movq -0x80(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x34c0
cmpl $-0x1, %eax
jne 0x4674
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8a17(%rip), %rsi      # 0xd00c
leaq 0x8a17(%rip), %rdx      # 0xd013
callq 0xa038
jmp 0x4661
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x89f2(%rip), %rsi      # 0xd007
leaq 0x89ef(%rip), %rdx      # 0xd00b
callq 0xa038
jmp 0x4661
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x89d7(%rip), %rsi      # 0xd00c
leaq 0x89d7(%rip), %rdx      # 0xd013
callq 0xa038
jmp 0x4661
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x89c9(%rip), %rsi      # 0xd01e
leaq 0x89c6(%rip), %rdx      # 0xd022
callq 0xa038
movq -0x60(%rbp), %rdi
callq 0x3240
movl $0x1, %edi
callq 0x3330
movq -0x80(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x46b0
movl 0xdc84(%rip), %edi      # 0x12308
movl (%rax), %esi
callq 0x33c0
cmpl $-0x1, %eax
jne 0x46b0
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8972(%rip), %rsi      # 0xd014
leaq 0x8974(%rip), %rdx      # 0xd01d
callq 0xa038
jmp 0x4661
callq 0x6ada
testq %r13, %r13
jne 0x46d3
movl -0x3c(%rbp), %edi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6817
jmp 0x471e
movl -0xd8(%rbp), %eax
leaq (%r14,%rax,8), %rbx
movq (%r14,%rax,8), %rax
movl (%rax), %edi
cmpq %r13, -0xe0(%rbp)
jne 0x46fd
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6817
movq %rbx, -0x30(%rbp)
jmp 0x471e
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6817
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x6d31
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x6d31
movl -0x3c(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6887
movq -0x80(%rbp), %rax
movq 0x30(%rax), %rax
leaq (%rax,%r13), %rsi
addq $0x10, %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x9c82
movq -0x80(%rbp), %rdi
callq 0xc0d0
leaq -0x1c0(%rbp), %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x6ba5
callq 0x6ada
callq 0x3410
movq -0x80(%rbp), %rbx
movq 0x30(%rbx), %rcx
movl %eax, (%rcx)
callq 0x3410
movq %rbx, %rdi
movl %eax, %esi
callq 0xc092
callq 0x3410
movq -0x80(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x34c0
cmpl $-0x1, %eax
jne 0x4829
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8847(%rip), %rsi      # 0xd00c
leaq 0x8847(%rip), %rdx      # 0xd013
callq 0xa038
jmp 0x481d
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x881c(%rip), %rsi      # 0xd007
leaq 0x8819(%rip), %rdx      # 0xd00b
callq 0xa038
jmp 0x481d
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x87fb(%rip), %rsi      # 0xd00c
leaq 0x87fb(%rip), %rdx      # 0xd013
callq 0xa038
movq -0xa0(%rbp), %rdi
jmp 0x4665
movq -0x80(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x486b
movl 0xdacf(%rip), %edi      # 0x12308
movl (%rax), %esi
callq 0x33c0
cmpl $-0x1, %eax
jne 0x486b
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x87b7(%rip), %rsi      # 0xd014
leaq 0x87b9(%rip), %rdx      # 0xd01d
callq 0xa038
jmp 0x481d
movl -0x3c(%rbp), %ebx
movl -0x38(%rbp), %r14d
movl -0x34(%rbp), %r15d
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6817
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6887
movq -0x80(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x10, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x9c82
movq -0x80(%rbp), %rdi
callq 0xc0d0
leaq -0x1d8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movl %eax, %edx
callq 0x6ba5
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
callq 0x9d16
jmp 0x4a3c
jmp 0x4a39
jmp 0x4a39
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x9d16
jmp 0x4a5a
jmp 0x4a39
jmp 0x4a39
jmp 0x4a39
jmp 0x4a57
jmp 0x4a57
jmp 0x4a39
movq %rax, %rbx
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x4940
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4940
movq %rax, %rbx
movl $0xe8, %esi
movq -0x30(%rbp), %rdi
jmp 0x4a50
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
jmp 0x4a57
movq %rax, %rbx
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x4a5a
movq -0x110(%rbp), %rsi
jmp 0x4a4d
movq %rax, %rbx
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x4a5a
movq -0xf0(%rbp), %rsi
jmp 0x4a4d
jmp 0x4a57
jmp 0x49d3
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x4a3c
movq -0x70(%rbp), %rsi
jmp 0x4a0a
jmp 0x4a39
jmp 0x4a39
movq %rax, %rbx
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x4a3c
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4a3c
jmp 0x4a57
jmp 0x4a57
movq %rax, %rbx
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x4a5a
movq -0x170(%rbp), %rsi
jmp 0x4a4d
jmp 0x4a39
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4a5a
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4a5a
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x4a7c
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3530