// File: /workspace/github_cpp_makefile_star2_O3/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 0x4a8b
callq 0x56d0
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 0x5792
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0xadd7(%rip), %rdx      # 0xeb12
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
movq %rdx, %rsi
callq 0x9ff0
movq $0x0, -0xd0(%rbp)
leaq -0x60(%rbp), %rbx
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %ecx
movq -0xd0(%rbp), %rax
movl %eax, %r13d
movl %ecx, -0x30(%rbp)
orb %cl, %r13b
callq 0x5860
testb $0x1, %r13b
je 0x3eaa
movl $0x2, %edx
movq 0xe23f(%rip), %rdi      # 0x11fd0
leaq 0x926c(%rip), %rsi      # 0xd004
callq 0x3300
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq %rbx, %rdi
leaq 0xad63(%rip), %rdx      # 0xeb12
movq %rdx, %rsi
callq 0x9ff0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %edx
movq %r14, %rdi
movq %rbx, %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), %rbx
movq %rbx, %rdi
callq 0x9f52
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0xc512
leaq -0x60(%rbp), %rdi
movq %r15, %rsi
callq 0x3350
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3e41
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x3e63
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x32c0
testb $0x1, -0x30(%rbp)
je 0x3f6c
movq %r15, %rdi
movq %r12, %rsi
leaq -0x60(%rbp), %rdx
callq 0x9b06
movq %r12, %rdi
movq %r15, %rsi
callq 0x3350
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x4055
movq -0x90(%rbp), %rsi
jmp 0x404d
callq 0x5b76
movq -0xc0(%rbp), %rdx
movq %r12, %rdi
xorl %esi, %esi
leaq 0xac50(%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 -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x180(%rbp), %r15
movq %r15, %rdi
callq 0x9f52
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc512
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3350
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x3f49
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x4072
movq -0x170(%rbp), %rsi
jmp 0x406a
testb $0x1, -0xd0(%rbp)
leaq -0x60(%rbp), %rbx
je 0x4059
leaq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
callq 0x9f52
movq %rbx, %rdi
leaq 0x9776(%rip), %rsi      # 0xd722
callq 0x3570
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq %rbx, %rdi
callq 0x30c0
leaq -0x90(%rbp), %r15
movq %r15, -0xa0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3ff1
movq %rdx, -0xa0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x90(%rbp)
jmp 0x3ff8
movups (%rcx), %xmm0
movups %xmm0, (%r15)
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 %r15, %rdi
je 0x403c
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x32c0
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x4055
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x32c0
leaq -0x60(%rbp), %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4072
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %r12, %rdi
leaq 0xaa96(%rip), %rsi      # 0xeb12
callq 0x30b0
testl %eax, %eax
je 0x3d76
leaq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
callq 0x9f52
leaq -0x140(%rbp), %rdi
callq 0x5e15
movl %eax, %r13d
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x40e5
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x32c0
testb %r13b, %r13b
je 0x41bd
leaq -0x110(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %rdi
callq 0x9f52
leaq -0x120(%rbp), %rdi
callq 0xc6ea
testb %al, %al
je 0x418b
leaq -0x198(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xc0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x9f52
leaq -0x1a8(%rbp), %rdi
callq 0x6038
movl %eax, %r13d
xorb $0x1, %r13b
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x418e
movq -0x198(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x418e
xorl %r13d, %r13d
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x41b0
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x32c0
movb $0x1, %cl
testb %r13b, %r13b
jne 0x3d66
jmp 0x420c
movl $0x20, %edx
movq 0xde07(%rip), %rdi      # 0x11fd0
leaq 0x8e53(%rip), %rsi      # 0xd023
callq 0x3300
movq 0xddf4(%rip), %rcx      # 0x11fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq 0xddd6(%rip), %rdi      # 0x11fd0
callq 0x3040
movq %rax, %rdi
callq 0x31b0
jmp 0x3d63
movq -0xc8(%rbp), %r15
movq -0xc0(%rbp), %r13
cmpb $0x7c, -0x1(%r15,%r13)
sete %al
movq %rax, -0xd0(%rbp)
je 0x3d5c
movl $0xe8, %edi
callq 0x32b0
movq %rax, -0x30(%rbp)
addq %r15, %r13
leaq -0xf0(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9f52
leaq -0x90(%rbp), %r15
leaq -0x80(%rbp), %rbx
movq -0x30(%rbp), %r13
movq %r13, %rdi
leaq -0x100(%rbp), %rsi
callq 0xa924
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x42a1
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %r13, -0x80(%rbp)
movq %r13, %rdi
callq 0xc0f6
movl %eax, %edi
callq 0x6098
movq %rax, -0xa8(%rbp)
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 0x60f9
movq -0x80(%rbp), %r13
cmpl $-0x1, %eax
je 0x437b
movq 0x30(%r13), %rcx
movq 0x38(%r13), %rax
subq %rcx, %rax
cmpq $0x28, %rax
jne 0x439a
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 0x9f52
movq %rbx, %rdi
callq 0x6773
movb %al, -0x30(%rbp)
testb %al, %al
je 0x44c4
movl -0x3c(%rbp), %r13d
movl -0x38(%rbp), %ebx
movl -0x34(%rbp), %r15d
movl %r13d, %edi
movl %ebx, %esi
movl %r15d, %edx
callq 0x6820
movl %r13d, %edi
movl %ebx, %esi
movl %r15d, %edx
callq 0x6890
movq -0x80(%rbp), %rdx
movq 0x30(%rdx), %rsi
addq $0x10, %rsi
leaq -0x60(%rbp), %rdi
callq 0x68f6
jmp 0x454c
testq %r13, %r13
je 0x4388
movq %r13, %rdi
callq 0x9b6a
movl $0xe8, %esi
movq %r13, %rdi
callq 0x32c0
jmp 0x3d58
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
testl %eax, %eax
je 0x44a0
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 -0xa8(%rbp), %rax
movq %rax, -0x30(%rbp)
xorl %r15d, %r15d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, -0xd8(%rbp)
cmpq %r15, -0xe0(%rbp)
je 0x4413
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x33a0
cmpl $-0x1, %eax
je 0x464d
callq 0x3090
testl %eax, %eax
je 0x45f1
movl %eax, %r13d
cmpl $-0x1, %eax
je 0x45ae
movq -0x80(%rbp), %rdi
movq 0x30(%rdi), %rax
movl %r13d, (%rax,%r15)
testq %r15, %r15
je 0x4464
movl (%rdi), %esi
movl %r13d, %edi
callq 0x34c0
cmpl $-0x1, %eax
je 0x45d1
movq -0x30(%rbp), %rax
movq -0x8(%rax), %rdi
movl $0x1, %esi
callq 0x6d34
jmp 0x4483
movl %r13d, %esi
callq 0xc0b8
movq -0x80(%rbp), %rax
movl (%rax), %esi
movl %r13d, %edi
callq 0x34c0
cmpl $-0x1, %eax
je 0x45d1
incq -0xd8(%rbp)
addq $0x28, %r15
addq $0x8, -0x30(%rbp)
cmpq %r15, -0x188(%rbp)
jne 0x43f5
movq 0xde71(%rip), %rsi      # 0x12318
cmpq 0xde72(%rip), %rsi      # 0x12320
je 0x452c
movq -0x80(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xde59(%rip)      # 0x12318
jmp 0x456f
callq 0x3090
testl %eax, %eax
je 0x4788
movl %eax, %r13d
cmpl $-0x1, %eax
leaq -0x80(%rbp), %rbx
je 0x47e8
movq -0x80(%rbp), %rdi
movq 0x30(%rdi), %rax
movl %r13d, (%rax)
movl %r13d, %esi
callq 0xc0b8
movq -0x80(%rbp), %rax
movl (%rax), %esi
movl %r13d, %edi
callq 0x34c0
cmpl $-0x1, %eax
je 0x4807
movq 0xde06(%rip), %rsi      # 0x12318
cmpq 0xde07(%rip), %rsi      # 0x12320
je 0x453d
movq -0x80(%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0xddee(%rip)      # 0x12318
jmp 0x454c
leaq 0xdddd(%rip), %rdi      # 0x12310
movq %rbx, %rdx
callq 0xa170
jmp 0x456f
leaq 0xddcc(%rip), %rdi      # 0x12310
movq %rbx, %rdx
callq 0xa170
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4565
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
cmpb $0x0, -0x30(%rbp)
jne 0x3d58
movl -0x3c(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6890
movq -0x80(%rbp), %rdi
callq 0xc0f6
movq -0xa8(%rbp), %rdi
movl %eax, %esi
callq 0x6d86
movq -0x80(%rbp), %rdi
cmpb $0x1, 0x4(%rdi)
jne 0x3d58
xorl %esi, %esi
callq 0x6dcb
jmp 0x3d58
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8a47(%rip), %rsi      # 0xd007
leaq 0x8a44(%rip), %rdx      # 0xd00b
callq 0x9ff0
jmp 0x466b
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8a29(%rip), %rsi      # 0xd00c
leaq 0x8a29(%rip), %rdx      # 0xd013
callq 0x9ff0
jmp 0x466b
callq 0x3410
movq -0x80(%rbp), %rbx
movq 0x30(%rbx), %rcx
movl %eax, (%rcx,%r15)
testq %r15, %r15
jne 0x4616
callq 0x3410
movq %rbx, %rdi
movl %eax, %esi
callq 0xc0b8
callq 0x3410
movq -0x80(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x34c0
cmpl $-0x1, %eax
jne 0x467e
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x89cd(%rip), %rsi      # 0xd00c
leaq 0x89cd(%rip), %rdx      # 0xd013
callq 0x9ff0
jmp 0x466b
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x89bf(%rip), %rsi      # 0xd01e
leaq 0x89bc(%rip), %rdx      # 0xd022
callq 0x9ff0
movq -0x60(%rbp), %rdi
callq 0x3240
movl $0x1, %edi
callq 0x3330
movq -0x80(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x46ba
movl 0xdc7a(%rip), %edi      # 0x12308
movl (%rax), %esi
callq 0x33c0
cmpl $-0x1, %eax
jne 0x46ba
leaq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8968(%rip), %rsi      # 0xd014
leaq 0x896a(%rip), %rdx      # 0xd01d
callq 0x9ff0
jmp 0x466b
callq 0x6ada
testq %r15, %r15
jne 0x46dd
movl -0x3c(%rbp), %edi
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6820
jmp 0x472f
movl -0xd8(%rbp), %eax
movq -0xa8(%rbp), %rcx
leaq (%rcx,%rax,8), %rbx
movq (%rcx,%rax,8), %rax
movl (%rax), %edi
cmpq %r15, -0xe0(%rbp)
jne 0x470e
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6820
movq %rbx, -0x30(%rbp)
jmp 0x472f
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6820
movq (%rbx), %rdi
movl $0x1, %esi
callq 0x6d34
movq -0x30(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x6d34
movl -0x3c(%rbp), %edi
movl -0x38(%rbp), %esi
movl -0x34(%rbp), %edx
callq 0x6890
movq -0x80(%rbp), %rax
movq 0x30(%rax), %rax
leaq (%rax,%r15), %rsi
addq $0x10, %rsi
leaq -0x1c0(%rbp), %rdi
callq 0x9c2c
movq -0x80(%rbp), %rdi
callq 0xc0f6
leaq -0x1c0(%rbp), %rdi
movq -0xa8(%rbp), %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 0xc0b8
callq 0x3410
movq -0x80(%rbp), %rcx
movl (%rcx), %esi
movl %eax, %edi
callq 0x34c0
cmpl $-0x1, %eax
jne 0x4830
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x8832(%rip), %rsi      # 0xd00c
leaq 0x8832(%rip), %rdx      # 0xd013
callq 0x9ff0
jmp 0x4824
leaq -0xa0(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x880e(%rip), %rsi      # 0xd007
leaq 0x880b(%rip), %rdx      # 0xd00b
callq 0x9ff0
jmp 0x4824
leaq -0xa0(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x87f4(%rip), %rsi      # 0xd00c
leaq 0x87f4(%rip), %rdx      # 0xd013
callq 0x9ff0
movq -0xa0(%rbp), %rdi
jmp 0x466f
movq -0x80(%rbp), %rax
cmpb $0x1, 0x4(%rax)
jne 0x4872
movl 0xdac8(%rip), %edi      # 0x12308
movl (%rax), %esi
callq 0x33c0
cmpl $-0x1, %eax
jne 0x4872
leaq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
movq %rax, (%rdi)
leaq 0x87b0(%rip), %rsi      # 0xd014
leaq 0x87b2(%rip), %rdx      # 0xd01d
callq 0x9ff0
jmp 0x4824
movl -0x3c(%rbp), %ebx
movl -0x38(%rbp), %r14d
movl -0x34(%rbp), %r15d
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6820
movl %ebx, %edi
movl %r14d, %esi
movl %r15d, %edx
callq 0x6890
movq -0x80(%rbp), %rax
movq 0x30(%rax), %rsi
addq $0x10, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x9c2c
movq -0x80(%rbp), %rdi
callq 0xc0f6
leaq -0x1d8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movl %eax, %edx
callq 0x6ba5
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
callq 0x9cc0
jmp 0x4a43
jmp 0x4a40
jmp 0x4a40
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x9cc0
jmp 0x4a61
jmp 0x4a40
jmp 0x4a40
jmp 0x4a40
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a40
movq %rax, %rbx
movq -0x100(%rbp), %rdi
leaq -0xf0(%rbp), %rax
cmpq %rax, %rdi
je 0x4947
movq -0xf0(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4947
movq %rax, %rbx
movl $0xe8, %esi
movq -0x30(%rbp), %rdi
jmp 0x4a57
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
jmp 0x4a5e
movq %rax, %rbx
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0x4a61
movq -0x130(%rbp), %rsi
jmp 0x4a54
movq %rax, %rbx
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x4a61
movq -0x110(%rbp), %rsi
jmp 0x4a54
jmp 0x4a5e
jmp 0x49dc
jmp 0x4a40
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x4a43
movq -0x70(%rbp), %rsi
jmp 0x4a13
jmp 0x4a40
jmp 0x4a5e
movq %rax, %rbx
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x4a43
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4a43
movq %rax, %rbx
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x4a61
movq -0x170(%rbp), %rsi
jmp 0x4a54
jmp 0x4a40
jmp 0x4a5e
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4a61
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x32c0
jmp 0x4a61
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4a83
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3530