// File: IsaacLaw12[P]RayTracer/./src/Model.cpp
// Function: Model::calculate_vertex_normals()
void Model::calculate_vertex_normals(){
    /* Assumes that calculate_face_normals was called first
      For every face calculate and store the vertex normal for its three vertices
    */
    int num_vert_norms = Faces.cols()*3;
    std::vector<Eigen::Vector3d> temp(num_vert_norms);
    vertex_normals = temp;
    Eigen::Vector3d original, average;
    for (int face_num=0; face_num<Faces.cols(); face_num++){
        original = get_face_normal(face_num);
        for (int f_vert=0; f_vert<3; f_vert++){
            int vertex_num = Faces(f_vert, face_num);
            average = get_face_normal(face_num);
            calc_vertex_normal(vertex_num, original, average);
            vertex_normals[3*face_num + f_vert] = average;
        }
    }
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
addq $0x1b0, %rdi            # imm = 0x1B0
callq 0x1da50
movl %eax, %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl %eax, 0xdc(%rsp)
movslq 0xdc(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xbf(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x1e2d0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0xc0(%rsp), %rdi
callq 0x1e2e0
jmp 0x1b65e
leaq 0xbf(%rsp), %rdi
callq 0x1e360
movq 0x20(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
leaq 0xc0(%rsp), %rsi
callq 0x1d6f0
jmp 0x1b686
leaq 0x90(%rsp), %rdi
callq 0x11e20
jmp 0x1b695
leaq 0x78(%rsp), %rdi
callq 0x11e20
jmp 0x1b6a1
movl $0x0, 0x74(%rsp)
movq 0x20(%rsp), %rdi
movslq 0x74(%rsp), %rax
movq %rax, 0x10(%rsp)
addq $0x1b0, %rdi            # imm = 0x1B0
callq 0x1da50
movq %rax, 0x18(%rsp)
jmp 0x1b6cb
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
cmpq %rcx, %rax
jge 0x1b825
movq 0x20(%rsp), %rsi
movl 0x74(%rsp), %edx
leaq 0x58(%rsp), %rdi
callq 0x1b990
jmp 0x1b6f3
leaq 0x90(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x9d10
movl $0x0, 0x54(%rsp)
cmpl $0x3, 0x54(%rsp)
jge 0x1b813
movq 0x20(%rsp), %rdi
addq $0x1b0, %rdi            # imm = 0x1B0
movslq 0x54(%rsp), %rsi
movslq 0x74(%rsp), %rdx
callq 0x1da60
movq %rax, 0x8(%rsp)
jmp 0x1b73a
movq 0x20(%rsp), %rsi
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x50(%rsp)
movl 0x74(%rsp), %edx
leaq 0x38(%rsp), %rdi
callq 0x1b990
jmp 0x1b75a
leaq 0x78(%rsp), %rdi
movq %rdi, (%rsp)
leaq 0x38(%rsp), %rsi
callq 0x9d10
movq 0x20(%rsp), %rdi
movq (%rsp), %rcx
movl 0x50(%rsp), %esi
leaq 0x90(%rsp), %rdx
callq 0x1ba30
jmp 0x1b789
movq 0x20(%rsp), %rdi
addq $0x1f8, %rdi            # imm = 0x1F8
movl 0x74(%rsp), %ecx
movl %ecx, %eax
leal (%rax,%rax,2), %eax
movl 0x54(%rsp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x1e370
movq %rax, %rdi
leaq 0x78(%rsp), %rsi
callq 0x9e50
jmp 0x1b7bb
jmp 0x1b7bd
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
jmp 0x1b70d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xbf(%rsp), %rdi
callq 0x1e360
jmp 0x1b83a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x1d290
jmp 0x1b83a
jmp 0x1b815
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x1b6a9
leaq 0xc0(%rsp), %rdi
callq 0x1d290
addq $0xe8, %rsp
retq
movq 0xb0(%rsp), %rdi
callq 0x45e0
nopw (%rax,%rax)