#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 */
int cos(double);
double fabs(int);
int sin(double);
double CosBeta(double beamHeight, double beamAzimuth, double leafInclination,
               double leafAzimuth) {
  double dotProduct = 0;
  dotProduct = fabs(cos(leafInclination) * sin(beamHeight) +
                    sin(leafInclination) * cos(beamHeight) *
                        cos(leafAzimuth - beamAzimuth));
  return dotProduct;
}


x86 assembly (clang, -O0):
<CosBeta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
mov    %eax,-0x34(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
imul   %ecx,%eax
add    %eax,%edi
call   1030 <fabs@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CosBeta>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
movaps %xmm2,%xmm0
call   1050 <cos@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
imul   %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
movsd  0x20(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
imul   %eax,%ebp
add    %ebx,%ebp
mov    %ebp,%edi
add    $0x28,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fabs@plt>

LLVM IR (-O0):
define double @CosBeta(double %0, double %1, double %2, double %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
store double 0.000000e+00, double* %9
%10 = load double, double* %7
%11 = call i32 @cos(double %10)
%12 = load double, double* %5
%13 = call i32 @sin(double %12)
%14 = mul nsw i32 %11, %13
%15 = load double, double* %7
%16 = call i32 @sin(double %15)
%17 = load double, double* %5
%18 = call i32 @cos(double %17)
%19 = mul nsw i32 %16, %18
%20 = load double, double* %8
%21 = load double, double* %6
%22 = fsub double %20, %21
%23 = call i32 @cos(double %22)
%24 = mul nsw i32 %19, %23
%25 = add nsw i32 %14, %24
%26 = call double @fabs(i32 %25)
store double %26, double* %9
%27 = load double, double* %9
ret double %27
}

LLVM IR (-O2):
define double @CosBeta(double %0, double %1, double %2, double %3) {
%5 = tail call i32 @cos(double %2)
%6 = tail call i32 @sin(double %0)
%7 = mul nsw i32 %6, %5
%8 = tail call i32 @sin(double %2)
%9 = tail call i32 @cos(double %0)
%10 = mul nsw i32 %9, %8
%11 = fsub double %3, %1
%12 = tail call i32 @cos(double %11)
%13 = mul nsw i32 %10, %12
%14 = add nsw i32 %13, %7
%15 = tail call double @fabs(i32 %14)
ret double %15
}