// File: /workspace/github_cpp_makefile_star2_O3/Jacobious52[P]Tanks/Test.cpp
// Function: test_array()
void test_array()
{
    // ---testing marray using pointers----

    printf("\nTesting array (of timers)..\n\n");
    MTArray array(5);
    assert(array.get_size() == 5, "init size");
    assert(array.get_count() == 0, "init count");

    array.add(new Timer(0, 0));
    assert(array.get_count() == 1, "count 1");

    array.add(new Timer(1, 1));
    Timer *t0 = new Timer(2, 2);
    array.add(t0);
    array.add(new Timer(3, 3));
    assert(array.get_count() == 4, "count 4");

    array.add(new Timer(4, 4));
    assert(array.get_count() == 5, "count 5");

    array.add(new Timer(5, 5));
    array.add(new Timer(6, 6));
    assert(array.get_count() == 7, "count 7");
    assert(array.get_size() == 10, "resized to 10");

    Timer *t1 = array.remove(2);
    assert(t1 == t0, "remove and return");
    delete t1;

    assert(array.get_count() == 6, "count 6");

    for (int i = 0; i < array.get_count(); ++i)
    {
        int d = i;
        if (i >= 2)
        {
            d += 1;
        }
        assert(array[i]->get_delay() == static_cast<double>(d), "iterating ");
        ConsoleTools::move_cursor(ConsoleTools::up , 1);
        ConsoleTools::move_cursor(ConsoleTools::right , StringTools::string_width("Passed: interating"));
        printf(": timer delay: %.2lf\n", array[i]->get_delay());
    }

    for (int i = 0; i < array.get_count(); ++i)
    {
        delete array.remove(i);
    }

    array.clear();
    assert(array.get_count() == 0, "clear");

    // -----test using int array------

    printf("\nTesting int array..\n\n");
    MutableArray<int> i_array(5);
    assert(i_array.get_size() == 5, "init size");
    assert(i_array.get_count() == 0, "init count");

    i_array.add(10);
    i_array.add(20);
    i_array.add(30);
    assert(i_array.get_count() == 3, "count 3");

    int x2 = i_array.remove(2);
    assert(x2 == 30, "remove and return");

    i_array.clear();
    assert(i_array.get_count() == 0, "clear");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
leaq 0x22ac(%rip), %rdi      # 0xc49a
callq 0x3310
movq $0x0, -0x40(%rbp)
movl $0x5, %eax
movq %rax, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movl $0x28, %edi
callq 0x3030
movq %rax, -0x48(%rbp)
leaq 0x2175(%rip), %rsi      # 0xc392
movl $0x1, %edi
callq 0xa0e0
leaq 0x216e(%rip), %rsi      # 0xc39c
movl $0x1, %edi
callq 0xa0e0
movl $0x20, %edi
callq 0x3220
movq %rax, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
movw $0x0, 0x18(%rax)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xa26b
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rbx, (%rcx,%rax,8)
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x211c(%rip), %rsi      # 0xc3a7
callq 0xa0e0
movl $0x20, %edi
callq 0x3220
movq %rax, %rbx
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x8(%rbx)
movq $0x1, 0x10(%rbx)
movw $0x0, 0x18(%rbx)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xa2d0
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq 0x1(%rax), %r14
movq %r14, -0x40(%rbp)
movq %rbx, (%rcx,%rax,8)
movl $0x20, %edi
callq 0x3220
movq %rax, %rbx
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0x8(%rbx)
movq $0x2, 0x10(%rbx)
movw $0x0, 0x18(%rbx)
cmpq -0x38(%rbp), %r14
jb 0xa31c
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %r14
movq -0x48(%rbp), %rax
leaq 0x1(%r14), %r15
movq %r15, -0x40(%rbp)
movq %rbx, (%rax,%r14,8)
movl $0x20, %edi
callq 0x3220
movq %rax, %r14
movabsq $0x4008000000000000, %rax # imm = 0x4008000000000000
movq %rax, 0x8(%r14)
movq $0x3, 0x10(%r14)
movw $0x0, 0x18(%r14)
cmpq -0x38(%rbp), %r15
jb 0xa369
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %r15
movq -0x48(%rbp), %rax
leaq 0x1(%r15), %rcx
movq %rcx, -0x40(%rbp)
movq %r14, (%rax,%r15,8)
xorl %edi, %edi
cmpq $0x4, %rcx
sete %dil
leaq 0x2025(%rip), %rsi      # 0xc3af
callq 0xa0e0
movl $0x20, %edi
callq 0x3220
movq %rax, %r14
movabsq $0x4010000000000000, %rax # imm = 0x4010000000000000
movq %rax, 0x8(%r14)
movq $0x4, 0x10(%r14)
movw $0x0, 0x18(%r14)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xa3d0
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %r14, (%rcx,%rax,8)
xorl %edi, %edi
cmpq $0x5, %rdx
sete %dil
leaq 0x1fc6(%rip), %rsi      # 0xc3b7
callq 0xa0e0
movl $0x20, %edi
callq 0x3220
movq %rax, %r14
movabsq $0x4014000000000000, %rax # imm = 0x4014000000000000
movq %rax, 0x8(%r14)
movq $0x5, 0x10(%r14)
movw $0x0, 0x18(%r14)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xa437
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %rax
movq -0x48(%rbp), %rcx
leaq 0x1(%rax), %r15
movq %r15, -0x40(%rbp)
movq %r14, (%rcx,%rax,8)
movl $0x20, %edi
callq 0x3220
movq %rax, %r14
movabsq $0x4018000000000000, %rax # imm = 0x4018000000000000
movq %rax, 0x8(%r14)
movq $0x6, 0x10(%r14)
movw $0x0, 0x18(%r14)
cmpq -0x38(%rbp), %r15
jb 0xa484
leaq -0x48(%rbp), %rdi
callq 0xb56e
movq -0x40(%rbp), %r15
movq -0x48(%rbp), %rax
leaq 0x1(%r15), %rcx
movq %rcx, -0x40(%rbp)
movq %r14, (%rax,%r15,8)
xorl %edi, %edi
cmpq $0x7, %rcx
sete %dil
leaq 0x1f1a(%rip), %rsi      # 0xc3bf
callq 0xa0e0
xorl %edi, %edi
cmpq $0xa, -0x38(%rbp)
sete %dil
leaq 0x1f0b(%rip), %rsi      # 0xc3c7
callq 0xa0e0
movq -0x40(%rbp), %rax
cmpq $0x3, %rax
jb 0xa4f8
movq -0x48(%rbp), %rcx
movq 0x10(%rcx), %r14
leaq -0x2(%rax), %rcx
xorl %edx, %edx
movq -0x48(%rbp), %rsi
movq 0x18(%rsi,%rdx,8), %rdi
movq %rdi, 0x10(%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0xa4d9
decq %rax
movq %rax, -0x40(%rbp)
jmp 0xa4fb
xorl %r14d, %r14d
xorl %edi, %edi
cmpq %rbx, %r14
sete %dil
leaq 0x1eca(%rip), %rsi      # 0xc3d5
callq 0xa0e0
testq %r14, %r14
je 0xa51c
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x3200
xorl %edi, %edi
cmpq $0x6, -0x40(%rbp)
sete %dil
leaq 0x1eb1(%rip), %rsi      # 0xc3e7
callq 0xa0e0
cmpq $0x0, -0x40(%rbp)
je 0xa69b
leaq -0x78(%rbp), %rbx
xorl %r14d, %r14d
leaq 0x1eb8(%rip), %r15      # 0xc40c
leaq -0x88(%rbp), %r12
leaq 0x1eab(%rip), %r13      # 0xc40d
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rdi
callq 0x8b82
leal 0x1(%r14), %eax
cmpq $0x2, %r14
cmovbl %r14d, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
cmpeqsd %xmm1, %xmm0
movq %xmm0, %rdi
andl $0x1, %edi
leaq 0x1e59(%rip), %rsi      # 0xc3ef
callq 0xa0e0
movl $0x41, %edi
movl $0x1, %esi
callq 0x38d6
movq %rbx, -0x88(%rbp)
movq %r12, %rdi
leaq 0x1e3f(%rip), %rsi      # 0xc3fa
movq %r15, %rdx
callq 0x56ee
movq %r12, %rdi
callq 0x6cee
movl $0x43, %edi
movl %eax, %esi
callq 0x38d6
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0xa5e8
callq 0x3200
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rdi
callq 0x8b82
movq %r13, %rdi
movb $0x1, %al
callq 0x3060
movq -0x40(%rbp), %rax
incq %r14
cmpq %r14, %rax
ja 0xa562
testq %rax, %rax
je 0xa69b
xorl %ebx, %ebx
movq -0x48(%rbp), %rcx
movq (%rcx,%rbx,8), %rdi
movq %rbx, %rcx
movq -0x48(%rbp), %rdx
movq 0x8(%rdx,%rcx,8), %rsi
movq %rsi, (%rdx,%rcx,8)
leaq 0x1(%rcx), %rdx
movq %rdx, %rcx
cmpq %rdx, %rax
jne 0xa625
decq %rax
movq %rax, -0x40(%rbp)
testq %rdi, %rdi
je 0xa651
movq $0x0, (%rdi)
callq 0x3200
incq %rbx
movq -0x40(%rbp), %rax
cmpq %rbx, %rax
ja 0xa61a
testq %rax, %rax
je 0xa69b
xorl %ecx, %ecx
movq -0x48(%rbp), %rdx
cmpq $0x0, (%rdx,%rcx,8)
je 0xa693
movq %rcx, %rdx
movq -0x48(%rbp), %rsi
movq 0x8(%rsi,%rdx,8), %rdi
movq %rdi, (%rsi,%rdx,8)
leaq 0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %rsi, %rax
jne 0xa677
decq %rax
incq %rcx
cmpq %rcx, %rax
ja 0xa669
movq $0x0, -0x40(%rbp)
leaq 0x1d79(%rip), %rsi      # 0xc423
movl $0x1, %edi
callq 0xa0e0
leaq 0x1dfd(%rip), %rdi      # 0xc4b8
callq 0x3310
movq $0x0, -0x60(%rbp)
movl $0x5, %eax
movq %rax, -0x58(%rbp)
movq %rax, -0x50(%rbp)
movl $0x14, %edi
callq 0x3030
movq %rax, -0x68(%rbp)
leaq 0x1ca8(%rip), %rsi      # 0xc392
movl $0x1, %edi
callq 0xa0e0
xorl %edi, %edi
cmpq $0x0, -0x60(%rbp)
sete %dil
leaq 0x1c96(%rip), %rsi      # 0xc39c
callq 0xa0e0
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rcx
cmpq %rcx, %rsi
jb 0xa729
leaq -0x68(%rbp), %rdi
callq 0xb5ea
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rax
leaq 0x1(%rsi), %rdx
movq %rdx, -0x60(%rbp)
movl $0xa, (%rax,%rsi,4)
cmpq %rcx, %rdx
jb 0xa756
leaq -0x68(%rbp), %rdi
callq 0xb5ea
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, -0x60(%rbp)
movl $0x14, (%rax,%rdx,4)
cmpq %rcx, %rsi
jb 0xa77b
leaq -0x68(%rbp), %rdi
callq 0xb5ea
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rsi
leaq 0x1(%rsi), %rcx
movq %rcx, -0x60(%rbp)
movl $0x1e, (%rax,%rsi,4)
xorl %edi, %edi
cmpq $0x3, %rcx
sete %dil
leaq 0x1c8e(%rip), %rsi      # 0xc429
callq 0xa0e0
movq -0x60(%rbp), %rbx
cmpq $0x3, %rbx
jb 0xa7d7
movq -0x68(%rbp), %rsi
leaq 0x8(%rsi), %rdi
movl 0x8(%rsi), %r14d
addq $0xc, %rsi
leaq -0x8(,%rbx,4), %rdx
callq 0x3370
decq %rbx
movq %rbx, -0x60(%rbp)
cmpl $0x1e, %r14d
sete %al
jmp 0xa7d9
xorl %eax, %eax
movzbl %al, %edi
leaq 0x1bf2(%rip), %rsi      # 0xc3d5
callq 0xa0e0
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0xa82d
movq -0x68(%rbp), %rcx
leaq 0x4(%rcx), %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpl $0x0, (%rcx,%rdi,4)
je 0xa81e
leaq (%rax,%rsi), %r8
xorl %r9d, %r9d
movl (%rdx,%r9,4), %r10d
movl %r10d, -0x4(%rdx,%r9,4)
incq %r9
cmpq %r9, %r8
jne 0xa80a
decq %rax
incq %rdi
addq $0x4, %rdx
decq %rsi
cmpq %rdi, %rax
ja 0xa7fd
movq $0x0, -0x60(%rbp)
leaq 0x1be7(%rip), %rsi      # 0xc423
movl $0x1, %edi
callq 0xa0e0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xa854
callq 0x3290
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xa862
callq 0x3290
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa8a6
jmp 0xa877
jmp 0xa8a6
movq %rax, %r14
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xa8a9
callq 0x3290
jmp 0xa8a9
jmp 0xa8a6
jmp 0xa8a6
jmp 0xa8a6
movq %rax, %r14
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0xa8a9
callq 0x3200
jmp 0xa8a9
movq %rax, %r14
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xa8b7
callq 0x3290
movq %r14, %rdi
callq 0x33d0