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

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
void getmaxcpumem(float *scpu, float *smem) {
  struct rusage rusage;
  getrusage(RUSAGE_SELF, &rusage);
  *scpu =
      ((float)(rusage.ru_utime.tv_usec + rusage.ru_stime.tv_usec) / 1000000) +
      ((float)(rusage.ru_utime.tv_sec + rusage.ru_stime.tv_sec));
  *smem = (float)(rusage.ru_maxrss) / 1000;
}


x86 assembly (clang, -O0):
<getmaxcpumem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    -0x38(%rbp),%rsi
call   1030 <getrusage@plt>
mov    -0x18(%rbp),%rax
add    -0x28(%rbp),%rax
cvtsi2ss %rax,%xmm0
movss  0xebd(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
add    -0x30(%rbp),%rax
cvtsi2ss %rax,%xmm1
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
cvtsi2ssq -0x38(%rbp),%xmm0
movss  0xe8e(%rip),%xmm1
divss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getmaxcpumem>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ebc(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <getrusage@plt>
mov    0x10(%rsp),%rax
add    0x20(%rsp),%rax
mov    0x8(%rsp),%rcx
cvtsi2ss %rax,%xmm0
divss  0xeb6(%rip),%xmm0
add    0x18(%rsp),%rcx
cvtsi2ss %rcx,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
xorps  %xmm0,%xmm0
cvtsi2ssq (%rsp),%xmm0
divss  0xe97(%rip),%xmm0
movss  %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rusage = type { i64, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
define void @getmaxcpumem(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca %struct.rusage
store float* %0, float** %3
store float* %1, float** %4
%6 = load i32, i32* @RUSAGE_SELF
%7 = call i32 @getrusage(i32 %6, %struct.rusage* %5)
%8 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 2
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 1
%13 = load i64, i64* %12
%14 = add nsw i64 %10, %13
%15 = sitofp i64 %14 to float
%16 = fdiv float %15, 1.000000e+06
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 2
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 0
%22 = load i64, i64* %21
%23 = add nsw i64 %19, %22
%24 = sitofp i64 %23 to float
%25 = fadd float %16, %24
%26 = load float*, float** %3
store float %25, float* %26
%27 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%28 = load i64, i64* %27
%29 = sitofp i64 %28 to float
%30 = fdiv float %29, 1.000000e+03
%31 = load float*, float** %4
store float %30, float* %31
ret void
}

LLVM IR (-O2):
%struct.rusage = type { i64, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
define void @getmaxcpumem(float* nocapture writeonly %0, float* nocapture writeonly %1) {
%3 = alloca %struct.rusage
%4 = bitcast %struct.rusage* %3 to i8*
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i32 @getrusage(i32 %5, %struct.rusage* %3)
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 2, i32 1
%8 = load i64, i64* %7
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 1
%10 = load i64, i64* %9
%11 = add nsw i64 %10, %8
%12 = sitofp i64 %11 to float
%13 = fdiv float %12, 1.000000e+06
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 2, i32 0
%15 = load i64, i64* %14
%16 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 1, i32 0
%17 = load i64, i64* %16
%18 = add nsw i64 %17, %15
%19 = sitofp i64 %18 to float
%20 = fadd float %13, %19
store float %20, float* %0
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 0
%22 = load i64, i64* %21
%23 = sitofp i64 %22 to float
%24 = fdiv float %23, 1.000000e+03
store float %24, float* %1
ret void
}