#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*/ free(char *);
char *get_freespace(char *);
char *get_memusage();
char *get_netusage(char *);
int /*<<< orphan*/ printf(char *);
char *smprintf(char *, char *, char *, char *);
main(void) {
  char *status;
  char *netstats;
  char *mem;
  char *rootfs;
  mem = get_memusage();
  netstats = get_netusage("eth0");
  rootfs = get_freespace("/");
  status = smprintf("%s %s /:%s\n", netstats, mem, rootfs);
  printf(status);
  free(rootfs);
  free(mem);
  free(netstats);
  free(status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <get_memusage@plt>
mov    %rax,-0x20(%rbp)
lea    0xe7f(%rip),%rdi
call   1060 <get_netusage@plt>
mov    %rax,-0x18(%rbp)
lea    0xe74(%rip),%rdi
call   1070 <get_freespace@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe5a(%rip),%rdi
call   1040 <smprintf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <get_memusage@plt>
mov    %rax,%r14
lea    0xe87(%rip),%rdi
call   1060 <get_netusage@plt>
mov    %rax,%r15
lea    0xe7d(%rip),%rdi
call   1070 <get_freespace@plt>
mov    %rax,%rbx
lea    0xe70(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
call   1040 <smprintf@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [12 x i8] c"%s %s /:%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* (...) @get_memusage()
store i8* %6, i8** %4
%7 = call i8* @get_netusage(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %3
%8 = call i8* @get_freespace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %5
%9 = load i8*, i8** %3
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = call i8* @smprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10, i8* %11)
store i8* %12, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 @free(i8* %15)
%17 = load i8*, i8** %4
%18 = call i32 @free(i8* %17)
%19 = load i8*, i8** %3
%20 = call i32 @free(i8* %19)
%21 = load i8*, i8** %2
%22 = call i32 @free(i8* %21)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"eth0\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [12 x i8] c"%s %s /:%s\0A\00"
define i32 @main() {
%1 = tail call i8* (...) @get_memusage()
%2 = tail call i8* @get_netusage(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = tail call i8* @get_freespace(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i8* @smprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %1, i8* %3)
%5 = tail call i32 @printf(i8* dereferenceable(1) %4)
%6 = tail call i32 @free(i8* %3)
%7 = tail call i32 @free(i8* %1)
%8 = tail call i32 @free(i8* %2)
%9 = tail call i32 @free(i8* %4)
ret i32 0
}