#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 */
scalar_t__ getloadavg(unsigned int *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int, unsigned int);
int main() {
  unsigned vec[3];
  if (getloadavg(vec, 3) < 0) {
    perror("la: getloadavg");
    return 1;
  }
  printf("load %u.%02u %u.%02u %u.%02u\n", vec[0] / 100, vec[0] % 100,
         vec[1] / 100, vec[1] % 100, vec[2] / 100, vec[2] % 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1030 <getloadavg@plt>
cmp    $0x0,%rax
jge    116f <main+0x3f>
lea    0xea2(%rip),%rdi
call   1050 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11df <main+0xaf>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
mov    $0x64,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%r8d
mov    -0x8(%rbp),%eax
mov    $0x64,%edi
xor    %edx,%edx
div    %edi
mov    %eax,%r9d
mov    -0x8(%rbp),%eax
mov    $0x64,%edi
xor    %edx,%edx
div    %edi
mov    %edx,%eax
mov    -0x14(%rbp),%edx
lea    0xe3f(%rip),%rdi
mov    %eax,(%rsp)
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rdi
mov    $0x3,%esi
call   1030 <getloadavg@plt>
test   %rax,%rax
js     119d <main+0x6d>
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%r8d
imul   $0x51eb851f,%rdx,%rsi
shr    $0x25,%rsi
imul   $0x64,%esi,%eax
sub    %eax,%edx
imul   $0x51eb851f,%r8,%rcx
shr    $0x25,%rcx
imul   $0x64,%ecx,%eax
sub    %eax,%r8d
mov    0x14(%rsp),%eax
imul   $0x51eb851f,%rax,%r9
shr    $0x25,%r9
imul   $0x64,%r9d,%edi
sub    %edi,%eax
mov    %eax,(%rsp)
lea    0xe7e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe5c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"la: getloadavg\00"
@.str.1 = [30 x i8] c"load %u.%02u %u.%02u %u.%02u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
store i32 0, i32* %1
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%4 = call i64 @getloadavg(i32* %3, i32 3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %28
8: ; preds = %0
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
%11 = udiv i32 %10, 100
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %12
%14 = urem i32 %13, 100
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%16 = load i32, i32* %15
%17 = udiv i32 %16, 100
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%19 = load i32, i32* %18
%20 = urem i32 %19, 100
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%22 = load i32, i32* %21
%23 = udiv i32 %22, 100
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%25 = load i32, i32* %24
%26 = urem i32 %25, 100
%27 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14, i32 %17, i32 %20, i32 %23, i32 %26)
store i32 0, i32* %1
br label %28
28: ; preds = %8, %6
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [15 x i8] c"la: getloadavg\00"
@.str.1 = [30 x i8] c"load %u.%02u %u.%02u %u.%02u\0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i64 @getloadavg(i32* %3, i32 3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %21
8: ; preds = %0
%9 = load i32, i32* %3
%10 = udiv i32 %9, 100
%11 = urem i32 %9, 100
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%13 = load i32, i32* %12
%14 = udiv i32 %13, 100
%15 = urem i32 %13, 100
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%17 = load i32, i32* %16
%18 = udiv i32 %17, 100
%19 = urem i32 %17, 100
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11, i32 %14, i32 %15, i32 %18, i32 %19)
br label %21
21: ; preds = %8, %6
%22 = phi i32 [ 1, %6 ], [ 0, %8 ]
ret i32 %22
}