// File: /workspace/github_cpp_makefile_star2_O1/IsaacLaw12[P]RayTracer/./src/WaveObject.cpp
// Function: WaveObject::find_surf_norm(Ray&, double)
Eigen::Vector3d WaveObject::find_surf_norm(Ray &ray, double t_value){
    double epsilon = .5;
    Eigen::Vector3d loc = ray.get_ray_loc(t_value);
    double offset_one = 0;
    double offset_two = 0;
    find_offsets(loc, offset_one, offset_two);

    Eigen::Vector3d intersect_point = wave_function(offset_one, offset_two);
    Eigen::Vector3d point_one = wave_function(offset_one + epsilon, offset_two);
    Eigen::Vector3d point_two = wave_function(offset_one, offset_two + epsilon);

    Eigen::Vector3d dir_one = point_one - intersect_point;
    Eigen::Vector3d dir_two = point_two - intersect_point;

    return -1 * (dir_one.cross(dir_two)).normalized();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x70(%rsp), %r15
movq %r15, %rdi
movq %rdx, %rsi
callq 0x15cc0
movapd (%r15), %xmm5
movsd 0x10(%r15), %xmm4
movupd 0x1e0(%r14), %xmm1
subpd %xmm1, %xmm5
movupd 0x210(%r14), %xmm1
movupd 0x228(%r14), %xmm2
subsd 0x1f0(%r14), %xmm4
mulpd %xmm5, %xmm1
movapd %xmm1, %xmm3
unpckhpd %xmm1, %xmm3            # xmm3 = xmm3[1],xmm1[1]
addsd %xmm1, %xmm3
movsd 0x220(%r14), %xmm1
mulsd %xmm4, %xmm1
addsd %xmm3, %xmm1
movapd %xmm1, %xmm0
movsd %xmm1, 0x8(%rsp)
mulpd %xmm5, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movapd %xmm4, %xmm1
mulsd 0x238(%r14), %xmm1
addsd %xmm3, %xmm1
movsd %xmm1, (%rsp)
leaq 0x50(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x134fc
movsd 0x8(%rsp), %xmm0
addsd 0x56a4(%rip), %xmm0     # 0x188f0
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
movsd (%rsp), %xmm1
callq 0x134fc
movsd (%rsp), %xmm1
addsd 0x5682(%rip), %xmm1     # 0x188f0
leaq 0x10(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movsd 0x8(%rsp), %xmm0
callq 0x134fc
movapd (%r12), %xmm2
movapd (%r15), %xmm0
subpd %xmm0, %xmm2
movapd (%r13), %xmm3
subpd %xmm0, %xmm3
movapd %xmm3, %xmm0
unpckhpd %xmm3, %xmm0            # xmm0 = xmm0[1],xmm3[1]
movsd 0x10(%r13), %xmm4
movhpd 0x10(%r12), %xmm4       # xmm4 = xmm4[0],mem[0]
movsd 0x10(%r15), %xmm1
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
subpd %xmm1, %xmm4
movapd %xmm3, %xmm5
shufpd $0x1, %xmm4, %xmm5      # xmm5 = xmm5[1],xmm4[0]
movapd %xmm2, %xmm1
shufpd $0x1, %xmm3, %xmm1      # xmm1 = xmm1[1],xmm3[0]
mulpd %xmm4, %xmm1
shufpd $0x1, %xmm2, %xmm4      # xmm4 = xmm4[1],xmm2[0]
mulsd %xmm2, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
mulpd %xmm4, %xmm5
subpd %xmm5, %xmm1
mulsd %xmm3, %xmm2
subsd %xmm2, %xmm0
movapd %xmm1, %xmm2
mulpd %xmm1, %xmm2
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm2, %xmm3
movapd %xmm0, %xmm2
mulsd %xmm0, %xmm2
addsd %xmm3, %xmm2
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm2
jbe 0x13331
movq %xmm2, %xmm2            # xmm2 = xmm2[0],zero
sqrtpd %xmm2, %xmm2
divsd %xmm2, %xmm0
unpcklpd %xmm2, %xmm2            # xmm2 = xmm2[0,0]
divpd %xmm2, %xmm1
movapd 0x3bd7(%rip), %xmm2     # 0x16f10
xorpd %xmm2, %xmm1
movupd %xmm1, (%rbx)
xorpd %xmm2, %xmm0
movlpd %xmm0, 0x10(%rbx)
movq %rbx, %rax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq