#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 rusage {
  int /*<<< orphan*/ ru_isrss;
  int /*<<< orphan*/ ru_idrss;
  int /*<<< orphan*/ ru_ixrss;
  int /*<<< orphan*/ ru_maxrss;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
scalar_t__ malloc(int);
void dumpUsage(char *msg, FILE *fd) {
  struct rusage *ru;
  ru = (struct rusage *)malloc(sizeof(struct rusage));
  getrusage(RUSAGE_SELF, ru);
  fprintf(fd, "%s: maxrss=%ld ixrss=%ld idrss=%ld isrss=%ld\n", msg,
          ru->ru_maxrss, ru->ru_ixrss, ru->ru_idrss, ru->ru_isrss);
}


x86 assembly (clang, -O0):
<dumpUsage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1050 <getrusage@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
lea    0xe74(%rip),%rsi
mov    %eax,(%rsp)
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpUsage>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1050 <getrusage@plt>
mov    0xc(%rbx),%ecx
mov    0x8(%rbx),%r8d
mov    (%rbx),%eax
mov    0x4(%rbx),%r9d
mov    %eax,(%rsp)
lea    0xe8c(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rusage = type { i32, i32, i32, i32 }
@RUSAGE_SELF = global i32 0
@.str = [46 x i8] c"%s: maxrss=%ld ixrss=%ld idrss=%ld isrss=%ld\0A\00"
define void @dumpUsage(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.rusage*
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = call i64 @malloc(i32 16)
%7 = inttoptr i64 %6 to %struct.rusage*
store %struct.rusage* %7, %struct.rusage** %5
%8 = load i32, i32* @RUSAGE_SELF
%9 = load %struct.rusage*, %struct.rusage** %5
%10 = call i32 @getrusage(i32 %8, %struct.rusage* %9)
%11 = load i32*, i32** %4
%12 = load i8*, i8** %3
%13 = load %struct.rusage*, %struct.rusage** %5
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %13, i32 0, i32 3
%15 = load i32, i32* %14
%16 = load %struct.rusage*, %struct.rusage** %5
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %16, i32 0, i32 2
%18 = load i32, i32* %17
%19 = load %struct.rusage*, %struct.rusage** %5
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = load %struct.rusage*, %struct.rusage** %5
%23 = getelementptr inbounds %struct.rusage, %struct.rusage* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %15, i32 %18, i32 %21, i32 %24)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { i32, i32, i32, i32 }
@RUSAGE_SELF = global i32 0
@.str = [46 x i8] c"%s: maxrss=%ld ixrss=%ld idrss=%ld isrss=%ld\0A\00"
define void @dumpUsage(i8* %0, i32* nocapture %1) {
%3 = tail call i64 @malloc(i32 16)
%4 = inttoptr i64 %3 to %struct.rusage*
%5 = load i32, i32* @RUSAGE_SELF
%6 = tail call i32 @getrusage(i32 %5, %struct.rusage* %4)
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 3
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %8, i32 %10, i32 %12, i32 %14)
ret void
}