#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 *);
double *scaleVector(int /*<<< orphan*/, double);
double *diffuse(double *objDiffuse, double *lightColor, double *N, double *L) {
  double NL = dotProduct(N, L);
  if (NL > 0) {
    return scaleVector(multVector(objDiffuse, lightColor), NL);
  }
  return getVector(0, 0, 0);
}


x86 assembly (clang, -O0):
<diffuse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <dotProduct@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    119e <diffuse+0x5e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <multVector@plt>
mov    %eax,%edi
movsd  -0x30(%rbp),%xmm0
call   1050 <scaleVector@plt>
mov    %rax,-0x8(%rbp)
jmp    11ad <diffuse+0x6d>
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1030 <getVector@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diffuse>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
mov    %rcx,%rsi
call   1040 <dotProduct@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1182 <diffuse+0x42>
mov    %rbx,%rdi
mov    %r14,%rsi
movsd  %xmm0,(%rsp)
call   1060 <multVector@plt>
mov    %eax,%edi
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <scaleVector@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <getVector@plt>

LLVM IR (-O0):
define double* @diffuse(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
%11 = load double*, double** %8
%12 = load double*, double** %9
%13 = call double @dotProduct(double* %11, double* %12)
store double %13, double* %10
%14 = load double, double* %10
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %22
16: ; preds = %4
%17 = load double*, double** %6
%18 = load double*, double** %7
%19 = call i32 @multVector(double* %17, double* %18)
%20 = load double, double* %10
%21 = call double* @scaleVector(i32 %19, double %20)
store double* %21, double** %5
br label %24
22: ; preds = %4
%23 = call double* @getVector(i32 0, i32 0, i32 0)
store double* %23, double** %5
br label %24
24: ; preds = %22, %16
%25 = load double*, double** %5
ret double* %25
}

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