// File: /workspace/github_c_makefile_star2_O1/Ihsoh[P]ilang/array.c
// Function: rarr_test
void rarr_test(void) {
	ResizableArray rarr1;

	rarr_init(&rarr1, sizeof(int));
	MYASSERT(
		rarr1.size == 0 && rarr1.len == 0 && rarr1.item_size == sizeof(int) && rarr1.buffer == NULL,
		"TEST rarr_init(...)"
	);

	#define	__CMP_RARR_ARR(rarr, arr, msg)	{	\
		int __temp[] = arr;	\
		if ((rarr)->len != sizeof(__temp) / sizeof(int)) {	\
			MYASSERT(0, (msg "xxxxxx"));	\
		}	\
		for (int __i = 0; __i < sizeof(__temp) / sizeof(int); __i++) {	\
			if (__temp[__i] != RARR_ELEMENT((rarr), __i, int)) {	\
				MYASSERT(0, (msg));	\
			}	\
		}	\
	}
	#define	__C	,

	// [] + [1, 2] => [1, 2]
	int arr1[] = {1, 2};
	rarr_append_with_raw(&rarr1, arr1, sizeof(arr1) / sizeof(int));
	__CMP_RARR_ARR(&rarr1, {1 __C 2}, "TEST rarr_append_with_raw(...)");

	// [1, 2] + [3, 4] => [1, 2, 3, 4]
	int arr2[] = {3, 4};
	ResizableArray rarr2;
	rarr_init(&rarr2, sizeof(int));
	rarr_append_with_raw(&rarr2, arr2, sizeof(arr2) / sizeof(int));
	rarr_append_with_rarr(&rarr1, &rarr2);
	__CMP_RARR_ARR(&rarr1, {1 __C 2 __C 3 __C 4}, "TEST rarr_append_with_rarr(...)");
	rarr_free(&rarr2);

	// INSERT([1, 2, 3, 4], 1, [10, 20]) => [1, 10, 20, 2, 3, 4]
	int arr3[] = {10, 20};
	rarr_insert_with_raw(&rarr1, arr3, sizeof(arr3) / sizeof(int), 1);
	__CMP_RARR_ARR(&rarr1, {1 __C 10 __C 20 __C 2 __C 3 __C 4}, "TEST rarr_insert_with_raw(...)");

	// INSERT([1, 10, 20, 2, 3, 4], 4, [20, 30]) => [1, 10, 20, 2, 20, 30, 3, 4]
	int arr4[] = {20, 30};
	ResizableArray rarr3;
	rarr_init(&rarr3, sizeof(int));
	rarr_append_with_raw(&rarr3, arr4, sizeof(arr4) / sizeof(int));
	rarr_insert_with_rarr(&rarr1, &rarr3, 4);
	__CMP_RARR_ARR(&rarr1, {1 __C 10 __C 20 __C 2 __C 20 __C 30 __C 3 __C 4}, "TEST rarr_insert_with_rarr(...)");
	rarr_free(&rarr3);

	// [100, 200] + [1, 10, 20, 2, 20, 30, 3, 4] => [100, 200, 1, 10, 20, 2, 20, 30, 3, 4]
	int arr5[] = {100, 200};
	rarr_prepend_with_raw(&rarr1, arr5, sizeof(arr5) / sizeof(int));
	__CMP_RARR_ARR(&rarr1, {100 __C 200 __C 1 __C 10 __C 20 __C 2 __C 20 __C 30 __C 3 __C 4}, "TEST rarr_prepend_with_raw(...)");

	// [300, 400] + [100, 200, 1, 10, 20, 2, 20, 30, 3, 4] => [300, 400, 100, 200, 1, 10, 20, 2, 20, 30, 3, 4]
	int arr6[] = {300, 400};
	ResizableArray rarr4;
	rarr_init(&rarr4, sizeof(int));
	rarr_append_with_raw(&rarr4, arr6, sizeof(arr6) / sizeof(int));
	rarr_prepend_with_rarr(&rarr1, &rarr4);
	__CMP_RARR_ARR(&rarr1, {300 __C 400 __C 100 __C 200 __C 1 __C 10 __C 20 __C 2 __C 20 __C 30 __C 3 __C 4}, "TEST rarr_prepend_with_rarr(...)");
	rarr_free(&rarr4);

	rarr_free(&rarr1);

	#undef	__CMP_RARR_ARR
	#undef	__COMMA
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xb0, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movq $0x4, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xa773
leaq 0x238a9(%rip), %rdi     # 0x2e009
leaq 0x23aaa(%rip), %rdx     # 0x2e211
movl $0x93, %esi
xorl %eax, %eax
callq 0xd08c
movabsq $0x200000001, %rax      # imm = 0x200000001
leaq -0xd0(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x40(%rbp), %rbx
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa3e8
cmpq $0x2, 0x8(%rbx)
je 0xa7b9
leaq 0x23863(%rip), %rdi     # 0x2e009
leaq 0x23a78(%rip), %rdx     # 0x2e225
movl $0xa5, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x23c08(%rip), %r15     # 0x2e3c8
leaq 0x23842(%rip), %rbx     # 0x2e009
leaq 0x23a7c(%rip), %r14     # 0x2e24a
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xa7f7
movq %rbx, %rdi
movl $0xa5, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0x1, %r12
je 0xa7d1
movabsq $0x400000003, %rax      # imm = 0x400000003
leaq -0xc8(%rbp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rbx
movaps %xmm0, (%rbx)
movq $0x4, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa3e8
leaq -0x40(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xa4c4
cmpq $0x4, 0x8(%r14)
je 0xa872
leaq 0x237aa(%rip), %rdi     # 0x2e009
leaq 0x23a03(%rip), %rdx     # 0x2e269
movl $0xad, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x23b57(%rip), %r15     # 0x2e3d0
leaq 0x23789(%rip), %rbx     # 0x2e009
leaq 0x23a08(%rip), %r14     # 0x2e28f
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xa8b0
movq %rbx, %rdi
movl $0xad, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0x4, %r12
jne 0xa88a
movq -0x88(%rbp), %rdi
testq %rdi, %rdi
je 0xa8ce
callq 0xa190
xorps %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movabsq $0x140000000a, %rax     # imm = 0x140000000A
leaq -0xc0(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x40(%rbp), %rbx
movl $0x2, %edx
movl $0x1, %ecx
movq %rbx, %rdi
callq 0xa547
cmpq $0x6, 0x8(%rbx)
je 0xa92a
leaq 0x236f2(%rip), %rdi     # 0x2e009
leaq 0x23991(%rip), %rdx     # 0x2e2af
movl $0xb3, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x23aaf(%rip), %r15     # 0x2e3e0
leaq 0x236d1(%rip), %rbx     # 0x2e009
leaq 0x23995(%rip), %r14     # 0x2e2d4
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xa968
movq %rbx, %rdi
movl $0xb3, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0x6, %r12
jne 0xa942
movabsq $0x1e00000014, %rax     # imm = 0x1E00000014
leaq -0xb8(%rbp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
leaq -0x80(%rbp), %rbx
movaps %xmm0, (%rbx)
movq $0x4, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa3e8
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %rsi
leaq -0x40(%rbp), %rbx
movl $0x4, %ecx
movq %rbx, %rdi
callq 0xa547
cmpq $0x8, 0x8(%rbx)
je 0xa9ea
leaq 0x23632(%rip), %rdi     # 0x2e009
leaq 0x23915(%rip), %rdx     # 0x2e2f3
movl $0xbb, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x23a6f(%rip), %r15     # 0x2e460
leaq 0x23611(%rip), %rbx     # 0x2e009
leaq 0x2391a(%rip), %r14     # 0x2e319
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xaa28
movq %rbx, %rdi
movl $0xbb, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0x8, %r12
jne 0xaa02
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0xaa43
callq 0xa190
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movabsq $0xc800000064, %rax     # imm = 0xC800000064
leaq -0xb0(%rbp), %rsi
movq %rax, (%rsi)
leaq -0x40(%rbp), %rbx
movl $0x2, %edx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0xa547
cmpq $0xa, 0x8(%rbx)
je 0xaa96
leaq 0x23586(%rip), %rdi     # 0x2e009
leaq 0x238af(%rip), %rdx     # 0x2e339
movl $0xc1, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x23963(%rip), %r15     # 0x2e400
leaq 0x23565(%rip), %rbx     # 0x2e009
leaq 0x238b4(%rip), %r14     # 0x2e35f
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xaad4
movq %rbx, %rdi
movl $0xc1, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0xa, %r12
jne 0xaaae
movabsq $0x1900000012c, %rax    # imm = 0x1900000012C
leaq -0xa8(%rbp), %rsi
movq %rax, (%rsi)
xorps %xmm0, %xmm0
leaq -0x60(%rbp), %rbx
movaps %xmm0, (%rbx)
movq $0x4, 0x10(%rbx)
movq $0x0, 0x18(%rbx)
movl $0x2, %edx
movq %rbx, %rdi
callq 0xa3e8
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %rsi
leaq -0x40(%rbp), %rbx
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0xa547
cmpq $0xc, 0x8(%rbx)
je 0xab53
leaq 0x234c9(%rip), %rdi     # 0x2e009
leaq 0x23838(%rip), %rdx     # 0x2e37f
movl $0xc9, %esi
xorl %eax, %eax
callq 0xd08c
leaq 0x238d6(%rip), %r15     # 0x2e430
leaq 0x234a8(%rip), %rbx     # 0x2e009
leaq 0x2383e(%rip), %r14     # 0x2e3a6
xorl %r12d, %r12d
movl (%r15), %eax
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
imulq %r12, %rdx
cmpl (%rcx,%rdx), %eax
je 0xab91
movq %rbx, %rdi
movl $0xc9, %esi
movq %r14, %rdx
xorl %eax, %eax
callq 0xd08c
incq %r12
addq $0x4, %r15
cmpq $0xc, %r12
jne 0xab6b
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0xabac
callq 0xa190
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0xabc5
callq 0xa190
addq $0xb0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)