#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ puts(char *);
int main(int argc, char **argv) {
  size_t i, j;
  int *mat = (int *)malloc((16 * 1024) * (16 * 1024) * sizeof(int));
  for (i = 0; i < (16 * 1024); ++i)
    for (j = 0; j < (16 * 1024); ++j)
      mat[j * (16 * 1024) + i] = 42;
  puts("TEST DONE");
  return 0;
}


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)
mov    $0x40000000,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x4000,-0x18(%rbp)
jae    11ae <main+0x8e>
movq   $0x0,-0x20(%rbp)
cmpq   $0x4000,-0x20(%rbp)
jae    1198 <main+0x78>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
shl    $0xe,%rcx
add    -0x18(%rbp),%rcx
movl   $0x2a,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1162 <main+0x42>
jmp    119d <main+0x7d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114c <main+0x2c>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x40000000,%edi
call   1040 <malloc@plt>
add    $0x30000,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movl   $0x2a,-0x30000(%rax,%rdx,1)
movl   $0x2a,-0x20000(%rax,%rdx,1)
movl   $0x2a,-0x10000(%rax,%rdx,1)
movl   $0x2a,(%rax,%rdx,1)
add    $0x40000,%rdx
cmp    $0x40000000,%rdx
jne    1150 <main+0x30>
add    $0x1,%rcx
add    $0x4,%rax
cmp    $0x4000,%rcx
jne    1140 <main+0x20>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"TEST DONE\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 @malloc(i32 1073741824)
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %8
store i64 0, i64* %6
br label %11
11: ; preds = %29, %2
%12 = load i64, i64* %6
%13 = icmp ult i64 %12, 16384
br i1 %13, label %14, label %32
14: ; preds = %11
store i64 0, i64* %7
br label %15
15: ; preds = %25, %14
%16 = load i64, i64* %7
%17 = icmp ult i64 %16, 16384
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32*, i32** %8
%20 = load i64, i64* %7
%21 = mul i64 %20, 16384
%22 = load i64, i64* %6
%23 = add i64 %21, %22
%24 = getelementptr inbounds i32, i32* %19, i64 %23
store i32 42, i32* %24
br label %25
25: ; preds = %18
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %15
28: ; preds = %15
br label %29
29: ; preds = %28
%30 = load i64, i64* %6
%31 = add i64 %30, 1
store i64 %31, i64* %6
br label %11
32: ; preds = %11
%33 = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"TEST DONE\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 1073741824)
%4 = inttoptr i64 %3 to i32*
br label %5
5: ; preds = %2, %26
%6 = phi i64 [ 0, %2 ], [ %27, %26 ]
br label %7
7: ; preds = %7, %5
%8 = phi i64 [ 0, %5 ], [ %24, %7 ]
%9 = shl nuw nsw i64 %8, 14
%10 = add nuw nsw i64 %9, %6
%11 = getelementptr inbounds i32, i32* %4, i64 %10
store i32 42, i32* %11
%12 = shl i64 %8, 14
%13 = or i64 %12, 16384
%14 = add nuw nsw i64 %13, %6
%15 = getelementptr inbounds i32, i32* %4, i64 %14
store i32 42, i32* %15
%16 = shl i64 %8, 14
%17 = or i64 %16, 32768
%18 = add nuw nsw i64 %17, %6
%19 = getelementptr inbounds i32, i32* %4, i64 %18
store i32 42, i32* %19
%20 = shl i64 %8, 14
%21 = or i64 %20, 49152
%22 = add nuw nsw i64 %21, %6
%23 = getelementptr inbounds i32, i32* %4, i64 %22
store i32 42, i32* %23
%24 = add nuw nsw i64 %8, 4
%25 = icmp eq i64 %24, 16384
br i1 %25, label %26, label %7
26: ; preds = %7
%27 = add nuw nsw i64 %6, 1
%28 = icmp eq i64 %27, 16384
br i1 %28, label %29, label %5
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret i32 0
}