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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, double);
int system(char *);
int main(int argc, char *argv[]) {
  struct timeval tv1, tv2;
  int ret;
  gettimeofday(&tv1, 0);
  ret = system(argv[1]);
  gettimeofday(&tv2, 0);
  printf("%f\n",
         (tv2.tv_sec - tv1.tv_sec) + (tv2.tv_usec - tv1.tv_usec) * 1E-6);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <system@plt>
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  -0x30(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%eax
sub    -0x18(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe78(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x8(%rbx),%rdi
call   1030 <system@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movsd  (%rsp),%xmm1
subsd  0x10(%rsp),%xmm1
mov    0x8(%rsp),%eax
sub    0x18(%rsp),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe88(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { double, i32 }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @gettimeofday(%struct.timeval* %6, i32 0)
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @system(i8* %12)
store i32 %13, i32* %8
%14 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%16 = load double, double* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%23 = load i32, i32* %22
%24 = sub nsw i32 %21, %23
%25 = sitofp i32 %24 to double
%26 = call double @llvm.fmuladd.f64(double %25, double 0x3EB0C6F7A0B5ED8D, double %19)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %26)
%28 = load i32, i32* %8
ret i32 %28
}

LLVM IR (-O2):
%struct.timeval = type { double, i32 }
@.str = [4 x i8] c"%f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %3 to i8*
%6 = bitcast %struct.timeval* %4 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @system(i8* %9)
%11 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%13 = load double, double* %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%15 = load double, double* %14
%16 = fsub double %13, %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
%22 = sitofp i32 %21 to double
%23 = call double @llvm.fmuladd.f64(double %22, double 0x3EB0C6F7A0B5ED8D, double %16)
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %23)
ret i32 %10
}