// File: /workspace/github_c_makefile_star2_O0/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
subq $0x1a0, %rsp            # imm = 0x1A0
leaq -0x20(%rbp), %rdi
movl $0x4, %esi
callq 0xa2b0
cmpq $0x0, -0x20(%rbp)
jne 0xa955
cmpq $0x0, -0x18(%rbp)
jne 0xa955
cmpq $0x4, -0x10(%rbp)
jne 0xa955
cmpq $0x0, -0x8(%rbp)
je 0xa96f
leaq 0x3b6ad(%rip), %rdi     # 0x46009
movl $0x93, %esi
leaq 0x3b8a9(%rip), %rdx     # 0x46211
movb $0x0, %al
callq 0xe240
movq 0x3ba8e(%rip), %rax     # 0x46404
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x2, %edx
callq 0xa3e0
movq 0x3ba71(%rip), %rax     # 0x46404
movq %rax, -0x30(%rbp)
cmpq $0x2, -0x18(%rbp)
je 0xa9b8
leaq 0x3b664(%rip), %rdi     # 0x46009
movl $0xa5, %esi
leaq 0x3b874(%rip), %rdx     # 0x46225
movb $0x0, %al
callq 0xe240
movl $0x0, -0x34(%rbp)
movslq -0x34(%rbp), %rax
cmpq $0x2, %rax
jae 0xaa0a
movslq -0x34(%rbp), %rax
movl -0x30(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x34(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xa9fd
leaq 0x3b61f(%rip), %rdi     # 0x46009
movl $0xa5, %esi
leaq 0x3b854(%rip), %rdx     # 0x4624a
movb $0x0, %al
callq 0xe240
jmp 0xa9ff
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xa9bf
movq 0x3b9fb(%rip), %rax     # 0x4640c
movq %rax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
movl $0x4, %esi
callq 0xa2b0
leaq -0x3c(%rbp), %rsi
leaq -0x60(%rbp), %rdi
movl $0x2, %edx
callq 0xa3e0
leaq -0x20(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xa5a0
movq 0x3b9f7(%rip), %rax     # 0x46440
movq %rax, -0x70(%rbp)
movq 0x3b9f4(%rip), %rax     # 0x46448
movq %rax, -0x68(%rbp)
cmpq $0x4, -0x18(%rbp)
je 0xaa79
leaq 0x3b5a3(%rip), %rdi     # 0x46009
movl $0xad, %esi
leaq 0x3b7f7(%rip), %rdx     # 0x46269
movb $0x0, %al
callq 0xe240
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
cmpq $0x4, %rax
jae 0xaacb
movslq -0x74(%rbp), %rax
movl -0x70(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x74(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xaabe
leaq 0x3b55e(%rip), %rdi     # 0x46009
movl $0xad, %esi
leaq 0x3b7d8(%rip), %rdx     # 0x4628f
movb $0x0, %al
callq 0xe240
jmp 0xaac0
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xaa80
leaq -0x60(%rbp), %rdi
callq 0xa350
movq 0x3b939(%rip), %rax     # 0x46414
movq %rax, -0x7c(%rbp)
leaq -0x7c(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x2, %edx
movl $0x1, %ecx
callq 0xa660
movq 0x3b953(%rip), %rax     # 0x46450
movq %rax, -0xa0(%rbp)
movq 0x3b94d(%rip), %rax     # 0x46458
movq %rax, -0x98(%rbp)
movq 0x3b947(%rip), %rax     # 0x46460
movq %rax, -0x90(%rbp)
cmpq $0x6, -0x18(%rbp)
je 0xab41
leaq 0x3b4db(%rip), %rdi     # 0x46009
movl $0xb3, %esi
leaq 0x3b775(%rip), %rdx     # 0x462af
movb $0x0, %al
callq 0xe240
movl $0x0, -0xa4(%rbp)
movslq -0xa4(%rbp), %rax
cmpq $0x6, %rax
jae 0xaba8
movslq -0xa4(%rbp), %rax
movl -0xa0(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0xa4(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xab95
leaq 0x3b487(%rip), %rdi     # 0x46009
movl $0xb3, %esi
leaq 0x3b746(%rip), %rdx     # 0x462d4
movb $0x0, %al
callq 0xe240
jmp 0xab97
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0xab4b
movq 0x3b86d(%rip), %rax     # 0x4641c
movq %rax, -0xac(%rbp)
leaq -0xd0(%rbp), %rdi
movl $0x4, %esi
callq 0xa2b0
leaq -0xac(%rbp), %rsi
leaq -0xd0(%rbp), %rdi
movl $0x2, %edx
callq 0xa3e0
leaq -0x20(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movl $0x4, %edx
callq 0xa790
movq 0x3b8d5(%rip), %rax     # 0x464d0
movq %rax, -0xf0(%rbp)
movq 0x3b8cf(%rip), %rax     # 0x464d8
movq %rax, -0xe8(%rbp)
movq 0x3b8c9(%rip), %rax     # 0x464e0
movq %rax, -0xe0(%rbp)
movq 0x3b8c3(%rip), %rax     # 0x464e8
movq %rax, -0xd8(%rbp)
cmpq $0x8, -0x18(%rbp)
je 0xac4d
leaq 0x3b3cf(%rip), %rdi     # 0x46009
movl $0xbb, %esi
leaq 0x3b6ad(%rip), %rdx     # 0x462f3
movb $0x0, %al
callq 0xe240
movl $0x0, -0xf4(%rbp)
movslq -0xf4(%rbp), %rax
cmpq $0x8, %rax
jae 0xacb4
movslq -0xf4(%rbp), %rax
movl -0xf0(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0xf4(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xaca1
leaq 0x3b37b(%rip), %rdi     # 0x46009
movl $0xbb, %esi
leaq 0x3b67f(%rip), %rdx     # 0x46319
movb $0x0, %al
callq 0xe240
jmp 0xaca3
movl -0xf4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf4(%rbp)
jmp 0xac57
leaq -0xd0(%rbp), %rdi
callq 0xa350
movq 0x3b75d(%rip), %rax     # 0x46424
movq %rax, -0xfc(%rbp)
leaq -0xfc(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movl $0x2, %edx
callq 0xa820
leaq -0x130(%rbp), %rdi
leaq 0x3b77f(%rip), %rsi     # 0x46470
movl $0x28, %edx
callq 0xa120
cmpq $0xa, -0x18(%rbp)
je 0xad1c
leaq 0x3b300(%rip), %rdi     # 0x46009
movl $0xc1, %esi
leaq 0x3b624(%rip), %rdx     # 0x46339
movb $0x0, %al
callq 0xe240
movl $0x0, -0x134(%rbp)
movslq -0x134(%rbp), %rax
cmpq $0xa, %rax
jae 0xad83
movslq -0x134(%rbp), %rax
movl -0x130(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x134(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xad70
leaq 0x3b2ac(%rip), %rdi     # 0x46009
movl $0xc1, %esi
leaq 0x3b5f6(%rip), %rdx     # 0x4635f
movb $0x0, %al
callq 0xe240
jmp 0xad72
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0xad26
movq 0x3b6a2(%rip), %rax     # 0x4642c
movq %rax, -0x13c(%rbp)
leaq -0x160(%rbp), %rdi
movl $0x4, %esi
callq 0xa2b0
leaq -0x13c(%rbp), %rsi
leaq -0x160(%rbp), %rdi
movl $0x2, %edx
callq 0xa3e0
leaq -0x20(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0xa8a0
leaq -0x190(%rbp), %rdi
leaq 0x3b6c8(%rip), %rsi     # 0x464a0
movl $0x30, %edx
callq 0xa120
cmpq $0xc, -0x18(%rbp)
je 0xae03
leaq 0x3b219(%rip), %rdi     # 0x46009
movl $0xc9, %esi
leaq 0x3b583(%rip), %rdx     # 0x4637f
movb $0x0, %al
callq 0xe240
movl $0x0, -0x194(%rbp)
movslq -0x194(%rbp), %rax
cmpq $0xc, %rax
jae 0xae6a
movslq -0x194(%rbp), %rax
movl -0x190(%rbp,%rax,4), %eax
movq -0x8(%rbp), %rcx
movslq -0x194(%rbp), %rdx
imulq -0x10(%rbp), %rdx
cmpl (%rcx,%rdx), %eax
je 0xae57
leaq 0x3b1c5(%rip), %rdi     # 0x46009
movl $0xc9, %esi
leaq 0x3b556(%rip), %rdx     # 0x463a6
movb $0x0, %al
callq 0xe240
jmp 0xae59
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
jmp 0xae0d
leaq -0x160(%rbp), %rdi
callq 0xa350
leaq -0x20(%rbp), %rdi
callq 0xa350
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nopl (%rax,%rax)