#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 /*<<< orphan*/ sort(int **, int);
int main() {
  int i, j, a[100][100], size;
  printf("Please input row of the matrix:");
  scanf("%d", &size);
  printf("Please input elements of the matrix:\n");
  for (i = 0; i < size; i++)
    for (j = 0; j < size; j++)
      scanf("%d", &a[i][j]);
  sort(a, size);
  printf("The result is:\n");
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++)
      printf("%d ", a[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
call   1050 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    11ea <main+0xba>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    11d7 <main+0xa7>
movslq -0x8(%rbp),%rax
lea    -0x9c50(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118e <main+0x5e>
jmp    11dc <main+0xac>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x48>
lea    -0x9c50(%rbp),%rdi
mov    -0x9c54(%rbp),%esi
call   1040 <sort@plt>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    128a <main+0x15a>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    126e <main+0x13e>
movslq -0x8(%rbp),%rcx
lea    -0x9c50(%rbp),%rax
imul   $0x190,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1227 <main+0xf7>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1211 <main+0xe1>
xor    %eax,%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c50,%rsp
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
lea    0xea1(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11ef <main+0x9f>
lea    0x10(%rsp),%r15
xor    %r12d,%r12d
lea    0xe7e(%rip),%r14
jmp    11c3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %esi,%rax
add    $0x1,%r12
add    $0x190,%r15
cmp    %rax,%r12
jge    11ef <main+0x9f>
test   %esi,%esi
jle    11b0 <main+0x60>
mov    %r15,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%rbx
jl     11d0 <main+0x80>
jmp    11b0 <main+0x60>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1060 <sort@plt>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    126e <main+0x11e>
lea    0xe0c(%rip),%r14
xor    %r15d,%r15d
jmp    123f <main+0xef>
nopl   0x0(%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>
test   %eax,%eax
jle    1220 <main+0xd0>
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 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1250 <main+0x100>
jmp    1220 <main+0xd0>
xor    %eax,%eax
add    $0x9c50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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