#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*/ abort();
int foo(int *);
int main(void) {
  int A[1111 * 1111];
  int i, res;
  for (i = 0; i < 1111 * 1111; i++)
    A[i] = 2;
  res = foo(A);
  if (res != 2468642)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b5660,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x4b5654(%rbp)
cmpl   $0x12d591,-0x4b5654(%rbp)
jge    1172 <main+0x52>
movslq -0x4b5654(%rbp),%rax
movl   $0x2,-0x4b5650(%rbp,%rax,4)
mov    -0x4b5654(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4b5654(%rbp)
jmp    113c <main+0x1c>
lea    -0x4b5650(%rbp),%rdi
call   1040 <foo@plt>
mov    %eax,-0x4b5658(%rbp)
cmpl   $0x25ab22,-0x4b5658(%rbp)
je     119b <main+0x7b>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x4b5660,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x4b5648,%rsp
mov    $0x2c,%eax
movaps 0xecd(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movaps %xmm0,-0xb0(%rsp,%rax,4)
ff
movaps %xmm0,-0xa0(%rsp,%rax,4)
ff
movaps %xmm0,-0x90(%rsp,%rax,4)
ff
movaps %xmm0,-0x80(%rsp,%rax,4)
movaps %xmm0,-0x70(%rsp,%rax,4)
movaps %xmm0,-0x60(%rsp,%rax,4)
movaps %xmm0,-0x50(%rsp,%rax,4)
movaps %xmm0,-0x40(%rsp,%rax,4)
movaps %xmm0,-0x30(%rsp,%rax,4)
movaps %xmm0,-0x20(%rsp,%rax,4)
movaps %xmm0,-0x10(%rsp,%rax,4)
movaps %xmm0,(%rsp,%rax,4)
add    $0x30,%rax
cmp    $0x12d5bc,%rax
jne    1140 <main+0x20>
movl   $0x2,0x4b5640(%rsp)
mov    %rsp,%rdi
call   1040 <foo@plt>
cmp    $0x25ab22,%eax
jne    11b4 <main+0x94>
xor    %eax,%eax
add    $0x4b5648,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [1234321 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1234321
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [1234321 x i32], [1234321 x i32]* %2, i64 0, i64 %10
store i32 2, i32* %11
br label %12
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
%16 = getelementptr inbounds [1234321 x i32], [1234321 x i32]* %2, i64 0, i64 0
%17 = call i32 @foo(i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 2468642
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %15
ret i32 0
}

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