// File: /workspace/github_cpp_makefile_star2_O3/mbottini[P]CS250lab2/main.cpp
// Function: convertRPN(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>>>> const&)
stringVector convertRPN(const stringVector& tokenVector) {
    stringVector RPNVector;
    std::stack<string> operatorStack;
    int precedence;

    for(stringIter i = tokenVector.begin(); i != tokenVector.end(); ++i) {
        if(isVariable(*i)) {
            RPNVector.push_back(*i);
        }

        else if(isOperator(*i)) {
            precedence = getPrecedence(*i);

            if(precedence == -1) {
                std::cout << "Invalid operator plugged into "
                << "precedence function!\n";
                RPNVector.clear();
                return RPNVector;
            }

            while(!(operatorStack.empty()) && 
                    precedence <= getPrecedence(operatorStack.top())) {
                RPNVector.push_back(operatorStack.top());
                operatorStack.pop();
            }

            operatorStack.push(*i);
        }

        else if(isLeftParen(*i)) {
            operatorStack.push(*i);
        }

        else if(isRightParen(*i)) {
            if(operatorStack.empty()) {
                std::cout << "Parentheses mismatch!\n";
                RPNVector.clear();
                return RPNVector;
            }

            while(operatorStack.top() != "(") {
                if(operatorStack.empty()) {
                    std::cout << "Parentheses mismatch!\n";
                    RPNVector.clear();
                    return RPNVector;
                }

                RPNVector.push_back(operatorStack.top());
                operatorStack.pop();
            }

            operatorStack.pop();
        }
    }

    while(!(operatorStack.empty())) {
        RPNVector.push_back(operatorStack.top());
        operatorStack.pop();
    }

    return RPNVector;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
leaq -0x80(%rbp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x4eb6
movq (%r14), %r12
movq %r14, -0x88(%rbp)
cmpq 0x8(%r14), %r12
je 0x3366
movl $0x200, %r14d           # imm = 0x200
leaq -0x80(%rbp), %r13
cmpq $0x1, 0x8(%r12)
jne 0x322f
movq (%r12), %rax
movsbl (%rax), %r15d
movl %r15d, %edi
callq 0x21f0
cmpl $0x76, %r15d
je 0x322f
testl %eax, %eax
je 0x322f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40b8
jmp 0x3345
movq %r12, %rdi
callq 0x3a3e
testb %al, %al
je 0x32ab
movq %r12, %rdi
callq 0x3c26
cmpl $-0x1, %eax
je 0x33b8
movl %eax, %r15d
movq -0x50(%rbp), %rdi
cmpq -0x70(%rbp), %rdi
je 0x333a
cmpq -0x48(%rbp), %rdi
jne 0x326e
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rdi
addq %r14, %rdi
addq $-0x20, %rdi
callq 0x3c26
cmpl %eax, %r15d
jg 0x333a
movq -0x50(%rbp), %rsi
cmpq -0x48(%rbp), %rsi
jne 0x3295
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rsi
addq %r14, %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x40b8
movq %r13, %rdi
callq 0x5034
jmp 0x324f
cmpq $0x1, 0x8(%r12)
jne 0x3345
movq (%r12), %rax
movzbl (%rax), %eax
cmpl $0x28, %eax
je 0x333a
cmpl $0x29, %eax
jne 0x3345
movq -0x50(%rbp), %rdi
movl $0x16, %r15d
cmpq -0x70(%rbp), %rdi
je 0x33af
cmpq -0x48(%rbp), %rdi
jne 0x32ed
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rdi
addq %r14, %rdi
addq $-0x20, %rdi
leaq 0x2e1a(%rip), %rsi      # 0x6112
callq 0x2060
testl %eax, %eax
je 0x335c
movq -0x50(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x33af
cmpq -0x48(%rbp), %rsi
jne 0x3320
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rsi
addq %r14, %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x40b8
movq %r13, %rdi
callq 0x5034
movq -0x50(%rbp), %rdi
jmp 0x32dc
movq %r13, %rdi
movq %r12, %rsi
callq 0x50c2
addq $0x20, %r12
movq -0x88(%rbp), %rax
cmpq 0x8(%rax), %r12
jne 0x31fd
jmp 0x3366
movq %r13, %rdi
callq 0x5034
jmp 0x3345
movq -0x50(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
je 0x33f4
movl $0x200, %r15d           # imm = 0x200
leaq -0x80(%rbp), %r14
cmpq -0x48(%rbp), %rsi
jne 0x338f
movq -0x38(%rbp), %rax
movq -0x8(%rax), %rsi
addq %r15, %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x40b8
movq %r14, %rdi
callq 0x5034
movq -0x50(%rbp), %rsi
cmpq -0x70(%rbp), %rsi
jne 0x337e
jmp 0x33f4
leaq 0x2d45(%rip), %rsi      # 0x60fb
jmp 0x33dd
movq 0x5c11(%rip), %rdi      # 0x8fd0
leaq 0x2d00(%rip), %rsi      # 0x60c6
movl $0x1e, %edx
callq 0x2180
movl $0x15, %r15d
leaq 0x2d08(%rip), %rsi      # 0x60e5
movq 0x5bec(%rip), %rdi      # 0x8fd0
movq %r15, %rdx
callq 0x2180
movq %rbx, %rdi
callq 0x4104
leaq -0x80(%rbp), %rdi
callq 0x4358
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x341c
movq %rax, %r14
jmp 0x3428
jmp 0x341c
jmp 0x341c
jmp 0x341c
movq %rax, %r14
leaq -0x80(%rbp), %rdi
callq 0x4358
movq %rbx, %rdi
callq 0x3f82
movq %r14, %rdi
callq 0x2220