#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*/ *);
int /*<<< orphan*/ printf(char *, char *, double);
void mtime_e(struct timeval *tvs, char *printme) {
  struct timeval tve;
  double elapsedTime;
  gettimeofday(&tve, NULL);
  elapsedTime = (tve.tv_sec - (*tvs).tv_sec) * 1000.0;
  elapsedTime += (tve.tv_usec - (*tvs).tv_usec) / 1000.0;
  printf("%s%lfms\n", printme, elapsedTime);
}


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

x86 assembly (clang, -O2):
<mtime_e>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movsd  0x8(%rsp),%xmm1
subsd  (%rbx),%xmm1
movsd  0x10(%rsp),%xmm0
movsd  0xeaf(%rip),%xmm2
subsd  0x8(%rbx),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe9f(%rip),%rdi
mov    %r14,%rsi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [9 x i8] c"%s%lfms\0A\00"
define void @mtime_e(%struct.timeval* %0, i8* %1) {
%3 = alloca %struct.timeval*
%4 = alloca i8*
%5 = alloca %struct.timeval
%6 = alloca double
store %struct.timeval* %0, %struct.timeval** %3
store i8* %1, i8** %4
%7 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%9 = load double, double* %8
%10 = load %struct.timeval*, %struct.timeval** %3
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = load double, double* %11
%13 = fsub double %9, %12
%14 = fmul double %13, 1.000000e+03
store double %14, double* %6
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%16 = load double, double* %15
%17 = load %struct.timeval*, %struct.timeval** %3
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %17, i32 0, i32 1
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = fdiv double %20, 1.000000e+03
%22 = load double, double* %6
%23 = fadd double %22, %21
store double %23, double* %6
%24 = load i8*, i8** %4
%25 = load double, double* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %24, double %25)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [9 x i8] c"%s%lfms\0A\00"
define void @mtime_e(%struct.timeval* nocapture %0, i8* %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 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%9 = load double, double* %8
%10 = fsub double %7, %9
%11 = fmul double %10, 1.000000e+03
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%13 = load double, double* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%15 = load double, double* %14
%16 = fsub double %13, %15
%17 = fdiv double %16, 1.000000e+03
%18 = fadd double %11, %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1, double %18)
ret void
}