// File: /workspace/github_c_makefile_star2_O0/upcrob[P]garry/chess.c
// Function: moveLoopDetected()
int moveLoopDetected()
{
	// setup variables
	int i, j, type, len, dupCount;
	int duplicates[MQ_SIZE];
	if (queueFull == TRUE)
		len = MQ_SIZE;
	else
		len = queueIndex;
	
	// clear duplicate array
	for (i = 0; i < len; i++)
		duplicates[i] = 0;
	
	// check for duplicates
	type = 1;
	for (i = 0; i < len; i++)
	{
		// go to next move if this has been classified
		if (duplicates[i] != 0)
			continue;
		
		// classify
		duplicates[i] = type;
		
		// classify next moves
		for (j = i + 1; j < len; j++)
		{
			// skip if classified
			if (duplicates[j] != 0)
				continue;
		
			Move* a = moveQueue[i];
			Move* b = moveQueue[j];
			if (a->pieceId == b->pieceId && a->startRow == b->startRow &&
				a->startCol == b->startCol && a->endRow == b->endRow &&
				a->endCol == b->endCol)
			{
				// moves were the same
				duplicates[j] = type;
			}
		}
				
		// next type
		type++;
	}
	
	// count duplicates
	int playerDup = 0;
	for (i = 1; i <= type; i++)
	{
		dupCount = 0;
		for (j = 0; j < len; j++)
		{
			if (duplicates[j] == i)
				dupCount++;
		}
		
		if (dupCount > MAX_REPEATS)
		{
			playerDup++;
			if (playerDup > 1)
				return TRUE;
		}
	}
	
	return FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
cmpl $0x1, 0x17b35(%rip)     # 0x21604
jne 0x9ada
movl $0x14, -0x14(%rbp)
jmp 0x9ae3
movl 0x17b20(%rip), %eax     # 0x21600
movl %eax, -0x14(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9b09
movslq -0x8(%rbp), %rax
movl $0x0, -0x70(%rbp,%rax,4)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x9aea
movl $0x1, -0x10(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9c1d
movslq -0x8(%rbp), %rax
cmpl $0x0, -0x70(%rbp,%rax,4)
je 0x9b33
jmp 0x9c0f
movl -0x10(%rbp), %ecx
movslq -0x8(%rbp), %rax
movl %ecx, -0x70(%rbp,%rax,4)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9c06
movslq -0xc(%rbp), %rax
cmpl $0x0, -0x70(%rbp,%rax,4)
je 0x9b63
jmp 0x9bf8
movq 0x17a8e(%rip), %rax     # 0x215f8
movslq -0x8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq 0x17a7b(%rip), %rax     # 0x215f8
movslq -0xc(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rax
movsbl (%rax), %eax
movq -0x80(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x9bf6
movq -0x78(%rbp), %rax
movsbl 0x1(%rax), %eax
movq -0x80(%rbp), %rcx
movsbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9bf6
movq -0x78(%rbp), %rax
movsbl 0x2(%rax), %eax
movq -0x80(%rbp), %rcx
movsbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9bf6
movq -0x78(%rbp), %rax
movsbl 0x3(%rax), %eax
movq -0x80(%rbp), %rcx
movsbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9bf6
movq -0x78(%rbp), %rax
movsbl 0x4(%rax), %eax
movq -0x80(%rbp), %rcx
movsbl 0x4(%rcx), %ecx
cmpl %ecx, %eax
jne 0x9bf6
movl -0x10(%rbp), %ecx
movslq -0xc(%rbp), %rax
movl %ecx, -0x70(%rbp,%rax,4)
jmp 0x9bf8
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9b47
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x9b17
movl $0x0, -0x84(%rbp)
movl $0x1, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x9ca5
movl $0x0, -0x18(%rbp)
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x9c6f
movslq -0xc(%rbp), %rax
movl -0x70(%rbp,%rax,4), %eax
cmpl -0x8(%rbp), %eax
jne 0x9c62
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9c64
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9c44
cmpl $0x3, -0x18(%rbp)
jle 0x9c98
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
cmpl $0x1, -0x84(%rbp)
jle 0x9c96
movl $0x1, -0x4(%rbp)
jmp 0x9cac
jmp 0x9c98
jmp 0x9c9a
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x9c2e
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)