#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 BUFSIZ;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                          char *, char *, char *, char *, float *, float *,
                          float *);
int /*<<< orphan*/ *popen(char *, char *);
void get_load_average(float *load_1, float *load_5, float *load_15) {
  FILE *fff;
  char throw_away[BUFSIZ];
  fff = popen("w | head -n 1", "r");
  if (fff != NULL) {
    fscanf(fff, "%64s %64s %64s %64s %64s %64s %64s %f %f %f", throw_away,
           throw_away, throw_away, throw_away, throw_away, throw_away,
           throw_away, load_1, load_5, load_15);
    fclose(fff);
  }
}


x86 assembly (clang, -O0):
<get_load_average>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xe88(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <popen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ed <get_load_average+0xbd>
mov    -0x40(%rbp),%rbx
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%r11
mov    -0x18(%rbp),%r10
mov    -0x20(%rbp),%rax
lea    0xe62(%rip),%rsi
sub    $0x30,%rsp
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
mov    %rbx,%r9
mov    %rbx,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
call   1040 <fscanf@plt>
add    $0x30,%rsp
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_load_average>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x2e92(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe98(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <popen@plt>
test   %rax,%rax
je     11ac <get_load_average+0x7c>
mov    %rax,%r13
lea    0xe8d(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %rbx,%r8
mov    %rbx,%r9
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rbx
push   %rbx
call   1040 <fscanf@plt>
add    $0x30,%rsp
mov    %r13,%rdi
call   1030 <fclose@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"w | head -n 1\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"%64s %64s %64s %64s %64s %64s %64s %f %f %f\00"
define void @get_load_average(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%10 = load i32, i32* @BUFSIZ
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %8
%13 = alloca i8, i64 %11
store i64 %11, i64* %9
%14 = call i32* @popen(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* %14, i32** %7
%15 = load i32*, i32** %7
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %25
17: ; preds = %3
%18 = load i32*, i32** %7
%19 = load float*, float** %4
%20 = load float*, float** %5
%21 = load float*, float** %6
%22 = call i32 @fscanf(i32* %18, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %13, i8* %13, i8* %13, i8* %13, i8* %13, i8* %13, float* %19, float* %20, float* %21)
%23 = load i32*, i32** %7
%24 = call i32 @fclose(i32* %23)
br label %25
25: ; preds = %17, %3
%26 = load i8*, i8** %8
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"w | head -n 1\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"%64s %64s %64s %64s %64s %64s %64s %f %f %f\00"
define void @get_load_average(float* %0, float* %1, float* %2) {
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = tail call i32* @popen(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))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* %6, i8* %6, i8* %6, i8* %6, i8* %6, i8* %6, float* %0, float* %1, float* %2)
%11 = call i32 @fclose(i32* %7)
br label %12
12: ; preds = %9, %3
ret void
}