// File: /workspace/github_cpp_makefile_star2_O3/tbonelaforge[P]gradebook/Main.cpp
// Function: main
int main() {
    int state; // 0 = unitialized, 1 = initialized, 2 = done
    bool idMode = true; // Whether to print students by id or by name.
    Gradebook gradebook;
    char C = '?';
    bool done = false;
    ifstream inData;

    try {
        inData.open("Grades.dat");
        if (!inData) {
            state = 0;
        } else {
            gradebook.deserialize(inData);
            state = 1;
        }
        while (C != 'Q' && state != 2) {
            displayMenu(state, gradebook, idMode);
            cin >> C;
            C = toupper(C);
            if (state == 0) {
                switch (C) {
                case 'Q':
                    handleQuit(state, gradebook);
                    break;
                case 'S':
                    handleSetup(state, gradebook);
                    break;
                default :
                    cout << "Unrecognized command." << endl;
                    break;
                }
            } else if (state == 1) {
                switch (C) {
                case 'A':
                    handleAddStudent(gradebook);
                    break;
                case 'G':
                    handleCalculateGrades(gradebook, idMode);
                    break;
                case 'O':
                    handleOutputGrades(gradebook, idMode);
                    break;
                case 'S':
                    handleSetup(state, gradebook);
                    break;
                case 'Q':
                    handleQuit(state, gradebook);
                    break;
                case 'M':
                    handleModeToggle(idMode);
                    break;
                case 'P':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddProgramGrade(gradebook, idMode);
                        break;
                    }
                case 'T':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddTestGrade(gradebook, idMode);
                        break;
                    }
                case 'F':
                    if (gradebook.getNumStudents() > 0) {
                        handleAddFinalExamGrade(gradebook, idMode);
                        break;
                    }
                case 'C':
                    if (gradebook.getNumStudents() > 0) {
                        handleChangeGrade(gradebook);
                        break;
                    }
                default :
                    cout << "Unrecognized Command." << endl;
                }
            }
        }
    } catch (string& e) {
        cout << "Got exception:" << endl << e;
        exit(1);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movb $0x1, -0x2a(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x5144
movb $0x3f, -0x29(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x2200
leaq 0x426b(%rip), %rsi      # 0x9068
leaq -0x288(%rbp), %rdi
movl $0x8, %edx
callq 0x2120
movq -0x288(%rbp), %rax
movq -0x18(%rax), %rax
xorl %r13d, %r13d
testb $0x5, -0x268(%rbp,%rax)
jne 0x4e3c
movl $0x1, %r13d
leaq -0x80(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x5b24
movl %r13d, -0x30(%rbp)
cmpb $0x51, -0x29(%rbp)
jne 0x4e6f
leaq -0x288(%rbp), %rdi
callq 0x2060
leaq -0x80(%rbp), %rdi
callq 0x51ac
xorl %eax, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x80(%rbp), %rbx
movq 0x8166(%rip), %r14      # 0xcfe0
leaq -0x29(%rbp), %r15
movzbl -0x2a(%rbp), %r12d
movl %r13d, %edi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x4a21
movq %r14, %rdi
movq %r15, %rsi
callq 0x2270
movsbl -0x29(%rbp), %edi
callq 0x2330
movb %al, -0x29(%rbp)
cmpl $0x1, %r13d
je 0x4f13
testl %r13d, %r13d
jne 0x4f60
cmpb $0x53, %al
je 0x4f54
movsbl %al, %eax
leaq 0x4b14(%rip), %rsi      # 0x99dd
cmpl $0x51, %eax
je 0x4f46
movl $0x15, %edx
movq 0x80ee(%rip), %rdi      # 0xcfc8
callq 0x2210
movq 0x80e2(%rip), %rcx      # 0xcfc8
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x80c4(%rip), %rdi      # 0xcfc8
callq 0x2040
movq %rax, %rdi
callq 0x2130
jmp 0x4f60
movsbl %al, %eax
addl $-0x41, %eax
leaq 0x4ad3(%rip), %rsi      # 0x99f3
cmpl $0x13, %eax
ja 0x4ece
leaq 0x40d8(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x4ab9(%rip), %rsi      # 0x99f3
jmpq *%rax
movq %rbx, %rdi
callq 0x42b7
jmp 0x4f60
leaq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x2d0e
jmp 0x4f60
leaq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x2652
cmpb $0x51, -0x29(%rbp)
je 0x4e46
movl -0x30(%rbp), %r13d
cmpl $0x2, %r13d
jne 0x4e7e
jmp 0x4e46
movq %rbx, %rdi
movl %r12d, %esi
callq 0x2eb9
jmp 0x4f60
movq %rbx, %rdi
callq 0x5896
testl %eax, %eax
jle 0x4fa3
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3033
jmp 0x4f60
movq %rbx, %rdi
callq 0x5896
testl %eax, %eax
jle 0x4fbc
movq %rbx, %rdi
movl %r12d, %esi
callq 0x343c
jmp 0x4f60
movq %rbx, %rdi
callq 0x5896
testl %eax, %eax
jle 0x4fd5
movq %rbx, %rdi
movl %r12d, %esi
callq 0x3889
jmp 0x4f60
movq %rbx, %rdi
callq 0x5896
leaq 0x4a0f(%rip), %rsi      # 0x99f3
testl %eax, %eax
jle 0x4ece
movq %rbx, %rdi
callq 0x3bdc
jmp 0x4f60
movq %rbx, %rdi
movl %r12d, %esi
callq 0x41b3
jmp 0x4f60
leaq -0x2a(%rbp), %rdi
callq 0x2dc3
jmp 0x4f60
movq %rax, %rbx
jmp 0x507e
jmp 0x501e
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x5072
movq %rbx, %rdi
callq 0x20a0
movq %rax, %rbx
movq 0x7f90(%rip), %rdi      # 0xcfc8
leaq 0x49ca(%rip), %rsi      # 0x9a09
movl $0xe, %edx
callq 0x2210
movq 0x7f78(%rip), %rdi      # 0xcfc8
callq 0x20d0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21a0
movl $0x1, %edi
callq 0x2230
movq %rax, %rbx
callq 0x22c0
leaq -0x288(%rbp), %rdi
callq 0x2060
leaq -0x80(%rbp), %rdi
callq 0x51ac
movq %rbx, %rdi
callq 0x2310
movq %rax, %rdi
callq 0x5097