#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 utsname {
  char *sysname;
  char *nodename;
  char *release;
  char *version;
  char *machine;
};
struct sysinfo {
  long const uptime;
  double const totalram;
  double const freeram;
  int procs;
};

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int /*<<< orphan*/ uname(struct utsname *);
int stuff(void) {
  struct utsname uname_pointer;
  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("Number of running processes : %d\n", si.procs);
  uname(&uname_pointer);
  printf("System name : %s \n"
         "Nodename    : %s \n"
         "Release     : %s \n"
         "Version     : %s \n"
         "Machine     : %s \n",
         uname_pointer.sysname, uname_pointer.nodename, uname_pointer.release,
         uname_pointer.version, uname_pointer.machine);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<stuff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movq   $0x3c,-0x30(%rbp)
movq   $0xe10,-0x38(%rbp)
movq   $0x15180,-0x40(%rbp)
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x68(%rbp),%rdi
call   1050 <sysinfo@plt>
mov    -0x68(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rax,%rsi
mov    -0x68(%rbp),%rax
mov    $0x15180,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rax
mov    $0xe10,%ecx
cqto
idiv   %rcx
mov    %rdx,%rax
mov    $0x3c,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
mov    $0x3c,%edi
cqto
idiv   %rdi
mov    %rdx,%r8
mov    -0x70(%rbp),%rdx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x60(%rbp),%xmm0
movsd  0xe1c(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
movsd  0xdfd(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x28(%rbp),%rdi
call   1040 <uname@plt>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x8(%rbp),%r9
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stuff>:
sub    $0x48,%rsp
mov    %rsp,%rdi
call   1050 <sysinfo@plt>
mov    (%rsp),%r8
movabs $0x1845c8a0ce512957,%rcx
c8 45 18
mov    %r8,%rax
imul   %rcx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0xd,%rdx
add    %rdx,%rsi
imul   $0x15180,%rsi,%rax
mov    %r8,%rcx
sub    %rax,%rcx
movslq %ecx,%rax
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0xb,%eax
add    %ecx,%eax
movslq %eax,%r9
movabs $0x48d159e26af37c05,%rcx
59 d1 48
mov    %r8,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xa,%rdx
add    %eax,%edx
imul   $0xe10,%edx,%eax
mov    %r8d,%ecx
sub    %eax,%ecx
movswl %cx,%eax
imul   $0xffff8889,%eax,%eax
shr    $0x10,%eax
add    %ecx,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
sar    $0x5,%ecx
add    %eax,%ecx
movswq %cx,%rcx
movabs $0x8888888888888889,%rdx
88 88 88
mov    %r8,%rax
imul   %rdx
add    %r8,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x5,%rdx
add    %rax,%rdx
imul   $0x3c,%rdx,%rax
sub    %rax,%r8
lea    0xe09(%rip),%rdi
mov    %r9,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xde9(%rip),%xmm0
lea    0xe15(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  0xdd3(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
lea    0xe11(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
call   1040 <uname@plt>
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    0x30(%rsp),%rcx
mov    0x38(%rsp),%r8
mov    0x40(%rsp),%r9
lea    0xe07(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
%struct.sysinfo = type { i64, double, double, i32 }
@.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 = [34 x i8] c"Number of running processes : %d\0A\00"
@.str.4 = [91 x i8] c"System name : %s \0ANodename : %s \0ARelease : %s \0AVersion : %s \0AMachine : %s \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @stuff() {
%1 = alloca %struct.utsname
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca %struct.sysinfo
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 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%12 = load i64, i64* %11
%13 = srem i64 %12, 86400
%14 = sdiv i64 %13, 3600
%15 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%16 = load i64, i64* %15
%17 = srem i64 %16, 3600
%18 = sdiv i64 %17, 60
%19 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%20 = load i64, i64* %19
%21 = srem i64 %20, 60
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %10, i64 %14, i64 %18, i64 %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 1
%24 = load double, double* %23
%25 = fdiv double %24, 0x4130000000000000
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 2
%28 = load double, double* %27
%29 = fdiv double %28, 0x4130000000000000
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 3
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = call i32 @uname(%struct.utsname* %1)
%35 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 1
%38 = load i8*, i8** %37
%39 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 2
%40 = load i8*, i8** %39
%41 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 3
%42 = load i8*, i8** %41
%43 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i32 0, i32 4
%44 = load i8*, i8** %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0), i8* %36, i8* %38, i8* %40, i8* %42, i8* %44)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i8*, i8*, i8*, i8* }
%struct.sysinfo = type { i64, double, double, i32 }
@.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 = [34 x i8] c"Number of running processes : %d\0A\00"
@.str.4 = [91 x i8] c"System name : %s \0ANodename : %s \0ARelease : %s \0AVersion : %s \0AMachine : %s \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @stuff() {
%1 = alloca %struct.utsname
%2 = alloca %struct.sysinfo
%3 = bitcast %struct.utsname* %1 to i8*
%4 = bitcast %struct.sysinfo* %2 to i8*
%5 = call i32 @sysinfo(%struct.sysinfo* %2)
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 0
%7 = load i64, i64* %6
%8 = sdiv i64 %7, 86400
%9 = srem i64 %7, 86400
%10 = trunc i64 %9 to i32
%11 = sdiv i32 %10, 3600
%12 = sext i32 %11 to i64
%13 = srem i64 %7, 3600
%14 = trunc i64 %13 to i16
%15 = sdiv i16 %14, 60
%16 = sext i16 %15 to i64
%17 = srem i64 %7, 60
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %8, i64 %12, i64 %16, i64 %17)
%19 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 1
%20 = load double, double* %19
%21 = fmul double %20, 0x3EB0000000000000
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double %21)
%23 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 2
%24 = load double, double* %23
%25 = fmul double %24, 0x3EB0000000000000
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %2, i64 0, i32 3
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = call i32 @uname(%struct.utsname* %1)
%31 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 0
%32 = load i8*, i8** %31
%33 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 1
%34 = load i8*, i8** %33
%35 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 2
%36 = load i8*, i8** %35
%37 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 3
%38 = load i8*, i8** %37
%39 = getelementptr inbounds %struct.utsname, %struct.utsname* %1, i64 0, i32 4
%40 = load i8*, i8** %39
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str.4, i64 0, i64 0), i8* %32, i8* %34, i8* %36, i8* %38, i8* %40)
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}