#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *, float *,
                          float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void check_load() {
  FILE *load = fopen("/proc/loadavg", "r");
  float one_minute = 0.0;
  float five_minutes = 0.0;
  float fifteen_minutes = 0.0;
  if (load == NULL) {
    fprintf(stderr, "Can't open /proc/loadavg for reading.\n");
    exit(12);
  }
  fscanf(load, "%f %f %f ", &one_minute, &five_minutes, &fifteen_minutes);
  if (one_minute > 1.0 || five_minutes > 1.0 || fifteen_minutes > 1.0) {
    printf("WARNING: Load average is above 1.0 (%.2f %.2f %.2f).\n", one_minute,
           five_minutes, fifteen_minutes);
    printf("         Consider running on an unloaded system.\n");
  }
}


x86 assembly (clang, -O0):
<check_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea9(%rip),%rdi
lea    0xeb0(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11b1 <check_load+0x61>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xc,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe83(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <fscanf@plt>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe22(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     121e <check_load+0xce>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe07(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     121e <check_load+0xce>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdec(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1255 <check_load+0x105>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe09(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_load>:
sub    $0x18,%rsp
lea    0xe99(%rip),%rdi
lea    0xea0(%rip),%rsi
call   1070 <fopen@plt>
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
test   %rax,%rax
je     120f <check_load+0xaf>
lea    0xea0(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rax,%rdi
call   1050 <fscanf@plt>
movss  0x14(%rsp),%xmm0
ucomiss 0xe41(%rip),%xmm0
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm2
ja     11e4 <check_load+0x84>
ucomiss 0xe2c(%rip),%xmm1
ja     11e4 <check_load+0x84>
ucomiss 0xe23(%rip),%xmm2
ja     11e4 <check_load+0x84>
add    $0x18,%rsp
ret
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
cvtss2sd %xmm2,%xmm2
lea    0xe4e(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
ret
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
lea    0xdf5(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xc,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/loadavg\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [39 x i8] c"Can't open /proc/loadavg for reading.\0A\00"
@.str.3 = [10 x i8] c"%f %f %f \00"
@.str.4 = [54 x i8] c"WARNING: Load average is above 1.0 (%.2f %.2f %.2f).\0A\00"
@.str.5 = [50 x i8] c" Consider running on an unloaded system.\0A\00"
define void @check_load() {
%1 = alloca i32*
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%6 = load i32*, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 12)
unreachable
12: ; preds = %0
%13 = load i32*, i32** %1
%14 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), float* %2, float* %3, float* %4)
%15 = load float, float* %2
%16 = fpext float %15 to double
%17 = fcmp ogt double %16, 1.000000e+00
br i1 %17, label %26, label %18
18: ; preds = %12
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = fcmp ogt double %20, 1.000000e+00
br i1 %21, label %26, label %22
22: ; preds = %18
%23 = load float, float* %4
%24 = fpext float %23 to double
%25 = fcmp ogt double %24, 1.000000e+00
br i1 %25, label %26, label %35
26: ; preds = %22, %18, %12
%27 = load float, float* %2
%28 = fpext float %27 to double
%29 = load float, float* %3
%30 = fpext float %29 to double
%31 = load float, float* %4
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), double %28, double %30, double %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %26, %22
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/loadavg\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [39 x i8] c"Can't open /proc/loadavg for reading.\0A\00"
@.str.3 = [10 x i8] c"%f %f %f \00"
@.str.4 = [54 x i8] c"WARNING: Load average is above 1.0 (%.2f %.2f %.2f).\0A\00"
@str = [49 x i8] c" Consider running on an unloaded system.\00"
define void @check_load() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%6 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%7 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%8 = icmp eq i32* %4, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @exit(i32 12)
unreachable
13: ; preds = %0
%14 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), float* %1, float* %2, float* %3)
%15 = load float, float* %1
%16 = fcmp ogt float %15, 1.000000e+00
%17 = load float, float* %2
%18 = fcmp ogt float %17, 1.000000e+00
%19 = select i1 %16, i1 true, i1 %18
%20 = load float, float* %3
%21 = fcmp ogt float %20, 1.000000e+00
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %29
23: ; preds = %13
%24 = fpext float %15 to double
%25 = fpext float %17 to double
%26 = fpext float %20 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), double %24, double %25, double %26)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %13, %23
ret void
}