#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(int);
double cos(double);
double k_exo(double);
double sin(double);
int tan(double);
double solar_day(double lat, double doy, double dem) {
  double tsw, ws, cosun, latrad, deltarad, ds;
  double Kexo;
  tsw = 0.7;
  Kexo = k_exo(doy);
  ds = 1.0 + 0.01672 * sin(2 * 3.1415927 * (doy - 93.5) / 365.0);
  latrad = lat * 3.1415927 / 180.0;
  deltarad = (0.4093 * sin((2 * 3.1415927 * doy / 365) - 1.39));
  ws = (acos(-tan(latrad) * tan(deltarad)));
  cosun = sin(deltarad) * sin(latrad) + cos(deltarad) * cos(latrad) * sin(ws);
  return (ws * cosun * Kexo * tsw) / (3.1415927 * ds * ds);
}


x86 assembly (clang, -O0):
<solar_day>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xed6(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <k_exo@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xead(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xe81(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movsd  0xe74(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe70(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe27(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe29(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe14(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe00(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xde4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <tan@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x74(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <tan@plt>
mov    -0x74(%rbp),%edi
imul   %eax,%edi
call   1040 <acos@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  -0x68(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xd15(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solar_day>:
push   %rbx
sub    $0x40,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
movaps %xmm1,%xmm0
call   1030 <k_exo@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0xe89(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
mulsd  0xe83(%rip),%xmm0
divsd  0xe83(%rip),%xmm0
call   1050 <sin@plt>
mulsd  0xe7e(%rip),%xmm0
addsd  0xe7e(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe72(%rip),%xmm0
divsd  0xe72(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe36(%rip),%xmm0
divsd  0xe36(%rip),%xmm0
addsd  0xe56(%rip),%xmm0
call   1050 <sin@plt>
mulsd  0xe51(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <tan@plt>
mov    %eax,%ebx
movsd  0x8(%rsp),%xmm0
call   1060 <tan@plt>
imul   %eax,%ebx
neg    %ebx
mov    %ebx,%edi
call   1040 <acos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1070 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x28(%rsp),%xmm1
addsd  %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  0x38(%rsp),%xmm0
mulsd  0xdaa(%rip),%xmm0
movsd  0xd82(%rip),%xmm1
movsd  0x30(%rsp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @solar_day(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
%11 = alloca double
%12 = alloca double
%13 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store double 0x3FE6666666666666, double* %7
%14 = load double, double* %5
%15 = call double @k_exo(double %14)
store double %15, double* %13
%16 = load double, double* %5
%17 = fsub double %16, 9.350000e+01
%18 = fmul double 0x401921FB5A7ED197, %17
%19 = fdiv double %18, 3.650000e+02
%20 = call double @sin(double %19)
%21 = call double @llvm.fmuladd.f64(double 1.672000e-02, double %20, double 1.000000e+00)
store double %21, double* %12
%22 = load double, double* %4
%23 = fmul double %22, 0x400921FB5A7ED197
%24 = fdiv double %23, 1.800000e+02
store double %24, double* %10
%25 = load double, double* %5
%26 = fmul double 0x401921FB5A7ED197, %25
%27 = fdiv double %26, 3.650000e+02
%28 = fsub double %27, 1.390000e+00
%29 = call double @sin(double %28)
%30 = fmul double 4.093000e-01, %29
store double %30, double* %11
%31 = load double, double* %10
%32 = call i32 @tan(double %31)
%33 = sub nsw i32 0, %32
%34 = load double, double* %11
%35 = call i32 @tan(double %34)
%36 = mul nsw i32 %33, %35
%37 = call double @acos(i32 %36)
store double %37, double* %8
%38 = load double, double* %11
%39 = call double @sin(double %38)
%40 = load double, double* %10
%41 = call double @sin(double %40)
%42 = load double, double* %11
%43 = call double @cos(double %42)
%44 = load double, double* %10
%45 = call double @cos(double %44)
%46 = fmul double %43, %45
%47 = load double, double* %8
%48 = call double @sin(double %47)
%49 = fmul double %46, %48
%50 = call double @llvm.fmuladd.f64(double %39, double %41, double %49)
store double %50, double* %9
%51 = load double, double* %8
%52 = load double, double* %9
%53 = fmul double %51, %52
%54 = load double, double* %13
%55 = fmul double %53, %54
%56 = load double, double* %7
%57 = fmul double %55, %56
%58 = load double, double* %12
%59 = fmul double 0x400921FB5A7ED197, %58
%60 = load double, double* %12
%61 = fmul double %59, %60
%62 = fdiv double %57, %61
ret double %62
}

LLVM IR (-O2):
define double @solar_day(double %0, double %1, double %2) {
%4 = tail call double @k_exo(double %1)
%5 = fadd double %1, -9.350000e+01
%6 = fmul double %5, 0x401921FB5A7ED197
%7 = fdiv double %6, 3.650000e+02
%8 = tail call double @sin(double %7)
%9 = tail call double @llvm.fmuladd.f64(double %8, double 1.672000e-02, double 1.000000e+00)
%10 = fmul double %0, 0x400921FB5A7ED197
%11 = fdiv double %10, 1.800000e+02
%12 = fmul double %1, 0x401921FB5A7ED197
%13 = fdiv double %12, 3.650000e+02
%14 = fadd double %13, -1.390000e+00
%15 = tail call double @sin(double %14)
%16 = fmul double %15, 4.093000e-01
%17 = tail call i32 @tan(double %11)
%18 = tail call i32 @tan(double %16)
%19 = mul i32 %17, %18
%20 = sub i32 0, %19
%21 = tail call double @acos(i32 %20)
%22 = tail call double @sin(double %16)
%23 = tail call double @sin(double %11)
%24 = tail call double @cos(double %16)
%25 = tail call double @cos(double %11)
%26 = fmul double %24, %25
%27 = tail call double @sin(double %21)
%28 = fmul double %26, %27
%29 = tail call double @llvm.fmuladd.f64(double %22, double %23, double %28)
%30 = fmul double %21, %29
%31 = fmul double %4, %30
%32 = fmul double %31, 0x3FE6666666666666
%33 = fmul double %9, 0x400921FB5A7ED197
%34 = fmul double %9, %33
%35 = fdiv double %32, %34
ret double %35
}