#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 LAT(int, int, double, double);
double acos(double);
double cos(double);
double declination(int);
double hour_angle(int);
double sin(double);
double solar_zenith(int, int, double, double, double);
double solar_azimuth(int time, int day, double latitude, double longitude,
                     double long_std) {
  double theta = 0, omega = 0, delta = 0, phi = latitude * 3.1415926 / 180.0,
         psi = 0, cospsi = 0;
  int lat = LAT(time, day, longitude, long_std);
  delta = 3.1415926 / 180.0 * declination(day);
  omega = 3.1415926 / 180.0 * hour_angle(lat);
  theta = 3.1415926 / 180.0 *
          solar_zenith(time, day, latitude, longitude, long_std);
  cospsi = (cos(theta) * sin(phi) - sin(delta)) / sin(theta) / cos(phi);
  if (cospsi > 1.0 && cospsi < 1.0 + 1e-6)
    cospsi = 1.0;
  if (cospsi < -1.0 && cospsi > -1.0 - 1e-6)
    cospsi = -1.0;
  psi = -acos(cospsi);
  if (lat > 43200 || lat < 0)
    psi = -psi;
  psi *= (180.0 / 3.1415926);
  return psi;
}


x86 assembly (clang, -O0):
<solar_azimuth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe68(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <LAT@plt>
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <declination@plt>
movaps %xmm0,%xmm1
movsd  0xe07(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x54(%rbp),%edi
call   1070 <hour_angle@plt>
movaps %xmm0,%xmm1
movsd  0xdeb(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1090 <solar_zenith@plt>
movaps %xmm0,%xmm1
movsd  0xdbd(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x78(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xd10(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    131a <solar_azimuth+0x1aa>
movsd  0xd1e(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    131a <solar_azimuth+0x1aa>
movsd  0xceb(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd06(%rip),%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1351 <solar_azimuth+0x1e1>
movsd  -0x50(%rbp),%xmm0
movsd  0xcf6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1351 <solar_azimuth+0x1e1>
movsd  0xcdc(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <acos@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0xa8c0,-0x54(%rbp)
jg     138e <solar_azimuth+0x21e>
cmpl   $0x0,-0x54(%rbp)
jge    13af <solar_azimuth+0x23f>
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xc81(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solar_azimuth>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
mov    %esi,%ebp
mov    %edi,%ebx
movsd  0xe6b(%rip),%xmm3
mulsd  %xmm0,%xmm3
divsd  0xe67(%rip),%xmm3
movsd  %xmm3,0x20(%rsp)
movapd %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1040 <LAT@plt>
mov    %eax,%r14d
mov    %ebp,%edi
call   1080 <declination@plt>
mulsd  0xe4b(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
mov    %r14d,%edi
call   1070 <hour_angle@plt>
mov    %ebx,%edi
mov    %ebp,%esi
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1090 <solar_zenith@plt>
mulsd  0xe1b(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1060 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,(%rsp)
movsd  0x28(%rsp),%xmm0
call   1050 <sin@plt>
movapd (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <sin@plt>
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <cos@plt>
movapd (%rsp),%xmm3
divsd  %xmm0,%xmm3
movsd  0xdaf(%rip),%xmm0
movapd %xmm3,%xmm1
cmpltsd 0xdaa(%rip),%xmm1
movapd %xmm1,%xmm2
andpd  %xmm0,%xmm1
cmpltsd %xmm3,%xmm0
andnpd %xmm3,%xmm2
orpd   %xmm2,%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm0,%xmm1
movsd  0xd89(%rip),%xmm2
movapd %xmm1,%xmm3
cmpltsd %xmm2,%xmm3
movsd  0xd80(%rip),%xmm0
cmpltsd %xmm1,%xmm0
movapd %xmm0,%xmm4
andnpd %xmm1,%xmm4
andpd  %xmm2,%xmm0
orpd   %xmm4,%xmm0
andpd  %xmm3,%xmm0
andnpd %xmm1,%xmm3
orpd   %xmm3,%xmm0
call   1030 <acos@plt>
cmp    $0xa8c1,%r14d
jae    12e7 <solar_azimuth+0x177>
xorpd  0xd59(%rip),%xmm0
mulsd  0xd49(%rip),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @solar_azimuth(i32 %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca i32
%7 = alloca i32
%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 i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
%18 = load double, double* %8
%19 = fmul double %18, 0x400921FB4D12D84A
%20 = fdiv double %19, 1.800000e+02
store double %20, double* %14
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %16
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = load double, double* %9
%24 = load double, double* %10
%25 = call i32 @LAT(i32 %21, i32 %22, double %23, double %24)
store i32 %25, i32* %17
%26 = load i32, i32* %7
%27 = call double @declination(i32 %26)
%28 = fmul double 0x3F91DF469D353918, %27
store double %28, double* %13
%29 = load i32, i32* %17
%30 = call double @hour_angle(i32 %29)
%31 = fmul double 0x3F91DF469D353918, %30
store double %31, double* %12
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load double, double* %8
%35 = load double, double* %9
%36 = load double, double* %10
%37 = call double @solar_zenith(i32 %32, i32 %33, double %34, double %35, double %36)
%38 = fmul double 0x3F91DF469D353918, %37
store double %38, double* %11
%39 = load double, double* %11
%40 = call double @cos(double %39)
%41 = load double, double* %14
%42 = call double @sin(double %41)
%43 = load double, double* %13
%44 = call double @sin(double %43)
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %40, double %42, double %45)
%47 = load double, double* %11
%48 = call double @sin(double %47)
%49 = fdiv double %46, %48
%50 = load double, double* %14
%51 = call double @cos(double %50)
%52 = fdiv double %49, %51
store double %52, double* %16
%53 = load double, double* %16
%54 = fcmp ogt double %53, 1.000000e+00
br i1 %54, label %55, label %59
55: ; preds = %5
%56 = load double, double* %16
%57 = fcmp olt double %56, 0x3FF000010C6F7A0B
br i1 %57, label %58, label %59
58: ; preds = %55
store double 1.000000e+00, double* %16
br label %59
59: ; preds = %58, %55, %5
%60 = load double, double* %16
%61 = fcmp olt double %60, -1.000000e+00
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load double, double* %16
%64 = fcmp ogt double %63, 0xBFF000010C6F7A0B
br i1 %64, label %65, label %66
65: ; preds = %62
store double -1.000000e+00, double* %16
br label %66
66: ; preds = %65, %62, %59
%67 = load double, double* %16
%68 = call double @acos(double %67)
%69 = fneg double %68
store double %69, double* %15
%70 = load i32, i32* %17
%71 = icmp sgt i32 %70, 43200
br i1 %71, label %75, label %72
72: ; preds = %66
%73 = load i32, i32* %17
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %72, %66
%76 = load double, double* %15
%77 = fneg double %76
store double %77, double* %15
br label %78
78: ; preds = %75, %72
%79 = load double, double* %15
%80 = fmul double %79, 0x404CA5DC22969FAA
store double %80, double* %15
%81 = load double, double* %15
ret double %81
}

LLVM IR (-O2):
define double @solar_azimuth(i32 %0, i32 %1, double %2, double %3, double %4) {
%6 = fmul double %2, 0x400921FB4D12D84A
%7 = fdiv double %6, 1.800000e+02
%8 = tail call i32 @LAT(i32 %0, i32 %1, double %3, double %4)
%9 = tail call double @declination(i32 %1)
%10 = fmul double %9, 0x3F91DF469D353918
%11 = tail call double @hour_angle(i32 %8)
%12 = tail call double @solar_zenith(i32 %0, i32 %1, double %2, double %3, double %4)
%13 = fmul double %12, 0x3F91DF469D353918
%14 = tail call double @cos(double %13)
%15 = tail call double @sin(double %7)
%16 = tail call double @sin(double %10)
%17 = fneg double %16
%18 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %17)
%19 = tail call double @sin(double %13)
%20 = fdiv double %18, %19
%21 = tail call double @cos(double %7)
%22 = fdiv double %20, %21
%23 = fcmp ogt double %22, 1.000000e+00
%24 = fcmp olt double %22, 0x3FF000010C6F7A0B
%25 = and i1 %23, %24
%26 = select i1 %25, double 1.000000e+00, double %22
%27 = fcmp olt double %26, -1.000000e+00
%28 = fcmp ogt double %26, 0xBFF000010C6F7A0B
%29 = and i1 %27, %28
%30 = select i1 %29, double -1.000000e+00, double %26
%31 = tail call double @acos(double %30)
%32 = fneg double %31
%33 = icmp ugt i32 %8, 43200
%34 = select i1 %33, double %31, double %32
%35 = fmul double %34, 0x404CA5DC22969FAA
ret double %35
}