// File: /workspace/github_cpp_makefile_star2_O1/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 $0x88, %rsp
movq %rdi, %rbx
leaq 0x98(%rdi), %rax
movq %rax, -0x50(%rbp)
leaq 0x118(%rdi), %rax
movq %rax, -0x48(%rbp)
movq $-0x7, %r13
movabsq $0x600000006, %r12      # imm = 0x600000006
xorl %r14d, %r14d
leaq -0xb0(%rbp), %r15
movq %r15, %rdi
movq -0x50(%rbp), %rsi
callq 0x52c4
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4d42
movl %eax, %r15d
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x4aa4
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x4aba
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5344
testb %al, %al
je 0x4b0d
jmp 0x4b29
leaq -0x98(%rbp), %r15
movq %r15, %rdi
movq -0x48(%rbp), %rsi
callq 0x52c4
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x4d42
movl %eax, %r15d
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0x4af9
movq -0x88(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r15b, %r15b
je 0x4b0d
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5344
testb %al, %al
jne 0x4b3d
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
addq %rax, %r12
incq %r13
sete %r14b
jne 0x4a65
jmp 0x4b4f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x541c
movl $0x2, -0x2c(%rbp)
jmp 0x4b4f
movq %rbx, %rdi
movq %r12, %rsi
callq 0x54e2
movl $0x1, -0x2c(%rbp)
testb $0x1, %r14b
je 0x4c8a
movl $0x6, %r13d
movabsq $0x500000006, %r15      # imm = 0x500000006
testq %r13, %r13
sete %r14b
je 0x4c6d
movq %r15, -0x38(%rbp)
movq %r13, -0x40(%rbp)
leaq -0x80(%rbp), %r12
movq %r12, %rdi
movq -0x50(%rbp), %rsi
callq 0x52c4
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4d42
movl %eax, %r12d
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x4bb4
movq -0x70(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r12b, %r12b
je 0x4bca
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5344
testb %al, %al
je 0x4c14
jmp 0x4c3f
leaq -0x68(%rbp), %r12
movq %r12, %rdi
movq -0x48(%rbp), %rsi
callq 0x52c4
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4d42
movl %eax, %r12d
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x4c00
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
testb %r12b, %r12b
je 0x4c14
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5344
testb %al, %al
jne 0x4c53
cmpq $0x2, %r13
setl %r14b
leaq -0x1(%r13), %rax
movabsq $-0x100000001, %rcx     # imm = 0xFFFFFFFEFFFFFFFF
addq %rcx, %r15
incq %r15
cmpq $0x1, %r13
movq %rax, %r13
jg 0x4b7e
jmp 0x4c65
movq %rbx, %rdi
movq %r15, %rsi
callq 0x541c
movl $0x2, -0x2c(%rbp)
jmp 0x4c65
movq %rbx, %rdi
movq %r15, %rsi
callq 0x54e2
movl $0x1, -0x2c(%rbp)
movq -0x40(%rbp), %r13
movq -0x38(%rbp), %r15
testb $0x1, %r14b
je 0x4c8a
movabsq $-0x100000001, %rax     # imm = 0xFFFFFFFEFFFFFFFF
addq %rax, %r15
addq $-0x1, %r13
jb 0x4b69
movl -0x2c(%rbp), %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop