#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 tms {
  double tms_cutime;
  double tms_cstime;
};
typedef double clock_t;

/* Variables and functions */
int /*<<< orphan*/ _SC_CLK_TCK;
int /*<<< orphan*/ printf(char *, int, double, int, double, int, double);
double sysconf(int /*<<< orphan*/);
double times(struct tms *);
void print_time(clock_t before, struct tms start) {
  struct tms end;
  double ticks, utime, stime, rtime, utime_sec, stime_sec, rtime_sec;
  int utime_min, stime_min, rtime_min;
  clock_t after = times(&end);
  ticks = sysconf(_SC_CLK_TCK);
  rtime = (after - before) / ticks;
  utime = (end.tms_cutime - start.tms_cutime) / ticks;
  stime = (end.tms_cstime - start.tms_cstime) / ticks;
  rtime_min = rtime / 60.0;
  utime_min = utime / 60.0;
  stime_min = stime / 60.0;
  rtime_sec = rtime - rtime_min;
  utime_sec = utime - utime_min;
  stime_sec = stime - stime_min;
  printf("\nreal    %dm%.3fs\nuser    %dm%.3fs\nsys     %dm%.3fs\n", rtime_min,
         rtime_sec, utime_min, utime_sec, stime_min, stime_sec);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x8(%rbp)
movsd  %xmm0,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <times@plt>
movsd  %xmm0,-0x78(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x78(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe4c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x6c(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x64(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x68(%rbp)
movsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x6c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x64(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x68(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x6c(%rbp),%esi
movsd  -0x60(%rbp),%xmm0
mov    -0x64(%rbp),%edx
movsd  -0x50(%rbp),%xmm1
mov    -0x68(%rbp),%ecx
movsd  -0x58(%rbp),%xmm2
lea    0xdc1(%rip),%rdi
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
sub    $0x38,%rsp
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
lea    0x28(%rsp),%rdi
call   1040 <times@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
movsd  0x8(%rsp),%xmm6
subsd  0x10(%rsp),%xmm6
divsd  %xmm0,%xmm6
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
subsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe6e(%rip),%xmm3
movapd %xmm6,%xmm4
divsd  %xmm3,%xmm4
cvttsd2si %xmm4,%esi
subsd  0x20(%rsp),%xmm2
movapd %xmm1,%xmm5
divsd  %xmm3,%xmm5
cvttsd2si %xmm5,%edx
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
divsd  %xmm3,%xmm0
cvttsd2si %xmm0,%ecx
cvttpd2dq %xmm4,%xmm3
cvtdq2pd %xmm3,%xmm3
cvttpd2dq %xmm5,%xmm4
cvtdq2pd %xmm4,%xmm4
subsd  %xmm3,%xmm6
subsd  %xmm4,%xmm1
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm2
lea    0xe1d(%rip),%rdi
movapd %xmm6,%xmm0
add    $0x38,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.tms = type { double, double }
@_SC_CLK_TCK = global i32 0
@.str = [53 x i8] c"\0Areal %dm%.3fs\0Auser %dm%.3fs\0Asys %dm%.3fs\0A\00"
define void @print_time(double %0, double %1, double %2) {
%4 = alloca %struct.tms
%5 = alloca double
%6 = alloca %struct.tms
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = bitcast %struct.tms* %4 to { double, double }*
%19 = getelementptr inbounds { double, double }, { double, double }* %18, i32 0, i32 0
store double %1, double* %19
%20 = getelementptr inbounds { double, double }, { double, double }* %18, i32 0, i32 1
store double %2, double* %20
store double %0, double* %5
%21 = call double @times(%struct.tms* %6)
store double %21, double* %17
%22 = load i32, i32* @_SC_CLK_TCK
%23 = call double @sysconf(i32 %22)
store double %23, double* %7
%24 = load double, double* %17
%25 = load double, double* %5
%26 = fsub double %24, %25
%27 = load double, double* %7
%28 = fdiv double %26, %27
store double %28, double* %10
%29 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%30 = load double, double* %29
%31 = getelementptr inbounds %struct.tms, %struct.tms* %4, i32 0, i32 0
%32 = load double, double* %31
%33 = fsub double %30, %32
%34 = load double, double* %7
%35 = fdiv double %33, %34
store double %35, double* %8
%36 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%37 = load double, double* %36
%38 = getelementptr inbounds %struct.tms, %struct.tms* %4, i32 0, i32 1
%39 = load double, double* %38
%40 = fsub double %37, %39
%41 = load double, double* %7
%42 = fdiv double %40, %41
store double %42, double* %9
%43 = load double, double* %10
%44 = fdiv double %43, 6.000000e+01
%45 = fptosi double %44 to i32
store i32 %45, i32* %16
%46 = load double, double* %8
%47 = fdiv double %46, 6.000000e+01
%48 = fptosi double %47 to i32
store i32 %48, i32* %14
%49 = load double, double* %9
%50 = fdiv double %49, 6.000000e+01
%51 = fptosi double %50 to i32
store i32 %51, i32* %15
%52 = load double, double* %10
%53 = load i32, i32* %16
%54 = sitofp i32 %53 to double
%55 = fsub double %52, %54
store double %55, double* %13
%56 = load double, double* %8
%57 = load i32, i32* %14
%58 = sitofp i32 %57 to double
%59 = fsub double %56, %58
store double %59, double* %11
%60 = load double, double* %9
%61 = load i32, i32* %15
%62 = sitofp i32 %61 to double
%63 = fsub double %60, %62
store double %63, double* %12
%64 = load i32, i32* %16
%65 = load double, double* %13
%66 = load i32, i32* %14
%67 = load double, double* %11
%68 = load i32, i32* %15
%69 = load double, double* %12
%70 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %64, double %65, i32 %66, double %67, i32 %68, double %69)
ret void
}

LLVM IR (-O2):
%struct.tms = type { double, double }
@_SC_CLK_TCK = global i32 0
@.str = [53 x i8] c"\0Areal %dm%.3fs\0Auser %dm%.3fs\0Asys %dm%.3fs\0A\00"
define void @print_time(double %0, double %1, double %2) {
%4 = alloca %struct.tms
%5 = bitcast %struct.tms* %4 to i8*
%6 = call double @times(%struct.tms* %4)
%7 = load i32, i32* @_SC_CLK_TCK
%8 = tail call double @sysconf(i32 %7)
%9 = fsub double %6, %0
%10 = fdiv double %9, %8
%11 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 0
%12 = load double, double* %11
%13 = fsub double %12, %1
%14 = fdiv double %13, %8
%15 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 1
%16 = load double, double* %15
%17 = fsub double %16, %2
%18 = fdiv double %17, %8
%19 = fdiv double %10, 6.000000e+01
%20 = fptosi double %19 to i32
%21 = fdiv double %14, 6.000000e+01
%22 = fptosi double %21 to i32
%23 = fdiv double %18, 6.000000e+01
%24 = fptosi double %23 to i32
%25 = sitofp i32 %20 to double
%26 = fsub double %10, %25
%27 = sitofp i32 %22 to double
%28 = fsub double %14, %27
%29 = sitofp i32 %24 to double
%30 = fsub double %18, %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i32 %20, double %26, i32 %22, double %28, i32 %24, double %30)
ret void
}