// File: tbonelaforge[P]gradebook/Main.cpp
// Function: handleAddStudent(Gradebook&)
void handleAddStudent(Gradebook &gradebook) {
    string firstName, lastName;
    int studentId;
    cout << "Enter the new student's first and last name: " << endl;
    cin >> firstName;
    while (firstName.length() > 20){
      cout<< "Error, too many characters, please shorten to less than 20"<<endl;
      cout << "Enter the new student's first name: " << endl;
      cin >> firstName;
    }

    cin >> lastName;
    while (lastName.length() > 20){
      cout<< "Error, too many characters, please shorten to less than 20"<<endl;
      cout << "Enter the new student's last name: " << endl;
      cin >> lastName;
    }

    cout << "Enter the new student's ID number: " << endl;
    cin >> studentId;
    while (studentId>9999 || studentId<1){
      cout<< " Error please enter a value between 1-9999"<< endl;
      cout << "Enter the new student's ID number: " << endl;
      cin >> studentId;
    }

    cout << "Adding " << firstName << " " << lastName << " (" << studentId << ") to the gradebook" << endl;
    try {
        Student * newStudent = gradebook.addStudent(studentId, firstName, lastName);
        cout << "Successfully added student " << newStudent->getId() << ": "
             << newStudent->getFirstName() << " " << newStudent->getLastName() << endl;
        saveGrades(gradebook);
    } catch (const string& reason) {
        cout << "Unable to add new student: " << endl << reason << endl;
    }
    transLog << "Added " << firstName << " " << lastName << " id " << studentId << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3350
leaq -0x48(%rbp), %rdi
callq 0x3350
movq 0x8f30(%rip), %rdi      # 0xdfc8
leaq 0x55a4(%rip), %rsi      # 0xa643
callq 0x3220
movq %rax, -0xf8(%rbp)
jmp 0x50ad
movq -0xf8(%rbp), %rdi
movq 0x8eed(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x50c2
movq 0x8f17(%rip), %rdi      # 0xdfe0
leaq -0x28(%rbp), %rsi
callq 0x3310
jmp 0x50d4
jmp 0x50d6
leaq -0x28(%rbp), %rdi
callq 0x3380
cmpq $0x14, %rax
jbe 0x5173
movq 0x8ed8(%rip), %rdi      # 0xdfc8
leaq 0x557a(%rip), %rsi      # 0xa671
callq 0x3220
movq %rax, -0x100(%rbp)
jmp 0x5105
movq -0x100(%rbp), %rdi
movq 0x8e95(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x511a
movq 0x8ea7(%rip), %rdi      # 0xdfc8
leaq 0x5584(%rip), %rsi      # 0xa6ac
callq 0x3220
movq %rax, -0x108(%rbp)
jmp 0x5136
movq -0x108(%rbp), %rdi
movq 0x8e64(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x514b
movq 0x8e8e(%rip), %rdi      # 0xdfe0
leaq -0x28(%rbp), %rsi
callq 0x3310
jmp 0x515d
jmp 0x50d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x574c
movq 0x8e66(%rip), %rdi      # 0xdfe0
leaq -0x48(%rbp), %rsi
callq 0x3310
jmp 0x5185
jmp 0x5187
leaq -0x48(%rbp), %rdi
callq 0x3380
cmpq $0x14, %rax
jbe 0x520f
movq 0x8e2b(%rip), %rdi      # 0xdfc8
leaq 0x54cd(%rip), %rsi      # 0xa671
callq 0x3220
movq %rax, -0x110(%rbp)
jmp 0x51b2
movq -0x110(%rbp), %rdi
movq 0x8de8(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x51c7
movq 0x8dfa(%rip), %rdi      # 0xdfc8
leaq 0x54fc(%rip), %rsi      # 0xa6d1
callq 0x3220
movq %rax, -0x118(%rbp)
jmp 0x51e3
movq -0x118(%rbp), %rdi
movq 0x8db7(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x51f8
movq 0x8de1(%rip), %rdi      # 0xdfe0
leaq -0x48(%rbp), %rsi
callq 0x3310
jmp 0x520a
jmp 0x5187
movq 0x8db2(%rip), %rdi      # 0xdfc8
leaq 0x54d8(%rip), %rsi      # 0xa6f5
callq 0x3220
movq %rax, -0x120(%rbp)
jmp 0x522b
movq -0x120(%rbp), %rdi
movq 0x8d6f(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x5240
movq 0x8d99(%rip), %rdi      # 0xdfe0
leaq -0x4c(%rbp), %rsi
callq 0x3150
jmp 0x5252
jmp 0x5254
movb $0x1, %al
cmpl $0x270f, -0x4c(%rbp)    # imm = 0x270F
movb %al, -0x121(%rbp)
jg 0x5272
cmpl $0x1, -0x4c(%rbp)
setl %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x527e
jmp 0x52f7
movq 0x8d43(%rip), %rdi      # 0xdfc8
leaq 0x548d(%rip), %rsi      # 0xa719
callq 0x3220
movq %rax, -0x130(%rbp)
jmp 0x529a
movq -0x130(%rbp), %rdi
movq 0x8d00(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x52af
movq 0x8d12(%rip), %rdi      # 0xdfc8
leaq 0x5438(%rip), %rsi      # 0xa6f5
callq 0x3220
movq %rax, -0x138(%rbp)
jmp 0x52cb
movq -0x138(%rbp), %rdi
movq 0x8ccf(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x52e0
movq 0x8cf9(%rip), %rdi      # 0xdfe0
leaq -0x4c(%rbp), %rsi
callq 0x3150
jmp 0x52f2
jmp 0x5254
movq 0x8cca(%rip), %rdi      # 0xdfc8
leaq 0x543f(%rip), %rsi      # 0xa744
callq 0x3220
movq %rax, -0x140(%rbp)
jmp 0x5313
movq -0x140(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3200
movq %rax, -0x148(%rbp)
jmp 0x532c
movq -0x148(%rbp), %rdi
leaq 0x4fed(%rip), %rsi      # 0xa327
callq 0x3220
movq %rax, -0x150(%rbp)
jmp 0x5348
movq -0x150(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3200
movq %rax, -0x158(%rbp)
jmp 0x5361
movq -0x158(%rbp), %rdi
leaq 0x53dd(%rip), %rsi      # 0xa74c
callq 0x3220
movq %rax, -0x160(%rbp)
jmp 0x537d
movq -0x160(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x33e0
movq %rax, -0x168(%rbp)
jmp 0x5395
movq -0x168(%rbp), %rdi
leaq 0x53ac(%rip), %rsi      # 0xa74f
callq 0x3220
movq %rax, -0x170(%rbp)
jmp 0x53b1
movq -0x170(%rbp), %rdi
movq 0x8be9(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x53c6
movq -0x8(%rbp), %rax
movq %rax, -0x180(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x174(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x30f0
jmp 0x53ec
leaq -0xa8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x30f0
jmp 0x53fe
movl -0x174(%rbp), %esi
movq -0x180(%rbp), %rdi
leaq -0x88(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
callq 0x6150
movq %rax, -0x188(%rbp)
jmp 0x5427
leaq -0xa8(%rbp), %rdi
callq 0x3498
leaq -0x88(%rbp), %rdi
callq 0x3498
movq -0x188(%rbp), %rax
movq %rax, -0x68(%rbp)
movq 0x8b77(%rip), %rdi      # 0xdfc8
leaq 0x530a(%rip), %rsi      # 0xa762
callq 0x3220
movq %rax, -0x190(%rbp)
jmp 0x5466
movq -0x68(%rbp), %rdi
callq 0x7540
movl %eax, -0x194(%rbp)
jmp 0x5477
movl -0x194(%rbp), %esi
movq -0x190(%rbp), %rdi
callq 0x33e0
movq %rax, -0x1a0(%rbp)
jmp 0x5492
movq -0x1a0(%rbp), %rdi
leaq 0x4c4e(%rip), %rsi      # 0xa0ee
callq 0x3220
movq %rax, -0x1a8(%rbp)
jmp 0x54ae
movq -0x68(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x7560
jmp 0x54c0
movq -0x1a8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3200
movq %rax, -0x1b0(%rbp)
jmp 0x54dc
movq -0x1b0(%rbp), %rdi
leaq 0x4e3d(%rip), %rsi      # 0xa327
callq 0x3220
movq %rax, -0x1b8(%rbp)
jmp 0x54f8
movq -0x68(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x7590
jmp 0x550a
movq -0x1b8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x3200
movq %rax, -0x1c0(%rbp)
jmp 0x5526
movq -0x1c0(%rbp), %rdi
movq 0x8a74(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x553b
leaq -0xe8(%rbp), %rdi
callq 0x3498
leaq -0xc8(%rbp), %rdi
callq 0x3498
movq -0x8(%rbp), %rdi
callq 0x36f0
jmp 0x555e
jmp 0x5669
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x55d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5597
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3498
leaq -0x88(%rbp), %rdi
callq 0x3498
jmp 0x55d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x55cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x3498
leaq -0xc8(%rbp), %rdi
callq 0x3498
movl -0x5c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x574c
movq -0x58(%rbp), %rdi
callq 0x30e0
movq %rax, -0xf0(%rbp)
movq 0x89ca(%rip), %rdi      # 0xdfc8
leaq 0x5179(%rip), %rsi      # 0xa77e
callq 0x3220
movq %rax, -0x1c8(%rbp)
jmp 0x5613
movq -0x1c8(%rbp), %rdi
movq 0x8987(%rip), %rsi      # 0xdfa8
callq 0x3250
movq %rax, -0x1d0(%rbp)
jmp 0x562f
movq -0x1d0(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x3200
movq %rax, -0x1d8(%rbp)
jmp 0x564b
movq -0x1d8(%rbp), %rdi
movq 0x894f(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x5660
callq 0x33b0
jmp 0x5667
jmp 0x5669
leaq 0x8c08(%rip), %rdi      # 0xe278
leaq 0x5123(%rip), %rsi      # 0xa79a
callq 0x3220
movq %rax, -0x1e0(%rbp)
jmp 0x5685
movq -0x1e0(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x3200
movq %rax, -0x1e8(%rbp)
jmp 0x569e
movq -0x1e8(%rbp), %rdi
leaq 0x4c7b(%rip), %rsi      # 0xa327
callq 0x3220
movq %rax, -0x1f0(%rbp)
jmp 0x56ba
movq -0x1f0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x3200
movq %rax, -0x1f8(%rbp)
jmp 0x56d3
movq -0x1f8(%rbp), %rdi
leaq 0x50c0(%rip), %rsi      # 0xa7a1
callq 0x3220
movq %rax, -0x200(%rbp)
jmp 0x56ef
movq -0x200(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x33e0
movq %rax, -0x208(%rbp)
jmp 0x5707
movq -0x208(%rbp), %rdi
movq 0x8893(%rip), %rsi      # 0xdfa8
callq 0x3250
jmp 0x571c
leaq -0x48(%rbp), %rdi
callq 0x3498
leaq -0x28(%rbp), %rdi
callq 0x3498
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
callq 0x33b0
jmp 0x574a
jmp 0x574c
leaq -0x48(%rbp), %rdi
callq 0x3498
leaq -0x28(%rbp), %rdi
callq 0x3498
movq -0x58(%rbp), %rdi
callq 0x33f0
movq %rax, %rdi
callq 0x5e40
nop