#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 getloadavg(double *, int);
int sockerror(int, char *);
int sockprint(int, char *, double, double, double);
int dump_loadavg(int fd) {
  double avg[3];
  if (getloadavg(avg, 3) == -1)
    return sockerror(fd, "getloadavg(3)");
  return sockprint(fd, "load: 1min: %f, 5min: %f, 15min: %f\r\n", avg[0],
                   avg[1], avg[2]);
}


x86 assembly (clang, -O0):
<dump_loadavg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x3,%esi
call   1030 <getloadavg@plt>
cmp    $0xffffffff,%eax
jne    1169 <dump_loadavg+0x39>
mov    -0x8(%rbp),%edi
lea    0xea4(%rip),%rsi
call   1050 <sockerror@plt>
mov    %eax,-0x4(%rbp)
jmp    118a <dump_loadavg+0x5a>
mov    -0x8(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
lea    0xe8c(%rip),%rsi
call   1040 <sockprint@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_loadavg>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0x3,%esi
call   1030 <getloadavg@plt>
cmp    $0xffffffff,%eax
je     116a <dump_loadavg+0x3a>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xead(%rip),%rsi
mov    %ebx,%edi
call   1040 <sockprint@plt>
jmp    1178 <dump_loadavg+0x48>
lea    0xe8f(%rip),%rsi
mov    %ebx,%edi
call   1050 <sockerror@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"getloadavg(3)\00"
@.str.1 = [38 x i8] c"load: 1min: %f, 5min: %f, 15min: %f\0D\0A\00"
define i32 @dump_loadavg(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x double]
store i32 %0, i32* %3
%5 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%6 = call i32 @getloadavg(double* %5, i32 3)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i32 @sockerror(i32 %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %2
br label %20
11: ; preds = %1
%12 = load i32, i32* %3
%13 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%18 = load double, double* %17
%19 = call i32 @sockprint(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %14, double %16, double %18)
store i32 %19, i32* %2
br label %20
20: ; preds = %11, %8
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [14 x i8] c"getloadavg(3)\00"
@.str.1 = [38 x i8] c"load: 1min: %f, 5min: %f, 15min: %f\0D\0A\00"
define i32 @dump_loadavg(i32 %0) {
%2 = alloca [3 x double]
%3 = bitcast [3 x double]* %2 to i8*
%4 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%5 = call i32 @getloadavg(double* %4, i32 3)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @sockerror(i32 %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %16
9: ; preds = %1
%10 = load double, double* %4
%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 i32 @sockprint(i32 %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), double %10, double %12, double %14)
br label %16
16: ; preds = %9, %7
%17 = phi i32 [ %8, %7 ], [ %15, %9 ]
ret i32 %17
}