// File: 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
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0xa801(%rip), %rdi      # 0xdfc8
leaq 0x68a5(%rip), %rsi      # 0xa073
callq 0x3220
movq %rax, %rdi
movq 0xa7cb(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa7f7(%rip), %rdi      # 0xdfe0
leaq -0x14(%rbp), %rsi
callq 0x3150
movb $0x1, %al
cmpl $0x0, -0x14(%rbp)
movb %al, -0x29(%rbp)
jl 0x3807
cmpl $0x6, -0x14(%rbp)
setg %al
movb %al, -0x29(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x3810
jmp 0x3862
movq 0xa7b1(%rip), %rdi      # 0xdfc8
leaq 0x688d(%rip), %rsi      # 0xa0ab
callq 0x3220
movq %rax, %rdi
movq 0xa77b(%rip), %rsi      # 0xdfa8
callq 0x3250
movq %rax, %rdi
leaq 0x6837(%rip), %rsi      # 0xa073
callq 0x3220
movq %rax, %rdi
movq 0xa75d(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa789(%rip), %rdi      # 0xdfe0
leaq -0x14(%rbp), %rsi
callq 0x3150
jmp 0x37f2
movq 0xa75f(%rip), %rdi      # 0xdfc8
leaq 0x685b(%rip), %rsi      # 0xa0cb
callq 0x3220
movq %rax, %rdi
movq 0xa729(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa755(%rip), %rdi      # 0xdfe0
leaq -0x18(%rbp), %rsi
callq 0x3150
movb $0x1, %al
cmpl $0x0, -0x18(%rbp)
movb %al, -0x2a(%rbp)
jl 0x38a9
cmpl $0x4, -0x18(%rbp)
setg %al
movb %al, -0x2a(%rbp)
movb -0x2a(%rbp), %al
testb $0x1, %al
jne 0x38b2
jmp 0x3904
movq 0xa70f(%rip), %rdi      # 0xdfc8
leaq 0x67eb(%rip), %rsi      # 0xa0ab
callq 0x3220
movq %rax, %rdi
movq 0xa6d9(%rip), %rsi      # 0xdfa8
callq 0x3250
movq %rax, %rdi
leaq 0x67ed(%rip), %rsi      # 0xa0cb
callq 0x3220
movq %rax, %rdi
movq 0xa6bb(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa6e7(%rip), %rdi      # 0xdfe0
leaq -0x18(%rbp), %rsi
callq 0x3150
jmp 0x3894
movq 0xa6bd(%rip), %rdi      # 0xdfc8
leaq 0x67df(%rip), %rsi      # 0xa0f1
callq 0x3220
movq %rax, %rdi
movq 0xa687(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa6b3(%rip), %rdi      # 0xdfe0
leaq -0x1c(%rbp), %rsi
callq 0x3150
movb $0x1, %al
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x2b(%rbp)
jl 0x394b
cmpl $0x1, -0x1c(%rbp)
setg %al
movb %al, -0x2b(%rbp)
movb -0x2b(%rbp), %al
testb $0x1, %al
jne 0x3954
jmp 0x39a6
movq 0xa66d(%rip), %rdi      # 0xdfc8
leaq 0x6749(%rip), %rsi      # 0xa0ab
callq 0x3220
movq %rax, %rdi
movq 0xa637(%rip), %rsi      # 0xdfa8
callq 0x3250
movq %rax, %rdi
leaq 0x6771(%rip), %rsi      # 0xa0f1
callq 0x3220
movq %rax, %rdi
movq 0xa619(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa645(%rip), %rdi      # 0xdfe0
leaq -0x1c(%rbp), %rsi
callq 0x3150
jmp 0x3936
cmpl $0x0, -0x1c(%rbp)
jle 0x3a7b
movq 0xa611(%rip), %rdi      # 0xdfc8
leaq 0x6759(%rip), %rsi      # 0xa117
callq 0x3220
movq %rax, %rdi
movq 0xa5db(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa607(%rip), %rdi      # 0xdfe0
leaq -0x20(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x28(%rbp), %rsi
callq 0x3150
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
addl -0x28(%rbp), %eax
cmpl $0x64, %eax
je 0x3a76
movq 0xa5b9(%rip), %rdi      # 0xdfc8
leaq 0x6758(%rip), %rsi      # 0xa16e
callq 0x3220
movq %rax, %rdi
movq 0xa583(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa597(%rip), %rdi      # 0xdfc8
leaq 0x66df(%rip), %rsi      # 0xa117
callq 0x3220
movq %rax, %rdi
movq 0xa561(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa58d(%rip), %rdi      # 0xdfe0
leaq -0x20(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x28(%rbp), %rsi
callq 0x3150
jmp 0x39fa
jmp 0x3b28
movq 0xa546(%rip), %rdi      # 0xdfc8
leaq 0x66fc(%rip), %rsi      # 0xa185
callq 0x3220
movq %rax, %rdi
movq 0xa510(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa53c(%rip), %rdi      # 0xdfe0
leaq -0x20(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x3150
movl -0x20(%rbp), %eax
addl -0x24(%rbp), %eax
cmpl $0x64, %eax
je 0x3b26
movq 0xa4fd(%rip), %rdi      # 0xdfc8
leaq 0x669c(%rip), %rsi      # 0xa16e
callq 0x3220
movq %rax, %rdi
movq 0xa4c7(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa4db(%rip), %rdi      # 0xdfc8
leaq 0x6691(%rip), %rsi      # 0xa185
callq 0x3220
movq %rax, %rdi
movq 0xa4a5(%rip), %rsi      # 0xdfa8
callq 0x3250
movq 0xa4d1(%rip), %rdi      # 0xdfe0
leaq -0x20(%rbp), %rsi
callq 0x3150
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x3150
jmp 0x3ab9
jmp 0x3b28
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movl -0x28(%rbp), %eax
movl %eax, (%rsp)
callq 0x6000
movq -0x10(%rbp), %rdi
callq 0x36f0
movq -0x8(%rbp), %rax
movl $0x1, (%rax)
leaq 0xa716(%rip), %rdi      # 0xe278
callq 0x3360
leaq 0xa70a(%rip), %rdi      # 0xe278
leaq 0x64df(%rip), %rsi      # 0xa054
movl $0x10, %edx
callq 0x3070
leaq 0xa6f2(%rip), %rdi      # 0xe278
leaq 0x6640(%rip), %rsi      # 0xa1cd
callq 0x3220
movq %rax, %rdi
leaq 0x6648(%rip), %rsi      # 0xa1e4
callq 0x3220
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x663a(%rip), %rsi      # 0xa1f0
callq 0x3220
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x6629(%rip), %rsi      # 0xa1f9
callq 0x3220
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x6619(%rip), %rsi      # 0xa203
callq 0x3220
movq %rax, %rdi
leaq 0x660f(%rip), %rsi      # 0xa208
callq 0x3220
movq %rax, %rdi
movl -0x20(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x65fc(%rip), %rsi      # 0xa20f
callq 0x3220
movq %rax, %rdi
movl -0x24(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
leaq 0x65e9(%rip), %rsi      # 0xa216
callq 0x3220
movq %rax, %rdi
movl -0x28(%rbp), %esi
callq 0x33e0
movq %rax, %rdi
movq 0xa361(%rip), %rsi      # 0xdfa8
callq 0x3250
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)