#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 */
typedef int pid_t;

/* Variables and functions */
int getpid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ system(char *);
void print_memStats() {
  char com[30] = "ps u -p ";
  pid_t pid = getpid();
  sprintf(com, "ps u -p %d", pid);
  printf("####################################\n");
  system("cat /proc/meminfo |grep \"^MemFree\\|^Cached\\|^Committed_AS\"");
  system(com);
  printf("####################################\n");
}


x86 assembly (clang, -O0):
<print_memStats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea9(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xea3(%rip),%ax
mov    %ax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xe89(%rip),%rsi
call   1060 <sprintf@plt>
lea    0xe88(%rip),%rdi
call   1050 <printf@plt>
lea    0xea2(%rip),%rdi
call   1040 <system@plt>
lea    -0x20(%rbp),%rdi
call   1040 <system@plt>
lea    0xe67(%rip),%rdi
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_memStats>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movups 0xec0(%rip),%xmm0
movups %xmm0,0xe(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xeb2(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1060 <sprintf@plt>
lea    0xee4(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1050 <system@plt>
mov    %r14,%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@__const.print_memStats.com = [30 x i8] c"ps u -p \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"ps u -p %d\00"
@.str.1 = [38 x i8] c"####################################\0A\00"
@.str.2 = [59 x i8] c"cat /proc/meminfo |grep \22^MemFree\\|^Cached\\|^Committed_AS\22\00"
define void @print_memStats() {
%1 = alloca [30 x i8]
%2 = alloca i32
%3 = bitcast [30 x i8]* %1 to i8*
%4 = call i32 (...) @getpid()
store i32 %4, i32* %2
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%6 = load i32, i32* %2
%7 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @system(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%11 = call i32 @system(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.print_memStats.com = [30 x i8] c"ps u -p \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [11 x i8] c"ps u -p %d\00"
@.str.2 = [59 x i8] c"cat /proc/meminfo |grep \22^MemFree\\|^Cached\\|^Committed_AS\22\00"
@str.3 = [37 x i8] c"####################################\00"
define void @print_memStats() {
%1 = alloca [30 x i8]
%2 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getpid()
%4 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @system(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @system(i8* %2)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.3, i64 0, i64 0))
ret void
}