#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ sum(int, int, int **, int **, int **);
void main() {
  int M1[100][100], M2[100][100], res[100][100], r, c, i, j;
  printf("Enter order of matrices:");
  scanf("%d %d", &r, &c);
  printf("ENTER elements of first matrix:");
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%d", &M1[i][j]);
    }
  }
  printf("Enter elements of second matrix:");
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%d", &M2[i][j]);
    }
  }
  sum(r, c, M1, M2, res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d4d0,%rsp
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x1d4c4(%rbp),%rsi
lea    -0x1d4c8(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1d4cc(%rbp)
mov    -0x1d4cc(%rbp),%eax
cmp    -0x1d4c4(%rbp),%eax
jge    1208 <main+0xd8>
movl   $0x0,-0x1d4d0(%rbp)
mov    -0x1d4d0(%rbp),%eax
cmp    -0x1d4c8(%rbp),%eax
jge    11ef <main+0xbf>
movslq -0x1d4cc(%rbp),%rax
lea    -0x9c40(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x1d4d0(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1d4d0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4d0(%rbp)
jmp    1195 <main+0x65>
jmp    11f4 <main+0xc4>
mov    -0x1d4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4cc(%rbp)
jmp    1179 <main+0x49>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1d4cc(%rbp)
mov    -0x1d4cc(%rbp),%eax
cmp    -0x1d4c4(%rbp),%eax
jge    12ad <main+0x17d>
movl   $0x0,-0x1d4d0(%rbp)
mov    -0x1d4d0(%rbp),%eax
cmp    -0x1d4c8(%rbp),%eax
jge    1294 <main+0x164>
movslq -0x1d4cc(%rbp),%rax
lea    -0x13880(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x1d4d0(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xda3(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1d4d0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4d0(%rbp)
jmp    123a <main+0x10a>
jmp    1299 <main+0x169>
mov    -0x1d4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1d4cc(%rbp)
jmp    121e <main+0xee>
mov    -0x1d4c4(%rbp),%edi
mov    -0x1d4c8(%rbp),%esi
lea    -0x9c40(%rbp),%rdx
lea    -0x13880(%rbp),%rcx
lea    -0x1d4c0(%rbp),%r8
call   1040 <sum@plt>
add    $0x1d4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d4d0,%rsp
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    11d5 <main+0xa5>
lea    0x9c50(%rsp),%r15
mov    0x8(%rsp),%eax
lea    0xe91(%rip),%r14
xor    %r12d,%r12d
jmp    11a3 <main+0x73>
add    $0x1,%r12
movslq %ecx,%rdx
add    $0x190,%r15
cmp    %rdx,%r12
jge    11d5 <main+0xa5>
test   %eax,%eax
jle    1190 <main+0x60>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11b0 <main+0x80>
mov    0xc(%rsp),%ecx
jmp    1190 <main+0x60>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
test   %edi,%edi
jle    1245 <main+0x115>
lea    0x10(%rsp),%r15
lea    0xe23(%rip),%r14
xor    %r12d,%r12d
jmp    1213 <main+0xe3>
xchg   %ax,%ax
add    $0x1,%r12
movslq %edi,%rax
add    $0x190,%r15
cmp    %rax,%r12
jge    1245 <main+0x115>
test   %esi,%esi
jle    1200 <main+0xd0>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     1220 <main+0xf0>
mov    0xc(%rsp),%edi
jmp    1200 <main+0xd0>
lea    0x9c50(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x13890(%rsp),%r8
call   1040 <sum@plt>
add    $0x1d4d0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter order of matrices:\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [32 x i8] c"ENTER elements of first matrix:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [33 x i8] c"Enter elements of second matrix:\00"
define void @main() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca [100 x [100 x i32]]
%3 = alloca [100 x [100 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %11
11: ; preds = %32, %0
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %35
15: ; preds = %11
store i32 0, i32* %7
br label %16
16: ; preds = %28, %15
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %22
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %23, i64 0, i64 %25
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %20
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %16
31: ; preds = %16
br label %32
32: ; preds = %31
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %11
35: ; preds = %11
%36 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %6
br label %37
37: ; preds = %58, %35
%38 = load i32, i32* %6
%39 = load i32, i32* %4
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %61
41: ; preds = %37
store i32 0, i32* %7
br label %42
42: ; preds = %54, %41
%43 = load i32, i32* %7
%44 = load i32, i32* %5
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %57
46: ; preds = %42
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %48
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100 x i32], [100 x i32]* %49, i64 0, i64 %51
%53 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %52)
br label %54
54: ; preds = %46
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %42
57: ; preds = %42
br label %58
58: ; preds = %57
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %37
61: ; preds = %37
%62 = load i32, i32* %4
%63 = load i32, i32* %5
%64 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 0
%65 = bitcast [100 x i32]* %64 to i32**
%66 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 0
%67 = bitcast [100 x i32]* %66 to i32**
%68 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %3, i64 0, i64 0
%69 = bitcast [100 x i32]* %68 to i32**
%70 = call i32 @sum(i32 %62, i32 %63, i32** %65, i32** %67, i32** %69)
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Enter order of matrices:\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [32 x i8] c"ENTER elements of first matrix:\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [33 x i8] c"Enter elements of second matrix:\00"
define void @main() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca [100 x [100 x i32]]
%3 = alloca [100 x [100 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [100 x [100 x i32]]* %1 to i8*
%7 = bitcast [100 x [100 x i32]]* %2 to i8*
%8 = bitcast [100 x [100 x i32]]* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %39
16: ; preds = %0
%17 = load i32, i32* %5
br label %18
18: ; preds = %16, %33
%19 = phi i32 [ %14, %16 ], [ %34, %33 ]
%20 = phi i32 [ %17, %16 ], [ %35, %33 ]
%21 = phi i64 [ 0, %16 ], [ %36, %33 ]
%22 = icmp sgt i32 %20, 0
br i1 %22, label %23, label %33
23: ; preds = %18, %23
%24 = phi i64 [ %27, %23 ], [ 0, %18 ]
%25 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %21, i64 %24
%26 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %25)
%27 = add nuw nsw i64 %24, 1
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = icmp slt i64 %27, %29
br i1 %30, label %23, label %31
31: ; preds = %23
%32 = load i32, i32* %4
br label %33
33: ; preds = %31, %18
%34 = phi i32 [ %32, %31 ], [ %19, %18 ]
%35 = phi i32 [ %28, %31 ], [ %20, %18 ]
%36 = add nuw nsw i64 %21, 1
%37 = sext i32 %34 to i64
%38 = icmp slt i64 %36, %37
br i1 %38, label %18, label %39
39: ; preds = %33, %0
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* %4
%42 = icmp sgt i32 %41, 0
%43 = load i32, i32* %5
br i1 %42, label %44, label %65
44: ; preds = %39, %59
%45 = phi i32 [ %60, %59 ], [ %41, %39 ]
%46 = phi i32 [ %61, %59 ], [ %43, %39 ]
%47 = phi i64 [ %62, %59 ], [ 0, %39 ]
%48 = icmp sgt i32 %46, 0
br i1 %48, label %49, label %59
49: ; preds = %44, %49
%50 = phi i64 [ %53, %49 ], [ 0, %44 ]
%51 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %47, i64 %50
%52 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %51)
%53 = add nuw nsw i64 %50, 1
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %53, %55
br i1 %56, label %49, label %57
57: ; preds = %49
%58 = load i32, i32* %4
br label %59
59: ; preds = %57, %44
%60 = phi i32 [ %58, %57 ], [ %45, %44 ]
%61 = phi i32 [ %54, %57 ], [ %46, %44 ]
%62 = add nuw nsw i64 %47, 1
%63 = sext i32 %60 to i64
%64 = icmp slt i64 %62, %63
br i1 %64, label %44, label %65
65: ; preds = %59, %39
%66 = phi i32 [ %43, %39 ], [ %61, %59 ]
%67 = phi i32 [ %41, %39 ], [ %60, %59 ]
%68 = bitcast [100 x [100 x i32]]* %1 to i32**
%69 = bitcast [100 x [100 x i32]]* %2 to i32**
%70 = bitcast [100 x [100 x i32]]* %3 to i32**
%71 = call i32 @sum(i32 %67, i32 %66, i32** %68, i32** %69, i32** %70)
ret void
}