#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ stdout;
int main(void) {
  void fillMatrix(int rows, int cols, int matrix[rows][cols]);
  void printMatrix(int rows, int cols, int matrix[rows][cols]);
  void zeroMatrix(int rows, int cols, int matrix[rows][cols]);
  int rows = 0, cols = 0;
  printf("Please enter number of rows and columns MxN: ");
  scanf("%ix%i", &rows, &cols);
  if (!rows || !cols) {
    fputs("Incorrect number of rows or cols", stdout);
    return 1;
  }
  int matrix[rows][cols];
  fillMatrix(rows, cols, matrix);
  printMatrix(rows, cols, matrix);
  zeroMatrix(rows, cols, matrix);
  printMatrix(rows, cols, matrix);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
call   1070 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11b1 <main+0x51>
cmpl   $0x0,-0xc(%rbp)
jne    11d2 <main+0x72>
mov    0x2e28(%rip),%rax
mov    (%rax),%esi
lea    0xe73(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    124f <main+0xef>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <fillMatrix@plt>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <printMatrix@plt>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <zeroMatrix@plt>
mov    -0x30(%rbp),%rdx
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <printMatrix@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1070 <scanf@plt>
mov    -0x18(%rbp),%eax
test   %rax,%rax
je     1203 <main+0xa3>
mov    -0x14(%rbp),%ecx
test   %ecx,%ecx
je     1203 <main+0xa3>
mov    %rsp,%r14
imul   %rax,%rcx
lea    0xf(,%rcx,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    %rbx,%rdx
call   1080 <fillMatrix@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    %rbx,%rdx
call   1050 <printMatrix@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    %rbx,%rdx
call   1060 <zeroMatrix@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    %rbx,%rdx
call   1050 <printMatrix@plt>
xor    %eax,%eax
mov    %r14,%rsp
jmp    121d <main+0xbd>
mov    0x2dd6(%rip),%rax
mov    (%rax),%esi
lea    0xe21(%rip),%rdi
call   1040 <fputs@plt>
mov    $0x1,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Please enter number of rows and columns MxN: \00"
@.str.1 = [6 x i8] c"%ix%i\00"
@.str.2 = [33 x i8] c"Incorrect number of rows or cols\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11, %0
%15 = load i32, i32* @stdout
%16 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %15)
store i32 1, i32* %1
br label %34
17: ; preds = %11
%18 = load i32, i32* %2
%19 = zext i32 %18 to i64
%20 = load i32, i32* %3
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %4
%23 = mul nuw i64 %19, %21
%24 = alloca i32, i64 %23
store i64 %19, i64* %5
store i64 %21, i64* %6
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = load i32, i32* %2
%32 = load i32, i32* %3
store i32 0, i32* %1
%33 = load i8*, i8** %4
br label %34
34: ; preds = %17, %14
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [46 x i8] c"Please enter number of rows and columns MxN: \00"
@.str.1 = [6 x i8] c"%ix%i\00"
@.str.2 = [33 x i8] c"Incorrect number of rows or cols\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = icmp ne i32 %7, 0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = load i32, i32* @stdout
%14 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %29
15: ; preds = %0
%16 = zext i32 %7 to i64
%17 = zext i32 %9 to i64
%18 = call i8* @llvm.stacksave()
%19 = mul nuw i64 %17, %16
%20 = alloca i32, i64 %19
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = load i32, i32* %1
%28 = load i32, i32* %2
br label %29
29: ; preds = %15, %12
%30 = phi i32 [ 0, %15 ], [ 1, %12 ]
ret i32 %30
}