#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 */
int /*<<< orphan*/ exit(int);
scalar_t__ getloadavg(double *, int);
int /*<<< orphan*/ perror(char *);
char *smprintf(char *, double, double, double);
char *getload(void) {
  double avgs[3];
  if (getloadavg(avgs, 3) < 0) {
    perror("getloadavg");
    exit(1);
  }
  return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
}


x86 assembly (clang, -O0):
<getload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1040 <getloadavg@plt>
cmp    $0x0,%rax
jge    1176 <getload+0x36>
lea    0xe99(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
lea    0xe7f(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getload>:
sub    $0x18,%rsp
mov    %rsp,%rdi
mov    $0x3,%esi
call   1040 <getloadavg@plt>
test   %rax,%rax
js     1178 <getload+0x38>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe9d(%rip),%rdi
call   1030 <smprintf@plt>
add    $0x18,%rsp
ret
lea    0xe81(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"getloadavg\00"
@.str.1 = [15 x i8] c"%.2f %.2f %.2f\00"
define i8* @getload() {
%1 = alloca [3 x double]
%2 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%3 = call i64 @getloadavg(double* %2, i32 3)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%10 = load double, double* %9
%11 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%14 = load double, double* %13
%15 = call i8* @smprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %10, double %12, double %14)
ret i8* %15
}

LLVM IR (-O2):
@.str = [11 x i8] c"getloadavg\00"
@.str.1 = [15 x i8] c"%.2f %.2f %.2f\00"
define i8* @getload() {
%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 %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = load double, double* %3
%11 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%14 = load double, double* %13
%15 = call i8* @smprintf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %10, double %12, double %14)
ret i8* %15
}