#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 acos(double);
double cosZ(double);
double cos_dec(double);
double cos_lat(double);
double sin_dec(double);
double sin_lat(double);
double sun(double zenith, double dec_sun, double lat) {
  double top = cosZ(zenith) - sin_dec(dec_sun) * sin_lat(lat);
  double bot = cos_dec(dec_sun) * cos_lat(lat);
  double ca = top / bot;
  double c = (ca > 1.0 || ca < -1.0) ? 1.0 : ca;
  return acos(c);
}


x86 assembly (clang, -O0):
<sun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <cosZ@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1080 <sin_dec@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <sin_lat@plt>
movsd  -0x50(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos_dec@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1060 <cos_lat@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdea(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1233 <sun+0xd3>
movsd  0xde0(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1245 <sun+0xe5>
movsd  0xdc5(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    124f <sun+0xef>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <acos@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun>:
sub    $0x28,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <cosZ@plt>
movaps %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1080 <sin_dec@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <sin_lat@plt>
mulsd  0x20(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1050 <cos_dec@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos_lat@plt>
mulsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm1
cmpltsd 0xe20(%rip),%xmm1
movapd %xmm1,%xmm0
andnpd %xmm2,%xmm0
movapd %xmm2,%xmm3
movsd  0xe14(%rip),%xmm2
andpd  %xmm2,%xmm1
orpd   %xmm0,%xmm1
movapd %xmm2,%xmm0
cmpltsd %xmm3,%xmm0
movapd %xmm0,%xmm3
andnpd %xmm1,%xmm3
andpd  %xmm2,%xmm0
orpd   %xmm3,%xmm0
add    $0x28,%rsp
jmp    1040 <acos@plt>

LLVM IR (-O0):
define double @sun(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%11 = load double, double* %4
%12 = call double @cosZ(double %11)
%13 = load double, double* %5
%14 = call double @sin_dec(double %13)
%15 = load double, double* %6
%16 = call double @sin_lat(double %15)
%17 = fneg double %14
%18 = call double @llvm.fmuladd.f64(double %17, double %16, double %12)
store double %18, double* %7
%19 = load double, double* %5
%20 = call double @cos_dec(double %19)
%21 = load double, double* %6
%22 = call double @cos_lat(double %21)
%23 = fmul double %20, %22
store double %23, double* %8
%24 = load double, double* %7
%25 = load double, double* %8
%26 = fdiv double %24, %25
store double %26, double* %9
%27 = load double, double* %9
%28 = fcmp ogt double %27, 1.000000e+00
br i1 %28, label %32, label %29
29: ; preds = %3
%30 = load double, double* %9
%31 = fcmp olt double %30, -1.000000e+00
br i1 %31, label %32, label %33
32: ; preds = %29, %3
br label %35
33: ; preds = %29
%34 = load double, double* %9
br label %35
35: ; preds = %33, %32
%36 = phi double [ 1.000000e+00, %32 ], [ %34, %33 ]
store double %36, double* %10
%37 = load double, double* %10
%38 = call double @acos(double %37)
ret double %38
}

LLVM IR (-O2):
define double @sun(double %0, double %1, double %2) {
%4 = tail call double @cosZ(double %0)
%5 = tail call double @sin_dec(double %1)
%6 = tail call double @sin_lat(double %2)
%7 = fneg double %5
%8 = tail call double @llvm.fmuladd.f64(double %7, double %6, double %4)
%9 = tail call double @cos_dec(double %1)
%10 = tail call double @cos_lat(double %2)
%11 = fmul double %9, %10
%12 = fdiv double %8, %11
%13 = fcmp ogt double %12, 1.000000e+00
%14 = fcmp olt double %12, -1.000000e+00
%15 = or i1 %13, %14
%16 = select i1 %15, double 1.000000e+00, double %12
%17 = tail call double @acos(double %16)
ret double %17
}