#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ mktime(struct tm *);
float timeit(struct tm *dates, long ndates) {
  struct timeval tbeg, tend, tres;
  gettimeofday(&tbeg, NULL);
  long s;
  for (s = 0; s < ndates; s++) {
    time_t made = mktime(&dates[s]);
  }
  gettimeofday(&tend, NULL);
  return ((tend.tv_sec * 1e6 + tend.tv_usec) -
          (tbeg.tv_sec * 1e6 + tbeg.tv_usec)) /
         1e6;
}


x86 assembly (clang, -O0):
<timeit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    117b <timeit+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1040 <mktime@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1145 <timeit+0x25>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe66(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  0xe4c(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeit>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
test   %r14,%r14
jle    1152 <timeit+0x32>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <mktime@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r14
jne    1140 <timeit+0x20>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
movss  0x10(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
unpcklps %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movss  0x14(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
unpcklps %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm1
mulpd  0xe74(%rip),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
divsd  0xe6c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define float @timeit(%struct.tm* %0, i64 %1) {
%3 = alloca %struct.tm*
%4 = alloca i64
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca i64
%9 = alloca i32
store %struct.tm* %0, %struct.tm** %3
store i64 %1, i64* %4
%10 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
store i64 0, i64* %8
br label %11
11: ; preds = %20, %2
%12 = load i64, i64* %8
%13 = load i64, i64* %4
%14 = icmp slt i64 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load %struct.tm*, %struct.tm** %3
%17 = load i64, i64* %8
%18 = getelementptr inbounds %struct.tm, %struct.tm* %16, i64 %17
%19 = call i32 @mktime(%struct.tm* %18)
store i32 %19, i32* %9
br label %20
20: ; preds = %15
%21 = load i64, i64* %8
%22 = add nsw i64 %21, 1
store i64 %22, i64* %8
br label %11
23: ; preds = %11
%24 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%26 = load i32, i32* %25
%27 = sitofp i32 %26 to double
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%29 = load i32, i32* %28
%30 = sitofp i32 %29 to double
%31 = call double @llvm.fmuladd.f64(double %27, double 1.000000e+06, double %30)
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%33 = load i32, i32* %32
%34 = sitofp i32 %33 to double
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%36 = load i32, i32* %35
%37 = sitofp i32 %36 to double
%38 = call double @llvm.fmuladd.f64(double %34, double 1.000000e+06, double %37)
%39 = fsub double %31, %38
%40 = fdiv double %39, 1.000000e+06
%41 = fptrunc double %40 to float
ret float %41
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.timeval = type { i32, i32 }
define float @timeit(%struct.tm* nocapture %0, i64 %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 = icmp sgt i64 %1, 0
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = phi i64 [ %13, %9 ], [ 0, %2 ]
%11 = getelementptr inbounds %struct.tm, %struct.tm* %0, i64 %10
%12 = tail call i32 @mktime(%struct.tm* %11)
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %15, label %9
15: ; preds = %9, %2
%16 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%22 = load i32, i32* %21
%23 = insertelement <2 x i32> poison, i32 %18, i64 0
%24 = insertelement <2 x i32> %23, i32 %22, i64 1
%25 = sitofp <2 x i32> %24 to <2 x double>
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%27 = load i32, i32* %26
%28 = insertelement <2 x i32> poison, i32 %20, i64 0
%29 = insertelement <2 x i32> %28, i32 %27, i64 1
%30 = sitofp <2 x i32> %29 to <2 x double>
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %25, <2 x double> <double 1.000000e+06, double 1.000000e+06>, <2 x double> %30)
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%33 = fsub <2 x double> %31, %32
%34 = extractelement <2 x double> %33, i64 0
%35 = fdiv double %34, 1.000000e+06
%36 = fptrunc double %35 to float
ret float %36
}