// File: MingYueRuYa[P]cprimeprimecode/memory_manager.cpp
// Function: demo05::test_per_class_allocator_2()
void test_per_class_allocator_2()
{
	cout << "\ntest_per_class_allocator_2\n";

	cout << sizeof(AirPlane) << endl;	//8

	size_t const N = 100;
	AirPlane *p[N];

	for (size_t i=0; i<N; ++i) {
		p[i] = new AirPlane();
	}

	//随机测试object是否正常
	p[1]->set(100, 'A');
	p[5]->set(10000, 'B');
	p[9]->set(1000000, 'C');

	cout << p[1] << ' ' << p[1]->getType() << ' ' << p[1]->getMiles() << endl;
	cout << p[5] << ' ' << p[5]->getType() << ' ' << p[5]->getMiles() << endl;
	cout << p[9] << ' ' << p[9]->getType() << ' ' << p[9]->getMiles() << endl;
	//result:
		//	0x85dc010 A 100
		//	0x85dc030 B 10000
		//	0x85dc050 C 1000000

	//输出前10个pointers，用以比较其间隔
	for (size_t i=0; i<10; ++i) {
		cout << p[i] << endl;
	}
	//result:	间隔为8，中间没有cookie
		//	0x85dc008
		//	0x85dc010
		//	0x85dc018
		//	0x85dc020
		//	0x85dc028
		//	0x85dc030
		//	0x85dc038
		//	0x85dc040
		//	0x85dc048
		//	0x85dc050

	for (size_t i=0; i<N; ++i) {
		delete p[i];
	}

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq 0x5fc6(%rip), %rdi      # 0x8fd8
leaq 0x30c6(%rip), %rsi      # 0x60df
callq 0x2190
movq 0x5fb3(%rip), %rdi      # 0x8fd8
movl $0x10, %esi
callq 0x2050
movq %rax, %rdi
movq 0x5f7f(%rip), %rsi      # 0x8fb8
callq 0x21c0
movq $0x64, -0x8(%rbp)
movq $0x0, -0x338(%rbp)
cmpq $0x64, -0x338(%rbp)
jae 0x30a5
movl $0x10, %edi
callq 0x2ec0
movq %rax, %rdi
movq %rdi, -0x350(%rbp)
xorl %esi, %esi
movl $0x10, %edx
callq 0x20b0
movq -0x350(%rbp), %rcx
movq -0x338(%rbp), %rax
movq %rcx, -0x330(%rbp,%rax,8)
movq -0x338(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x338(%rbp)
jmp 0x3051
movq -0x328(%rbp), %rdi
movl $0x64, %esi
movl $0x41, %edx
callq 0x4530
movq -0x308(%rbp), %rdi
movl $0x2710, %esi           # imm = 0x2710
movl $0x42, %edx
callq 0x4530
movq -0x2e8(%rbp), %rdi
movl $0xf4240, %esi          # imm = 0xF4240
movl $0x43, %edx
callq 0x4530
movq -0x328(%rbp), %rsi
movq 0x5ee3(%rip), %rdi      # 0x8fd8
callq 0x2130
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x380(%rbp)
movq -0x328(%rbp), %rdi
callq 0x4560
movq -0x380(%rbp), %rdi
movsbl %al, %esi
callq 0x2210
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x378(%rbp)
movq -0x328(%rbp), %rdi
callq 0x4580
movq -0x378(%rbp), %rdi
movq %rax, %rsi
callq 0x2050
movq %rax, %rdi
movq 0x5e56(%rip), %rsi      # 0x8fb8
callq 0x21c0
movq -0x308(%rbp), %rsi
movq 0x5e63(%rip), %rdi      # 0x8fd8
callq 0x2130
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x370(%rbp)
movq -0x308(%rbp), %rdi
callq 0x4560
movq -0x370(%rbp), %rdi
movsbl %al, %esi
callq 0x2210
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x368(%rbp)
movq -0x308(%rbp), %rdi
callq 0x4580
movq -0x368(%rbp), %rdi
movq %rax, %rsi
callq 0x2050
movq %rax, %rdi
movq 0x5dd6(%rip), %rsi      # 0x8fb8
callq 0x21c0
movq -0x2e8(%rbp), %rsi
movq 0x5de3(%rip), %rdi      # 0x8fd8
callq 0x2130
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x360(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x4560
movq -0x360(%rbp), %rdi
movsbl %al, %esi
callq 0x2210
movq %rax, %rdi
movl $0x20, %esi
callq 0x2210
movq %rax, -0x358(%rbp)
movq -0x2e8(%rbp), %rdi
callq 0x4580
movq -0x358(%rbp), %rdi
movq %rax, %rsi
callq 0x2050
movq %rax, %rdi
movq 0x5d56(%rip), %rsi      # 0x8fb8
callq 0x21c0
movq $0x0, -0x340(%rbp)
cmpq $0xa, -0x340(%rbp)
jae 0x32ba
movq -0x340(%rbp), %rax
movq -0x330(%rbp,%rax,8), %rsi
movq 0x5d46(%rip), %rdi      # 0x8fd8
callq 0x2130
movq %rax, %rdi
movq 0x5d17(%rip), %rsi      # 0x8fb8
callq 0x21c0
movq -0x340(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x340(%rbp)
jmp 0x3272
movq $0x0, -0x348(%rbp)
cmpq $0x64, -0x348(%rbp)
jae 0x3312
movq -0x348(%rbp), %rax
movq -0x330(%rbp,%rax,8), %rax
movq %rax, -0x388(%rbp)
cmpq $0x0, %rax
je 0x32fc
movq -0x388(%rbp), %rdi
movl $0x10, %esi
callq 0x2fa0
jmp 0x32fe
movq -0x348(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x348(%rbp)
jmp 0x32c5
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
nopl (%rax,%rax)