// File: iZhangHui[P]CppPrimer/CH03_StringsVectorsAndArrays/examples/arrayScores.cc
// Function: main
int main ()
{
	vector<unsigned> grades;
	// count the number of grades by clusters of ten: 
	// 0--9, 10--19, . . . 90--99, 100
	unsigned scores[11] = {};  // 11 buckets, all value initialized to 0
	unsigned grade;
	while (cin >> grade) {
		if (grade <= 100)
			// increment the counter for the current cluster
			++scores[grade/10]; 
		grades.push_back(grade);
	}
	cout << "grades.size = " << grades.size() << endl;

	for (auto g : grades)  // for every element in grades
		cout << g << " " ;
	cout << endl;

	for (auto i : scores)       // for each counter in scores
		cout << i << " ";       // print the value of that counter
	cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl $0x0, -0x4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1500
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movl $0x2c, %edx
callq 0x1090
movq 0x3d1e(%rip), %rdi      # 0x4fe0
leaq -0x54(%rbp), %rsi
callq 0x1030
movq %rax, -0xb0(%rbp)
jmp 0x12d4
movq -0xb0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x1100
movb %al, -0xb1(%rbp)
jmp 0x12f2
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x12fe
jmp 0x134d
cmpl $0x64, -0x54(%rbp)
ja 0x1339
movl -0x54(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %eax
movl -0x50(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x50(%rbp,%rax,4)
jmp 0x1339
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x1690
jmp 0x14f1
leaq -0x20(%rbp), %rdi
leaq -0x54(%rbp), %rsi
callq 0x1520
jmp 0x1348
jmp 0x12bb
movq 0x3c7c(%rip), %rdi      # 0x4fd0
leaq 0x1ca9(%rip), %rsi      # 0x3004
callq 0x10c0
movq %rax, -0xc0(%rbp)
jmp 0x1369
leaq -0x20(%rbp), %rdi
callq 0x1590
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
callq 0x1040
movq %rax, -0xc8(%rbp)
jmp 0x138a
movq -0xc8(%rbp), %rdi
movq 0x3c28(%rip), %rsi      # 0x4fc0
callq 0x10f0
jmp 0x139f
leaq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x15b0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x15e0
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1610
testb $0x1, %al
jne 0x13d4
jmp 0x1422
leaq -0x78(%rbp), %rdi
callq 0x1650
movl (%rax), %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %esi
movq 0x3bde(%rip), %rdi      # 0x4fd0
callq 0x1110
movq %rax, -0xd0(%rbp)
jmp 0x1400
movq -0xd0(%rbp), %rdi
leaq 0x1c03(%rip), %rsi      # 0x3011
callq 0x10c0
jmp 0x1415
jmp 0x1417
leaq -0x78(%rbp), %rdi
callq 0x1670
jmp 0x13c1
movq 0x3ba7(%rip), %rdi      # 0x4fd0
movq 0x3b90(%rip), %rsi      # 0x4fc0
callq 0x10f0
jmp 0x1437
leaq -0x50(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x90(%rbp), %rax
addq $0x2c, %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
cmpq -0xa0(%rbp), %rax
je 0x14c7
movq -0x98(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %esi
movq 0x3b42(%rip), %rdi      # 0x4fd0
callq 0x1110
movq %rax, -0xd8(%rbp)
jmp 0x149c
movq -0xd8(%rbp), %rdi
leaq 0x1b67(%rip), %rsi      # 0x3011
callq 0x10c0
jmp 0x14b1
jmp 0x14b3
movq -0x98(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x98(%rbp)
jmp 0x1462
movq 0x3b02(%rip), %rdi      # 0x4fd0
movq 0x3aeb(%rip), %rsi      # 0x4fc0
callq 0x10f0
jmp 0x14dc
leaq -0x20(%rbp), %rdi
callq 0x1690
movl -0x4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x1140
nopw (%rax,%rax)