// File: Jacobious52[P]Tanks/GameView.cpp
// Function: GameView::_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void GameView::_init(std::string name1, std::string name2)
{
    ConsoleTools::clear_screen();

    add_child(DebugView::shared_view());

    _position = Point<int>::zero();
    _size = ConsoleTools::get_terminal_size();

    // create tebrrain
    _terrain = new Terrain();
    add_child(_terrain);

    turn = false;

    // create tank 1
    int spawn_x = (rand() % 20) + 5;
    _tank1 = new Tank(name1, TextureTools::get_texture("tank1"), ConsoleTools::red);
    _tank1->set_position(Point<int>(spawn_x, _terrain->get_floor(spawn_x) - _tank1->get_size().y));
    add_child(_tank1);

    // create base for tank 1
    Sprite *base1 = new Sprite("        ");
    base1->set_position(_tank1->get_position() + Point<int>(-2, _tank1->get_size().y));
    base1->set_bcolor(ConsoleTools::white);
    base1->tag = TERRAIN_ROCK;
    _terrain->add_child(base1);

    // create tank 2
    spawn_x = (rand() % 20) + 5;
    _tank2 = new Tank(name2, TextureTools::get_texture("tank2"), ConsoleTools::blue);
    _tank2->set_position(Point<int>(get_size().x - spawn_x, _terrain->get_floor(get_size().x - spawn_x) - _tank2->get_size().y));
    add_child(_tank2);

    // create base for tank 2
    Sprite *base2 = new Sprite("        ");
    base2->set_position(_tank2->get_position() + Point<int>(-1, _tank2->get_size().y));
    base2->set_bcolor(ConsoleTools::white);
    base2->tag = TERRAIN_ROCK;
    _terrain->add_child(base2);

    // create box for input
    _input_box = new Sprite(TextureTools::get_texture("input"));
    _input_box->set_position(Point<int>(get_size().x/2 - _input_box->get_size().x/8, 3));
    _input_box->set_bcolor(ConsoleTools::endc);
    _input_box->set_fcolor(ConsoleTools::magneta);

    // create bullet, don't fire
    _bullet = new Bullet(_tank1->get_position(), 0, 0, _terrain);
    add_child(_bullet);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rsi, -0x260(%rbp)
movq %rdx, -0x258(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x250(%rbp)
callq 0x4be0
callq 0x70a0
movq -0x250(%rbp), %rdi
movq %rax, %rsi
callq 0x10420
callq 0x7110
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, 0x18(%rax)
callq 0x4cb0
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rcx
movq %rcx, 0x20(%rax)
movl $0x38, %edi
callq 0x43a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x248(%rbp)
callq 0x7130
jmp 0x516d
movq -0x250(%rbp), %rdi
movq -0x248(%rbp), %rax
movq %rax, 0x38(%rdi)
movq 0x38(%rdi), %rsi
callq 0x10420
movq -0x250(%rbp), %rax
movb $0x0, 0x60(%rax)
callq 0x4110
movl %eax, %ecx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x23, %rdx
addl %eax, %edx
shll $0x2, %edx
movl %edx, %eax
leal (%rax,%rax,4), %edx
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0x5(%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movl $0x80, %edi
callq 0x43a0
movq -0x260(%rbp), %rsi
movq %rax, -0x268(%rbp)
movb $0x1, -0x9a(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4190
jmp 0x51f0
leaq -0x99(%rbp), %rdi
movq %rdi, -0x270(%rbp)
callq 0x45f0
movq -0x270(%rbp), %rdx
leaq 0xee8f(%rip), %rsi      # 0x140a0
leaq -0x98(%rbp), %rdi
callq 0x4490
jmp 0x521f
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xd2a0
jmp 0x5231
movq -0x268(%rbp), %rdi
leaq -0x58(%rbp), %rsi
leaq -0x78(%rbp), %rdx
movl $0x1f, %ecx
callq 0x71a0
jmp 0x524c
movq -0x250(%rbp), %rax
movq -0x268(%rbp), %rcx
movb $0x0, -0x9a(%rbp)
movq %rcx, 0x40(%rax)
leaq -0x78(%rbp), %rdi
callq 0x4200
jmp 0x5270
leaq -0x98(%rbp), %rdi
callq 0x4200
jmp 0x527e
leaq -0x99(%rbp), %rdi
callq 0x4400
leaq -0x58(%rbp), %rdi
callq 0x4200
jmp 0x5295
movq -0x250(%rbp), %rax
movq 0x38(%rax), %rdi
movq 0x40(%rax), %rax
movq %rax, -0x288(%rbp)
movl -0x38(%rbp), %esi
movl %esi, -0x28c(%rbp)
callq 0xc7b0
movl %eax, %ecx
movq -0x250(%rbp), %rax
movl %ecx, -0x290(%rbp)
movq 0x40(%rax), %rdi
callq 0x106a0
movl -0x290(%rbp), %edx
movl -0x28c(%rbp), %esi
movq %rax, -0xac(%rbp)
movl -0xa8(%rbp), %eax
subl %eax, %edx
leaq -0xa4(%rbp), %rdi
callq 0x4ed0
movq -0x288(%rbp), %rdi
movq -0xa4(%rbp), %rsi
callq 0x10680
movq -0x250(%rbp), %rdi
movq 0x40(%rdi), %rsi
callq 0x10420
movl $0x60, %edi
callq 0x43a0
movq %rax, -0x280(%rbp)
movb $0x1, -0xda(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x278(%rbp)
callq 0x45f0
movq -0x278(%rbp), %rdx
leaq 0xed52(%rip), %rsi      # 0x140a6
leaq -0xd8(%rbp), %rdi
callq 0x4490
jmp 0x5362
movq -0x280(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x72a0
jmp 0x5377
movb $0x0, -0xda(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4200
jmp 0x538c
leaq -0xd9(%rbp), %rdi
callq 0x4400
movq -0x280(%rbp), %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0xb8(%rbp)
movq -0xb8(%rbp), %rcx
movq %rcx, -0x2a0(%rbp)
movq 0x40(%rax), %rdi
callq 0x10660
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0xec(%rbp)
movq 0x40(%rax), %rdi
callq 0x106a0
movq %rax, -0xfc(%rbp)
movl -0xf8(%rbp), %edx
leaq -0xf4(%rbp), %rdi
movq %rdi, -0x2a8(%rbp)
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
callq 0x4ed0
movq -0x2a8(%rbp), %rsi
leaq -0xec(%rbp), %rdi
callq 0x73d0
movq -0x2a0(%rbp), %rdi
movq %rax, -0xe4(%rbp)
movq -0xe4(%rbp), %rsi
callq 0x10680
movq -0xb8(%rbp), %rdi
movl $0x25, %esi
callq 0xa6b0
movq -0x250(%rbp), %rax
movq -0xb8(%rbp), %rcx
movl $0xb, 0x8(%rcx)
movq 0x38(%rax), %rdi
movq -0xb8(%rbp), %rsi
callq 0x10420
callq 0x4110
movl %eax, %ecx
movslq %ecx, %rax
imulq $0x66666667, %rax, %rdx # imm = 0x66666667
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x23, %rdx
addl %eax, %edx
shll $0x2, %edx
movl %edx, %eax
leal (%rax,%rax,4), %edx
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0x5(%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movl $0x80, %edi
callq 0x43a0
movq -0x258(%rbp), %rsi
movq %rax, -0x298(%rbp)
movb $0x1, -0x162(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x4190
jmp 0x54c6
leaq -0x161(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x45f0
movq -0x2b0(%rbp), %rdx
leaq 0xebc8(%rip), %rsi      # 0x140af
leaq -0x160(%rbp), %rdi
callq 0x4490
jmp 0x54f5
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xd2a0
jmp 0x550a
movq -0x298(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x140(%rbp), %rdx
movl $0x22, %ecx
callq 0x71a0
jmp 0x552b
movq -0x250(%rbp), %rax
movq -0x298(%rbp), %rcx
movb $0x0, -0x162(%rbp)
movq %rcx, 0x48(%rax)
leaq -0x140(%rbp), %rdi
callq 0x4200
jmp 0x5552
leaq -0x160(%rbp), %rdi
callq 0x4200
jmp 0x5560
leaq -0x161(%rbp), %rdi
callq 0x4400
leaq -0x120(%rbp), %rdi
callq 0x4200
jmp 0x557a
movq -0x250(%rbp), %rdi
movq 0x48(%rdi), %rax
movq %rax, -0x2c8(%rbp)
callq 0x106a0
movq -0x250(%rbp), %rdi
movq %rax, -0x174(%rbp)
movl -0x174(%rbp), %eax
movl -0x38(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x2cc(%rbp)
movq 0x38(%rdi), %rax
movq %rax, -0x2d8(%rbp)
callq 0x106a0
movq -0x2d8(%rbp), %rdi
movq %rax, -0x17c(%rbp)
movl -0x17c(%rbp), %esi
movl -0x38(%rbp), %eax
subl %eax, %esi
callq 0xc7b0
movl %eax, %ecx
movq -0x250(%rbp), %rax
movl %ecx, -0x2d0(%rbp)
movq 0x48(%rax), %rdi
callq 0x106a0
movl -0x2d0(%rbp), %edx
movl -0x2cc(%rbp), %esi
movq %rax, -0x184(%rbp)
movl -0x180(%rbp), %eax
subl %eax, %edx
leaq -0x16c(%rbp), %rdi
callq 0x4ed0
movq -0x2c8(%rbp), %rdi
movq -0x16c(%rbp), %rsi
callq 0x10680
movq -0x250(%rbp), %rdi
movq 0x48(%rdi), %rsi
callq 0x10420
movl $0x60, %edi
callq 0x43a0
movq %rax, -0x2c0(%rbp)
movb $0x1, -0x1b2(%rbp)
leaq -0x1b1(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x45f0
movq -0x2b8(%rbp), %rdx
leaq 0xea2d(%rip), %rsi      # 0x140a6
leaq -0x1b0(%rbp), %rdi
callq 0x4490
jmp 0x5687
movq -0x2c0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x72a0
jmp 0x569c
movb $0x0, -0x1b2(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4200
jmp 0x56b1
leaq -0x1b1(%rbp), %rdi
callq 0x4400
movq -0x2c0(%rbp), %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x190(%rbp)
movq -0x190(%rbp), %rcx
movq %rcx, -0x2f0(%rbp)
movq 0x48(%rax), %rdi
callq 0x10660
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x1c4(%rbp)
movq 0x48(%rax), %rdi
callq 0x106a0
movq %rax, -0x1d4(%rbp)
movl -0x1d0(%rbp), %edx
leaq -0x1cc(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x4ed0
movq -0x2f8(%rbp), %rsi
leaq -0x1c4(%rbp), %rdi
callq 0x73d0
movq -0x2f0(%rbp), %rdi
movq %rax, -0x1bc(%rbp)
movq -0x1bc(%rbp), %rsi
callq 0x10680
movq -0x190(%rbp), %rdi
movl $0x25, %esi
callq 0xa6b0
movq -0x250(%rbp), %rax
movq -0x190(%rbp), %rcx
movl $0xb, 0x8(%rcx)
movq 0x38(%rax), %rdi
movq -0x190(%rbp), %rsi
callq 0x10420
movl $0x60, %edi
callq 0x43a0
movq %rax, -0x2e8(%rbp)
movb $0x1, -0x21a(%rbp)
leaq -0x219(%rbp), %rdi
movq %rdi, -0x2e0(%rbp)
callq 0x45f0
movq -0x2e0(%rbp), %rdx
leaq 0xe8f1(%rip), %rsi      # 0x140b5
leaq -0x218(%rbp), %rdi
callq 0x4490
jmp 0x57d2
leaq -0x1f8(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0xd2a0
jmp 0x57e7
movq -0x2e8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x72a0
jmp 0x57fc
movq -0x250(%rbp), %rax
movq -0x2e8(%rbp), %rcx
movb $0x0, -0x21a(%rbp)
movq %rcx, 0x58(%rax)
leaq -0x1f8(%rbp), %rdi
callq 0x4200
jmp 0x5823
leaq -0x218(%rbp), %rdi
callq 0x4200
jmp 0x5831
leaq -0x219(%rbp), %rdi
callq 0x4400
movq -0x250(%rbp), %rdi
movq 0x58(%rdi), %rax
movq %rax, -0x310(%rbp)
callq 0x106a0
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x22c(%rbp)
movl -0x22c(%rbp), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %edx, %ecx
sarl %ecx
movl %ecx, -0x314(%rbp)
movq 0x58(%rax), %rdi
callq 0x106a0
movl -0x314(%rbp), %esi
movq %rax, -0x234(%rbp)
movl -0x234(%rbp), %eax
movl %eax, %ecx
addl $0x7, %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x3, %eax
subl %eax, %esi
leaq -0x224(%rbp), %rdi
movl $0x3, %edx
callq 0x4ed0
movq -0x310(%rbp), %rdi
movq -0x224(%rbp), %rsi
callq 0x10680
movq -0x250(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %esi, %esi
callq 0xa6b0
movq -0x250(%rbp), %rax
movq 0x58(%rax), %rdi
movl $0x23, %esi
callq 0xa670
movl $0x88, %edi
callq 0x43a0
movq %rax, %rcx
movq -0x250(%rbp), %rax
movq %rcx, -0x308(%rbp)
movq 0x40(%rax), %rdi
callq 0x10660
movq %rax, -0x300(%rbp)
jmp 0x591d
movq -0x308(%rbp), %rdi
movq -0x250(%rbp), %rax
movq -0x300(%rbp), %rcx
movq %rcx, -0x23c(%rbp)
movq 0x38(%rax), %rdx
movq -0x23c(%rbp), %rsi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x7410
jmp 0x5951
movq -0x250(%rbp), %rdi
movq -0x308(%rbp), %rax
movq %rax, 0x50(%rdi)
movq 0x50(%rdi), %rsi
callq 0x10420
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
movq -0x248(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x4360
jmp 0x5bd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x59fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x59e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x59d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x4200
jmp 0x59d3
jmp 0x59d5
leaq -0x98(%rbp), %rdi
callq 0x4200
jmp 0x59e3
jmp 0x59e5
leaq -0x99(%rbp), %rdi
callq 0x4400
leaq -0x58(%rbp), %rdi
callq 0x4200
jmp 0x59fc
jmp 0x59fe
testb $0x1, -0x9a(%rbp)
jne 0x5a09
jmp 0x5a15
movq -0x268(%rbp), %rdi
callq 0x4360
jmp 0x5bd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5a44
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x4200
jmp 0x5a42
jmp 0x5a44
leaq -0xd9(%rbp), %rdi
callq 0x4400
testb $0x1, -0xda(%rbp)
jne 0x5a5b
jmp 0x5a67
movq -0x280(%rbp), %rdi
callq 0x4360
jmp 0x5bd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5ade
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5ac2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5ab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x4200
jmp 0x5ab0
jmp 0x5ab2
leaq -0x160(%rbp), %rdi
callq 0x4200
jmp 0x5ac0
jmp 0x5ac2
leaq -0x161(%rbp), %rdi
callq 0x4400
leaq -0x120(%rbp), %rdi
callq 0x4200
jmp 0x5adc
jmp 0x5ade
testb $0x1, -0x162(%rbp)
jne 0x5ae9
jmp 0x5af5
movq -0x298(%rbp), %rdi
callq 0x4360
jmp 0x5bd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5b24
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1b0(%rbp), %rdi
callq 0x4200
jmp 0x5b22
jmp 0x5b24
leaq -0x1b1(%rbp), %rdi
callq 0x4400
testb $0x1, -0x1b2(%rbp)
jne 0x5b3b
jmp 0x5b47
movq -0x2c0(%rbp), %rdi
callq 0x4360
jmp 0x5bd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5b94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x5b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x4200
jmp 0x5b82
jmp 0x5b84
leaq -0x218(%rbp), %rdi
callq 0x4200
jmp 0x5b92
jmp 0x5b94
leaq -0x219(%rbp), %rdi
callq 0x4400
testb $0x1, -0x21a(%rbp)
jne 0x5bab
jmp 0x5bb7
movq -0x2e8(%rbp), %rdi
callq 0x4360
jmp 0x5bd1
movq -0x308(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x4360
movq -0x30(%rbp), %rdi
callq 0x45e0
movq %rax, %rdi
callq 0x4ec0
nopw %cs:(%rax,%rax)