#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*/ clear_zero_rows_cols(size_t, size_t, int **);
int /*<<< orphan*/ print_matrix(size_t, size_t, int **);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
int main(void) {
  printf("Enter M, N, and MxN elements. Cells with 0 will clear the entire row "
         "and rol\n");
  size_t M, N;
  while (scanf("%zu%zu", &M, &N) == 2) {
    int matrix[M][N];
    size_t i;
    for (i = 0; i < M; i++) {
      size_t j;
      for (j = 0; j < N; j++) {
        scanf("%d", &matrix[i][j]);
      }
    }
    printf("Received:\n");
    print_matrix(M, N, matrix);
    printf("Cleared:\n");
    clear_zero_rows_cols(M, N, matrix);
    print_matrix(M, N, matrix);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    128c <main+0x14c>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
imul   %rax,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1235 <main+0xf5>
movq   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    121f <main+0xdf>
mov    -0x48(%rbp),%rsi
mov    -0x50(%rbp),%rax
imul   -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x40(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11d3 <main+0x93>
jmp    1224 <main+0xe4>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11bd <main+0x7d>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <print_matrix@plt>
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <clear_zero_rows_cols@plt>
mov    -0x48(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <print_matrix@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    115b <main+0x1b>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1294 <main+0x154>
lea    0xe84(%rip),%r14
jmp    11ff <main+0xbf>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xec0(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rbx
mov    %rbx,%rdx
call   1060 <print_matrix@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rbx,%rdx
call   1040 <clear_zero_rows_cols@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %rbx,%rdx
call   1060 <print_matrix@plt>
mov    -0x50(%rbp),%rsp
lea    0xe19(%rip),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x30(%rbp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1294 <main+0x154>
mov    %rsp,-0x50(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,-0x48(%rbp)
imul   %rcx,%rax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    -0x38(%rbp),%rax
test   %rax,%rax
je     1190 <main+0x50>
mov    -0x30(%rbp),%rcx
shlq   $0x2,-0x48(%rbp)
mov    -0x40(%rbp),%r15
xor    %r13d,%r13d
jmp    1263 <main+0x123>
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
add    $0x1,%r13
add    -0x48(%rbp),%r15
cmp    %rax,%r13
jae    1190 <main+0x50>
test   %rcx,%rcx
je     1250 <main+0x110>
mov    %r15,%r12
xor    %ebx,%ebx
nopl   (%rax)
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
mov    -0x30(%rbp),%rcx
add    $0x4,%r12
cmp    %rcx,%rbx
jb     1270 <main+0x130>
mov    -0x38(%rbp),%rax
jmp    1252 <main+0x112>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [78 x i8] c"Enter M, N, and MxN elements. Cells with 0 will clear the entire row and rol\0A\00"
@.str.1 = [7 x i8] c"%zu%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [11 x i8] c"Received:\0A\00"
@.str.4 = [10 x i8] c"Cleared:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %42, %0
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %58
13: ; preds = %10
%14 = load i64, i64* %2
%15 = load i64, i64* %3
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %4
%17 = mul nuw i64 %14, %15
%18 = alloca i32, i64 %17
store i64 %14, i64* %5
store i64 %15, i64* %6
store i64 0, i64* %7
br label %19
19: ; preds = %39, %13
%20 = load i64, i64* %7
%21 = load i64, i64* %2
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %42
23: ; preds = %19
store i64 0, i64* %8
br label %24
24: ; preds = %35, %23
%25 = load i64, i64* %8
%26 = load i64, i64* %3
%27 = icmp ult i64 %25, %26
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = load i64, i64* %7
%30 = mul nsw i64 %29, %15
%31 = getelementptr inbounds i32, i32* %18, i64 %30
%32 = load i64, i64* %8
%33 = getelementptr inbounds i32, i32* %31, i64 %32
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %33)
br label %35
35: ; preds = %28
%36 = load i64, i64* %8
%37 = add i64 %36, 1
store i64 %37, i64* %8
br label %24
38: ; preds = %24
br label %39
39: ; preds = %38
%40 = load i64, i64* %7
%41 = add i64 %40, 1
store i64 %41, i64* %7
br label %19
42: ; preds = %19
%43 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%44 = load i64, i64* %2
%45 = load i64, i64* %3
%46 = bitcast i32* %18 to i32**
%47 = call i32 @print_matrix(i64 %44, i64 %45, i32** %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%49 = load i64, i64* %2
%50 = load i64, i64* %3
%51 = bitcast i32* %18 to i32**
%52 = call i32 @clear_zero_rows_cols(i64 %49, i64 %50, i32** %51)
%53 = load i64, i64* %2
%54 = load i64, i64* %3
%55 = bitcast i32* %18 to i32**
%56 = call i32 @print_matrix(i64 %53, i64 %54, i32** %55)
%57 = load i8*, i8** %4
br label %10
58: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%zu%zu\00"
@.str.2 = [3 x i8] c"%d\00"
@str = [77 x i8] c"Enter M, N, and MxN elements. Cells with 0 will clear the entire row and rol\00"
@str.5 = [10 x i8] c"Received:\00"
@str.6 = [9 x i8] c"Cleared:\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %2)
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %55
8: ; preds = %0, %40
%9 = load i64, i64* %1
%10 = load i64, i64* %2
%11 = call i8* @llvm.stacksave()
%12 = mul nuw i64 %10, %9
%13 = alloca i32, i64 %12
%14 = load i64, i64* %1
%15 = icmp eq i64 %14, 0
br i1 %15, label %40, label %16
16: ; preds = %8
%17 = load i64, i64* %2
br label %18
18: ; preds = %16, %35
%19 = phi i64 [ %36, %35 ], [ %14, %16 ]
%20 = phi i64 [ %37, %35 ], [ %17, %16 ]
%21 = phi i64 [ %38, %35 ], [ 0, %16 ]
%22 = icmp eq i64 %20, 0
br i1 %22, label %35, label %23
23: ; preds = %18
%24 = mul nsw i64 %21, %10
%25 = getelementptr inbounds i32, i32* %13, i64 %24
br label %26
26: ; preds = %23, %26
%27 = phi i64 [ 0, %23 ], [ %30, %26 ]
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %28)
%30 = add nuw i64 %27, 1
%31 = load i64, i64* %2
%32 = icmp ult i64 %30, %31
br i1 %32, label %26, label %33
33: ; preds = %26
%34 = load i64, i64* %1
br label %35
35: ; preds = %33, %18
%36 = phi i64 [ %34, %33 ], [ %19, %18 ]
%37 = phi i64 [ %31, %33 ], [ 0, %18 ]
%38 = add nuw i64 %21, 1
%39 = icmp ult i64 %38, %36
br i1 %39, label %18, label %40
40: ; preds = %35, %8
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
%42 = load i64, i64* %1
%43 = load i64, i64* %2
%44 = bitcast i32* %13 to i32**
%45 = call i32 @print_matrix(i64 %42, i64 %43, i32** %44)
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
%47 = load i64, i64* %1
%48 = load i64, i64* %2
%49 = call i32 @clear_zero_rows_cols(i64 %47, i64 %48, i32** %44)
%50 = load i64, i64* %1
%51 = load i64, i64* %2
%52 = call i32 @print_matrix(i64 %50, i64 %51, i32** %44)
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %2)
%54 = icmp eq i32 %53, 2
br i1 %54, label %8, label %55
55: ; preds = %40, %0
ret i32 0
}