// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rdi, %rbx
cmpl %edx, %esi
jg 0x27f57
movl %edx, %r14d
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %esi, 0x14(%rsp)
movl %esi, %r12d
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
movl %edx, 0x10(%rsp)
leaq 0x7252d(%rip), %rax     # 0x9a308
movq (%rax), %rdi
movslq %r12d, %r13
movq (%rbx), %rax
shlq $0x4, %r13
movq (%rax,%r13), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x48(%rax), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x27e18
movq 0x7219e(%rip), %rcx     # 0x99fa8
cmpb $0x0, (%rcx)
je 0x27e14
incl 0x8(%rax)
jmp 0x27e18
lock
incl 0x8(%rax)
leaq 0x18(%rsp), %rsi
callq 0xdb74
movl %eax, %ebp
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x27e33
callq 0xdce4
testb %bpl, %bpl
je 0x27e4b
movq %rbx, %rdi
movl %r12d, %esi
callq 0x27556
movl %eax, %r12d
jmp 0x27f2b
movq (%rbx), %rax
movq (%rax,%r13), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rbp
testq %rbp, %rbp
je 0x27e74
movq 0x72142(%rip), %rcx     # 0x99fa8
cmpb $0x0, (%rcx)
je 0x27e70
incl 0x8(%rbp)
jmp 0x27e74
lock
incl 0x8(%rbp)
testq %rax, %rax
je 0x27ea3
testl %r15d, %r15d
js 0x27ea8
movq (%rbx), %rax
movq (%rax,%r13), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rdi
testq %rdi, %rdi
je 0x27ead
movq 0x7210f(%rip), %rcx     # 0x99fa8
cmpb $0x0, (%rcx)
je 0x27eb7
incl 0x8(%rdi)
jmp 0x27ebb
xorl %r14d, %r14d
jmp 0x27ec8
movb $0x1, %r14b
jmp 0x27ec8
cmpl %r15d, 0x20(%rax)
setl %r14b
jmp 0x27ec8
lock
incl 0x8(%rdi)
cmpl %r15d, 0x20(%rax)
setl %r14b
callq 0xdce4
testq %rbp, %rbp
je 0x27ed5
movq %rbp, %rdi
callq 0xdce4
testb %r14b, %r14b
je 0x27f04
movq (%rbx), %rax
movq (%rax,%r13), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rdi
testq %rdi, %rdi
movl 0x10(%rsp), %r14d
je 0x27f0b
movq 0x720ae(%rip), %rcx     # 0x99fa8
cmpb $0x0, (%rcx)
je 0x27f10
incl 0x8(%rdi)
jmp 0x27f14
movl 0x10(%rsp), %r14d
jmp 0x27f2b
movl 0x20(%rax), %ebp
jmp 0x27f1c
lock
incl 0x8(%rdi)
movl 0x20(%rax), %ebp
callq 0xdce4
movl %ebp, %r15d
andl $0x1, %r15d
addl %ebp, %r15d
movl %r12d, 0xc(%rsp)
leal 0x1(%r12), %eax
cmpl %r14d, %r12d
movl %eax, %r12d
jl 0x27dd4
movl 0xc(%rsp), %eax
testl %eax, %eax
movl 0x14(%rsp), %esi
js 0x27f57
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %ebp
movl $0x38, %edi
callq 0xa1b0
movq %rax, %r14
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x50503(%rip), %rsi     # 0x78479
leaq 0x5050f(%rip), %rdx     # 0x7848c
leaq 0x58(%rsp), %rdi
callq 0xdfa8
leaq 0x504ff(%rip), %rsi     # 0x7848d
leaq 0x58(%rsp), %rdi
callq 0xa560
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x27fbb
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x27fc8
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
movq 0x8(%rax), %rdx
movq %rdx, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movslq %ebp, %rax
movq (%rbx), %rcx
shlq $0x4, %rax
movq (%rcx,%rax), %rdx
movq %rdx, 0x28(%rsp)
movq 0x8(%rcx,%rax), %rax
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x28017
movq 0x71f9f(%rip), %rcx     # 0x99fa8
cmpb $0x0, (%rcx)
jne 0x28014
lock
incl 0x8(%rax)
jmp 0x28017
incl 0x8(%rax)
movb $0x1, %bpl
leaq 0x38(%rsp), %rsi
leaq 0x28(%rsp), %rcx
movq %r14, %rdi
movl $0x3, %edx
callq 0x203f4
xorl %ebp, %ebp
leaq 0x6f5fe(%rip), %rsi     # 0x97638
leaq -0x1351b(%rip), %rdx    # 0x14b26
movq %r14, %rdi
callq 0xa4f0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2805b
callq 0xdce4
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x2806a
callq 0xa2b0
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x28079
callq 0xa2b0
testb %bpl, %bpl
jne 0x28097
jmp 0x280b3
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x28097
callq 0xa2b0
jmp 0x28097
movq %rax, %rbx
movq %r14, %rdi
callq 0xa240
jmp 0x280b3
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x280b3
callq 0xdce4
movq %rbx, %rdi
callq 0xa510