#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 *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
void get2DArrayFromConsole(int n, int m, int a[n][m]) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      printf("[%d][%d] = ", i, j);
      scanf("%d", &a[i][j]);
    }
}


x86 assembly (clang, -O0):
<get2DArrayFromConsole>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c0 <get2DArrayFromConsole+0xa0>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ad <get2DArrayFromConsole+0x8d>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe72(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <get2DArrayFromConsole+0x33>
jmp    11b2 <get2DArrayFromConsole+0x92>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <get2DArrayFromConsole+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get2DArrayFromConsole>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,0xc(%rsp)
test   %edi,%edi
jle    11c7 <get2DArrayFromConsole+0xa7>
mov    0xc(%rsp),%r15d
mov    %edi,%eax
mov    %rax,0x20(%rsp)
lea    0x0(,%r15,4),%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
lea    0xe9f(%rip),%r12
lea    0xea4(%rip),%r13
jmp    1185 <get2DArrayFromConsole+0x65>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    0x18(%rsp),%rax
add    %rax,0x10(%rsp)
cmp    0x20(%rsp),%rbp
je     11c7 <get2DArrayFromConsole+0xa7>
cmpl   $0x0,0xc(%rsp)
jle    1170 <get2DArrayFromConsole+0x50>
mov    0x10(%rsp),%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%r14
add    $0x4,%rbx
cmp    %r14,%r15
jne    11a0 <get2DArrayFromConsole+0x80>
jmp    1170 <get2DArrayFromConsole+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"[%d][%d] = \00"
@.str.1 = [3 x i8] c"%d\00"
define void @get2DArrayFromConsole(i32 %0, i32 %1, i32* %2) {
%4 = zext i32 %1 to i64
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %16
%10 = phi i64 [ 0, %6 ], [ %17, %16 ]
br i1 %7, label %11, label %16
11: ; preds = %9
%12 = mul nuw nsw i64 %10, %4
%13 = getelementptr inbounds i32, i32* %2, i64 %12
%14 = trunc i64 %10 to i32
br label %19
15: ; preds = %16, %3
ret void
16: ; preds = %19, %9
%17 = add nuw nsw i64 %10, 1
%18 = icmp eq i64 %17, %8
br i1 %18, label %15, label %9
19: ; preds = %11, %19
%20 = phi i64 [ 0, %11 ], [ %25, %19 ]
%21 = trunc i64 %20 to i32
%22 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %21)
%23 = getelementptr inbounds i32, i32* %13, i64 %20
%24 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = add nuw nsw i64 %20, 1
%26 = icmp eq i64 %25, %4
br i1 %26, label %16, label %19
}