// File: /workspace/github_cpp_makefile_star2_O1/BohangZhang[P]Sorcery-C-Project/player.cc
// Function: Player::play(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Player::play(int i, int p, string t) {
    if (getHand()->getHand().size() < i) throw 7; // Number; The card doesn't exist
    else {
        shared_ptr<Card> c = getHand()->getHand()[i - 1];
        if (getMagic() < c->getCost()) throw 6; // Number; You don't have enough Magic
        string card_type = c->getType();
        if (card_type == "Spell") { 
            c->action(p,t);
            getHand()->pop(i);
        } else if (card_type == "Enchantment") {
            if (t == "r") throw 9; // Number; Wrong command, Enchantment can't be played on Ritual
            
            shared_ptr<Player> targetplayer {nullptr};
            if (p == 1) {targetplayer = getGame()->get1();} 
            else {targetplayer = getGame()->get2();}   
    
            int j;
            istringstream ss{t};
            ss >> j;
            shared_ptr<Minion> m = targetplayer->getSlot()->getSlot()[j - 1];
            shared_ptr<Minion> h = dynamic_pointer_cast<Minion>(c);
            h->setOrigin(m);
            targetplayer->getSlot()->getSlot()[j - 1] = h;
            getHand()->pop(i);
        } else throw 10; // Number; Wrong command, this card can't be played to a target
        subMagic(c->getCost());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rcx, %r13
movl %edx, %r12d
movl %esi, %r15d
movq %rdi, %r14
movq 0x38(%rdi), %rdi
movq 0x40(%r14), %rbx
testq %rbx, %rbx
je 0x1899b
movq 0x1b633(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18997
incl 0x8(%rbx)
jmp 0x1899b
lock
incl 0x8(%rbx)
callq 0x16056
movq 0x8(%rax), %rbp
subq (%rax), %rbp
sarq $0x4, %rbp
movl %r15d, 0x18(%rsp)
movslq %r15d, %r15
testq %rbx, %rbx
je 0x189c0
movq %rbx, %rdi
callq 0xb634
cmpq %r15, %rbp
jb 0x18e2a
movq 0x38(%r14), %rdi
movq 0x40(%r14), %rbp
testq %rbp, %rbp
je 0x189eb
movq 0x1b5e3(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x189e7
incl 0x8(%rbp)
jmp 0x189eb
lock
incl 0x8(%rbp)
callq 0x16056
movq (%rax), %rax
shlq $0x4, %r15
movq -0x10(%rax,%r15), %rcx
movq %rcx, 0x10(%rsp)
movq -0x8(%rax,%r15), %rbx
testq %rbx, %rbx
je 0x18a20
movq 0x1b5ae(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18a1c
incl 0x8(%rbx)
jmp 0x18a20
lock
incl 0x8(%rbx)
testq %rbp, %rbp
je 0x18a2d
movq %rbp, %rdi
callq 0xb634
movl 0x24(%r14), %ebp
movq 0x10(%rsp), %rdi
callq 0xe85e
cmpl %eax, %ebp
jl 0x18e4b
leaq 0x60(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0xe816
leaq 0xee8f(%rip), %rsi      # 0x278e8
leaq 0x60(%rsp), %rdi
callq 0x50a0
testl %eax, %eax
je 0x18ad0
leaq 0xfe04(%rip), %rsi      # 0x28872
leaq 0x60(%rsp), %rdi
callq 0x50a0
testl %eax, %eax
jne 0x18e6c
leaq 0xee0b(%rip), %rsi      # 0x27892
movq %r13, %rdi
callq 0x50a0
testl %eax, %eax
je 0x18e73
cmpl $0x1, %r12d
jne 0x18b3b
movq 0x88(%r14), %rsi
movq 0x90(%r14), %rbp
testq %rbp, %rbp
je 0x18b72
movq 0x1b501(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18b6e
incl 0x8(%rbp)
jmp 0x18b72
leaq 0x50(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xb6a4
movq 0x10(%rsp), %rdi
movq (%rdi), %rax
leaq 0x40(%rsp), %rdx
movl %r12d, %esi
callq *0x48(%rax)
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x18b18
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%r14), %rdi
movq 0x40(%r14), %r15
testq %r15, %r15
movl 0x18(%rsp), %esi
je 0x18b64
movq 0x1b490(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18b5f
incl 0x8(%r15)
jmp 0x18b64
movq 0x88(%r14), %rsi
movq 0x90(%r14), %rbp
testq %rbp, %rbp
je 0x18b85
movq 0x1b46b(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18b81
incl 0x8(%rbp)
jmp 0x18b85
lock
incl 0x8(%r15)
callq 0x16088
jmp 0x18dcf
lock
incl 0x8(%rbp)
leaq 0x80(%rsp), %rdi
callq 0x12096
jmp 0x18b92
lock
incl 0x8(%rbp)
leaq 0x80(%rsp), %rdi
callq 0x120c2
movq 0x80(%rsp), %r12
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0x18bc4
callq 0xb634
testq %rbp, %rbp
je 0x18bd1
movq %rbp, %rdi
callq 0xb634
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
movl $0x8, %edx
callq 0x52e0
leaq 0x80(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0x5130
movq 0x48(%r12), %rdi
movq 0x50(%r12), %rbp
testq %rbp, %rbp
je 0x18c1c
movq 0x1b3b2(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18c18
incl 0x8(%rbp)
jmp 0x18c1c
lock
incl 0x8(%rbp)
callq 0x24706
movslq 0x1c(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r15
movq -0x8(%rax,%rcx), %r13
testq %r13, %r13
je 0x18c53
movq 0x1b37d(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18c4e
incl 0x8(%r13)
jmp 0x18c53
lock
incl 0x8(%r13)
testq %rbp, %rbp
je 0x18c60
movq %rbp, %rdi
callq 0xb634
leaq 0x1a449(%rip), %rsi     # 0x330b0
leaq 0x1ad2a(%rip), %rdx     # 0x33998
movq 0x10(%rsp), %rdi
xorl %ecx, %ecx
callq 0x5220
testq %rax, %rax
je 0x18c9f
movq %rax, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
testq %rbx, %rbx
je 0x18cad
movq 0x1b32b(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18ca9
incl 0x8(%rbx)
jmp 0x18cad
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
jmp 0x18cad
lock
incl 0x8(%rbx)
movq 0x20(%rsp), %rdi
movq %r15, 0x30(%rsp)
movq %r13, 0x38(%rsp)
testq %r13, %r13
movl 0x18(%rsp), %r15d
je 0x18cdd
movq 0x1b2f3(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18cd8
incl 0x8(%r13)
jmp 0x18cdd
lock
incl 0x8(%r13)
movq (%rdi), %rax
leaq 0x30(%rsp), %rsi
callq *0xf8(%rax)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x18cfa
callq 0xb634
movq 0x48(%r12), %rdi
movq 0x50(%r12), %rbp
testq %rbp, %rbp
je 0x18d1e
movq 0x1b2b0(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18d1a
incl 0x8(%rbp)
jmp 0x18d1e
lock
incl 0x8(%rbp)
callq 0x24706
movslq 0x1c(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq 0x28(%rsp), %rsi
movq -0x8(%rsi), %rdx
leaq (%rax,%rcx), %rdi
addq $-0x8, %rdi
movq %rdx, -0x8(%rdi)
callq 0xe8da
testq %rbp, %rbp
je 0x18d56
movq %rbp, %rdi
callq 0xb634
movq 0x38(%r14), %rdi
movq 0x40(%r14), %rbp
testq %rbp, %rbp
je 0x18d78
movq 0x1b256(%rip), %rax     # 0x33fc0
cmpb $0x0, (%rax)
je 0x18d74
incl 0x8(%rbp)
jmp 0x18d78
lock
incl 0x8(%rbp)
movl %r15d, %esi
callq 0x16088
testq %rbp, %rbp
je 0x18d8d
movq %rbp, %rdi
callq 0xb634
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18d9c
callq 0xb634
testq %r13, %r13
je 0x18da9
movq %r13, %rdi
callq 0xb634
movq 0x1b200(%rip), %rsi     # 0x33fb0
leaq 0x80(%rsp), %rdi
callq 0x5280
leaq 0xf8(%rsp), %rdi
callq 0x50b0
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x18ddc
movq %r15, %rdi
callq 0xb634
movq 0x10(%rsp), %rdi
callq 0xe85e
movq %r14, %rdi
movl %eax, %esi
callq 0x17cb4
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18e0b
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x51f0
testq %rbx, %rbx
je 0x18e18
movq %rbx, %rdi
callq 0xb634
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x5100
movl $0x7, (%rax)
movq 0x1b14f(%rip), %rsi     # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0x4, %edi
callq 0x5100
movl $0x6, (%rax)
movq 0x1b12e(%rip), %rsi     # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0xa, %ebp
jmp 0x18e78
movl $0x9, %ebp
movl $0x4, %edi
callq 0x5100
movl %ebp, (%rax)
movq 0x1b105(%rip), %rsi     # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
jmp 0x18e97
movq %rax, %r14
testq %rbp, %rbp
je 0x18ea7
movq %rbp, %rdi
callq 0xb634
movq $0x0, 0x8(%rsp)
jmp 0x18f57
movq %rax, %r14
testq %r15, %r15
je 0x18f89
movq %r15, %rdi
jmp 0x18f64
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %r15, %rdi
je 0x18f89
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x18f89
jmp 0x18eee
movq %rax, %r14
jmp 0x18efb
movq %rax, %r14
movq 0x38(%rsp), %rbp
testq %rbp, %rbp
je 0x18f08
movq %rbp, %rdi
callq 0xb634
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18f17
callq 0xb634
testq %r13, %r13
je 0x18f36
movq %r13, %rdi
jmp 0x18f2c
movq %rax, %r14
testq %rbp, %rbp
je 0x18f36
movq %rbp, %rdi
callq 0xb634
jmp 0x18f36
movq %rax, %r14
movq 0x1b073(%rip), %rsi     # 0x33fb0
leaq 0x80(%rsp), %rdi
callq 0x5280
leaq 0xf8(%rsp), %rdi
callq 0x50b0
cmpq $0x0, 0x8(%rsp)
je 0x18f89
movq 0x8(%rsp), %rdi
callq 0xb634
jmp 0x18f89
movq %rax, %r14
jmp 0x18f57
jmp 0x18f81
movq %rax, %r14
movq %rbp, %rbx
testq %rbp, %rbp
jne 0x18fa9
jmp 0x18fb1
jmp 0x18f81
movq %rax, %r14
jmp 0x18fa4
movq %rax, %r14
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18fa4
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x51f0
testq %rbx, %rbx
je 0x18fb1
movq %rbx, %rdi
callq 0xb634
movq %r14, %rdi
callq 0x5320
nop