// File: /workspace/github_c_makefile_star2_O3/chatziko-k08[P]lecture-code/tests/ADTVector_test.c
// Function: test_iterate
void test_iterate(void) {
	Vector vec = vector_create(0, NULL);
	int N = 1000;
	int* array = malloc(N * sizeof(*array));		// Στο vector θα προσθέσουμε pointers προς τα στοιχεία αυτού του πίνακα

	// first/last σε κενό vector
	TEST_ASSERT(vector_first(vec) == VECTOR_BOF);
	TEST_ASSERT(vector_last(vec) == VECTOR_EOF);

	// εισαγωγή στοιχείων
	for (int i = 0; i < 1000; i++)
		vector_insert_last(vec, &array[i]);

	int i = 0;
	for (VectorNode node = vector_first(vec); node != VECTOR_EOF; node = vector_next(vec, node))
		TEST_ASSERT(vector_node_value(vec, node) == &array[i++]);
	TEST_ASSERT(i == N);

	for (VectorNode node = vector_last(vec); node != VECTOR_BOF; node = vector_previous(vec, node))
		TEST_ASSERT(vector_node_value(vec, node) == &array[--i]);
	TEST_ASSERT(i == 0);

	vector_destroy(vec);
	free(array);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %edi, %edi
xorl %esi, %esi
callq 0x4a9c
movq %rax, %rbx
movl $0xfa0, %edi            # imm = 0xFA0
callq 0x21a0
movq %rax, %r12
movq %rbx, %rdi
callq 0x4ccd
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x11ee(%rip), %rsi      # 0x5318
leaq 0x14d2(%rip), %rcx      # 0x5603
leaq 0x12a6(%rip), %r8       # 0x53de
movl $0x5d, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
movq %rbx, %rdi
callq 0x4cda
xorl %edi, %edi
testq %rax, %rax
sete %dil
leaq 0x11b4(%rip), %rsi      # 0x5318
leaq 0x1498(%rip), %rcx      # 0x5603
leaq 0x128c(%rip), %r8       # 0x53fe
movl $0x5e, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
xorl %r14d, %r14d
leaq (%r12,%r14), %rsi
movq %rbx, %rdi
callq 0x4b6d
addq $0x4, %r14
cmpq $0xfa0, %r14            # imm = 0xFA0
jne 0x4189
movq %rbx, %rdi
callq 0x4ccd
testq %rax, %rax
movq %r12, (%rsp)
je 0x4218
movq %rax, %r15
leaq 0x1446(%rip), %r13      # 0x5603
leaq 0x1259(%rip), %rbp      # 0x541d
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4d1d
xorl %edi, %edi
cmpq %rax, %r12
sete %dil
leaq 0x1136(%rip), %rsi      # 0x5318
movl $0x66, %edx
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4cf2
movq %rax, %r15
addq $0x4, %r12
incl %r14d
testq %rax, %rax
jne 0x41c7
jmp 0x421b
xorl %r14d, %r14d
xorl %edi, %edi
cmpl $0x3e8, %r14d           # imm = 0x3E8
sete %dil
leaq 0x10e9(%rip), %rsi      # 0x5318
leaq 0x13cd(%rip), %rcx      # 0x5603
leaq 0x120c(%rip), %r8       # 0x5449
movl $0x67, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
movq %rbx, %rdi
callq 0x4cda
testq %rax, %rax
movq (%rsp), %rcx
je 0x42c9
movq %rax, %r15
movslq %r14d, %rax
leaq (%rcx,%rax,4), %r12
addq $-0x4, %r12
leaq 0x138c(%rip), %r13      # 0x5603
leaq 0x11d2(%rip), %rbp      # 0x5450
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4d1d
xorl %edi, %edi
cmpq %rax, %r12
sete %dil
leaq 0x107f(%rip), %rsi      # 0x5318
movl $0x6a, %edx
movq %r13, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4d0f
movq %rax, %r15
decl %r14d
addq $-0x4, %r12
testq %rax, %rax
jne 0x427e
xorl %edi, %edi
testl %r14d, %r14d
sete %dil
leaq 0x103f(%rip), %rsi      # 0x5318
leaq 0x1323(%rip), %rcx      # 0x5603
leaq 0x1195(%rip), %r8       # 0x547c
movl $0x6b, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x4316
movq %rbx, %rdi
callq 0x4c89
movq (%rsp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a0
callq 0x2e2b