// File: /workspace/github_cpp_makefile_star2_O3/t0mm4rx[P]piscine_cpp/day07/ex02/main.cpp
// Function: main
int main(void)
{
	std::cout << "Test copy with int array." << std::endl;
	Array<int> *arr = new Array<int>(5);
	for (unsigned int i = 0; i < arr->size(); i++)
		(*arr)[i] = i * 2;
	Array<int> copy = *arr;
	(*arr)[0] = 42;
	(*arr)[1] = -54;
	std::cout << "Length: " << copy.size() << std::endl;
	for (unsigned int i = 0; i < copy.size(); i++)
		std::cout << copy[i] << std::endl;
	delete arr;
	std::cout << "Test initializing int array." << std::endl;
	Array<int> *arr2 = new Array<int>(5);
	std::cout << "Length: " << arr2->size() << std::endl;
	for (unsigned int i = 0; i < arr2->size(); i++)
		std::cout << (*arr2)[i] << std::endl;
	try
	{
		std::cout << (*arr2)[5] << std::endl;
	}
	catch (std::exception &e)
	{
		std::cout << "Exception while reading arr2[5]." << std::endl;
	}
	delete arr2;
	std::cout << "Test empty array." << std::endl;
	Array<std::string> *arr3 = new Array<std::string>();
	std::cout << "Length: " << arr3->size() << std::endl;
	try
	{
		std::cout << (*arr3)[4] << std::endl;
	}
	catch (std::exception &e)
	{
		std::cout << "Exception while reading arr3[4]." << std::endl;
	}
	try
	{
		std::cout << (*arr3)[-1] << std::endl;
	}
	catch (std::exception &e)
	{
		std::cout << "Exception while reading arr3[-1]." << std::endl;
	}
	delete arr3;
	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x2d04(%rip), %rbx      # 0x3fc8
leaq 0xd39(%rip), %rsi       # 0x2004
movl $0x19, %edx
movq %rbx, %rdi
callq 0x10f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
movl $0x10, %edi
callq 0x10d0
movq %rax, %rbx
movl $0x14, %edi
callq 0x1030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
movq %rax, (%rbx)
movl $0x5, 0x8(%rbx)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1870
movl %r15d, (%rax)
incl %r14d
addl $0x2, %r15d
cmpl 0x8(%rbx), %r14d
jb 0x1333
leaq -0x38(%rbp), %rdi
movq $0x0, (%rdi)
movl $0x0, 0x8(%rdi)
movq %rbx, %rsi
callq 0x1984
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1870
movl $0x2a, (%rax)
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1870
movl $0xffffffca, (%rax)     # imm = 0xFFFFFFCA
movq 0x2c36(%rip), %rdi      # 0x3fc8
leaq 0xc85(%rip), %rsi       # 0x201e
movl $0x8, %edx
callq 0x10f0
movl -0x30(%rbp), %esi
movq 0x2c1b(%rip), %rdi      # 0x3fc8
callq 0x1090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
cmpl $0x0, -0x30(%rbp)
jne 0x1519
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x13f3
callq 0x1100
movl $0x10, %esi
movq %rbx, %rdi
callq 0x10e0
movq 0x2bc1(%rip), %rbx      # 0x3fc8
leaq 0xc19(%rip), %rsi       # 0x2027
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x10f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq 0x2b8f(%rip), %rdi      # 0x3fc8
callq 0x1040
movq %rax, %rdi
callq 0x10a0
movl $0x10, %edi
callq 0x10d0
movq %rax, %rbx
movl $0x14, %edi
callq 0x1030
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
movq %rax, (%rbx)
movl $0x5, 0x8(%rbx)
movq 0x2b4d(%rip), %rdi      # 0x3fc8
leaq 0xb9c(%rip), %rsi       # 0x201e
movl $0x8, %edx
callq 0x10f0
movl 0x8(%rbx), %esi
movq 0x2b32(%rip), %rdi      # 0x3fc8
callq 0x1090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
cmpl $0x0, 0x8(%rbx)
jne 0x1574
movq %rbx, %rdi
movl $0x5, %esi
callq 0x1870
movl (%rax), %esi
movq 0x2ae3(%rip), %rdi      # 0x3fc8
callq 0x1140
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
jmp 0x160d
xorl %r14d, %r14d
leaq -0x38(%rbp), %r15
movq 0x2aa1(%rip), %r12      # 0x3fc8
movq %r15, %rdi
movl %r14d, %esi
callq 0x1870
movl (%rax), %esi
movq %r12, %rdi
callq 0x1140
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r13, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
incl %r14d
cmpl -0x30(%rbp), %r14d
jb 0x1527
jmp 0x13e6
xorl %r14d, %r14d
movq 0x2a4a(%rip), %r15      # 0x3fc8
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1870
movl (%rax), %esi
movq %r15, %rdi
callq 0x1140
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r12, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
incl %r14d
cmpl 0x8(%rbx), %r14d
jb 0x157e
jmp 0x14cf
jmp 0x1844
movq %rax, %r14
cmpl $0x1, %edx
jne 0x1847
movq %r14, %rdi
callq 0x1060
movq 0x29dd(%rip), %rdi      # 0x3fc8
leaq 0xa52(%rip), %rsi       # 0x2044
movl $0x20, %edx
callq 0x10f0
movq 0x29c5(%rip), %rdi      # 0x3fc8
callq 0x1070
callq 0x1120
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x161a
callq 0x1100
movl $0x10, %esi
movq %rbx, %rdi
callq 0x10e0
movq 0x299a(%rip), %rbx      # 0x3fc8
leaq 0xa30(%rip), %rsi       # 0x2065
movl $0x11, %edx
movq %rbx, %rdi
callq 0x10f0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq 0x2968(%rip), %rdi      # 0x3fc8
callq 0x1040
movq %rax, %rdi
callq 0x10a0
movl $0x10, %edi
callq 0x10d0
movq %rax, %rbx
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq 0x2939(%rip), %rdi      # 0x3fc8
leaq 0x988(%rip), %rsi       # 0x201e
movl $0x8, %edx
callq 0x10f0
movq 0x2921(%rip), %rdi      # 0x3fc8
xorl %esi, %esi
callq 0x1090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
movq %rbx, %rdi
movl $0x4, %esi
callq 0x18c8
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x28d5(%rip), %rdi      # 0x3fc8
callq 0x10f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %rdi
callq 0x10a0
jmp 0x1761
movq %rax, %r14
cmpl $0x1, %edx
jne 0x1847
movq %r14, %rdi
callq 0x1060
movq 0x2889(%rip), %rdi      # 0x3fc8
leaq 0x931(%rip), %rsi       # 0x2077
movl $0x20, %edx
callq 0x10f0
movq 0x2871(%rip), %rdi      # 0x3fc8
callq 0x1070
callq 0x1120
movl $0x8, %edi
callq 0x1080
movq 0x284e(%rip), %rcx      # 0x3fc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x2858(%rip), %rsi      # 0x3fd8
movq 0x2869(%rip), %rdx      # 0x3ff0
movq %rax, %rdi
callq 0x1130
movq %rax, %r14
cmpl $0x1, %edx
jne 0x1847
movq %r14, %rdi
callq 0x1060
movq 0x281e(%rip), %rdi      # 0x3fc8
leaq 0x8e7(%rip), %rsi       # 0x2098
movl $0x21, %edx
callq 0x10f0
movq 0x2806(%rip), %rdi      # 0x3fc8
callq 0x1070
callq 0x1120
movq %rbx, %rdi
callq 0x1916
movl $0x10, %esi
movq %rbx, %rdi
callq 0x10e0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x17ef
callq 0x1100
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1844
movq %rax, %r14
callq 0x1120
jmp 0x1847
jmp 0x1844
movq %rax, %r14
callq 0x1120
jmp 0x1847
jmp 0x1844
jmp 0x1844
movq %rax, %r14
callq 0x1120
jmp 0x1847
movq %rax, %rdi
callq 0x18ba
movq %rax, %r14
movl $0x10, %esi
movq %rbx, %rdi
callq 0x10e0
jmp 0x1847
jmp 0x1844
jmp 0x1844
movq %rax, %r14
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x1867
callq 0x1100
jmp 0x1867
movq %rax, %r14
movl $0x10, %esi
movq %rbx, %rdi
callq 0x10e0
movq %r14, %rdi
callq 0x1150
nop