#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*/ brk(int *);
int getpagesize();
int /*<<< orphan*/ printf(char *, ...);
int *sbrk(int);
int main() {
  int *p = sbrk(0);
  printf("%p\n", p);
  sbrk(4);
  *p = 123456789;
  printf("%d\n", *p);
  *(p + 10) = 987654321;
  printf("%d\n", *(p + 10));
  printf("page:%d\n", getpagesize());
  brk(p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <sbrk@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <sbrk@plt>
mov    -0x8(%rbp),%rax
movl   $0x75bcd15,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movl   $0x3ade68b1,0x28(%rax)
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <getpagesize@plt>
mov    %eax,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <brk@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <sbrk@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <sbrk@plt>
movl   $0x75bcd15,(%rbx)
lea    0xe93(%rip),%r14
mov    %r14,%rdi
mov    $0x75bcd15,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x3ade68b1,0x28(%rbx)
mov    %r14,%rdi
mov    $0x3ade68b1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <getpagesize@plt>
lea    0xe5b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <brk@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%p\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [9 x i8] c"page:%d\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = call i32* @sbrk(i32 0)
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = call i32* @sbrk(i32 4)
%6 = load i32*, i32** %1
store i32 123456789, i32* %6
%7 = load i32*, i32** %1
%8 = load i32, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %1
%11 = getelementptr inbounds i32, i32* %10, i64 10
store i32 987654321, i32* %11
%12 = load i32*, i32** %1
%13 = getelementptr inbounds i32, i32* %12, i64 10
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = call i32 (...) @getpagesize()
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %1
%19 = call i32 @brk(i32* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%p\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [9 x i8] c"page:%d\0A\00"
define i32 @main() {
%1 = tail call i32* @sbrk(i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%3 = tail call i32* @sbrk(i32 4)
store i32 123456789, i32* %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 123456789)
%5 = getelementptr inbounds i32, i32* %1, i64 10
store i32 987654321, i32* %5
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 987654321)
%7 = tail call i32 (...) @getpagesize()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @brk(i32* %1)
ret i32 0
}