#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 r, c, a[100][100], b[100][100], i, j;
  printf("Enter number of rows");
  scanf("%d", &r);
  printf("Enter number of columns");
  scanf("%d", &c);
  printf("\nEnter elements of matrix:\n");
  for (i = 0; i < r; ++i)
    for (j = 0; j < c; ++j) {
      printf("Enter element a%d%d: ", i + 1, j + 1);
      scanf("%d", &a[i][j]);
    }
  for (j = 0; j < c; j++) {
    for (i = 0; i < r; i++) {
      printf("%d", a[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x13894(%rbp)
mov    -0x13894(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    122d <main+0x10d>
movl   $0x0,-0x13898(%rbp)
mov    -0x13898(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1214 <main+0xf4>
mov    -0x13894(%rbp),%esi
add    $0x1,%esi
mov    -0x13898(%rbp),%edx
add    $0x1,%edx
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x13894(%rbp),%rax
lea    -0x9c50(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0x13898(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe1a(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x13898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13898(%rbp)
jmp    119f <main+0x7f>
jmp    1219 <main+0xf9>
mov    -0x13894(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13894(%rbp)
jmp    1186 <main+0x66>
movl   $0x0,-0x13898(%rbp)
mov    -0x13898(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12c5 <main+0x1a5>
movl   $0x0,-0x13894(%rbp)
mov    -0x13894(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a3 <main+0x183>
movslq -0x13894(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0x13898(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x13894(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13894(%rbp)
jmp    1250 <main+0x130>
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x13898(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x13898(%rbp)
jmp    1237 <main+0x117>
xor    %eax,%eax
add    $0x138a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeaf(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
test   %eax,%eax
jle    1212 <main+0xd2>
lea    0x10(%rsp),%rbp
lea    0xe7e(%rip),%r14
lea    0xe5c(%rip),%r15
xor    %r12d,%r12d
jmp    11cf <main+0x8f>
xchg   %ax,%ax
movslq %eax,%rdx
add    $0x190,%rbp
cmp    %rdx,%r12
jge    1212 <main+0xd2>
add    $0x1,%r12
test   %ecx,%ecx
jle    11c0 <main+0x80>
mov    %rbp,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rcx
add    $0x4,%r13
cmp    %rcx,%rbx
jl     11e0 <main+0xa0>
mov    0x8(%rsp),%eax
jmp    11c0 <main+0x80>
test   %ecx,%ecx
jle    1288 <main+0x148>
lea    0x10(%rsp),%r14
lea    0xdf3(%rip),%r12
xor    %r15d,%r15d
test   %eax,%eax
jle    1262 <main+0x122>
nopl   0x0(%rax)
mov    %r14,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x190,%rbp
cmp    %rax,%rbx
jl     1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
cmp    %rax,%r15
jge    1288 <main+0x148>
mov    0x8(%rsp),%eax
add    $0x4,%r14
test   %eax,%eax
jg     1230 <main+0xf0>
jmp    1262 <main+0x122>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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