#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*/ printf(char *, double);
void print_elapsed(struct timeval *t1, struct timeval *t2) {
  double elapsed;
  elapsed = (t2->tv_sec - t1->tv_sec) * 1000.0;
  elapsed += (t2->tv_usec - t1->tv_usec) / 1000.0;
  printf("Found in: %f ms\n", elapsed);
}


x86 assembly (clang, -O0):
<print_elapsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  (%rax),%xmm0
movsd  0xec8(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  0xea5(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_elapsed>:
movsd  (%rsi),%xmm1
subsd  (%rdi),%xmm1
movsd  0x8(%rsi),%xmm0
movsd  0xedb(%rip),%xmm2
subsd  0x8(%rdi),%xmm0
mulsd  %xmm2,%xmm1
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xecb(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [17 x i8] c"Found in: %f ms\0A\00"
define void @print_elapsed(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca double
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%6 = load %struct.timeval*, %struct.timeval** %4
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%8 = load double, double* %7
%9 = load %struct.timeval*, %struct.timeval** %3
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 0
%11 = load double, double* %10
%12 = fsub double %8, %11
%13 = fmul double %12, 1.000000e+03
store double %13, double* %5
%14 = load %struct.timeval*, %struct.timeval** %4
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, 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* %5
%23 = fadd double %22, %21
store double %23, double* %5
%24 = load double, double* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %24)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [17 x i8] c"Found in: %f ms\0A\00"
define void @print_elapsed(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load double, double* %3
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%6 = load double, double* %5
%7 = fsub double %4, %6
%8 = fmul double %7, 1.000000e+03
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%12 = load double, double* %11
%13 = fsub double %10, %12
%14 = fdiv double %13, 1.000000e+03
%15 = fadd double %8, %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %15)
ret void
}