#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*/ free(int *);
int *malloc(int);
int main(int argc, char **argv) {
  int i;
  int *a = malloc(sizeof(int) * 10);
  if (!a)
    return -1;
  for (i = 0; i < 11; i++) {
    a[i] = i;
  }
  free(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115b <main+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1198 <main+0x78>
movl   $0x0,-0x14(%rbp)
cmpl   $0xb,-0x14(%rbp)
jge    1188 <main+0x68>
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1162 <main+0x42>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x28,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1166 <main+0x46>
movaps 0xec9(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xecf(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x900000008,%rcx
mov    %rcx,0x20(%rax)
movl   $0xa,0x28(%rax)
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32* @malloc(i32 40)
store i32* %8, i32** %7
%9 = load i32*, i32** %7
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 -1, i32* %3
br label %28
12: ; preds = %2
store i32 0, i32* %6
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 11
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i32*, i32** %7
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %13
25: ; preds = %13
%26 = load i32*, i32** %7
%27 = call i32 @free(i32* %26)
store i32 0, i32* %3
br label %28
28: ; preds = %25, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 40)
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %2
%6 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %3, i64 4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %3, i64 8
store i32 8, i32* %9
%10 = getelementptr inbounds i32, i32* %3, i64 9
store i32 9, i32* %10
%11 = getelementptr inbounds i32, i32* %3, i64 10
store i32 10, i32* %11
%12 = tail call i32 @free(i32* %3)
br label %13
13: ; preds = %2, %5
%14 = phi i32 [ 0, %5 ], [ -1, %2 ]
ret i32 %14
}