#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(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ print_list();
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  printf("\n---- running test5 ---\n");
  int *mem1 = (int *)malloc(1048576);
  *mem1 = 10;
  int *mem2 = (int *)malloc(1048528);
  *mem2 = 11;
  printf("NO FREES:\n");
  print_list();
  free(mem2);
  printf("FREE RIGHT:\n");
  print_list();
  free(mem1);
  printf("FREE LEFT:\n");
  print_list();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
call   1050 <printf@plt>
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
mov    $0xfffd0,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0xb,(%rax)
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <print_list@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
lea    0xe5f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <print_list@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
lea    0xe50(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <print_list@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x100000,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
movl   $0xa,(%rax)
mov    $0xfffd0,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movl   $0xb,(%rax)
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <print_list@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <print_list@plt>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <print_list@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"\0A---- running test5 ---\0A\00"
@.str.1 = [11 x i8] c"NO FREES:\0A\00"
@.str.2 = [13 x i8] c"FREE RIGHT:\0A\00"
@.str.3 = [12 x i8] c"FREE LEFT:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @malloc(i32 1048576)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %6
%11 = load i32*, i32** %6
store i32 10, i32* %11
%12 = call i64 @malloc(i32 1048528)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %7
%14 = load i32*, i32** %7
store i32 11, i32* %14
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (...) @print_list()
%17 = load i32*, i32** %7
%18 = call i32 @free(i32* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @print_list()
%21 = load i32*, i32** %6
%22 = call i32 @free(i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (...) @print_list()
%25 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [24 x i8] c"\0A---- running test5 ---\00"
@str.4 = [10 x i8] c"NO FREES:\00"
@str.5 = [12 x i8] c"FREE RIGHT:\00"
@str.6 = [11 x i8] c"FREE LEFT:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%4 = tail call i64 @malloc(i32 1048576)
%5 = inttoptr i64 %4 to i32*
store i32 10, i32* %5
%6 = tail call i64 @malloc(i32 1048528)
%7 = inttoptr i64 %6 to i32*
store i32 11, i32* %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
%9 = tail call i32 (...) @print_list()
%10 = tail call i32 @free(i32* %7)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0))
%12 = tail call i32 (...) @print_list()
%13 = tail call i32 @free(i32* %5)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
%15 = tail call i32 (...) @print_list()
%16 = tail call i32 @exit(i32 0)
unreachable
}