#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 */
struct tm {
  int tm_mday;
  int tm_mon;
  int tm_year;
  int tm_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ acos(double);
double adjust_to_range(double, int /*<<< orphan*/, int);
int /*<<< orphan*/ asin(double);
int /*<<< orphan*/ atan(double);
int calculate_day_of_year(int, int, int);
struct tm *calloc(int, int);
double cos(int /*<<< orphan*/);
int floor(double);
double sin(int /*<<< orphan*/);
double tan(int /*<<< orphan*/);
int to_degree(int /*<<< orphan*/);
int /*<<< orphan*/ to_radian(double);
struct tm *calculate_sunrise(bool sunrise, int day, int month, int year,
                             double latitude, double longitude,
                             double local_offset) {
  int day_of_year = calculate_day_of_year(day, month, year);
  double zenith = 90.83333333333333;
  double lngHour = longitude / 15;
  double t;
  if (sunrise) {
    t = day_of_year + ((6 - lngHour) / 24);
  } else {
    t = day_of_year + ((18 - lngHour) / 24);
  }
  double M = (0.9856 * t) - 3.289;
  double L = M + (1.916 * sin(to_radian(M))) + (0.020 * sin(to_radian(2 * M))) +
             282.634;
  L = adjust_to_range(L, 0, 360);
  double RA = to_degree(atan(0.91764 * tan(to_radian(L))));
  RA = adjust_to_range(RA, 0, 360);
  double Lquadrant = (floor(L / 90)) * 90;
  double RAquadrant = (floor(RA / 90)) * 90;
  RA = RA + (Lquadrant - RAquadrant);
  RA = RA / 15;
  double sinDec = 0.39782 * sin(to_radian(L));
  double cosDec = cos(asin(sinDec));
  double cosH = (cos(to_radian(zenith)) - (sinDec * sin(to_radian(latitude)))) /
                (cosDec * cos(to_radian(latitude)));
  if ((cosH > 1) && sunrise) {
    return NULL;
  } else if ((cosH < -1) && !sunrise) {
    return NULL;
  }
  double H;
  if (sunrise) {
    H = 360 - to_degree(acos(cosH));
  } else {
    H = to_degree(acos(cosH));
  }
  H = H / 15;
  double T = H + RA - (0.06571 * t) - 6.622;
  double UTC = T - lngHour;
  UTC = adjust_to_range(UTC, 0, 24);
  double localT = UTC + local_offset;
  struct tm *time = calloc(1, sizeof(struct tm));
  time->tm_mday = day;
  time->tm_mon = month - 1;
  time->tm_year = year - 1900;
  time->tm_hour = floor(localT);
  localT -= time->tm_hour;
  localT *= 60;
  time->tm_min = floor(localT);
  localT -= time->tm_min;
  localT *= 60;
  time->tm_sec = floor(localT);
  return time;
}


x86 assembly (clang, -O0):
<calculate_sunrise>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10a0 <calculate_day_of_year@plt>
mov    %eax,-0x34(%rbp)
movsd  0xe09(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1250 <calculate_sunrise+0x90>
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xdd2(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1277 <calculate_sunrise+0xb7>
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  0xdbb(%rip),%xmm1
subsd  -0x48(%rbp),%xmm1
movsd  0xda6(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  0xde4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movsd  -0xe8(%rbp),%xmm1
ff
movsd  0xd99(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  0xd79(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movsd  -0xe0(%rbp),%xmm1
ff
movsd  0xd50(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd38(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
xor    %edi,%edi
mov    $0x168,%esi
call   10d0 <adjust_to_range@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10b0 <tan@plt>
movaps %xmm0,%xmm1
movsd  0xcf5(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <atan@plt>
mov    %eax,%edi
call   1060 <to_degree@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
xor    %edi,%edi
mov    $0x168,%esi
call   10d0 <adjust_to_range@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xcb1(%rip),%xmm1
divsd  %xmm1,%xmm0
call   10e0 <floor@plt>
imul   $0x5a,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xc8f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   10e0 <floor@plt>
imul   $0x5a,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xc1d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xc28(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
call   1090 <asin@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
movsd  -0xd8(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xd0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
movsd  -0xc8(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xb39(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1510 <calculate_sunrise+0x350>
cmpl   $0x0,-0xc(%rbp)
je     1510 <calculate_sunrise+0x350>
movq   $0x0,-0x8(%rbp)
jmp    173d <calculate_sunrise+0x57d>
movsd  0xb60(%rip),%xmm0
ucomisd -0x90(%rbp),%xmm0
ff
jbe    153d <calculate_sunrise+0x37d>
cmpl   $0x0,-0xc(%rbp)
jne    153d <calculate_sunrise+0x37d>
movq   $0x0,-0x8(%rbp)
jmp    173d <calculate_sunrise+0x57d>
jmp    1542 <calculate_sunrise+0x382>
cmpl   $0x0,-0xc(%rbp)
je     157a <calculate_sunrise+0x3ba>
movsd  -0x90(%rbp),%xmm0
ff
call   1040 <acos@plt>
mov    %eax,%edi
call   1060 <to_degree@plt>
mov    %eax,%ecx
mov    $0x168,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    159a <calculate_sunrise+0x3da>
movsd  -0x90(%rbp),%xmm0
ff
call   1040 <acos@plt>
mov    %eax,%edi
call   1060 <to_degree@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  0xa56(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm1
ff
addsd  -0x68(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xac0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xaa8(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
xor    %edi,%edi
mov    $0x18,%esi
call   10d0 <adjust_to_range@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    $0x1,%edi
mov    $0x18,%esi
call   1050 <calloc@plt>
mov    %rax,-0xb8(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%ecx
sub    $0x76c,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,0x8(%rax)
movsd  -0xb0(%rbp),%xmm0
ff
call   10e0 <floor@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0xb8(%rbp),%rax
cvtsi2sdl 0xc(%rax),%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  0x9c8(%rip),%xmm0
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
call   10e0 <floor@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0xb8(%rbp),%rax
cvtsi2sdl 0x10(%rax),%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
movsd  0x977(%rip),%xmm0
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
call   10e0 <floor@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xb8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_sunrise>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %edi,%ebx
mov    %esi,0x1c(%rsp)
mov    %esi,%edi
mov    %edx,%esi
mov    %ecx,%edx
call   10a0 <calculate_day_of_year@plt>
movsd  0x10(%rsp),%xmm2
divsd  0xdfb(%rip),%xmm2
xor    %r15d,%r15d
mov    %ebx,0x18(%rsp)
test   %ebx,%ebx
setne  %r15b
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xe60(%rip),%rax
movsd  (%rax,%r15,8),%xmm1
movsd  %xmm2,0x10(%rsp)
subsd  %xmm2,%xmm1
divsd  0xdd0(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xdcc(%rip),%xmm0
movsd  %xmm1,0x28(%rsp)
mulsd  %xmm1,%xmm0
addsd  0xdc2(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
mulsd  0xdb0(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
addsd  %xmm1,%xmm1
movapd %xmm1,%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
mulsd  0xd8d(%rip),%xmm0
addsd  (%rsp),%xmm0
addsd  0xd88(%rip),%xmm0
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x168,%esi
call   10d0 <adjust_to_range@plt>
movsd  %xmm0,(%rsp)
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10b0 <tan@plt>
mulsd  0xd69(%rip),%xmm0
call   1080 <atan@plt>
mov    %eax,%edi
call   1060 <to_degree@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xor    %edi,%edi
mov    $0x168,%esi
call   10d0 <adjust_to_range@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
divsd  0xd3f(%rip),%xmm0
call   10e0 <floor@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
divsd  0xd2a(%rip),%xmm0
call   10e0 <floor@plt>
mov    %eax,%r14d
movsd  (%rsp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
mulsd  0xd11(%rip),%xmm0
movsd  %xmm0,0x38(%rsp)
call   1090 <asin@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0xcf9(%rip),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   1070 <sin@plt>
mulsd  0x38(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <to_radian@plt>
mov    %eax,%edi
call   10c0 <cos@plt>
mulsd  0x40(%rsp),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
ucomisd 0xca1(%rip),%xmm1
seta   %al
mov    %r15d,%ecx
and    %al,%cl
movsd  0xc99(%rip),%xmm0
ucomisd %xmm1,%xmm0
setbe  %al
cmp    $0x1,%cl
je     14f5 <calculate_sunrise+0x335>
or     %al,%r15b
je     14f5 <calculate_sunrise+0x335>
movapd %xmm1,%xmm0
imul   $0x5a,%ebp,%ebx
imul   $0x5a,%r14d,%ebp
call   1040 <acos@plt>
mov    %eax,%edi
call   1060 <to_degree@plt>
mov    $0x168,%ecx
sub    %eax,%ecx
cmpl   $0x0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
subsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  0xbd9(%rip),%xmm0
divsd  %xmm0,%xmm2
cmove  %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm0,%xmm1
addsd  %xmm2,%xmm1
movsd  0x28(%rsp),%xmm0
mulsd  0xc1d(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xc19(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
xor    %edi,%edi
mov    $0x18,%esi
call   10d0 <adjust_to_range@plt>
addsd  0x30(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    $0x1,%edi
mov    $0x18,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    0x1c(%rsp),%eax
mov    %eax,(%rbx)
add    $0xffffffff,%r13d
mov    %r13d,0x4(%rbx)
add    $0xfffff894,%r12d
mov    %r12d,0x8(%rbx)
movsd  (%rsp),%xmm0
call   10e0 <floor@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mov    %eax,0xc(%rbx)
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
mulsd  0xbb4(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   10e0 <floor@plt>
mov    %eax,0x10(%rbx)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xb8f(%rip),%xmm1
movapd %xmm1,%xmm0
call   10e0 <floor@plt>
mov    %eax,0x14(%rbx)
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define %struct.tm* @calculate_sunrise(i32 %0, i32 %1, i32 %2, i32 %3, double %4, double %5, double %6) {
%8 = alloca %struct.tm*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca %struct.tm*
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
%33 = load i32, i32* %10
%34 = load i32, i32* %11
%35 = load i32, i32* %12
%36 = call i32 @calculate_day_of_year(i32 %33, i32 %34, i32 %35)
store i32 %36, i32* %16
store double 0x4056B55555555555, double* %17
%37 = load double, double* %14
%38 = fdiv double %37, 1.500000e+01
store double %38, double* %18
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %7
%42 = load i32, i32* %16
%43 = sitofp i32 %42 to double
%44 = load double, double* %18
%45 = fsub double 6.000000e+00, %44
%46 = fdiv double %45, 2.400000e+01
%47 = fadd double %43, %46
store double %47, double* %19
br label %55
48: ; preds = %7
%49 = load i32, i32* %16
%50 = sitofp i32 %49 to double
%51 = load double, double* %18
%52 = fsub double 1.800000e+01, %51
%53 = fdiv double %52, 2.400000e+01
%54 = fadd double %50, %53
store double %54, double* %19
br label %55
55: ; preds = %48, %41
%56 = load double, double* %19
%57 = call double @llvm.fmuladd.f64(double 9.856000e-01, double %56, double -3.289000e+00)
store double %57, double* %20
%58 = load double, double* %20
%59 = load double, double* %20
%60 = call i32 @to_radian(double %59)
%61 = call double @sin(i32 %60)
%62 = call double @llvm.fmuladd.f64(double 1.916000e+00, double %61, double %58)
%63 = load double, double* %20
%64 = fmul double 2.000000e+00, %63
%65 = call i32 @to_radian(double %64)
%66 = call double @sin(i32 %65)
%67 = call double @llvm.fmuladd.f64(double 2.000000e-02, double %66, double %62)
%68 = fadd double %67, 2.826340e+02
store double %68, double* %21
%69 = load double, double* %21
%70 = call double @adjust_to_range(double %69, i32 0, i32 360)
store double %70, double* %21
%71 = load double, double* %21
%72 = call i32 @to_radian(double %71)
%73 = call double @tan(i32 %72)
%74 = fmul double 9.176400e-01, %73
%75 = call i32 @atan(double %74)
%76 = call i32 @to_degree(i32 %75)
%77 = sitofp i32 %76 to double
store double %77, double* %22
%78 = load double, double* %22
%79 = call double @adjust_to_range(double %78, i32 0, i32 360)
store double %79, double* %22
%80 = load double, double* %21
%81 = fdiv double %80, 9.000000e+01
%82 = call i32 @floor(double %81)
%83 = mul nsw i32 %82, 90
%84 = sitofp i32 %83 to double
store double %84, double* %23
%85 = load double, double* %22
%86 = fdiv double %85, 9.000000e+01
%87 = call i32 @floor(double %86)
%88 = mul nsw i32 %87, 90
%89 = sitofp i32 %88 to double
store double %89, double* %24
%90 = load double, double* %22
%91 = load double, double* %23
%92 = load double, double* %24
%93 = fsub double %91, %92
%94 = fadd double %90, %93
store double %94, double* %22
%95 = load double, double* %22
%96 = fdiv double %95, 1.500000e+01
store double %96, double* %22
%97 = load double, double* %21
%98 = call i32 @to_radian(double %97)
%99 = call double @sin(i32 %98)
%100 = fmul double 3.978200e-01, %99
store double %100, double* %25
%101 = load double, double* %25
%102 = call i32 @asin(double %101)
%103 = call double @cos(i32 %102)
store double %103, double* %26
%104 = load double, double* %17
%105 = call i32 @to_radian(double %104)
%106 = call double @cos(i32 %105)
%107 = load double, double* %25
%108 = load double, double* %13
%109 = call i32 @to_radian(double %108)
%110 = call double @sin(i32 %109)
%111 = fneg double %107
%112 = call double @llvm.fmuladd.f64(double %111, double %110, double %106)
%113 = load double, double* %26
%114 = load double, double* %13
%115 = call i32 @to_radian(double %114)
%116 = call double @cos(i32 %115)
%117 = fmul double %113, %116
%118 = fdiv double %112, %117
store double %118, double* %27
%119 = load double, double* %27
%120 = fcmp ogt double %119, 1.000000e+00
br i1 %120, label %121, label %125
121: ; preds = %55
%122 = load i32, i32* %9
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %125
124: ; preds = %121
store %struct.tm* null, %struct.tm** %8
br label %205
125: ; preds = %121, %55
%126 = load double, double* %27
%127 = fcmp olt double %126, -1.000000e+00
br i1 %127, label %128, label %132
128: ; preds = %125
%129 = load i32, i32* %9
%130 = icmp ne i32 %129, 0
br i1 %130, label %132, label %131
131: ; preds = %128
store %struct.tm* null, %struct.tm** %8
br label %205
132: ; preds = %128, %125
br label %133
133: ; preds = %132
%134 = load i32, i32* %9
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %142
136: ; preds = %133
%137 = load double, double* %27
%138 = call i32 @acos(double %137)
%139 = call i32 @to_degree(i32 %138)
%140 = sub nsw i32 360, %139
%141 = sitofp i32 %140 to double
store double %141, double* %28
br label %147
142: ; preds = %133
%143 = load double, double* %27
%144 = call i32 @acos(double %143)
%145 = call i32 @to_degree(i32 %144)
%146 = sitofp i32 %145 to double
store double %146, double* %28
br label %147
147: ; preds = %142, %136
%148 = load double, double* %28
%149 = fdiv double %148, 1.500000e+01
store double %149, double* %28
%150 = load double, double* %28
%151 = load double, double* %22
%152 = fadd double %150, %151
%153 = load double, double* %19
%154 = call double @llvm.fmuladd.f64(double -6.571000e-02, double %153, double %152)
%155 = fsub double %154, 6.622000e+00
store double %155, double* %29
%156 = load double, double* %29
%157 = load double, double* %18
%158 = fsub double %156, %157
store double %158, double* %30
%159 = load double, double* %30
%160 = call double @adjust_to_range(double %159, i32 0, i32 24)
store double %160, double* %30
%161 = load double, double* %30
%162 = load double, double* %15
%163 = fadd double %161, %162
store double %163, double* %31
%164 = call %struct.tm* @calloc(i32 1, i32 24)
store %struct.tm* %164, %struct.tm** %32
%165 = load i32, i32* %10
%166 = load %struct.tm*, %struct.tm** %32
%167 = getelementptr inbounds %struct.tm, %struct.tm* %166, i32 0, i32 0
store i32 %165, i32* %167
%168 = load i32, i32* %11
%169 = sub nsw i32 %168, 1
%170 = load %struct.tm*, %struct.tm** %32
%171 = getelementptr inbounds %struct.tm, %struct.tm* %170, i32 0, i32 1
store i32 %169, i32* %171
%172 = load i32, i32* %12
%173 = sub nsw i32 %172, 1900
%174 = load %struct.tm*, %struct.tm** %32
%175 = getelementptr inbounds %struct.tm, %struct.tm* %174, i32 0, i32 2
store i32 %173, i32* %175
%176 = load double, double* %31
%177 = call i32 @floor(double %176)
%178 = load %struct.tm*, %struct.tm** %32
%179 = getelementptr inbounds %struct.tm, %struct.tm* %178, i32 0, i32 3
store i32 %177, i32* %179
%180 = load %struct.tm*, %struct.tm** %32
%181 = getelementptr inbounds %struct.tm, %struct.tm* %180, i32 0, i32 3
%182 = load i32, i32* %181
%183 = sitofp i32 %182 to double
%184 = load double, double* %31
%185 = fsub double %184, %183
store double %185, double* %31
%186 = load double, double* %31
%187 = fmul double %186, 6.000000e+01
store double %187, double* %31
%188 = load double, double* %31
%189 = call i32 @floor(double %188)
%190 = load %struct.tm*, %struct.tm** %32
%191 = getelementptr inbounds %struct.tm, %struct.tm* %190, i32 0, i32 4
store i32 %189, i32* %191
%192 = load %struct.tm*, %struct.tm** %32
%193 = getelementptr inbounds %struct.tm, %struct.tm* %192, i32 0, i32 4
%194 = load i32, i32* %193
%195 = sitofp i32 %194 to double
%196 = load double, double* %31
%197 = fsub double %196, %195
store double %197, double* %31
%198 = load double, double* %31
%199 = fmul double %198, 6.000000e+01
store double %199, double* %31
%200 = load double, double* %31
%201 = call i32 @floor(double %200)
%202 = load %struct.tm*, %struct.tm** %32
%203 = getelementptr inbounds %struct.tm, %struct.tm* %202, i32 0, i32 5
store i32 %201, i32* %203
%204 = load %struct.tm*, %struct.tm** %32
store %struct.tm* %204, %struct.tm** %8
br label %205
205: ; preds = %147, %131, %124
%206 = load %struct.tm*, %struct.tm** %8
ret %struct.tm* %206
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
define noalias %struct.tm* @calculate_sunrise(i32 %0, i32 %1, i32 %2, i32 %3, double %4, double %5, double %6) {
%8 = tail call i32 @calculate_day_of_year(i32 %1, i32 %2, i32 %3)
%9 = fdiv double %5, 1.500000e+01
%10 = icmp ne i32 %0, 0
%11 = sitofp i32 %8 to double
%12 = select i1 %10, double 6.000000e+00, double 1.800000e+01
%13 = fsub double %12, %9
%14 = fdiv double %13, 2.400000e+01
%15 = fadd double %14, %11
%16 = tail call double @llvm.fmuladd.f64(double %15, double 9.856000e-01, double -3.289000e+00)
%17 = tail call i32 @to_radian(double %16)
%18 = tail call double @sin(i32 %17)
%19 = tail call double @llvm.fmuladd.f64(double %18, double 1.916000e+00, double %16)
%20 = fmul double %16, 2.000000e+00
%21 = tail call i32 @to_radian(double %20)
%22 = tail call double @sin(i32 %21)
%23 = tail call double @llvm.fmuladd.f64(double %22, double 2.000000e-02, double %19)
%24 = fadd double %23, 2.826340e+02
%25 = tail call double @adjust_to_range(double %24, i32 0, i32 360)
%26 = tail call i32 @to_radian(double %25)
%27 = tail call double @tan(i32 %26)
%28 = fmul double %27, 9.176400e-01
%29 = tail call i32 @atan(double %28)
%30 = tail call i32 @to_degree(i32 %29)
%31 = sitofp i32 %30 to double
%32 = tail call double @adjust_to_range(double %31, i32 0, i32 360)
%33 = fdiv double %25, 9.000000e+01
%34 = tail call i32 @floor(double %33)
%35 = fdiv double %32, 9.000000e+01
%36 = tail call i32 @floor(double %35)
%37 = tail call i32 @to_radian(double %25)
%38 = tail call double @sin(i32 %37)
%39 = fmul double %38, 3.978200e-01
%40 = tail call i32 @asin(double %39)
%41 = tail call double @cos(i32 %40)
%42 = tail call i32 @to_radian(double 0x4056B55555555555)
%43 = tail call double @cos(i32 %42)
%44 = tail call i32 @to_radian(double %4)
%45 = tail call double @sin(i32 %44)
%46 = fneg double %39
%47 = tail call double @llvm.fmuladd.f64(double %46, double %45, double %43)
%48 = tail call i32 @to_radian(double %4)
%49 = tail call double @cos(i32 %48)
%50 = fmul double %41, %49
%51 = fdiv double %47, %50
%52 = fcmp ogt double %51, 1.000000e+00
%53 = and i1 %10, %52
%54 = xor i1 %53, true
%55 = fcmp uge double %51, -1.000000e+00
%56 = or i1 %10, %55
%57 = select i1 %54, i1 %56, i1 false
br i1 %57, label %58, label %96
58: ; preds = %7
%59 = mul nsw i32 %34, 90
%60 = sitofp i32 %59 to double
%61 = mul nsw i32 %36, 90
%62 = sitofp i32 %61 to double
%63 = fsub double %60, %62
%64 = fadd double %32, %63
%65 = fdiv double %64, 1.500000e+01
%66 = tail call i32 @acos(double %51)
%67 = tail call i32 @to_degree(i32 %66)
%68 = sub nsw i32 360, %67
%69 = select i1 %10, i32 %68, i32 %67
%70 = sitofp i32 %69 to double
%71 = fdiv double %70, 1.500000e+01
%72 = fadd double %65, %71
%73 = tail call double @llvm.fmuladd.f64(double %15, double -6.571000e-02, double %72)
%74 = fadd double %73, -6.622000e+00
%75 = fsub double %74, %9
%76 = tail call double @adjust_to_range(double %75, i32 0, i32 24)
%77 = fadd double %76, %6
%78 = tail call %struct.tm* @calloc(i32 1, i32 24)
%79 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 0
store i32 %1, i32* %79
%80 = add nsw i32 %2, -1
%81 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 1
store i32 %80, i32* %81
%82 = add nsw i32 %3, -1900
%83 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 2
store i32 %82, i32* %83
%84 = tail call i32 @floor(double %77)
%85 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 3
store i32 %84, i32* %85
%86 = sitofp i32 %84 to double
%87 = fsub double %77, %86
%88 = fmul double %87, 6.000000e+01
%89 = tail call i32 @floor(double %88)
%90 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 4
store i32 %89, i32* %90
%91 = sitofp i32 %89 to double
%92 = fsub double %88, %91
%93 = fmul double %92, 6.000000e+01
%94 = tail call i32 @floor(double %93)
%95 = getelementptr inbounds %struct.tm, %struct.tm* %78, i64 0, i32 5
store i32 %94, i32* %95
br label %96
96: ; preds = %7, %58
%97 = phi %struct.tm* [ %78, %58 ], [ null, %7 ]
ret %struct.tm* %97
}