#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double dotProduct(double *, double *);
double *getVector(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ multVector(double *, double *);
int /*<<< orphan*/ pow(double, double);
double *scaleVector(int /*<<< orphan*/, int /*<<< orphan*/);
double *specular(double *objSpecular, double *lightColor, double *R, double *V,
                 double *N, double *L, double shininess) {
  double RV = dotProduct(R, V);
  double NL = dotProduct(N, L);
  if (NL > 0 && RV > 0) {
    return scaleVector(multVector(objSpecular, lightColor), pow(RV, shininess));
  }
  return getVector(0, 0, 0);
}


x86 assembly (clang, -O0):
<specular>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <dotProduct@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <dotProduct@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ef <specular+0x9f>
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ef <specular+0x9f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <multVector@plt>
mov    %eax,-0x54(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1060 <pow@plt>
mov    -0x54(%rbp),%edi
mov    %eax,%esi
call   1050 <scaleVector@plt>
mov    %rax,-0x8(%rbp)
jmp    11fe <specular+0xae>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1030 <getVector@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<specular>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
mov    %r9,%r12
mov    %r8,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rdi
mov    %rcx,%rsi
call   1040 <dotProduct@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <dotProduct@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11d1 <specular+0x81>
movsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d1 <specular+0x81>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <multVector@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1060 <pow@plt>
mov    %ebx,%edi
mov    %eax,%esi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <scaleVector@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <getVector@plt>

LLVM IR (-O0):
define double* @specular(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double* %0, double** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store double* %4, double** %13
store double* %5, double** %14
store double %6, double* %15
%18 = load double*, double** %11
%19 = load double*, double** %12
%20 = call double @dotProduct(double* %18, double* %19)
store double %20, double* %16
%21 = load double*, double** %13
%22 = load double*, double** %14
%23 = call double @dotProduct(double* %21, double* %22)
store double %23, double* %17
%24 = load double, double* %17
%25 = fcmp ogt double %24, 0.000000e+00
br i1 %25, label %26, label %37
26: ; preds = %7
%27 = load double, double* %16
%28 = fcmp ogt double %27, 0.000000e+00
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load double*, double** %9
%31 = load double*, double** %10
%32 = call i32 @multVector(double* %30, double* %31)
%33 = load double, double* %16
%34 = load double, double* %15
%35 = call i32 @pow(double %33, double %34)
%36 = call double* @scaleVector(i32 %32, i32 %35)
store double* %36, double** %8
br label %39
37: ; preds = %26, %7
%38 = call double* @getVector(i32 0, i32 0, i32 0)
store double* %38, double** %8
br label %39
39: ; preds = %37, %29
%40 = load double*, double** %8
ret double* %40
}

LLVM IR (-O2):
define double* @specular(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double %6) {
%8 = tail call double @dotProduct(double* %2, double* %3)
%9 = tail call double @dotProduct(double* %4, double* %5)
%10 = fcmp ogt double %9, 0.000000e+00
%11 = fcmp ogt double %8, 0.000000e+00
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = tail call i32 @multVector(double* %0, double* %1)
%15 = tail call i32 @pow(double %8, double %6)
%16 = tail call double* @scaleVector(i32 %14, i32 %15)
br label %19
17: ; preds = %7
%18 = tail call double* @getVector(i32 0, i32 0, i32 0)
br label %19
19: ; preds = %17, %13
%20 = phi double* [ %16, %13 ], [ %18, %17 ]
ret double* %20
}