#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*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ print_list();
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  printf("\n---- Running test1-2 ---\n");
  printf("Before any allocation\n");
  print_list();
  int *mem1 = (int *)malloc(8);
  *mem1 = 10;
  printf("mem1 = malloc(8)\n");
  print_list();
  int *mem2 = (int *)malloc(8);
  *mem2 = 11;
  printf("mem2 = malloc(8)\n");
  print_list();
  int *mem3 = (int *)malloc(8);
  *mem3 = 12;
  printf("mem3 = malloc(8)\n");
  print_list();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xa,(%rax)
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0xb,(%rax)
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xc,(%rax)
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <print_list@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
movl   $0xa,(%rax)
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
movl   $0xb,(%rax)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <print_list@plt>
mov    $0x8,%edi
call   1050 <malloc@plt>
movl   $0xc,(%rax)
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <print_list@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"\0A---- Running test1-2 ---\0A\00"
@.str.1 = [23 x i8] c"Before any allocation\0A\00"
@.str.2 = [18 x i8] c"mem1 = malloc(8)\0A\00"
@.str.3 = [18 x i8] c"mem2 = malloc(8)\0A\00"
@.str.4 = [18 x i8] c"mem3 = malloc(8)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (...) @print_list()
%12 = call i64 @malloc(i32 8)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %6
%14 = load i32*, i32** %6
store i32 10, i32* %14
%15 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (...) @print_list()
%17 = call i64 @malloc(i32 8)
%18 = inttoptr i64 %17 to i32*
store i32* %18, i32** %7
%19 = load i32*, i32** %7
store i32 11, i32* %19
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (...) @print_list()
%22 = call i64 @malloc(i32 8)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %8
%24 = load i32*, i32** %8
store i32 12, i32* %24
%25 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @print_list()
%27 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [26 x i8] c"\0A---- Running test1-2 ---\00"
@str.5 = [22 x i8] c"Before any allocation\00"
@str.6 = [17 x i8] c"mem1 = malloc(8)\00"
@str.7 = [17 x i8] c"mem2 = malloc(8)\00"
@str.8 = [17 x i8] c"mem3 = malloc(8)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 (...) @print_list()
%6 = tail call i64 @malloc(i32 8)
%7 = inttoptr i64 %6 to i32*
store i32 10, i32* %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 (...) @print_list()
%10 = tail call i64 @malloc(i32 8)
%11 = inttoptr i64 %10 to i32*
store i32 11, i32* %11
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.7, i64 0, i64 0))
%13 = tail call i32 (...) @print_list()
%14 = tail call i64 @malloc(i32 8)
%15 = inttoptr i64 %14 to i32*
store i32 12, i32* %15
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%17 = tail call i32 (...) @print_list()
%18 = tail call i32 @exit(i32 0)
unreachable
}