#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 EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ stdout;
int main() {
  int *array = malloc(1000000 * sizeof(int));
  for (int i = 0; i < 1000000; i++)
    array[i] = 2 << i;
  fprintf(stdout, "array[0] = %d\n", array[0]);
  free(array);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xf4240,-0x14(%rbp)
jge    1184 <main+0x54>
mov    -0x14(%rbp),%ecx
mov    $0x2,%edx
shl    %cl,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x3d0900,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
mov    $0x2,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    %edx,(%rbx,%rax,4)
lea    0x1(%rax),%ecx
mov    $0x2,%edx
shl    %cl,%edx
lea    0x2(%rax),%ecx
mov    $0x2,%esi
shl    %cl,%esi
mov    %edx,0x4(%rbx,%rax,4)
mov    %esi,0x8(%rbx,%rax,4)
lea    0x3(%rax),%ecx
mov    $0x2,%edx
shl    %cl,%edx
lea    0x4(%rax),%ecx
mov    $0x2,%esi
shl    %cl,%esi
mov    %edx,0xc(%rbx,%rax,4)
mov    %esi,0x10(%rbx,%rax,4)
add    $0x5,%rax
cmp    $0xf4240,%rax
jne    1140 <main+0x10>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%edx
lea    0xe5e(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [15 x i8] c"array[0] = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32* @malloc(i32 4000000)
store i32* %4, i32** %2
store i32 0, i32* %3
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1000000
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = load i32, i32* %3
%10 = shl i32 2, %9
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32 %10, i32* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
%19 = load i32, i32* @stdout
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %2
%25 = call i32 @free(i32* %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [15 x i8] c"array[0] = %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32* @malloc(i32 4000000)
br label %8
2: ; preds = %8
%3 = load i32, i32* @stdout
%4 = load i32, i32* %1
%5 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @free(i32* %1)
%7 = load i32, i32* @EXIT_SUCCESS
ret i32 %7
8: ; preds = %8, %0
%9 = phi i64 [ 0, %0 ], [ %29, %8 ]
%10 = trunc i64 %9 to i32
%11 = shl i32 2, %10
%12 = getelementptr inbounds i32, i32* %1, i64 %9
store i32 %11, i32* %12
%13 = add nuw nsw i64 %9, 1
%14 = trunc i64 %13 to i32
%15 = shl i32 2, %14
%16 = getelementptr inbounds i32, i32* %1, i64 %13
store i32 %15, i32* %16
%17 = add nuw nsw i64 %9, 2
%18 = trunc i64 %17 to i32
%19 = shl i32 2, %18
%20 = getelementptr inbounds i32, i32* %1, i64 %17
store i32 %19, i32* %20
%21 = add nuw nsw i64 %9, 3
%22 = trunc i64 %21 to i32
%23 = shl i32 2, %22
%24 = getelementptr inbounds i32, i32* %1, i64 %21
store i32 %23, i32* %24
%25 = add nuw nsw i64 %9, 4
%26 = trunc i64 %25 to i32
%27 = shl i32 2, %26
%28 = getelementptr inbounds i32, i32* %1, i64 %25
store i32 %27, i32* %28
%29 = add nuw nsw i64 %9, 5
%30 = icmp eq i64 %29, 1000000
br i1 %30, label %2, label %8
}