#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*/ printStudentTable(int **);
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ sortArray(int **, int);
int main(void) {
  int studentData[7][2] = {0};
  int count = 0;
  for (count = 0; count < 7; ++count) {
    studentData[count][0] = (rand() % 100000);
  }
  for (count = 0; count < 7; ++count) {
    studentData[count][1] = 18 + (rand() % 13);
  }
  printf("Before sorting...\n");
  printStudentTable(studentData);
  sortArray(studentData, 0);
  printf("After sorting by ID_INDEX...\n");
  printStudentTable(studentData);
  sortArray(studentData, 1);
  printf("After sorting by AGE_INDEX...\n");
  printStudentTable(studentData);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x7,-0x44(%rbp)
jge    11ac <main+0x5c>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x186a0,%ecx
cltd
idiv   %ecx
movslq -0x44(%rbp),%rax
mov    %edx,-0x40(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117d <main+0x2d>
movl   $0x0,-0x44(%rbp)
cmpl   $0x7,-0x44(%rbp)
jge    11e5 <main+0x95>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0xd,%ecx
cltd
idiv   %ecx
add    $0x12,%edx
movslq -0x44(%rbp),%rax
mov    %edx,-0x3c(%rbp,%rax,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11b3 <main+0x63>
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1060 <printStudentTable@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1050 <sortArray@plt>
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1060 <printStudentTable@plt>
lea    -0x40(%rbp),%rdi
mov    $0x1,%esi
call   1050 <sortArray@plt>
lea    0xe02(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1060 <printStudentTable@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x28(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x14f8b589,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0xd,%ecx
add    %edx,%ecx
imul   $0x186a0,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x30(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x24(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x2c(%rsp)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
sar    $0x2,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%edx
lea    (%rcx,%rdx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x12,%eax
mov    %eax,0x34(%rsp)
lea    0xc2a(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <printStudentTable@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <sortArray@plt>
lea    0xc1b(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <printStudentTable@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <sortArray@plt>
lea    0xc17(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <printStudentTable@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Before sorting...\0A\00"
@.str.1 = [30 x i8] c"After sorting by ID_INDEX...\0A\00"
@.str.2 = [31 x i8] c"After sorting by AGE_INDEX...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [7 x [2 x i32]]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [7 x [2 x i32]]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %3
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 7
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 100000
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 %12
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
store i32 %10, i32* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
store i32 0, i32* %3
br label %19
19: ; preds = %30, %18
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 7
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 13
%25 = add nsw i32 18, %24
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 %27
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %28, i64 0, i64 1
store i32 %25, i32* %29
br label %30
30: ; preds = %22
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %19
33: ; preds = %19
%34 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%35 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 0
%36 = bitcast [2 x i32]* %35 to i32**
%37 = call i32 @printStudentTable(i32** %36)
%38 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 0
%39 = bitcast [2 x i32]* %38 to i32**
%40 = call i32 @sortArray(i32** %39, i32 0)
%41 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%42 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 0
%43 = bitcast [2 x i32]* %42 to i32**
%44 = call i32 @printStudentTable(i32** %43)
%45 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 0
%46 = bitcast [2 x i32]* %45 to i32**
%47 = call i32 @sortArray(i32** %46, i32 1)
%48 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%49 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %2, i64 0, i64 0
%50 = bitcast [2 x i32]* %49 to i32**
%51 = call i32 @printStudentTable(i32** %50)
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
@str = [18 x i8] c"Before sorting...\00"
@str.3 = [29 x i8] c"After sorting by ID_INDEX...\00"
@str.4 = [30 x i8] c"After sorting by AGE_INDEX...\00"
define i32 @main() {
%1 = alloca [7 x [2 x i32]]
%2 = bitcast [7 x [2 x i32]]* %1 to i8*
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100000
%5 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 0, i64 0
store i32 %4, i32* %5
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 100000
%8 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 1, i64 0
store i32 %7, i32* %8
%9 = tail call i32 (...) @rand()
%10 = srem i32 %9, 100000
%11 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 2, i64 0
store i32 %10, i32* %11
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 100000
%14 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 3, i64 0
store i32 %13, i32* %14
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 100000
%17 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 4, i64 0
store i32 %16, i32* %17
%18 = tail call i32 (...) @rand()
%19 = srem i32 %18, 100000
%20 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 5, i64 0
store i32 %19, i32* %20
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 100000
%23 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 6, i64 0
store i32 %22, i32* %23
%24 = tail call i32 (...) @rand()
%25 = srem i32 %24, 13
%26 = add nsw i32 %25, 18
%27 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 0, i64 1
store i32 %26, i32* %27
%28 = tail call i32 (...) @rand()
%29 = srem i32 %28, 13
%30 = add nsw i32 %29, 18
%31 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 1, i64 1
store i32 %30, i32* %31
%32 = tail call i32 (...) @rand()
%33 = srem i32 %32, 13
%34 = add nsw i32 %33, 18
%35 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 2, i64 1
store i32 %34, i32* %35
%36 = tail call i32 (...) @rand()
%37 = srem i32 %36, 13
%38 = add nsw i32 %37, 18
%39 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 3, i64 1
store i32 %38, i32* %39
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 13
%42 = add nsw i32 %41, 18
%43 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 4, i64 1
store i32 %42, i32* %43
%44 = tail call i32 (...) @rand()
%45 = srem i32 %44, 13
%46 = add nsw i32 %45, 18
%47 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 5, i64 1
store i32 %46, i32* %47
%48 = tail call i32 (...) @rand()
%49 = srem i32 %48, 13
%50 = add nsw i32 %49, 18
%51 = getelementptr inbounds [7 x [2 x i32]], [7 x [2 x i32]]* %1, i64 0, i64 6, i64 1
store i32 %50, i32* %51
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%53 = bitcast [7 x [2 x i32]]* %1 to i32**
%54 = call i32 @printStudentTable(i32** %53)
%55 = call i32 @sortArray(i32** %53, i32 0)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
%57 = call i32 @printStudentTable(i32** %53)
%58 = call i32 @sortArray(i32** %53, i32 1)
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.4, i64 0, i64 0))
%60 = call i32 @printStudentTable(i32** %53)
ret i32 0
}