#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 fmod(double, int);
double greenwich_to_local_time(double, double);
int /*<<< orphan*/ solar_angles(double, double, double, double, double *,
                                double *, double *);
int /*<<< orphan*/ solar_coords_and_times(double, double *, double *, double *);
double su_cal_to_jul_day(int, int, int);
int /*<<< orphan*/ su_jul_to_cal_date(long, int *, int *, int *);
double su_solar_distance_factor2(double);
void su_solar_params2(double jtime, double lat, double lon, double *mu0,
                      double *theta0, double *phi0, double *solar_dist_fac) {
  int year;
  int month;
  int day;
  long jwhole;
  double jfrac;
  double delta;
  double gw_mean_sol_time;
  double gw_appar_sol_time;
  double loc_mean_sol_time;
  double loc_appar_sol_time;
  double local_hour;
  double eot;
  double jday;
  solar_coords_and_times(jtime, &delta, &gw_mean_sol_time, &gw_appar_sol_time);
  loc_mean_sol_time = greenwich_to_local_time(lon, gw_mean_sol_time);
  loc_appar_sol_time = greenwich_to_local_time(lon, gw_appar_sol_time);
  jwhole = (int)jtime;
  jfrac = jtime - jwhole;
  if (jfrac < .5)
    jfrac = jfrac + .5;
  else {
    jfrac = jfrac - .5;
    jwhole = jwhole + 1;
  }
  local_hour =
      jfrac * 24. + lon / (15. * (3.14159265358979323846264338327 / 180.0));
  eot = fmod(loc_mean_sol_time - loc_appar_sol_time, 1.);
  solar_angles(delta, lat, local_hour, eot, mu0, theta0, phi0);
  if (solar_dist_fac) {
    su_jul_to_cal_date(jwhole, &year, &month, &day);
    jday = (int)(jtime - (su_cal_to_jul_day(year, 1, 1) - .5));
    *solar_dist_fac = su_solar_distance_factor2(jday + local_hour / 24.);
  }
}


x86 assembly (clang, -O0):
<su_solar_params2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x60(%rbp),%rdi
lea    -0x68(%rbp),%rsi
lea    -0x70(%rbp),%rdx
call   1050 <solar_coords_and_times@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
call   1040 <greenwich_to_local_time@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
call   1040 <greenwich_to_local_time@plt>
movsd  %xmm0,-0x80(%rbp)
cvttsd2si -0x8(%rbp),%eax
cltq
mov    %rax,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdq -0x50(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe01(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    1221 <su_solar_params2+0xb1>
movsd  0xdee(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1243 <su_solar_params2+0xd3>
movsd  -0x58(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xdbb(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xda7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
subsd  -0x80(%rbp),%xmm0
mov    $0x1,%edi
call   1070 <fmod@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm2
ff
movsd  -0x90(%rbp),%xmm3
ff
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1090 <solar_angles@plt>
cmpq   $0x0,-0x38(%rbp)
je     134c <su_solar_params2+0x1dc>
mov    -0x50(%rbp),%rdi
lea    -0x3c(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x44(%rbp),%rcx
call   1030 <su_jul_to_cal_date@plt>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x3c(%rbp),%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <su_cal_to_jul_day@plt>
movaps %xmm0,%xmm1
movsd  -0xa0(%rbp),%xmm0
ff
movsd  0xcf9(%rip),%xmm2
subsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
movsd  0xcd1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1080 <su_solar_distance_factor2@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<su_solar_params2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x28(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rdi
lea    0x38(%rsp),%rsi
lea    0x30(%rsp),%rdx
call   1050 <solar_coords_and_times@plt>
movsd  0x38(%rsp),%xmm1
movsd  (%rsp),%xmm0
call   1040 <greenwich_to_local_time@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x30(%rsp),%xmm1
movsd  (%rsp),%xmm0
call   1040 <greenwich_to_local_time@plt>
movapd 0x10(%rsp),%xmm2
cvttpd2dq %xmm2,%xmm1
cvtdq2pd %xmm1,%xmm1
subsd  %xmm1,%xmm2
movsd  0xe15(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm2,%xmm1
seta   %al
lea    0xe25(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm3
movapd %xmm2,0x50(%rsp)
addsd  %xmm2,%xmm3
movsd  (%rsp),%xmm1
divsd  0xdf1(%rip),%xmm1
mulsd  0xdf1(%rip),%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%edi
call   1070 <fmod@plt>
movapd %xmm0,%xmm3
movsd  0x40(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  (%rsp),%xmm2
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1090 <solar_angles@plt>
test   %r14,%r14
je     12e3 <su_solar_params2+0x173>
cvttsd2si 0x10(%rsp),%eax
xor    %edi,%edi
movsd  0xd88(%rip),%xmm0
ucomisd 0x50(%rsp),%xmm0
setbe  %dil
cltq
add    %rax,%rdi
lea    0xc(%rsp),%rsi
lea    0x4c(%rsp),%rdx
lea    0x48(%rsp),%rcx
call   1030 <su_jul_to_cal_date@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1060 <su_cal_to_jul_day@plt>
addsd  0xd62(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm1
movsd  (%rsp),%xmm0
divsd  0xd3b(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1080 <su_solar_distance_factor2@plt>
movsd  %xmm0,(%r14)
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @su_solar_params2(double %0, double %1, double %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i64
%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
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%28 = load double, double* %8
%29 = call i32 @solar_coords_and_times(double %28, double* %20, double* %21, double* %22)
%30 = load double, double* %10
%31 = load double, double* %21
%32 = call double @greenwich_to_local_time(double %30, double %31)
store double %32, double* %23
%33 = load double, double* %10
%34 = load double, double* %22
%35 = call double @greenwich_to_local_time(double %33, double %34)
store double %35, double* %24
%36 = load double, double* %8
%37 = fptosi double %36 to i32
%38 = sext i32 %37 to i64
store i64 %38, i64* %18
%39 = load double, double* %8
%40 = load i64, i64* %18
%41 = sitofp i64 %40 to double
%42 = fsub double %39, %41
store double %42, double* %19
%43 = load double, double* %19
%44 = fcmp olt double %43, 5.000000e-01
br i1 %44, label %45, label %48
45: ; preds = %7
%46 = load double, double* %19
%47 = fadd double %46, 5.000000e-01
store double %47, double* %19
br label %53
48: ; preds = %7
%49 = load double, double* %19
%50 = fsub double %49, 5.000000e-01
store double %50, double* %19
%51 = load i64, i64* %18
%52 = add nsw i64 %51, 1
store i64 %52, i64* %18
br label %53
53: ; preds = %48, %45
%54 = load double, double* %19
%55 = load double, double* %10
%56 = fdiv double %55, 0x3FD0C152382D7365
%57 = call double @llvm.fmuladd.f64(double %54, double 2.400000e+01, double %56)
store double %57, double* %25
%58 = load double, double* %23
%59 = load double, double* %24
%60 = fsub double %58, %59
%61 = call double @fmod(double %60, i32 1)
store double %61, double* %26
%62 = load double, double* %20
%63 = load double, double* %9
%64 = load double, double* %25
%65 = load double, double* %26
%66 = load double*, double** %11
%67 = load double*, double** %12
%68 = load double*, double** %13
%69 = call i32 @solar_angles(double %62, double %63, double %64, double %65, double* %66, double* %67, double* %68)
%70 = load double*, double** %14
%71 = icmp ne double* %70, null
br i1 %71, label %72, label %88
72: ; preds = %53
%73 = load i64, i64* %18
%74 = call i32 @su_jul_to_cal_date(i64 %73, i32* %15, i32* %16, i32* %17)
%75 = load double, double* %8
%76 = load i32, i32* %15
%77 = call double @su_cal_to_jul_day(i32 %76, i32 1, i32 1)
%78 = fsub double %77, 5.000000e-01
%79 = fsub double %75, %78
%80 = fptosi double %79 to i32
%81 = sitofp i32 %80 to double
store double %81, double* %27
%82 = load double, double* %27
%83 = load double, double* %25
%84 = fdiv double %83, 2.400000e+01
%85 = fadd double %82, %84
%86 = call double @su_solar_distance_factor2(double %85)
%87 = load double*, double** %14
store double %86, double* %87
br label %88
88: ; preds = %72, %53
ret void
}

LLVM IR (-O2):
define void @su_solar_params2(double %0, double %1, double %2, double* %3, double* %4, double* %5, double* writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = bitcast i32* %8 to i8*
%15 = bitcast i32* %9 to i8*
%16 = bitcast i32* %10 to i8*
%17 = bitcast double* %11 to i8*
%18 = bitcast double* %12 to i8*
%19 = bitcast double* %13 to i8*
%20 = call i32 @solar_coords_and_times(double %0, double* %11, double* %12, double* %13)
%21 = load double, double* %12
%22 = call double @greenwich_to_local_time(double %2, double %21)
%23 = load double, double* %13
%24 = call double @greenwich_to_local_time(double %2, double %23)
%25 = fptosi double %0 to i32
%26 = sitofp i32 %25 to double
%27 = fsub double %0, %26
%28 = fcmp olt double %27, 5.000000e-01
%29 = select i1 %28, double 5.000000e-01, double -5.000000e-01
%30 = fadd double %27, %29
%31 = fdiv double %2, 0x3FD0C152382D7365
%32 = call double @llvm.fmuladd.f64(double %30, double 2.400000e+01, double %31)
%33 = fsub double %22, %24
%34 = call double @fmod(double %33, i32 1)
%35 = load double, double* %11
%36 = call i32 @solar_angles(double %35, double %1, double %32, double %34, double* %3, double* %4, double* %5)
%37 = icmp eq double* %6, null
br i1 %37, label %53, label %38
38: ; preds = %7
%39 = sext i32 %25 to i64
%40 = xor i1 %28, true
%41 = zext i1 %40 to i64
%42 = add nsw i64 %41, %39
%43 = call i32 @su_jul_to_cal_date(i64 %42, i32* %8, i32* %9, i32* %10)
%44 = load i32, i32* %8
%45 = call double @su_cal_to_jul_day(i32 %44, i32 1, i32 1)
%46 = fadd double %45, -5.000000e-01
%47 = fsub double %0, %46
%48 = fptosi double %47 to i32
%49 = sitofp i32 %48 to double
%50 = fdiv double %32, 2.400000e+01
%51 = fadd double %50, %49
%52 = call double @su_solar_distance_factor2(double %51)
store double %52, double* %6
br label %53
53: ; preds = %38, %7
ret void
}