// File: /workspace/github_cpp_makefile_star2_O1/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), %r15      # 0xcfc8
leaq 0x69fa(%rip), %rsi      # 0x9073
movl $0x37, %edx
movq %r15, %rdi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa92c(%rip), %rdi      # 0xcfe0
leaq -0x40(%rbp), %rbx
movq %rbx, %rsi
callq 0x2110
cmpl $0x7, (%rbx)
jb 0x2765
leaq 0x69a3(%rip), %r14      # 0x9073
movq 0xa909(%rip), %r12      # 0xcfe0
leaq -0x40(%rbp), %r13
movl $0x1f, %edx
movq %r15, %rdi
leaq 0x69c1(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %rbx
movl $0x37, %edx
movq %rax, %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
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
cmpl $0x6, -0x40(%rbp)
ja 0x26db
leaq 0x695f(%rip), %rsi      # 0x90cb
movl $0x25, %edx
movq %r15, %rdi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa839(%rip), %rdi      # 0xcfe0
leaq -0x3c(%rbp), %rbx
movq %rbx, %rsi
callq 0x2110
cmpl $0x5, (%rbx)
jb 0x2858
leaq 0x6908(%rip), %r14      # 0x90cb
movq 0xa816(%rip), %r12      # 0xcfe0
leaq -0x3c(%rbp), %r13
movl $0x1f, %edx
movq %r15, %rdi
leaq 0x68ce(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %rbx
movl $0x25, %edx
movq %rax, %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
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
cmpl $0x4, -0x3c(%rbp)
ja 0x27ce
leaq 0x6892(%rip), %rsi      # 0x90f1
movl $0x25, %edx
movq %r15, %rdi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa746(%rip), %rdi      # 0xcfe0
leaq -0x38(%rbp), %rbx
movq %rbx, %rsi
callq 0x2110
movl (%rbx), %eax
cmpl $0x2, %eax
jb 0x294f
leaq 0x6839(%rip), %r14      # 0x90f1
movq 0xa721(%rip), %r12      # 0xcfe0
leaq -0x38(%rbp), %r13
movl $0x1f, %edx
movq %r15, %rdi
leaq 0x67d9(%rip), %rsi      # 0x90ab
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rax, %rbx
movl $0x25, %edx
movq %rax, %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
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
movl -0x38(%rbp), %eax
cmpl $0x1, %eax
ja 0x28c3
testl %eax, %eax
je 0x2a96
leaq 0x67b9(%rip), %rsi      # 0x9117
movl $0x56, %edx
movq %r15, %rdi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa647(%rip), %rdi      # 0xcfe0
leaq -0x30(%rbp), %rbx
movq %rbx, %rsi
callq 0x2110
leaq -0x2c(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x2110
leaq -0x34(%rbp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
movl (%r14), %eax
addl (%rbx), %eax
addl (%r12), %eax
cmpl $0x64, %eax
je 0x2bae
movq 0xa604(%rip), %rbx      # 0xcfe0
leaq -0x30(%rbp), %r14
leaq -0x2c(%rbp), %r12
leaq -0x34(%rbp), %r13
movl $0x16, %edx
movq %r15, %rdi
leaq 0x6777(%rip), %rsi      # 0x916e
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x56, %edx
movq %r15, %rdi
leaq 0x66e5(%rip), %rsi      # 0x9117
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2110
movq %rax, %rdi
movq %r12, %rsi
callq 0x2110
movq %rax, %rdi
movq %r13, %rsi
callq 0x2110
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
cmpl $0x64, %eax
jne 0x29e8
jmp 0x2bae
leaq 0x66e8(%rip), %rsi      # 0x9185
movl $0x47, %edx
movq %r15, %rdi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq 0xa508(%rip), %rdi      # 0xcfe0
leaq -0x30(%rbp), %rbx
movq %rbx, %rsi
callq 0x2110
leaq -0x2c(%rbp), %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x2110
movl (%r14), %eax
addl (%rbx), %eax
cmpl $0x64, %eax
je 0x2bae
leaq 0x667d(%rip), %r14      # 0x9185
movq 0xa4d1(%rip), %r12      # 0xcfe0
leaq -0x30(%rbp), %r13
leaq -0x2c(%rbp), %rbx
movl $0x16, %edx
movq %r15, %rdi
leaq 0x6648(%rip), %rsi      # 0x916e
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movl $0x47, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2210
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movq %r12, %rdi
movq %r13, %rsi
callq 0x2110
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2110
movl -0x2c(%rbp), %eax
addl -0x30(%rbp), %eax
cmpl $0x64, %eax
jne 0x2b17
movl -0x40(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x38(%rbp), %ecx
movl -0x30(%rbp), %r8d
movl -0x2c(%rbp), %r9d
movl -0x34(%rbp), %eax
movl %eax, (%rsp)
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x5234
movq %rbx, %rdi
callq 0x256c
movq -0x50(%rbp), %rax
movl $0x1, (%rax)
leaq 0xa5fe(%rip), %rbx      # 0xd1e8
movq %rbx, %rdi
callq 0x2280
leaq 0x645b(%rip), %rsi      # 0x9054
movq %rbx, %rdi
movl $0x10, %edx
callq 0x2050
leaq 0x65c0(%rip), %rsi      # 0x91cd
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2210
leaq 0x65c3(%rip), %rsi      # 0x91e4
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2210
movl -0x40(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x65ad(%rip), %rsi      # 0x91f0
movl $0x8, %edx
movq %rax, %rdi
callq 0x2210
movl -0x3c(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x6594(%rip), %rsi      # 0x91f9
movl $0x9, %edx
movq %rax, %rdi
callq 0x2210
movl -0x38(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x657c(%rip), %rsi      # 0x9203
movl $0x4, %edx
movq %rax, %rdi
callq 0x2210
leaq 0x656d(%rip), %rsi      # 0x9208
movl $0x6, %edx
movq %rbx, %rdi
callq 0x2210
movl -0x30(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x6552(%rip), %rsi      # 0x920f
movl $0x6, %edx
movq %rax, %rdi
callq 0x2210
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
callq 0x2300
movq %rax, %rbx
leaq 0x6537(%rip), %rsi      # 0x9216
movl $0x6, %edx
movq %rax, %rdi
callq 0x2210
movl -0x34(%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