#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);
void dcc_getloadavg(double loadavg[3]) {
  int num;
  int i;
  num = getloadavg(loadavg, 3);
  if (num < 0)
    num = 0;
  for (i = num; i < 3; ++i)
    loadavg[i] = -1;
}


x86 assembly (clang, -O0):
<dcc_getloadavg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1030 <getloadavg@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    113e <dcc_getloadavg+0x2e>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    1171 <dcc_getloadavg+0x61>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1144 <dcc_getloadavg+0x34>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcc_getloadavg>:
push   %rbx
mov    %rdi,%rbx
mov    $0x3,%esi
call   1030 <getloadavg@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmovns %eax,%ecx
cmp    $0x2,%ecx
ja     120e <dcc_getloadavg+0xfe>
mov    %ecx,%eax
mov    $0x3,%r9d
sub    %rax,%r9
cmp    $0x4,%r9
jb     11ea <dcc_getloadavg+0xda>
mov    %r9,%r8
and    $0xfffffffffffffffc,%r8
lea    -0x4(%r8),%rcx
mov    %rcx,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0xc,%rcx
jae    1168 <dcc_getloadavg+0x58>
xor    %edx,%edx
jmp    11b1 <dcc_getloadavg+0xa1>
and    $0xfffffffffffffffc,%rdi
lea    (%rbx,%rax,8),%rcx
add    $0x70,%rcx
xor    %edx,%edx
movaps 0xe83(%rip),%xmm0
nopl   (%rax)
movups %xmm0,-0x70(%rcx,%rdx,8)
movups %xmm0,-0x60(%rcx,%rdx,8)
movups %xmm0,-0x50(%rcx,%rdx,8)
movups %xmm0,-0x40(%rcx,%rdx,8)
movups %xmm0,-0x30(%rcx,%rdx,8)
movups %xmm0,-0x20(%rcx,%rdx,8)
movups %xmm0,-0x10(%rcx,%rdx,8)
movups %xmm0,(%rcx,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rdi
jne    1180 <dcc_getloadavg+0x70>
test   %rsi,%rsi
je     11e2 <dcc_getloadavg+0xd2>
add    %rax,%rdx
lea    (%rbx,%rdx,8),%rcx
add    $0x10,%rcx
shl    $0x5,%rsi
xor    %edx,%edx
movaps 0xe32(%rip),%xmm0
xchg   %ax,%ax
movups %xmm0,-0x10(%rcx,%rdx,1)
movups %xmm0,(%rcx,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%rsi
jne    11d0 <dcc_getloadavg+0xc0>
cmp    %r8,%r9
je     120e <dcc_getloadavg+0xfe>
add    %r8,%rax
movabs $0xbff0000000000000,%rcx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rcx,(%rbx,%rax,8)
add    $0x1,%rax
cmp    $0x3,%rax
jne    1200 <dcc_getloadavg+0xf0>
pop    %rbx
ret

LLVM IR (-O0):
define void @dcc_getloadavg(double* %0) {
%2 = alloca double*
%3 = alloca i32
%4 = alloca i32
store double* %0, double** %2
%5 = load double*, double** %2
%6 = call i32 @getloadavg(double* %5, i32 3)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %3
br label %10
10: ; preds = %9, %1
%11 = load i32, i32* %3
store i32 %11, i32* %4
br label %12
12: ; preds = %20, %10
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load double*, double** %2
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* %16, i64 %18
store double -1.000000e+00, double* %19
br label %20
20: ; preds = %15
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %12
23: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @dcc_getloadavg(double* %0) {
%2 = tail call i32 @getloadavg(double* %0, i32 3)
%3 = icmp sgt i32 %2, 0
%4 = select i1 %3, i32 %2, i32 0
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %72
6: ; preds = %1
%7 = zext i32 %4 to i64
%8 = sub nsw i64 3, %7
%9 = icmp ult i64 %8, 4
br i1 %9, label %65, label %10
10: ; preds = %6
%11 = and i64 %8, -4
%12 = add nsw i64 %11, %7
%13 = add nsw i64 %11, -4
%14 = lshr exact i64 %13, 2
%15 = add nuw nsw i64 %14, 1
%16 = and i64 %15, 3
%17 = icmp ult i64 %13, 12
br i1 %17, label %49, label %18
18: ; preds = %10
%19 = and i64 %15, 9223372036854775804
br label %20
20: ; preds = %20, %18
%21 = phi i64 [ 0, %18 ], [ %46, %20 ]
%22 = phi i64 [ 0, %18 ], [ %47, %20 ]
%23 = add i64 %21, %7
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %25
%26 = getelementptr inbounds double, double* %24, i64 2
%27 = bitcast double* %26 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %27
%28 = or i64 %21, 4
%29 = add i64 %28, %7
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %31
%32 = getelementptr inbounds double, double* %30, i64 2
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %33
%34 = or i64 %21, 8
%35 = add i64 %34, %7
%36 = getelementptr inbounds double, double* %0, i64 %35
%37 = bitcast double* %36 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %37
%38 = getelementptr inbounds double, double* %36, i64 2
%39 = bitcast double* %38 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %39
%40 = or i64 %21, 12
%41 = add i64 %40, %7
%42 = getelementptr inbounds double, double* %0, i64 %41
%43 = bitcast double* %42 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %43
%44 = getelementptr inbounds double, double* %42, i64 2
%45 = bitcast double* %44 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %45
%46 = add nuw i64 %21, 16
%47 = add nuw i64 %22, 4
%48 = icmp eq i64 %47, %19
br i1 %48, label %49, label %20
49: ; preds = %20, %10
%50 = phi i64 [ 0, %10 ], [ %46, %20 ]
%51 = icmp eq i64 %16, 0
br i1 %51, label %63, label %52
52: ; preds = %49, %52
%53 = phi i64 [ %60, %52 ], [ %50, %49 ]
%54 = phi i64 [ %61, %52 ], [ 0, %49 ]
%55 = add i64 %53, %7
%56 = getelementptr inbounds double, double* %0, i64 %55
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %57
%58 = getelementptr inbounds double, double* %56, i64 2
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> <double -1.000000e+00, double -1.000000e+00>, <2 x double>* %59
%60 = add nuw i64 %53, 4
%61 = add i64 %54, 1
%62 = icmp eq i64 %61, %16
br i1 %62, label %63, label %52
63: ; preds = %52, %49
%64 = icmp eq i64 %8, %11
br i1 %64, label %72, label %65
65: ; preds = %6, %63
%66 = phi i64 [ %7, %6 ], [ %12, %63 ]
br label %67
67: ; preds = %65, %67
%68 = phi i64 [ %70, %67 ], [ %66, %65 ]
%69 = getelementptr inbounds double, double* %0, i64 %68
store double -1.000000e+00, double* %69
%70 = add nuw nsw i64 %68, 1
%71 = icmp eq i64 %70, 3
br i1 %71, label %72, label %67
72: ; preds = %67, %63, %1
ret void
}