// File: /workspace/github_cpp_makefile_star2_O1/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 0x22c4(%rip), %rdi      # 0xc4a2
callq 0x3320
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 0x218d(%rip), %rsi      # 0xc39a
movl $0x1, %edi
callq 0xa0d0
xorl %edi, %edi
cmpq $0x0, -0x40(%rbp)
sete %dil
leaq 0x217b(%rip), %rsi      # 0xc3a4
callq 0xa0d0
movl $0x20, %edi
callq 0x3230
movq %rax, %rbx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rax)
movw $0x0, 0x18(%rax)
movq -0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0xa25d
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq %rbx, (%rax,%rcx,8)
xorl %edi, %edi
testq %rcx, %rcx
sete %dil
leaq 0x212e(%rip), %rsi      # 0xc3af
callq 0xa0d0
movl $0x20, %edi
callq 0x3230
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 0xa2c2
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %r14
movq %r14, -0x40(%rbp)
movq %rbx, (%rax,%rcx,8)
movl $0x20, %edi
callq 0x3230
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 0xa30e
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %r15
movq %r15, -0x40(%rbp)
movq %rbx, (%rax,%rcx,8)
movl $0x20, %edi
callq 0x3230
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 0xa35b
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq %r14, (%rax,%rcx,8)
xorl %edi, %edi
cmpq $0x4, %rdx
sete %dil
leaq 0x2037(%rip), %rsi      # 0xc3b7
callq 0xa0d0
movl $0x20, %edi
callq 0x3230
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 0xa3c2
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq %r14, (%rax,%rcx,8)
xorl %edi, %edi
cmpq $0x5, %rdx
sete %dil
leaq 0x1fd8(%rip), %rsi      # 0xc3bf
callq 0xa0d0
movl $0x20, %edi
callq 0x3230
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 0xa429
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %r15
movq %r15, -0x40(%rbp)
movq %r14, (%rax,%rcx,8)
movl $0x20, %edi
callq 0x3230
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 0xa476
leaq -0x48(%rbp), %rdi
callq 0xb56c
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x40(%rbp)
movq %r14, (%rax,%rcx,8)
xorl %edi, %edi
cmpq $0x7, %rdx
sete %dil
leaq 0x1f2c(%rip), %rsi      # 0xc3c7
callq 0xa0d0
xorl %edi, %edi
cmpq $0xa, -0x38(%rbp)
sete %dil
leaq 0x1f1d(%rip), %rsi      # 0xc3cf
callq 0xa0d0
movq -0x40(%rbp), %rax
cmpq $0x3, %rax
jb 0xa4ee
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 0xa4cf
decq %rax
movq %rax, -0x40(%rbp)
jmp 0xa4f1
xorl %r14d, %r14d
xorl %edi, %edi
cmpq %rbx, %r14
sete %dil
leaq 0x1edc(%rip), %rsi      # 0xc3dd
callq 0xa0d0
testq %r14, %r14
je 0xa51a
movq $0x0, (%r14)
movq %r14, %rdi
callq 0x3210
xorl %edi, %edi
cmpq $0x6, -0x40(%rbp)
sete %dil
leaq 0x1ec3(%rip), %rsi      # 0xc3ef
callq 0xa0d0
cmpq $0x0, -0x40(%rbp)
je 0xa602
leaq -0x78(%rbp), %rbx
xorl %r14d, %r14d
leaq 0x1eca(%rip), %r15      # 0xc414
leaq -0x88(%rbp), %r12
leaq 0x1ebd(%rip), %r13      # 0xc415
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rdi
callq 0x8b76
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 0x1e6b(%rip), %rsi      # 0xc3f7
callq 0xa0d0
movl $0x41, %edi
movl $0x1, %esi
callq 0x38e6
movq %rbx, -0x88(%rbp)
movq %r12, %rdi
leaq 0x1e51(%rip), %rsi      # 0xc402
movq %r15, %rdx
callq 0x56e4
movq %r12, %rdi
callq 0x6cee
movl $0x43, %edi
movl %eax, %esi
callq 0x38e6
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0xa5de
callq 0x3210
movq -0x48(%rbp), %rax
movq (%rax,%r14,8), %rdi
callq 0x8b76
movq %r13, %rdi
movb $0x1, %al
callq 0x3060
incq %r14
cmpq %r14, -0x40(%rbp)
ja 0xa558
movq -0x40(%rbp), %rax
testq %rax, %rax
je 0xa655
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 0xa618
decq %rax
movq %rax, -0x40(%rbp)
testq %rdi, %rdi
je 0xa649
movq $0x0, (%rdi)
callq 0x3210
incq %rbx
movq -0x40(%rbp), %rax
cmpq %rbx, %rax
ja 0xa60d
testq %rax, %rax
je 0xa692
xorl %ecx, %ecx
movq -0x48(%rbp), %rdx
cmpq $0x0, (%rdx,%rcx,8)
movq %rcx, %rdx
je 0xa68a
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 0xa66a
decq %rax
movq %rax, -0x40(%rbp)
incq %rcx
cmpq %rcx, %rax
ja 0xa65c
movq $0x0, -0x40(%rbp)
leaq 0x1d8a(%rip), %rsi      # 0xc42b
movl $0x1, %edi
callq 0xa0d0
leaq 0x1e0e(%rip), %rdi      # 0xc4c0
callq 0x3320
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 0x1cb9(%rip), %rsi      # 0xc39a
movl $0x1, %edi
callq 0xa0d0
xorl %edi, %edi
cmpq $0x0, -0x60(%rbp)
sete %dil
leaq 0x1ca7(%rip), %rsi      # 0xc3a4
callq 0xa0d0
movq -0x60(%rbp), %rax
cmpq -0x58(%rbp), %rax
jb 0xa715
leaq -0x68(%rbp), %rdi
callq 0xb5e8
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x60(%rbp)
movl $0xa, (%rax,%rcx,4)
cmpq -0x58(%rbp), %rdx
jb 0xa73b
leaq -0x68(%rbp), %rdi
callq 0xb5e8
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x60(%rbp)
movl $0x14, (%rax,%rcx,4)
cmpq -0x58(%rbp), %rdx
jb 0xa761
leaq -0x68(%rbp), %rdi
callq 0xb5e8
movq -0x68(%rbp), %rax
movq -0x60(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, -0x60(%rbp)
movl $0x1e, (%rax,%rcx,4)
xorl %edi, %edi
cmpq $0x3, %rdx
sete %dil
leaq 0x1ca8(%rip), %rsi      # 0xc431
callq 0xa0d0
movq -0x60(%rbp), %rbx
cmpq $0x3, %rbx
jb 0xa7c5
movq -0x68(%rbp), %rsi
leaq 0x8(%rsi), %rdi
movl 0x8(%rsi), %r14d
addq $0xc, %rsi
leaq -0x8(,%rbx,4), %rdx
callq 0x3380
decq %rbx
movq %rbx, -0x60(%rbp)
cmpl $0x1e, %r14d
sete %al
jmp 0xa7c7
xorl %eax, %eax
movzbl %al, %edi
leaq 0x1c0c(%rip), %rsi      # 0xc3dd
callq 0xa0d0
movq -0x60(%rbp), %rax
testq %rax, %rax
je 0xa81f
movq -0x68(%rbp), %rcx
leaq 0x4(%rcx), %rdx
xorl %esi, %esi
xorl %edi, %edi
cmpl $0x0, (%rcx,%rdi,4)
je 0xa810
leaq (%rax,%rsi), %r8
xorl %r9d, %r9d
movl (%rdx,%r9,4), %r10d
movl %r10d, -0x4(%rdx,%r9,4)
incq %r9
cmpq %r9, %r8
jne 0xa7f8
decq %rax
movq %rax, -0x60(%rbp)
incq %rdi
addq $0x4, %rdx
decq %rsi
cmpq %rdi, %rax
ja 0xa7eb
movq $0x0, -0x60(%rbp)
leaq 0x1bfd(%rip), %rsi      # 0xc42b
movl $0x1, %edi
callq 0xa0d0
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xa846
callq 0x32a0
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xa854
callq 0x32a0
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa898
jmp 0xa869
jmp 0xa898
movq %rax, %r14
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xa89b
callq 0x32a0
jmp 0xa89b
jmp 0xa898
jmp 0xa898
jmp 0xa898
movq %rax, %r14
movq -0x88(%rbp), %rdi
cmpq %rbx, %rdi
je 0xa89b
callq 0x3210
jmp 0xa89b
movq %rax, %r14
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xa8a9
callq 0x32a0
movq %r14, %rdi
callq 0x33e0