#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 {
  scalar_t__ tms_cstime;
  scalar_t__ tms_cutime;
  scalar_t__ tms_stime;
  scalar_t__ tms_utime;
};
typedef int /*<<< orphan*/ clock_t;

/* Variables and functions */
scalar_t__ HZ;
int /*<<< orphan*/ times(struct tms *);
double csecond() {
  struct tms buf;
  static struct tms buf0;
  static int firstcall = 1;
  clock_t rv;
  static clock_t rv0;
  if (firstcall) {
    firstcall = 0;
    rv0 = times(&buf0);
  }
  rv = times(&buf);
  return ((double)((buf.tms_utime + buf.tms_stime + buf.tms_cutime +
                    buf.tms_cstime) -
                   (buf0.tms_utime + buf0.tms_stime + buf0.tms_cutime +
                    buf0.tms_cstime)) /
          (double)HZ);
}


x86 assembly (clang, -O0):
<csecond>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
cmpl   $0x0,0x2f09(%rip)
je     1141 <csecond+0x31>
movl   $0x0,0x2ef9(%rip)
lea    0x2f02(%rip),%rdi
call   1030 <times@plt>
mov    %eax,0x2f17(%rip)
lea    -0x20(%rbp),%rdi
call   1030 <times@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
add    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    0x2eec(%rip),%rcx
add    0x2edd(%rip),%rcx
add    0x2ece(%rip),%rcx
add    0x2ebf(%rip),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e58(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csecond>:
sub    $0x28,%rsp
cmpb   $0x0,0x2f65(%rip)
jne    1130 <csecond+0x20>
movb   $0x1,0x2f5c(%rip)
lea    0x2f35(%rip),%rdi
call   1030 <times@plt>
mov    %rsp,%rdi
call   1030 <times@plt>
movdqa (%rsp),%xmm0
movdqa 0x10(%rsp),%xmm1
psubq  0x2f25(%rip),%xmm1
psubq  0x2f0d(%rip),%xmm0
paddq  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddq  %xmm0,%xmm1
movq   %xmm1,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2e6c(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.tms = type { i64, i64, i64, i64 }
@csecond.buf0 = internal global %struct.tms zeroinitializer
@csecond.firstcall = internal global i32 1
@csecond.rv0 = internal global i32 0
@HZ = global i64 0
define double @csecond() {
%1 = alloca %struct.tms
%2 = alloca i32
%3 = load i32, i32* @csecond.firstcall
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
store i32 0, i32* @csecond.firstcall
%6 = call i32 @times(%struct.tms* @csecond.buf0)
store i32 %6, i32* @csecond.rv0
br label %7
7: ; preds = %5, %0
%8 = call i32 @times(%struct.tms* %1)
store i32 %8, i32* %2
%9 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 3
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 2
%12 = load i64, i64* %11
%13 = add nsw i64 %10, %12
%14 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 1
%15 = load i64, i64* %14
%16 = add nsw i64 %13, %15
%17 = getelementptr inbounds %struct.tms, %struct.tms* %1, i32 0, i32 0
%18 = load i64, i64* %17
%19 = add nsw i64 %16, %18
%20 = load i64, i64* getelementptr inbounds (%struct.tms, %struct.tms* @csecond.buf0, i32 0, i32 3)
%21 = load i64, i64* getelementptr inbounds (%struct.tms, %struct.tms* @csecond.buf0, i32 0, i32 2)
%22 = add nsw i64 %20, %21
%23 = load i64, i64* getelementptr inbounds (%struct.tms, %struct.tms* @csecond.buf0, i32 0, i32 1)
%24 = add nsw i64 %22, %23
%25 = load i64, i64* getelementptr inbounds (%struct.tms, %struct.tms* @csecond.buf0, i32 0, i32 0)
%26 = add nsw i64 %24, %25
%27 = sub nsw i64 %19, %26
%28 = sitofp i64 %27 to double
%29 = load i64, i64* @HZ
%30 = sitofp i64 %29 to double
%31 = fdiv double %28, %30
ret double %31
}

LLVM IR (-O2):
%struct.tms = type { i64, i64, i64, i64 }
@csecond.buf0 = internal global %struct.tms zeroinitializer
@csecond.firstcall = internal unnamed_addr global i1 false
@HZ = global i64 0
define double @csecond() {
%1 = alloca <4 x i64>
%2 = bitcast <4 x i64>* %1 to i8*
%3 = load i1, i1* @csecond.firstcall
br i1 %3, label %6, label %4
4: ; preds = %0
store i1 true, i1* @csecond.firstcall
%5 = tail call i32 @times(%struct.tms* @csecond.buf0)
br label %6
6: ; preds = %4, %0
%7 = bitcast <4 x i64>* %1 to %struct.tms*
%8 = call i32 @times(%struct.tms* %7)
%9 = load <4 x i64>, <4 x i64>* %1
%10 = load <4 x i64>, <4 x i64>* bitcast (%struct.tms* @csecond.buf0 to <4 x i64>*)
%11 = sub <4 x i64> %9, %10
%12 = call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> %11)
%13 = sitofp i64 %12 to double
%14 = load i64, i64* @HZ
%15 = sitofp i64 %14 to double
%16 = fdiv double %13, %15
ret double %16
}