// File: /workspace/github_cpp_makefile_star2_O3/janthonyo[P]Redes-Practicas/./domino.cc
// Function: domino::startPlayer()
int startPlayer()
	{
		ficha aux;

		// Comprobamos quien tiene el doble mayor
		for (int i = 6; i >= 0; i--)
		{
			aux.left = i;
			aux.right = i;

			if(hasFicha(aux, player1.hand))
			{
				if(putInBoard(aux))
				{
					quitPieceJ1(aux);
					return 2;
				}
			}

			else if(hasFicha(aux, player2.hand))
			{
				if(putInBoard(aux))
				{
					quitPieceJ2(aux);
					return 1;
				}
			}

		}

		// Comprobamos quien tiene la ficha mas alta
		for (int i = 6; i >= 0; i--)
		{
			for (int j = i - 1; j >= 0; j--)
			{
				aux.left = i;
				aux.right = j;

				if(hasFicha(aux, player1.hand))
				{
					if(putInBoard(aux))
					{
						quitPieceJ1(aux);
						return 2;
					}
				}

				else if(hasFicha(aux, player2.hand))
				{
					if(putInBoard(aux))
					{
						quitPieceJ2(aux);
						return 1;
					}
				}
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x98(%rdi), %r14
leaq 0x118(%rdi), %rax
movq %rax, -0x30(%rbp)
movq $-0x7, %r13
movabsq $0x600000006, %r12      # imm = 0x600000006
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5188
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4bf6
movl %eax, %r15d
movq -0xa0(%rbp), %rdi
testq %rdi, %rdi
je 0x49b3
movq -0x90(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x49cc
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5208
testb %al, %al
je 0x4a20
jmp 0x4b1b
leaq -0x88(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rsi
callq 0x5188
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4bf6
movl %eax, %r15d
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0x4a08
movq -0x78(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x4a20
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5208
testb %al, %al
jne 0x4b35
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
addq %rax, %r12
incq %r13
jne 0x4975
movl $0x7, %r12d
movabsq $0x500000006, %r13      # imm = 0x500000006
movq %r13, -0x38(%rbp)
movq %r12, -0x40(%rbp)
leaq -0x70(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x5188
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4bf6
movl %eax, %r15d
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x4a83
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x4a99
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5208
testb %al, %al
je 0x4ae3
jmp 0x4b13
leaq -0x58(%rbp), %r15
movq %r15, %rdi
movq -0x30(%rbp), %rsi
callq 0x5188
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x4bf6
movl %eax, %r15d
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0x4acf
movq -0x48(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x4ae3
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5208
testb %al, %al
jne 0x4b2d
decq %r12
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
addq %rax, %r13
incq %r13
cmpq $0x1, %r12
jg 0x4a4e
movq -0x40(%rbp), %r12
decq %r12
movq -0x38(%rbp), %r13
addq %rax, %r13
jmp 0x4a46
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x4b21
movq %rbx, %rdi
movq %r12, %rsi
callq 0x52da
movl $0x2, %eax
jmp 0x4b45
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x4b3b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x53a2
movl $0x1, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq