#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 mallinfo {
  int arena;
  int ordblks;
  int smblks;
  int hblks;
  int hblkhd;
  int usmblks;
  int fsmblks;
  int uordblks;
  int fordblks;
  int keepcost;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ malloc_stats();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  char *buf;
  struct mallinfo m;
  buf = malloc(sizeof(char) * 50);
  if (buf != NULL) {
    malloc_stats();
    printf("\nmalloc info using mallinfo\n");
    printf("Arena: %d\n", m.arena);
    printf("Number of free chunks: %d\n", m.ordblks);
    printf("Number of fast bins: %d\n", m.smblks);
    printf("Number of Anonymous mappings: %d\n", m.hblks);
    printf("Size of Anonymous mappings: %d\n", m.hblkhd);
    printf("Maximum total allocated size: %d\n", m.usmblks);
    printf("Size of Available fast bins: %d\n", m.fsmblks);
    printf("Size of total allocated space: %d\n", m.uordblks);
    printf("Size of available chunks: %d\n", m.fordblks);
    printf("Size of trimmable space: %d\n", m.keepcost);
    free(buf);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1247 <main+0xf7>
mov    $0x0,%al
call   1060 <malloc_stats@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xeeb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x32,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     121e <main+0xbe>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <malloc_stats@plt>
lea    0xf9d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xef6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.mallinfo = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@.str = [29 x i8] c"\0Amalloc info using mallinfo\0A\00"
@.str.1 = [11 x i8] c"Arena: %d\0A\00"
@.str.2 = [27 x i8] c"Number of free chunks: %d\0A\00"
@.str.3 = [25 x i8] c"Number of fast bins: %d\0A\00"
@.str.4 = [34 x i8] c"Number of Anonymous mappings: %d\0A\00"
@.str.5 = [32 x i8] c"Size of Anonymous mappings: %d\0A\00"
@.str.6 = [34 x i8] c"Maximum total allocated size: %d\0A\00"
@.str.7 = [33 x i8] c"Size of Available fast bins: %d\0A\00"
@.str.8 = [35 x i8] c"Size of total allocated space: %d\0A\00"
@.str.9 = [30 x i8] c"Size of available chunks: %d\0A\00"
@.str.10 = [29 x i8] c"Size of trimmable space: %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.mallinfo
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @malloc(i32 50)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %46
11: ; preds = %2
%12 = call i32 (...) @malloc_stats()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 1
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 2
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 3
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 4
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 5
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 6
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 7
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 8
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %7, i32 0, i32 9
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %6
%45 = call i32 @free(i8* %44)
br label %46
46: ; preds = %11, %2
%47 = load i32, i32* @EXIT_SUCCESS
%48 = call i32 @exit(i32 %47)
unreachable
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"Arena: %d\0A\00"
@.str.2 = [27 x i8] c"Number of free chunks: %d\0A\00"
@.str.3 = [25 x i8] c"Number of fast bins: %d\0A\00"
@.str.4 = [34 x i8] c"Number of Anonymous mappings: %d\0A\00"
@.str.5 = [32 x i8] c"Size of Anonymous mappings: %d\0A\00"
@.str.6 = [34 x i8] c"Maximum total allocated size: %d\0A\00"
@.str.7 = [33 x i8] c"Size of Available fast bins: %d\0A\00"
@.str.8 = [35 x i8] c"Size of total allocated space: %d\0A\00"
@.str.9 = [30 x i8] c"Size of available chunks: %d\0A\00"
@.str.10 = [29 x i8] c"Size of trimmable space: %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [28 x i8] c"\0Amalloc info using mallinfo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%4 = icmp eq i8* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = tail call i32 (...) @malloc_stats()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 undef)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 undef)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 undef)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 undef)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), i32 undef)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 undef)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i32 undef)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i32 undef)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 undef)
%18 = tail call i32 @free(i8* %3)
br label %19
19: ; preds = %5, %2
%20 = load i32, i32* @EXIT_SUCCESS
%21 = tail call i32 @exit(i32 %20)
unreachable
}