#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 timeval {
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, double *, double *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_uptime(char *, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ readAndParse(char *, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char *);
int getInfo() {
  for (;;) {
    double uptime, idle_time;
    char hostname[1000];
    struct timeval now;
    struct timeval;
    FILE *fp;
    gettimeofday(&now, NULL);
    printf("%s\n", ctime(&(now.tv_sec)));
    printf("Machine hostname: ");
    fp = fopen("/proc/sys/kernel/hostname", "r");
    fgets(hostname, 1000, fp);
    fclose(fp);
    printf("%s\n", hostname);
    printf(" vendor_id:\t\t");
    readAndParse("/proc/cpuinfo", "vendor_id", 0);
    printf(" model name:\t\t");
    readAndParse("/proc/cpuinfo", "name", 0);
    printf(" kernel version:\t");
    readAndParse("/proc/version", "Linux", 1);
    printf("\n uptime:\t\t");
    fp = fopen("/proc/uptime", "r");
    fscanf(fp, "%lf %lf\n", &uptime, &idle_time);
    fclose(fp);
    print_uptime("", (long)uptime);
    printf(" Memory Total:\t\t");
    readAndParse("/proc/meminfo", "MemTotal:", 2);
    printf(" kB");
    printf("\n Memory Free:\t\t");
    readAndParse("/proc/meminfo", "MemFree:", 2);
    printf(" kB\n\n\n");
    sleep(1);
    system("clear");
  }
  return 0;
}


x86 assembly (clang, -O0):
<getInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    -0x408(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
lea    -0x408(%rbp),%rdi
call   1050 <ctime@plt>
mov    %rax,%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    0xefc(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x410(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x410(%rbp),%rdx
mov    $0x3e8,%esi
call   10a0 <fgets@plt>
mov    -0x410(%rbp),%rdi
call   1040 <fclose@plt>
lea    -0x400(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xde1(%rip),%rdi
lea    0xde8(%rip),%rsi
xor    %edx,%edx
call   10c0 <readAndParse@plt>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdbe(%rip),%rdi
lea    0xda4(%rip),%rsi
xor    %edx,%edx
call   10c0 <readAndParse@plt>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdd4(%rip),%rdi
lea    0xddb(%rip),%rsi
mov    $0x1,%edx
call   10c0 <readAndParse@plt>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdce(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x410(%rbp)
mov    -0x410(%rbp),%rdi
lea    0xdba(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1090 <fscanf@plt>
mov    -0x410(%rbp),%rdi
call   1040 <fclose@plt>
cvttsd2si -0x8(%rbp),%rsi
lea    0xd2d(%rip),%rdi
call   1030 <print_uptime@plt>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd94(%rip),%rdi
lea    0xd9b(%rip),%rsi
mov    $0x2,%edx
call   10c0 <readAndParse@plt>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xd60(%rip),%rdi
lea    0xd86(%rip),%rsi
mov    $0x2,%edx
call   10c0 <readAndParse@plt>
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
lea    0xd6d(%rip),%rdi
call   1060 <system@plt>
jmp    11bb <getInfo+0xb>

x86 assembly (clang, -O2):
<getInfo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xf1d(%rip),%r13
lea    0x20(%rsp),%r12
lea    0xe57(%rip),%r14
lea    0xed0(%rip),%rbp
nopl   0x0(%rax,%rax,1)
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    %rbx,%rdi
call   1060 <ctime@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdef(%rip),%rdi
mov    %r13,%rsi
call   10c0 <fopen@plt>
mov    %rax,%r15
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %rax,%rdx
call   10b0 <fgets@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0xdd7(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
lea    0xde2(%rip),%rsi
xor    %edx,%edx
call   10d0 <readAndParse@plt>
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%rdi
lea    0xda2(%rip),%rsi
xor    %edx,%edx
call   10d0 <readAndParse@plt>
lea    0xdce(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdd2(%rip),%rdi
lea    0xdd9(%rip),%rsi
mov    $0x1,%edx
call   10d0 <readAndParse@plt>
lea    0xdce(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    %r13,%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0xdc4(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x18(%rsp),%rcx
call   10a0 <fscanf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
cvttsd2si 0x10(%rsp),%rsi
lea    0xd38(%rip),%rdi
call   1030 <print_uptime@plt>
lea    0xd9c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0xdaa(%rip),%rsi
mov    $0x2,%edx
call   10d0 <readAndParse@plt>
lea    0xda3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd99(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
lea    0xd99(%rip),%rsi
mov    $0x2,%edx
call   10d0 <readAndParse@plt>
lea    0xd97(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
lea    0xd7b(%rip),%rdi
call   1070 <system@plt>
jmp    11f0 <getInfo+0x30>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [19 x i8] c"Machine hostname: \00"
@.str.2 = [26 x i8] c"/proc/sys/kernel/hostname\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [14 x i8] c" vendor_id:\09\09\00"
@.str.5 = [14 x i8] c"/proc/cpuinfo\00"
@.str.6 = [10 x i8] c"vendor_id\00"
@.str.7 = [15 x i8] c" model name:\09\09\00"
@.str.8 = [5 x i8] c"name\00"
@.str.9 = [18 x i8] c" kernel version:\09\00"
@.str.10 = [14 x i8] c"/proc/version\00"
@.str.11 = [6 x i8] c"Linux\00"
@.str.12 = [12 x i8] c"\0A uptime:\09\09\00"
@.str.13 = [13 x i8] c"/proc/uptime\00"
@.str.14 = [9 x i8] c"%lf %lf\0A\00"
@.str.15 = [1 x i8] zeroinitializer
@.str.16 = [17 x i8] c" Memory Total:\09\09\00"
@.str.17 = [14 x i8] c"/proc/meminfo\00"
@.str.18 = [10 x i8] c"MemTotal:\00"
@.str.19 = [4 x i8] c" kB\00"
@.str.20 = [17 x i8] c"\0A Memory Free:\09\09\00"
@.str.21 = [9 x i8] c"MemFree:\00"
@.str.22 = [7 x i8] c" kB\0A\0A\0A\00"
@.str.23 = [6 x i8] c"clear\00"
define i32 @getInfo() {
%1 = alloca double
%2 = alloca double
%3 = alloca [1000 x i8]
%4 = alloca %struct.timeval
%5 = alloca i32*
br label %6
6: ; preds = %6, %0
%7 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%9 = call i8* @ctime(i32* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %12, i32** %5
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = call i32 @fgets(i8* %13, i32 1000, i32* %14)
%16 = load i32*, i32** %5
%17 = call i32 @fclose(i32* %16)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%21 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 0)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%25 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 1)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%27 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %27, i32** %5
%28 = load i32*, i32** %5
%29 = call i32 @fscanf(i32* %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), double* %1, double* %2)
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
%32 = load double, double* %1
%33 = fptosi double %32 to i64
%34 = call i32 @print_uptime(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.15, i64 0, i64 0), i64 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
%36 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 2)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0))
%39 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0), i32 2)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.22, i64 0, i64 0))
%41 = call i32 @sleep(i32 1)
%42 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i64 0, i64 0))
br label %6
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str.1 = [19 x i8] c"Machine hostname: \00"
@.str.2 = [26 x i8] c"/proc/sys/kernel/hostname\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [14 x i8] c" vendor_id:\09\09\00"
@.str.5 = [14 x i8] c"/proc/cpuinfo\00"
@.str.6 = [10 x i8] c"vendor_id\00"
@.str.7 = [15 x i8] c" model name:\09\09\00"
@.str.8 = [5 x i8] c"name\00"
@.str.9 = [18 x i8] c" kernel version:\09\00"
@.str.10 = [14 x i8] c"/proc/version\00"
@.str.11 = [6 x i8] c"Linux\00"
@.str.12 = [12 x i8] c"\0A uptime:\09\09\00"
@.str.13 = [13 x i8] c"/proc/uptime\00"
@.str.14 = [9 x i8] c"%lf %lf\0A\00"
@.str.15 = [1 x i8] zeroinitializer
@.str.16 = [17 x i8] c" Memory Total:\09\09\00"
@.str.17 = [14 x i8] c"/proc/meminfo\00"
@.str.18 = [10 x i8] c"MemTotal:\00"
@.str.19 = [4 x i8] c" kB\00"
@.str.20 = [17 x i8] c"\0A Memory Free:\09\09\00"
@.str.21 = [9 x i8] c"MemFree:\00"
@.str.23 = [6 x i8] c"clear\00"
@str = [6 x i8] c" kB\0A\0A\00"
define i32 @getInfo() {
%1 = alloca double
%2 = alloca double
%3 = alloca [1000 x i8]
%4 = alloca %struct.timeval
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.timeval* %4 to i8*
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
br label %10
10: ; preds = %10, %0
%11 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%12 = call i8* @ctime(i32* %9)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32* @fopen(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @fgets(i8* %7, i32 1000, i32* %15)
%17 = call i32 @fclose(i32* %15)
%18 = call i32 @puts(i8* %7)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 0)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%22 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 0)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
%24 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 1)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%26 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), double* %1, double* %2)
%28 = call i32 @fclose(i32* %26)
%29 = load double, double* %1
%30 = fptosi double %29 to i64
%31 = call i32 @print_uptime(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.15, i64 0, i64 0), i64 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.16, i64 0, i64 0))
%33 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.18, i64 0, i64 0), i32 2)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.19, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i64 0, i64 0))
%36 = call i32 @readAndParse(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.21, i64 0, i64 0), i32 2)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%38 = call i32 @sleep(i32 1)
%39 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i64 0, i64 0))
br label %10
}