// File: 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
subq $0x1b0, %rsp            # imm = 0x1B0
leaq 0x373a(%rip), %rdi      # 0x143ac
xorl %eax, %eax
callq 0x3070
leaq -0x20(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
movl $0x5, %esi
callq 0x127f0
movq -0xa8(%rbp), %rdi
callq 0x12820
movq %rax, -0xa0(%rbp)
jmp 0x10ca3
movq -0xa0(%rbp), %rax
subq $0x5, %rax
sete %al
movzbl %al, %edi
leaq 0x3710(%rip), %rsi      # 0x143cb
callq 0x109f0
jmp 0x10cc2
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0xb0(%rbp)
jmp 0x10cd4
movq -0xb0(%rbp), %rax
testq %rax, %rax
sete %al
movzbl %al, %edi
leaq 0x36ea(%rip), %rsi      # 0x143d5
callq 0x109f0
jmp 0x10cf2
movl $0x20, %edi
callq 0x3310
movq %rax, -0xb8(%rbp)
jmp 0x10d05
movq -0xb8(%rbp), %rdi
xorps %xmm0, %xmm0
xorl %esi, %esi
callq 0xbbc0
jmp 0x10d18
movq -0xb8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10d2a
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0xc0(%rbp)
jmp 0x10d3c
movq -0xc0(%rbp), %rax
subq $0x1, %rax
sete %al
movzbl %al, %edi
leaq 0x368c(%rip), %rsi      # 0x143e0
callq 0x109f0
jmp 0x10d5b
movl $0x20, %edi
callq 0x3310
movq %rax, -0xc8(%rbp)
jmp 0x10d6e
movq -0xc8(%rbp), %rdi
movsd 0x35b3(%rip), %xmm0     # 0x14330
movl $0x1, %esi
callq 0xbbc0
jmp 0x10d89
movq -0xc8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10d9b
movl $0x20, %edi
callq 0x3310
movq %rax, -0xd0(%rbp)
jmp 0x10dae
movq -0xd0(%rbp), %rdi
movsd 0x343b(%rip), %xmm0     # 0x141f8
movl $0x2, %esi
callq 0xbbc0
jmp 0x10dc9
movq -0xd0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10de3
movl $0x20, %edi
callq 0x3310
movq %rax, -0xd8(%rbp)
jmp 0x10df6
movq -0xd8(%rbp), %rdi
movsd 0x3533(%rip), %xmm0     # 0x14338
movl $0x3, %esi
callq 0xbbc0
jmp 0x10e11
movq -0xd8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10e23
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0xe0(%rbp)
jmp 0x10e35
movq -0xe0(%rbp), %rax
subq $0x4, %rax
sete %al
movzbl %al, %edi
leaq 0x359b(%rip), %rsi      # 0x143e8
callq 0x109f0
jmp 0x10e54
movl $0x20, %edi
callq 0x3310
movq %rax, -0xe8(%rbp)
jmp 0x10e67
movq -0xe8(%rbp), %rdi
movsd 0x34ca(%rip), %xmm0     # 0x14340
movl $0x4, %esi
callq 0xbbc0
jmp 0x10e82
movq -0xe8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10e94
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0xf0(%rbp)
jmp 0x10ea6
movq -0xf0(%rbp), %rax
subq $0x5, %rax
sete %al
movzbl %al, %edi
leaq 0x3532(%rip), %rsi      # 0x143f0
callq 0x109f0
jmp 0x10ec5
movl $0x20, %edi
callq 0x3310
movq %rax, -0xf8(%rbp)
jmp 0x10ed8
movq -0xf8(%rbp), %rdi
movsd 0x3301(%rip), %xmm0     # 0x141e8
movl $0x5, %esi
callq 0xbbc0
jmp 0x10ef3
movq -0xf8(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10f05
movl $0x20, %edi
callq 0x3310
movq %rax, -0x100(%rbp)
jmp 0x10f18
movq -0x100(%rbp), %rdi
movsd 0x3421(%rip), %xmm0     # 0x14348
movl $0x6, %esi
callq 0xbbc0
jmp 0x10f33
movq -0x100(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12860
jmp 0x10f45
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0x108(%rbp)
jmp 0x10f57
movq -0x108(%rbp), %rax
subq $0x7, %rax
sete %al
movzbl %al, %edi
leaq 0x3489(%rip), %rsi      # 0x143f8
callq 0x109f0
jmp 0x10f76
leaq -0x20(%rbp), %rdi
callq 0x12820
movq %rax, -0x110(%rbp)
jmp 0x10f88
movq -0x110(%rbp), %rax
subq $0xa, %rax
sete %al
movzbl %al, %edi
leaq 0x3460(%rip), %rsi      # 0x14400
callq 0x109f0
jmp 0x10fa7
leaq -0x20(%rbp), %rdi
movl $0x2, %esi
callq 0x128b0
movq %rax, -0x118(%rbp)
jmp 0x10fbe
movq -0x118(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
sete %al
movzbl %al, %edi
leaq 0x342d(%rip), %rsi      # 0x1440e
callq 0x109f0
jmp 0x10fe8
movq -0x40(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x11013
movq -0x120(%rbp), %rdi
callq 0xbc40
jmp 0x11007
movq -0x120(%rbp), %rdi
callq 0x32e0
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0x128(%rbp)
jmp 0x11025
movq -0x128(%rbp), %rax
subq $0x6, %rax
sete %al
movzbl %al, %edi
leaq 0x33e3(%rip), %rsi      # 0x14420
callq 0x109f0
jmp 0x11044
movl $0x0, -0x44(%rbp)
movslq -0x44(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0x130(%rbp)
jmp 0x11068
movq -0x138(%rbp), %rax
movq -0x130(%rbp), %rcx
cmpq %rcx, %rax
jae 0x112e6
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x2, -0x44(%rbp)
jl 0x11196
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x11196
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x11575
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0xe8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0x100(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
movslq -0x44(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12960
movq %rax, -0x140(%rbp)
jmp 0x111ac
movq -0x140(%rbp), %rdi
callq 0xda70
movsd %xmm0, -0x148(%rbp)
jmp 0x111c2
movsd -0x148(%rbp), %xmm0
cvtsi2sdl -0x48(%rbp), %xmm1
cmpeqsd %xmm1, %xmm0
movq %xmm0, %rax
movl %eax, %edi
andl $0x1, %edi
leaq 0x3243(%rip), %rsi      # 0x14428
callq 0x109f0
jmp 0x111ec
movl $0x41, %edi
movl $0x1, %esi
callq 0x3b50
jmp 0x111fd
leaq -0x69(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x34e0
movq -0x150(%rbp), %rdx
leaq 0x3218(%rip), %rsi      # 0x14433
leaq -0x68(%rbp), %rdi
callq 0x33a0
jmp 0x11226
leaq -0x68(%rbp), %rdi
callq 0x9d80
movl %eax, -0x154(%rbp)
jmp 0x11237
movl -0x154(%rbp), %esi
movl $0x43, %edi
callq 0x3b50
jmp 0x11249
leaq -0x68(%rbp), %rdi
callq 0x31c0
jmp 0x11254
leaq -0x69(%rbp), %rdi
callq 0x3360
movslq -0x44(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x12960
movq %rax, -0x160(%rbp)
jmp 0x11273
movq -0x160(%rbp), %rdi
callq 0xda70
movsd %xmm0, -0x168(%rbp)
jmp 0x11289
movsd -0x168(%rbp), %xmm0
leaq 0x31ae(%rip), %rdi      # 0x14446
movb $0x1, %al
callq 0x3070
jmp 0x112a1
jmp 0x112a3
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1104b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x112d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x31c0
jmp 0x112d6
jmp 0x112d8
leaq -0x69(%rbp), %rdi
callq 0x3360
jmp 0x11575
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0x170(%rbp)
jmp 0x1130a
movq -0x178(%rbp), %rax
movq -0x170(%rbp), %rcx
cmpq %rcx, %rax
jae 0x11384
movslq -0x70(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x128b0
movq %rax, -0x180(%rbp)
jmp 0x11333
movq -0x180(%rbp), %rax
cmpq $0x0, %rax
je 0x1135a
movq -0x180(%rbp), %rdi
callq 0xbc40
jmp 0x1134e
movq -0x180(%rbp), %rdi
callq 0x32e0
jmp 0x1135c
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x112ed
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x32e0
jmp 0x11575
leaq -0x20(%rbp), %rdi
callq 0x12990
jmp 0x1138f
leaq -0x20(%rbp), %rdi
callq 0x12840
movq %rax, -0x188(%rbp)
jmp 0x113a1
movq -0x188(%rbp), %rax
testq %rax, %rax
sete %al
movzbl %al, %edi
leaq 0x30a4(%rip), %rsi      # 0x1445c
callq 0x109f0
jmp 0x113bf
leaq 0x309c(%rip), %rdi      # 0x14462
xorl %eax, %eax
callq 0x3070
jmp 0x113cf
leaq -0x90(%rbp), %rdi
movl $0x5, %esi
callq 0x12a00
jmp 0x113e2
leaq -0x90(%rbp), %rdi
callq 0x12a30
movq %rax, -0x190(%rbp)
jmp 0x113f7
movq -0x190(%rbp), %rax
subq $0x5, %rax
sete %al
movzbl %al, %edi
leaq 0x2fbc(%rip), %rsi      # 0x143cb
callq 0x109f0
jmp 0x11416
leaq -0x90(%rbp), %rdi
callq 0x12a50
movq %rax, -0x198(%rbp)
jmp 0x1142b
movq -0x198(%rbp), %rax
testq %rax, %rax
sete %al
movzbl %al, %edi
leaq 0x2f93(%rip), %rsi      # 0x143d5
callq 0x109f0
jmp 0x11449
leaq -0x90(%rbp), %rdi
movl $0xa, %esi
callq 0x12a70
jmp 0x1145c
leaq -0x90(%rbp), %rdi
movl $0x14, %esi
callq 0x12a70
jmp 0x1146f
leaq -0x90(%rbp), %rdi
movl $0x1e, %esi
callq 0x12a70
jmp 0x11482
leaq -0x90(%rbp), %rdi
callq 0x12a50
movq %rax, -0x1a0(%rbp)
jmp 0x11497
movq -0x1a0(%rbp), %rax
subq $0x3, %rax
sete %al
movzbl %al, %edi
leaq 0x2fca(%rip), %rsi      # 0x14479
callq 0x109f0
jmp 0x114b6
leaq -0x90(%rbp), %rdi
movl $0x2, %esi
callq 0x12ac0
movl %eax, -0x1a4(%rbp)
jmp 0x114cf
movl -0x1a4(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
subl $0x1e, %eax
sete %al
movzbl %al, %edi
leaq 0x2f1d(%rip), %rsi      # 0x1440e
callq 0x109f0
jmp 0x114f8
leaq -0x90(%rbp), %rdi
callq 0x12b60
jmp 0x11506
leaq -0x90(%rbp), %rdi
callq 0x12a50
movq %rax, -0x1b0(%rbp)
jmp 0x1151b
movq -0x1b0(%rbp), %rax
testq %rax, %rax
sete %al
movzbl %al, %edi
leaq 0x2f2a(%rip), %rsi      # 0x1445c
callq 0x109f0
jmp 0x11539
leaq -0x90(%rbp), %rdi
callq 0x12bd0
jmp 0x11547
leaq -0x20(%rbp), %rdi
callq 0x12c00
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x12bd0
jmp 0x11573
jmp 0x11575
leaq -0x20(%rbp), %rdi
callq 0x12c00
jmp 0x11580
jmp 0x11582
movq -0x28(%rbp), %rdi
callq 0x34d0
movq %rax, %rdi
callq 0x3d90
nopw %cs:(%rax,%rax)