#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 timespec {
  double tv_sec;
  double tv_nsec;
};
struct sysinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
double one_sysinfo_step(void) {
  struct timespec t1, t2;
  int i;
  struct sysinfo info;
  clock_gettime(CLOCK_MONOTONIC, &t1);
  for (i = 0; i < 100000; i++)
    sysinfo(&info);
  clock_gettime(CLOCK_MONOTONIC, &t2);
  return (t2.tv_sec - t1.tv_sec) + 1.0e-9 * (t2.tv_nsec - t1.tv_nsec);
}


x86 assembly (clang, -O0):
<one_sysinfo_step>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x186a0,-0x24(%rbp)
jge    1165 <one_sysinfo_step+0x45>
lea    -0x28(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <one_sysinfo_step+0x21>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
movsd  -0x20(%rbp),%xmm1
subsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<one_sysinfo_step>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0x2eb9(%rip),%r14
mov    (%r14),%edi
lea    0x20(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    $0x186a0,%ebp
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <sysinfo@plt>
add    $0xffffffff,%ebp
jne    1150 <one_sysinfo_step+0x30>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1030 <clock_gettime@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
subsd  0x20(%rsp),%xmm1
subsd  0x28(%rsp),%xmm0
mulsd  0xe76(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timespec = type { double, double }
%struct.sysinfo = type { i32 }
@CLOCK_MONOTONIC = global i32 0
define double @one_sysinfo_step() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca i32
%4 = alloca %struct.sysinfo
%5 = load i32, i32* @CLOCK_MONOTONIC
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* %1)
store i32 0, i32* %3
br label %7
7: ; preds = %12, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 100000
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = call i32 @sysinfo(%struct.sysinfo* %4)
br label %12
12: ; preds = %10
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %7
15: ; preds = %7
%16 = load i32, i32* @CLOCK_MONOTONIC
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %2)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%19 = load double, double* %18
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%21 = load double, double* %20
%22 = fsub double %19, %21
%23 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%24 = load double, double* %23
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%26 = load double, double* %25
%27 = fsub double %24, %26
%28 = call double @llvm.fmuladd.f64(double 1.000000e-09, double %27, double %22)
ret double %28
}

LLVM IR (-O2):
%struct.timespec = type { double, double }
%struct.sysinfo = type { i32 }
@CLOCK_MONOTONIC = global i32 0
define double @one_sysinfo_step() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = alloca %struct.sysinfo
%4 = bitcast %struct.timespec* %1 to i8*
%5 = bitcast %struct.timespec* %2 to i8*
%6 = bitcast %struct.sysinfo* %3 to i8*
%7 = load i32, i32* @CLOCK_MONOTONIC
%8 = call i32 @clock_gettime(i32 %7, %struct.timespec* %1)
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 0, %0 ], [ %12, %9 ]
%11 = call i32 @sysinfo(%struct.sysinfo* %3)
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, 100000
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = load i32, i32* @CLOCK_MONOTONIC
%16 = call i32 @clock_gettime(i32 %15, %struct.timespec* %2)
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%18 = load double, double* %17
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%20 = load double, double* %19
%21 = fsub double %18, %20
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%23 = load double, double* %22
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%25 = load double, double* %24
%26 = fsub double %23, %25
%27 = call double @llvm.fmuladd.f64(double %26, double 1.000000e-09, double %21)
ret double %27
}