#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 */
typedef int /*<<< orphan*/ x;

/* Variables and functions */
int /*<<< orphan*/ bfree(int *, int);
scalar_t__ my_malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int x[512];
  int *a;
  int i;
  bfree(x, sizeof(x));
  a = (int *)my_malloc(sizeof(x));
  for (i = 0; i < 512; i++)
    a[i] = i;
  for (i = 0; i < 512; i++)
    printf("%d ", a[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x810(%rbp),%rdi
mov    $0x800,%esi
call   1050 <bfree@plt>
mov    $0x800,%edi
call   1030 <my_malloc@plt>
mov    %rax,-0x818(%rbp)
movl   $0x0,-0x81c(%rbp)
cmpl   $0x200,-0x81c(%rbp)
jge    11a9 <main+0x79>
mov    -0x81c(%rbp),%edx
mov    -0x818(%rbp),%rax
movslq -0x81c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x81c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x81c(%rbp)
jmp    116e <main+0x3e>
movl   $0x0,-0x81c(%rbp)
cmpl   $0x200,-0x81c(%rbp)
jge    11f6 <main+0xc6>
mov    -0x818(%rbp),%rax
movslq -0x81c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x81c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x81c(%rbp)
jmp    11b3 <main+0x83>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsp,%rdi
mov    $0x800,%esi
call   1060 <bfree@plt>
mov    $0x800,%edi
call   1030 <my_malloc@plt>
mov    %rax,%r15
movdqa 0xe92(%rip),%xmm0
xor    %eax,%eax
movdqa 0xe97(%rip),%xmm8
movdqa 0xe9e(%rip),%xmm9
movdqa 0xea5(%rip),%xmm10
movdqa 0xead(%rip),%xmm4
movdqa 0xeb5(%rip),%xmm5
movdqa 0xebd(%rip),%xmm6
movdqa 0xec5(%rip),%xmm7
movdqa 0xecd(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqu %xmm0,(%r15,%rax,4)
movdqu %xmm2,0x10(%r15,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqu %xmm2,0x20(%r15,%rax,4)
movdqu %xmm3,0x30(%r15,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqu %xmm2,0x40(%r15,%rax,4)
movdqu %xmm3,0x50(%r15,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqu %xmm2,0x60(%r15,%rax,4)
movdqu %xmm3,0x70(%r15,%rax,4)
add    $0x20,%rax
paddd  %xmm1,%xmm0
cmp    $0x200,%rax
jne    11c0 <main+0x80>
lea    0xe43(%rip),%r14
xor    %ebx,%ebx
nop
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x200,%rbx
jne    1250 <main+0x110>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i32]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [512 x i32], [512 x i32]* %2, i64 0, i64 0
%6 = call i32 @bfree(i32* %5, i32 2048)
%7 = call i64 @my_malloc(i32 2048)
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %3
store i32 0, i32* %4
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 512
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
br label %18
18: ; preds = %12
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %9
21: ; preds = %9
store i32 0, i32* %4
br label %22
22: ; preds = %32, %21
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 512
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %22
35: ; preds = %22
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [512 x i32]
%2 = bitcast [512 x i32]* %1 to i8*
%3 = getelementptr inbounds [512 x i32], [512 x i32]* %1, i64 0, i64 0
%4 = call i32 @bfree(i32* %3, i32 2048)
%5 = call i64 @my_malloc(i32 2048)
%6 = inttoptr i64 %5 to i32*
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ 0, %0 ], [ %36, %7 ]
%9 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %37, %7 ]
%10 = add <4 x i32> %9, <i32 4, i32 4, i32 4, i32 4>
%11 = getelementptr inbounds i32, i32* %6, i64 %8
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %9, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %11, i64 4
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %14
%15 = or i64 %8, 8
%16 = add <4 x i32> %9, <i32 8, i32 8, i32 8, i32 8>
%17 = add <4 x i32> %9, <i32 12, i32 12, i32 12, i32 12>
%18 = getelementptr inbounds i32, i32* %6, i64 %15
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %18, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %21
%22 = or i64 %8, 16
%23 = add <4 x i32> %9, <i32 16, i32 16, i32 16, i32 16>
%24 = add <4 x i32> %9, <i32 20, i32 20, i32 20, i32 20>
%25 = getelementptr inbounds i32, i32* %6, i64 %22
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %23, <4 x i32>* %26
%27 = getelementptr inbounds i32, i32* %25, i64 4
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %28
%29 = or i64 %8, 24
%30 = add <4 x i32> %9, <i32 24, i32 24, i32 24, i32 24>
%31 = add <4 x i32> %9, <i32 28, i32 28, i32 28, i32 28>
%32 = getelementptr inbounds i32, i32* %6, i64 %29
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %33
%34 = getelementptr inbounds i32, i32* %32, i64 4
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> %31, <4 x i32>* %35
%36 = add nuw nsw i64 %8, 32
%37 = add <4 x i32> %9, <i32 32, i32 32, i32 32, i32 32>
%38 = icmp eq i64 %36, 512
br i1 %38, label %39, label %7
39: ; preds = %7, %39
%40 = phi i64 [ %44, %39 ], [ 0, %7 ]
%41 = getelementptr inbounds i32, i32* %6, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = add nuw nsw i64 %40, 1
%45 = icmp eq i64 %44, 512
br i1 %45, label %46, label %39
46: ; preds = %39
%47 = call i32 @putchar(i32 10)
ret i32 0
}