#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*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ shared_memory_release(int *);
int *shared_memory_reserve(size_t, int);
int main(int argc, const char *argv[]) {
  size_t array_size = 11;
  int *array = shared_memory_reserve(array_size, sizeof(int));
  for (size_t i = 0; i < array_size; ++i) {
    array[i] = (int)(i * i);
  }
  for (size_t i = 0; i < array_size; ++i) {
    printf("%i ", array[i]);
  }
  puts("");
  shared_memory_release(array);
  return 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)
movq   $0xb,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1060 <shared_memory_reserve@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ad <main+0x6d>
mov    -0x28(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1178 <main+0x38>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11eb <main+0xab>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe2b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11b5 <main+0x75>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    -0x20(%rbp),%rdi
call   1040 <shared_memory_release@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0xb,%edi
mov    $0x4,%esi
call   1060 <shared_memory_reserve@plt>
mov    %rax,%rbx
movaps 0xea3(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xea9(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x5100000040,%rax
mov    %rax,0x20(%rbx)
movl   $0x64,0x28(%rbx)
lea    0xe99(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    0x28(%rbx),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1040 <shared_memory_release@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%i \00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 11, i64* %6
%10 = load i64, i64* %6
%11 = call i32* @shared_memory_reserve(i64 %10, i32 4)
store i32* %11, i32** %7
store i64 0, i64* %8
br label %12
12: ; preds = %24, %2
%13 = load i64, i64* %8
%14 = load i64, i64* %6
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i64, i64* %8
%18 = load i64, i64* %8
%19 = mul i64 %17, %18
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %7
%22 = load i64, i64* %8
%23 = getelementptr inbounds i32, i32* %21, i64 %22
store i32 %20, i32* %23
br label %24
24: ; preds = %16
%25 = load i64, i64* %8
%26 = add i64 %25, 1
store i64 %26, i64* %8
br label %12
27: ; preds = %12
store i64 0, i64* %9
br label %28
28: ; preds = %38, %27
%29 = load i64, i64* %9
%30 = load i64, i64* %6
%31 = icmp ult i64 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = load i32*, i32** %7
%34 = load i64, i64* %9
%35 = getelementptr inbounds i32, i32* %33, i64 %34
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %32
%39 = load i64, i64* %9
%40 = add i64 %39, 1
store i64 %40, i64* %9
br label %28
41: ; preds = %28
%42 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%43 = load i32*, i32** %7
%44 = call i32 @shared_memory_release(i32* %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%i \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @shared_memory_reserve(i64 11, i32 4)
%4 = getelementptr inbounds i32, i32* %3, i64 1
%5 = getelementptr inbounds i32, i32* %3, i64 2
%6 = getelementptr inbounds i32, i32* %3, i64 3
%7 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 4, i32 9>, <4 x i32>* %7
%8 = getelementptr inbounds i32, i32* %3, i64 4
%9 = getelementptr inbounds i32, i32* %3, i64 5
%10 = getelementptr inbounds i32, i32* %3, i64 6
%11 = getelementptr inbounds i32, i32* %3, i64 7
%12 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 16, i32 25, i32 36, i32 49>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %3, i64 8
store i32 64, i32* %13
%14 = getelementptr inbounds i32, i32* %3, i64 9
store i32 81, i32* %14
%15 = getelementptr inbounds i32, i32* %3, i64 10
store i32 100, i32* %15
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 0)
%17 = load i32, i32* %4
%18 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %5
%20 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %6
%22 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %8
%24 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %9
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %10
%28 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %11
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %13
%32 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %14
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %15
%36 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = tail call i32 @putchar(i32 10)
%38 = tail call i32 @shared_memory_release(i32* %3)
ret i32 0
}