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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
void print_time(struct timeval start, struct timeval end) {
  long int ms = ((end.tv_sec * 1000000 + end.tv_usec) -
                 (start.tv_sec * 1000000 + start.tv_usec));
  double s = ms / 1e6;
  printf("Time : %f s\n", s);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x8(%rbp)
mov    %edx,-0x20(%rbp)
mov    %rcx,-0x18(%rbp)
imul   $0xf4240,-0x20(%rbp),%eax
cltq
add    -0x18(%rbp),%rax
imul   $0xf4240,-0x10(%rbp),%ecx
movslq %ecx,%rcx
add    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
imul   $0xf4240,%edx,%eax
cltq
imul   $0xf4240,%edi,%edx
movslq %edx,%rdx
add    %rsi,%rdx
sub    %rdx,%rcx
add    %rax,%rcx
cvtsi2sd %rcx,%xmm0
divsd  0xec9(%rip),%xmm0
lea    0xeca(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [13 x i8] c"Time : %f s\0A\00"
define void @print_time(i32 %0, i64 %1, i32 %2, i64 %3) {
%5 = mul nsw i32 %2, 1000000
%6 = sext i32 %5 to i64
%7 = mul nsw i32 %0, 1000000
%8 = sext i32 %7 to i64
%9 = add i64 %8, %1
%10 = sub i64 %3, %9
%11 = add i64 %10, %6
%12 = sitofp i64 %11 to double
%13 = fdiv double %12, 1.000000e+06
%14 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %13)
ret void
}