// File: brandoncanaday[P]1730sh/Input.cpp
// Function: Input::inputToProcesses()
vector<Process> Input::inputToProcesses() { 
  vector<Process> p_vector;
  // if empty
  if(this->shellInput.length() == 0) { return p_vector; } // if
  // splits up original shell input
  stringstream ss(this->shellInput);
  vector<string> argv;
  string a;
  while(ss >> a) { 
    argv.push_back(a);
  } // while
  // deals with double-quotes
  vector<string> processed_argv = processArgv(argv);
  // finally, add trimmed, concatenated/processed, and sanitized args to p_vector
  for(unsigned int i = 0; i < processed_argv.size(); i++) {
    if(i == 0) { 
      Process p;
      p_vector.push_back(p); // create a new Process
      p_vector[i].args.push_back(processed_argv[i]); // push the name of the process to be the first argument of the Process vector<string>
    } else if(processed_argv[i-1] == "|") { 
      Process p;
      p_vector.push_back(p); // create a new Process
      p_vector.back().args.push_back(processed_argv[i]); // push the name of the process to be the first argument of the Process vector<string>	
    } else { 
      if(processed_argv[i] != "<" && processed_argv[i-1] != "<" &&
	 processed_argv[i] != ">" && processed_argv[i-1] != ">" &&
	 processed_argv[i] != ">>" && processed_argv[i-1] != ">>" &&
	 processed_argv[i] != "e>" && processed_argv[i-1] != "e>" &&
	 processed_argv[i] != "e>>" && processed_argv[i-1] != "e>>") {
	if(processed_argv[i] == "|") {
	  p_vector.back().hasPipe = true;
	} else if(processed_argv[i] != "&") {
	  p_vector.back().args.push_back(processed_argv[i]); // push the process arguments to the Process vector<string>
	} // if/else
      } // if
    } // if/else
  } // for
  return p_vector;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x288(%rbp)
movq %rdi, %rax
movq %rax, -0x280(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x278(%rbp)
movb $0x0, -0x11(%rbp)
callq 0x123b0
movq -0x278(%rbp), %rdi
addq $0x10, %rdi
callq 0x34d0
cmpq $0x0, %rax
jne 0x10b8e
movb $0x1, -0x11(%rbp)
movl $0x1, -0x18(%rbp)
jmp 0x11235
movq -0x278(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x298(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0xb6f0
movl %eax, -0x28c(%rbp)
jmp 0x10bb7
movl -0x28c(%rbp), %edx
movq -0x298(%rbp), %rsi
leaq -0x1a0(%rbp), %rdi
callq 0x3510
jmp 0x10bd2
leaq -0x1c8(%rbp), %rdi
callq 0xb710
leaq -0x1e8(%rbp), %rdi
callq 0x3450
leaq -0x1a0(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x33e0
movq %rax, -0x2a0(%rbp)
jmp 0x10c06
movq -0x2a0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33d0
movb %al, -0x2a1(%rbp)
jmp 0x10c24
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x10c30
jmp 0x10c75
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0xb730
jmp 0x10c45
jmp 0x10bea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x11257
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x1120f
leaq -0x218(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0xb530
jmp 0x10c8a
leaq -0x200(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x11360
jmp 0x10c9f
leaq -0x218(%rbp), %rdi
callq 0xb620
movl $0x0, -0x21c(%rbp)
movl -0x21c(%rbp), %eax
movq %rax, -0x2b0(%rbp)
leaq -0x200(%rbp), %rdi
callq 0xb7a0
movq %rax, %rcx
movq -0x2b0(%rbp), %rax
cmpq %rcx, %rax
jae 0x111c6
cmpl $0x0, -0x21c(%rbp)
jne 0x10db1
leaq -0x248(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x12420
movq -0x288(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
callq 0x12460
jmp 0x10d16
movq -0x288(%rbp), %rdi
movl -0x21c(%rbp), %eax
movl %eax, %esi
callq 0xb490
addq $0x10, %rax
movq %rax, -0x2c0(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq -0x2c0(%rbp), %rdi
movq %rax, %rsi
callq 0xb730
jmp 0x10d5a
leaq -0x248(%rbp), %rdi
callq 0xc210
jmp 0x111b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x218(%rbp), %rdi
callq 0xb620
jmp 0x1120f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x248(%rbp), %rdi
callq 0xc210
jmp 0x11203
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x328a(%rip), %rsi      # 0x1405b
callq 0xb390
movb %al, -0x2c1(%rbp)
jmp 0x10dde
movb -0x2c1(%rbp), %al
testb $0x1, %al
jne 0x10ded
jmp 0x10e9c
leaq -0x270(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x12420
movq -0x288(%rbp), %rdi
movq -0x2d0(%rbp), %rsi
callq 0x12460
jmp 0x10e15
movq -0x288(%rbp), %rdi
callq 0xbac0
addq $0x10, %rax
movq %rax, -0x2d8(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq -0x2d8(%rbp), %rdi
movq %rax, %rsi
callq 0xb730
jmp 0x10e51
leaq -0x270(%rbp), %rdi
callq 0xc210
jmp 0x111ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
jmp 0x11203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1a8(%rbp)
movl %eax, -0x1ac(%rbp)
leaq -0x270(%rbp), %rdi
callq 0xc210
jmp 0x11203
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x31a3(%rip), %rsi      # 0x1405d
callq 0xb950
movb %al, -0x2d9(%rbp)
jmp 0x10ec7
movb -0x2d9(%rbp), %al
testb $0x1, %al
jne 0x10ed6
jmp 0x111ac
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x3167(%rip), %rsi      # 0x1405d
callq 0xb950
movb %al, -0x2da(%rbp)
jmp 0x10f03
movb -0x2da(%rbp), %al
testb $0x1, %al
jne 0x10f12
jmp 0x111ac
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x3134(%rip), %rsi      # 0x14064
callq 0xb950
movb %al, -0x2db(%rbp)
jmp 0x10f3d
movb -0x2db(%rbp), %al
testb $0x1, %al
jne 0x10f4c
jmp 0x111ac
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x30f8(%rip), %rsi      # 0x14064
callq 0xb950
movb %al, -0x2dc(%rbp)
jmp 0x10f79
movb -0x2dc(%rbp), %al
testb $0x1, %al
jne 0x10f88
jmp 0x111ac
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x30bd(%rip), %rsi      # 0x14063
callq 0xb950
movb %al, -0x2dd(%rbp)
jmp 0x10fb3
movb -0x2dd(%rbp), %al
testb $0x1, %al
jne 0x10fc2
jmp 0x111ac
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x3081(%rip), %rsi      # 0x14063
callq 0xb950
movb %al, -0x2de(%rbp)
jmp 0x10fef
movb -0x2de(%rbp), %al
testb $0x1, %al
jne 0x10ffe
jmp 0x111ac
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x3043(%rip), %rsi      # 0x1405f
callq 0xb950
movb %al, -0x2df(%rbp)
jmp 0x11029
movb -0x2df(%rbp), %al
testb $0x1, %al
jne 0x11038
jmp 0x111ac
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x3007(%rip), %rsi      # 0x1405f
callq 0xb950
movb %al, -0x2e0(%rbp)
jmp 0x11065
movb -0x2e0(%rbp), %al
testb $0x1, %al
jne 0x11074
jmp 0x111ac
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x2fd0(%rip), %rsi      # 0x14062
callq 0xb950
movb %al, -0x2e1(%rbp)
jmp 0x1109f
movb -0x2e1(%rbp), %al
testb $0x1, %al
jne 0x110ae
jmp 0x111ac
movl -0x21c(%rbp), %eax
decl %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x2f94(%rip), %rsi      # 0x14062
callq 0xb950
movb %al, -0x2e2(%rbp)
jmp 0x110db
movb -0x2e2(%rbp), %al
testb $0x1, %al
jne 0x110ea
jmp 0x111ac
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x2f53(%rip), %rsi      # 0x1405b
callq 0xb390
movb %al, -0x2e3(%rbp)
jmp 0x11115
movb -0x2e3(%rbp), %al
testb $0x1, %al
jne 0x11121
jmp 0x11133
movq -0x288(%rbp), %rdi
callq 0xbac0
movb $0x1, 0xa(%rax)
jmp 0x111aa
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq %rax, %rdi
leaq 0x43ac(%rip), %rsi      # 0x154fd
callq 0xb950
movb %al, -0x2e4(%rbp)
jmp 0x1115e
movb -0x2e4(%rbp), %al
testb $0x1, %al
jne 0x1116a
jmp 0x111a8
movq -0x288(%rbp), %rdi
callq 0xbac0
addq $0x10, %rax
movq %rax, -0x2f0(%rbp)
movl -0x21c(%rbp), %eax
movl %eax, %esi
leaq -0x200(%rbp), %rdi
callq 0xb4b0
movq -0x2f0(%rbp), %rdi
movq %rax, %rsi
callq 0xb730
jmp 0x111a6
jmp 0x111a8
jmp 0x111aa
jmp 0x111ac
jmp 0x111ae
jmp 0x111b0
jmp 0x111b2
movl -0x21c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x21c(%rbp)
jmp 0x10cb5
movb $0x1, -0x11(%rbp)
movl $0x1, -0x18(%rbp)
leaq -0x200(%rbp), %rdi
callq 0xb620
leaq -0x1e8(%rbp), %rdi
callq 0x31e0
leaq -0x1c8(%rbp), %rdi
callq 0xb620
leaq -0x1a0(%rbp), %rdi
callq 0x3230
jmp 0x11235
leaq -0x200(%rbp), %rdi
callq 0xb620
leaq -0x1e8(%rbp), %rdi
callq 0x31e0
leaq -0x1c8(%rbp), %rdi
callq 0xb620
leaq -0x1a0(%rbp), %rdi
callq 0x3230
jmp 0x11257
testb $0x1, -0x11(%rbp)
jne 0x11247
movq -0x288(%rbp), %rdi
callq 0xc090
movq -0x280(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x288(%rbp), %rdi
callq 0xc090
movq -0x1a8(%rbp), %rdi
callq 0x3580
nop