// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rbx
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movups %xmm0, -0x54(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movq 0x2d3e(%rip), %r14      # 0x3fe0
leaq -0x44(%rbp), %r15
movl $0xcccccccd, %r12d      # imm = 0xCCCCCCCD
movq %r14, %rdi
movq %r15, %rsi
callq 0x1100
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1301
movl -0x44(%rbp), %eax
cmpl $0x64, %eax
ja 0x12de
movl %eax, %ecx
imulq %r12, %rcx
shrq $0x21, %rcx
andl $-0x4, %ecx
incl -0x70(%rbp,%rcx)
movq -0x38(%rbp), %rsi
cmpq -0x30(%rbp), %rsi
je 0x12f4
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x38(%rbp)
jmp 0x12ac
movq %rbx, %rdi
movq %r15, %rdx
callq 0x1478
jmp 0x12ac
movq 0x2cc8(%rip), %rdi      # 0x3fd0
leaq 0xcf5(%rip), %rsi       # 0x2004
movl $0xe, %edx
callq 0x10d0
movq -0x38(%rbp), %rsi
subq -0x40(%rbp), %rsi
sarq $0x2, %rsi
movq 0x2ca4(%rip), %rbx      # 0x3fd0
movq %rbx, %rdi
callq 0x1060
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1070
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %r13
cmpq %r13, %r12
je 0x139e
movq 0x2c5e(%rip), %r14      # 0x3fd0
leaq 0xc98(%rip), %r15       # 0x2011
movl (%r12), %esi
movq %r14, %rdi
callq 0x1060
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x10d0
addq $0x4, %r12
cmpq %r13, %r12
jne 0x1379
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10a0
movsbl %al, %esi
movq 0x2c14(%rip), %rdi      # 0x3fd0
callq 0x1030
movq %rax, %rdi
callq 0x1070
xorl %r15d, %r15d
movq 0x2bfd(%rip), %rbx      # 0x3fd0
leaq 0xc37(%rip), %r14       # 0x2011
movl -0x70(%rbp,%r15), %esi
movq %rbx, %rdi
callq 0x1060
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x10d0
addq $0x4, %r15
cmpq $0x2c, %r15
jne 0x13da
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10a0
movsbl %al, %esi
movq 0x2bb1(%rip), %rdi      # 0x3fd0
callq 0x1030
movq %rax, %rdi
callq 0x1070
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1441
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1458
jmp 0x1458
jmp 0x1458
movq %rax, %rbx
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x1470
movq -0x30(%rbp), %rsi
subq %rdi, %rsi
callq 0x10c0
movq %rbx, %rdi
callq 0x1110