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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int, int, long);
void print_time_diff(struct timeval *start, struct timeval *end) {
  long lstart = start->tv_sec * 1000000 + start->tv_usec;
  long lend = end->tv_sec * 1000000 + end->tv_usec;
  printf("Time diff(start %d.%d, end %d.%d :  %2.3f\n", start->tv_sec,
         start->tv_usec, end->tv_sec, end->tv_usec,
         (lend - lstart) / 1000000.0);
  return;
}


x86 assembly (clang, -O0):
<print_time_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x8(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xf4240,(%rax),%eax
mov    -0x10(%rbp),%rcx
add    0x4(%rcx),%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cvtsi2sd %rax,%xmm0
movsd  0xe82(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r9
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time_diff>:
mov    (%rdi),%eax
mov    0x4(%rdi),%edx
imul   $0xf4240,%eax,%ecx
add    %edx,%ecx
movslq %ecx,%rdi
mov    (%rsi),%ecx
mov    0x4(%rsi),%r8d
imul   $0xf4240,%ecx,%esi
add    %r8d,%esi
movslq %esi,%rsi
sub    %rdi,%rsi
cvtsi2sd %rsi,%xmm0
divsd  0xebe(%rip),%xmm0
cvttsd2si %xmm0,%r9
lea    0xeba(%rip),%rdi
mov    %eax,%esi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@.str = [43 x i8] c"Time diff(start %d.%d, end %d.%d : %2.3f\0A\00"
define void @print_time_diff(%struct.timeval* %0, %struct.timeval* %1) {
%3 = alloca %struct.timeval*
%4 = alloca %struct.timeval*
%5 = alloca i64
%6 = alloca i64
store %struct.timeval* %0, %struct.timeval** %3
store %struct.timeval* %1, %struct.timeval** %4
%7 = load %struct.timeval*, %struct.timeval** %3
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = mul nsw i32 %9, 1000000
%11 = load %struct.timeval*, %struct.timeval** %3
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %10, %13
%15 = sext i32 %14 to i64
store i64 %15, i64* %5
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000000
%20 = load %struct.timeval*, %struct.timeval** %4
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = add nsw i32 %19, %22
%24 = sext i32 %23 to i64
store i64 %24, i64* %6
%25 = load %struct.timeval*, %struct.timeval** %3
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = load %struct.timeval*, %struct.timeval** %3
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i32 0, i32 1
%30 = load i32, i32* %29
%31 = load %struct.timeval*, %struct.timeval** %4
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %31, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load %struct.timeval*, %struct.timeval** %4
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = load i64, i64* %6
%38 = load i64, i64* %5
%39 = sub nsw i64 %37, %38
%40 = sitofp i64 %39 to double
%41 = fdiv double %40, 1.000000e+06
%42 = fptosi double %41 to i64
%43 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %30, i32 %33, i32 %36, i64 %42)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@.str = [43 x i8] c"Time diff(start %d.%d, end %d.%d : %2.3f\0A\00"
define void @print_time_diff(%struct.timeval* nocapture %0, %struct.timeval* nocapture %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, 1000000
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = add nsw i32 %5, %7
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = mul nsw i32 %11, 1000000
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%14 = load i32, i32* %13
%15 = add nsw i32 %12, %14
%16 = sext i32 %15 to i64
%17 = sub nsw i64 %16, %9
%18 = sitofp i64 %17 to double
%19 = fdiv double %18, 1.000000e+06
%20 = fptosi double %19 to i64
%21 = tail call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %7, i32 %11, i32 %14, i64 %20)
ret void
}