#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 **createMatrix(int, int);
int /*<<< orphan*/ delMatrix(int **, int);
int /*<<< orphan*/ displayMatrix(int **, int, int);
int /*<<< orphan*/ inputMatrix(int **, int, int);
scalar_t__ isDiagonal(int **, int);
scalar_t__ isIdentity(int **, int);
scalar_t__ isLowerTriangular(int **, int);
scalar_t__ isTriDiagonal(int **, int);
scalar_t__ isUpperTriangular(int **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int **mat, size;
  printf("Please enter the order for a 2D square matrix.\n");
  scanf("%d", &size);
  mat = createMatrix(size, size);
  printf("Please enter the elements for the matrix.\n");
  inputMatrix(mat, size, size);
  printf("The matrix you have entered is:\n\n");
  displayMatrix(mat, size, size);
  printf("\n\n");
  if (isUpperTriangular(mat, size))
    printf("The matrix is an Upper Triangular matrix.\n");
  else
    printf("The matrix is not an Upper Triangular matrix.\n");
  if (isLowerTriangular(mat, size))
    printf("The matrix is a Lower Triangular matrix.\n");
  else
    printf("The matrix is not a Lower Triangular matrix.\n");
  if (isIdentity(mat, size))
    printf("The matrix is an Identity matrix.\n");
  else
    printf("The matrix is not an Identity matrix.\n");
  if (isDiagonal(mat, size))
    printf("The matrix is a Diagonal matrix.\n");
  else
    printf("The matrix is not a Diagonal matrix.\n");
  if (isTriDiagonal(mat, size))
    printf("The matrix is a Tridiagonal matrix.\n");
  else
    printf("The matrix is not a Tridiagonal matrix.\n");
  printf("\n\n");
  delMatrix(mat, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe3a(%rip),%rdi
call   1070 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10b0 <createMatrix@plt>
mov    %rax,-0x10(%rbp)
lea    0xe42(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <inputMatrix@plt>
lea    0xe52(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
call   10d0 <displayMatrix@plt>
lea    0xe56(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <isUpperTriangular@plt>
cmp    $0x0,%rax
je     1253 <main+0xa3>
lea    0xe37(%rip),%rdi
call   1070 <printf@plt>
jmp    125f <main+0xaf>
lea    0xe51(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <isLowerTriangular@plt>
cmp    $0x0,%rax
je     1286 <main+0xd6>
lea    0xe5e(%rip),%rdi
call   1070 <printf@plt>
jmp    1292 <main+0xe2>
lea    0xe77(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <isIdentity@plt>
cmp    $0x0,%rax
je     12b9 <main+0x109>
lea    0xe83(%rip),%rdi
call   1070 <printf@plt>
jmp    12c5 <main+0x115>
lea    0xe95(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1080 <isDiagonal@plt>
cmp    $0x0,%rax
je     12ec <main+0x13c>
lea    0xe9a(%rip),%rdi
call   1070 <printf@plt>
jmp    12f8 <main+0x148>
lea    0xeab(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <isTriDiagonal@plt>
cmp    $0x0,%rax
je     131f <main+0x16f>
lea    0xeaf(%rip),%rdi
call   1070 <printf@plt>
jmp    132b <main+0x17b>
lea    0xec3(%rip),%rdi
call   1070 <printf@plt>
lea    0xd4b(%rip),%rdi
call   1070 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <delMatrix@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xe48(%rip),%rdi
call   1060 <puts@plt>
lea    0xe39(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10c0 <scanf@plt>
mov    0x4(%rsp),%edi
mov    %edi,%esi
call   10b0 <createMatrix@plt>
mov    %rax,%rbx
lea    0xe4c(%rip),%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   1040 <inputMatrix@plt>
lea    0xe5c(%rip),%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%edx
mov    %rbx,%rdi
mov    %edx,%esi
call   10d0 <displayMatrix@plt>
lea    0xe61(%rip),%r14
mov    %r14,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1090 <isUpperTriangular@plt>
test   %rax,%rax
lea    0xe45(%rip),%rax
lea    0xf9c(%rip),%rdi
cmove  %rax,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <isLowerTriangular@plt>
test   %rax,%rax
lea    0xe4d(%rip),%rax
lea    0xf4d(%rip),%rdi
cmove  %rax,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1030 <isIdentity@plt>
test   %rax,%rax
lea    0xe54(%rip),%rax
lea    0xf05(%rip),%rdi
cmove  %rax,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1080 <isDiagonal@plt>
test   %rax,%rax
lea    0xe54(%rip),%rax
lea    0xebe(%rip),%rdi
cmove  %rax,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1070 <isTriDiagonal@plt>
test   %rax,%rax
lea    0xe53(%rip),%rax
lea    0xe74(%rip),%rdi
cmove  %rax,%rdi
call   1060 <puts@plt>
mov    %r14,%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   10a0 <delMatrix@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Please enter the order for a 2D square matrix.\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [43 x i8] c"Please enter the elements for the matrix.\0A\00"
@.str.3 = [34 x i8] c"The matrix you have entered is:\0A\0A\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
@.str.5 = [43 x i8] c"The matrix is an Upper Triangular matrix.\0A\00"
@.str.6 = [47 x i8] c"The matrix is not an Upper Triangular matrix.\0A\00"
@.str.7 = [42 x i8] c"The matrix is a Lower Triangular matrix.\0A\00"
@.str.8 = [46 x i8] c"The matrix is not a Lower Triangular matrix.\0A\00"
@.str.9 = [35 x i8] c"The matrix is an Identity matrix.\0A\00"
@.str.10 = [39 x i8] c"The matrix is not an Identity matrix.\0A\00"
@.str.11 = [34 x i8] c"The matrix is a Diagonal matrix.\0A\00"
@.str.12 = [38 x i8] c"The matrix is not a Diagonal matrix.\0A\00"
@.str.13 = [37 x i8] c"The matrix is a Tridiagonal matrix.\0A\00"
@.str.14 = [41 x i8] c"The matrix is not a Tridiagonal matrix.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = load i32, i32* %3
%8 = call i32** @createMatrix(i32 %6, i32 %7)
store i32** %8, i32*** %2
%9 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32**, i32*** %2
%11 = load i32, i32* %3
%12 = load i32, i32* %3
%13 = call i32 @inputMatrix(i32** %10, i32 %11, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%15 = load i32**, i32*** %2
%16 = load i32, i32* %3
%17 = load i32, i32* %3
%18 = call i32 @displayMatrix(i32** %15, i32 %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%20 = load i32**, i32*** %2
%21 = load i32, i32* %3
%22 = call i64 @isUpperTriangular(i32** %20, i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %0
%25 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %28
26: ; preds = %0
%27 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
%29 = load i32**, i32*** %2
%30 = load i32, i32* %3
%31 = call i64 @isLowerTriangular(i32** %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %37
35: ; preds = %28
%36 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
%38 = load i32**, i32*** %2
%39 = load i32, i32* %3
%40 = call i64 @isIdentity(i32** %38, i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %46
44: ; preds = %37
%45 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
%47 = load i32**, i32*** %2
%48 = load i32, i32* %3
%49 = call i64 @isDiagonal(i32** %47, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %46
%52 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
br label %55
53: ; preds = %46
%54 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.12, i64 0, i64 0))
br label %55
55: ; preds = %53, %51
%56 = load i32**, i32*** %2
%57 = load i32, i32* %3
%58 = call i64 @isTriDiagonal(i32** %56, i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
br label %64
62: ; preds = %55
%63 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0))
br label %64
64: ; preds = %62, %60
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32**, i32*** %2
%67 = load i32, i32* %3
%68 = call i32 @delMatrix(i32** %66, i32 %67)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [47 x i8] c"Please enter the order for a 2D square matrix.\00"
@str.15 = [42 x i8] c"Please enter the elements for the matrix.\00"
@str.16 = [33 x i8] c"The matrix you have entered is:\0A\00"
@str.18 = [46 x i8] c"The matrix is not an Upper Triangular matrix.\00"
@str.19 = [45 x i8] c"The matrix is not a Lower Triangular matrix.\00"
@str.20 = [38 x i8] c"The matrix is not an Identity matrix.\00"
@str.21 = [37 x i8] c"The matrix is not a Diagonal matrix.\00"
@str.22 = [40 x i8] c"The matrix is not a Tridiagonal matrix.\00"
@str.23 = [2 x i8] c"\0A\00"
@str.24 = [36 x i8] c"The matrix is a Tridiagonal matrix.\00"
@str.25 = [33 x i8] c"The matrix is a Diagonal matrix.\00"
@str.26 = [34 x i8] c"The matrix is an Identity matrix.\00"
@str.27 = [41 x i8] c"The matrix is a Lower Triangular matrix.\00"
@str.28 = [42 x i8] c"The matrix is an Upper Triangular matrix.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = call i32** @createMatrix(i32 %5, i32 %5)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.15, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = call i32 @inputMatrix(i32** %6, i32 %8, i32 %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = call i32 @displayMatrix(i32** %6, i32 %11, i32 %11)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.23, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = call i64 @isUpperTriangular(i32** %6, i32 %14)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @str.18, i64 0, i64 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @str.28, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = load i32, i32* %1
%20 = call i64 @isLowerTriangular(i32** %6, i32 %19)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @str.19, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @str.27, i64 0, i64 0)
%23 = call i32 @puts(i8* dereferenceable(1) %22)
%24 = load i32, i32* %1
%25 = call i64 @isIdentity(i32** %6, i32 %24)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @str.20, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str.26, i64 0, i64 0)
%28 = call i32 @puts(i8* dereferenceable(1) %27)
%29 = load i32, i32* %1
%30 = call i64 @isDiagonal(i32** %6, i32 %29)
%31 = icmp eq i64 %30, 0
%32 = select i1 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @str.21, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str.25, i64 0, i64 0)
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = load i32, i32* %1
%35 = call i64 @isTriDiagonal(i32** %6, i32 %34)
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @str.22, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str.24, i64 0, i64 0)
%38 = call i32 @puts(i8* dereferenceable(1) %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.23, i64 0, i64 0))
%40 = load i32, i32* %1
%41 = call i32 @delMatrix(i32** %6, i32 %40)
ret i32 0
}