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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3d0914(%rbp)
cmpl   $0xf4240,-0x3d0914(%rbp)
jge    116d <main+0x5d>
mov    -0x3d0914(%rbp),%ecx
mov    $0x2,%eax
shl    %cl,%eax
mov    %eax,%ecx
movslq -0x3d0914(%rbp),%rax
mov    %ecx,-0x3d0910(%rbp,%rax,4)
mov    -0x3d0914(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d0914(%rbp)
jmp    112c <main+0x1c>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x3d0910(%rbp),%edx
lea    0xe7d(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x3d0908,%rsp
xor    %eax,%eax
nopl   0x0(%rax)
mov    $0x2,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    %edx,(%rsp,%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(%rsp,%rax,4)
mov    %esi,0x8(%rsp,%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(%rsp,%rax,4)
mov    %esi,0x10(%rsp,%rax,4)
add    $0x5,%rax
cmp    $0xf4240,%rax
jne    1120 <main+0x10>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%edx
lea    0xe7d(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
add    $0x3d0908,%rsp
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 [1000000 x i32]
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 1000000
br i1 %6, label %7, label %16
7: ; preds = %4
%8 = load i32, i32* %3
%9 = shl i32 2, %8
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 %11
store i32 %9, i32* %12
br label %13
13: ; preds = %7
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %4
16: ; preds = %4
%17 = load i32, i32* @stdout
%18 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %2, i64 0, i64 0
%19 = load i32, i32* %18
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @EXIT_SUCCESS
ret i32 %21
}

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 = alloca [1000000 x i32]
%2 = bitcast [1000000 x i32]* %1 to i8*
br label %9
3: ; preds = %9
%4 = load i32, i32* @stdout
%5 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 0
%6 = load i32, i32* %5
%7 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @EXIT_SUCCESS
ret i32 %8
9: ; preds = %9, %0
%10 = phi i64 [ 0, %0 ], [ %30, %9 ]
%11 = trunc i64 %10 to i32
%12 = shl i32 2, %11
%13 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %10
store i32 %12, i32* %13
%14 = add nuw nsw i64 %10, 1
%15 = trunc i64 %14 to i32
%16 = shl i32 2, %15
%17 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %14
store i32 %16, i32* %17
%18 = add nuw nsw i64 %10, 2
%19 = trunc i64 %18 to i32
%20 = shl i32 2, %19
%21 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %18
store i32 %20, i32* %21
%22 = add nuw nsw i64 %10, 3
%23 = trunc i64 %22 to i32
%24 = shl i32 2, %23
%25 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %22
store i32 %24, i32* %25
%26 = add nuw nsw i64 %10, 4
%27 = trunc i64 %26 to i32
%28 = shl i32 2, %27
%29 = getelementptr inbounds [1000000 x i32], [1000000 x i32]* %1, i64 0, i64 %26
store i32 %28, i32* %29
%30 = add nuw nsw i64 %10, 5
%31 = icmp eq i64 %30, 1000000
br i1 %31, label %3, label %9
}