// File: /workspace/github_cpp_makefile_star2_O2/menhits[P]phplus/src/Parser.cpp
// Function: findExpressionSplit(std::vector<std::shared_ptr<TokenData>, std::allocator<std::shared_ptr<TokenData>>> const&, int, int)
int findExpressionSplit(const vector<Token>& tokens, int left, int right)
{
	int minPrece=-1;
	int indexOfMin=-1;
	
	for (int i=left; i<=right; i++)
	{
		//cout << "looking at " << tokens[i]->getText() << endl;
		/*if (tokens[i]->getOp())
		{
			//cout << "precedence: " << tokens[i]->getOp()->getPrecedence()
		}
		*/
		
		if (ops->isOpenBrac(tokens[i]->getOp()))
		{
			int j=skipBrace(tokens, i);
			
			i=j; // i is now the close brace, and after it is incremented it will be the token after that
		}
		else if (tokens[i]->getOp() && (minPrece<0 || tokens[i]->getOp()->getPrecedence()<minPrece))
		{
			minPrece=tokens[i]->getOp()->getPrecedence();
			indexOfMin=i;
			
			// this ensures that if the precedence is divisable by 2, the same precedence again will replace this one as the min
			// it is my way of making even precedences be right associative and odd ones be left associative
			if (minPrece%2)
			{
				minPrece++;
			}
		}
	}
	
	if (indexOfMin<0)
	{
		throw PhplusError(FUNC+" could not find operator to split expression", INTERNAL_ERROR, tokens[left]);
	}
	
	return indexOfMin;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, 0x14(%rsp)
movl %esi, %r13d
movq %rdi, %rbx
pushq $-0x1
popq %r14
leaq 0x48(%rsp), %r12
movl %esi, 0x10(%rsp)
movl %r14d, 0xc(%rsp)
cmpl 0x14(%rsp), %r13d
jg 0x1f886
leaq 0x5ab64(%rip), %rax     # 0x7a2f0
movq (%rax), %rbp
movslq %r13d, %r15
movq (%rbx), %rax
shlq $0x4, %r15
movq (%rax,%r15), %rsi
addq $0x40, %rsi
movq %r12, %rdi
callq 0xc950
movq %rbp, %rdi
movq %r12, %rsi
callq 0xc7ec
movl %eax, %ebp
leaq 0x50(%rsp), %rdi
callq 0xc984
testb %bpl, %bpl
je 0x1f7d8
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1f29d
movl %eax, %r13d
jmp 0x1f87e
movq (%rbx), %rax
movq (%rax,%r15), %rsi
addq $0x40, %rsi
leaq 0x18(%rsp), %rdi
callq 0xc950
cmpq $0x0, 0x18(%rsp)
je 0x1f832
testl %r14d, %r14d
js 0x1f83e
movq (%rbx), %rax
movq (%rax,%r15), %rsi
addq $0x40, %rsi
leaq 0x38(%rsp), %rdi
callq 0xc950
movq 0x38(%rsp), %rax
movl 0x20(%rax), %ebp
leaq 0x40(%rsp), %rdi
callq 0xc984
leaq 0x20(%rsp), %rdi
callq 0xc984
cmpl %r14d, %ebp
jl 0x1f848
jmp 0x1f87e
leaq 0x20(%rsp), %rdi
callq 0xc984
jmp 0x1f87e
leaq 0x20(%rsp), %rdi
callq 0xc984
movq (%rbx), %rax
movq (%rax,%r15), %rsi
addq $0x40, %rsi
leaq 0x18(%rsp), %rdi
callq 0xc950
movq 0x18(%rsp), %rax
movl 0x20(%rax), %ebp
leaq 0x20(%rsp), %rdi
callq 0xc984
movl %ebp, %r14d
andl $0x1, %r14d
addl %ebp, %r14d
movl %r13d, 0xc(%rsp)
incl %r13d
jmp 0x1f77a
movl 0xc(%rsp), %eax
testl %eax, %eax
js 0x1f8a0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x38
popq %rdi
callq 0xa1b0
movq %rax, %r14
leaq 0x35c60(%rip), %rsi     # 0x55512
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0xa150
leaq 0x35c5e(%rip), %rdx     # 0x55526
leaq 0x68(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xc882
movslq 0x10(%rsp), %rsi
shlq $0x4, %rsi
addq (%rbx), %rsi
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
callq 0x12e2e
movb $0x1, %bpl
leaq 0x68(%rsp), %rsi
pushq $0x3
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x19f06
xorl %ebp, %ebp
leaq 0x57c89(%rip), %rsi     # 0x77598
leaq -0xe284(%rip), %rdx     # 0x11692
movq %r14, %rdi
callq 0xa4e0
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xc984
leaq 0x68(%rsp), %rdi
callq 0xa558
jmp 0x1f93d
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x18(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
jne 0x1f951
jmp 0x1f968
movq %rax, %rbx
movq %r14, %rdi
callq 0xa230
jmp 0x1f968
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xc984
movq %rbx, %rdi
callq 0xa500