#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 *);
void main() {
  int r, c, i, j;
  int a[10][10];
  printf("Enter the number or rows and columns.\n");
  scanf("%d", &r);
  scanf("%d", &c);
  printf("enter the elements of the matrix. Row-wise\n");
  for (i = 0; i < r; i++)
    for (j = 0; j < c; j++)
      scanf("%d", &a[i][j]);
  printf("Given matrix is\n");
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      printf("%d\t", a[i][j]);
    }
    printf("\n");
  }
  printf("Transpose of a matrix\n");
  for (j = 0; j < c; j++) {
    for (i = 0; i < r; i++) {
      printf("%d\t", a[i][j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d7 <main+0xb7>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c4 <main+0xa4>
movslq -0xc(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
imul   $0x28,%rax,%rax
add    %rax,%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe76(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1181 <main+0x61>
jmp    11c9 <main+0xa9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <main+0x4e>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    125c <main+0x13c>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1240 <main+0x120>
movslq -0xc(%rbp),%rcx
lea    -0x1a0(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ff <main+0xdf>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ec <main+0xcc>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e1 <main+0x1c1>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c5 <main+0x1a5>
movslq -0xc(%rbp),%rcx
lea    -0x1a0(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1284 <main+0x164>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1271 <main+0x151>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a0,%rsp
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9d(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jle    11f3 <main+0xb3>
lea    0x10(%rsp),%r15
mov    0x8(%rsp),%eax
xor    %r12d,%r12d
lea    0xe5c(%rip),%r14
jmp    11c0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r12
movslq %ecx,%rdx
add    $0x28,%r15
cmp    %rdx,%r12
jge    11f3 <main+0xb3>
test   %eax,%eax
jle    11b0 <main+0x70>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11d0 <main+0x90>
mov    0xc(%rsp),%ecx
jmp    11b0 <main+0x70>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0xc(%rsp)
jle    126e <main+0x12e>
lea    0x10(%rsp),%r12
lea    0xdf1(%rip),%r14
xor    %r15d,%r15d
jmp    123c <main+0xfc>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0xc(%rsp),%rax
add    $0x28,%r12
cmp    %rax,%r15
jge    126e <main+0x12e>
cmpl   $0x0,0x8(%rsp)
jle    1220 <main+0xe0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
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+0x110>
jmp    1220 <main+0xe0>
lea    0xdf3(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x8(%rsp)
jle    12f2 <main+0x1b2>
lea    0x10(%rsp),%r14
lea    0xd76(%rip),%r12
xor    %r15d,%r15d
jmp    12bc <main+0x17c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq 0x8(%rsp),%rax
add    $0x4,%r14
cmp    %rax,%r15
jge    12f2 <main+0x1b2>
cmpl   $0x0,0xc(%rsp)
jle    12a0 <main+0x160>
mov    %r14,%r13
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x28,%r13
cmp    %rax,%rbx
jl     12d0 <main+0x190>
jmp    12a0 <main+0x160>
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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