#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 */
struct sysinfo {
  long const uptime;
  double const totalram;
  double const freeram;
  double const procs;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double const, ...);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int main() {
  const long minute = 60;
  const long hour = minute * 60;
  const long day = hour * 24;
  const double megabyte = 1024 * 1024;
  struct sysinfo si;
  sysinfo(&si);
  printf("system uptime : %ld days, %ld:%02ld:%02ld\n", si.uptime / day,
         (si.uptime % day) / hour, (si.uptime % hour) / minute,
         si.uptime % minute);
  printf("total RAM   : %5.1f MB\n", si.totalram / megabyte);
  printf("free RAM   : %5.1f MB\n", si.freeram / megabyte);
  printf("process count : %d\n", si.procs);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x3c,-0x10(%rbp)
movq   $0xe10,-0x18(%rbp)
movq   $0x15180,-0x20(%rbp)
movsd  0xeb1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
lea    -0x48(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x48(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
cvtsi2sd %rax,%xmm0
mov    -0x48(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
mov    -0x48(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rdx,%rcx
mov    -0x50(%rbp),%rdx
lea    0xe3f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
movsd  0xe23(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe4b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
movsd  0xe04(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
lea    0x8(%rsp),%rdi
call   1040 <sysinfo@plt>
mov    0x8(%rsp),%rcx
movabs $0x1845c8a0ce512957,%rdx
c8 45 18
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xd,%rdx
add    %rax,%rdx
cvtsi2sd %rdx,%xmm0
imul   $0x15180,%rdx,%rax
mov    %rcx,%rdx
sub    %rax,%rdx
movslq %edx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rdx
shr    $0x20,%rdx
add    %edx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0xb,%eax
add    %edx,%eax
movslq %eax,%rsi
movabs $0x48d159e26af37c05,%rdx
59 d1 48
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xa,%rdx
add    %eax,%edx
imul   $0xe10,%edx,%eax
mov    %ecx,%edx
sub    %eax,%edx
movswl %dx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %edx,%eax
movzwl %ax,%eax
movswl %ax,%edx
shr    $0xf,%eax
sar    $0x5,%edx
add    %eax,%edx
movswq %dx,%r8
movabs $0x8888888888888889,%rdx
88 88 88
mov    %rcx,%rax
imul   %rdx
add    %rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x5,%rdx
add    %rax,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%rcx
lea    0xe12(%rip),%rdi
mov    %r8,%rdx
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xdf2(%rip),%xmm0
lea    0xe1e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xddc(%rip),%xmm0
mulsd  0x18(%rsp),%xmm0
lea    0xe1a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
lea    0xe1d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i64, double, double, double }
@.str = [43 x i8] c"system uptime : %ld days, %ld:%02ld:%02ld\0A\00"
@.str.1 = [24 x i8] c"total RAM : %5.1f MB\0A\00"
@.str.2 = [23 x i8] c"free RAM : %5.1f MB\0A\00"
@.str.3 = [20 x i8] c"process count : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca %struct.sysinfo
store i32 0, i32* %1
store i64 60, i64* %2
store i64 3600, i64* %3
store i64 86400, i64* %4
store double 0x4130000000000000, double* %5
%7 = call i32 @sysinfo(%struct.sysinfo* %6)
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%9 = load i64, i64* %8
%10 = sdiv i64 %9, 86400
%11 = sitofp i64 %10 to double
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%13 = load i64, i64* %12
%14 = srem i64 %13, 86400
%15 = sdiv i64 %14, 3600
%16 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%17 = load i64, i64* %16
%18 = srem i64 %17, 3600
%19 = sdiv i64 %18, 60
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%21 = load i64, i64* %20
%22 = srem i64 %21, 60
%23 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %11, i64 %15, i64 %19, i64 %22)
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 1
%25 = load double, double* %24
%26 = fdiv double %25, 0x4130000000000000
%27 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %26)
%28 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 2
%29 = load double, double* %28
%30 = fdiv double %29, 0x4130000000000000
%31 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %30)
%32 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 3
%33 = load double, double* %32
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %33)
ret i32 0
}

LLVM IR (-O2):
%struct.sysinfo = type { i64, double, double, double }
@.str = [43 x i8] c"system uptime : %ld days, %ld:%02ld:%02ld\0A\00"
@.str.1 = [24 x i8] c"total RAM : %5.1f MB\0A\00"
@.str.2 = [23 x i8] c"free RAM : %5.1f MB\0A\00"
@.str.3 = [20 x i8] c"process count : %d\0A\00"
define i32 @main() {
%1 = alloca %struct.sysinfo
%2 = bitcast %struct.sysinfo* %1 to i8*
%3 = call i32 @sysinfo(%struct.sysinfo* %1)
%4 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 0
%5 = load i64, i64* %4
%6 = sdiv i64 %5, 86400
%7 = sitofp i64 %6 to double
%8 = srem i64 %5, 86400
%9 = trunc i64 %8 to i32
%10 = sdiv i32 %9, 3600
%11 = sext i32 %10 to i64
%12 = srem i64 %5, 3600
%13 = trunc i64 %12 to i16
%14 = sdiv i16 %13, 60
%15 = sext i16 %14 to i64
%16 = srem i64 %5, 60
%17 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %7, i64 %11, i64 %15, i64 %16)
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%19 = load double, double* %18
%20 = fmul double %19, 0x3EB0000000000000
%21 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%23 = load double, double* %22
%24 = fmul double %23, 0x3EB0000000000000
%25 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %24)
%26 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%27 = load double, double* %26
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %27)
ret i32 0
}