#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 */

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ getchar();
void *malloc(int);
int /*<<< orphan*/ malloc_stats();
int malloc_usable_size(void *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  void *handle;
  printf("\n Before Malloc Call \n");
  malloc_stats();
  getchar();
  printf("\n After Malloc Call \n");
  handle = malloc(350);
  malloc_stats();
  printf("\n usable size %d \n", malloc_usable_size(handle));
  getchar();
  printf(" \n After free call \n");
  free(handle);
  malloc_stats();
  getchar();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1080 <malloc_stats@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x15e,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <malloc_stats@plt>
mov    -0x10(%rbp),%rdi
call   1050 <malloc_usable_size@plt>
mov    %eax,%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1080 <malloc_stats@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <malloc_stats@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
mov    $0x15e,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1090 <malloc_stats@plt>
mov    %rbx,%rdi
call   1060 <malloc_usable_size@plt>
lea    0xe36(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
lea    0xe5d(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1090 <malloc_stats@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"\0A Before Malloc Call \0A\00"
@.str.1 = [22 x i8] c"\0A After Malloc Call \0A\00"
@.str.2 = [19 x i8] c"\0A usable size %d \0A\00"
@.str.3 = [21 x i8] c" \0A After free call \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @malloc_stats()
%5 = call i32 (...) @getchar()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = call i8* @malloc(i32 350)
store i8* %7, i8** %2
%8 = call i32 (...) @malloc_stats()
%9 = load i8*, i8** %2
%10 = call i32 @malloc_usable_size(i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = call i32 (...) @getchar()
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
%16 = call i32 (...) @malloc_stats()
%17 = call i32 (...) @getchar()
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @exit(i32 %18)
unreachable
}

LLVM IR (-O2):
@.str.2 = [19 x i8] c"\0A usable size %d \0A\00"
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"\0A Before Malloc Call \00"
@str.4 = [21 x i8] c"\0A After Malloc Call \00"
@str.5 = [20 x i8] c" \0A After free call \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @malloc_stats()
%3 = tail call i32 (...) @getchar()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%5 = tail call dereferenceable_or_null(350) i8* @malloc(i32 350)
%6 = tail call i32 (...) @malloc_stats()
%7 = tail call i32 @malloc_usable_size(i8* %5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @getchar()
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.5, i64 0, i64 0))
%11 = tail call i32 @free(i8* %5)
%12 = tail call i32 (...) @malloc_stats()
%13 = tail call i32 (...) @getchar()
%14 = load i32, i32* @EXIT_SUCCESS
%15 = tail call i32 @exit(i32 %14)
unreachable
}