#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*/ printf(char *, ...);
void printMatrix(int *m) {
  int actualVal = 0;
  for (int i = 0; i < 2000; i++) {
    for (int j = 0; j < 2000; j++) {
      actualVal = *(m + (i * 2000 + j));
      printf("%d ", actualVal);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x7d0,-0x10(%rbp)
jge    119d <printMatrix+0x8d>
movl   $0x0,-0x14(%rbp)
cmpl   $0x7d0,-0x14(%rbp)
jge    1181 <printMatrix+0x71>
mov    -0x8(%rbp),%rax
imul   $0x7d0,-0x10(%rbp),%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <printMatrix+0x2e>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <printMatrix+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xece(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x7d0,%rbx
jne    1150 <printMatrix+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
add    $0x1f40,%r12
cmp    $0x7d0,%r15
jne    1140 <printMatrix+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @printMatrix(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %29, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2000
br i1 %8, label %9, label %32
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2000
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = load i32*, i32** %2
%15 = load i32, i32* %4
%16 = mul nsw i32 %15, 2000
%17 = load i32, i32* %5
%18 = add nsw i32 %16, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %14, i64 %19
%21 = load i32, i32* %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %13
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %10
27: ; preds = %10
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %6
32: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @printMatrix(i32* nocapture %0) {
br label %2
2: ; preds = %1, %6
%3 = phi i64 [ 0, %1 ], [ %8, %6 ]
%4 = mul nuw nsw i64 %3, 2000
br label %10
5: ; preds = %6
ret void
6: ; preds = %10
%7 = tail call i32 @putchar(i32 10)
%8 = add nuw nsw i64 %3, 1
%9 = icmp eq i64 %8, 2000
br i1 %9, label %5, label %2
10: ; preds = %2, %10
%11 = phi i64 [ 0, %2 ], [ %16, %10 ]
%12 = add nuw nsw i64 %11, %4
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i64 %11, 1
%17 = icmp eq i64 %16, 2000
br i1 %17, label %6, label %10
}