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

/* Variables and functions */
char const *bprintf(char *, double, double, double);
scalar_t__ getloadavg(double *, int);
int /*<<< orphan*/ warn(char *);
const char *load_avg(void) {
  double avgs[3];
  if (getloadavg(avgs, 3) < 0) {
    warn("getloadavg: Failed to obtain load average");
    return NULL;
  }
  return bprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
}


x86 assembly (clang, -O0):
<load_avg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1040 <getloadavg@plt>
cmp    $0x0,%rax
jge    1169 <load_avg+0x39>
lea    0xea9(%rip),%rdi
call   1030 <warn@plt>
movq   $0x0,-0x8(%rbp)
jmp    1188 <load_avg+0x58>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
lea    0xeab(%rip),%rdi
call   1050 <bprintf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_avg>:
sub    $0x18,%rsp
mov    %rsp,%rdi
mov    $0x3,%esi
call   1040 <getloadavg@plt>
test   %rax,%rax
js     1168 <load_avg+0x38>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xecc(%rip),%rdi
call   1050 <bprintf@plt>
add    $0x18,%rsp
ret
lea    0xe91(%rip),%rdi
call   1030 <warn@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"getloadavg: Failed to obtain load average\00"
@.str.1 = [15 x i8] c"%.2f %.2f %.2f\00"
define i8* @load_avg() {
%1 = alloca i8*
%2 = alloca [3 x double]
%3 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%4 = call i64 @getloadavg(double* %3, i32 3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @warn(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
store i8* null, i8** %1
br label %16
8: ; preds = %0
%9 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%10 = load double, double* %9
%11 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%14 = load double, double* %13
%15 = call i8* @bprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %10, double %12, double %14)
store i8* %15, i8** %1
br label %16
16: ; preds = %8, %6
%17 = load i8*, i8** %1
ret i8* %17
}

LLVM IR (-O2):
@.str = [42 x i8] c"getloadavg: Failed to obtain load average\00"
@.str.1 = [15 x i8] c"%.2f %.2f %.2f\00"
define i8* @load_avg() {
%1 = alloca [3 x double]
%2 = bitcast [3 x double]* %1 to i8*
%3 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%4 = call i64 @getloadavg(double* %3, i32 3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @warn(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %0
%9 = load double, double* %3
%10 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%13 = load double, double* %12
%14 = call i8* @bprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %9, double %11, double %13)
br label %15
15: ; preds = %8, %6
%16 = phi i8* [ null, %6 ], [ %14, %8 ]
ret i8* %16
}