#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
void main(void) {
  struct timeval tv;
  gettimeofday(&tv, NULL);
  double epochtime = tv.tv_sec + tv.tv_usec / 1000000.;
  double gpstime = epochtime - 315964800. + 17;
  printf("%f\n", gpstime);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xec9(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xea7(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe93(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
cvtsi2sdl (%rsp),%xmm1
cvtsi2sdl 0x4(%rsp),%xmm0
divsd  0xec2(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0xebe(%rip),%xmm0
addsd  0xebe(%rip),%xmm0
lea    0xebf(%rip),%rdi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [4 x i8] c"%f\0A\00"
define void @main() {
%1 = alloca %struct.timeval
%2 = alloca double
%3 = alloca double
%4 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%6 = load i32, i32* %5
%7 = sitofp i32 %6 to double
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%9 = load i32, i32* %8
%10 = sitofp i32 %9 to double
%11 = fdiv double %10, 1.000000e+06
%12 = fadd double %7, %11
store double %12, double* %2
%13 = load double, double* %2
%14 = fsub double %13, 0x41B2D53D80000000
%15 = fadd double %14, 1.700000e+01
store double %15, double* %3
%16 = load double, double* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %16)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [4 x i8] c"%f\0A\00"
define void @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = sitofp i32 %5 to double
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = sitofp i32 %8 to double
%10 = fdiv double %9, 1.000000e+06
%11 = fadd double %10, %6
%12 = fadd double %11, 0xC1B2D53D80000000
%13 = fadd double %12, 1.700000e+01
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %13)
ret void
}