// File: /workspace/github_c_makefile_star2_O0/chatziko-k08[P]lecture-code/tests/ADTPriorityQueue_test.c
// Function: test_remove
void test_remove(void) {
	PriorityQueue pqueue = pqueue_create(compare_ints, free, NULL);

	// προσθήκη δεδομένων, τυχαία σειρά
	int N = 10;
	int** array = malloc(N * sizeof(*array));
	for (int i = 0; i < N; i++)
		array[i] = create_int(i);
	shuffle(array, N);

	for (int i = 0; i < N; i++)
		pqueue_insert(pqueue, array[i]);

	// Διαδοχικά remove ώστε να συμβούν και resizes
	for (int i = N-1; i >= 0; i--) {
		int* value = pqueue_max(pqueue);
		TEST_ASSERT(*value == i);
		pqueue_remove_max(pqueue);
		TEST_ASSERT(pqueue_size(pqueue) == i);
	}

	pqueue_destroy(pqueue);

	// remove από ουρά χωρίς συνάρτηση destroy
	pqueue = pqueue_create(compare_ints, NULL, NULL);
	pqueue_insert(pqueue, &N);
	TEST_ASSERT(pqueue_max(pqueue) == &N);
	pqueue_remove_max(pqueue);
	pqueue_destroy(pqueue);
	free(array);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
leaq -0x3df(%rip), %rdi      # 0x4480
movq 0x475a(%rip), %rsi      # 0x8fc0
xorl %eax, %eax
movl %eax, %edx
callq 0x5550
movq %rax, -0x8(%rbp)
movl $0xa, -0xc(%rbp)
movslq -0xc(%rbp), %rdi
shlq $0x3, %rdi
callq 0x2180
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x48bc
movl -0x1c(%rbp), %edi
callq 0x4450
movq %rax, %rdx
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4892
movq -0x18(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x43b0
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x48f7
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x56c0
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x48cf
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x49af
movq -0x8(%rbp), %rdi
callq 0x5670
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpl -0x24(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x19b2(%rip), %rsi      # 0x62e1
movl $0x5e, %edx
leaq 0x1b55(%rip), %rcx      # 0x6490
leaq 0x1a71(%rip), %r8       # 0x63b3
movb $0x0, %al
callq 0x2380
cmpl $0x0, %eax
jne 0x4953
callq 0x2e60
jmp 0x4955
movq -0x8(%rbp), %rdi
callq 0x5790
movq -0x8(%rbp), %rdi
callq 0x5650
cmpl -0x24(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x1968(%rip), %rsi      # 0x62e1
movl $0x60, %edx
leaq 0x1b0b(%rip), %rcx      # 0x6490
leaq 0x1a33(%rip), %r8       # 0x63bf
movb $0x0, %al
callq 0x2380
cmpl $0x0, %eax
jne 0x499d
callq 0x2e60
jmp 0x499f
jmp 0x49a1
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4900
movq -0x8(%rbp), %rdi
callq 0x59c0
leaq -0x53f(%rip), %rdi      # 0x4480
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x5550
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xc(%rbp), %rsi
callq 0x56c0
movq -0x8(%rbp), %rdi
callq 0x5670
leaq -0xc(%rbp), %rcx
cmpq %rcx, %rax
sete %al
andb $0x1, %al
movzbl %al, %edi
leaq 0x18e6(%rip), %rsi      # 0x62e1
movl $0x68, %edx
leaq 0x1a89(%rip), %rcx      # 0x6490
leaq 0x19ca(%rip), %r8       # 0x63d8
movb $0x0, %al
callq 0x2380
cmpl $0x0, %eax
jne 0x4a1f
callq 0x2e60
jmp 0x4a21
movq -0x8(%rbp), %rdi
callq 0x5790
movq -0x8(%rbp), %rdi
callq 0x59c0
movq -0x18(%rbp), %rdi
callq 0x2280
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)