#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 */
scalar_t__ floor(double);
int /*<<< orphan*/ sun_normalize_delta(long *, long *, double *);
void sun_translate_gpstime(int *week, double *tow, long delta_day,
                           long delta_sec, double delta_subsec) {
  sun_normalize_delta(&delta_day, &delta_sec, &delta_subsec);
  long carry;
  int delta_week = 0;
  carry = delta_day / 7;
  delta_week += carry;
  delta_day -= carry * 7;
  *tow += (double)(delta_day * (60 * 60 * 24) + delta_sec) + delta_subsec;
  carry = (long)floor(*tow / (7 * (60 * 60 * 24)));
  *tow -= (double)(carry * (7 * (60 * 60 * 24)));
  delta_week += carry;
  *week += delta_week;
}


x86 assembly (clang, -O0):
<sun_translate_gpstime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <sun_normalize_delta@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x7,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x34(%rbp)
imul   $0x7,-0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
imul   $0x15180,-0x18(%rbp),%rax
add    -0x20(%rbp),%rax
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe49(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %rax,-0x30(%rbp)
imul   $0x93a80,-0x30(%rbp),%rax
cvtsi2sd %rax,%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sun_translate_gpstime>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,0x8(%rsp)
mov    %rcx,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
call   1030 <sun_normalize_delta@plt>
mov    0x8(%rsp),%rcx
movabs $0x4924924924924925,%rdx
92 24 49
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    %rbx
add    %rax,%rbx
lea    0x0(,%rbx,8),%rax
mov    %rbx,%rdx
sub    %rax,%rdx
add    %rcx,%rdx
mov    %rdx,0x8(%rsp)
imul   $0x15180,%rdx,%rax
add    0x18(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x10(%rsp),%xmm0
addsd  (%r15),%xmm0
movsd  %xmm0,(%r15)
divsd  0xe46(%rip),%xmm0
call   1040 <floor@plt>
imul   $0x93a80,%rax,%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
movsd  (%r15),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
add    %eax,%ebx
add    %ebx,(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sun_translate_gpstime(i32* %0, double* %1, i64 %2, i64 %3, double %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
%11 = alloca i64
%12 = alloca i32
store i32* %0, i32** %6
store double* %1, double** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store double %4, double* %10
%13 = call i32 @sun_normalize_delta(i64* %8, i64* %9, double* %10)
store i32 0, i32* %12
%14 = load i64, i64* %8
%15 = sdiv i64 %14, 7
store i64 %15, i64* %11
%16 = load i64, i64* %11
%17 = load i32, i32* %12
%18 = sext i32 %17 to i64
%19 = add nsw i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %12
%21 = load i64, i64* %11
%22 = mul nsw i64 %21, 7
%23 = load i64, i64* %8
%24 = sub nsw i64 %23, %22
store i64 %24, i64* %8
%25 = load i64, i64* %8
%26 = mul nsw i64 %25, 86400
%27 = load i64, i64* %9
%28 = add nsw i64 %26, %27
%29 = sitofp i64 %28 to double
%30 = load double, double* %10
%31 = fadd double %29, %30
%32 = load double*, double** %7
%33 = load double, double* %32
%34 = fadd double %33, %31
store double %34, double* %32
%35 = load double*, double** %7
%36 = load double, double* %35
%37 = fdiv double %36, 6.048000e+05
%38 = call i64 @floor(double %37)
store i64 %38, i64* %11
%39 = load i64, i64* %11
%40 = mul nsw i64 %39, 604800
%41 = sitofp i64 %40 to double
%42 = load double*, double** %7
%43 = load double, double* %42
%44 = fsub double %43, %41
store double %44, double* %42
%45 = load i64, i64* %11
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = add nsw i64 %47, %45
%49 = trunc i64 %48 to i32
store i32 %49, i32* %12
%50 = load i32, i32* %12
%51 = load i32*, i32** %6
%52 = load i32, i32* %51
%53 = add nsw i32 %52, %50
store i32 %53, i32* %51
ret void
}

LLVM IR (-O2):
define void @sun_translate_gpstime(i32* nocapture %0, double* nocapture %1, i64 %2, i64 %3, double %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca double
store i64 %2, i64* %6
store i64 %3, i64* %7
store double %4, double* %8
%9 = call i32 @sun_normalize_delta(i64* %6, i64* %7, double* %8)
%10 = load i64, i64* %6
%11 = sdiv i64 %10, 7
%12 = mul nsw i64 %11, -7
%13 = add i64 %12, %10
store i64 %13, i64* %6
%14 = mul nsw i64 %13, 86400
%15 = load i64, i64* %7
%16 = add nsw i64 %14, %15
%17 = sitofp i64 %16 to double
%18 = load double, double* %8
%19 = fadd double %18, %17
%20 = load double, double* %1
%21 = fadd double %20, %19
store double %21, double* %1
%22 = fdiv double %21, 6.048000e+05
%23 = call i64 @floor(double %22)
%24 = mul nsw i64 %23, 604800
%25 = sitofp i64 %24 to double
%26 = load double, double* %1
%27 = fsub double %26, %25
store double %27, double* %1
%28 = add i64 %23, %11
%29 = trunc i64 %28 to i32
%30 = load i32, i32* %0
%31 = add nsw i32 %30, %29
store i32 %31, i32* %0
ret void
}