#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 */
long sun_date2mjulianday(int, int, int);
void sun_date2gpstime(int year, int month, int day, int *week, double *tow) {
  long mjd = sun_date2mjulianday(year, month, day);
  long gpsdaynum = mjd - 44244;
  *week = gpsdaynum / 7;
  *tow = (double)((gpsdaynum % 7) * (60 * 60 * 24));
}


x86 assembly (clang, -O0):
<sun_date2gpstime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <sun_date2mjulianday@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
sub    $0xacd4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    $0x7,%ecx
cqto
idiv   %rcx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    $0x7,%ecx
cqto
idiv   %rcx
imul   $0x15180,%rdx,%rax
cvtsi2sd %rax,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun_date2gpstime>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
call   1030 <sun_date2mjulianday@plt>
mov    %rax,%rcx
add    $0xffffffffffff532c,%rax
movabs $0x4924924924924925,%rdx
92 24 49
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    %rdx
add    %rax,%rdx
mov    %edx,(%rbx)
lea    0x0(,%rdx,8),%rax
sub    %rax,%rdx
lea    (%rcx,%rdx,1),%rax
add    $0xffffffffffff532c,%rax
imul   $0x15180,%rax,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @sun_date2gpstime(i32 %0, i32 %1, i32 %2, i32* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca double*
%11 = alloca i64
%12 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store double* %4, double** %10
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = call i64 @sun_date2mjulianday(i32 %13, i32 %14, i32 %15)
store i64 %16, i64* %11
%17 = load i64, i64* %11
%18 = sub nsw i64 %17, 44244
store i64 %18, i64* %12
%19 = load i64, i64* %12
%20 = sdiv i64 %19, 7
%21 = trunc i64 %20 to i32
%22 = load i32*, i32** %9
store i32 %21, i32* %22
%23 = load i64, i64* %12
%24 = srem i64 %23, 7
%25 = mul nsw i64 %24, 86400
%26 = sitofp i64 %25 to double
%27 = load double*, double** %10
store double %26, double* %27
ret void
}

LLVM IR (-O2):
define void @sun_date2gpstime(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = tail call i64 @sun_date2mjulianday(i32 %0, i32 %1, i32 %2)
%7 = add nsw i64 %6, -44244
%8 = sdiv i64 %7, 7
%9 = trunc i64 %8 to i32
store i32 %9, i32* %3
%10 = srem i64 %7, 7
%11 = mul nsw i64 %10, 86400
%12 = sitofp i64 %11 to double
store double %12, double* %4
ret void
}