#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  double tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_CHILDREN;
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ exit(int);
scalar_t__ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, double, double);
void print_cpu_time(void) {
  double user, sys;
  struct rusage myusage, childusage;
  if (getrusage(RUSAGE_SELF, &myusage) < 0) {
    perror("getrusage() parent failed");
    exit(-1);
  }
  if (getrusage(RUSAGE_CHILDREN, &childusage) < 0) {
    perror("getrusage() children failed");
    exit(-1);
  }
  user = (double)myusage.ru_utime.tv_sec + myusage.ru_utime.tv_usec / 1000000.0;
  user += (double)childusage.ru_utime.tv_sec +
          childusage.ru_utime.tv_usec / 1000000.0;
  sys = (double)myusage.ru_stime.tv_sec + myusage.ru_stime.tv_usec / 1000000.0;
  sys += (double)childusage.ru_stime.tv_sec +
         childusage.ru_stime.tv_usec / 1000000.0;
  printf("\nuser time = %g, sys time = %g\n", user, sys);
}


x86 assembly (clang, -O0):
<print_cpu_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <getrusage@plt>
cmp    $0x0,%rax
jge    117a <print_cpu_time+0x3a>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    -0x50(%rbp),%rsi
call   1040 <getrusage@plt>
cmp    $0x0,%rax
jge    11ac <print_cpu_time+0x6c>
lea    0xe85(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
cvtsi2sdq -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe41(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
cvtsi2sdq -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xe21(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
cvtsi2sdq -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xdfc(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdq -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xddc(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cpu_time>:
sub    $0x48,%rsp
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1040 <getrusage@plt>
test   %rax,%rax
js     11fc <print_cpu_time+0xbc>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0x28(%rsp),%rsi
call   1040 <getrusage@plt>
test   %rax,%rax
js     1205 <print_cpu_time+0xc5>
movapd 0x10(%rsp),%xmm1
cvtsi2sdq 0x40(%rsp),%xmm0
cvtsi2sdq 0x18(%rsp),%xmm2
unpcklpd %xmm0,%xmm2
movhpd 0x38(%rsp),%xmm1
movapd 0xe60(%rip),%xmm3
divpd  %xmm3,%xmm1
addpd  %xmm2,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x30(%rsp),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sdq 0x8(%rsp),%xmm2
movapd (%rsp),%xmm4
unpcklpd %xmm1,%xmm2
movhpd 0x28(%rsp),%xmm4
divpd  %xmm3,%xmm4
addpd  %xmm2,%xmm4
movapd %xmm4,%xmm1
unpckhpd %xmm4,%xmm1
addsd  %xmm4,%xmm1
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
add    $0x48,%rsp
ret
lea    0xe0d(%rip),%rdi
jmp    120c <print_cpu_time+0xcc>
lea    0xe1e(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i64 }
%struct.TYPE_3__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
@.str = [26 x i8] c"getrusage() parent failed\00"
@RUSAGE_CHILDREN = global i32 0
@.str.1 = [28 x i8] c"getrusage() children failed\00"
@.str.2 = [32 x i8] c"\0Auser time = %g, sys time = %g\0A\00"
define void @print_cpu_time() {
%1 = alloca double
%2 = alloca double
%3 = alloca %struct.rusage
%4 = alloca %struct.rusage
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i64 @getrusage(i32 %5, %struct.rusage* %3)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
%12 = load i32, i32* @RUSAGE_CHILDREN
%13 = call i64 @getrusage(i32 %12, %struct.rusage* %4)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %11
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 1
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i64, i64* %20
%22 = sitofp i64 %21 to double
%23 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load double, double* %24
%26 = fdiv double %25, 1.000000e+06
%27 = fadd double %22, %26
store double %27, double* %1
%28 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i32 0, i32 1
%30 = load i64, i64* %29
%31 = sitofp i64 %30 to double
%32 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 1
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %32, i32 0, i32 0
%34 = load double, double* %33
%35 = fdiv double %34, 1.000000e+06
%36 = fadd double %31, %35
%37 = load double, double* %1
%38 = fadd double %37, %36
store double %38, double* %1
%39 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i32 0, i32 1
%41 = load i64, i64* %40
%42 = sitofp i64 %41 to double
%43 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%44 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %43, i32 0, i32 0
%45 = load double, double* %44
%46 = fdiv double %45, 1.000000e+06
%47 = fadd double %42, %46
store double %47, double* %2
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = sitofp i64 %50 to double
%52 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%53 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %52, i32 0, i32 0
%54 = load double, double* %53
%55 = fdiv double %54, 1.000000e+06
%56 = fadd double %51, %55
%57 = load double, double* %2
%58 = fadd double %57, %56
store double %58, double* %2
%59 = load double, double* %1
%60 = load double, double* %2
%61 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %59, double %60)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, i64 }
%struct.TYPE_3__ = type { double, i64 }
@RUSAGE_SELF = global i32 0
@.str = [26 x i8] c"getrusage() parent failed\00"
@RUSAGE_CHILDREN = global i32 0
@.str.1 = [28 x i8] c"getrusage() children failed\00"
@.str.2 = [32 x i8] c"\0Auser time = %g, sys time = %g\0A\00"
define void @print_cpu_time() {
%1 = alloca %struct.rusage
%2 = alloca %struct.rusage
%3 = bitcast %struct.rusage* %1 to i8*
%4 = bitcast %struct.rusage* %2 to i8*
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i64 @getrusage(i32 %5, %struct.rusage* %1)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
%12 = load i32, i32* @RUSAGE_CHILDREN
%13 = call i64 @getrusage(i32 %12, %struct.rusage* %2)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %11
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%20 = load i64, i64* %19
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%22 = bitcast double* %21 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 1, i32 1
%25 = load i64, i64* %24
%26 = insertelement <2 x i64> poison, i64 %20, i64 0
%27 = insertelement <2 x i64> %26, i64 %25, i64 1
%28 = sitofp <2 x i64> %27 to <2 x double>
%29 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 1, i32 0
%30 = load double, double* %29
%31 = insertelement <2 x double> %23, double %30, i64 1
%32 = fdiv <2 x double> %31, <double 1.000000e+06, double 1.000000e+06>
%33 = fadd <2 x double> %32, %28
%34 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%35 = fadd <2 x double> %33, %34
%36 = extractelement <2 x double> %35, i64 0
%37 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%38 = bitcast i64* %37 to <2 x i64>*
%39 = load <2 x i64>, <2 x i64>* %38
%40 = bitcast %struct.rusage* %1 to <2 x double>*
%41 = load <2 x double>, <2 x double>* %40
%42 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 1
%43 = load i64, i64* %42
%44 = insertelement <2 x i64> %39, i64 %43, i64 1
%45 = sitofp <2 x i64> %44 to <2 x double>
%46 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 0
%47 = load double, double* %46
%48 = insertelement <2 x double> %41, double %47, i64 1
%49 = fdiv <2 x double> %48, <double 1.000000e+06, double 1.000000e+06>
%50 = fadd <2 x double> %49, %45
%51 = shufflevector <2 x double> %50, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%52 = fadd <2 x double> %50, %51
%53 = extractelement <2 x double> %52, i64 0
%54 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), double %36, double %53)
ret void
}