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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ function();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, float);
main() {
  struct timeval tpstart, tpend;
  float timeuse;
  gettimeofday(&tpstart, NULL);
  function();
  gettimeofday(&tpend, NULL);
  timeuse = 1000000 * (tpend.tv_sec - tpstart.tv_sec) + tpend.tv_usec -
            tpstart.tv_usec;
  timeuse /= 1000000;
  printf("Used Time:%f\n", timeuse);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    $0x0,%al
call   1050 <function@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    -0x10(%rbp),%eax
imul   $0xf4240,%eax,%eax
cvtsi2ss %eax,%xmm0
addss  -0x14(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xe64(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <function@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%eax
sub    0x10(%rsp),%eax
imul   $0xf4240,%eax,%eax
cvtsi2ss %eax,%xmm0
addss  0xc(%rsp),%xmm0
subss  0x14(%rsp),%xmm0
divss  0xe77(%rip),%xmm0
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, float }
@.str = [14 x i8] c"Used Time:%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = call i32 (...) @function()
%7 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%11 = load i32, i32* %10
%12 = sub nsw i32 %9, %11
%13 = mul nsw i32 1000000, %12
%14 = sitofp i32 %13 to float
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 1
%16 = load float, float* %15
%17 = fadd float %14, %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%19 = load float, float* %18
%20 = fsub float %17, %19
store float %20, float* %4
%21 = load float, float* %4
%22 = fdiv float %21, 1.000000e+06
store float %22, float* %4
%23 = load float, float* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %23)
%25 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i32, float }
@.str = [14 x i8] c"Used Time:%f\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%6 = tail call i32 (...) @function()
%7 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = sub nsw i32 %9, %11
%13 = mul nsw i32 %12, 1000000
%14 = sitofp i32 %13 to float
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%16 = load float, float* %15
%17 = fadd float %16, %14
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%19 = load float, float* %18
%20 = fsub float %17, %19
%21 = fdiv float %20, 1.000000e+06
%22 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), float %21)
%23 = tail call i32 @exit(i32 0)
unreachable
}