#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 *);
scalar_t__ malloc(int);
int main(int argc, char **argv) {
  int x = 0;
  int *elems = (int *)malloc(1000000 * sizeof(int));
  for (int i = 0; i < 1000000; i++) {
    elems[i] = i;
  }
  free(elems);
}


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)
movl   $0x0,-0x14(%rbp)
mov    $0x3d0900,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xf4240,-0x24(%rbp)
jge    117b <main+0x5b>
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1152 <main+0x32>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3d0900,%edi
call   1040 <malloc@plt>
movdqa 0xecd(%rip),%xmm0
mov    $0x24,%ecx
movdqa 0xecf(%rip),%xmm8
movdqa 0xed6(%rip),%xmm9
movdqa 0xedd(%rip),%xmm10
movdqa 0xee4(%rip),%xmm11
movdqa 0xeeb(%rip),%xmm12
movdqa 0xef3(%rip),%xmm6
movdqa 0xefb(%rip),%xmm7
movdqa 0xf03(%rip),%xmm1
movdqa 0xf0b(%rip),%xmm2
movdqa 0xf13(%rip),%xmm3
nopl   (%rax)
movdqa %xmm0,%xmm4
paddd  %xmm8,%xmm4
movdqu %xmm0,-0x90(%rax,%rcx,4)
ff ff
movdqu %xmm4,-0x80(%rax,%rcx,4)
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm10,%xmm5
movdqu %xmm4,-0x70(%rax,%rcx,4)
movdqu %xmm5,-0x60(%rax,%rcx,4)
movdqa %xmm0,%xmm4
paddd  %xmm11,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm12,%xmm5
movdqu %xmm4,-0x50(%rax,%rcx,4)
movdqu %xmm5,-0x40(%rax,%rcx,4)
movdqa %xmm0,%xmm4
paddd  %xmm6,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm7,%xmm5
movdqu %xmm4,-0x30(%rax,%rcx,4)
movdqu %xmm5,-0x20(%rax,%rcx,4)
movdqa %xmm0,%xmm4
paddd  %xmm1,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqu %xmm4,-0x10(%rax,%rcx,4)
movdqu %xmm5,(%rax,%rcx,4)
paddd  %xmm3,%xmm0
add    $0x28,%rcx
cmp    $0xf4264,%rcx
jne    1190 <main+0x70>
mov    %rax,%rdi
call   1030 <free@plt>
xor    %eax,%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*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = call i64 @malloc(i32 4000000)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %7
store i32 0, i32* %8
br label %11
11: ; preds = %20, %2
%12 = load i32, i32* %8
%13 = icmp slt i32 %12, 1000000
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %8
%16 = load i32*, i32** %7
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
store i32 %15, i32* %19
br label %20
20: ; preds = %14
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %11
23: ; preds = %11
%24 = load i32*, i32** %7
%25 = call i32 @free(i32* %24)
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 4000000)
%4 = inttoptr i64 %3 to i32*
br label %5
5: ; preds = %5, %2
%6 = phi i64 [ 0, %2 ], [ %41, %5 ]
%7 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %42, %5 ]
%8 = add <4 x i32> %7, <i32 4, i32 4, i32 4, i32 4>
%9 = getelementptr inbounds i32, i32* %4, i64 %6
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %9, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %8, <4 x i32>* %12
%13 = add nuw nsw i64 %6, 8
%14 = add <4 x i32> %7, <i32 8, i32 8, i32 8, i32 8>
%15 = add <4 x i32> %7, <i32 12, i32 12, i32 12, i32 12>
%16 = getelementptr inbounds i32, i32* %4, i64 %13
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %14, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %16, i64 4
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %19
%20 = add nuw nsw i64 %6, 16
%21 = add <4 x i32> %7, <i32 16, i32 16, i32 16, i32 16>
%22 = add <4 x i32> %7, <i32 20, i32 20, i32 20, i32 20>
%23 = getelementptr inbounds i32, i32* %4, i64 %20
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %21, <4 x i32>* %24
%25 = getelementptr inbounds i32, i32* %23, i64 4
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %26
%27 = add nuw nsw i64 %6, 24
%28 = add <4 x i32> %7, <i32 24, i32 24, i32 24, i32 24>
%29 = add <4 x i32> %7, <i32 28, i32 28, i32 28, i32 28>
%30 = getelementptr inbounds i32, i32* %4, i64 %27
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %31
%32 = getelementptr inbounds i32, i32* %30, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %33
%34 = add nuw nsw i64 %6, 32
%35 = add <4 x i32> %7, <i32 32, i32 32, i32 32, i32 32>
%36 = add <4 x i32> %7, <i32 36, i32 36, i32 36, i32 36>
%37 = getelementptr inbounds i32, i32* %4, i64 %34
%38 = bitcast i32* %37 to <4 x i32>*
store <4 x i32> %35, <4 x i32>* %38
%39 = getelementptr inbounds i32, i32* %37, i64 4
%40 = bitcast i32* %39 to <4 x i32>*
store <4 x i32> %36, <4 x i32>* %40
%41 = add nuw nsw i64 %6, 40
%42 = add <4 x i32> %7, <i32 40, i32 40, i32 40, i32 40>
%43 = icmp eq i64 %41, 1000000
br i1 %43, label %44, label %5
44: ; preds = %5
%45 = tail call i32 @free(i32* %4)
ret i32 0
}