// File: /workspace/github_cpp_makefile_star2_O3/BohangZhang[P]Sorcery-C-Project/spell.cc
// Function: Spell::action(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Spell::action(int p, string t) {
    shared_ptr<Player> targetplayer = nullptr;
    if (p == 1) {
        targetplayer = this->master->getGame()->get1();
    } else {
        targetplayer = this->master->getGame()->get2();
    }
    
    if (t == "r") {
        if (targetplayer->isRitualEmpty()) {
            throw 15; // You haven't played a Ritual card!
        }
        if (name == "Banish") {
            targetplayer->setRitual(shared_ptr<Ritual>(nullptr));
        } else {
            throw 17; // The Spell cannot be played upon a Ritual!
        }
    } else {
        int j;
        istringstream ss{t};
        ss >> j;
        if (targetplayer->getSlot()->getSize() < j) {
            throw 3; // The target Minion DNE!
        }
        if (name == "Unsummon") {
            shared_ptr<Slot> s = targetplayer->getSlot();
            shared_ptr<Minion> m = s->getSlot()[j-1];
            if (m->getType() == "Enchantment") {
                shared_ptr<Card> p = m->getMaster()->getDatabase()->getCard(m->getOriginName())->clone();
                p->setMaster(m->getMaster());
                m->getMaster()->getDeck()->push(p);
                s->pop(m);
            } else {
                shared_ptr<Card> p = m->getMaster()->getDatabase()->getCard(m->getName())->clone();
                p->setMaster(m->getMaster());
                m->getMaster()->getDeck()->push(p);
                s->pop(m);
            }
            return;
        }
        if (name == "Banish") {
            shared_ptr<Slot> s = targetplayer->getSlot();
            targetplayer->getGraveyard()->pushfirst(s->getSlot()[j-1]);
            s->getSlot().erase(s->getSlot().begin()+j-1);
            return;
        }
        if (name == "Disenchant") {
            shared_ptr<Minion> m = targetplayer->getSlot()->getSlot()[j-1];
            if (m->getType() == "Enchantment") {
                targetplayer->getSlot()->getSlot()[j-1] = m->getOrigin();
            } else {
                throw 18; // Number, Target Minion hasn't been enchanted.
            }
            return;
        }
        throw 10; // Number, Wrong Spell
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdx, %r12
movq %rdi, %r15
cmpl $0x1, %esi
jne 0x249fa
movq 0x70(%r15), %rsi
leaq 0x10(%rsp), %rdi
callq 0x17a62
movq 0x10(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x11e6a
jmp 0x24a1a
movq 0x70(%r15), %rsi
leaq 0x10(%rsp), %rdi
callq 0x17a62
movq 0x10(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x11e96
movq 0x130(%rsp), %r14
movq 0x138(%rsp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x130(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24a44
callq 0xb478
leaq 0x1e47(%rip), %rsi      # 0x26892
movq %r12, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24b51
leaq 0x130(%rsp), %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x52e0
leaq 0x130(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x5130
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x17a94
movq 0x10(%rsp), %rdi
callq 0x243da
movl %eax, %ebp
movl 0xc(%rsp), %r12d
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24aaf
callq 0xb478
cmpl %r12d, %ebp
jl 0x251f0
addq $0x8, %r15
leaq 0x32a5(%rip), %rsi      # 0x27d68
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24bad
leaq 0x3287(%rip), %rsi      # 0x27d61
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24bfc
leaq 0x3280(%rip), %rsi      # 0x27d71
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0x25220
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x17a94
movq 0x10(%rsp), %rdi
callq 0x243d6
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r15
movq -0x8(%rax,%rcx), %r12
testq %r12, %r12
je 0x24c6c
movq 0xe482(%rip), %rax      # 0x32fc0
cmpb $0x0, (%rax)
je 0x24c66
incl 0x8(%r12)
jmp 0x24c6c
movq %r14, %rdi
callq 0x17bfa
testb %al, %al
jne 0x251f7
addq $0x8, %r15
leaq 0x31f5(%rip), %rsi      # 0x27d61
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0x251fe
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r14, %rdi
callq 0x17c9a
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x251d1
callq 0xb478
jmp 0x251d1
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17a94
movq 0x50(%rsp), %rdi
callq 0x243d6
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r15
movq -0x8(%rax,%rcx), %r14
testq %r14, %r14
je 0x24d47
movq 0xe3d6(%rip), %rax      # 0x32fc0
cmpb $0x0, (%rax)
je 0x24d42
incl 0x8(%r14)
jmp 0x24d47
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x17a94
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17ac0
movq 0x50(%rsp), %r14
movq 0x10(%rsp), %rdi
callq 0x243d6
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %rdx
movq %rdx, 0x70(%rsp)
movq -0x8(%rax,%rcx), %rax
movq %rax, 0x78(%rsp)
testq %rax, %rax
je 0x25000
movq 0xe36b(%rip), %rcx      # 0x32fc0
cmpb $0x0, (%rcx)
je 0x24ffc
incl 0x8(%rax)
jmp 0x25000
lock
incl 0x8(%r12)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24c7b
callq 0xb478
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xe5f6
leaq 0x2be3(%rip), %rsi      # 0x27872
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x50a0
movl %eax, %ebp
movq (%r13), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x24cb9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x51f0
testl %ebp, %ebp
jne 0x25242
movq (%r15), %rax
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq *0x68(%rax)
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17a94
movq 0x50(%rsp), %rdi
callq 0x243d6
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movaps 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0x10(%rsp)
movq -0x8(%rax,%rcx), %rdi
movups %xmm0, -0x10(%rax,%rcx)
testq %rdi, %rdi
je 0x24d13
callq 0xb478
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x24d22
callq 0xb478
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24d31
callq 0xb478
testq %r12, %r12
je 0x251b0
movq %r12, %rdi
jmp 0x251ab
lock
incl 0x8(%r14)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xe5f6
leaq 0x2b17(%rip), %rsi      # 0x27872
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x50a0
movl %eax, %ebp
movq (%r12), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x24d85
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x51f0
testl %ebp, %ebp
je 0x24ec4
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
movq 0x60(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17b18
movq 0x30(%rsp), %r12
leaq 0xf0(%rsp), %rdi
movq %r15, %rsi
callq 0xe5d2
leaq 0x40(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %r12, %rsi
callq 0xe71a
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x24df2
callq 0xb478
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24e13
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x24e22
callq 0xb478
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x24e31
callq 0xb478
movq 0x10(%rsp), %r12
leaq 0xc0(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
leaq 0xc0(%rsp), %rsi
movq %r12, %rdi
callq 0xe676
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x24e68
callq 0xb478
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x17aec
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
testq %rax, %rax
je 0x2506c
movq 0xe10d(%rip), %rcx      # 0x32fc0
cmpb $0x0, (%rcx)
je 0x25068
incl 0x8(%rax)
jmp 0x2506c
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
movq 0x60(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17b18
movq 0x30(%rsp), %r12
movq (%r15), %rax
leaq 0x110(%rsp), %rdi
movq %r15, %rsi
callq *0x70(%rax)
leaq 0x40(%rsp), %rdi
leaq 0x110(%rsp), %rdx
movq %r12, %rsi
callq 0xe71a
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x24f2a
callq 0xb478
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24f4b
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x24f5a
callq 0xb478
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x24f69
callq 0xb478
movq 0x10(%rsp), %r12
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
leaq 0xd0(%rsp), %rsi
movq %r12, %rdi
callq 0xe676
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x24fa0
callq 0xb478
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0xe68a
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x17aec
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
testq %rax, %rax
je 0x250f8
movq 0xdfd5(%rip), %rcx      # 0x32fc0
cmpb $0x0, (%rcx)
je 0x250f4
incl 0x8(%rax)
jmp 0x250f8
lock
incl 0x8(%rax)
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x15b74
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2501c
callq 0xb478
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2502b
callq 0xb478
movq 0x10(%rsp), %rdi
callq 0x243d6
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x243d6
movq (%rax), %rax
movslq 0xc(%rsp), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
movq %r14, %rdi
callq 0x15ee6
movq 0x18(%rsp), %rdi
jmp 0x251a6
lock
incl 0x8(%rax)
leaq 0x90(%rsp), %rsi
callq 0xf4f8
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x2508b
callq 0xb478
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2509a
callq 0xb478
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x250a9
callq 0xb478
movq 0x50(%rsp), %rdi
movq %r15, 0x80(%rsp)
movq %r14, 0x88(%rsp)
testq %r14, %r14
je 0x250da
movq 0xdef6(%rip), %rax      # 0x32fc0
cmpb $0x0, (%rax)
je 0x250d5
incl 0x8(%r14)
jmp 0x250da
lock
incl 0x8(%r14)
leaq 0x80(%rsp), %rsi
callq 0x2441a
movq 0x88(%rsp), %rdi
jmp 0x2517b
lock
incl 0x8(%rax)
leaq 0xb0(%rsp), %rsi
callq 0xf4f8
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x25117
callq 0xb478
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x25126
callq 0xb478
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25135
callq 0xb478
movq 0x50(%rsp), %rdi
movq %r15, 0xa0(%rsp)
movq %r14, 0xa8(%rsp)
testq %r14, %r14
je 0x25166
movq 0xde6a(%rip), %rax      # 0x32fc0
cmpb $0x0, (%rax)
je 0x25161
incl 0x8(%r14)
jmp 0x25166
lock
incl 0x8(%r14)
leaq 0xa0(%rsp), %rsi
callq 0x2441a
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x25185
callq 0xb478
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x25194
callq 0xb478
testq %r14, %r14
je 0x251a1
movq %r14, %rdi
callq 0xb478
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x251b0
callq 0xb478
movq 0xddf9(%rip), %rsi      # 0x32fb0
leaq 0x130(%rsp), %rdi
callq 0x5280
leaq 0x1a8(%rsp), %rdi
callq 0x50b0
testq %rbx, %rbx
je 0x251de
movq %rbx, %rdi
callq 0xb478
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, %ebp
jmp 0x25225
movl $0xf, %ebp
jmp 0x25203
movl $0x11, %ebp
movl $0x4, %edi
callq 0x5100
movl %ebp, (%rax)
movq 0xdd7a(%rip), %rsi      # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0xa, %ebp
movl $0x4, %edi
callq 0x5100
movl %ebp, (%rax)
movq 0xdd58(%rip), %rsi      # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0x4, %edi
callq 0x5100
movl $0x12, (%rax)
movq 0xdd37(%rip), %rsi      # 0x32f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movq %rax, %r15
movq 0xa8(%rsp), %rdi
jmp 0x25331
movq %rax, %r15
movq 0xb8(%rsp), %rdi
jmp 0x252ff
jmp 0x2531a
jmp 0x2533d
movq %rax, %r15
movq 0xd8(%rsp), %rdi
jmp 0x25331
jmp 0x2533d
movq %rax, %r15
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x252b6
callq 0xb478
jmp 0x252b6
movq %rax, %r15
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25384
movq 0x120(%rsp), %rsi
jmp 0x25377
jmp 0x25381
jmp 0x2539a
jmp 0x253e9
movq %rax, %r15
movq 0x88(%rsp), %rdi
jmp 0x25331
movq %rax, %r15
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x25309
callq 0xb478
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2531d
callq 0xb478
jmp 0x2531d
movq %rax, %r15
movq 0x38(%rsp), %rdi
jmp 0x25331
jmp 0x2533d
movq %rax, %r15
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x25340
callq 0xb478
jmp 0x25340
movq %rax, %r15
movq 0x18(%rsp), %rdi
jmp 0x253a2
movq %rax, %r15
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2535e
callq 0xb478
jmp 0x2535e
movq %rax, %r15
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25384
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x25384
movq %rax, %r15
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x2539d
callq 0xb478
jmp 0x2539d
jmp 0x2547b
movq %rax, %r15
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x253ec
callq 0xb478
jmp 0x253ec
movq %rax, %r15
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x253c7
callq 0xb478
jmp 0x253c7
jmp 0x253e9
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2547e
callq 0xb478
jmp 0x2547e
jmp 0x2547b
jmp 0x25498
movq %rax, %r15
testq %r14, %r14
je 0x253f9
movq %r14, %rdi
callq 0xb478
movq 0x58(%rsp), %rdi
jmp 0x25483
movq %rax, %r15
jmp 0x253f9
jmp 0x25498
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x25424
callq 0xb478
jmp 0x25424
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2543c
callq 0xb478
jmp 0x2543c
jmp 0x25439
jmp 0x25439
movq %rax, %r15
testq %r12, %r12
je 0x2549b
movq %r12, %rdi
jmp 0x25488
jmp 0x2547b
jmp 0x25498
jmp 0x2547b
movq %rax, %r15
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x254bc
callq 0xb478
jmp 0x254bc
jmp 0x25465
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
jne 0x254c4
jmp 0x254c9
jmp 0x25476
movq %rax, %r15
jmp 0x254c9
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2549b
callq 0xb478
jmp 0x2549b
jmp 0x25498
jmp 0x25493
movq %rax, %r15
jmp 0x254bc
movq %rax, %r15
movq 0xdb0e(%rip), %rsi      # 0x32fb0
leaq 0x130(%rsp), %rdi
callq 0x5280
leaq 0x1a8(%rsp), %rdi
callq 0x50b0
testq %rbx, %rbx
je 0x254c9
movq %rbx, %rdi
callq 0xb478
movq %r15, %rdi
callq 0x5320
nop