// File: /workspace/github_cpp_makefile_star2_O2/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), %rax
movq %rax, -0x40(%rbp)
leaq 0x118(%rdi), %rax
movq %rax, -0x38(%rbp)
pushq $0x6
popq %r14
leaq -0x70(%rbp), %r15
testl %r14d, %r14d
js 0x4260
movl %r14d, %r13d
movabsq $0x100000001, %rax      # imm = 0x100000001
imulq %rax, %r13
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0x4b12
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x43fc
movl %eax, %r12d
movq %r15, %rdi
callq 0x4d28
testb %r12b, %r12b
je 0x4210
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4b6a
testb %al, %al
je 0x4258
jmp 0x4344
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
movq -0x38(%rbp), %rsi
callq 0x4b12
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x43fc
movl %eax, %r12d
movq %r15, %rdi
leaq -0x70(%rbp), %r15
callq 0x4d28
testb %r12b, %r12b
je 0x4258
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4b6a
testb %al, %al
jne 0x435b
decl %r14d
jmp 0x41b8
pushq $0x6
popq %r14
leaq -0x58(%rbp), %r12
testl %r14d, %r14d
js 0x4369
movl %r14d, %r15d
movabsq $0x100000001, %rax      # imm = 0x100000001
imulq %rax, %r15
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %r15
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x4330
movq %r12, %rdi
movq -0x40(%rbp), %rsi
callq 0x4b12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x43fc
movl %eax, %r13d
movq %r12, %rdi
callq 0x4d28
testb %r13b, %r13b
je 0x42d7
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4b6a
testb %al, %al
je 0x431b
jmp 0x433c
leaq -0x88(%rbp), %r12
movq %r12, %rdi
movq -0x38(%rbp), %rsi
callq 0x4b12
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x43fc
movl %eax, %r13d
movq %r12, %rdi
leaq -0x58(%rbp), %r12
callq 0x4d28
testb %r13b, %r13b
je 0x431b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4b6a
testb %al, %al
jne 0x4353
decl %r14d
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
addq %rax, %r15
jmp 0x4293
movl -0x2c(%rbp), %r14d
decl %r14d
jmp 0x4268
movq %rbx, %rdi
movq %r15, %rsi
jmp 0x434a
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4c08
pushq $0x2
jmp 0x4368
movq %rbx, %rdi
movq %r15, %rsi
jmp 0x4361
movq %rbx, %rdi
movq %r13, %rsi
callq 0x4c98
pushq $0x1
popq %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq