#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ readAndParse(char *, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char *);
int memmonitor() {
  for (;;) {
    printf(" MemTotal:\t\t");
    readAndParse("/proc/meminfo", "MemTotal:", 2);
    printf(" kB");
    printf("\n MemFree:\t\t");
    readAndParse("/proc/meminfo", "MemFree:", 2);
    printf(" kB\n");
    sleep(1);
    system("clear");
  }
  return (0);
}


x86 assembly (clang, -O0):
<memmonitor>:
push   %rbp
mov    %rsp,%rbp
jmp    1149 <memmonitor+0x9>
lea    0xeb0(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0xeb8(%rip),%rsi
mov    $0x2,%edx
call   1050 <readAndParse@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    0xea3(%rip),%rsi
mov    $0x2,%edx
call   1050 <readAndParse@plt>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
lea    0xe8a(%rip),%rdi
call   1030 <system@plt>
jmp    1149 <memmonitor+0x9>

x86 assembly (clang, -O2):
<memmonitor>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeab(%rip),%r12
lea    0xeb2(%rip),%r15
lea    0xed1(%rip),%rbx
lea    0xeae(%rip),%r13
lea    0xeb4(%rip),%rbp
lea    0xeb6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x2,%edx
call   1060 <readAndParse@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1060 <readAndParse@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %r14,%rdi
call   1040 <system@plt>
jmp    1190 <memmonitor+0x40>

LLVM IR (-O0):
@.str = [13 x i8] c" MemTotal:\09\09\00"
@.str.1 = [14 x i8] c"/proc/meminfo\00"
@.str.2 = [10 x i8] c"MemTotal:\00"
@.str.3 = [4 x i8] c" kB\00"
@.str.4 = [13 x i8] c"\0A MemFree:\09\09\00"
@.str.5 = [9 x i8] c"MemFree:\00"
@.str.6 = [5 x i8] c" kB\0A\00"
@.str.7 = [6 x i8] c"clear\00"
define i32 @memmonitor() {
br label %1
1: ; preds = %1, %0
%2 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 2)
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 2)
%7 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%8 = call i32 @sleep(i32 1)
%9 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %1
}

LLVM IR (-O2):
@.str = [13 x i8] c" MemTotal:\09\09\00"
@.str.1 = [14 x i8] c"/proc/meminfo\00"
@.str.2 = [10 x i8] c"MemTotal:\00"
@.str.4 = [13 x i8] c"\0A MemFree:\09\09\00"
@.str.5 = [9 x i8] c"MemFree:\00"
@.str.7 = [6 x i8] c"clear\00"
@str = [4 x i8] c" kB\00"
define i32 @memmonitor() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 2)
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%6 = tail call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 2)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @sleep(i32 1)
%9 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %1
}