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

/* Variables and functions */
double HZ;
int /*<<< orphan*/ error(char *, int /*<<< orphan*/);
int /*<<< orphan*/ getparam(char *);
int times(struct tms *);
double cputime(void) {
  struct tms buffer;
  if (times(&buffer) == -1)
    error("cputime in %s: times() call failed\n", (getparam("argv0")));
  return ((buffer.tms_utime + buffer.tms_stime) / (60.0 * HZ));
}


x86 assembly (clang, -O0):
<cputime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x10(%rbp),%rdi
call   1050 <times@plt>
cmp    $0xffffffff,%eax
jne    1164 <cputime+0x34>
lea    0xedb(%rip),%rdi
call   1030 <getparam@plt>
mov    %eax,%esi
lea    0xea9(%rip),%rdi
call   1040 <error@plt>
movsd  -0x10(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xe8a(%rip),%xmm1
mov    0x2e63(%rip),%rax
mulsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cputime>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
call   1050 <times@plt>
cmp    $0xffffffff,%eax
jne    115d <cputime+0x2d>
lea    0xee2(%rip),%rdi
call   1030 <getparam@plt>
lea    0xeb2(%rip),%rdi
mov    %eax,%esi
call   1040 <error@plt>
movsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
mov    0x2e70(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xe84(%rip),%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.tms = type { double, double }
@.str = [36 x i8] c"cputime in %s: times() call failed\0A\00"
@.str.1 = [6 x i8] c"argv0\00"
@HZ = global double 0.000000e+00
define double @cputime() {
%1 = alloca %struct.tms
%2 = call i32 @times(%struct.tms* %1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @getparam(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %4, %0
%8 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 0
%9 = load double, double* %8
%10 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 1
%11 = load double, double* %10
%12 = fadd double %9, %11
%13 = load double, double* @HZ
%14 = fmul double 6.000000e+01, %13
%15 = fdiv double %12, %14
ret double %15
}

LLVM IR (-O2):
%struct.tms = type { double, double }
@.str = [36 x i8] c"cputime in %s: times() call failed\0A\00"
@.str.1 = [6 x i8] c"argv0\00"
@HZ = global double 0.000000e+00
define double @cputime() {
%1 = alloca %struct.tms
%2 = bitcast %struct.tms* %1 to i8*
%3 = call i32 @times(%struct.tms* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @getparam(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %5, %0
%9 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 0
%10 = load double, double* %9
%11 = getelementptr inbounds %struct.tms, %struct.tms* %1, i64 0, i32 1
%12 = load double, double* %11
%13 = fadd double %10, %12
%14 = load double, double* @HZ
%15 = fmul double %14, 6.000000e+01
%16 = fdiv double %13, %15
ret double %16
}