// File: /workspace/github_cpp_makefile_star2_O1/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 0x24d46
movq 0x70(%r15), %rsi
leaq 0x10(%rsp), %rdi
callq 0x17b9e
movq 0x10(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x12096
jmp 0x24d66
movq 0x70(%r15), %rsi
leaq 0x10(%rsp), %rdi
callq 0x17b9e
movq 0x10(%rsp), %rsi
leaq 0x130(%rsp), %rdi
callq 0x120c2
movq 0x130(%rsp), %r14
movq 0x138(%rsp), %rbx
xorps %xmm0, %xmm0
movaps %xmm0, 0x130(%rsp)
movq 0x138(%rsp), %rdi
testq %rdi, %rdi
je 0x24d93
callq 0xb634
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24da2
callq 0xb634
leaq 0x2ae9(%rip), %rsi      # 0x27892
movq %r12, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24eaf
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 0x17bd0
movq 0x10(%rsp), %rdi
callq 0x2470a
movl %eax, %ebp
movl 0xc(%rsp), %r12d
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24e0d
callq 0xb634
cmpl %r12d, %ebp
jl 0x2554e
addq $0x8, %r15
leaq 0x3f47(%rip), %rsi      # 0x28d68
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24f0b
leaq 0x3f29(%rip), %rsi      # 0x28d61
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
je 0x24f5a
leaq 0x3f22(%rip), %rsi      # 0x28d71
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0x2557e
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x17bd0
movq 0x10(%rsp), %rdi
callq 0x24706
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r15
movq -0x8(%rax,%rcx), %r12
testq %r12, %r12
je 0x24fca
movq 0xf124(%rip), %rax      # 0x33fc0
cmpb $0x0, (%rax)
je 0x24fc4
incl 0x8(%r12)
jmp 0x24fca
movq %r14, %rdi
callq 0x17d36
testb %al, %al
jne 0x25555
addq $0x8, %r15
leaq 0x3e97(%rip), %rsi      # 0x28d61
movq %r15, %rdi
callq 0x50a0
testl %eax, %eax
jne 0x2555c
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rsi
movaps %xmm0, (%rsi)
movq %r14, %rdi
callq 0x17dd6
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x2552f
callq 0xb634
jmp 0x2552f
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17bd0
movq 0x50(%rsp), %rdi
callq 0x24706
movslq 0xc(%rsp), %rcx
movq (%rax), %rax
shlq $0x4, %rcx
movq -0x10(%rax,%rcx), %r15
movq -0x8(%rax,%rcx), %r14
testq %r14, %r14
je 0x250a5
movq 0xf078(%rip), %rax      # 0x33fc0
cmpb $0x0, (%rax)
je 0x250a0
incl 0x8(%r14)
jmp 0x250a5
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x17bd0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17bfc
movq 0x50(%rsp), %r14
movq 0x10(%rsp), %rdi
callq 0x24706
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 0x2535e
movq 0xf00d(%rip), %rcx      # 0x33fc0
cmpb $0x0, (%rcx)
je 0x2535a
incl 0x8(%rax)
jmp 0x2535e
lock
incl 0x8(%r12)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x24fd9
callq 0xb634
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xe816
leaq 0x3885(%rip), %rsi      # 0x28872
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x50a0
movl %eax, %ebp
movq (%r13), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x25017
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x51f0
testl %ebp, %ebp
jne 0x255a0
movq (%r15), %rax
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq *0x68(%rax)
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
callq 0x17bd0
movq 0x50(%rsp), %rdi
callq 0x24706
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 0x25071
callq 0xb634
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x25080
callq 0xb634
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2508f
callq 0xb634
testq %r12, %r12
je 0x2550e
movq %r12, %rdi
jmp 0x25509
lock
incl 0x8(%r14)
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0xe816
leaq 0x37b9(%rip), %rsi      # 0x28872
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x50a0
movl %eax, %ebp
movq (%r12), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x250e3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x51f0
testl %ebp, %ebp
je 0x25222
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
movq 0x60(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17c54
movq 0x30(%rsp), %r12
leaq 0xf0(%rsp), %rdi
movq %r15, %rsi
callq 0xe7f2
leaq 0x40(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
movq %r12, %rsi
callq 0xe936
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x25150
callq 0xb634
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x25171
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25180
callq 0xb634
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2518f
callq 0xb634
movq 0x10(%rsp), %r12
leaq 0xc0(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
leaq 0xc0(%rsp), %rsi
movq %r12, %rdi
callq 0xe896
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x251c6
callq 0xb634
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x17c28
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0x90(%rsp)
movq %rax, 0x98(%rsp)
testq %rax, %rax
je 0x253ca
movq 0xedaf(%rip), %rcx      # 0x33fc0
cmpb $0x0, (%rcx)
je 0x253c6
incl 0x8(%rax)
jmp 0x253ca
leaq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
movq 0x60(%rsp), %rsi
leaq 0x30(%rsp), %rdi
callq 0x17c54
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 0xe936
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
leaq 0x10(%rsp), %rdi
callq *0x50(%rax)
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x25288
callq 0xb634
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x252a9
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x51f0
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x252b8
callq 0xb634
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x252c7
callq 0xb634
movq 0x10(%rsp), %r12
leaq 0xd0(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
leaq 0xd0(%rsp), %rsi
movq %r12, %rdi
callq 0xe896
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x252fe
callq 0xb634
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0xe8aa
movq 0x30(%rsp), %rsi
leaq 0x40(%rsp), %rdi
callq 0x17c28
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
movq %rcx, 0xb0(%rsp)
movq %rax, 0xb8(%rsp)
testq %rax, %rax
je 0x25456
movq 0xec77(%rip), %rcx      # 0x33fc0
cmpb $0x0, (%rcx)
je 0x25452
incl 0x8(%rax)
jmp 0x25456
lock
incl 0x8(%rax)
leaq 0x70(%rsp), %rsi
movq %r14, %rdi
callq 0x15c44
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x2537a
callq 0xb634
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x25389
callq 0xb634
movq 0x10(%rsp), %rdi
callq 0x24706
movq %rax, %r14
movq 0x10(%rsp), %rdi
callq 0x24706
movq (%rax), %rax
movslq 0xc(%rsp), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x10, %rsi
movq %r14, %rdi
callq 0x15fb6
movq 0x18(%rsp), %rdi
jmp 0x25504
lock
incl 0x8(%rax)
leaq 0x90(%rsp), %rsi
callq 0xf714
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x253e9
callq 0xb634
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x253f8
callq 0xb634
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25407
callq 0xb634
movq 0x50(%rsp), %rdi
movq %r15, 0x80(%rsp)
movq %r14, 0x88(%rsp)
testq %r14, %r14
je 0x25438
movq 0xeb98(%rip), %rax      # 0x33fc0
cmpb $0x0, (%rax)
je 0x25433
incl 0x8(%r14)
jmp 0x25438
lock
incl 0x8(%r14)
leaq 0x80(%rsp), %rsi
callq 0x2474a
movq 0x88(%rsp), %rdi
jmp 0x254d9
lock
incl 0x8(%rax)
leaq 0xb0(%rsp), %rsi
callq 0xf714
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
je 0x25475
callq 0xb634
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x25484
callq 0xb634
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x25493
callq 0xb634
movq 0x50(%rsp), %rdi
movq %r15, 0xa0(%rsp)
movq %r14, 0xa8(%rsp)
testq %r14, %r14
je 0x254c4
movq 0xeb0c(%rip), %rax      # 0x33fc0
cmpb $0x0, (%rax)
je 0x254bf
incl 0x8(%r14)
jmp 0x254c4
lock
incl 0x8(%r14)
leaq 0xa0(%rsp), %rsi
callq 0x2474a
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x254e3
callq 0xb634
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x254f2
callq 0xb634
testq %r14, %r14
je 0x254ff
movq %r14, %rdi
callq 0xb634
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x2550e
callq 0xb634
movq 0xea9b(%rip), %rsi      # 0x33fb0
leaq 0x130(%rsp), %rdi
callq 0x5280
leaq 0x1a8(%rsp), %rdi
callq 0x50b0
testq %rbx, %rbx
je 0x2553c
movq %rbx, %rdi
callq 0xb634
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x3, %ebp
jmp 0x25583
movl $0xf, %ebp
jmp 0x25561
movl $0x11, %ebp
movl $0x4, %edi
callq 0x5100
movl %ebp, (%rax)
movq 0xea1c(%rip), %rsi      # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0xa, %ebp
movl $0x4, %edi
callq 0x5100
movl %ebp, (%rax)
movq 0xe9fa(%rip), %rsi      # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movl $0x4, %edi
callq 0x5100
movl $0x12, (%rax)
movq 0xe9d9(%rip), %rsi      # 0x33f90
movq %rax, %rdi
xorl %edx, %edx
callq 0x5300
movq %rax, %r15
movq 0xa8(%rsp), %rdi
jmp 0x2568f
movq %rax, %r15
movq 0xb8(%rsp), %rdi
jmp 0x2565d
jmp 0x25678
jmp 0x2569b
movq %rax, %r15
movq 0xd8(%rsp), %rdi
jmp 0x2568f
jmp 0x2569b
movq %rax, %r15
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x25614
callq 0xb634
jmp 0x25614
movq %rax, %r15
leaq 0x120(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x256e2
movq 0x120(%rsp), %rsi
jmp 0x256d5
jmp 0x256df
jmp 0x256f8
jmp 0x25747
movq %rax, %r15
movq 0x88(%rsp), %rdi
jmp 0x2568f
movq %rax, %r15
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x25667
callq 0xb634
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x2567b
callq 0xb634
jmp 0x2567b
movq %rax, %r15
movq 0x38(%rsp), %rdi
jmp 0x2568f
jmp 0x2569b
movq %rax, %r15
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x2569e
callq 0xb634
jmp 0x2569e
movq %rax, %r15
movq 0x18(%rsp), %rdi
jmp 0x25700
movq %rax, %r15
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x256bc
callq 0xb634
jmp 0x256bc
movq %rax, %r15
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x256e2
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x51f0
jmp 0x256e2
movq %rax, %r15
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x256fb
callq 0xb634
jmp 0x256fb
jmp 0x257e0
movq %rax, %r15
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2574a
callq 0xb634
jmp 0x2574a
movq %rax, %r15
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x25725
callq 0xb634
jmp 0x25725
jmp 0x25747
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x257e3
callq 0xb634
jmp 0x257e3
jmp 0x257e0
jmp 0x257fd
movq %rax, %r15
testq %r14, %r14
je 0x25757
movq %r14, %rdi
callq 0xb634
movq 0x58(%rsp), %rdi
jmp 0x257e8
movq %rax, %r15
jmp 0x25757
jmp 0x257fd
movq %rax, %r15
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x25782
callq 0xb634
jmp 0x25782
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x2579a
callq 0xb634
jmp 0x2579a
jmp 0x25797
jmp 0x25797
movq %rax, %r15
testq %r12, %r12
je 0x25800
movq %r12, %rdi
jmp 0x257ed
jmp 0x257e0
jmp 0x257fd
jmp 0x257e0
movq %rax, %r15
movq 0xe8(%rsp), %rdi
testq %rdi, %rdi
je 0x25821
callq 0xb634
jmp 0x25821
jmp 0x257c3
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x257dc
callq 0xb634
jmp 0x257dc
jmp 0x257d9
movq %rax, %r15
xorl %ebx, %ebx
jmp 0x25821
movq %rax, %r15
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x25800
callq 0xb634
jmp 0x25800
jmp 0x257fd
jmp 0x257f8
movq %rax, %r15
jmp 0x25821
movq %rax, %r15
movq 0xe7a9(%rip), %rsi      # 0x33fb0
leaq 0x130(%rsp), %rdi
callq 0x5280
leaq 0x1a8(%rsp), %rdi
callq 0x50b0
testq %rbx, %rbx
je 0x2582e
movq %rbx, %rdi
callq 0xb634
movq %r15, %rdi
callq 0x5320