// File: /workspace/github_cpp_makefile_star2_O3/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 0x18851
movq 0x1a77d(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x1884d
incl 0x8(%rbx)
jmp 0x18851
lock
incl 0x8(%rbx)
callq 0x15f86
movq 0x8(%rax), %rbp
subq (%rax), %rbp
sarq $0x4, %rbp
movl %r15d, 0x8(%rsp)
movslq %r15d, %r15
testq %rbx, %rbx
je 0x18876
movq %rbx, %rdi
callq 0xb478
cmpq %r15, %rbp
jb 0x18cd0
movq 0x38(%r14), %rdi
movq 0x40(%r14), %rbp
testq %rbp, %rbp
je 0x188a1
movq 0x1a72d(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x1889d
incl 0x8(%rbp)
jmp 0x188a1
lock
incl 0x8(%rbp)
callq 0x15f86
movq (%rax), %rax
shlq $0x4, %r15
movq -0x10(%rax,%r15), %rcx
movq %rcx, 0x18(%rsp)
movq -0x8(%rax,%r15), %r15
testq %r15, %r15
je 0x188d8
movq 0x1a6f8(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x188d3
incl 0x8(%r15)
jmp 0x188d8
lock
incl 0x8(%r15)
testq %rbp, %rbp
je 0x188e5
movq %rbp, %rdi
callq 0xb478
movl 0x24(%r14), %ebx
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0xe63e
cmpl %eax, %ebx
jl 0x18cf1
leaq 0x60(%rsp), %rdi
movq %rbp, %rsi
callq 0xe5f6
leaq 0xdfd6(%rip), %rsi      # 0x268e8
leaq 0x60(%rsp), %rdi
callq 0x50a0
testl %eax, %eax
je 0x18989
leaq 0xef4b(%rip), %rsi      # 0x27872
leaq 0x60(%rsp), %rdi
callq 0x50a0
testl %eax, %eax
jne 0x18d12
leaq 0xdf52(%rip), %rsi      # 0x26892
movq %r13, %rdi
callq 0x50a0
testl %eax, %eax
je 0x18d19
cmpl $0x1, %r12d
jne 0x189ee
movq 0x88(%r14), %rsi
movq 0x90(%r14), %rbp
testq %rbp, %rbp
je 0x18a28
movq 0x1a648(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18a24
incl 0x8(%rbp)
jmp 0x18a28
leaq 0x50(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0xb4e8
movq (%rbp), %rax
leaq 0x40(%rsp), %rdx
movq %rbp, %rdi
movl %r12d, %esi
callq *0x48(%rax)
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x189d0
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%r14), %rdi
movq 0x40(%r14), %rbx
testq %rbx, %rbx
je 0x18a16
movq 0x1a5dc(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18a12
incl 0x8(%rbx)
jmp 0x18a16
movq 0x88(%r14), %rsi
movq 0x90(%r14), %rbp
testq %rbp, %rbp
je 0x18a3b
movq 0x1a5b8(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18a37
incl 0x8(%rbp)
jmp 0x18a3b
lock
incl 0x8(%rbx)
movl 0x8(%rsp), %esi
callq 0x15fb8
jmp 0x18c77
lock
incl 0x8(%rbp)
leaq 0x80(%rsp), %rdi
callq 0x11e6a
jmp 0x18a48
lock
incl 0x8(%rbp)
leaq 0x80(%rsp), %rdi
callq 0x11e96
movq 0x80(%rsp), %rbx
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
testq %rbp, %rbp
je 0x18a75
movq %rbp, %rdi
callq 0xb478
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
movl $0x8, %edx
callq 0x52e0
leaq 0x80(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x5130
movq 0x48(%rbx), %rdi
movq 0x50(%rbx), %rbp
testq %rbp, %rbp
je 0x18abe
movq 0x1a510(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18aba
incl 0x8(%rbp)
jmp 0x18abe
lock
incl 0x8(%rbp)
callq 0x243d6
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r12
movq -0x8(%rax,%rcx), %r13
testq %r13, %r13
je 0x18af5
movq 0x1a4db(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18af0
incl 0x8(%r13)
jmp 0x18af5
lock
incl 0x8(%r13)
testq %rbp, %rbp
je 0x18b02
movq %rbp, %rdi
callq 0xb478
leaq 0x195a7(%rip), %rsi     # 0x320b0
leaq 0x19e88(%rip), %rdx     # 0x32998
movq 0x18(%rsp), %rdi
xorl %ecx, %ecx
callq 0x5220
testq %rax, %rax
je 0x18b42
movq %rax, 0x20(%rsp)
movq %r15, 0x28(%rsp)
testq %r15, %r15
je 0x18b58
movq 0x1a489(%rip), %rcx     # 0x32fc0
cmpb $0x0, (%rcx)
je 0x18b4e
incl 0x8(%r15)
jmp 0x18b58
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
xorl %eax, %eax
jmp 0x18b58
lock
incl 0x8(%r15)
movq 0x20(%rsp), %rax
movq %r12, 0x30(%rsp)
movq %r13, 0x38(%rsp)
testq %r13, %r13
je 0x18b7e
movq 0x1a452(%rip), %rcx     # 0x32fc0
cmpb $0x0, (%rcx)
je 0x18b79
incl 0x8(%r13)
jmp 0x18b7e
lock
incl 0x8(%r13)
movq (%rax), %rcx
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
callq *0xf8(%rcx)
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x18b9e
callq 0xb478
movq 0x48(%rbx), %rdi
movq 0x50(%rbx), %rbp
testq %rbp, %rbp
je 0x18bc0
movq 0x1a40e(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18bbc
incl 0x8(%rbp)
jmp 0x18bc0
lock
incl 0x8(%rbp)
callq 0x243d6
movslq 0xc(%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 0xe6ba
testq %rbp, %rbp
je 0x18bf8
movq %rbp, %rdi
callq 0xb478
movq 0x38(%r14), %rdi
movq 0x40(%r14), %rbp
testq %rbp, %rbp
je 0x18c1a
movq 0x1a3b4(%rip), %rax     # 0x32fc0
cmpb $0x0, (%rax)
je 0x18c16
incl 0x8(%rbp)
jmp 0x18c1a
lock
incl 0x8(%rbp)
movl 0x8(%rsp), %esi
callq 0x15fb8
testq %rbp, %rbp
je 0x18c30
movq %rbp, %rdi
callq 0xb478
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18c3f
callq 0xb478
testq %r13, %r13
movq 0x18(%rsp), %rbp
je 0x18c51
movq %r13, %rdi
callq 0xb478
movq 0x1a358(%rip), %rsi     # 0x32fb0
leaq 0x80(%rsp), %rdi
callq 0x5280
leaq 0xf8(%rsp), %rdi
callq 0x50b0
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0x18c84
movq %rbx, %rdi
callq 0xb478
movq %rbp, %rdi
callq 0xe63e
movq %r14, %rdi
movl %eax, %esi
callq 0x17b78
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18cb1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x51f0
testq %r15, %r15
je 0x18cbe
movq %r15, %rdi
callq 0xb478
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 0x1a2a9(%rip), %rsi     # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0x4, %edi
callq 0x5100
movl $0x6, (%rax)
movq 0x1a288(%rip), %rsi     # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0xa, %ebx
jmp 0x18d1e
movl $0x9, %ebx
movl $0x4, %edi
callq 0x5100
movl %ebx, (%rax)
movq 0x1a25f(%rip), %rsi     # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
jmp 0x18d3d
movq %rax, %r14
testq %rbp, %rbp
je 0x18e30
movq %rbp, %rdi
jmp 0x18e00
movq %rax, %r14
testq %rbx, %rbx
je 0x18e30
movq %rbx, %rdi
jmp 0x18e00
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x18e30
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x18e30
jmp 0x18d8a
movq %rax, %r14
jmp 0x18d97
movq %rax, %r14
movq 0x38(%rsp), %rbp
testq %rbp, %rbp
je 0x18da4
movq %rbp, %rdi
callq 0xb478
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x18db3
callq 0xb478
testq %r13, %r13
je 0x18dd2
movq %r13, %rdi
jmp 0x18dc8
movq %rax, %r14
testq %rbp, %rbp
je 0x18dd2
movq %rbp, %rdi
callq 0xb478
jmp 0x18dd2
movq %rax, %r14
movq 0x1a1d7(%rip), %rsi     # 0x32fb0
leaq 0x80(%rsp), %rdi
callq 0x5280
leaq 0xf8(%rsp), %rdi
callq 0x50b0
cmpq $0x0, 0x10(%rsp)
je 0x18e30
movq 0x10(%rsp), %rdi
callq 0xb478
jmp 0x18e30
movq %rax, %r14
jmp 0x18df3
jmp 0x18e28
movq %rax, %r14
testq %rbp, %rbp
je 0x18e58
movq %rbp, %rdi
jmp 0x18e53
movq %rax, %r14
testq %rbx, %rbx
je 0x18e58
movq %rbx, %rdi
jmp 0x18e53
movq %rax, %r14
jmp 0x18e4b
movq %rax, %r14
leaq 0x70(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x18e4b
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x51f0
testq %r15, %r15
je 0x18e58
movq %r15, %rdi
callq 0xb478
movq %r14, %rdi
callq 0x5320