#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 {
  int freeram;
  int mem_unit;
  int freeswap;
  int totalram;
  int totalswap;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, int, int);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
void print_sysinfo(void) {
  struct sysinfo si;
  sysinfo(&si);
  printf("freeram (%luKB),  freeswap (%luKB), totalram (%luKB), totalswap "
         "(%luKB)\n",
         (si.freeram / 1024) * si.mem_unit, (si.freeswap / 1024) * si.mem_unit,
         (si.totalram / 1024) * si.mem_unit,
         (si.totalswap / 1024) * si.mem_unit);
}


x86 assembly (clang, -O0):
<print_sysinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x18(%rbp),%rdi
call   1040 <sysinfo@plt>
mov    -0x18(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
imul   -0x14(%rbp),%esi
mov    -0x10(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
imul   -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
imul   -0x14(%rbp),%ecx
mov    -0x8(%rbp),%eax
mov    $0x400,%edi
cltd
idiv   %edi
mov    -0x1c(%rbp),%edx
mov    %eax,%r8d
imul   -0x14(%rbp),%r8d
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_sysinfo>:
sub    $0x18,%rsp
mov    %rsp,%rdi
call   1040 <sysinfo@plt>
mov    (%rsp),%eax
lea    0x3ff(%rax),%esi
test   %eax,%eax
cmovns %eax,%esi
mov    0x4(%rsp),%eax
sar    $0xa,%esi
imul   %eax,%esi
mov    0x8(%rsp),%ecx
lea    0x3ff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0xa,%edx
imul   %eax,%edx
mov    0xc(%rsp),%edi
lea    0x3ff(%rdi),%ecx
test   %edi,%edi
cmovns %edi,%ecx
sar    $0xa,%ecx
imul   %eax,%ecx
mov    0x10(%rsp),%edi
lea    0x3ff(%rdi),%r8d
test   %edi,%edi
cmovns %edi,%r8d
sar    $0xa,%r8d
imul   %eax,%r8d
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32, i32, i32, i32 }
@.str = [73 x i8] c"freeram (%luKB), freeswap (%luKB), totalram (%luKB), totalswap (%luKB)\0A\00"
define void @print_sysinfo() {
%1 = alloca %struct.sysinfo
%2 = call i32 @sysinfo(%struct.sysinfo* %1)
%3 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = sdiv i32 %4, 1024
%6 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%7 = load i32, i32* %6
%8 = mul nsw i32 %5, %7
%9 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 2
%10 = load i32, i32* %9
%11 = sdiv i32 %10, 1024
%12 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%13 = load i32, i32* %12
%14 = mul nsw i32 %11, %13
%15 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 3
%16 = load i32, i32* %15
%17 = sdiv i32 %16, 1024
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%19 = load i32, i32* %18
%20 = mul nsw i32 %17, %19
%21 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 4
%22 = load i32, i32* %21
%23 = sdiv i32 %22, 1024
%24 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i32 0, i32 1
%25 = load i32, i32* %24
%26 = mul nsw i32 %23, %25
%27 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %14, i32 %20, i32 %26)
ret void
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32, i32, i32, i32 }
@.str = [73 x i8] c"freeram (%luKB), freeswap (%luKB), totalram (%luKB), totalswap (%luKB)\0A\00"
define void @print_sysinfo() {
%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 i32, i32* %4
%6 = sdiv i32 %5, 1024
%7 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = mul nsw i32 %6, %8
%10 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 2
%11 = load i32, i32* %10
%12 = sdiv i32 %11, 1024
%13 = mul nsw i32 %12, %8
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 3
%15 = load i32, i32* %14
%16 = sdiv i32 %15, 1024
%17 = mul nsw i32 %16, %8
%18 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %1, i64 0, i32 4
%19 = load i32, i32* %18
%20 = sdiv i32 %19, 1024
%21 = mul nsw i32 %20, %8
%22 = call i32 @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %13, i32 %17, i32 %21)
ret void
}