#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 calcJD(int const, int const, int const);
int calcSolNoonUTC(double, double const);
double calcTimeJulianCent(double);
double floor(double);
void get_solar_noon(const int year, const int month, const int day,
                    const double longitude, const double zone,
                    const int day_saving, int *const hour, int *const minute,
                    int *const second) {
  double floatHour;
  double floatMinute;
  double floatSec;
  double jd;
  double t;
  double noon;
  jd = calcJD(year, month, day);
  t = calcTimeJulianCent(jd);
  noon = calcSolNoonUTC(t, longitude) - (60 * zone) + (60 * day_saving);
  floatHour = noon / 60.0;
  *hour = (int)floor(floatHour);
  floatMinute = 60.0 * (floatHour - floor(floatHour));
  *minute = (int)floor(floatMinute);
  floatSec = 60.0 * (floatMinute - floor(floatMinute));
  *second = (int)floor(floatSec + 0.5);
  if (*second > 59) {
    *second = 0;
    *minute += 1;
  }
}


x86 assembly (clang, -O0):
<get_solar_noon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <calcJD@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <calcTimeJulianCent@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <calcSolNoonUTC@plt>
cvtsi2sd %eax,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe61(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
imul   $0x3c,-0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0xe33(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <floor@plt>
movsd  -0x78(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xdf1(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1060 <floor@plt>
movsd  -0x70(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xdaf(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xd96(%rip),%xmm0
addsd  -0x50(%rbp),%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x10(%rbp),%rax
cmpl   $0x3b,(%rax)
jle    12a0 <get_solar_noon+0x160>
mov    0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_solar_noon>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %ecx,%ebp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    0x40(%rsp),%r15
call   1050 <calcJD@plt>
call   1040 <calcTimeJulianCent@plt>
movsd  0x10(%rsp),%xmm1
call   1030 <calcSolNoonUTC@plt>
cvtsi2sd %eax,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  0xe76(%rip),%xmm1
imul   $0x3c,%ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
divsd  0xe64(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1060 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe41(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,(%r14)
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe19(%rip),%xmm1
addsd  0xe19(%rip),%xmm1
movapd %xmm1,%xmm0
call   1060 <floor@plt>
cvttsd2si %xmm0,%eax
mov    %eax,(%r15)
cmp    $0x3c,%eax
jl     1217 <get_solar_noon+0xd7>
movl   $0x0,(%r15)
addl   $0x1,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_solar_noon(i32 %0, i32 %1, i32 %2, double %3, double %4, i32 %5, i32* %6, i32* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store double %3, double* %13
store double %4, double* %14
store i32 %5, i32* %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = load i32, i32* %12
%28 = call double @calcJD(i32 %25, i32 %26, i32 %27)
store double %28, double* %22
%29 = load double, double* %22
%30 = call double @calcTimeJulianCent(double %29)
store double %30, double* %23
%31 = load double, double* %23
%32 = load double, double* %13
%33 = call i32 @calcSolNoonUTC(double %31, double %32)
%34 = sitofp i32 %33 to double
%35 = load double, double* %14
%36 = call double @llvm.fmuladd.f64(double -6.000000e+01, double %35, double %34)
%37 = load i32, i32* %15
%38 = mul nsw i32 60, %37
%39 = sitofp i32 %38 to double
%40 = fadd double %36, %39
store double %40, double* %24
%41 = load double, double* %24
%42 = fdiv double %41, 6.000000e+01
store double %42, double* %19
%43 = load double, double* %19
%44 = call double @llvm.floor.f64(double %43)
%45 = fptosi double %44 to i32
%46 = load i32*, i32** %16
store i32 %45, i32* %46
%47 = load double, double* %19
%48 = load double, double* %19
%49 = call double @llvm.floor.f64(double %48)
%50 = fsub double %47, %49
%51 = fmul double 6.000000e+01, %50
store double %51, double* %20
%52 = load double, double* %20
%53 = call double @llvm.floor.f64(double %52)
%54 = fptosi double %53 to i32
%55 = load i32*, i32** %17
store i32 %54, i32* %55
%56 = load double, double* %20
%57 = load double, double* %20
%58 = call double @llvm.floor.f64(double %57)
%59 = fsub double %56, %58
%60 = fmul double 6.000000e+01, %59
store double %60, double* %21
%61 = load double, double* %21
%62 = fadd double %61, 5.000000e-01
%63 = call double @llvm.floor.f64(double %62)
%64 = fptosi double %63 to i32
%65 = load i32*, i32** %18
store i32 %64, i32* %65
%66 = load i32*, i32** %18
%67 = load i32, i32* %66
%68 = icmp sgt i32 %67, 59
br i1 %68, label %69, label %74
69: ; preds = %9
%70 = load i32*, i32** %18
store i32 0, i32* %70
%71 = load i32*, i32** %17
%72 = load i32, i32* %71
%73 = add nsw i32 %72, 1
store i32 %73, i32* %71
br label %74
74: ; preds = %69, %9
ret void
}

LLVM IR (-O2):
define void @get_solar_noon(i32 %0, i32 %1, i32 %2, double %3, double %4, i32 %5, i32* nocapture writeonly %6, i32* nocapture %7, i32* nocapture writeonly %8) {
%10 = tail call double @calcJD(i32 %0, i32 %1, i32 %2)
%11 = tail call double @calcTimeJulianCent(double %10)
%12 = tail call i32 @calcSolNoonUTC(double %11, double %3)
%13 = sitofp i32 %12 to double
%14 = tail call double @llvm.fmuladd.f64(double %4, double -6.000000e+01, double %13)
%15 = mul nsw i32 %5, 60
%16 = sitofp i32 %15 to double
%17 = fadd double %14, %16
%18 = fdiv double %17, 6.000000e+01
%19 = tail call double @llvm.floor.f64(double %18)
%20 = fptosi double %19 to i32
store i32 %20, i32* %6
%21 = fsub double %18, %19
%22 = fmul double %21, 6.000000e+01
%23 = tail call double @llvm.floor.f64(double %22)
%24 = fptosi double %23 to i32
store i32 %24, i32* %7
%25 = fsub double %22, %23
%26 = fmul double %25, 6.000000e+01
%27 = fadd double %26, 5.000000e-01
%28 = tail call double @llvm.floor.f64(double %27)
%29 = fptosi double %28 to i32
store i32 %29, i32* %8
%30 = icmp sgt i32 %29, 59
br i1 %30, label %31, label %34
31: ; preds = %9
store i32 0, i32* %8
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %34
34: ; preds = %31, %9
ret void
}