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

/* Variables and functions */
struct timeval calc_offset(struct timeval in, double offset) {
  struct timeval out;
  double dummy;
  dummy = (((double)in.tv_sec) + ((double)in.tv_usec) / 1000000.0);
  dummy += offset;
  out.tv_sec = (int)dummy;
  out.tv_usec = (suseconds_t)((dummy - (double)out.tv_sec) * 1000000.0);
  return out;
}


x86 assembly (clang, -O0):
<calc_offset>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x20(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
cvtsi2sdq -0x18(%rbp),%xmm2
movsd  0xedd(%rip),%xmm1
divsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%eax
mov    %eax,-0x10(%rbp)
movsd  -0x30(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%rdx
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_offset>:
cvtsi2sd %edi,%xmm1
cvtsi2sd %rsi,%xmm2
movsd  0xeef(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%eax
cvttpd2dq %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm2
cvttsd2si %xmm2,%rdx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define { i32, i64 } @calc_offset(i32 %0, i64 %1, double %2) {
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca double
%7 = alloca double
%8 = bitcast %struct.timeval* %5 to { i32, i64 }*
%9 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %8, i32 0, i32 0
store i32 %0, i32* %9
%10 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %8, i32 0, i32 1
store i64 %1, i64* %10
store double %2, double* %6
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%12 = load i32, i32* %11
%13 = sitofp i32 %12 to double
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sitofp i64 %15 to double
%17 = fdiv double %16, 1.000000e+06
%18 = fadd double %13, %17
store double %18, double* %7
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fadd double %20, %19
store double %21, double* %7
%22 = load double, double* %7
%23 = fptosi double %22 to i32
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
store i32 %23, i32* %24
%25 = load double, double* %7
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%27 = load i32, i32* %26
%28 = sitofp i32 %27 to double
%29 = fsub double %25, %28
%30 = fmul double %29, 1.000000e+06
%31 = fptosi double %30 to i64
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
store i64 %31, i64* %32
%33 = bitcast %struct.timeval* %4 to { i32, i64 }*
%34 = load { i32, i64 }, { i32, i64 }* %33
ret { i32, i64 } %34
}

LLVM IR (-O2):
define { i32, i64 } @calc_offset(i32 %0, i64 %1, double %2) {
%4 = sitofp i32 %0 to double
%5 = sitofp i64 %1 to double
%6 = fdiv double %5, 1.000000e+06
%7 = fadd double %6, %4
%8 = fadd double %7, %2
%9 = fptosi double %8 to i32
%10 = sitofp i32 %9 to double
%11 = fsub double %8, %10
%12 = fmul double %11, 1.000000e+06
%13 = fptosi double %12 to i64
%14 = insertvalue { i32, i64 } poison, i32 %9, 0
%15 = insertvalue { i32, i64 } %14, i64 %13, 1
ret { i32, i64 } %15
}