#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 {
  long tv_sec;
  long tv_usec;
};

/* Variables and functions */
void gu_timeval_add(struct timeval *t, double s) {
  double ret = (double)t->tv_sec + ((double)t->tv_usec) * 1.0e-06 + s;
  t->tv_sec = (long)ret;
  t->tv_usec = (long)((ret - (double)t->tv_sec) * 1.0e+06);
}


x86 assembly (clang, -O0):
<gu_timeval_add>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
mov    -0x8(%rbp),%rax
cvtsi2sdq 0x8(%rax),%xmm0
movsd  0xee0(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
cvttsd2si -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
cvtsi2sdq (%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<gu_timeval_add>:
cvtsi2sdq (%rdi),%xmm1
cvtsi2sdq 0x8(%rdi),%xmm2
mulsd  0xeed(%rip),%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
cvttsd2si %xmm2,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
subsd  %xmm0,%xmm2
mulsd  0xed4(%rip),%xmm2
mov    %rax,(%rdi)
cvttsd2si %xmm2,%rax
mov    %rax,0x8(%rdi)
ret

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

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define void @gu_timeval_add(%struct.timeval* nocapture %0, double %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%4 = load i64, i64* %3
%5 = sitofp i64 %4 to double
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%7 = load i64, i64* %6
%8 = sitofp i64 %7 to double
%9 = tail call double @llvm.fmuladd.f64(double %8, double 0x3EB0C6F7A0B5ED8D, double %5)
%10 = fadd double %9, %1
%11 = fptosi double %10 to i64
store i64 %11, i64* %3
%12 = sitofp i64 %11 to double
%13 = fsub double %10, %12
%14 = fmul double %13, 1.000000e+06
%15 = fptosi double %14 to i64
store i64 %15, i64* %6
ret void
}