// File: /workspace/github_cpp_makefile_star2_O3/Worthy-Wang[P]Warcraft3-StartWar/warcraftWorld.cpp
// Function: warcraft::WarcraftWorld::createAndShow(warcraft::Headquarters*)
bool WarcraftWorld::createAndShow(Headquarters *head)
{
    //基地生命元少于当前创造的勇士生命值时 返回false
    while (head->getBaseHp() < GameConfig::getInstance()->getInitWarriorHp(_caseNum, head->getWarriorType()))
        return false;
    //创建勇士
    WarriorPtr warrior = head->createWarrior(head->getWarriorType());
    WarriorViewPtr warriorView;

    //设置武器
    switch (head->getWarriorType())
    {
    case DRAGON:
    {
        WeaponPtr weapon = head->createWeapon(head->getWarriorId() % 3, DRAGON);
        warrior->setWeapon(weapon);
        warriorView.reset(new DragonView(warrior));
        HeadquartersView headView(head);
        //show
        warriorView->show();
        cout << "It has a " << weapon->getName() << endl;
        break;
    }
    case ICEMAN:
    {
        WeaponPtr weapon = head->createWeapon(head->getWarriorId() % 3, ICEMAN);
        warrior->setWeapon(weapon);
        warriorView.reset(new IcemanView(warrior));
        HeadquartersView headView(head);
        //show
        warriorView->show();
        cout << "It has a " << weapon->getName() << endl;
        break;
    }
    case LION:
    {
        WeaponPtr weapon = head->createWeapon(head->getWarriorId() % 3, LION);
        warrior->setWeapon(weapon);
        warriorView.reset(new LionView(warrior));
        HeadquartersView headView(head);
        //show
        warriorView->show();
        break;
    }
    case NINJA:
    {
        WeaponPtr weapon1 = head->createWeapon(head->getWarriorId() % 3, NINJA);
        WeaponPtr weapon2 = head->createWeapon((head->getWarriorId() + 1) % 3, NINJA);
        warrior->setWeapon(weapon1);
        warrior->setWeapon(weapon2);
        warriorView.reset(new NinjaView(warrior));
        HeadquartersView headView(head);
        //show
        warriorView->show();
        cout << "It has a " << weapon1->getName() << " and a " << weapon2->getName() << endl;
        break;
    }
    case WOLF:
    {
        warriorView.reset(new WolfView(warrior));
        HeadquartersView headView(head);
        //show
        warriorView->show();
        break;
    }
    }
    if (head->getColor() == RED)
        _citys[0]->attach(warrior);
    else
        _citys[GameConfig::getInstance()->getCityNum(_caseNum) + 1]->attach(warrior);
    head->nextWarriorType();
    head->nextWarriorId();
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movq %rdi, %r14
movq 0x8(%rsi), %r12
movq 0x10(%rsi), %rax
leaq 0x9dcd(%rip), %rcx      # 0x17158
movq (%rcx), %rcx
movq 0x28(%rdi), %rdx
movq 0x20(%rsi), %rsi
movl (%rsi,%rax,4), %eax
leaq -0x58(%rbp), %rsi
movl %eax, (%rsi)
movq 0x18(%rcx), %rax
shlq $0x7, %rdx
leaq (%rax,%rdx), %rdi
addq $-0x60, %rdi
callq 0x681a
movq (%rax), %r13
cmpq %r13, %r12
jb 0xdcfd
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %rcx
movl (%rcx,%rax,4), %edx
leaq -0x38(%rbp), %rdi
movq %rbx, %rsi
callq 0x6ebc
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %rcx
movl (%rcx,%rax,4), %eax
cmpq $0x4, %rax
ja 0xdbcb
leaq 0x356a(%rip), %rcx      # 0x10964
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rbx), %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %rdx
shrq %rdx
leaq (%rdx,%rdx,2), %rax
subq %rax, %rcx
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
movq %rcx, %rdx
xorl %ecx, %ecx
callq 0x77d2
movq -0x38(%rbp), %rdi
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x150(%rbp)
movq %rax, -0x148(%rbp)
testq %rax, %rax
je 0xd758
movq 0x9b63(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd754
incl 0x8(%rax)
jmp 0xd758
movl $0x18, %edi
callq 0x4160
movq %rax, %r15
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0xc0(%rbp)
movq %rax, -0xb8(%rbp)
testq %rax, %rax
je 0xd647
movq 0x9b1f(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd643
incl 0x8(%rax)
jmp 0xd647
movq 0x18(%rbx), %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %rdx
shrq %rdx
leaq (%rdx,%rdx,2), %rax
subq %rax, %rcx
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl $0x2, %ecx
callq 0x77d2
movq -0x38(%rbp), %rdi
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x130(%rbp)
movq %rax, -0x128(%rbp)
testq %rax, %rax
je 0xd686
movq 0x9aa9(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd682
incl 0x8(%rax)
jmp 0xd686
movq 0x18(%rbx), %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %rdx
shrq %rdx
leaq (%rdx,%rdx,2), %rax
subq %rax, %rcx
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl $0x3, %ecx
callq 0x77d2
movq -0x38(%rbp), %rdi
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x110(%rbp)
movq %rax, -0x108(%rbp)
testq %rax, %rax
je 0xd6ef
movq 0x9a3c(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd6eb
incl 0x8(%rax)
jmp 0xd6ef
movq 0x18(%rbx), %rcx
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %r15
shrq %rdx
leaq (%rdx,%rdx,2), %rax
subq %rax, %rcx
leaq -0xb0(%rbp), %rdi
movq %rbx, %rsi
movq %rcx, %rdx
movl $0x1, %ecx
callq 0x77d2
movq 0x18(%rbx), %rcx
leaq 0x1(%rcx), %rax
mulq %r15
shrq %rdx
leaq (%rdx,%rdx,2), %rax
negq %rax
leaq (%rcx,%rax), %rdx
incq %rdx
leaq -0xa0(%rbp), %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq 0x77d2
movq -0x38(%rbp), %rdi
movq -0xb0(%rbp), %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0xf0(%rbp)
movq %rax, -0xe8(%rbp)
testq %rax, %rax
je 0xd7c1
movq 0x9996(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd7bd
incl 0x8(%rax)
jmp 0xd7c1
lock
incl 0x8(%rax)
leaq -0xc0(%rbp), %rsi
movq %r15, %rdi
callq 0x832a
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x82dc
movq -0xb8(%rbp), %rdi
testq %rdi, %rdi
je 0xd673
callq 0x57a8
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
jmp 0xdbcb
lock
incl 0x8(%rax)
addq $0x40, %rdi
leaq -0x130(%rbp), %rsi
callq 0x8f74
movq -0x128(%rbp), %rdi
testq %rdi, %rdi
je 0xd6a7
callq 0x57a8
movl $0x18, %edi
callq 0x4160
movq %rax, %r15
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x120(%rbp)
movq %rax, -0x118(%rbp)
testq %rax, %rax
je 0xd827
movq 0x98ee(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd823
incl 0x8(%rax)
jmp 0xd827
lock
incl 0x8(%rax)
addq $0x40, %rdi
leaq -0x110(%rbp), %rsi
callq 0x8f74
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0xd710
callq 0x57a8
movl $0x18, %edi
callq 0x4160
movq %rax, %r15
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
testq %rax, %rax
je 0xd8df
movq 0x9885(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd8db
incl 0x8(%rax)
jmp 0xd8df
lock
incl 0x8(%rax)
addq $0x40, %rdi
leaq -0x150(%rbp), %rsi
callq 0x8f74
movq -0x148(%rbp), %rdi
testq %rdi, %rdi
je 0xd779
callq 0x57a8
movl $0x18, %edi
callq 0x4160
movq %rax, %r15
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x140(%rbp)
movq %rax, -0x138(%rbp)
testq %rax, %rax
je 0xd922
movq 0x981c(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xd91e
incl 0x8(%rax)
jmp 0xd922
lock
incl 0x8(%rax)
addq $0x40, %rdi
leaq -0xf0(%rbp), %rsi
callq 0x8f74
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0xd7e2
callq 0x57a8
movq -0x38(%rbp), %rdi
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rax, -0xd8(%rbp)
testq %rax, %rax
je 0xda14
movq 0x97b6(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xda10
incl 0x8(%rax)
jmp 0xda14
lock
incl 0x8(%rax)
leaq -0x120(%rbp), %rsi
movq %r15, %rdi
callq 0x7f86
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x7f38
movq -0x118(%rbp), %rdi
testq %rdi, %rdi
je 0xd853
callq 0x57a8
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x976c(%rip), %rdi      # 0x16fd0
leaq 0x3230(%rip), %rsi      # 0x10a9b
movl $0x9, %edx
callq 0x4190
movq -0x90(%rbp), %rax
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x570a
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x9729(%rip), %rdi      # 0x16fd0
callq 0x4190
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4150
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x40f0
jmp 0xd9eb
lock
incl 0x8(%rax)
leaq -0x100(%rbp), %rsi
movq %r15, %rdi
callq 0x815e
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x8110
movq -0xf8(%rbp), %rdi
testq %rdi, %rdi
je 0xd90b
callq 0x57a8
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq -0x50(%rbp), %rdi
jmp 0xdbc1
lock
incl 0x8(%rax)
movq %r13, -0x158(%rbp)
movq %r12, %r13
movb $0x1, %r12b
leaq -0x140(%rbp), %rsi
movq %r15, %rdi
callq 0x7bee
xorl %r12d, %r12d
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x7ba0
movq -0x138(%rbp), %rdi
testq %rdi, %rdi
je 0xd95e
callq 0x57a8
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %r13, %r12
movq 0x965e(%rip), %rdi      # 0x16fd0
leaq 0x3122(%rip), %rsi      # 0x10a9b
movl $0x9, %edx
callq 0x4190
movq -0x90(%rbp), %rax
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x570a
movq -0x158(%rbp), %r13
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x9614(%rip), %rdi      # 0x16fd0
callq 0x4190
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4150
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x40f0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xda04
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x88(%rbp), %rdi
jmp 0xdbc1
lock
incl 0x8(%rax)
addq $0x40, %rdi
leaq -0xe0(%rbp), %rsi
callq 0x8f74
movq -0xd8(%rbp), %rdi
testq %rdi, %rdi
je 0xda35
callq 0x57a8
movl $0x18, %edi
callq 0x4160
movq %rax, %r15
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
testq %rax, %rax
je 0xda72
movq 0x9564(%rip), %rcx      # 0x16fc8
cmpb $0x0, (%rcx)
je 0xda6e
incl 0x8(%rax)
jmp 0xda72
lock
incl 0x8(%rax)
leaq -0xd0(%rbp), %rsi
movq %r15, %rdi
callq 0x7dba
leaq -0x70(%rbp), %rdi
movq %r15, %rsi
callq 0x7d6c
movq -0xc8(%rbp), %rdi
testq %rdi, %rdi
je 0xda9e
callq 0x57a8
movq -0x70(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x9521(%rip), %rdi      # 0x16fd0
leaq 0x2fe5(%rip), %rsi      # 0x10a9b
movl $0x9, %edx
callq 0x4190
movq -0xb0(%rbp), %rax
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x570a
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq 0x94de(%rip), %rdi      # 0x16fd0
callq 0x4190
movq %rax, %r15
leaq 0x2fa4(%rip), %rsi      # 0x10aa5
movl $0x7, %edx
movq %rax, %rdi
callq 0x4190
movq -0xa0(%rbp), %rax
leaq -0x80(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %rdi
callq 0x570a
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %r15, %rdi
callq 0x4190
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4150
movsbl %al, %esi
movq %r15, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x40f0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xdb90
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xdba9
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0xdbba
callq 0x57a8
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0xdbcb
callq 0x57a8
cmpl $0x0, (%rbx)
je 0xdc24
leaq 0x9581(%rip), %rax      # 0x17158
movq (%rax), %rax
movq 0x10(%r14), %rcx
movq 0x28(%r14), %rdx
movq 0x18(%rax), %rax
shlq $0x7, %rdx
movq -0x78(%rax,%rdx), %rax
shlq $0x4, %rax
movq 0x10(%rcx,%rax), %rax
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rdx
leaq -0x160(%rbp), %rsi
movq %rcx, -0x8(%rsi)
movq %rdx, (%rsi)
testq %rdx, %rdx
je 0xdc62
movq 0x93ae(%rip), %rdi      # 0x16fc8
cmpb $0x0, (%rdi)
je 0xdc57
incl 0x8(%rdx)
jmp 0xdc62
movq 0x10(%r14), %rax
movq (%rax), %rax
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rdx
leaq -0x170(%rbp), %rsi
movq %rcx, -0x8(%rsi)
movq %rdx, (%rsi)
testq %rdx, %rdx
je 0xdc93
movq 0x937b(%rip), %rdi      # 0x16fc8
cmpb $0x0, (%rdi)
je 0xdc88
incl 0x8(%rdx)
jmp 0xdc93
lock
incl 0x8(%rdx)
movq -0x168(%rbp), %rcx
xorl %edx, %edx
cmpl $0x0, 0x8(%rcx)
setne %dl
shll $0x4, %edx
leaq (%rdx,%rax), %rdi
addq $0x10, %rdi
movq %rcx, -0x8(%rdi)
callq 0xac4a
movq -0x160(%rbp), %rdi
jmp 0xdcb7
lock
incl 0x8(%rdx)
movq -0x178(%rbp), %rcx
xorl %edx, %edx
cmpl $0x0, 0x8(%rcx)
setne %dl
shll $0x4, %edx
leaq (%rdx,%rax), %rdi
addq $0x10, %rdi
movq %rcx, -0x8(%rdi)
callq 0xac4a
movq -0x170(%rbp), %rdi
testq %rdi, %rdi
je 0xdcc1
callq 0x57a8
movq 0x10(%rbx), %rax
movq 0x28(%rbx), %rcx
incq %rax
subq 0x20(%rbx), %rcx
sarq $0x2, %rcx
xorl %edx, %edx
divq %rcx
movq %rdx, 0x10(%rbx)
incq 0x18(%rbx)
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xdcef
callq 0x57a8
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0xdcfd
callq 0x57a8
cmpq %r13, %r12
setae %al
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xddf8
jmp 0xddfd
jmp 0xde04
jmp 0xde04
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
jmp 0xdd6a
jmp 0xddfd
jmp 0xdd82
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
jmp 0xdd6a
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
jmp 0xdda1
movq %rax, %rbx
movq -0x118(%rbp), %rdi
jmp 0xddc6
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
testq %rdi, %rdi
je 0xde67
callq 0x57a8
jmp 0xde67
jmp 0xde04
movq %rax, %rbx
jmp 0xddab
jmp 0xde04
jmp 0xddf0
movq %rax, %rbx
movq -0x148(%rbp), %rdi
jmp 0xddc6
movq %rax, %rbx
movq -0x108(%rbp), %rdi
testq %rdi, %rdi
je 0xddab
callq 0x57a8
movq -0x50(%rbp), %rdi
jmp 0xdea6
movq %rax, %rbx
jmp 0xde78
movq %rax, %rbx
movq -0x128(%rbp), %rdi
testq %rdi, %rdi
je 0xde9f
callq 0x57a8
jmp 0xde9f
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
jmp 0xdea6
jmp 0xddf0
jmp 0xddf0
jmp 0xddf0
jmp 0xddf0
movq %rax, %rbx
jmp 0xdeb0
movq %rax, %rbx
jmp 0xde4e
movq %rax, %rbx
jmp 0xde67
jmp 0xde04
movq %rax, %rbx
jmp 0xde9f
movq %rax, %rbx
movq -0x138(%rbp), %rdi
testq %rdi, %rdi
je 0xde20
callq 0x57a8
testb %r12b, %r12b
je 0xde9f
movl $0x18, %esi
movq %r15, %rdi
jmp 0xde9a
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xde4e
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xde67
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x98(%rbp), %rdi
testq %rdi, %rdi
je 0xde78
callq 0x57a8
movq -0xa8(%rbp), %rdi
jmp 0xdea6
jmp 0xde83
movq %rax, %rbx
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0xde9f
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x4170
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xdeb0
callq 0x57a8
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xdebe
callq 0x57a8
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0xdecc
callq 0x57a8
movq %rbx, %rdi
callq 0x4230