#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*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ system(char *);
int main(void) {
  struct timeval t1, t2;
  double timeuse = 0.0;
  gettimeofday(&t1, NULL);
  system("./t1_s1");
  gettimeofday(&t2, NULL);
  timeuse = t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) / 1000000.0;
  printf("t1_s1: %fsecs\n", timeuse);
  gettimeofday(&t1, NULL);
  system("./t1_s2");
  gettimeofday(&t2, NULL);
  timeuse = t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) / 1000000.0;
  printf("t1_s2: %fsecs\n", timeuse);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    0xead(%rip),%rdi
call   1030 <system@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe77(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    0xe64(%rip),%rdi
call   1030 <system@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  0xe17(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xebb(%rip),%rdi
call   1030 <system@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movapd (%rsp),%xmm1
subpd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xe86(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xe84(%rip),%rdi
call   1030 <system@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movapd (%rsp),%xmm1
subpd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
divsd  0xe3b(%rip),%xmm0
addsd  %xmm1,%xmm0
lea    0xe57(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [8 x i8] c"./t1_s1\00"
@.str.1 = [15 x i8] c"t1_s1: %fsecs\0A\00"
@.str.2 = [8 x i8] c"./t1_s2\00"
@.str.3 = [15 x i8] c"t1_s2: %fsecs\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%9 = load double, double* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%11 = load double, double* %10
%12 = fsub double %9, %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%14 = load double, double* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%16 = load double, double* %15
%17 = fsub double %14, %16
%18 = fdiv double %17, 1.000000e+06
%19 = fadd double %12, %18
store double %19, double* %4
%20 = load double, double* %4
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%23 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%26 = load double, double* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%28 = load double, double* %27
%29 = fsub double %26, %28
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%31 = load double, double* %30
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%33 = load double, double* %32
%34 = fsub double %31, %33
%35 = fdiv double %34, 1.000000e+06
%36 = fadd double %29, %35
store double %36, double* %4
%37 = load double, double* %4
%38 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %37)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [8 x i8] c"./t1_s1\00"
@.str.1 = [15 x i8] c"t1_s1: %fsecs\0A\00"
@.str.2 = [8 x i8] c"./t1_s2\00"
@.str.3 = [15 x i8] c"t1_s2: %fsecs\0A\00"
define i32 @main() {
%1 = alloca <2 x double>
%2 = bitcast <2 x double>* %1 to %struct.timeval*
%3 = alloca <2 x double>
%4 = bitcast <2 x double>* %3 to %struct.timeval*
%5 = bitcast <2 x double>* %1 to i8*
%6 = bitcast <2 x double>* %3 to i8*
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%8 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%10 = load <2 x double>, <2 x double>* %3
%11 = load <2 x double>, <2 x double>* %1
%12 = fsub <2 x double> %10, %11
%13 = extractelement <2 x double> %12, i64 1
%14 = fdiv double %13, 1.000000e+06
%15 = extractelement <2 x double> %12, i64 0
%16 = fadd double %15, %14
%17 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %16)
%18 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%19 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%21 = load <2 x double>, <2 x double>* %3
%22 = load <2 x double>, <2 x double>* %1
%23 = fsub <2 x double> %21, %22
%24 = extractelement <2 x double> %23, i64 1
%25 = fdiv double %24, 1.000000e+06
%26 = extractelement <2 x double> %23, i64 0
%27 = fadd double %26, %25
%28 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %27)
ret i32 0
}