#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 suntime_get_sunrise_utc(double, double, double, int, int, int);
double suntime_get_sunset_utc(double, double, double, int, int, int);
double suntime_get_nighttime(double latitude, double longitude, double zenith,
                             int year, int month, int day) {
  double sunrise, sunset;
  sunrise =
      suntime_get_sunrise_utc(latitude, longitude, zenith, year, month, day);
  sunset =
      suntime_get_sunset_utc(latitude, longitude, zenith, year, month, day);
  if (sunrise > sunset)
    return (sunrise - sunset);
  return (sunrise + (24 - sunset));
}


x86 assembly (clang, -O0):
<suntime_get_nighttime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1030 <suntime_get_sunrise_utc@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1040 <suntime_get_sunset_utc@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11a8 <suntime_get_nighttime+0x88>
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c3 <suntime_get_nighttime+0xa3>
movsd  -0x38(%rbp),%xmm0
movsd  0xe4b(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<suntime_get_nighttime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <suntime_get_sunrise_utc@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r14d,%edx
call   1040 <suntime_get_sunset_utc@plt>
movsd  0xe90(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd 0xe94(%rip),%xmm2
xorpd  %xmm0,%xmm2
movsd  0x18(%rsp),%xmm3
cmpltsd %xmm3,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
addsd  %xmm3,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @suntime_get_nighttime(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%16 = load double, double* %8
%17 = load double, double* %9
%18 = load double, double* %10
%19 = load i32, i32* %11
%20 = load i32, i32* %12
%21 = load i32, i32* %13
%22 = call double @suntime_get_sunrise_utc(double %16, double %17, double %18, i32 %19, i32 %20, i32 %21)
store double %22, double* %14
%23 = load double, double* %8
%24 = load double, double* %9
%25 = load double, double* %10
%26 = load i32, i32* %11
%27 = load i32, i32* %12
%28 = load i32, i32* %13
%29 = call double @suntime_get_sunset_utc(double %23, double %24, double %25, i32 %26, i32 %27, i32 %28)
store double %29, double* %15
%30 = load double, double* %14
%31 = load double, double* %15
%32 = fcmp ogt double %30, %31
br i1 %32, label %33, label %37
33: ; preds = %6
%34 = load double, double* %14
%35 = load double, double* %15
%36 = fsub double %34, %35
store double %36, double* %7
br label %42
37: ; preds = %6
%38 = load double, double* %14
%39 = load double, double* %15
%40 = fsub double 2.400000e+01, %39
%41 = fadd double %38, %40
store double %41, double* %7
br label %42
42: ; preds = %37, %33
%43 = load double, double* %7
ret double %43
}

LLVM IR (-O2):
define double @suntime_get_nighttime(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5) {
%7 = tail call double @suntime_get_sunrise_utc(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5)
%8 = tail call double @suntime_get_sunset_utc(double %0, double %1, double %2, i32 %3, i32 %4, i32 %5)
%9 = fcmp ogt double %7, %8
%10 = fsub double 2.400000e+01, %8
%11 = fneg double %8
%12 = select i1 %9, double %11, double %10
%13 = fadd double %7, %12
ret double %13
}