int main() {
  static int x[5000][5000];
  for (int j = 0; j < 5000; j++) {
    for (int i = 0; i < 5000; i++) {
      x[j][i]++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1388,-0x8(%rbp)
jge    1176 <main+0x76>
movl   $0x0,-0xc(%rbp)
cmpl   $0x1388,-0xc(%rbp)
jge    1163 <main+0x63>
movslq -0x8(%rbp),%rcx
lea    0x2ef2(%rip),%rax
imul   $0x4e20,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1126 <main+0x26>
jmp    1168 <main+0x68>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1112 <main+0x12>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
lea    0x2f29(%rip),%rax
xor    %ecx,%ecx
pcmpeqd %xmm0,%xmm0
jmp    1123 <main+0x23>
nop
add    $0x1,%rcx
add    $0x4e20,%rax
cmp    $0x1388,%rcx
je     117d <main+0x7d>
mov    $0xc,%edx
nopl   0x0(%rax,%rax,1)
movdqa -0x30(%rax,%rdx,4),%xmm1
movdqa -0x20(%rax,%rdx,4),%xmm2
psubd  %xmm0,%xmm1
psubd  %xmm0,%xmm2
movdqa %xmm1,-0x30(%rax,%rdx,4)
movdqa %xmm2,-0x20(%rax,%rdx,4)
cmp    $0x138c,%rdx
je     1110 <main+0x10>
movdqa -0x10(%rax,%rdx,4),%xmm1
movdqa (%rax,%rdx,4),%xmm2
psubd  %xmm0,%xmm1
psubd  %xmm0,%xmm2
movdqa %xmm1,-0x10(%rax,%rdx,4)
movdqa %xmm2,(%rax,%rdx,4)
add    $0x10,%rdx
jmp    1130 <main+0x30>
xor    %eax,%eax
ret

LLVM IR (-O0):
@main.x = internal global [5000 x [5000 x i32]] zeroinitializer
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %24, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 5000
br i1 %6, label %7, label %27
7: ; preds = %4
store i32 0, i32* %3
br label %8
8: ; preds = %20, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5000
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5000 x [5000 x i32]], [5000 x [5000 x i32]]* @main.x, i64 0, i64 %13
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [5000 x i32], [5000 x i32]* %14, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1
store i32 %19, i32* %17
br label %20
20: ; preds = %11
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %8
23: ; preds = %8
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %4
27: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@main.x = internal unnamed_addr global [5000 x [5000 x i32]] zeroinitializer
define i32 @main() {
br label %1
1: ; preds = %30, %0
%2 = phi i64 [ 0, %0 ], [ %31, %30 ]
br label %3
3: ; preds = %17, %1
%4 = phi i64 [ 0, %1 ], [ %28, %17 ]
%5 = getelementptr inbounds [5000 x [5000 x i32]], [5000 x [5000 x i32]]* @main.x, i64 0, i64 %2, i64 %4
%6 = bitcast i32* %5 to <4 x i32>*
%7 = load <4 x i32>, <4 x i32>* %6
%8 = getelementptr inbounds i32, i32* %5, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
%10 = load <4 x i32>, <4 x i32>* %9
%11 = add nsw <4 x i32> %7, <i32 1, i32 1, i32 1, i32 1>
%12 = add nsw <4 x i32> %10, <i32 1, i32 1, i32 1, i32 1>
%13 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> %11, <4 x i32>* %13
%14 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %14
%15 = or i64 %4, 8
%16 = icmp eq i64 %15, 5000
br i1 %16, label %30, label %17
17: ; preds = %3
%18 = getelementptr inbounds [5000 x [5000 x i32]], [5000 x [5000 x i32]]* @main.x, i64 0, i64 %2, i64 %15
%19 = bitcast i32* %18 to <4 x i32>*
%20 = load <4 x i32>, <4 x i32>* %19
%21 = getelementptr inbounds i32, i32* %18, i64 4
%22 = bitcast i32* %21 to <4 x i32>*
%23 = load <4 x i32>, <4 x i32>* %22
%24 = add nsw <4 x i32> %20, <i32 1, i32 1, i32 1, i32 1>
%25 = add nsw <4 x i32> %23, <i32 1, i32 1, i32 1, i32 1>
%26 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %26
%27 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %27
%28 = add nuw nsw i64 %4, 16
br label %3
29: ; preds = %30
ret i32 0
30: ; preds = %3
%31 = add nuw nsw i64 %2, 1
%32 = icmp eq i64 %31, 5000
br i1 %32, label %29, label %1
}