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

/* Variables and functions */
char const *bprintf(char *, int);
int /*<<< orphan*/ memcpy(long double *, long double *, int);
int pscanf(char *, char *, long double *, long double *, long double *,
           long double *, long double *, long double *, long double *);
const char *cpu_perc(void) {
  static long double a[7];
  long double b[7], sum;
  memcpy(b, a, sizeof(b));
  if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a[0], &a[1],
             &a[2], &a[3], &a[4], &a[5], &a[6]) != 7) {
    return NULL;
  }
  if (b[0] == 0) {
    return NULL;
  }
  sum = (b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6]) -
        (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]);
  if (sum == 0) {
    return NULL;
  }
  return bprintf("%d", (int)(100 *
                             ((b[0] + b[1] + b[2] + b[5] + b[6]) -
                              (a[0] + a[1] + a[2] + a[5] + a[6])) /
                             sum));
}


x86 assembly (clang, -O0):
<cpu_perc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
lea    -0x80(%rbp),%rdi
lea    0x2f0a(%rip),%rsi
mov    $0x70,%edx
call   1040 <memcpy@plt>
lea    0xead(%rip),%rdi
lea    0xeb1(%rip),%rsi
lea    0x2eeb(%rip),%rdx
mov    %rdx,%rcx
add    $0x10,%rcx
mov    %rdx,%r8
add    $0x20,%r8
mov    %rdx,%r9
add    $0x30,%r9
mov    %rdx,%r11
add    $0x40,%r11
mov    %rdx,%r10
add    $0x50,%r10
mov    %rdx,%rax
add    $0x60,%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1050 <pscanf@plt>
cmp    $0x7,%eax
je     11b8 <cpu_perc+0x88>
movq   $0x0,-0x8(%rbp)
jmp    12fc <cpu_perc+0x1cc>
fldt   -0x80(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11e1 <cpu_perc+0xb1>
jp     11e1 <cpu_perc+0xb1>
jmp    11d4 <cpu_perc+0xa4>
movq   $0x0,-0x8(%rbp)
jmp    12fc <cpu_perc+0x1cc>
fldt   -0x80(%rbp)
fldt   -0x70(%rbp)
faddp  %st,%st(1)
fldt   -0x60(%rbp)
faddp  %st,%st(1)
fldt   -0x50(%rbp)
faddp  %st,%st(1)
fldt   -0x40(%rbp)
faddp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fldt   0x2e48(%rip)
fldt   0x2e52(%rip)
faddp  %st,%st(1)
fldt   0x2e5a(%rip)
faddp  %st,%st(1)
fldt   0x2e62(%rip)
faddp  %st,%st(1)
fldt   0x2e6a(%rip)
faddp  %st,%st(1)
fldt   0x2e72(%rip)
faddp  %st,%st(1)
fldt   0x2e7a(%rip)
faddp  %st,%st(1)
fsubrp %st,%st(1)
fstpt  -0x90(%rbp)
fldt   -0x90(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    126c <cpu_perc+0x13c>
jp     126c <cpu_perc+0x13c>
jmp    125f <cpu_perc+0x12f>
movq   $0x0,-0x8(%rbp)
jmp    12fc <cpu_perc+0x1cc>
fldt   -0x80(%rbp)
fldt   -0x70(%rbp)
faddp  %st,%st(1)
fldt   -0x60(%rbp)
faddp  %st,%st(1)
fldt   -0x30(%rbp)
faddp  %st,%st(1)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fldt   0x2dc7(%rip)
fldt   0x2dd1(%rip)
faddp  %st,%st(1)
fldt   0x2dd9(%rip)
faddp  %st,%st(1)
fldt   0x2e01(%rip)
faddp  %st,%st(1)
fldt   0x2e09(%rip)
faddp  %st,%st(1)
fsubrp %st,%st(1)
flds   0xd4f(%rip)
fmulp  %st,%st(1)
fldt   -0x90(%rbp)
fdivrp %st,%st(1)
fnstcw -0x96(%rbp)
movzwl -0x96(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x98(%rbp)
fldcw  -0x98(%rbp)
fistpl -0x94(%rbp)
fldcw  -0x96(%rbp)
mov    -0x94(%rbp),%esi
lea    0xd3c(%rip),%rdi
call   1030 <bprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_perc>:
push   %rbx
sub    $0x90,%rsp
lea    0x2f11(%rip),%rbx
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x70,%edx
call   1040 <memcpy@plt>
sub    $0x8,%rsp
lea    0x2f54(%rip),%rax
lea    0x2f3d(%rip),%r10
lea    0x2f26(%rip),%r11
lea    0xe93(%rip),%rdi
lea    0xe97(%rip),%rsi
lea    0x2ee1(%rip),%rcx
lea    0x2eea(%rip),%r8
lea    0x2ef3(%rip),%r9
mov    %rbx,%rdx
push   %rax
push   %r10
push   %r11
call   1050 <pscanf@plt>
add    $0x20,%rsp
cmp    $0x7,%eax
jne    1236 <cpu_perc+0x106>
fldt   0x20(%rsp)
fldz
fxch   %st(1)
fucomi %st(1),%st
fstp   %st(1)
jne    11b7 <cpu_perc+0x87>
jnp    1234 <cpu_perc+0x104>
fldt   0x30(%rsp)
faddp  %st,%st(1)
fldt   0x40(%rsp)
faddp  %st,%st(1)
fldt   0x50(%rsp)
fld    %st(1)
fstpt  0x14(%rsp)
faddp  %st,%st(1)
fldt   0x60(%rsp)
faddp  %st,%st(1)
fldt   0x70(%rsp)
fadd   %st,%st(1)
fldt   0x80(%rsp)
fadd   %st,%st(2)
fldt   0x2e66(%rip)
fldt   0x2e70(%rip)
faddp  %st,%st(1)
fldt   0x2e78(%rip)
faddp  %st,%st(1)
fldt   0x2e80(%rip)
fadd   %st(1),%st
fldt   0x2e88(%rip)
faddp  %st,%st(1)
fldt   0x2e90(%rip)
fadd   %st,%st(1)
fldt   0x2e98(%rip)
fadd   %st,%st(2)
fxch   %st(6)
fsubp  %st,%st(2)
fldz
fxch   %st(2)
fucomi %st(2),%st
fstp   %st(2)
jne    1241 <cpu_perc+0x111>
jp     1241 <cpu_perc+0x111>
fstp   %st(4)
fstp   %st(2)
fstp   %st(0)
fstp   %st(1)
fstp   %st(0)
fstp   %st(0)
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
ret
fldt   0x14(%rsp)
faddp  %st,%st(5)
fxch   %st(4)
faddp  %st,%st(3)
fxch   %st(1)
faddp  %st,%st(3)
fxch   %st(2)
faddp  %st,%st(3)
fsubp  %st,%st(2)
fxch   %st(1)
fmuls  0xda3(%rip)
fdivp  %st,%st(1)
fnstcw 0xc(%rsp)
movzwl 0xc(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0xe(%rsp)
fldcw  0xe(%rsp)
fistpl 0x10(%rsp)
fldcw  0xc(%rsp)
mov    0x10(%rsp),%esi
lea    0xda6(%rip),%rdi
call   1030 <bprintf@plt>
jmp    1238 <cpu_perc+0x108>

LLVM IR (-O0):
@cpu_perc.a = internal global [7 x x86_fp80] zeroinitializer
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [32 x i8] c"%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf\00"
@.str.2 = [3 x i8] c"%d\00"
define i8* @cpu_perc() {
%1 = alloca i8*
%2 = alloca [7 x x86_fp80]
%3 = alloca x86_fp80
%4 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 0
%5 = call i32 @memcpy(x86_fp80* %4, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0), i32 112)
%6 = call i32 @pscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 1), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 2), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 3), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 4), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 5), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 6))
%7 = icmp ne i32 %6, 7
br i1 %7, label %8, label %9
8: ; preds = %0
store i8* null, i8** %1
br label %82
9: ; preds = %0
%10 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 0
%11 = load x86_fp80, x86_fp80* %10
%12 = fcmp oeq x86_fp80 %11, 0xK00000000000000000000
br i1 %12, label %13, label %14
13: ; preds = %9
store i8* null, i8** %1
br label %82
14: ; preds = %9
%15 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 0
%16 = load x86_fp80, x86_fp80* %15
%17 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 1
%18 = load x86_fp80, x86_fp80* %17
%19 = fadd x86_fp80 %16, %18
%20 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 2
%21 = load x86_fp80, x86_fp80* %20
%22 = fadd x86_fp80 %19, %21
%23 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 3
%24 = load x86_fp80, x86_fp80* %23
%25 = fadd x86_fp80 %22, %24
%26 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 4
%27 = load x86_fp80, x86_fp80* %26
%28 = fadd x86_fp80 %25, %27
%29 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 5
%30 = load x86_fp80, x86_fp80* %29
%31 = fadd x86_fp80 %28, %30
%32 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 6
%33 = load x86_fp80, x86_fp80* %32
%34 = fadd x86_fp80 %31, %33
%35 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0)
%36 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 1)
%37 = fadd x86_fp80 %35, %36
%38 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 2)
%39 = fadd x86_fp80 %37, %38
%40 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 3)
%41 = fadd x86_fp80 %39, %40
%42 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 4)
%43 = fadd x86_fp80 %41, %42
%44 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 5)
%45 = fadd x86_fp80 %43, %44
%46 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 6)
%47 = fadd x86_fp80 %45, %46
%48 = fsub x86_fp80 %34, %47
store x86_fp80 %48, x86_fp80* %3
%49 = load x86_fp80, x86_fp80* %3
%50 = fcmp oeq x86_fp80 %49, 0xK00000000000000000000
br i1 %50, label %51, label %52
51: ; preds = %14
store i8* null, i8** %1
br label %82
52: ; preds = %14
%53 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 0
%54 = load x86_fp80, x86_fp80* %53
%55 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 1
%56 = load x86_fp80, x86_fp80* %55
%57 = fadd x86_fp80 %54, %56
%58 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 2
%59 = load x86_fp80, x86_fp80* %58
%60 = fadd x86_fp80 %57, %59
%61 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 5
%62 = load x86_fp80, x86_fp80* %61
%63 = fadd x86_fp80 %60, %62
%64 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %2, i64 0, i64 6
%65 = load x86_fp80, x86_fp80* %64
%66 = fadd x86_fp80 %63, %65
%67 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0)
%68 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 1)
%69 = fadd x86_fp80 %67, %68
%70 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 2)
%71 = fadd x86_fp80 %69, %70
%72 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 5)
%73 = fadd x86_fp80 %71, %72
%74 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 6)
%75 = fadd x86_fp80 %73, %74
%76 = fsub x86_fp80 %66, %75
%77 = fmul x86_fp80 0xK4005C800000000000000, %76
%78 = load x86_fp80, x86_fp80* %3
%79 = fdiv x86_fp80 %77, %78
%80 = fptosi x86_fp80 %79 to i32
%81 = call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %80)
store i8* %81, i8** %1
br label %82
82: ; preds = %52, %51, %13, %8
%83 = load i8*, i8** %1
ret i8* %83
}

LLVM IR (-O2):
@cpu_perc.a = internal global [7 x x86_fp80] zeroinitializer
@.str = [11 x i8] c"/proc/stat\00"
@.str.1 = [32 x i8] c"%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf\00"
@.str.2 = [3 x i8] c"%d\00"
define i8* @cpu_perc() {
%1 = alloca [7 x x86_fp80]
%2 = bitcast [7 x x86_fp80]* %1 to i8*
%3 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 0
%4 = call i32 @memcpy(x86_fp80* %3, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0), i32 112)
%5 = call i32 @pscanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 1), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 2), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 3), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 4), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 5), x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 6))
%6 = icmp eq i32 %5, 7
br i1 %6, label %7, label %54
7: ; preds = %0
%8 = load x86_fp80, x86_fp80* %3
%9 = fcmp oeq x86_fp80 %8, 0xK00000000000000000000
br i1 %9, label %54, label %10
10: ; preds = %7
%11 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 1
%12 = load x86_fp80, x86_fp80* %11
%13 = fadd x86_fp80 %8, %12
%14 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 2
%15 = load x86_fp80, x86_fp80* %14
%16 = fadd x86_fp80 %13, %15
%17 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 3
%18 = load x86_fp80, x86_fp80* %17
%19 = fadd x86_fp80 %16, %18
%20 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 4
%21 = load x86_fp80, x86_fp80* %20
%22 = fadd x86_fp80 %19, %21
%23 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 5
%24 = load x86_fp80, x86_fp80* %23
%25 = fadd x86_fp80 %22, %24
%26 = getelementptr inbounds [7 x x86_fp80], [7 x x86_fp80]* %1, i64 0, i64 6
%27 = load x86_fp80, x86_fp80* %26
%28 = fadd x86_fp80 %25, %27
%29 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 0)
%30 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 1)
%31 = fadd x86_fp80 %29, %30
%32 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 2)
%33 = fadd x86_fp80 %31, %32
%34 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 3)
%35 = fadd x86_fp80 %33, %34
%36 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 4)
%37 = fadd x86_fp80 %35, %36
%38 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 5)
%39 = fadd x86_fp80 %37, %38
%40 = load x86_fp80, x86_fp80* getelementptr inbounds ([7 x x86_fp80], [7 x x86_fp80]* @cpu_perc.a, i64 0, i64 6)
%41 = fadd x86_fp80 %39, %40
%42 = fsub x86_fp80 %28, %41
%43 = fcmp oeq x86_fp80 %42, 0xK00000000000000000000
br i1 %43, label %54, label %44
44: ; preds = %10
%45 = fadd x86_fp80 %16, %24
%46 = fadd x86_fp80 %45, %27
%47 = fadd x86_fp80 %33, %38
%48 = fadd x86_fp80 %47, %40
%49 = fsub x86_fp80 %46, %48
%50 = fmul x86_fp80 %49, 0xK4005C800000000000000
%51 = fdiv x86_fp80 %50, %42
%52 = fptosi x86_fp80 %51 to i32
%53 = call i8* @bprintf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %10, %7, %0, %44
%55 = phi i8* [ %53, %44 ], [ null, %0 ], [ null, %7 ], [ null, %10 ]
ret i8* %55
}