#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*/ disp_heap();
int /*<<< orphan*/ getc();
unsigned int *malloc(int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  unsigned int *ptr = malloc(sizeof(int));
  *ptr = 0xDDCCBBAA;
  puts("Heap:\n");
  getc();
  disp_heap();
  ptr = malloc(0x1500);
  *(unsigned int *)((unsigned int)ptr + 0x1450) = 0xDDCCBBAA;
  puts("\nHeap:\n");
  getc();
  disp_heap();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0xddccbbaa,(%rax)
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <getc@plt>
mov    $0x0,%al
call   1040 <disp_heap@plt>
mov    $0x1500,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1450,%eax
mov    %eax,%eax
movl   $0xddccbbaa,(%rax)
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1060 <getc@plt>
mov    $0x0,%al
call   1040 <disp_heap@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
call   1050 <malloc@plt>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getc@plt>
xor    %eax,%eax
call   1040 <disp_heap@plt>
mov    $0x1500,%edi
call   1050 <malloc@plt>
add    $0x1450,%eax
movl   $0xddccbbaa,(%rax)
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getc@plt>
xor    %eax,%eax
call   1040 <disp_heap@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Heap:\0A\00"
@.str.1 = [8 x i8] c"\0AHeap:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = call i32* @malloc(i32 4)
store i32* %6, i32** %5
%7 = load i32*, i32** %5
store i32 -573785174, i32* %7
%8 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @getc()
%10 = call i32 (...) @disp_heap()
%11 = call i32* @malloc(i32 5376)
store i32* %11, i32** %5
%12 = load i32*, i32** %5
%13 = ptrtoint i32* %12 to i32
%14 = add i32 %13, 5200
%15 = zext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store i32 -573785174, i32* %16
%17 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (...) @getc()
%19 = call i32 (...) @disp_heap()
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Heap:\0A\00"
@.str.1 = [8 x i8] c"\0AHeap:\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 4)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @getc()
%6 = tail call i32 (...) @disp_heap()
%7 = tail call i32* @malloc(i32 5376)
%8 = ptrtoint i32* %7 to i64
%9 = add i64 %8, 5200
%10 = and i64 %9, 4294967295
%11 = inttoptr i64 %10 to i32*
store i32 -573785174, i32* %11
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 (...) @getc()
%14 = tail call i32 (...) @disp_heap()
ret i32 0
}