// File: /workspace/github_cpp_makefile_star2_O1/tbonelaforge[P]gradebook/Gradebook.cpp
// Function: Gradebook::addStudent(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Student * Gradebook::addStudent(int newId, string firstName, string lastName) {
    Student * current = head;
    Student * previous = NULL;
    while (current != NULL) {
        if (current->getId() == newId) {
            throw "Student Id " + to_string(newId) + " already exists.";
        }
        if (current->getId() > newId) {
            break;
        }
        previous = current;
        current = current->next;
    }
    Student * newStudent = new Student(numPrograms, numTests, numFinals);
    newStudent->setId(newId);
    newStudent->setFirstName(firstName);
    newStudent->setLastName(lastName);
    if (previous != NULL) {
        previous->next = newStudent;
    } else {
        head = newStudent;
    }
    newStudent->next = current;
    addToIndex(newStudent);
    numStudents += 1;
    return newStudent;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, -0x38(%rbp)
movq %rdx, %r14
movl %esi, %r12d
movq %rdi, -0x30(%rbp)
movq 0x38(%rdi), %rbx
xorl %r13d, %r13d
testq %rbx, %rbx
je 0x536e
movq %rbx, %r15
movq %rbx, %rdi
callq 0x629c
cmpl %r12d, %eax
je 0x545b
movq %r15, %rdi
callq 0x629c
cmpl %r12d, %eax
jg 0x536b
movq (%r15), %rbx
movq %r15, %r13
jmp 0x533d
movq %r15, %rbx
movl $0x78, %edi
callq 0x21c0
movq %rax, %r15
movq -0x30(%rbp), %rax
movl (%rax), %esi
movl 0x10(%rax), %edx
movl 0x20(%rax), %ecx
movq %r15, %rdi
callq 0x6128
movq %r15, %rdi
movl %r12d, %esi
callq 0x6276
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x58(%rbp), %r12
movq %r12, %rdi
callq 0x508c
movq %r15, %rdi
movq %r12, %rsi
callq 0x6280
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x53dc
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x68(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %r14
movq %r14, %rdi
callq 0x508c
movq %r15, %rdi
movq %r14, %rsi
callq 0x628e
movq -0x30(%rbp), %rax
leaq 0x38(%rax), %r14
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x5427
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x21d0
testq %r13, %r13
cmovneq %r13, %r14
movq %r15, (%r14)
movq %rbx, (%r15)
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x556a
incl 0x48(%rbx)
movq %r15, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x20e0
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
movl %r12d, %esi
callq 0x600a
leaq 0x45f9(%rip), %rsi      # 0x9a77
leaq -0xb8(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x5f90
movb $0x1, %r15b
leaq 0x45e8(%rip), %rdx      # 0x9a83
leaq -0xb8(%rbp), %rsi
movq %rbx, %rdi
callq 0x5f33
xorl %r15d, %r15d
leaq 0x78cc(%rip), %rsi      # 0xcd80
movq 0x7aed(%rip), %rdx      # 0xcfa8
movq %rbx, %rdi
callq 0x22f0
movq %rax, %r14
movq -0x78(%rbp), %rdi
cmpq %r12, %rdi
je 0x5562
movq -0x68(%rbp), %rsi
jmp 0x54ed
movq %rax, %r14
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x5562
movq -0x48(%rbp), %rsi
incq %rsi
jmp 0x54fd
movq %rax, %r14
movl $0x78, %esi
movq %r15, %rdi
callq 0x21d0
jmp 0x5562
movq %rax, %r14
leaq -0xa8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x552e
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21d0
jmp 0x552e
movq %rax, %r14
movb $0x1, %r15b
leaq -0x88(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5555
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x21d0
jmp 0x5555
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0x5562
movq %rbx, %rdi
callq 0x2150
movq %r14, %rdi
callq 0x2310