// File: clementino1971[P]ICC065-protoTerminal/source/commands.cpp
// Function: run(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>>>>)
void run(vector<string> commands){
    int nWords = commands.size();

    char *myArgs[nWords+1];
    myArgs[nWords]=NULL;

    for(int i=0;i<nWords;i++){
        char* buffer = new char[commands[i].length()+1];
        strcpy(buffer, commands[i].c_str());


        if(strcmp(buffer,"<") == 0){
            buffer = new char[commands[i+1].length()+1];
            strcpy(buffer,commands[i+1].c_str());	

            freopen(buffer,"r+",stdin);

            i++;
            continue;
        }

        if(strcmp(buffer,">") == 0){
            buffer = new char[commands[i+1].length()+1];
            strcpy(buffer, commands[i+1].c_str());

            freopen(buffer, "w+", stdout);

            i++;
            continue;
        }

        myArgs[i] = buffer;

    }
    execvp(myArgs[0], myArgs);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x40(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x4f60
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
incl %eax
movl %eax, %ecx
movq %rsp, %rax
movq %rax, -0x18(%rbp)
leaq 0xf(,%rcx,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rax
subq %rdx, %rax
movq %rax, -0x38(%rbp)
movq %rax, %rsp
movq %rcx, -0x20(%rbp)
movslq -0xc(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x9639
movq -0x40(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3430
movq %rax, %rdi
addq $0x1, %rdi
callq 0x3030
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movslq -0x24(%rbp), %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3100
movq -0x48(%rbp), %rdi
movq %rax, %rsi
callq 0x3270
movq -0x30(%rbp), %rdi
leaq 0xc00(%rip), %rsi       # 0xa0fb
callq 0x33d0
cmpl $0x0, %eax
jne 0x9589
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3430
movq %rax, %rdi
addq $0x1, %rdi
callq 0x3030
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3100
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x3270
movq -0x30(%rbp), %rdi
movq 0x5a54(%rip), %rax      # 0xefc0
movq (%rax), %rdx
leaq 0xb87(%rip), %rsi       # 0xa0fd
callq 0x32d0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x962b
movq -0x30(%rbp), %rdi
leaq 0xb6c(%rip), %rsi       # 0xa100
callq 0x33d0
cmpl $0x0, %eax
jne 0x961b
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3430
movq %rax, %rdi
addq $0x1, %rdi
callq 0x3030
movq -0x40(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x4c80
movq %rax, %rdi
callq 0x3100
movq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x3270
movq -0x30(%rbp), %rdi
movq 0x59a7(%rip), %rax      # 0xefa8
movq (%rax), %rdx
leaq 0xaf7(%rip), %rsi       # 0xa102
callq 0x32d0
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x962b
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rdx
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9496
movq -0x38(%rbp), %rsi
movq (%rsi), %rdi
callq 0x31f0
movq -0x18(%rbp), %rax
movq %rax, %rsp
movq %rbp, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)