// File: /workspace/github_cpp_makefile_star2_O3/tbonelaforge[P]gradebook/Main.cpp
// Function: handleSetup(int&, Gradebook&)
void handleSetup(int &state, Gradebook &gradebook) {
    int numPrograms, numTests, numFinals;
    int programsWeight, testsWeight, finalExamWeight;

    cout << "Enter number of programming assignments (Between 0-6): " << endl;
    cin >> numPrograms;
    while (numPrograms<0||numPrograms>6){
      cout << "Error, incorrect value entered." <<endl<<"Enter number of programming assignments (Between 0-6): " << endl;
      cin >> numPrograms;
    }

    cout << "Enter number of tests (Between 0-4): " << endl;
    cin >> numTests;
    while (numTests<0||numTests>4){
      cout << "Error, incorrect value entered." <<endl<<"Enter number of tests (Between 0-4): " << endl;
      cin >> numTests;
    }

    cout << "Enter number of Final Exams: (0 or 1)" << endl;
    cin >> numFinals;
    while (numFinals<0||numFinals>1){
      cout << "Error, incorrect value entered." <<endl<< "Enter number of Final Exams: (0 or 1)" << endl;
      cin >> numFinals;
    }

    if (numFinals > 0) {
        cout << "Enter the relative percentages for programs, tests, and final exam. example: \n30 50 20" << endl;
        cin >> programsWeight >> testsWeight >> finalExamWeight;
		while ((programsWeight + testsWeight + finalExamWeight) != 100) {
			cout << "Error, must equal 100%" << endl;
			cout << "Enter the relative percentages for programs, tests, and final exam. example: \n30 50 20" << endl;
			cin >> programsWeight >> testsWeight >> finalExamWeight;
		}
    } else {
        cout << "Enter the relative percentages for programs, and tests. example: \n40 60" << endl;
        cin >> programsWeight >> testsWeight;
		while ((programsWeight + testsWeight) != 100) {
			cout << "Error, must equal 100%" << endl;
			cout << "Enter the relative percentages for programs, and tests. example: \n40 60" << endl;
			cin >> programsWeight >> testsWeight;
		}
    }
    gradebook.initialize(
                         numPrograms,
                         numTests,
                         numFinals,
                         programsWeight,
                         testsWeight,
                         finalExamWeight
                         );
    saveGrades(gradebook);
    state = 1;
    
    transLog.close();
    transLog.open("Grades.trn");
    transLog << "Initialized Gradebook:" 
        << " Programs: " << numPrograms
        << " Tests: " << numTests
        << " Finals: " << numFinals << "  | "
        << " Pwt: " << programsWeight
        << " Twt: " << testsWeight
        << " Fwt: " << finalExamWeight << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x48(%rbp)
movq %rdi, -0x50(%rbp)
movq 0xa956(%rip), %rbx      # 0xcfc8
leaq 0x69fa(%rip), %rsi      # 0x9073
movl $0x37, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa92c(%rip), %rdi      # 0xcfe0
leaq -0x3c(%rbp), %r14
movq %r14, %rsi
callq 0x2110
cmpl $0x7, (%r14)
jb 0x2766
leaq 0x69a2(%rip), %r15      # 0x9073
movq 0xa908(%rip), %r12      # 0xcfe0
leaq -0x3c(%rbp), %r13
movl $0x1f, %edx
movq %rbx, %rdi
leaq 0x69c0(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %r14
movl $0x37, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
cmpl $0x6, -0x3c(%rbp)
ja 0x26dc
leaq 0x695e(%rip), %rsi      # 0x90cb
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa838(%rip), %rdi      # 0xcfe0
leaq -0x38(%rbp), %r14
movq %r14, %rsi
callq 0x2110
cmpl $0x5, (%r14)
jb 0x285a
leaq 0x6906(%rip), %r15      # 0x90cb
movq 0xa814(%rip), %r12      # 0xcfe0
leaq -0x38(%rbp), %r13
movl $0x1f, %edx
movq %rbx, %rdi
leaq 0x68cc(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %r14
movl $0x25, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
cmpl $0x4, -0x38(%rbp)
ja 0x27d0
leaq 0x6890(%rip), %rsi      # 0x90f1
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa744(%rip), %rdi      # 0xcfe0
leaq -0x34(%rbp), %r14
movq %r14, %rsi
callq 0x2110
movl (%r14), %eax
cmpl $0x2, %eax
jb 0x2952
leaq 0x6836(%rip), %r15      # 0x90f1
movq 0xa71e(%rip), %r12      # 0xcfe0
leaq -0x34(%rbp), %r13
movl $0x1f, %edx
movq %rbx, %rdi
leaq 0x67d6(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %r14
movl $0x25, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
movl -0x34(%rbp), %eax
cmpl $0x1, %eax
ja 0x28c6
testl %eax, %eax
je 0x2c1a
leaq 0x67b6(%rip), %rsi      # 0x9117
movl $0x56, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa644(%rip), %rdi      # 0xcfe0
leaq -0x30(%rbp), %r14
movq %r14, %rsi
callq 0x2110
leaq -0x2c(%rbp), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2110
leaq -0x40(%rbp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
movl (%r14), %r8d
movl (%r15), %r9d
leal (%r9,%r8), %ecx
movl (%r12), %eax
addl %eax, %ecx
cmpl $0x64, %ecx
je 0x2aa3
movq 0xa5fa(%rip), %r14      # 0xcfe0
leaq -0x30(%rbp), %r15
leaq -0x2c(%rbp), %r12
leaq -0x40(%rbp), %r13
movl $0x16, %edx
movq %rbx, %rdi
leaq 0x676d(%rip), %rsi      # 0x916e
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x56, %edx
movq %rbx, %rdi
leaq 0x66db(%rip), %rsi      # 0x9117
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r14, %rdi
movq %r15, %rsi
callq 0x2110
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
movq %rax, %rdi
movq %r13, %rsi
callq 0x2110
movl -0x30(%rbp), %r8d
movl -0x2c(%rbp), %r9d
leal (%r9,%r8), %ecx
movl -0x40(%rbp), %eax
addl %eax, %ecx
cmpl $0x64, %ecx
jne 0x29f2
movl -0x3c(%rbp), %esi
movl -0x38(%rbp), %edx
movl -0x34(%rbp), %ecx
movl %eax, (%rsp)
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x5250
movq %rbx, %rdi
callq 0x256c
movq -0x50(%rbp), %rax
movl $0x1, (%rax)
leaq 0xa714(%rip), %rbx      # 0xd1e8
movq %rbx, %rdi
callq 0x2280
leaq 0x6571(%rip), %rsi      # 0x9054
movq %rbx, %rdi
movl $0x10, %edx
callq 0x2050
leaq 0x66d6(%rip), %rsi      # 0x91cd
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2210
leaq 0x66d9(%rip), %rsi      # 0x91e4
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2210
movl -0x3c(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x66c3(%rip), %rsi      # 0x91f0
movl $0x8, %edx
movq %rax, %rdi
callq 0x2210
movl -0x38(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x66aa(%rip), %rsi      # 0x91f9
movl $0x9, %edx
movq %rax, %rdi
callq 0x2210
movl -0x34(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x6692(%rip), %rsi      # 0x9203
movl $0x4, %edx
movq %rax, %rdi
callq 0x2210
leaq 0x6683(%rip), %rsi      # 0x9208
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2210
movl -0x30(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x6668(%rip), %rsi      # 0x920f
movl $0x6, %edx
movq %rax, %rdi
callq 0x2210
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x664d(%rip), %rsi      # 0x9216
movl $0x6, %edx
movq %rax, %rdi
callq 0x2210
movl -0x40(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6564(%rip), %rsi      # 0x9185
movl $0x47, %edx
movq %rbx, %rdi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa384(%rip), %r15      # 0xcfe0
leaq -0x30(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2110
leaq -0x2c(%rbp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x2110
leaq 0x64ed(%rip), %r14      # 0x916e
movl $0x16, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x47, %edx
movq %rbx, %rdi
leaq 0x64be(%rip), %rsi      # 0x9185
callq 0x2210
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r15, %rdi
movq %r12, %rsi
callq 0x2110
movq %rax, %rdi
movq %r13, %rsi
callq 0x2110
jmp 0x2c81