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

/* Variables and functions */
int /*<<< orphan*/ _SC_CLK_TCK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
long sysconf(int /*<<< orphan*/);
void pr_times(clock_t real, struct tms *tmsstart, struct tms *tmsend) {
  static long clktck = 0;
  if (clktck == 0) {
    if ((clktck = sysconf(_SC_CLK_TCK)) < 0) {
      fprintf(stderr, "sysconf error\n");
      exit(1);
    }
  }
  printf("  real:  %7.2f\n", real / (double)clktck);
  printf("  user:  %7.2f\n",
         (tmsend->tms_utime - tmsstart->tms_utime) / (double)clktck);
  printf("  sys:   %7.2f\n",
         (tmsend->tms_stime - tmsstart->tms_stime) / (double)clktck);
  printf("  child user:  %7.2f\n",
         (tmsend->tms_cutime - tmsstart->tms_cutime) / (double)clktck);
  printf("  child sys:   %7.2f\n",
         (tmsend->tms_cstime - tmsstart->tms_cstime) / (double)clktck);
}


x86 assembly (clang, -O0):
<pr_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,0x2eeb(%rip)
jne    11a6 <pr_times+0x66>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %rax,0x2ed0(%rip)
cmp    $0x0,%rax
jge    11a1 <pr_times+0x61>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11a6 <pr_times+0x66>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdq 0x2e94(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdq 0x2e6b(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
cvtsi2sdq 0x2e40(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x10(%rax),%xmm0
cvtsi2sdq 0x2e15(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe01(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x18(%rax),%xmm0
cvtsi2sdq 0x2dea(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_times>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2ef7(%rip),%rax
test   %rax,%rax
jne    117e <pr_times+0x3e>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
movsd  %xmm0,(%rsp)
call   1050 <sysconf@plt>
movsd  (%rsp),%xmm0
mov    %rax,0x2ed3(%rip)
test   %rax,%rax
js     1234 <pr_times+0xf4>
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
movsd  (%rbx),%xmm0
subsd  (%r14),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x2ea0(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
movsd  0x8(%rbx),%xmm0
subsd  0x8(%r14),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x2e79(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
movsd  0x10(%rbx),%xmm0
subsd  0x10(%r14),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x2e52(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
movsd  0x18(%rbx),%xmm0
subsd  0x18(%r14),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x2e2b(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe2d(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.tms = type { double, double, double, double }
@pr_times.clktck = internal global i64 0
@_SC_CLK_TCK = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"sysconf error\0A\00"
@.str.1 = [16 x i8] c" real: %7.2f\0A\00"
@.str.2 = [16 x i8] c" user: %7.2f\0A\00"
@.str.3 = [16 x i8] c" sys: %7.2f\0A\00"
@.str.4 = [22 x i8] c" child user: %7.2f\0A\00"
@.str.5 = [22 x i8] c" child sys: %7.2f\0A\00"
define void @pr_times(double %0, %struct.tms* %1, %struct.tms* %2) {
%4 = alloca double
%5 = alloca %struct.tms*
%6 = alloca %struct.tms*
store double %0, double* %4
store %struct.tms* %1, %struct.tms** %5
store %struct.tms* %2, %struct.tms** %6
%7 = load i64, i64* @pr_times.clktck
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %3
%10 = load i32, i32* @_SC_CLK_TCK
%11 = call i64 @sysconf(i32 %10)
store i64 %11, i64* @pr_times.clktck
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %9
br label %18
18: ; preds = %17, %3
%19 = load double, double* %4
%20 = load i64, i64* @pr_times.clktck
%21 = sitofp i64 %20 to double
%22 = fdiv double %19, %21
%23 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = load %struct.tms*, %struct.tms** %6
%25 = getelementptr inbounds %struct.tms, %struct.tms* %24, i32 0, i32 0
%26 = load double, double* %25
%27 = load %struct.tms*, %struct.tms** %5
%28 = getelementptr inbounds %struct.tms, %struct.tms* %27, i32 0, i32 0
%29 = load double, double* %28
%30 = fsub double %26, %29
%31 = load i64, i64* @pr_times.clktck
%32 = sitofp i64 %31 to double
%33 = fdiv double %30, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %33)
%35 = load %struct.tms*, %struct.tms** %6
%36 = getelementptr inbounds %struct.tms, %struct.tms* %35, i32 0, i32 1
%37 = load double, double* %36
%38 = load %struct.tms*, %struct.tms** %5
%39 = getelementptr inbounds %struct.tms, %struct.tms* %38, i32 0, i32 1
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = load i64, i64* @pr_times.clktck
%43 = sitofp i64 %42 to double
%44 = fdiv double %41, %43
%45 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %44)
%46 = load %struct.tms*, %struct.tms** %6
%47 = getelementptr inbounds %struct.tms, %struct.tms* %46, i32 0, i32 2
%48 = load double, double* %47
%49 = load %struct.tms*, %struct.tms** %5
%50 = getelementptr inbounds %struct.tms, %struct.tms* %49, i32 0, i32 2
%51 = load double, double* %50
%52 = fsub double %48, %51
%53 = load i64, i64* @pr_times.clktck
%54 = sitofp i64 %53 to double
%55 = fdiv double %52, %54
%56 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %55)
%57 = load %struct.tms*, %struct.tms** %6
%58 = getelementptr inbounds %struct.tms, %struct.tms* %57, i32 0, i32 3
%59 = load double, double* %58
%60 = load %struct.tms*, %struct.tms** %5
%61 = getelementptr inbounds %struct.tms, %struct.tms* %60, i32 0, i32 3
%62 = load double, double* %61
%63 = fsub double %59, %62
%64 = load i64, i64* @pr_times.clktck
%65 = sitofp i64 %64 to double
%66 = fdiv double %63, %65
%67 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %66)
ret void
}

LLVM IR (-O2):
%struct.tms = type { double, double, double, double }
@pr_times.clktck = internal unnamed_addr global i64 0
@_SC_CLK_TCK = global i32 0
@stderr = global i32 0
@.str = [15 x i8] c"sysconf error\0A\00"
@.str.1 = [16 x i8] c" real: %7.2f\0A\00"
@.str.2 = [16 x i8] c" user: %7.2f\0A\00"
@.str.3 = [16 x i8] c" sys: %7.2f\0A\00"
@.str.4 = [22 x i8] c" child user: %7.2f\0A\00"
@.str.5 = [22 x i8] c" child sys: %7.2f\0A\00"
define void @pr_times(double %0, %struct.tms* nocapture %1, %struct.tms* nocapture %2) {
%4 = load i64, i64* @pr_times.clktck
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i32, i32* @_SC_CLK_TCK
%8 = tail call i64 @sysconf(i32 %7)
store i64 %8, i64* @pr_times.clktck
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %6, %3
%15 = phi i64 [ %8, %6 ], [ %4, %3 ]
%16 = sitofp i64 %15 to double
%17 = fdiv double %0, %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), double %17)
%19 = getelementptr inbounds %struct.tms, %struct.tms* %2, i64 0, i32 0
%20 = load double, double* %19
%21 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 0
%22 = load double, double* %21
%23 = fsub double %20, %22
%24 = load i64, i64* @pr_times.clktck
%25 = sitofp i64 %24 to double
%26 = fdiv double %23, %25
%27 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), double %26)
%28 = getelementptr inbounds %struct.tms, %struct.tms* %2, i64 0, i32 1
%29 = load double, double* %28
%30 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 1
%31 = load double, double* %30
%32 = fsub double %29, %31
%33 = load i64, i64* @pr_times.clktck
%34 = sitofp i64 %33 to double
%35 = fdiv double %32, %34
%36 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), double %35)
%37 = getelementptr inbounds %struct.tms, %struct.tms* %2, i64 0, i32 2
%38 = load double, double* %37
%39 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 2
%40 = load double, double* %39
%41 = fsub double %38, %40
%42 = load i64, i64* @pr_times.clktck
%43 = sitofp i64 %42 to double
%44 = fdiv double %41, %43
%45 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %44)
%46 = getelementptr inbounds %struct.tms, %struct.tms* %2, i64 0, i32 3
%47 = load double, double* %46
%48 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 3
%49 = load double, double* %48
%50 = fsub double %47, %49
%51 = load i64, i64* @pr_times.clktck
%52 = sitofp i64 %51 to double
%53 = fdiv double %50, %52
%54 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %53)
ret void
}