#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 {
  double const totalram;
  double const freeram;
};

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, double const, double const,
                            double const);
int /*<<< orphan*/ strncat(char *, char *, size_t);
int /*<<< orphan*/ sysinfo(struct sysinfo *);
int infomemoria(char *b, size_t s) {
  const double megabyte = 1024 * 1024;
  struct sysinfo si;
  sysinfo(&si);
  char buffer[500];
  buffer[0] = '\x0';
  snprintf(buffer, 500,
           "<p><b>Total RAM:</b> %5.1f MB<br><b>Total RAM in Use:</b> %5.1f "
           "MB<br><b>Total RAM Free:</b> %5.1f MB</p>",
           si.totalram / megabyte, (si.totalram - si.freeram) / megabyte,
           si.freeram / megabyte);
  strncat(b, buffer, s);
  return 1;
}


x86 assembly (clang, -O0):
<infomemoria>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <sysinfo@plt>
movb   $0x0,-0x220(%rbp)
lea    -0x220(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
movsd  0xe8c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe76(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  0xe65(%rip),%xmm3
divsd  %xmm3,%xmm2
mov    $0x1f4,%esi
lea    0xe5d(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x220(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <strncat@plt>
mov    $0x1,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<infomemoria>:
push   %r15
push   %r14
push   %rbx
sub    $0x210,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsp,%rdi
call   1050 <sysinfo@plt>
movb   $0x0,0x10(%rsp)
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0xe9e(%rip),%xmm3
movapd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
subsd  %xmm2,%xmm1
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm2
lea    0xe8b(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1f4,%esi
call   1030 <snprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <strncat@plt>
mov    $0x1,%eax
add    $0x210,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sysinfo = type { double, double }
@.str = [106 x i8] c"<p><b>Total RAM:</b> %5.1f MB<br><b>Total RAM in Use:</b> %5.1f MB<br><b>Total RAM Free:</b> %5.1f MB</p>\00"
define i32 @infomemoria(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca double
%6 = alloca %struct.sysinfo
%7 = alloca [500 x i8]
store i8* %0, i8** %3
store i64 %1, i64* %4
store double 0x4130000000000000, double* %5
%8 = call i32 @sysinfo(%struct.sysinfo* %6)
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
store i8 0, i8* %9
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%12 = load double, double* %11
%13 = fdiv double %12, 0x4130000000000000
%14 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 0
%15 = load double, double* %14
%16 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 1
%17 = load double, double* %16
%18 = fsub double %15, %17
%19 = fdiv double %18, 0x4130000000000000
%20 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %6, i32 0, i32 1
%21 = load double, double* %20
%22 = fdiv double %21, 0x4130000000000000
%23 = call i32 @snprintf(i8* %10, i32 500, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), double %13, double %19, double %22)
%24 = load i8*, i8** %3
%25 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%26 = load i64, i64* %4
%27 = call i32 @strncat(i8* %24, i8* %25, i64 %26)
ret i32 1
}

LLVM IR (-O2):
%struct.sysinfo = type { double, double }
@.str = [106 x i8] c"<p><b>Total RAM:</b> %5.1f MB<br><b>Total RAM in Use:</b> %5.1f MB<br><b>Total RAM Free:</b> %5.1f MB</p>\00"
define i32 @infomemoria(i8* %0, i64 %1) {
%3 = alloca %struct.sysinfo
%4 = alloca [500 x i8]
%5 = bitcast %struct.sysinfo* %3 to i8*
%6 = call i32 @sysinfo(%struct.sysinfo* %3)
%7 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
store i8 0, i8* %7
%8 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 0
%9 = load double, double* %8
%10 = fmul double %9, 0x3EB0000000000000
%11 = getelementptr inbounds %struct.sysinfo, %struct.sysinfo* %3, i64 0, i32 1
%12 = load double, double* %11
%13 = fsub double %9, %12
%14 = fmul double %13, 0x3EB0000000000000
%15 = fmul double %12, 0x3EB0000000000000
%16 = call i32 @snprintf(i8* %7, i32 500, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str, i64 0, i64 0), double %10, double %14, double %15)
%17 = call i32 @strncat(i8* %0, i8* %7, i64 %1)
ret i32 1
}