#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*/ scanf(char *, int *);
int *getMatrix(int c, int r) {
  int *data;
  data = (int *)malloc(4 * c * r);
  for (int i = 0; i < c; ++i) {
    for (int j = 0; j < r; ++j) {
      scanf("%d", data + i * r + j);
    }
  }
  return data;
}


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
shl    $0x2,%edi
imul   -0x8(%rbp),%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b3 <getMatrix+0x93>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a0 <getMatrix+0x80>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
imul   -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe73(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <getMatrix+0x3b>
jmp    11a5 <getMatrix+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <getMatrix+0x28>
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
sub    $0x28,%rsp
mov    %edi,%ebx
mov    %esi,0xc(%rsp)
imul   %esi,%edi
shl    $0x2,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %ebx,%ebx
jle    11b7 <getMatrix+0x97>
movslq 0xc(%rsp),%r12
mov    %ebx,%eax
mov    %rax,0x20(%rsp)
mov    %r12d,%eax
mov    %rax,0x18(%rsp)
shl    $0x2,%r12
xor    %r15d,%r15d
lea    0xe96(%rip),%rbx
mov    0x10(%rsp),%r13
jmp    118e <getMatrix+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
add    %r12,%r13
cmp    0x20(%rsp),%r15
je     11b7 <getMatrix+0x97>
mov    0x18(%rsp),%r14
mov    %r13,%rbp
cmpl   $0x0,0xc(%rsp)
jle    1180 <getMatrix+0x60>
nopl   (%rax)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <scanf@plt>
add    $0x4,%rbp
add    $0xffffffffffffffff,%r14
jne    11a0 <getMatrix+0x80>
jmp    1180 <getMatrix+0x60>
mov    0x10(%rsp),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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