// File: /workspace/github_c_makefile_star2_O0/archer1357[P]Offline-Raytracer/utils.c
// Function: calc_pointLight
void calc_pointLight(const struct PointLight *pointLight,
                     const float *toLightDir,
                     float lightDist,
                     const float *rayDir,
                     float shininess,float intensity,
                     const float *nor,
                     float *outCol,float *outSpec) {

  float fromLightDir[3],atten,eyeDir[3],reflectVec[3],NdotL,spec,diffuse;

  //
  vec3_mulScalar(fromLightDir,toLightDir,-1.0f);

  atten = 1.0f/(pointLight->constAtten+
                pointLight->linAtten*lightDist+
                pointLight->quadAtten*lightDist*lightDist);

  vec3_mulScalar(eyeDir,rayDir,-1.0f);

  reflect(reflectVec,fromLightDir,nor);

  NdotL = maxOf(0.0f, vec3_dot(nor, toLightDir));

  spec=0.0f;

  if(NdotL > 0.0f) {
    float EdotR;

    EdotR=maxOf(0.0f, vec3_dot(eyeDir, reflectVec));
    spec+=powf(EdotR,shininess*128.0f) *intensity;
    spec*=atten;
  }

  diffuse=NdotL*atten;

  outCol[0]=pointLight->col[0]*diffuse;
  outCol[1]=pointLight->col[1]*diffuse;
  outCol[2]=pointLight->col[2]*diffuse;

  *outSpec=spec;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movss %xmm1, -0x24(%rbp)
movss %xmm2, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
leaq -0x4c(%rbp), %rdi
movq -0x10(%rbp), %rsi
movss 0xc2052(%rip), %xmm0    # 0x4e4c04
callq 0x40cb40
movq -0x8(%rbp), %rax
movss 0x18(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x1c(%rax), %xmm0
movss -0x14(%rbp), %xmm2
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss 0x20(%rax), %xmm1
mulss -0x14(%rbp), %xmm1
movss -0x14(%rbp), %xmm2
mulss %xmm2, %xmm1
addss %xmm0, %xmm1
movss 0xc088b(%rip), %xmm0    # 0x4e3484
divss %xmm1, %xmm0
movss %xmm0, -0x50(%rbp)
leaq -0x5c(%rbp), %rdi
movq -0x20(%rbp), %rsi
movss 0xc1ff2(%rip), %xmm0    # 0x4e4c04
callq 0x40cb40
leaq -0x68(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x40dad0
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x40c970
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x40dbf0
movss %xmm0, -0x6c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x6c(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x422cb4
leaq -0x5c(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x40c970
movaps %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0x40dbf0
movss %xmm0, -0x78(%rbp)
movss -0x78(%rbp), %xmm0
movss 0xc07f0(%rip), %xmm1    # 0x4e3474
mulss -0x24(%rbp), %xmm1
callq 0x401038
movss -0x28(%rbp), %xmm2
movss -0x70(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x50(%rbp), %xmm0
mulss -0x70(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x6c(%rbp), %xmm0
mulss -0x50(%rbp), %xmm0
movss %xmm0, -0x74(%rbp)
movq -0x8(%rbp), %rax
movss (%rax), %xmm0
mulss -0x74(%rbp), %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, (%rax)
movq -0x8(%rbp), %rax
movss 0x4(%rax), %xmm0
mulss -0x74(%rbp), %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x4(%rax)
movq -0x8(%rbp), %rax
movss 0x8(%rax), %xmm0
mulss -0x74(%rbp), %xmm0
movq -0x38(%rbp), %rax
movss %xmm0, 0x8(%rax)
movss -0x70(%rbp), %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)