#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*/ display(int **, int, int);
int /*<<< orphan*/ multiplication(int **, int **, int **, int, int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *, int *);
int /*<<< orphan*/ take_data(int **, int **, int, int, int, int);
int main() {
  int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k;
  printf("Enter rows and column for first matrix: ");
  scanf("%d%d", &r1, &c1);
  printf("Enter rows and column for second matrix: ");
  scanf("%d%d", &r2, &c2);
  while (c1 != r2) {
    printf("Error! column of first matrix not equal to row of second.\n");
    printf("Enter rows and column for first matrix: ");
    scanf("%d%d", &r1, &c1);
    printf("Enter rows and column for second matrix: ");
    scanf("%d%d", &r2, &c2);
  }
  take_data(a, b, r1, c1, r2, c2);
  multiplication(a, b, mult, r1, c1, r2, c2);
  display(mult, r1, c2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x4c4(%rbp),%rsi
lea    -0x4c8(%rbp),%rdx
call   1060 <scanf@plt>
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
lea    0xe8e(%rip),%rdi
lea    -0x4cc(%rbp),%rsi
lea    -0x4d0(%rbp),%rdx
call   1060 <scanf@plt>
mov    -0x4c8(%rbp),%eax
cmp    -0x4cc(%rbp),%eax
je     121d <main+0xcd>
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
lea    0xe2d(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4a(%rip),%rdi
lea    -0x4c4(%rbp),%rsi
lea    -0x4c8(%rbp),%rdx
call   1060 <scanf@plt>
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
lea    0xe24(%rip),%rdi
lea    -0x4cc(%rbp),%rsi
lea    -0x4d0(%rbp),%rdx
call   1060 <scanf@plt>
jmp    11ae <main+0x5e>
lea    -0x1a0(%rbp),%rdi
lea    -0x330(%rbp),%rsi
mov    -0x4c4(%rbp),%edx
mov    -0x4c8(%rbp),%ecx
mov    -0x4cc(%rbp),%r8d
mov    -0x4d0(%rbp),%r9d
call   1070 <take_data@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x330(%rbp),%rsi
lea    -0x4c0(%rbp),%rdx
mov    -0x4c4(%rbp),%ecx
mov    -0x4c8(%rbp),%r8d
mov    -0x4cc(%rbp),%r9d
mov    -0x4d0(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <multiplication@plt>
lea    -0x4c0(%rbp),%rdi
mov    -0x4c4(%rbp),%esi
mov    -0x4d0(%rbp),%edx
call   1030 <display@plt>
xor    %eax,%eax
add    $0x4f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4d8,%rsp
lea    0xe88(%rip),%rdi
call   1060 <printf@plt>
lea    0xea5(%rip),%rbx
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xe91(%rip),%rdi
call   1060 <printf@plt>
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <scanf@plt>
mov    0x18(%rsp),%ecx
cmp    0x14(%rsp),%ecx
je     1226 <main+0xc6>
lea    0xe64(%rip),%rbx
lea    0x1c(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0xe58(%rip),%rbp
lea    0x14(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0d(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1070 <scanf@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <scanf@plt>
mov    0x18(%rsp),%ecx
cmp    0x14(%rsp),%ecx
jne    11e0 <main+0x80>
mov    0x1c(%rsp),%edx
mov    0x10(%rsp),%r9d
lea    0x340(%rsp),%r14
lea    0x1b0(%rsp),%rbp
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %ecx,%r8d
call   1080 <take_data@plt>
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    0x10(%rsp),%eax
mov    %eax,(%rsp)
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1050 <multiplication@plt>
mov    0x1c(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
call   1040 <display@plt>
xor    %eax,%eax
add    $0x4d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter rows and column for first matrix: \00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [42 x i8] c"Enter rows and column for second matrix: \00"
@.str.3 = [59 x i8] c"Error! column of first matrix not equal to row of second.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [10 x i32]]
%3 = alloca [10 x [10 x i32]]
%4 = alloca [10 x [10 x i32]]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
%14 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
br label %16
16: ; preds = %20, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %7
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6)
%24 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8)
br label %16
26: ; preds = %16
%27 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %2, i64 0, i64 0
%28 = bitcast [10 x i32]* %27 to i32**
%29 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %3, i64 0, i64 0
%30 = bitcast [10 x i32]* %29 to i32**
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = call i32 @take_data(i32** %28, i32** %30, i32 %31, i32 %32, i32 %33, i32 %34)
%36 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %2, i64 0, i64 0
%37 = bitcast [10 x i32]* %36 to i32**
%38 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %3, i64 0, i64 0
%39 = bitcast [10 x i32]* %38 to i32**
%40 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%41 = bitcast [10 x i32]* %40 to i32**
%42 = load i32, i32* %5
%43 = load i32, i32* %6
%44 = load i32, i32* %7
%45 = load i32, i32* %8
%46 = call i32 @multiplication(i32** %37, i32** %39, i32** %41, i32 %42, i32 %43, i32 %44, i32 %45)
%47 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%48 = bitcast [10 x i32]* %47 to i32**
%49 = load i32, i32* %5
%50 = load i32, i32* %8
%51 = call i32 @display(i32** %48, i32 %49, i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"Enter rows and column for first matrix: \00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [42 x i8] c"Enter rows and column for second matrix: \00"
@str = [58 x i8] c"Error! column of first matrix not equal to row of second.\00"
define i32 @main() {
%1 = alloca [10 x [10 x i32]]
%2 = alloca [10 x [10 x i32]]
%3 = alloca [10 x [10 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast [10 x [10 x i32]]* %1 to i8*
%9 = bitcast [10 x [10 x i32]]* %2 to i8*
%10 = bitcast [10 x [10 x i32]]* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = icmp eq i32 %19, %20
br i1 %21, label %31, label %22
22: ; preds = %0, %22
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i32* %7)
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %22
31: ; preds = %22, %0
%32 = phi i32 [ %19, %0 ], [ %28, %22 ]
%33 = bitcast [10 x [10 x i32]]* %1 to i32**
%34 = bitcast [10 x [10 x i32]]* %2 to i32**
%35 = load i32, i32* %4
%36 = load i32, i32* %7
%37 = call i32 @take_data(i32** %33, i32** %34, i32 %35, i32 %32, i32 %32, i32 %36)
%38 = bitcast [10 x [10 x i32]]* %3 to i32**
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = call i32 @multiplication(i32** %33, i32** %34, i32** %38, i32 %39, i32 %40, i32 %41, i32 %42)
%44 = load i32, i32* %4
%45 = load i32, i32* %7
%46 = call i32 @display(i32** %38, i32 %44, i32 %45)
ret i32 0
}