#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 */
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fillRand(int *, size_t);
int /*<<< orphan*/ free(int *);
int *malloc(size_t);
int /*<<< orphan*/ printMat(int *, size_t, size_t);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int sscanf(char *, char *, size_t *, size_t *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  char buff[50];
  int *arr;
  size_t n, m;
  printf("Please,enter matrix dismension(ex. '3 5')\n");
  fgets(buff, (sizeof(buff) / sizeof((buff)[0])), stdin);
  while (sscanf(buff, "%zu %zu\n", &m, &n) != 2)
    ;
  arr = malloc(m * n * sizeof(int));
  srand(time(NULL));
  fillRand(arr, m * n);
  printMat(arr, m, n);
  free(arr);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe5a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1080 <fgets@plt>
lea    -0x40(%rbp),%rdi
lea    0xe5e(%rip),%rsi
lea    -0x58(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
je     11e8 <main+0x58>
jmp    11c2 <main+0x32>
mov    -0x58(%rbp),%rdi
imul   -0x50(%rbp),%rdi
shl    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rsi
imul   -0x50(%rbp),%rsi
call   1040 <fillRand@plt>
mov    -0x48(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
call   1050 <printMat@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x32,%esi
call   1080 <fgets@plt>
lea    0xe37(%rip),%r15
mov    %rsp,%r12
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
call   10b0 <sscanf@plt>
cmp    $0x2,%eax
jne    11e0 <main+0x50>
mov    (%rsp),%rdi
imul   0x8(%rsp),%rdi
shl    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    0x8(%rsp),%rsi
imul   (%rsp),%rsi
mov    %rbx,%rdi
call   1050 <fillRand@plt>
mov    (%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <printMat@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2d8c(%rip),%rax
mov    (%rax),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Please,enter matrix dismension(ex. '3 5')\0A\00"
@stdin = global i32 0
@.str.1 = [9 x i8] c"%zu %zu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 50, i32 %8)
br label %10
10: ; preds = %14, %0
%11 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %5, i64* %4)
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %10
br label %10
15: ; preds = %10
%16 = load i64, i64* %5
%17 = load i64, i64* %4
%18 = mul i64 %16, %17
%19 = mul i64 %18, 4
%20 = call i32* @malloc(i64 %19)
store i32* %20, i32** %3
%21 = call i32 @time(i32* null)
%22 = call i32 @srand(i32 %21)
%23 = load i32*, i32** %3
%24 = load i64, i64* %5
%25 = load i64, i64* %4
%26 = mul i64 %24, %25
%27 = call i32 @fillRand(i32* %23, i64 %26)
%28 = load i32*, i32** %3
%29 = load i64, i64* %5
%30 = load i64, i64* %4
%31 = call i32 @printMat(i32* %28, i64 %29, i64 %30)
%32 = load i32*, i32** %3
%33 = call i32 @free(i32* %32)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [9 x i8] c"%zu %zu\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [42 x i8] c"Please,enter matrix dismension(ex. '3 5')\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca i64
%3 = alloca i64
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%5 = bitcast i64* %2 to i8*
%6 = bitcast i64* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %4, i32 50, i32 %8)
br label %10
10: ; preds = %10, %0
%11 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %2)
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %10
13: ; preds = %10
%14 = load i64, i64* %3
%15 = load i64, i64* %2
%16 = shl i64 %14, 2
%17 = mul i64 %16, %15
%18 = call i32* @malloc(i64 %17)
%19 = call i32 @time(i32* null)
%20 = call i32 @srand(i32 %19)
%21 = load i64, i64* %3
%22 = load i64, i64* %2
%23 = mul i64 %22, %21
%24 = call i32 @fillRand(i32* %18, i64 %23)
%25 = load i64, i64* %3
%26 = load i64, i64* %2
%27 = call i32 @printMat(i32* %18, i64 %25, i64 %26)
%28 = call i32 @free(i32* %18)
%29 = load i32, i32* @EXIT_SUCCESS
ret i32 %29
}