// File: 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
subq $0x150, %rsp            # imm = 0x150
movl $0x0, -0x4(%rbp)
movq 0x5687(%rip), %rdi      # 0x7fe0
leaq -0x8(%rbp), %rsi
callq 0x2040
movq %rax, %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x2150
testb $0x1, %al
jne 0x2977
jmp 0x2989
leaq 0x57ba(%rip), %rdi      # 0x8138
leaq -0x8(%rbp), %rsi
callq 0x2f50
jmp 0x2952
leaq 0x57a8(%rip), %rax      # 0x8138
movq %rax, -0x10(%rbp)
leaq 0x579d(%rip), %rdi      # 0x8138
callq 0x2fc0
movq %rax, -0x18(%rbp)
leaq 0x578d(%rip), %rdi      # 0x8138
callq 0x2ff0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x3020
testb $0x1, %al
jne 0x29ca
jmp 0x2d99
leaq -0x18(%rbp), %rdi
callq 0x3060
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
movq 0x55ee(%rip), %rdi      # 0x7fd0
callq 0x2160
movq %rax, %rdi
leaq 0x2636(%rip), %rsi      # 0x5027
callq 0x2100
leaq -0x48(%rbp), %rdi
callq 0x2180
cmpl $0x3c, -0x24(%rbp)
jae 0x2a39
leaq 0x5714(%rip), %rdi      # 0x8120
xorl %eax, %eax
movl %eax, %esi
callq 0x3080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2030
jmp 0x2a23
jmp 0x2aba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2d8e
movl -0x24(%rbp), %eax
addl $-0x32, %eax
movl %eax, %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x23, %rsi
leaq 0x56cb(%rip), %rdi      # 0x8120
callq 0x3080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2030
jmp 0x2a68
cmpl $0x64, -0x24(%rbp)
je 0x2ab8
movl -0x24(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x7, %edx
jbe 0x2a91
leaq -0x48(%rbp), %rdi
movl $0x2b, %esi
callq 0x20c0
jmp 0x2a8f
jmp 0x2ab6
movl -0x24(%rbp), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
cmpl $0x3, %edx
jae 0x2ab4
leaq -0x48(%rbp), %rdi
movl $0x2d, %esi
callq 0x20c0
jmp 0x2ab2
jmp 0x2ab4
jmp 0x2ab6
jmp 0x2ab8
jmp 0x2aba
movq 0x550f(%rip), %rdi      # 0x7fd0
leaq -0x48(%rbp), %rsi
callq 0x20f0
movq %rax, -0x120(%rbp)
jmp 0x2ad3
movq -0x120(%rbp), %rdi
movq 0x54df(%rip), %rsi      # 0x7fc0
callq 0x2130
jmp 0x2ae8
cmpl $0x3b, -0x24(%rbp)
jbe 0x2d77
cmpl $0x64, -0x24(%rbp)
je 0x2d77
movq 0x54cd(%rip), %rdi      # 0x7fd0
leaq 0x2508(%rip), %rsi      # 0x5012
callq 0x2100
movq %rax, -0x128(%rbp)
jmp 0x2b18
movq -0x128(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x2160
movq %rax, -0x130(%rbp)
jmp 0x2b30
movq -0x130(%rbp), %rdi
leaq 0x24e9(%rip), %rsi      # 0x5027
callq 0x2100
jmp 0x2b45
movl -0x24(%rbp), %eax
addl $-0x32, %eax
movl %eax, %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x23, %rsi
leaq 0x55bf(%rip), %rdi      # 0x8120
callq 0x3080
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x2030
jmp 0x2b74
leaq -0x98(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2080
jmp 0x2b86
movl -0x24(%rbp), %edx
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x27c0
jmp 0x2b9b
movq 0x542e(%rip), %rdi      # 0x7fd0
leaq -0x78(%rbp), %rsi
callq 0x20f0
movq %rax, -0x138(%rbp)
jmp 0x2bb4
movq -0x138(%rbp), %rdi
leaq 0x2465(%rip), %rsi      # 0x5027
callq 0x2100
jmp 0x2bc9
leaq -0x78(%rbp), %rdi
callq 0x20b0
leaq -0x98(%rbp), %rdi
callq 0x20b0
leaq -0xd8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2080
jmp 0x2bf0
movl -0x24(%rbp), %edx
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x2840
jmp 0x2c08
movq 0x53c1(%rip), %rdi      # 0x7fd0
leaq -0xb8(%rbp), %rsi
callq 0x20f0
movq %rax, -0x140(%rbp)
jmp 0x2c24
movq -0x140(%rbp), %rdi
leaq 0x23f5(%rip), %rsi      # 0x5027
callq 0x2100
jmp 0x2c39
leaq -0xb8(%rbp), %rdi
callq 0x20b0
leaq -0xd8(%rbp), %rdi
callq 0x20b0
leaq -0x118(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2080
jmp 0x2c63
movl -0x24(%rbp), %edx
leaq -0xf8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x28c0
jmp 0x2c7b
movq 0x534e(%rip), %rdi      # 0x7fd0
leaq -0xf8(%rbp), %rsi
callq 0x20f0
movq %rax, -0x148(%rbp)
jmp 0x2c97
movq -0x148(%rbp), %rdi
leaq 0x2382(%rip), %rsi      # 0x5027
callq 0x2100
jmp 0x2cac
leaq -0xf8(%rbp), %rdi
callq 0x20b0
leaq -0x118(%rbp), %rdi
callq 0x20b0
movq 0x5305(%rip), %rdi      # 0x7fd0
movq 0x52ee(%rip), %rsi      # 0x7fc0
callq 0x2130
jmp 0x2cd9
jmp 0x2d77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2d01
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x20b0
leaq -0x98(%rbp), %rdi
callq 0x20b0
jmp 0x2d8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2d35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x20b0
leaq -0xd8(%rbp), %rdi
callq 0x20b0
jmp 0x2d8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2d69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x20b0
leaq -0x118(%rbp), %rdi
callq 0x20b0
jmp 0x2d8e
leaq -0x48(%rbp), %rdi
callq 0x20b0
leaq -0x18(%rbp), %rdi
callq 0x30a0
jmp 0x29b4
leaq -0x48(%rbp), %rdi
callq 0x20b0
jmp 0x2da4
xorl %eax, %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x21d0
nopl (%rax)