// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH05_Statements/examples/ifgrades.cc
// Function: main
int main()
{
	// read a set of scores from the input
	unsigned grade;
	while (cin >> grade) 
		grades.push_back(grade);

	// now process those grades
	for (auto it : grades) {   // for each grade we read
		cout << it << " " ;    // print the grade
		string lettergrade;    // hold coresponding letter grade
		// if failing grade, no need to check for a plus or minus
		if (it < 60)
			lettergrade = scores[0];
		else {
			lettergrade = scores[(it - 50)/10];  // fetch the letter grade
			if (it != 100)  // add plus or minus only if not already an A++
				if (it % 10 > 7)
					lettergrade += '+';   // grades ending in 8 or 9 get a +
				else if (it % 10 < 3)
					lettergrade += '-';   // grades ending in 0, 1, or 2 get a -
		}
		cout << lettergrade << endl;
		if (it > 59 && it !=100) {
			cout << "alternative versions: " << it << " ";
			// start over with just the basic grade, no + or -
			lettergrade = scores[(it - 50)/10];
			cout << goodVers(lettergrade, it) << " ";
			cout << badVers(lettergrade, it) << " ";
			cout << rightVers(lettergrade, it) << " ";
			cout << endl;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq 0x29c6(%rip), %rdi      # 0x3fe0
leaq -0x4c(%rbp), %rsi
callq 0x1180
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1689
leaq 0x2ae0(%rip), %rbx      # 0x4118
leaq -0x4c(%rbp), %r14
movq 0x299d(%rip), %r15      # 0x3fe0
movq 0x2ad6(%rip), %rsi      # 0x4120
cmpq 0x2ad7(%rip), %rsi      # 0x4128
je 0x1665
movl -0x4c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x2abd(%rip)      # 0x4120
jmp 0x1670
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1dd4
movq %r15, %rdi
movq %r14, %rsi
callq 0x1180
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x1643
movq 0x2a88(%rip), %r15      # 0x4118
movq 0x2a89(%rip), %rax      # 0x4120
movq %rax, -0xd8(%rbp)
cmpq %rax, %r15
je 0x1a00
movq 0x2922(%rip), %rbx      # 0x3fd0
leaq 0x968(%rip), %r14       # 0x201d
movl (%r15), %r13d
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1090
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1130
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
cmpq $0x3b, %r13
ja 0x16ff
movq 0x2a0c(%rip), %rsi      # 0x4100
leaq -0x70(%rbp), %rdi
callq 0x1080
jmp 0x175e
leal -0x32(%r13), %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x1e, %rsi
andq $-0x20, %rsi
addq 0x29e5(%rip), %rsi      # 0x4100
leaq -0x70(%rbp), %rdi
callq 0x1080
cmpl $0x64, %r13d
je 0x175e
movq %r13, %rax
movl $0xcccccccd, %ecx       # imm = 0xCCCCCCCD
imulq %rcx, %rax
shrq $0x23, %rax
addl %eax, %eax
leal (%rax,%rax,4), %eax
movl %r13d, %ecx
subl %eax, %ecx
movb $0x2b, %al
cmpl $0x7, %ecx
ja 0x1752
movb $0x2d, %al
cmpl $0x2, %ecx
ja 0x175e
movzbl %al, %esi
leaq -0x70(%rbp), %rdi
callq 0x10e0
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %rbx, %rdi
callq 0x1130
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x1100
movsbl %al, %esi
movq %r12, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
cmpl $0x3c, %r13d
setb %al
cmpq $0x64, %r13
sete %cl
orb %al, %cl
jne 0x19d6
movl $0x16, %edx
movq %rbx, %rdi
leaq 0x84b(%rip), %rsi       # 0x2008
callq 0x1130
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1090
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1130
leal -0x32(%r13), %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x1e, %rsi
andq $-0x20, %rsi
addq 0x2907(%rip), %rsi      # 0x4100
leaq -0x70(%rbp), %rdi
callq 0x1080
leaq -0xc0(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
callq 0x1be6
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x147c
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1130
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1872
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x1894
movq -0xc0(%rbp), %rsi
incq %rsi
callq 0x1120
leaq -0xa0(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
callq 0x1be6
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x14fc
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1130
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1904
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x1926
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x1120
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %r12
movq %r12, %rdi
callq 0x1be6
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
movl %r13d, %edx
callq 0x157f
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x1130
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x1130
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1993
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x19af
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x1120
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1100
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x10a0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x19ef
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1120
addq $0x4, %r15
cmpq -0xd8(%rbp), %r15
jne 0x16b5
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x1a87
movq %rax, %rbx
jmp 0x1abf
movq %rax, %rbx
jmp 0x1a51
jmp 0x1ae3
jmp 0x1ae3
jmp 0x1ae3
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1a51
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x1ae6
movq -0x80(%rbp), %rsi
jmp 0x1ad9
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1a87
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x1ae6
movq -0xc0(%rbp), %rsi
jmp 0x1ad9
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x1abf
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1120
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x1ae6
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x1120
jmp 0x1ae6
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x1aff
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x1120
movq %rbx, %rdi
callq 0x1190
nop