#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 /*<<< orphan*/ acos(int);
int cos(double);
double deg2rad(double);
double rad2deg(int /*<<< orphan*/);
int sin(double);
double surface_incidence_angle(double zenith, double azimuth_astro,
                               double azm_rotation, double slope) {
  double zenith_rad = deg2rad(zenith);
  double slope_rad = deg2rad(slope);
  return rad2deg(acos(cos(zenith_rad) * cos(slope_rad) +
                      sin(slope_rad) * sin(zenith_rad) *
                          cos(deg2rad(azimuth_astro - azm_rotation))));
}


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

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

LLVM IR (-O0):
define double @surface_incidence_angle(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* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%11 = load double, double* %5
%12 = call double @deg2rad(double %11)
store double %12, double* %9
%13 = load double, double* %8
%14 = call double @deg2rad(double %13)
store double %14, double* %10
%15 = load double, double* %9
%16 = call i32 @cos(double %15)
%17 = load double, double* %10
%18 = call i32 @cos(double %17)
%19 = mul nsw i32 %16, %18
%20 = load double, double* %10
%21 = call i32 @sin(double %20)
%22 = load double, double* %9
%23 = call i32 @sin(double %22)
%24 = mul nsw i32 %21, %23
%25 = load double, double* %6
%26 = load double, double* %7
%27 = fsub double %25, %26
%28 = call double @deg2rad(double %27)
%29 = call i32 @cos(double %28)
%30 = mul nsw i32 %24, %29
%31 = add nsw i32 %19, %30
%32 = call i32 @acos(i32 %31)
%33 = call double @rad2deg(i32 %32)
ret double %33
}

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