#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, long double *,
                          long double *, long double *, long double *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main(void) {
  long double res1[4], res2[4], load_avg;
  FILE *file_pointer;
  for (;;) {
    file_pointer = fopen("/proc/stat", "r");
    fscanf(file_pointer, "%*s %Lf %Lf %Lf %Lf", &res1[0], &res1[1], &res1[2],
           &res1[3]);
    fclose(file_pointer);
    sleep(1);
    file_pointer = fopen("/proc/stat", "r");
    fscanf(file_pointer, "%*s %Lf %Lf %Lf %Lf", &res2[0], &res2[1], &res2[2],
           &res2[3]);
    fclose(file_pointer);
    load_avg = ((res2[0] + res2[1] + res2[2]) - (res1[0] + res1[1] + res1[2])) /
               ((res2[0] + res2[1] + res2[2] + res2[3]) -
                (res1[0] + res1[1] + res1[2] + res1[3]));
    fprintf(stderr, "%2.3Lf %%\n", 100 * load_avg);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9b(%rip),%rdi
mov    %rdi,-0xc8(%rbp)
lea    0xe98(%rip),%rsi
mov    %rsi,-0xc0(%rbp)
call   1060 <fopen@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    -0x30(%rbp),%r8
lea    -0x20(%rbp),%r9
lea    0xe6d(%rip),%rsi
mov    %rsi,-0xb8(%rbp)
lea    -0x50(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
call   1060 <fopen@plt>
mov    -0xb8(%rbp),%rsi
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
lea    -0x80(%rbp),%rcx
lea    -0x70(%rbp),%r8
lea    -0x60(%rbp),%r9
lea    -0x90(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <fclose@plt>
fldt   -0x90(%rbp)
fldt   -0x80(%rbp)
faddp  %st,%st(1)
fldt   -0x70(%rbp)
faddp  %st,%st(1)
fldt   -0x50(%rbp)
fldt   -0x40(%rbp)
faddp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fld    %st(1)
fsub   %st(1),%st
fldt   -0x60(%rbp)
faddp  %st,%st(3)
fldt   -0x20(%rbp)
faddp  %st,%st(2)
fxch   %st(2)
fsubp  %st,%st(1)
fdivrp %st,%st(1)
fstpt  -0xa0(%rbp)
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
fldt   -0xa0(%rbp)
flds   0xd9e(%rip)
fmulp  %st,%st(1)
fnstcw -0xae(%rbp)
movzwl -0xae(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0xb0(%rbp)
fldcw  -0xb0(%rbp)
fistpl -0xac(%rbp)
fldcw  -0xae(%rbp)
mov    -0xac(%rbp),%edx
lea    0xd89(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1162 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe9c(%rip),%r14
lea    0xea0(%rip),%r15
lea    0xe9b(%rip),%r12
lea    0xea8(%rip),%rbp
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %r12,%rsi
lea    0x50(%rsp),%rdx
lea    0x60(%rsp),%rcx
lea    0x70(%rsp),%r8
lea    0x80(%rsp),%r9
call   1040 <fscanf@plt>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
lea    0x10(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x30(%rsp),%r8
lea    0x40(%rsp),%r9
call   1040 <fscanf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
fldt   0x10(%rsp)
fldt   0x20(%rsp)
faddp  %st,%st(1)
fldt   0x30(%rsp)
faddp  %st,%st(1)
fldt   0x50(%rsp)
fldt   0x60(%rsp)
faddp  %st,%st(1)
fldt   0x70(%rsp)
faddp  %st,%st(1)
fld    %st(1)
fsub   %st(1),%st
fldt   0x40(%rsp)
faddp  %st,%st(3)
fldt   0x80(%rsp)
faddp  %st,%st(2)
fxch   %st(2)
fsubp  %st,%st(1)
fdivrp %st,%st(1)
mov    0x2da9(%rip),%rax
mov    (%rax),%edi
fmuls  0xdc1(%rip)
fnstcw 0x8(%rsp)
movzwl 0x8(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0xa(%rsp)
fldcw  0xa(%rsp)
fistpl 0xc(%rsp)
fldcw  0x8(%rsp)
mov    0xc(%rsp),%edx
mov    %rbp,%rsi
call   1050 <fprintf@plt>
jmp    1180 <main+0x30>

LLVM IR (-O0):
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"%*s %Lf %Lf %Lf %Lf\00"
@stderr = global i32 0
@.str.3 = [11 x i8] c"%2.3Lf %%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x x86_fp80]
%3 = alloca [4 x x86_fp80]
%4 = alloca x86_fp80
%5 = alloca i32*
store i32 0, i32* %1
br label %6
6: ; preds = %6, %0
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32*, i32** %5
%9 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 0
%10 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 1
%11 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 2
%12 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 3
%13 = call i32 @fscanf(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %9, x86_fp80* %10, x86_fp80* %11, x86_fp80* %12)
%14 = load i32*, i32** %5
%15 = call i32 @fclose(i32* %14)
%16 = call i32 @sleep(i32 1)
%17 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %17, i32** %5
%18 = load i32*, i32** %5
%19 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 0
%20 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 1
%21 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 2
%22 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 3
%23 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %19, x86_fp80* %20, x86_fp80* %21, x86_fp80* %22)
%24 = load i32*, i32** %5
%25 = call i32 @fclose(i32* %24)
%26 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 0
%27 = load x86_fp80, x86_fp80* %26
%28 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 1
%29 = load x86_fp80, x86_fp80* %28
%30 = fadd x86_fp80 %27, %29
%31 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 2
%32 = load x86_fp80, x86_fp80* %31
%33 = fadd x86_fp80 %30, %32
%34 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 0
%35 = load x86_fp80, x86_fp80* %34
%36 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 1
%37 = load x86_fp80, x86_fp80* %36
%38 = fadd x86_fp80 %35, %37
%39 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 2
%40 = load x86_fp80, x86_fp80* %39
%41 = fadd x86_fp80 %38, %40
%42 = fsub x86_fp80 %33, %41
%43 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 0
%44 = load x86_fp80, x86_fp80* %43
%45 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 1
%46 = load x86_fp80, x86_fp80* %45
%47 = fadd x86_fp80 %44, %46
%48 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 2
%49 = load x86_fp80, x86_fp80* %48
%50 = fadd x86_fp80 %47, %49
%51 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %3, i64 0, i64 3
%52 = load x86_fp80, x86_fp80* %51
%53 = fadd x86_fp80 %50, %52
%54 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 0
%55 = load x86_fp80, x86_fp80* %54
%56 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 1
%57 = load x86_fp80, x86_fp80* %56
%58 = fadd x86_fp80 %55, %57
%59 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 2
%60 = load x86_fp80, x86_fp80* %59
%61 = fadd x86_fp80 %58, %60
%62 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 3
%63 = load x86_fp80, x86_fp80* %62
%64 = fadd x86_fp80 %61, %63
%65 = fsub x86_fp80 %53, %64
%66 = fdiv x86_fp80 %42, %65
store x86_fp80 %66, x86_fp80* %4
%67 = load i32, i32* @stderr
%68 = load x86_fp80, x86_fp80* %4
%69 = fmul x86_fp80 0xK4005C800000000000000, %68
%70 = fptosi x86_fp80 %69 to i32
%71 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %70)
br label %6
}

LLVM IR (-O2):
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"%*s %Lf %Lf %Lf %Lf\00"
@stderr = global i32 0
@.str.3 = [11 x i8] c"%2.3Lf %%\0A\00"
define i32 @main() {
%1 = alloca [4 x x86_fp80]
%2 = alloca [4 x x86_fp80]
%3 = bitcast [4 x x86_fp80]* %1 to i8*
%4 = bitcast [4 x x86_fp80]* %2 to i8*
%5 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %1, i64 0, i64 0
%6 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %1, i64 0, i64 1
%7 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %1, i64 0, i64 2
%8 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %1, i64 0, i64 3
%9 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 0
%10 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 1
%11 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 2
%12 = getelementptr inbounds [4 x x86_fp80], [4 x x86_fp80]* %2, i64 0, i64 3
br label %13
13: ; preds = %13, %0
%14 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %5, x86_fp80* %6, x86_fp80* %7, x86_fp80* %8)
%16 = call i32 @fclose(i32* %14)
%17 = call i32 @sleep(i32 1)
%18 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), x86_fp80* %9, x86_fp80* %10, x86_fp80* %11, x86_fp80* %12)
%20 = call i32 @fclose(i32* %18)
%21 = load x86_fp80, x86_fp80* %9
%22 = load x86_fp80, x86_fp80* %10
%23 = fadd x86_fp80 %21, %22
%24 = load x86_fp80, x86_fp80* %11
%25 = fadd x86_fp80 %23, %24
%26 = load x86_fp80, x86_fp80* %5
%27 = load x86_fp80, x86_fp80* %6
%28 = fadd x86_fp80 %26, %27
%29 = load x86_fp80, x86_fp80* %7
%30 = fadd x86_fp80 %28, %29
%31 = fsub x86_fp80 %25, %30
%32 = load x86_fp80, x86_fp80* %12
%33 = fadd x86_fp80 %25, %32
%34 = load x86_fp80, x86_fp80* %8
%35 = fadd x86_fp80 %30, %34
%36 = fsub x86_fp80 %33, %35
%37 = fdiv x86_fp80 %31, %36
%38 = load i32, i32* @stderr
%39 = fmul x86_fp80 %37, 0xK4005C800000000000000
%40 = fptosi x86_fp80 %39 to i32
%41 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %13
}