#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;
  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 volatile j;
  for (j = 0; j < 1000000000; j++)
    ;
  gettimeofday(&end, NULL);
  timeuse = 1000000 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec;
  timeuse /= 1000000;
  printf("运行时间为：%f\n", timeuse);
  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)
mov    -0x3c(%rbp),%eax
cmp    $0x3b9aca00,%eax
jge    116b <main+0x4b>
jmp    115d <main+0x3d>
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>
mov    -0x30(%rbp),%eax
sub    -0x20(%rbp),%eax
imul   $0xf4240,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0x18(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,0x4(%rsp)
mov    0x4(%rsp),%eax
cmp    $0x3b9ac9ff,%eax
jg     1160 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addl   $0x1,0x4(%rsp)
mov    0x4(%rsp),%eax
cmp    $0x3b9aca00,%eax
jl     1150 <main+0x30>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    0x18(%rsp),%eax
imul   $0xf4240,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  0x10(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
divsd  0xe6e(%rip),%xmm0
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, double }
@.str = [22 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA\EF\BC\9A%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 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 volatile i32 0, i32* %9
br label %11
11: ; preds = %15, %2
%12 = load volatile i32, i32* %9
%13 = icmp slt i32 %12, 1000000000
br i1 %13, label %14, label %18
14: ; preds = %11
br label %15
15: ; preds = %14
%16 = load volatile i32, i32* %9
%17 = add nsw i32 %16, 1
store volatile 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 i32, i32* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%23 = load i32, i32* %22
%24 = sub nsw i32 %21, %23
%25 = mul nsw i32 1000000, %24
%26 = sitofp i32 %25 to double
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%28 = load double, double* %27
%29 = fadd double %26, %28
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%31 = load double, double* %30
%32 = fsub double %29, %31
store double %32, double* %8
%33 = load double, double* %8
%34 = fdiv double %33, 1.000000e+06
store double %34, double* %8
%35 = load double, double* %8
%36 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %35)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, double }
@.str = [22 x i8] c"\E8\BF\90\E8\A1\8C\E6\97\B6\E9\97\B4\E4\B8\BA\EF\BC\9A%f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca i32
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%9 = bitcast i32* %5 to i8*
store volatile i32 0, i32* %5
%10 = load volatile i32, i32* %5
%11 = icmp slt i32 %10, 1000000000
br i1 %11, label %12, label %17
12: ; preds = %2, %12
%13 = load volatile i32, i32* %5
%14 = add nsw i32 %13, 1
store volatile i32 %14, i32* %5
%15 = load volatile i32, i32* %5
%16 = icmp slt i32 %15, 1000000000
br i1 %16, label %12, label %17
17: ; preds = %12, %2
%18 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = sub nsw i32 %20, %22
%24 = mul nsw i32 %23, 1000000
%25 = sitofp i32 %24 to double
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%27 = load double, double* %26
%28 = fadd double %27, %25
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%30 = load double, double* %29
%31 = fsub double %28, %30
%32 = fdiv double %31, 1.000000e+06
%33 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), double %32)
ret i32 0
}