// File: /workspace/github_cpp_makefile_star2_O3/havluj[P]spreadsheet/src/CExpressionParser.cpp
// Function: CExpressionParser::InfixToRPN(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>>>>&)
bool CExpressionParser::InfixToRPN(std::vector<std::string>& inputs) {
    std::list<std::string> infix;
    Tokenize(infix, " ");

    typedef std::list<std::string>::const_iterator tok_iter;
    std::stack<std::string> stack;
    std::queue<std::string> outputQueue;

    bool success = true;

    // For each token
    for (tok_iter it = infix.begin(); it != infix.end(); it++) {
	  // Read a token.
	  std::string token = *it;

	  // If the token is a number, then add it to the output queue.
	  if (IsNumber(token) || IsFloat(token) || IsPi(token) || IsE(token)) {
		outputQueue.push(token);
	  }// If the token is a function token, then push it onto the stack.
	  else if (IsFunction(token)) {
		stack.push(token);
	  } else if (IsComma(token)) {
		// Until token at the top of stack is left parenthesis, pop operators 
		// off the stack onto the output queue.             
		std::string stackToken = stack.top();

		while (stackToken != "(") {
		    outputQueue.push(stackToken);
		    stack.pop();
		    stackToken = stack.top();
		}

		if (stackToken == "(") {
		    success = true;
		} else {
		    success = false;
		}
	  }// If the token (o1) is an operator, then:
	  else if (IsOperator(token)) {
		// While there is operator token, o2, at the top of the stack, and:
		// either o1 is left-associative and its precedence is equal to that of o2,
		// or o1 has precedence less than that of o2
		while (!stack.empty() && IsOperator(stack.top()) &&
			  ((OpLeftAssoc(token) && OpPrecedence(token) == OpPrecedence(stack.top())) ||
			  (OpPrecedence(token) < OpPrecedence(stack.top())))) {
		    // Pop o2 off the stack, onto the output queue
		    std::string stackToken = stack.top();
		    stack.pop();
		    outputQueue.push(stackToken);
		}

		// Push o1 onto the stack
		stack.push(token);

	  }// If the token is a left parenthesis, then push it onto the stack.
	  else if (token == "(") {
		// Push token to top of the stack  
		stack.push(token);
	  }// If the token is a right parenthesis:
	  else if (token == ")") {
		// Until the token at the top of the stack is a left parenthesis, pop operators 
		// off the stack onto the output queue.
		while (!stack.empty() && stack.top() != "(") {
		    // Add to end of list  
		    outputQueue.push(stack.top());
		    stack.pop();
		}

		// If stack runs out without finding a left parenthesis, 
		// there are mismatched parentheses
		if (!stack.empty()) {
		    std::string stackToken = stack.top();

		    // Mismatched parentheses
		    if (stackToken != "(") {
			  success = false;
		    }
		} else {
		    return false;
		}

		// Pop left parenthesis from the stack, but not onto output queue.
		stack.pop();

		// If token at top of stack is function token, pop it onto output queue
		if (!stack.empty()) {
		    std::string stackToken = stack.top();
		    if (IsFunction(stackToken)) {
			  outputQueue.push(stackToken);
			  stack.pop();
		    }
		}
	  }
    }

    // While there are still operator tokens in the stack:
    while (!stack.empty()) {
	  // Pop the operator onto the output queue
	  outputQueue.push(stack.top());
	  stack.pop();
    }

    while (!outputQueue.empty()) {
	  std::string token = outputQueue.front();
	  inputs.push_back(token);
	  outputQueue.pop();
    }

    return success;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
movq %rdi, %r15
leaq 0xa0(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x248b(%rip), %rsi      # 0xe893
leaq 0x2485(%rip), %rdx      # 0xe894
leaq 0x10(%rsp), %rdi
callq 0x8438
leaq 0xa0(%rsp), %rsi
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0xaa3c
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0xc445
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, 0xb8(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0xcf18
leaq 0xc0(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0xcf18
leaq 0x70(%rsp), %rbx
movb $0x1, %al
movl %eax, 0xc(%rsp)
leaq 0x80(%rsp), %r13
leaq 0x60(%rsp), %rbp
leaq 0xa0(%rsp), %r14
movq (%r14), %r14
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0xc991
leaq 0x90(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x5370
movq %r13, %rdi
callq 0xa8e5
leaq 0xc0(%rsp), %rdi
testb %al, %al
jne 0xc54c
movq %r13, %rdi
callq 0xa846
leaq 0xc0(%rsp), %rdi
testb %al, %al
jne 0xc54c
movq %r13, %rdi
callq 0xa4a0
leaq 0xc0(%rsp), %rdi
testb %al, %al
jne 0xc54c
movq %r13, %rdi
callq 0xa58f
leaq 0xc0(%rsp), %rdi
testb %al, %al
jne 0xc54c
movq %r13, %rdi
callq 0xa67e
leaq 0x10(%rsp), %rdi
testb %al, %al
je 0xc58a
movb $0x1, %r15b
movq %r13, %rsi
callq 0xd0ac
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xc57c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
testb %r15b, %r15b
jne 0xc4b4
jmp 0xc97d
movq %r13, %rdi
leaq 0x2378(%rip), %rsi      # 0xe90c
callq 0x40a0
testl %eax, %eax
je 0xc6ec
movq %r13, %rdi
callq 0xa37c
testb %al, %al
je 0xc7b9
movq 0x40(%rsp), %rax
leaq 0x10(%rsp), %rdi
cmpq 0x20(%rsp), %rax
je 0xc54c
cmpq 0x48(%rsp), %rax
jne 0xc5da
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
addq $-0x20, %rax
movq %rax, %rdi
callq 0xa37c
testb %al, %al
je 0xc6e2
movq %r13, %rdi
callq 0xa2ea
testb %al, %al
je 0xc630
movq %r13, %rdi
callq 0xa247
movl %eax, %r15d
movq 0x40(%rsp), %rdi
cmpq 0x48(%rsp), %rdi
jne 0xc622
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rdi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rdi
addq $-0x20, %rdi
callq 0xa247
cmpl %eax, %r15d
je 0xc666
movq %r13, %rdi
callq 0xa247
movl %eax, %r15d
movq 0x40(%rsp), %rdi
cmpq 0x48(%rsp), %rdi
jne 0xc658
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rdi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rdi
addq $-0x20, %rdi
callq 0xa247
cmpl %eax, %r15d
jae 0xc6e2
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
jne 0xc683
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq %rbx, %r15
movq %rbx, 0x60(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
movq %rbp, %r12
movq %rbp, %rdi
callq 0x5370
leaq 0x10(%rsp), %rdi
callq 0xd346
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0xd0ac
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0xc6d2
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x40(%rsp), %rax
cmpq 0x20(%rsp), %rax
jne 0xc5c2
leaq 0x10(%rsp), %rdi
jmp 0xc54c
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
movq %rbx, %r15
jne 0xc70c
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq %r15, 0x60(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x5370
movq %rbp, %r12
movq %r12, %rdi
leaq 0x21cf(%rip), %rsi      # 0xe900
callq 0x40a0
testl %eax, %eax
je 0xc782
leaq 0xc0(%rsp), %rdi
movq %r12, %rsi
callq 0xd0ac
leaq 0x10(%rsp), %rdi
callq 0xd346
movq 0x40(%rsp), %rsi
cmpq 0x48(%rsp), %rsi
jne 0xc771
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
movq %rbp, %r12
movq %rbp, %rdi
callq 0x4190
jmp 0xc727
movq %r12, %rdi
leaq 0x2174(%rip), %rsi      # 0xe900
callq 0x40a0
testl %eax, %eax
sete %al
movl %eax, 0xc(%rsp)
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0xc7b1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42d0
movb $0x1, %r15b
jmp 0xc557
movq %r13, %rdi
leaq 0x213d(%rip), %rsi      # 0xe900
callq 0x40a0
leaq 0x10(%rsp), %rdi
testl %eax, %eax
je 0xc54c
movq %r13, %rdi
leaq 0x2185(%rip), %rsi      # 0xe964
callq 0x40a0
movb $0x1, %r15b
testl %eax, %eax
jne 0xc557
jmp 0xc824
cmpq 0x48(%rsp), %rsi
jne 0xc809
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
leaq 0xc0(%rsp), %rdi
callq 0xd0ac
leaq 0x10(%rsp), %rdi
callq 0xd346
movq 0x40(%rsp), %rdi
cmpq 0x20(%rsp), %rdi
je 0xc975
cmpq 0x48(%rsp), %rdi
jne 0xc84c
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rdi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rdi
addq $-0x20, %rdi
leaq 0x20a9(%rip), %rsi      # 0xe900
callq 0x40a0
movq 0x40(%rsp), %rsi
testl %eax, %eax
jne 0xc7f1
cmpq 0x20(%rsp), %rsi
je 0xc975
cmpq 0x48(%rsp), %rsi
jne 0xc888
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
movq %rbx, 0x60(%rsp)
movq -0x20(%rsi), %rax
movq -0x18(%rsi), %rdx
addq %rax, %rdx
movq %rbp, %r12
movq %rbp, %rdi
movq %rax, %rsi
callq 0x5370
movq %r12, %rdi
leaq 0x2050(%rip), %rsi      # 0xe900
callq 0x40a0
testl %eax, %eax
sete %r12b
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xc8d7
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42d0
movl 0xc(%rsp), %eax
andb %r12b, %al
movl %eax, 0xc(%rsp)
leaq 0x10(%rsp), %rdi
callq 0xd346
movq 0x40(%rsp), %rax
cmpq 0x20(%rsp), %rax
je 0xc557
cmpq 0x48(%rsp), %rax
jne 0xc914
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq %rbx, 0x60(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
movq %rbp, %r12
movq %rbp, %rdi
callq 0x5370
movq %r12, %rdi
callq 0xa67e
testb %al, %al
je 0xc955
leaq 0xc0(%rsp), %rdi
movq %rbp, %rsi
callq 0xd0ac
leaq 0x10(%rsp), %rdi
callq 0xd346
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
je 0xc557
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xc557
xorl %r15d, %r15d
jmp 0xc557
leaq 0xa0(%rsp), %rax
cmpq %rax, %r14
je 0xc991
xorl %ebx, %ebx
jmp 0xca81
movq 0x40(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0xc9e3
movl $0x200, %r12d           # imm = 0x200
leaq 0xc0(%rsp), %r14
leaq 0x10(%rsp), %r15
cmpq 0x48(%rsp), %rsi
jne 0xc9c3
movq 0x58(%rsp), %rax
movq -0x8(%rax), %rsi
addq %r12, %rsi
addq $-0x20, %rsi
movq %r14, %rdi
callq 0xd0ac
movq %r15, %rdi
callq 0xd346
movq 0x40(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
jne 0xc9b0
movq 0xd0(%rsp), %rax
cmpq %rax, 0xf0(%rsp)
je 0xca7d
leaq 0x80(%rsp), %r14
leaq 0xc0(%rsp), %r15
movq 0xb8(%rsp), %rbx
leaq 0x90(%rsp), %rcx
movq %rcx, 0x80(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x5370
movq %rbx, %rdi
movq %r14, %rsi
callq 0xcc60
movq %r15, %rdi
callq 0xd88a
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xca6b
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0xd0(%rsp), %rax
cmpq %rax, 0xf0(%rsp)
jne 0xca11
movl 0xc(%rsp), %ebx
leaq 0xc0(%rsp), %rdi
callq 0xcc9e
leaq 0x10(%rsp), %rdi
callq 0xcc9e
leaq 0xa0(%rsp), %rdi
callq 0xce4a
andb $0x1, %bl
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xcb29
movq %rax, %r12
movq 0x60(%rsp), %rdi
cmpq %rbx, %rdi
jne 0xcb0f
jmp 0xcb2c
jmp 0xcb29
jmp 0xcb29
jmp 0xcb29
movq %rax, %r12
jmp 0xcb5e
jmp 0xcaf9
movq %rax, %r12
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0xcb68
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xcb68
movq %rax, %r12
jmp 0xcb68
jmp 0xcb02
jmp 0xcb29
movq %rax, %r12
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0xcb2c
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0xcb2c
jmp 0xcb24
jmp 0xcb29
jmp 0xcb24
movq %rax, %r12
jmp 0xcb51
movq %rax, %r12
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xcb51
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xc0(%rsp), %rdi
callq 0xcc9e
leaq 0x10(%rsp), %rdi
callq 0xcc9e
leaq 0xa0(%rsp), %rdi
callq 0xce4a
movq %r12, %rdi
callq 0x45a0