#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_sec;
  double tv_usec;
};
struct TYPE_3__ {
  double tv_sec;
  double tv_usec;
};
struct rusage {
  int /*<<< orphan*/ ru_nivcsw;
  int /*<<< orphan*/ ru_nvcsw;
  int /*<<< orphan*/ ru_nswap;
  int /*<<< orphan*/ ru_minflt;
  int /*<<< orphan*/ ru_majflt;
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ memset(struct rusage *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
void usage_dump() {
  struct rusage usage;
  if (getrusage(RUSAGE_SELF, &usage) < 0) {
    memset(&usage, 0, sizeof(struct rusage));
  }
  fprintf(stderr, "\nMemory statistics:");
  fprintf(stderr, "\n==================\n");
  fprintf(stderr, "User time: %.03lf ms\nSystem time: %.03lf ms\n",
          usage.ru_utime.tv_sec * (double)1000.0 +
              usage.ru_utime.tv_usec / (double)1000.0,
          usage.ru_stime.tv_sec * (double)1000.0 +
              usage.ru_stime.tv_usec / (double)1000.0);
  fprintf(stderr,
          "Major page faults: %lu (required I/O)\nMinor page faults: %lu\n",
          usage.ru_majflt, usage.ru_minflt);
  fprintf(stderr, "Number of swaps: %lu\n", usage.ru_nswap);
  fprintf(
      stderr,
      "Voluntary context switches: %lu\nInvoluntary context switches: %lu\n",
      usage.ru_nvcsw, usage.ru_nivcsw);
  fprintf(stderr, "==================\n");
}


x86 assembly (clang, -O0):
<usage_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
call   1050 <getrusage@plt>
cmp    $0x0,%rax
jge    1164 <usage_dump+0x34>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe53(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xe47(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  0xe2d(%rip),%xmm3
divsd  %xmm3,%xmm2
movsd  0xe21(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
lea    0xe43(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage_dump>:
push   %rbx
sub    $0x40,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1050 <getrusage@plt>
test   %rax,%rax
jns    115e <usage_dump+0x2e>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1030 <memset@plt>
mov    0x2e7b(%rip),%rbx
mov    (%rbx),%edi
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe9e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x28(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm3
movsd  0x30(%rsp),%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
divsd  %xmm1,%xmm2
mulsd  0x20(%rsp),%xmm1
addsd  %xmm2,%xmm1
lea    0xe6f(%rip),%rsi
mov    $0x2,%al
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    0x14(%rsp),%ecx
mov    0x18(%rsp),%edx
lea    0xe84(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    0x10(%rsp),%edx
lea    0xeae(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%edx
lea    0xeac(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe07(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.rusage = type { i32, i32, i32, i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, double }
%struct.TYPE_3__ = type { double, double }
@RUSAGE_SELF = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"\0AMemory statistics:\00"
@.str.1 = [21 x i8] c"\0A==================\0A\00"
@.str.2 = [45 x i8] c"User time: %.03lf ms\0ASystem time: %.03lf ms\0A\00"
@.str.3 = [62 x i8] c"Major page faults: %lu (required I/O)\0AMinor page faults: %lu\0A\00"
@.str.4 = [22 x i8] c"Number of swaps: %lu\0A\00"
@.str.5 = [67 x i8] c"Voluntary context switches: %lu\0AInvoluntary context switches: %lu\0A\00"
@.str.6 = [20 x i8] c"==================\0A\00"
define void @usage_dump() {
%1 = alloca %struct.rusage
%2 = load i32, i32* @RUSAGE_SELF
%3 = call i64 @getrusage(i32 %2, %struct.rusage* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @memset(%struct.rusage* %1, i32 0, i32 56)
br label %7
7: ; preds = %5, %0
%8 = load i32, i32* @stderr
%9 = call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stderr
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 6
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 6
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 1
%18 = load double, double* %17
%19 = fdiv double %18, 1.000000e+03
%20 = call double @llvm.fmuladd.f64(double %15, double 1.000000e+03, double %19)
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 5
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load double, double* %22
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 5
%25 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i32 0, i32 1
%26 = load double, double* %25
%27 = fdiv double %26, 1.000000e+03
%28 = call double @llvm.fmuladd.f64(double %23, double 1.000000e+03, double %27)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %20, double %28)
%30 = load i32, i32* @stderr
%31 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 4
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 3
%34 = load i32, i32* %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %32, i32 %34)
%36 = load i32, i32* @stderr
%37 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 2
%38 = load i32, i32* %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* @stderr
%41 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 1
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 0
%44 = load i32, i32* %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), i32 %42, i32 %44)
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.rusage = type { i32, i32, i32, i32, i32, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { double, double }
%struct.TYPE_3__ = type { double, double }
@RUSAGE_SELF = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"\0AMemory statistics:\00"
@.str.1 = [21 x i8] c"\0A==================\0A\00"
@.str.2 = [45 x i8] c"User time: %.03lf ms\0ASystem time: %.03lf ms\0A\00"
@.str.3 = [62 x i8] c"Major page faults: %lu (required I/O)\0AMinor page faults: %lu\0A\00"
@.str.4 = [22 x i8] c"Number of swaps: %lu\0A\00"
@.str.5 = [67 x i8] c"Voluntary context switches: %lu\0AInvoluntary context switches: %lu\0A\00"
@.str.6 = [20 x i8] c"==================\0A\00"
define void @usage_dump() {
%1 = alloca %struct.rusage
%2 = bitcast %struct.rusage* %1 to i8*
%3 = load i32, i32* @RUSAGE_SELF
%4 = call i64 @getrusage(i32 %3, %struct.rusage* %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @memset(%struct.rusage* %1, i32 0, i32 56)
br label %8
8: ; preds = %6, %0
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 6, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 6, i32 1
%17 = load double, double* %16
%18 = fdiv double %17, 1.000000e+03
%19 = call double @llvm.fmuladd.f64(double %15, double 1.000000e+03, double %18)
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 5, i32 0
%21 = load double, double* %20
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 5, i32 1
%23 = load double, double* %22
%24 = fdiv double %23, 1.000000e+03
%25 = call double @llvm.fmuladd.f64(double %21, double 1.000000e+03, double %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %19, double %25)
%27 = load i32, i32* @stderr
%28 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 4
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 3
%31 = load i32, i32* %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %31)
%33 = load i32, i32* @stderr
%34 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 2
%35 = load i32, i32* %34
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @stderr
%38 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %41)
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
ret void
}