// File: /workspace/github_cpp_makefile_star2_O3/janthonyo[P]Redes-Practicas/funcionesServer.cc
// Function: canPutPiece(int, domino&)
bool canPutPiece(int i, domino& game)
{
    //Devuelve true si tienes piezas disponibles para colocar, false si no
    //i es el sd de quien envio el mensaje, tambien identificado como i en server.cc
    if(i==game.getSocketP1())
    {
        for (int j = 0; j < (int) game.getHand1().size(); j++) {
            //Comprueba si coincide first
            if(game.getFirst() == game.getHand1()[j].left)
            {
                return true;
            }
            if(game.getFirst() == game.getHand1()[j].right)
            {
                return true;
            }

            //Comprueba si coincide last
            if(game.getLast() == game.getHand1()[j].left)
            {
                return true;
            }
            if(game.getLast() == game.getHand1()[j].right)
            {
                return true;
            }
        }
    }

    else if(i==game.getSocketP2())
    {
        for (int j = 0; j < (int) game.getHand2().size(); j++) {
            //Comprueba si coincide first
            if(game.getFirst() == game.getHand2()[j].left)
            {
                return true;
            }
            if(game.getFirst() == game.getHand2()[j].right)
            {
                return true;
            }

            //Comprueba si coincide last
            if(game.getLast() == game.getHand2()[j].left)
            {
                return true;
            }
            if(game.getLast() == game.getHand2()[j].right)
            {
                return true;
            }
        }
    }

    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl %edi, 0x94(%rsi)
movq %rsi, -0x58(%rbp)
jne 0x83d4
leaq 0x98(%rsi), %r12
xorl %r13d, %r13d
leaq -0x48(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
subq %rdi, %rax
shrq $0x3, %rax
movslq %eax, %r14
cmpq %r14, %r13
setl %al
movl %eax, -0x4c(%rbp)
testq %rdi, %rdi
je 0x82ef
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpq %r14, %r13
jge 0x8502
movq -0x58(%rbp), %r15
movl 0x130(%r15), %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %r12, %r14
movl (%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x130(%r15), %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl 0x4(%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x134(%r15), %eax
movl %eax, -0x2c(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl (%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x134(%r15), %r15d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl 0x4(%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
incq %r13
cmpl %r12d, %r15d
movq %r14, %r12
jne 0x82b8
jmp 0x8502
cmpl %edi, 0x114(%rsi)
jne 0x84fb
leaq 0x118(%rsi), %r12
xorl %r13d, %r13d
leaq -0x48(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
subq %rdi, %rax
shrq $0x3, %rax
movslq %eax, %r14
cmpq %r14, %r13
setl %al
movl %eax, -0x4c(%rbp)
testq %rdi, %rdi
je 0x8425
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21f0
cmpq %r14, %r13
movq -0x58(%rbp), %rbx
jge 0x8502
movl 0x130(%rbx), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %r12, %r14
movl (%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x130(%rbx), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl 0x4(%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x134(%rbx), %eax
movl %eax, -0x2c(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl (%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
cmpl %r12d, -0x2c(%rbp)
je 0x8502
movl 0x134(%rbx), %ebx
movq %r15, %rdi
movq %r14, %rsi
callq 0x5188
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl 0x4(%rdi,%r13,8), %r12d
subq %rdi, %rsi
callq 0x21f0
incq %r13
cmpl %r12d, %ebx
movq %r14, %r12
jne 0x83ee
jmp 0x8502
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq