// File: /workspace/github_cpp_makefile_star2_O2/tbonelaforge[P]gradebook/Main.cpp
// Function: handleAddProgramGrade(Gradebook&, bool)
void handleAddProgramGrade(Gradebook &gradebook, bool idMode) {
    int programNumber, programGrade;
    cout << "Enter programming assignment number: (1 - " << gradebook.getNumPrograms() << ")" << endl;
    cin >> programNumber;
    if (programNumber < 1 || programNumber > gradebook.getNumPrograms()) {
        cout << "Invalid Program Number." << endl;
        return;
    }
    if (gradebook.getProgramRecorded(programNumber)) {
        cout << "Program " << programNumber << " already recorded..." << endl;
        return;
    }
    Student * student;
    if (!idMode) {
        Node * current = gradebook.getIndex();
        while (current != NULL) {
            student = current->student;
            cout << "Enter Program Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> programGrade;
            student->setProgramGrade(programNumber - 1, programGrade);
            saveGrades(gradebook);
            current = current->next;
        }
    } else {
        student = gradebook.getHead();
        while (student != NULL) {
            cout << "Enter Program Grade for "
                 << student->getLastName() << ", " << student->getFirstName() << endl;
            cin >> programGrade;
            student->setProgramGrade(programNumber - 1, programGrade);
            saveGrades(gradebook);
            student = student->next;
        }
    }
    gradebook.setProgramRecorded(programNumber);
    saveGrades(gradebook);
    handleOutputGrades(gradebook, idMode);
    
    transLog << "Recorded grades for Program: " << programNumber << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, %r15d
movq %rdi, %r14
movq 0x84da(%rip), %rdi      # 0xafc8
leaq 0x47c0(%rip), %rsi      # 0x72b5
callq 0x2170
movq %rax, %rbx
movq %r14, %rdi
callq 0x41d6
movq %rbx, %rdi
movl %eax, %esi
callq 0x22c0
leaq 0x45ff(%rip), %rsi      # 0x7115
movq %rax, %rdi
callq 0x2170
movq %rax, %rdi
callq 0x20b0
movq 0x84b3(%rip), %rdi      # 0xafe0
leaq -0x2c(%rbp), %rbx
movq %rbx, %rsi
callq 0x20e0
movl (%rbx), %ebx
testl %ebx, %ebx
jle 0x2b4b
movq %r14, %rdi
callq 0x41d6
cmpl %eax, %ebx
jle 0x2b75
movq 0x8476(%rip), %rdi      # 0xafc8
leaq 0x4787(%rip), %rsi      # 0x72e0
callq 0x2170
movq %rax, %rdi
callq 0x20b0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl -0x2c(%rbp), %esi
movq %r14, %rdi
callq 0x4a4e
testb %al, %al
je 0x2bae
movq 0x843d(%rip), %rdi      # 0xafc8
leaq 0x4fc4(%rip), %rsi      # 0x7b56
callq 0x2170
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x22c0
leaq 0x474f(%rip), %rsi      # 0x72f8
movq %rax, %rdi
jmp 0x2b59
movl %r15d, -0x3c(%rbp)
testb %r15b, %r15b
movq %r14, -0x38(%rbp)
movq %r14, %rdi
je 0x2c7b
callq 0x45a8
movq %rax, %r15
leaq -0x80(%rbp), %r13
leaq -0x60(%rbp), %r14
leaq -0x30(%rbp), %r12
testq %r15, %r15
je 0x2d35
movq 0x83e2(%rip), %rdi      # 0xafc8
leaq 0x4720(%rip), %rsi      # 0x730d
callq 0x2170
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0x4d5e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x4711(%rip), %rsi      # 0x7326
callq 0x2170
movq %rax, %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d42
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x2358
movq %r13, %rdi
callq 0x2358
movq 0x838e(%rip), %rdi      # 0xafe0
movq %r12, %rsi
callq 0x20e0
movl -0x2c(%rbp), %esi
decl %esi
movl -0x30(%rbp), %edx
movq %r15, %rdi
callq 0x4da8
movq -0x38(%rbp), %rdi
callq 0x255c
movq (%r15), %r15
jmp 0x2bd6
callq 0x45b2
movq %rax, %r15
leaq -0x80(%rbp), %r14
leaq -0x60(%rbp), %r13
testq %r15, %r15
je 0x2d35
movq (%r15), %r12
movq 0x832a(%rip), %rdi      # 0xafc8
leaq 0x4668(%rip), %rsi      # 0x730d
callq 0x2170
movq %rax, %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x4d5e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2160
movq %rax, %rdi
leaq 0x4659(%rip), %rsi      # 0x7326
callq 0x2170
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
callq 0x4d42
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2160
movq %rax, %rdi
callq 0x20b0
movq %r13, %rdi
callq 0x2358
movq %r14, %rdi
callq 0x2358
movq 0x82d6(%rip), %rdi      # 0xafe0
leaq -0x30(%rbp), %rsi
callq 0x20e0
movl -0x2c(%rbp), %esi
decl %esi
movl -0x30(%rbp), %edx
movq %r12, %rdi
callq 0x4da8
movq -0x38(%rbp), %rdi
callq 0x255c
movq 0x8(%r15), %r15
jmp 0x2c8b
movl -0x2c(%rbp), %esi
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x4a02
movq %rbx, %rdi
callq 0x255c
movzbl -0x3c(%rbp), %esi
movq %rbx, %rdi
callq 0x29fe
leaq 0x8479(%rip), %rdi      # 0xb1d8
leaq 0x45c3(%rip), %rsi      # 0x7329
callq 0x2170
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x22c0
jmp 0x2b5e
jmp 0x2d91
jmp 0x2d91
jmp 0x2d81
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2358
jmp 0x2d94
jmp 0x2d91
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2358
movq %rbx, %rdi
callq 0x22d0