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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
double howlong(struct timeval t1) {
  struct timeval end;
  double elapsed;
  gettimeofday(&end, NULL);
  elapsed = (end.tv_sec - t1.tv_sec) * 1000.0;
  elapsed += (end.tv_usec - t1.tv_usec) / 1000.0;
  return elapsed;
}


x86 assembly (clang, -O0):
<howlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xebf(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  0xea4(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<howlong>:
sub    $0x28,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x20(%rsp),%xmm0
subsd  0x8(%rsp),%xmm1
movsd  0xeba(%rip),%xmm2
mulsd  %xmm2,%xmm1
subsd  0x10(%rsp),%xmm0
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
%struct.timeval = type { double, double }
define double @howlong(double %0, double %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%7 = load double, double* %6
%8 = fsub double %7, %0
%9 = fmul double %8, 1.000000e+03
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%11 = load double, double* %10
%12 = fsub double %11, %1
%13 = fdiv double %12, 1.000000e+03
%14 = fadd double %9, %13
ret double %14
}