#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 sin(double);
int tan(double);
double Kin(double doy, double lat, double tsw) {
  double dr, ra, latrad, deltarad, ws;
  dr = 1 + 0.033 * cos(2 * 3.1415927 / 365.0 * doy);
  latrad = lat * 3.1415927 / 180.0;
  deltarad = 0.409 * sin(2 * 3.1415927 / 365 * doy - 1.39);
  ws = acos(-tan(latrad) * tan(deltarad));
  ra = 1366.6 * dr *
       (ws * sin(latrad) * sin(deltarad) +
        cos(latrad) * cos(deltarad) * sin(ws));
  double result = tsw * ra;
  return (result);
}


x86 assembly (clang, -O0):
<Kin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  0xeae(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
movsd  0xebc(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe97(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe58(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xe34(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <tan@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x7c(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <tan@plt>
mov    -0x7c(%rbp),%edi
imul   %eax,%edi
call   1030 <acos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xdee(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x68(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm3
movaps %xmm0,%xmm4
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Kin>:
push   %rbx
sub    $0x40,%rsp
movsd  %xmm2,0x38(%rsp)
movsd  %xmm1,0x8(%rsp)
mulsd  0xea7(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1060 <cos@plt>
mulsd  0xe9c(%rip),%xmm0
addsd  0xe9c(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe90(%rip),%xmm0
divsd  0xe90(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xe84(%rip),%xmm0
call   1040 <sin@plt>
mulsd  0xe7f(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <tan@plt>
mov    %eax,%ebx
movsd  0x10(%rsp),%xmm0
call   1050 <tan@plt>
imul   %eax,%ebx
neg    %ebx
mov    %ebx,%edi
call   1030 <acos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe49(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0x30(%rsp),%xmm1
addsd  %xmm1,%xmm0
mulsd  0x18(%rsp),%xmm0
mulsd  0x38(%rsp),%xmm0
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @Kin(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
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%13 = load double, double* %4
%14 = fmul double 0x3F91A099D9121BC4, %13
%15 = call double @cos(double %14)
%16 = call double @llvm.fmuladd.f64(double 3.300000e-02, double %15, double 1.000000e+00)
store double %16, double* %7
%17 = load double, double* %5
%18 = fmul double %17, 0x400921FB5A7ED197
%19 = fdiv double %18, 1.800000e+02
store double %19, double* %9
%20 = load double, double* %4
%21 = call double @llvm.fmuladd.f64(double 0x3F91A099D9121BC4, double %20, double -1.390000e+00)
%22 = call double @sin(double %21)
%23 = fmul double 4.090000e-01, %22
store double %23, double* %10
%24 = load double, double* %9
%25 = call i32 @tan(double %24)
%26 = sub nsw i32 0, %25
%27 = load double, double* %10
%28 = call i32 @tan(double %27)
%29 = mul nsw i32 %26, %28
%30 = call double @acos(i32 %29)
store double %30, double* %11
%31 = load double, double* %7
%32 = fmul double 1.366600e+03, %31
%33 = load double, double* %11
%34 = load double, double* %9
%35 = call double @sin(double %34)
%36 = fmul double %33, %35
%37 = load double, double* %10
%38 = call double @sin(double %37)
%39 = load double, double* %9
%40 = call double @cos(double %39)
%41 = load double, double* %10
%42 = call double @cos(double %41)
%43 = fmul double %40, %42
%44 = load double, double* %11
%45 = call double @sin(double %44)
%46 = fmul double %43, %45
%47 = call double @llvm.fmuladd.f64(double %36, double %38, double %46)
%48 = fmul double %32, %47
store double %48, double* %8
%49 = load double, double* %6
%50 = load double, double* %8
%51 = fmul double %49, %50
store double %51, double* %12
%52 = load double, double* %12
ret double %52
}

LLVM IR (-O2):
define double @Kin(double %0, double %1, double %2) {
%4 = fmul double %0, 0x3F91A099D9121BC4
%5 = tail call double @cos(double %4)
%6 = tail call double @llvm.fmuladd.f64(double %5, double 3.300000e-02, double 1.000000e+00)
%7 = fmul double %1, 0x400921FB5A7ED197
%8 = fdiv double %7, 1.800000e+02
%9 = tail call double @llvm.fmuladd.f64(double %0, double 0x3F91A099D9121BC4, double -1.390000e+00)
%10 = tail call double @sin(double %9)
%11 = fmul double %10, 4.090000e-01
%12 = tail call i32 @tan(double %8)
%13 = tail call i32 @tan(double %11)
%14 = mul i32 %12, %13
%15 = sub i32 0, %14
%16 = tail call double @acos(i32 %15)
%17 = fmul double %6, 1.366600e+03
%18 = tail call double @sin(double %8)
%19 = fmul double %16, %18
%20 = tail call double @sin(double %11)
%21 = tail call double @cos(double %8)
%22 = tail call double @cos(double %11)
%23 = fmul double %21, %22
%24 = tail call double @sin(double %16)
%25 = fmul double %23, %24
%26 = tail call double @llvm.fmuladd.f64(double %19, double %20, double %25)
%27 = fmul double %17, %26
%28 = fmul double %27, %2
ret double %28
}