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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void print_time(char *label, int n) {
  static struct timeval t0;
  struct timeval t;
  int usec;
  if (label) {
    printf("%s - repeat %d\n", label, n);
    gettimeofday(&t0, 0);
    return;
  }
  gettimeofday(&t, 0);
  usec = (t.tv_sec - t0.tv_sec) * 1000000 + (t.tv_usec - t0.tv_usec);
  printf("- %.3f seconds, %d usec/transform\n", usec / 1000000.0, usec / n);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1162 <print_time+0x42>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0x2ede(%rip),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
jmp    11b2 <print_time+0x92>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    -0x18(%rbp),%eax
sub    0x2ebe(%rip),%eax
imul   $0xf4240,%eax,%eax
mov    -0x14(%rbp),%ecx
sub    0x2eb3(%rip),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe69(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x1c(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
test   %rdi,%rdi
je     1152 <print_time+0x32>
mov    %rdi,%rsi
lea    0xed2(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x2eee(%rip),%rdi
xor    %esi,%esi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <gettimeofday@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%eax
sub    0x2ec8(%rip),%ecx
sub    0x2ec6(%rip),%eax
imul   $0xf4240,%ecx,%ecx
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
divsd  0xe7a(%rip),%xmm0
cltd
idiv   %ebx
lea    0xe88(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@print_time.t0 = internal global %struct.timeval zeroinitializer
@.str = [16 x i8] c"%s - repeat %d\0A\00"
@.str.1 = [35 x i8] c"- %.3f seconds, %d usec/transform\0A\00"
define void @print_time(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = call i32 @gettimeofday(%struct.timeval* @print_time.t0, i32 0)
br label %33
14: ; preds = %2
%15 = call i32 @gettimeofday(%struct.timeval* %5, i32 0)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @print_time.t0, i32 0, i32 0)
%19 = sub nsw i32 %17, %18
%20 = mul nsw i32 %19, 1000000
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @print_time.t0, i32 0, i32 1)
%24 = sub nsw i32 %22, %23
%25 = add nsw i32 %20, %24
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 1.000000e+06
%29 = load i32, i32* %6
%30 = load i32, i32* %4
%31 = sdiv i32 %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %28, i32 %31)
br label %33
33: ; preds = %14, %9
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@print_time.t0 = internal global %struct.timeval zeroinitializer
@.str = [16 x i8] c"%s - repeat %d\0A\00"
@.str.1 = [35 x i8] c"- %.3f seconds, %d usec/transform\0A\00"
define void @print_time(i8* %0, i32 %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%8 = tail call i32 @gettimeofday(%struct.timeval* @print_time.t0, i32 0)
br label %25
9: ; preds = %2
%10 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @print_time.t0, i64 0, i32 0)
%14 = sub nsw i32 %12, %13
%15 = mul nsw i32 %14, 1000000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%17 = load i32, i32* %16
%18 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @print_time.t0, i64 0, i32 1)
%19 = sub nsw i32 %17, %18
%20 = add nsw i32 %19, %15
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 1.000000e+06
%23 = sdiv i32 %20, %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %22, i32 %23)
br label %25
25: ; preds = %9, %6
ret void
}