#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*/ free(void *);
void *malloc(int);
int /*<<< orphan*/ printf(char *, void *);
int main() {
  void *m1 = malloc(500);
  void *m2 = malloc(40);
  malloc(1);
  void *m3 = malloc(80);
  free(m1);
  free(m2);
  void *m4 = malloc(40);
  free(m3);
  void *m5 = malloc(80);
  printf("m1, %p\n", m1);
  printf("m2, %p\n", m2);
  printf("m3, %p\n", m3);
  printf("m4, %p\n", m4);
  printf("m5, %p\n", m5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1f4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x1,%edi
call   1050 <malloc@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x1f4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%r13
lea    0xe67(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xe52(%rip),%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"m1, %p\0A\00"
@.str.1 = [8 x i8] c"m2, %p\0A\00"
@.str.2 = [8 x i8] c"m3, %p\0A\00"
@.str.3 = [8 x i8] c"m4, %p\0A\00"
@.str.4 = [8 x i8] c"m5, %p\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = call i8* @malloc(i32 500)
store i8* %7, i8** %2
%8 = call i8* @malloc(i32 40)
store i8* %8, i8** %3
%9 = call i8* @malloc(i32 1)
%10 = call i8* @malloc(i32 80)
store i8* %10, i8** %4
%11 = load i8*, i8** %2
%12 = call i32 @free(i8* %11)
%13 = load i8*, i8** %3
%14 = call i32 @free(i8* %13)
%15 = call i8* @malloc(i32 40)
store i8* %15, i8** %5
%16 = load i8*, i8** %4
%17 = call i32 @free(i8* %16)
%18 = call i8* @malloc(i32 80)
store i8* %18, i8** %6
%19 = load i8*, i8** %2
%20 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %3
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %4
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"m1, %p\0A\00"
@.str.1 = [8 x i8] c"m2, %p\0A\00"
@.str.2 = [8 x i8] c"m3, %p\0A\00"
@.str.3 = [8 x i8] c"m4, %p\0A\00"
@.str.4 = [8 x i8] c"m5, %p\0A\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(500) i8* @malloc(i32 500)
%2 = tail call dereferenceable_or_null(40) i8* @malloc(i32 40)
%3 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%4 = tail call i32 @free(i8* %1)
%5 = tail call i32 @free(i8* %2)
%6 = tail call dereferenceable_or_null(40) i8* @malloc(i32 40)
%7 = tail call i32 @free(i8* %3)
%8 = tail call dereferenceable_or_null(80) i8* @malloc(i32 80)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %8)
ret i32 0
}