#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 totalram;
  int freeram;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
const char *plugin_status() {
  static char buf[4];
  static unsigned short cycle = 0;
  static struct sysinfo info;
  if (cycle++ % 5 != 0) {
    return buf;
  }
  sysinfo(&info);
  snprintf(buf, 4, "%3li",
           ((info.totalram - info.freeram) * 100) / info.totalram);
  return buf;
}


x86 assembly (clang, -O0):
<plugin_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2f09(%rip),%ax
mov    %ax,%cx
add    $0x1,%cx
mov    %cx,0x2efb(%rip)
movzwl %ax,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1161 <plugin_status+0x41>
lea    0x2edc(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <plugin_status+0x88>
lea    0x2ed4(%rip),%rdi
call   1040 <sysinfo@plt>
mov    0x2ec9(%rip),%eax
sub    0x2ec7(%rip),%eax
imul   $0x64,%eax,%eax
cltd
idivl  0x2eb9(%rip)
mov    %eax,%ecx
lea    0x2ea8(%rip),%rdi
mov    $0x4,%esi
lea    0xe68(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2e90(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<plugin_status>:
push   %rax
movzwl 0x2f10(%rip),%eax
lea    0x1(%rax),%ecx
mov    %cx,0x2f06(%rip)
imul   $0xffffcccd,%eax,%eax
movzwl %ax,%eax
cmp    $0x3333,%eax
ja     117c <plugin_status+0x5c>
lea    0x2ef3(%rip),%rdi
call   1040 <sysinfo@plt>
mov    0x2ee8(%rip),%ecx
mov    %ecx,%eax
sub    0x2ee4(%rip),%eax
imul   $0x64,%eax,%eax
cltd
idiv   %ecx
lea    0x2ecb(%rip),%rdi
lea    0xe90(%rip),%rdx
mov    $0x4,%esi
mov    %eax,%ecx
call   1030 <snprintf@plt>
lea    0x2eb1(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.sysinfo = type { i32, i32 }
@plugin_status.buf = internal global [4 x i8] zeroinitializer
@plugin_status.cycle = internal global i16 0
@plugin_status.info = internal global %struct.sysinfo zeroinitializer
@.str = [5 x i8] c"%3li\00"
define i8* @plugin_status() {
%1 = alloca i8*
%2 = load i16, i16* @plugin_status.cycle
%3 = add i16 %2, 1
store i16 %3, i16* @plugin_status.cycle
%4 = zext i16 %2 to i32
%5 = srem i32 %4, 5
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @plugin_status.buf, i64 0, i64 0), i8** %1
br label %17
8: ; preds = %0
%9 = call i32 @sysinfo(%struct.sysinfo* @plugin_status.info)
%10 = load i32, i32* getelementptr inbounds (%struct.sysinfo, %struct.sysinfo* @plugin_status.info, i32 0, i32 0)
%11 = load i32, i32* getelementptr inbounds (%struct.sysinfo, %struct.sysinfo* @plugin_status.info, i32 0, i32 1)
%12 = sub nsw i32 %10, %11
%13 = mul nsw i32 %12, 100
%14 = load i32, i32* getelementptr inbounds (%struct.sysinfo, %struct.sysinfo* @plugin_status.info, i32 0, i32 0)
%15 = sdiv i32 %13, %14
%16 = call i32 @snprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @plugin_status.buf, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @plugin_status.buf, i64 0, i64 0), i8** %1
br label %17
17: ; preds = %8, %7
%18 = load i8*, i8** %1
ret i8* %18
}

LLVM IR (-O2):
%struct.sysinfo = type { i32, i32 }
@plugin_status.buf = internal global [4 x i8] zeroinitializer
@plugin_status.cycle = internal unnamed_addr global i16 0
@plugin_status.info = internal global %struct.sysinfo zeroinitializer
@.str = [5 x i8] c"%3li\00"
define i8* @plugin_status() {
%1 = load i16, i16* @plugin_status.cycle
%2 = add i16 %1, 1
store i16 %2, i16* @plugin_status.cycle
%3 = urem i16 %1, 5
%4 = icmp eq i16 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %0
%6 = tail call i32 @sysinfo(%struct.sysinfo* @plugin_status.info)
%7 = load i32, i32* getelementptr inbounds (%struct.sysinfo, %struct.sysinfo* @plugin_status.info, i64 0, i32 0)
%8 = load i32, i32* getelementptr inbounds (%struct.sysinfo, %struct.sysinfo* @plugin_status.info, i64 0, i32 1)
%9 = sub nsw i32 %7, %8
%10 = mul nsw i32 %9, 100
%11 = sdiv i32 %10, %7
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @plugin_status.buf, i64 0, i64 0), i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %0, %5
ret i8* getelementptr inbounds ([4 x i8], [4 x i8]* @plugin_status.buf, i64 0, i64 0)
}