#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dump_mi(struct mallinfo *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(char *);
struct mallinfo mallinfo();
char *malloc(int);
int /*<<< orphan*/ malloc_stats();
int /*<<< orphan*/ stderr;
void doit(int bytes) {
  char *buf;
  struct mallinfo mi;
  fprintf(stderr, "\n Allocating %10d bytes ------- \n", bytes);
  buf = malloc(bytes);
  malloc_stats();
  mi = mallinfo();
  dump_mi(&mi);
  free(buf);
}


x86 assembly (clang, -O0):
<doit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe82(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x4(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <malloc_stats@plt>
mov    $0x0,%al
call   1040 <mallinfo@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1080 <dump_mi@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doit>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    %ebx,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <malloc_stats@plt>
xor    %eax,%eax
call   1040 <mallinfo@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1080 <dump_mi@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.mallinfo = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"\0A Allocating %10d bytes ------- \0A\00"
define void @doit(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.mallinfo
%5 = alloca %struct.mallinfo
store i32 %0, i32* %2
%6 = load i32, i32* @stderr
%7 = load i32, i32* %2
%8 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %3
%11 = call i32 (...) @malloc_stats()
%12 = call i32 (...) @mallinfo()
%13 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %5, i32 0, i32 0
store i32 %12, i32* %13
%14 = bitcast %struct.mallinfo* %4 to i8*
%15 = bitcast %struct.mallinfo* %5 to i8*
%16 = call i32 @dump_mi(%struct.mallinfo* %4)
%17 = load i8*, i8** %3
%18 = call i32 @free(i8* %17)
ret void
}

LLVM IR (-O2):
%struct.mallinfo = type { i32 }
@stderr = global i32 0
@.str = [34 x i8] c"\0A Allocating %10d bytes ------- \0A\00"
define void @doit(i32 %0) {
%2 = alloca %struct.mallinfo
%3 = bitcast %struct.mallinfo* %2 to i8*
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %0)
%6 = tail call i8* @malloc(i32 %0)
%7 = tail call i32 (...) @malloc_stats()
%8 = tail call i32 (...) @mallinfo()
%9 = getelementptr inbounds %struct.mallinfo, %struct.mallinfo* %2, i64 0, i32 0
store i32 %8, i32* %9
%10 = call i32 @dump_mi(%struct.mallinfo* %2)
%11 = call i32 @free(i8* %6)
ret void
}