#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 main() {
  int i, j, row, col, matrix[10][10];
  printf("Enter the size of the matrix: ");
  scanf("%d", &row);
  col = row;
  printf("Enter the Matrix Elements: \n");
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) {
      scanf("%d", &matrix[i][j]);
    }
  }
  for (i = 0; i < row; i++) {
    printf("\n");
    for (j = 0; j < col; j++) {
      if (j >= i) {
        printf("%d ", matrix[i][j]);
      } else {
        printf("0 ");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d4 <main+0xb4>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c1 <main+0xa1>
movslq -0x8(%rbp),%rax
lea    -0x1b0(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe71(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117e <main+0x5e>
jmp    11c6 <main+0xa6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116b <main+0x4b>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1274 <main+0x154>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1261 <main+0x141>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1240 <main+0x120>
movslq -0x8(%rbp),%rcx
lea    -0x1b0(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <main+0x12e>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1253 <main+0x133>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11fc <main+0xdc>
jmp    1266 <main+0x146>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11db <main+0xbb>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%r15d
lea    0xead(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1259 <main+0x119>
lea    0x10(%rsp),%r12
xor    %r13d,%r13d
lea    0xe83(%rip),%r14
jmp    11b0 <main+0x70>
xchg   %ax,%ax
add    $0x1,%r13
movslq %eax,%rcx
add    $0x28,%r12
cmp    %rcx,%r13
jge    11db <main+0x9b>
mov    %r15,%rbp
mov    %r12,%rbx
test   %r15d,%r15d
jle    11a0 <main+0x60>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%rbp
jne    11c0 <main+0x80>
mov    0xc(%rsp),%eax
jmp    11a0 <main+0x60>
test   %eax,%eax
jle    1259 <main+0x119>
lea    0x10(%rsp),%r13
lea    0xe3b(%rip),%r14
lea    0xe30(%rip),%r12
xor    %ebx,%ebx
jmp    1212 <main+0xd2>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x28,%r13
cmp    %rax,%rbx
jge    1259 <main+0x119>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    1200 <main+0xc0>
xor    %ebp,%ebp
jmp    1243 <main+0x103>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     1200 <main+0xc0>
cmp    %rbx,%rbp
jb     1230 <main+0xf0>
mov    0x0(%r13,%rbp,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    123a <main+0xfa>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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