#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 main(int argc, char *argv[]) {
  struct timeval start, end;
  gettimeofday(&start, NULL);
  double timeuse;
  int j;
  for (j = 0; j < 100000; j++)
    ;
  gettimeofday(&end, NULL);
  timeuse =
      1.0 * 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
  timeuse /= 1000000.0;
  printf("运行时间为：%.6f\n", timeuse);
  printf("运行时间为: %.6f\n", (end.tv_usec - start.tv_usec) * 1.0 / 1000000 +
                                   end.tv_sec - start.tv_sec);
  return 0;
}


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    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x186a0,-0x3c(%rbp)
jge    116a <main+0x4a>
jmp    115c <main+0x3c>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    114a <main+0x2a>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe72(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe53(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe4e(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe1b(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
lea    0x38(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0x28(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x38(%rsp),%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  0x40(%rsp),%xmm3
movsd  %xmm3,0x8(%rsp)
subsd  %xmm2,%xmm0
movsd  0xe88(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
divsd  0xe58(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [24 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA\EF\BC\9A%.6f\0A\00"
@.str.1 = [23 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA: %.6f\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 double
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
store i32 0, i32* %9
br label %11
11: ; preds = %15, %2
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 100000
br i1 %13, label %14, label %18
14: ; preds = %11
br label %15
15: ; preds = %14
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
br label %11
18: ; preds = %11
%19 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%21 = load double, double* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%23 = load double, double* %22
%24 = fsub double %21, %23
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%26 = load double, double* %25
%27 = call double @llvm.fmuladd.f64(double 1.000000e+06, double %24, double %26)
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%29 = load double, double* %28
%30 = fsub double %27, %29
store double %30, double* %8
%31 = load double, double* %8
%32 = fdiv double %31, 1.000000e+06
store double %32, double* %8
%33 = load double, double* %8
%34 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %33)
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%36 = load double, double* %35
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%38 = load double, double* %37
%39 = fsub double %36, %38
%40 = fmul double %39, 1.000000e+00
%41 = fdiv double %40, 1.000000e+06
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%46 = load double, double* %45
%47 = fsub double %44, %46
%48 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %47)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [24 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA\EF\BC\9A%.6f\0A\00"
@.str.1 = [23 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA: %.6f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %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* null)
%8 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load double, double* %11
%13 = fsub double %10, %12
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%15 = load double, double* %14
%16 = tail call double @llvm.fmuladd.f64(double %13, double 1.000000e+06, double %15)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%18 = load double, double* %17
%19 = fsub double %16, %18
%20 = fdiv double %19, 1.000000e+06
%21 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), double %20)
%22 = fsub double %15, %18
%23 = fdiv double %22, 1.000000e+06
%24 = fadd double %10, %23
%25 = fsub double %24, %12
%26 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %25)
ret i32 0
}