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

/* Variables and functions */
double joules2watts(double joules, struct timeval *start,
                    struct timeval *stop) {
  return joules / ((stop->tv_usec - start->tv_usec) / (double)1000000.0 +
                   stop->tv_sec - start->tv_sec);
}


x86 assembly (clang, -O0):
<joules2watts>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
movsd  0xed2(%rip),%xmm2
divsd  %xmm2,%xmm1
mov    -0x18(%rbp),%rax
addsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm1
divsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<joules2watts>:
movsd  (%rsi),%xmm1
subsd  (%rdi),%xmm1
divsd  0xef0(%rip),%xmm1
addsd  0x8(%rsi),%xmm1
subsd  0x8(%rdi),%xmm1
divsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
define double @joules2watts(double %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca double
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
store double %0, double* %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%7 = load double, double* %4
%8 = load %struct.timeval*, %struct.timeval** %6
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%10 = load double, double* %9
%11 = load %struct.timeval*, %struct.timeval** %5
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%13 = load double, double* %12
%14 = fsub double %10, %13
%15 = fdiv double %14, 1.000000e+06
%16 = load %struct.timeval*, %struct.timeval** %6
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 1
%18 = load double, double* %17
%19 = fadd double %15, %18
%20 = load %struct.timeval*, %struct.timeval** %5
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%22 = load double, double* %21
%23 = fsub double %19, %22
%24 = fdiv double %7, %23
ret double %24
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
define double @joules2watts(double %0, %struct.timeval* nocapture %1, %struct.timeval* nocapture %2) {
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%5 = load double, double* %4
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = load double, double* %6
%8 = fsub double %5, %7
%9 = fdiv double %8, 1.000000e+06
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%11 = load double, double* %10
%12 = fadd double %11, %9
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%14 = load double, double* %13
%15 = fsub double %12, %14
%16 = fdiv double %0, %15
ret double %16
}