// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl %esi, 0x8(%rsp)
cmpl %edx, %esi
jg 0x27c24
movl %edx, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl 0x8(%rsp), %eax
movl %eax, %r12d
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl %edx, 0xc(%rsp)
leaq 0x71862(%rip), %rax     # 0x99308
movq (%rax), %rdi
movslq %r12d, %r14
movq (%rbx), %rax
shlq $0x4, %r14
movq (%rax,%r14), %rax
movq 0x40(%rax), %rcx
movq %rcx, 0x18(%rsp)
movq 0x48(%rax), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x27ae3
movq 0x714d3(%rip), %rcx     # 0x98fa8
cmpb $0x0, (%rcx)
je 0x27adf
incl 0x8(%rax)
jmp 0x27ae3
lock
incl 0x8(%rax)
leaq 0x18(%rsp), %rsi
callq 0xdb52
movl %eax, %r15d
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x27aff
callq 0xdcba
testb %r15b, %r15b
je 0x27b17
movq %rbx, %rdi
movl %r12d, %esi
callq 0x27318
movl %eax, %r12d
jmp 0x27c13
movq (%rbx), %rax
movq (%rax,%r14), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %r15
testq %r15, %r15
je 0x27b42
movq 0x71476(%rip), %rcx     # 0x98fa8
cmpb $0x0, (%rcx)
je 0x27b3d
incl 0x8(%r15)
jmp 0x27b42
lock
incl 0x8(%r15)
testq %rax, %rax
je 0x27b7a
testl %ebp, %ebp
js 0x27b81
movq (%rbx), %rax
movq (%rax,%r14), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rcx
movq %rcx, 0x10(%rsp)
testq %rcx, %rcx
je 0x27b91
movq 0x7143d(%rip), %rcx     # 0x98fa8
cmpb $0x0, (%rcx)
je 0x27b88
movq 0x10(%rsp), %rcx
incl 0x8(%rcx)
jmp 0x27b91
movb $0x1, %al
xorl %r13d, %r13d
jmp 0x27b9a
movb $0x1, %al
movb $0x1, %r13b
jmp 0x27b9a
movq 0x10(%rsp), %rcx
lock
incl 0x8(%rcx)
cmpl %ebp, 0x20(%rax)
setl %r13b
xorl %eax, %eax
testb %al, %al
jne 0x27bb0
cmpq $0x0, 0x10(%rsp)
je 0x27bb0
movq 0x10(%rsp), %rdi
callq 0xdcba
testq %r15, %r15
je 0x27bbd
movq %r15, %rdi
callq 0xdcba
testb %r13b, %r13b
je 0x27bec
movq (%rbx), %rax
movq (%rax,%r14), %rcx
movq 0x40(%rcx), %rax
movq 0x48(%rcx), %rdi
testq %rdi, %rdi
movl 0xc(%rsp), %r13d
je 0x27bf7
movq 0x713c6(%rip), %rcx     # 0x98fa8
cmpb $0x0, (%rcx)
je 0x27bf3
incl 0x8(%rdi)
jmp 0x27bf7
movl 0xc(%rsp), %r13d
jmp 0x27c13
lock
incl 0x8(%rdi)
movl 0x20(%rax), %r14d
testq %rdi, %rdi
je 0x27c05
callq 0xdcba
movl %r14d, %ebp
andl $0x1, %ebp
addl %r14d, %ebp
movl %r12d, 0x4(%rsp)
leal 0x1(%r12), %eax
cmpl %r13d, %r12d
movl %eax, %r12d
jl 0x27a9f
movl 0x4(%rsp), %eax
testl %eax, %eax
js 0x27c3b
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x38, %edi
callq 0xa1b0
movq %rax, %r14
leaq 0x68(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4f821(%rip), %rsi     # 0x77479
leaq 0x4f82d(%rip), %rdx     # 0x7748c
leaq 0x58(%rsp), %rdi
callq 0xdf6a
leaq 0x4f81d(%rip), %rsi     # 0x7748d
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 0x27c9d
movups (%rcx), %xmm0
movups %xmm0, (%r12)
jmp 0x27caa
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 0x8(%rsp), %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 0x27cfb
movq 0x712bb(%rip), %rcx     # 0x98fa8
cmpb $0x0, (%rcx)
jne 0x27cf8
lock
incl 0x8(%rax)
jmp 0x27cfb
incl 0x8(%rax)
movb $0x1, %bpl
leaq 0x38(%rsp), %rsi
leaq 0x28(%rsp), %rcx
movq %r14, %rdi
movl $0x3, %edx
callq 0x200e4
xorl %ebp, %ebp
leaq 0x6e91a(%rip), %rsi     # 0x96638
leaq -0x1342d(%rip), %rdx    # 0x148f8
movq %r14, %rdi
callq 0xa4f0
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x27d3f
callq 0xdcba
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x27d56
callq 0xa2b0
jmp 0x27d56
movq %rax, %rbx
movb $0x1, %bpl
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x27d6d
callq 0xa2b0
jmp 0x27d6d
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x27d8e
movq %r14, %rdi
callq 0xa240
jmp 0x27d8e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x27d8e
callq 0xdcba
movq %rbx, %rdi
callq 0xa510