// File: /workspace/github_cpp_makefile_star2_O1/IsaacLaw12[P]RayTracer/./src/Model.cpp
// Function: Model::calculate_face_normals()
void Model::calculate_face_normals(){
    /*
      Calculate the normal for each face by taking the cross product of two of the triangle's sides
    */
    FaceNormals = Eigen::MatrixXd();
    Eigen::Vector3d first_vertex, second_vertex, third_vertex;
    Eigen::Vector3d first_vector, second_vector;
    for (int i=0; i<Faces.cols(); i++){
        first_vertex << get_vertex( Faces(0, i) - 1 );
        second_vertex << get_vertex( Faces(1, i) - 1 );
        third_vertex << get_vertex( Faces(2, i) - 1 );
        // Calculate normal in counter clockwise direction?
        first_vector = first_vertex - third_vertex;
        second_vector = first_vertex - second_vertex;

        add_face_normal((-1*first_vector.cross(second_vector)).normalized());
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
movq 0x1c8(%rdi), %rdi
xorpd %xmm0, %xmm0
movupd %xmm0, 0x1c8(%rbx)
movq $0x0, 0x1d8(%rbx)
callq 0x3320
cmpq $0x0, 0x1c0(%rbx)
jle 0x961e
xorl %r12d, %r12d
movq %rsp, %r14
leaq 0x20(%rsp), %r15
movq 0x1b8(%rbx), %rax
testq %rax, %rax
jle 0x962d
movq 0x1b0(%rbx), %rcx
imulq %r12, %rax
movl (%rcx,%rax,4), %edx
decl %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x993e
movq 0x1b8(%rbx), %rax
cmpq $0x2, %rax
jl 0x962d
cmpq %r12, 0x1c0(%rbx)
jle 0x962d
movaps (%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
movsd 0x10(%rsp), %xmm0
movapd %xmm0, 0x60(%rsp)
movq 0x1b0(%rbx), %rcx
imulq %r12, %rax
movl 0x4(%rcx,%rax,4), %edx
decl %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x993e
movq 0x1b8(%rbx), %rax
cmpq $0x3, %rax
jl 0x962d
cmpq %r12, 0x1c0(%rbx)
jle 0x962d
movaps (%rsp), %xmm0
movaps %xmm0, 0x50(%rsp)
movsd 0x10(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x1b0(%rbx), %rcx
imulq %r12, %rax
movl 0x8(%rcx,%rax,4), %edx
decl %edx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x993e
movapd 0x70(%rsp), %xmm5
movapd %xmm5, %xmm1
subpd (%rsp), %xmm1
movapd 0x40(%rsp), %xmm2
movhpd 0x10(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0]
subpd 0x50(%rsp), %xmm5
movapd %xmm5, %xmm0
unpckhpd %xmm5, %xmm0            # xmm0 = xmm0[1],xmm5[1]
movapd 0x60(%rsp), %xmm6
unpcklpd %xmm6, %xmm6            # xmm6 = xmm6[0,0]
subpd %xmm2, %xmm6
movapd %xmm6, %xmm2
shufpd $0x1, %xmm1, %xmm2      # xmm2 = xmm2[1],xmm1[0]
movapd %xmm1, %xmm3
mulsd %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm5, %xmm4
shufpd $0x1, %xmm6, %xmm4      # xmm4 = xmm4[1],xmm6[0]
mulpd %xmm2, %xmm4
shufpd $0x1, %xmm5, %xmm3      # xmm3 = xmm3[1],xmm5[0]
mulpd %xmm6, %xmm3
subpd %xmm4, %xmm3
mulsd %xmm5, %xmm1
subsd %xmm1, %xmm0
movapd %xmm3, %xmm1
movapd 0xd95b(%rip), %xmm5     # 0x16f10
xorpd %xmm5, %xmm1
mulpd %xmm3, %xmm3
movapd %xmm3, %xmm4
unpckhpd %xmm3, %xmm4            # xmm4 = xmm4[1],xmm3[1]
addsd %xmm3, %xmm4
movapd %xmm0, %xmm2
xorpd %xmm5, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm4, %xmm0
ucomisd 0xd93f(%rip), %xmm0     # 0x16f20
jbe 0x95f7
movq %xmm0, %xmm0            # xmm0 = xmm0[0],zero
sqrtpd %xmm0, %xmm0
divsd %xmm0, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movsd %xmm2, 0x30(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x97ec
incq %r12
cmpq %r12, 0x1c0(%rbx)
jg 0x9473
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xce5f(%rip), %rdi      # 0x16493
leaq 0xce8d(%rip), %rsi      # 0x164c8
leaq 0xd9ae(%rip), %rcx      # 0x16ff0
movl $0x16d, %edx            # imm = 0x16D
callq 0x31a0