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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
void cal_run_time(struct timeval start, struct timeval end) {
  double time_slot;
  time_slot = end.tv_sec - start.tv_sec +
              ((double)end.tv_usec / 1000000 - (double)start.tv_usec / 1000000);
  printf("time coast: %lf\n", time_slot);
  return;
}


x86 assembly (clang, -O0):
<cal_run_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x8(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
movsd  0xebe(%rip),%xmm2
divsd  %xmm2,%xmm1
cvtsi2sdq -0x8(%rbp),%xmm2
movsd  0xeac(%rip),%xmm3
divsd  %xmm3,%xmm2
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cal_run_time>:
cvtsi2sd %rdi,%xmm3
cvtsi2sd %rsi,%xmm2
subsd  %xmm0,%xmm1
unpcklpd %xmm3,%xmm2
divpd  0xed6(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
lea    0xecf(%rip),%rdi
movapd %xmm2,%xmm0
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.timeval = type { double, i64 }
@.str = [17 x i8] c"time coast: %lf\0A\00"
define void @cal_run_time(double %0, i64 %1, double %2, i64 %3) {
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca double
%8 = bitcast %struct.timeval* %5 to { double, i64 }*
%9 = getelementptr inbounds { double, i64 }, { double, i64 }* %8, i32 0, i32 0
store double %0, double* %9
%10 = getelementptr inbounds { double, i64 }, { double, i64 }* %8, i32 0, i32 1
store i64 %1, i64* %10
%11 = bitcast %struct.timeval* %6 to { double, i64 }*
%12 = getelementptr inbounds { double, i64 }, { double, i64 }* %11, i32 0, i32 0
store double %2, double* %12
%13 = getelementptr inbounds { double, i64 }, { double, i64 }* %11, i32 0, i32 1
store i64 %3, i64* %13
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%17 = load double, double* %16
%18 = fsub double %15, %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%20 = load i64, i64* %19
%21 = sitofp i64 %20 to double
%22 = fdiv double %21, 1.000000e+06
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%24 = load i64, i64* %23
%25 = sitofp i64 %24 to double
%26 = fdiv double %25, 1.000000e+06
%27 = fsub double %22, %26
%28 = fadd double %18, %27
store double %28, double* %7
%29 = load double, double* %7
%30 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %29)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"time coast: %lf\0A\00"
define void @cal_run_time(double %0, i64 %1, double %2, i64 %3) {
%5 = fsub double %2, %0
%6 = insertelement <2 x i64> poison, i64 %3, i64 0
%7 = insertelement <2 x i64> %6, i64 %1, i64 1
%8 = sitofp <2 x i64> %7 to <2 x double>
%9 = fdiv <2 x double> %8, <double 1.000000e+06, double 1.000000e+06>
%10 = shufflevector <2 x double> %9, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%11 = fsub <2 x double> %9, %10
%12 = extractelement <2 x double> %11, i64 0
%13 = fadd double %5, %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %13)
ret void
}