// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/R3Graphics/R3PointLight.cpp
// Function: gaps::R3PointLight::Reflection(gaps::R3Brdf const&, gaps::R3Point const&, gaps::R3Point const&, gaps::R3Vector const&) const
RNRgb R3PointLight::
Reflection(const R3Brdf& brdf, const R3Point& eye, 
    const R3Point& point, const R3Vector& normal) const
{
    // Check if light is active
    if (!IsActive()) return RNblack_rgb;

    // Get material properties
    const RNRgb& Dc = brdf.Diffuse();
    const RNRgb& Sc = brdf.Specular();
    RNScalar s = brdf.Shininess();

    // Get light properties
    RNScalar I = IntensityAtPoint(point);
    R3Vector L = DirectionFromPoint(point);
    const RNRgb& Ic = Color();

    // Compute geometric stuff
    RNScalar NL = normal.Dot(L);
    if (RNIsNegativeOrZero(NL)) return RNblack_rgb;
    R3Vector R = (2.0 * NL) * normal - L;
    R3Vector V = eye - point;
    V.Normalize();
    RNScalar VR = V.Dot(R);

    // Compute diffuse reflection
    RNRgb rgb = (I * NL) * Dc * Ic;

    // Compute specular reflection
    if (RNIsPositive(VR)) rgb += (I * pow(VR,s)) * Sc * Ic;

    // Return total reflection
    return rgb;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x20(%rsi)
je 0x427b1
movq %r9, %rbp
movq %r8, %r12
movq %rdx, %r15
movq %rsi, %r14
movq %rcx, (%rsp)
movsd 0x98(%rdx), %xmm0
movsd %xmm0, 0x18(%rsp)
movq (%rsi), %rax
movq %rsi, %rdi
movq %r8, %rsi
callq *0x40(%rax)
movsd %xmm0, 0x8(%rsp)
movq (%r14), %rax
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq *0xb0(%rax)
movq %rbp, %rdi
movq %r13, %rsi
callq 0x76fea
movapd %xmm0, %xmm1
leaq 0xfda87(%rip), %rax     # 0x1400d8
movsd (%rax), %xmm0
ucomisd %xmm1, %xmm0
jae 0x427b1
movapd %xmm1, %xmm0
addsd %xmm1, %xmm0
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movsd %xmm1, 0x10(%rsp)
callq 0x77722
leaq 0x80(%rsp), %rbp
leaq 0x50(%rsp), %rdx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x77a2b
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq (%rsp), %rsi
movq %r12, %rdx
callq 0x7651c
movq %r13, %rdi
callq 0x77074
movq %r13, %rdi
movq %rbp, %rsi
callq 0x76fea
movsd %xmm0, (%rsp)
movsd 0x10(%rsp), %xmm2
mulsd 0x8(%rsp), %xmm2
movsd 0x38(%r15), %xmm0
mulsd %xmm2, %xmm0
movsd 0x40(%r15), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x48(%r15), %xmm2
leaq 0x20(%rsp), %r12
movq %r12, %rdi
callq 0x88530
movsd (%r12), %xmm0
movsd 0x8(%r12), %xmm1
mulsd 0x30(%r14), %xmm0
mulsd 0x38(%r14), %xmm1
movsd 0x10(%r12), %xmm2
mulsd 0x40(%r14), %xmm2
movq %rbx, %rdi
callq 0x88530
movsd (%rsp), %xmm0
leaq 0xfd9aa(%rip), %rax     # 0x1400d8
ucomisd (%rax), %xmm0
jbe 0x427c0
movsd 0x18(%rsp), %xmm1
callq 0x220a0
movsd 0x8(%rsp), %xmm2
mulsd %xmm0, %xmm2
movsd 0x50(%r15), %xmm0
mulsd %xmm2, %xmm0
movsd 0x58(%r15), %xmm1
mulsd %xmm2, %xmm1
mulsd 0x60(%r15), %xmm2
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x88530
movsd (%r15), %xmm0
movsd 0x8(%r15), %xmm1
mulsd 0x30(%r14), %xmm0
mulsd 0x38(%r14), %xmm1
movsd 0x10(%r15), %xmm2
mulsd 0x40(%r14), %xmm2
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x88530
movq %rbx, %rdi
movq %r14, %rsi
callq 0x885e2
jmp 0x427c0
leaq 0x105e28(%rip), %rsi    # 0x1485e0
movq %rbx, %rdi
callq 0x88512
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop