#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__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_CHILDREN;
int getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, ...);
void log_process_usage() {
  struct rusage ru;
  if (getrusage(RUSAGE_CHILDREN, &ru) == -1)
    pexit("getrusage");
  printf("System resource info:\n");
  printf("\t- CPU (user): %lds %ldms\n", (long)ru.ru_utime.tv_sec,
         (long)ru.ru_utime.tv_usec);
  printf("\t- CPU (system): %lds %ldms\n", (long)ru.ru_stime.tv_sec,
         (long)ru.ru_stime.tv_usec);
}


x86 assembly (clang, -O0):
<log_process_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1040 <getrusage@plt>
cmp    $0xffffffff,%eax
jne    115f <log_process_usage+0x2f>
lea    0xea6(%rip),%rdi
call   1050 <pexit@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_process_usage>:
sub    $0x28,%rsp
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1050 <getrusage@plt>
cmp    $0xffffffff,%eax
jne    1168 <log_process_usage+0x28>
lea    0xe9d(%rip),%rdi
call   1060 <pexit@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
mov    0x18(%rsp),%rdx
mov    0x20(%rsp),%rsi
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rsi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_CHILDREN = global i32 0
@.str = [10 x i8] c"getrusage\00"
@.str.1 = [23 x i8] c"System resource info:\0A\00"
@.str.2 = [27 x i8] c"\09- CPU (user): %lds %ldms\0A\00"
@.str.3 = [29 x i8] c"\09- CPU (system): %lds %ldms\0A\00"
define void @log_process_usage() {
%1 = alloca %struct.rusage
%2 = load i32, i32* @RUSAGE_CHILDREN
%3 = call i32 @getrusage(i32 %2, %struct.rusage* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 1
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i64, i64* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %11, i64 %14)
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 1
%18 = load i64, i64* %17
%19 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %19, i32 0, i32 0
%21 = load i64, i64* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %18, i64 %21)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_CHILDREN = global i32 0
@.str = [10 x i8] c"getrusage\00"
@.str.2 = [27 x i8] c"\09- CPU (user): %lds %ldms\0A\00"
@.str.3 = [29 x i8] c"\09- CPU (system): %lds %ldms\0A\00"
@str = [22 x i8] c"System resource info:\00"
define void @log_process_usage() {
%1 = alloca %struct.rusage
%2 = bitcast %struct.rusage* %1 to i8*
%3 = load i32, i32* @RUSAGE_CHILDREN
%4 = call i32 @getrusage(i32 %3, %struct.rusage* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @pexit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%13 = load i64, i64* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 %11, i64 %13)
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%16 = load i64, i64* %15
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%18 = load i64, i64* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i64 %16, i64 %18)
ret void
}