// File: 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
subq $0x170, %rsp            # imm = 0x170
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x114(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b30
movl %eax, %ecx
movl -0x114(%rbp), %eax
cmpl %ecx, %eax
jne 0xfe39
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x118(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x7ce0
leaq -0x30(%rbp), %rdi
callq 0x8bc0
movl %eax, -0x11c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x76a0
movl -0x11c(%rbp), %ecx
movl -0x118(%rbp), %eax
cmpl %ecx, %eax
jge 0xfe34
movq -0x10(%rbp), %rdi
callq 0x10be0
movl %eax, -0x120(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x7ce0
movslq -0x14(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9750
movl (%rax), %eax
movl %eax, -0x124(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x76a0
movl -0x124(%rbp), %ecx
movl -0x120(%rbp), %eax
cmpl %ecx, %eax
jne 0xfd20
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10be0
movl %eax, -0x128(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x7ce0
movslq -0x14(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x9750
movl 0x4(%rax), %eax
movl %eax, -0x12c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x76a0
movl -0x12c(%rbp), %ecx
movl -0x128(%rbp), %eax
cmpl %ecx, %eax
jne 0xfd74
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10c00
movl %eax, -0x130(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x7ce0
movslq -0x14(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x9750
movl (%rax), %eax
movl %eax, -0x134(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x76a0
movl -0x134(%rbp), %ecx
movl -0x130(%rbp), %eax
cmpl %ecx, %eax
jne 0xfdc7
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10c00
movl %eax, -0x138(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x7ce0
movslq -0x14(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x9750
movl 0x4(%rax), %eax
movl %eax, -0x13c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x76a0
movl -0x13c(%rbp), %ecx
movl -0x138(%rbp), %eax
cmpl %ecx, %eax
jne 0xfe24
movb $0x1, -0x1(%rbp)
jmp 0x10049
jmp 0xfe26
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xfc8b
jmp 0x10045
movl -0x8(%rbp), %eax
movl %eax, -0x140(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7b50
movl %eax, %ecx
movl -0x140(%rbp), %eax
cmpl %ecx, %eax
jne 0x10043
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x144(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x7d20
leaq -0xb0(%rbp), %rdi
callq 0x8bc0
movl %eax, -0x148(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x76a0
movl -0x148(%rbp), %ecx
movl -0x144(%rbp), %eax
cmpl %ecx, %eax
jge 0x10041
movq -0x10(%rbp), %rdi
callq 0x10be0
movl %eax, -0x14c(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x7d20
movslq -0x94(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x9750
movl (%rax), %eax
movl %eax, -0x150(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x76a0
movl -0x150(%rbp), %ecx
movl -0x14c(%rbp), %eax
cmpl %ecx, %eax
jne 0xff12
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10be0
movl %eax, -0x154(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x7d20
movslq -0x94(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x9750
movl 0x4(%rax), %eax
movl %eax, -0x158(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x76a0
movl -0x158(%rbp), %ecx
movl -0x154(%rbp), %eax
cmpl %ecx, %eax
jne 0xff72
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10c00
movl %eax, -0x15c(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x7d20
movslq -0x94(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x9750
movl (%rax), %eax
movl %eax, -0x160(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x76a0
movl -0x160(%rbp), %ecx
movl -0x15c(%rbp), %eax
cmpl %ecx, %eax
jne 0xffce
movb $0x1, -0x1(%rbp)
jmp 0x10049
movq -0x10(%rbp), %rdi
callq 0x10c00
movl %eax, -0x164(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x7d20
movslq -0x94(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x9750
movl 0x4(%rax), %eax
movl %eax, -0x168(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x76a0
movl -0x168(%rbp), %ecx
movl -0x164(%rbp), %eax
cmpl %ecx, %eax
jne 0x1002b
movb $0x1, -0x1(%rbp)
jmp 0x10049
jmp 0x1002d
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xfe65
jmp 0x10043
jmp 0x10045
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw (%rax,%rax)