#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
int main(void) {
  int iaMat[100][100], iRow, iCol, i, j;
  printf("\nEnter the order of the matrix\n");
  scanf("%d%d", &iRow, &iCol);
  if (iRow != iCol) {
    printf("\nMatrix should be a Square Matrix\n");
    exit(0);
  }
  for (i = 0; i < iRow; i++) {
    for (j = 0; j < iCol; j++) {
      if (i < j)
        iaMat[i][j] = 1;
      else if (i == j)
        iaMat[i][j] = 0;
      else
        iaMat[i][j] = -1;
    }
  }
  printf("\nMatrix \n");
  for (i = 0; i < iRow; i++) {
    for (j = 0; j < iCol; j++) {
      printf("%2d\t", iaMat[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x9c54(%rbp),%rsi
lea    -0x9c58(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x9c54(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
je     1191 <main+0x61>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
movl   $0x0,-0x9c5c(%rbp)
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    12a0 <main+0x170>
movl   $0x0,-0x9c60(%rbp)
mov    -0x9c60(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jge    1287 <main+0x157>
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c60(%rbp),%eax
jge    1206 <main+0xd6>
movslq -0x9c5c(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9c60(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    126e <main+0x13e>
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c60(%rbp),%eax
jne    1243 <main+0x113>
movslq -0x9c5c(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9c60(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1269 <main+0x139>
movslq -0x9c5c(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9c60(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    126e <main+0x13e>
jmp    1273 <main+0x143>
mov    -0x9c60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c60(%rbp)
jmp    11b7 <main+0x87>
jmp    128c <main+0x15c>
mov    -0x9c5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c5c(%rbp)
jmp    119b <main+0x6b>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x9c5c(%rbp)
mov    -0x9c5c(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    134c <main+0x21c>
movl   $0x0,-0x9c60(%rbp)
mov    -0x9c60(%rbp),%eax
cmp    -0x9c58(%rbp),%eax
jge    132a <main+0x1fa>
movslq -0x9c5c(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x9c60(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x9c60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c60(%rbp)
jmp    12d4 <main+0x1a4>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x9c5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c5c(%rbp)
jmp    12b8 <main+0x188>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xea5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    0x8(%rsp),%eax
jne    127f <main+0x12f>
test   %eax,%eax
jle    11f9 <main+0xa9>
lea    0x10(%rsp),%rcx
xor    %edx,%edx
jmp    11b0 <main+0x60>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdx
add    $0x190,%rcx
cmp    %rax,%rdx
je     11f9 <main+0xa9>
imul   $0x190,%rdx,%rsi
add    %rsp,%rsi
add    $0x10,%rsi
lea    (%rsi,%rdx,4),%rsi
xor    %edi,%edi
jmp    11e0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
movl   $0x1,(%rcx,%rdi,4)
add    $0x1,%rdi
cmp    %rdi,%rax
je     11a0 <main+0x50>
cmp    %rdi,%rdx
jb     11d0 <main+0x80>
jne    11f0 <main+0xa0>
movl   $0x0,(%rsi)
jmp    11d7 <main+0x87>
nop
movl   $0xffffffff,(%rcx,%rdi,4)
jmp    11d7 <main+0x87>
lea    0xe29(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    126e <main+0x11e>
lea    0x10(%rsp),%r12
lea    0xded(%rip),%r14
xor    %r15d,%r15d
jmp    123f <main+0xef>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x190,%r12
cmp    %rax,%r15
jge    126e <main+0x11e>
cmpl   $0x0,0x8(%rsp)
jle    1220 <main+0xd0>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1250 <main+0x100>
jmp    1220 <main+0xd0>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdac(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"\0AEnter the order of the matrix\0A\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [35 x i8] c"\0AMatrix should be a Square Matrix\0A\00"
@.str.3 = [10 x i8] c"\0AMatrix \0A\00"
@.str.4 = [5 x i8] c"%2d\09\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [100 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %0
store i32 0, i32* %5
br label %16
16: ; preds = %60, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %63
20: ; preds = %16
store i32 0, i32* %6
br label %21
21: ; preds = %56, %20
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %59
25: ; preds = %21
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %25
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %32, i64 0, i64 %34
store i32 1, i32* %35
br label %55
36: ; preds = %25
%37 = load i32, i32* %5
%38 = load i32, i32* %6
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %42
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %43, i64 0, i64 %45
store i32 0, i32* %46
br label %54
47: ; preds = %36
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %49
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100 x i32], [100 x i32]* %50, i64 0, i64 %52
store i32 -1, i32* %53
br label %54
54: ; preds = %47, %40
br label %55
55: ; preds = %54, %29
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %21
59: ; preds = %21
br label %60
60: ; preds = %59
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %16
63: ; preds = %16
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %65
65: ; preds = %88, %63
%66 = load i32, i32* %5
%67 = load i32, i32* %3
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %91
69: ; preds = %65
store i32 0, i32* %6
br label %70
70: ; preds = %83, %69
%71 = load i32, i32* %6
%72 = load i32, i32* %4
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %86
74: ; preds = %70
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %76
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [100 x i32], [100 x i32]* %77, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %74
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %70
86: ; preds = %70
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %88
88: ; preds = %86
%89 = load i32, i32* %5
%90 = add nsw i32 %89, 1
store i32 %90, i32* %5
br label %65
91: ; preds = %65
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%d%d\00"
@.str.4 = [5 x i8] c"%2d\09\00"
@str = [31 x i8] c"\0AEnter the order of the matrix\00"
@str.6 = [9 x i8] c"\0AMatrix \00"
@str.7 = [34 x i8] c"\0AMatrix should be a Square Matrix\00"
define i32 @main() {
%1 = alloca [100 x [100 x i32]]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [100 x [100 x i32]]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = icmp sgt i32 %9, 0
br i1 %13, label %14, label %38
14: ; preds = %12
%15 = zext i32 %9 to i64
br label %19
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.7, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %35, %14
%20 = phi i64 [ 0, %14 ], [ %36, %35 ]
%21 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %20, i64 %20
br label %22
22: ; preds = %19, %32
%23 = phi i64 [ 0, %19 ], [ %33, %32 ]
%24 = icmp ult i64 %20, %23
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %20, i64 %23
store i32 1, i32* %26
br label %32
27: ; preds = %22
%28 = icmp eq i64 %20, %23
br i1 %28, label %29, label %30
29: ; preds = %27
store i32 0, i32* %21
br label %32
30: ; preds = %27
%31 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %20, i64 %23
store i32 -1, i32* %31
br label %32
32: ; preds = %25, %30, %29
%33 = add nuw nsw i64 %23, 1
%34 = icmp eq i64 %33, %15
br i1 %34, label %35, label %22
35: ; preds = %32
%36 = add nuw nsw i64 %20, 1
%37 = icmp eq i64 %36, %15
br i1 %37, label %38, label %19
38: ; preds = %35, %12
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
%40 = load i32, i32* %2
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %61
42: ; preds = %38, %55
%43 = phi i64 [ %57, %55 ], [ 0, %38 ]
%44 = load i32, i32* %3
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %42, %46
%47 = phi i64 [ %51, %46 ], [ 0, %42 ]
%48 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %1, i64 0, i64 %43, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %49)
%51 = add nuw nsw i64 %47, 1
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = icmp slt i64 %51, %53
br i1 %54, label %46, label %55
55: ; preds = %46, %42
%56 = call i32 @putchar(i32 10)
%57 = add nuw nsw i64 %43, 1
%58 = load i32, i32* %2
%59 = sext i32 %58 to i64
%60 = icmp slt i64 %57, %59
br i1 %60, label %42, label %61
61: ; preds = %55, %38
ret i32 0
}