#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 **allocateMatrix(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int **getMatrix(int n, int m) {
  int **M = allocateMatrix(n, m);
  for (int i = 0; i < n; i++) {
    printf("Input row %d elements, separated by spaces: ", i);
    for (int j = 0; j < m; j++) {
      scanf("%d", &M[i][j]);
    }
  }
  return M;
}


x86 assembly (clang, -O0):
<getMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <allocateMatrix@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c6 <getMatrix+0x96>
mov    -0x14(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b3 <getMatrix+0x83>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe8d(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1176 <getMatrix+0x46>
jmp    11b8 <getMatrix+0x88>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <getMatrix+0x24>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
mov    %esi,0x4(%rsp)
call   1040 <allocateMatrix@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    11ba <getMatrix+0x8a>
mov    %ebp,%r13d
mov    0x4(%rsp),%r15d
shl    $0x2,%r15
xor    %ebp,%ebp
lea    0xecb(%rip),%r12
jmp    1179 <getMatrix+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
cmp    %r13,%rbp
je     11ba <getMatrix+0x8a>
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    1170 <getMatrix+0x40>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rsi
add    %r14,%rsi
mov    %r12,%rdi
call   1050 <scanf@plt>
add    $0x4,%r14
cmp    %r14,%r15
jne    11a0 <getMatrix+0x70>
jmp    1170 <getMatrix+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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