// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdx, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
cmpl $0x1, %esi
jne 0x1b7f4
movq 0x70(%rbx), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1215c
movq 0x10(%rsp), %rsi
leaq 0x150(%rsp), %rdi
callq 0xe58e
jmp 0x1b814
movq 0x70(%rbx), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1215c
movq 0x10(%rsp), %rsi
leaq 0x150(%rsp), %rdi
callq 0xe5a0
leaq 0x70(%rsp), %rdi
leaq 0x150(%rsp), %rsi
callq 0x9f0c
leaq 0x158(%rsp), %rdi
callq 0x8ea0
leaq 0x18(%rsp), %rdi
callq 0x8ea0
leaq 0x1fb0(%rip), %rsi      # 0x1d7f4
movq %r14, %rdi
callq 0x8dc3
testb %al, %al
je 0x1b8a7
movq 0x70(%rsp), %rdi
callq 0x1224e
testb %al, %al
jne 0x1be2b
addq $0x8, %rbx
leaq 0x3451(%rip), %rsi      # 0x1ecbe
movq %rbx, %rdi
callq 0x8dc3
testb %al, %al
je 0x1be2f
movq 0x70(%rsp), %rdi
xorps %xmm0, %xmm0
leaq 0xb0(%rsp), %rsi
movaps %xmm0, (%rsi)
callq 0x1230e
leaq 0xb8(%rsp), %rdi
callq 0x8ea0
jmp 0x1be15
leaq 0x150(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x52f0
leaq 0x150(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x5140
movq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x12172
movq 0x10(%rsp), %rdi
callq 0x1b2e6
movl %eax, %ebp
movl 0xc(%rsp), %r14d
leaq 0x18(%rsp), %rdi
callq 0x8ea0
cmpl %r14d, %ebp
jl 0x1be4d
addq $0x8, %rbx
leaq 0x33bb(%rip), %rsi      # 0x1ecc5
movq %rbx, %rdi
callq 0x8dc3
testb %al, %al
je 0x1bae1
movq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x12172
movq 0x60(%rsp), %rdi
callq 0x1b2e2
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x8f30
movq (%rbx), %rsi
leaq 0x10(%rsp), %rdi
callq 0xb3f4
leaq 0x2e6c(%rip), %rsi      # 0x1e7d4
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x8dc3
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5378
testb %bpl, %bpl
je 0x1bc92
movq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xb45c
movq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x121a8
movq 0x40(%rsp), %rbx
movq 0x30(%rsp), %rsi
movq (%rsi), %rax
leaq 0x130(%rsp), %rdi
callq *0x70(%rax)
leaq 0x50(%rsp), %rdi
leaq 0x130(%rsp), %rdx
movq %rbx, %rsi
callq 0xb4ee
movq 0x50(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
leaq 0x58(%rsp), %rdi
callq 0x8ea0
leaq 0x130(%rsp), %rdi
callq 0x5378
leaq 0x48(%rsp), %rdi
callq 0x8ea0
leaq 0x88(%rsp), %rdi
callq 0x8ea0
movq 0x10(%rsp), %rbx
movq 0x30(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0xb45c
leaq 0xa0(%rsp), %rsi
movq %rbx, %rdi
callq 0xb452
leaq 0xa8(%rsp), %rdi
callq 0x8ea0
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0xb45c
movq 0x40(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x12196
movq 0x50(%rsp), %rbx
leaq 0x100(%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xb86e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc2d8
leaq 0x108(%rsp), %rdi
callq 0x8ea0
leaq 0x58(%rsp), %rdi
callq 0x8ea0
leaq 0x48(%rsp), %rdi
callq 0x8ea0
movq 0x60(%rsp), %rbx
leaq 0xf0(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x8f30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1b326
leaq 0xf8(%rsp), %rdi
jmp 0x1bde5
leaq 0x31d6(%rip), %rsi      # 0x1ecbe
movq %rbx, %rdi
callq 0x8dc3
testb %al, %al
je 0x1bba8
movq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x12172
movq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdi
callq 0x12184
movq 0x60(%rsp), %rbx
movq 0x10(%rsp), %rdi
callq 0x1b2e2
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0x8f30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x10b26
leaq 0xc8(%rsp), %rdi
callq 0x8ea0
leaq 0x68(%rsp), %rdi
callq 0x8ea0
movq 0x10(%rsp), %rdi
callq 0x1b2e2
movq %rax, %rbx
movq 0x10(%rsp), %rdi
callq 0x1b2e2
movq (%rax), %rax
movslq 0xc(%rsp), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
movq %rbx, %rdi
callq 0x10dc0
leaq 0x18(%rsp), %rdi
jmp 0x1be03
leaq 0x311f(%rip), %rsi      # 0x1ecce
movq %rbx, %rdi
callq 0x8dc3
testb %al, %al
je 0x1be6b
movq 0x70(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x12172
movq 0x10(%rsp), %rdi
callq 0x1b2e2
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
callq 0x8f30
leaq 0x18(%rsp), %rdi
callq 0x8ea0
movq (%rbx), %rsi
leaq 0x10(%rsp), %rdi
callq 0xb3f4
leaq 0x2bbd(%rip), %rsi      # 0x1e7d4
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
callq 0x8dc3
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5378
testb %bpl, %bpl
je 0x1be6f
movq 0x60(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x68(%rax)
movq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x12172
movq 0x30(%rsp), %rdi
callq 0x1b2e2
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
leaq (%rax,%rcx), %rdi
addq $-0x10, %rdi
leaq 0x10(%rsp), %rsi
callq 0xe1ca
leaq 0x38(%rsp), %rdi
callq 0x8ea0
leaq 0x18(%rsp), %rdi
jmp 0x1bdf9
movq 0x30(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0xb45c
movq 0x80(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x121a8
movq 0x40(%rsp), %rbx
movq 0x30(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0xb3e2
leaq 0x50(%rsp), %rdi
leaq 0x110(%rsp), %rdx
movq %rbx, %rsi
callq 0xb4ee
movq 0x50(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
leaq 0x58(%rsp), %rdi
callq 0x8ea0
leaq 0x110(%rsp), %rdi
callq 0x5378
leaq 0x48(%rsp), %rdi
callq 0x8ea0
leaq 0x88(%rsp), %rdi
callq 0x8ea0
movq 0x10(%rsp), %rbx
movq 0x30(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0xb45c
leaq 0x90(%rsp), %rsi
movq %rbx, %rdi
callq 0xb452
leaq 0x98(%rsp), %rdi
callq 0x8ea0
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0xb45c
movq 0x40(%rsp), %rsi
leaq 0x50(%rsp), %rdi
callq 0x12196
movq 0x50(%rsp), %rbx
leaq 0xe0(%rsp), %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xb86e
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc2d8
leaq 0xe8(%rsp), %rdi
callq 0x8ea0
leaq 0x58(%rsp), %rdi
callq 0x8ea0
leaq 0x48(%rsp), %rdi
callq 0x8ea0
movq 0x60(%rsp), %rbx
leaq 0xd0(%rsp), %r14
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x8f30
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1b326
leaq 0xd8(%rsp), %rdi
callq 0x8ea0
leaq 0x18(%rsp), %rdi
callq 0x8ea0
leaq 0x38(%rsp), %rdi
callq 0x8ea0
leaq 0x68(%rsp), %rdi
callq 0x8ea0
leaq 0x150(%rsp), %rdi
callq 0x5100
leaq 0x78(%rsp), %rdi
callq 0x8ea0
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbx
popq %r14
popq %rbp
retq
pushq $0xf
jmp 0x1be31
pushq $0x11
popq %rbx
pushq $0x4
popq %rdi
callq 0x5120
movl %ebx, (%rax)
movq 0xf15d(%rip), %rsi      # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
pushq $0x3
popq %rbx
pushq $0x4
popq %rdi
callq 0x5120
movl %ebx, (%rax)
movq 0xf13f(%rip), %rsi      # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
pushq $0xa
jmp 0x1be4f
pushq $0x4
popq %rdi
callq 0x5120
movl $0x12, (%rax)
movq 0xf11c(%rip), %rsi      # 0x2afa0
movq %rax, %rdi
xorl %edx, %edx
callq 0x5310
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x1bef9
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
jmp 0x1bef9
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0x1bec0
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x8ea0
leaq 0x58(%rsp), %rdi
callq 0x8ea0
jmp 0x1bed6
jmp 0x1bed3
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x1bef9
jmp 0x1bf02
jmp 0x1bf02
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x1bef9
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x8ea0
jmp 0x1bf05
jmp 0x1bf02
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x1bf86
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x8ea0
jmp 0x1bf3c
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x8ea0
jmp 0x1bf49
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x8ea0
jmp 0x1bf53
movq %rax, %rbx
leaq 0x110(%rsp), %rdi
jmp 0x1bf5b
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0x1bf90
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x5378
jmp 0x1bf69
jmp 0x1bf66
jmp 0x1bfd2
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x8ea0
jmp 0x1bf7e
jmp 0x1bfd2
jmp 0x1bf7b
jmp 0x1bfd9
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x8ea0
leaq 0x38(%rsp), %rdi
callq 0x8ea0
leaq 0x68(%rsp), %rdi
jmp 0x1bfe1
jmp 0x1bfcd
jmp 0x1bfd2
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x8ea0
jmp 0x1bfb9
jmp 0x1bfcd
jmp 0x1bfd9
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x8ea0
jmp 0x1bfdc
jmp 0x1c00e
jmp 0x1bfd9
jmp 0x1c00e
jmp 0x1bfd9
movq %rax, %rbx
jmp 0x1bf8b
movq %rax, %rbx
jmp 0x1bf95
jmp 0x1c00e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x8ea0
jmp 0x1c011
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x1c003
jmp 0x1c00e
jmp 0x1c020
jmp 0x1bffb
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x8ea0
jmp 0x1c023
jmp 0x1c020
jmp 0x1c020
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x5100
jmp 0x1c023
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x8ea0
movq %rbx, %rdi
callq 0x5330
nop