#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int scanf(char *, int *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
void sortGPA(double pgpa[], int pid[], char pname[][31], int num) {
  int i, pass, temp1, sorted;
  int result, submenu;
  double temp;
  char temp2[31];
  pass = 1;
  do {
    printf("--SUBMENU OPTIONS:--\n");
    printf("1) Ascending order\n");
    printf("2) Descending order\n");
    fflush(stdin);
    result = scanf("%d", &submenu);
    if ((result != 1) || (submenu < 1) || (submenu > 2)) {
      printf("Invalid input, please enter one of the menu choices.\n");
    }
  } while ((result != 1) || (submenu < 1) || (submenu > 2));
  if (submenu == 1) {
    do {
      sorted = 1;
      for (i = 0; i < num - pass; i++) {
        if (pgpa[i] > pgpa[i + 1]) {
          temp = pgpa[i];
          pgpa[i] = pgpa[i + 1];
          pgpa[i + 1] = temp;
          sorted = 0;
          temp1 = pid[i];
          pid[i] = pid[i + 1];
          pid[i + 1] = temp1;
          strcpy(temp2, pname[i]);
          strcpy(pname[i], pname[i + 1]);
          strcpy(pname[i + 1], temp2);
        }
      }
      pass++;
    } while (!sorted);
  } else {
    pass = 1;
    do {
      sorted = 1;
      for (i = 0; i < num - pass; i++) {
        if (pgpa[i] < pgpa[i + 1]) {
          temp = pgpa[i];
          pgpa[i] = pgpa[i + 1];
          pgpa[i + 1] = temp;
          sorted = 0;
          temp1 = pid[i];
          pid[i] = pid[i + 1];
          pid[i + 1] = temp1;
          strcpy(temp2, pname[i]);
          strcpy(pname[i], pname[i + 1]);
          strcpy(pname[i + 1], temp2);
        }
      }
      pass++;
    } while (!sorted);
  }
}


x86 assembly (clang, -O0):
<sortGPA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x24(%rbp)
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xea8(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x1,-0x30(%rbp)
jne    11c1 <sortGPA+0x81>
cmpl   $0x1,-0x34(%rbp)
jl     11c1 <sortGPA+0x81>
cmpl   $0x2,-0x34(%rbp)
jle    11cd <sortGPA+0x8d>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    11d2 <sortGPA+0x92>
mov    $0x1,%al
cmpl   $0x1,-0x30(%rbp)
mov    %al,-0x61(%rbp)
jne    11fa <sortGPA+0xba>
mov    $0x1,%al
cmpl   $0x1,-0x34(%rbp)
mov    %al,-0x61(%rbp)
jl     11fa <sortGPA+0xba>
cmpl   $0x2,-0x34(%rbp)
setg   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    115e <sortGPA+0x1e>
cmpl   $0x1,-0x34(%rbp)
jne    1370 <sortGPA+0x230>
jmp    1214 <sortGPA+0xd4>
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1351 <sortGPA+0x211>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
ucomisd (%rax,%rcx,8),%xmm0
jbe    133e <sortGPA+0x1fe>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
imul   $0x1f,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x1f,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1f,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1f,%rax,%rax
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    1343 <sortGPA+0x203>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1222 <sortGPA+0xe2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x2c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1214 <sortGPA+0xd4>
jmp    14d7 <sortGPA+0x397>
movl   $0x1,-0x24(%rbp)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    14b8 <sortGPA+0x378>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    14a5 <sortGPA+0x365>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
imul   $0x1f,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rax
imul   $0x1f,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1f,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
imul   $0x1f,%rax,%rax
add    %rax,%rdi
lea    -0x60(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    14aa <sortGPA+0x36a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1385 <sortGPA+0x245>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x2c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1377 <sortGPA+0x237>
jmp    14d7 <sortGPA+0x397>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sortGPA>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%r14
lea    0xe9c(%rip),%r12
mov    0x2e7a(%rip),%rbx
lea    0xe8b(%rip),%r15
lea    0x4(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    11e0 <sortGPA+0xa0>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11e0 <sortGPA+0xa0>
cmp    $0x3,%eax
jge    11e0 <sortGPA+0xa0>
cmp    $0x1,%ebp
jne    1180 <sortGPA+0x40>
test   %eax,%eax
jle    1180 <sortGPA+0x40>
cmp    $0x2,%eax
jg     1180 <sortGPA+0x40>
jmp    11f7 <sortGPA+0xb7>
cs nopw 0x0(%rax,%rax,1)
lea    0xe58(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%ebp
je     11cb <sortGPA+0x8b>
jmp    1180 <sortGPA+0x40>
cmp    $0x1,%eax
jne    12b3 <sortGPA+0x173>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%r15d
mov    $0x1,%ecx
lea    0x20(%rsp),%r13
jmp    1232 <sortGPA+0xf2>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rsp),%ecx
add    $0x1,%ecx
add    $0xffffffff,%r15d
test   %eax,%eax
jne    1363 <sortGPA+0x223>
cmp    0x8(%rsp),%ecx
jge    1363 <sortGPA+0x223>
mov    %ecx,(%rsp)
mov    %r15d,%r15d
mov    $0x1,%eax
mov    0x10(%rsp),%rbp
xor    %ecx,%ecx
jmp    125c <sortGPA+0x11c>
add    $0x1f,%rbp
mov    %r12,%rcx
cmp    %r12,%r15
je     1220 <sortGPA+0xe0>
movsd  (%r14,%rcx,8),%xmm0
movsd  0x8(%r14,%rcx,8),%xmm1
lea    0x1(%rcx),%r12
ucomisd %xmm1,%xmm0
jbe    1250 <sortGPA+0x110>
movsd  %xmm1,(%r14,%rcx,8)
movsd  %xmm0,0x8(%r14,%rcx,8)
mov    0x18(%rsp),%rax
rolq   $0x20,(%rax,%rcx,4)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0x1f(%rbp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
jmp    1250 <sortGPA+0x110>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%r15d
mov    $0x1,%ecx
lea    0x20(%rsp),%r13
jmp    12e2 <sortGPA+0x1a2>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%ecx
add    $0x1,%ecx
add    $0xffffffff,%r15d
test   %eax,%eax
jne    1363 <sortGPA+0x223>
cmp    0x8(%rsp),%ecx
jge    1363 <sortGPA+0x223>
mov    %ecx,(%rsp)
mov    %r15d,%r15d
mov    $0x1,%eax
mov    0x10(%rsp),%rbp
xor    %ecx,%ecx
jmp    130c <sortGPA+0x1cc>
nopl   0x0(%rax)
add    $0x1f,%rbp
mov    %rbx,%rcx
cmp    %rbx,%r15
je     12d0 <sortGPA+0x190>
movsd  (%r14,%rcx,8),%xmm0
movsd  0x8(%r14,%rcx,8),%xmm1
lea    0x1(%rcx),%rbx
ucomisd %xmm0,%xmm1
jbe    1300 <sortGPA+0x1c0>
movsd  %xmm1,(%r14,%rcx,8)
movsd  %xmm0,0x8(%r14,%rcx,8)
mov    0x18(%rsp),%rax
rolq   $0x20,(%rax,%rcx,4)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
lea    0x1f(%rbp),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
jmp    1300 <sortGPA+0x1c0>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"--SUBMENU OPTIONS:--\0A\00"
@.str.1 = [20 x i8] c"1) Ascending order\0A\00"
@.str.2 = [21 x i8] c"2) Descending order\0A\00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [54 x i8] c"Invalid input, please enter one of the menu choices.\0A\00"
define void @sortGPA(double* %0, i32* %1, [31 x i8]* %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32*
%7 = alloca [31 x i8]*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
%16 = alloca [31 x i8]
store double* %0, double** %5
store i32* %1, i32** %6
store [31 x i8]* %2, [31 x i8]** %7
store i32 %3, i32* %8
store i32 1, i32* %10
br label %17
17: ; preds = %44, %4
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @stdin
%22 = call i32 @fflush(i32 %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %14)
store i32 %23, i32* %13
%24 = load i32, i32* %13
%25 = icmp ne i32 %24, 1
br i1 %25, label %32, label %26
26: ; preds = %17
%27 = load i32, i32* %14
%28 = icmp slt i32 %27, 1
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = load i32, i32* %14
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %34
32: ; preds = %29, %26, %17
%33 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
br label %35
35: ; preds = %34
%36 = load i32, i32* %13
%37 = icmp ne i32 %36, 1
br i1 %37, label %44, label %38
38: ; preds = %35
%39 = load i32, i32* %14
%40 = icmp slt i32 %39, 1
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = load i32, i32* %14
%43 = icmp sgt i32 %42, 2
br label %44
44: ; preds = %41, %38, %35
%45 = phi i1 [ true, %38 ], [ true, %35 ], [ %43, %41 ]
br i1 %45, label %17, label %46
46: ; preds = %44
%47 = load i32, i32* %14
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %152
49: ; preds = %46
br label %50
50: ; preds = %147, %49
store i32 1, i32* %12
store i32 0, i32* %9
br label %51
51: ; preds = %141, %50
%52 = load i32, i32* %9
%53 = load i32, i32* %8
%54 = load i32, i32* %10
%55 = sub nsw i32 %53, %54
%56 = icmp slt i32 %52, %55
br i1 %56, label %57, label %144
57: ; preds = %51
%58 = load double*, double** %5
%59 = load i32, i32* %9
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = load double*, double** %5
%64 = load i32, i32* %9
%65 = add nsw i32 %64, 1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %63, i64 %66
%68 = load double, double* %67
%69 = fcmp ogt double %62, %68
br i1 %69, label %70, label %140
70: ; preds = %57
%71 = load double*, double** %5
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds double, double* %71, i64 %73
%75 = load double, double* %74
store double %75, double* %15
%76 = load double*, double** %5
%77 = load i32, i32* %9
%78 = add nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %76, i64 %79
%81 = load double, double* %80
%82 = load double*, double** %5
%83 = load i32, i32* %9
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %82, i64 %84
store double %81, double* %85
%86 = load double, double* %15
%87 = load double*, double** %5
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %87, i64 %90
store double %86, double* %91
store i32 0, i32* %12
%92 = load i32*, i32** %6
%93 = load i32, i32* %9
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = load i32, i32* %95
store i32 %96, i32* %11
%97 = load i32*, i32** %6
%98 = load i32, i32* %9
%99 = add nsw i32 %98, 1
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i32, i32* %97, i64 %100
%102 = load i32, i32* %101
%103 = load i32*, i32** %6
%104 = load i32, i32* %9
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i32, i32* %103, i64 %105
store i32 %102, i32* %106
%107 = load i32, i32* %11
%108 = load i32*, i32** %6
%109 = load i32, i32* %9
%110 = add nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i32, i32* %108, i64 %111
store i32 %107, i32* %112
%113 = getelementptr inbounds [31 x i8], [31 x i8]* %16, i64 0, i64 0
%114 = load [31 x i8]*, [31 x i8]** %7
%115 = load i32, i32* %9
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [31 x i8], [31 x i8]* %114, i64 %116
%118 = getelementptr inbounds [31 x i8], [31 x i8]* %117, i64 0, i64 0
%119 = call i32 @strcpy(i8* %113, i8* %118)
%120 = load [31 x i8]*, [31 x i8]** %7
%121 = load i32, i32* %9
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [31 x i8], [31 x i8]* %120, i64 %122
%124 = getelementptr inbounds [31 x i8], [31 x i8]* %123, i64 0, i64 0
%125 = load [31 x i8]*, [31 x i8]** %7
%126 = load i32, i32* %9
%127 = add nsw i32 %126, 1
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds [31 x i8], [31 x i8]* %125, i64 %128
%130 = getelementptr inbounds [31 x i8], [31 x i8]* %129, i64 0, i64 0
%131 = call i32 @strcpy(i8* %124, i8* %130)
%132 = load [31 x i8]*, [31 x i8]** %7
%133 = load i32, i32* %9
%134 = add nsw i32 %133, 1
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [31 x i8], [31 x i8]* %132, i64 %135
%137 = getelementptr inbounds [31 x i8], [31 x i8]* %136, i64 0, i64 0
%138 = getelementptr inbounds [31 x i8], [31 x i8]* %16, i64 0, i64 0
%139 = call i32 @strcpy(i8* %137, i8* %138)
br label %140
140: ; preds = %70, %57
br label %141
141: ; preds = %140
%142 = load i32, i32* %9
%143 = add nsw i32 %142, 1
store i32 %143, i32* %9
br label %51
144: ; preds = %51
%145 = load i32, i32* %10
%146 = add nsw i32 %145, 1
store i32 %146, i32* %10
br label %147
147: ; preds = %144
%148 = load i32, i32* %12
%149 = icmp ne i32 %148, 0
%150 = xor i1 %149, true
br i1 %150, label %50, label %151
151: ; preds = %147
br label %255
152: ; preds = %46
store i32 1, i32* %10
br label %153
153: ; preds = %250, %152
store i32 1, i32* %12
store i32 0, i32* %9
br label %154
154: ; preds = %244, %153
%155 = load i32, i32* %9
%156 = load i32, i32* %8
%157 = load i32, i32* %10
%158 = sub nsw i32 %156, %157
%159 = icmp slt i32 %155, %158
br i1 %159, label %160, label %247
160: ; preds = %154
%161 = load double*, double** %5
%162 = load i32, i32* %9
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds double, double* %161, i64 %163
%165 = load double, double* %164
%166 = load double*, double** %5
%167 = load i32, i32* %9
%168 = add nsw i32 %167, 1
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %166, i64 %169
%171 = load double, double* %170
%172 = fcmp olt double %165, %171
br i1 %172, label %173, label %243
173: ; preds = %160
%174 = load double*, double** %5
%175 = load i32, i32* %9
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds double, double* %174, i64 %176
%178 = load double, double* %177
store double %178, double* %15
%179 = load double*, double** %5
%180 = load i32, i32* %9
%181 = add nsw i32 %180, 1
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds double, double* %179, i64 %182
%184 = load double, double* %183
%185 = load double*, double** %5
%186 = load i32, i32* %9
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %185, i64 %187
store double %184, double* %188
%189 = load double, double* %15
%190 = load double*, double** %5
%191 = load i32, i32* %9
%192 = add nsw i32 %191, 1
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds double, double* %190, i64 %193
store double %189, double* %194
store i32 0, i32* %12
%195 = load i32*, i32** %6
%196 = load i32, i32* %9
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds i32, i32* %195, i64 %197
%199 = load i32, i32* %198
store i32 %199, i32* %11
%200 = load i32*, i32** %6
%201 = load i32, i32* %9
%202 = add nsw i32 %201, 1
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i32, i32* %200, i64 %203
%205 = load i32, i32* %204
%206 = load i32*, i32** %6
%207 = load i32, i32* %9
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds i32, i32* %206, i64 %208
store i32 %205, i32* %209
%210 = load i32, i32* %11
%211 = load i32*, i32** %6
%212 = load i32, i32* %9
%213 = add nsw i32 %212, 1
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds i32, i32* %211, i64 %214
store i32 %210, i32* %215
%216 = getelementptr inbounds [31 x i8], [31 x i8]* %16, i64 0, i64 0
%217 = load [31 x i8]*, [31 x i8]** %7
%218 = load i32, i32* %9
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds [31 x i8], [31 x i8]* %217, i64 %219
%221 = getelementptr inbounds [31 x i8], [31 x i8]* %220, i64 0, i64 0
%222 = call i32 @strcpy(i8* %216, i8* %221)
%223 = load [31 x i8]*, [31 x i8]** %7
%224 = load i32, i32* %9
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds [31 x i8], [31 x i8]* %223, i64 %225
%227 = getelementptr inbounds [31 x i8], [31 x i8]* %226, i64 0, i64 0
%228 = load [31 x i8]*, [31 x i8]** %7
%229 = load i32, i32* %9
%230 = add nsw i32 %229, 1
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds [31 x i8], [31 x i8]* %228, i64 %231
%233 = getelementptr inbounds [31 x i8], [31 x i8]* %232, i64 0, i64 0
%234 = call i32 @strcpy(i8* %227, i8* %233)
%235 = load [31 x i8]*, [31 x i8]** %7
%236 = load i32, i32* %9
%237 = add nsw i32 %236, 1
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [31 x i8], [31 x i8]* %235, i64 %238
%240 = getelementptr inbounds [31 x i8], [31 x i8]* %239, i64 0, i64 0
%241 = getelementptr inbounds [31 x i8], [31 x i8]* %16, i64 0, i64 0
%242 = call i32 @strcpy(i8* %240, i8* %241)
br label %243
243: ; preds = %173, %160
br label %244
244: ; preds = %243
%245 = load i32, i32* %9
%246 = add nsw i32 %245, 1
store i32 %246, i32* %9
br label %154
247: ; preds = %154
%248 = load i32, i32* %10
%249 = add nsw i32 %248, 1
store i32 %249, i32* %10
br label %250
250: ; preds = %247
%251 = load i32, i32* %12
%252 = icmp ne i32 %251, 0
%253 = xor i1 %252, true
br i1 %253, label %153, label %254
254: ; preds = %250
br label %255
255: ; preds = %254, %151
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@str = [21 x i8] c"--SUBMENU OPTIONS:--\00"
@str.5 = [19 x i8] c"1) Ascending order\00"
@str.6 = [20 x i8] c"2) Descending order\00"
@str.7 = [53 x i8] c"Invalid input, please enter one of the menu choices.\00"
define void @sortGPA(double* nocapture %0, i32* nocapture %1, [31 x i8]* %2, i32 %3) {
%5 = alloca i32
%6 = alloca [31 x i8]
%7 = bitcast i32* %5 to i8*
%8 = getelementptr inbounds [31 x i8], [31 x i8]* %6, i64 0, i64 0
br label %9
9: ; preds = %25, %4
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fflush(i32 %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%16 = icmp ne i32 %15, 1
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 1
%19 = select i1 %16, i1 true, i1 %18
%20 = icmp sgt i32 %17, 2
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %22, label %25
22: ; preds = %9
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.7, i64 0, i64 0))
%24 = load i32, i32* %5
br label %25
25: ; preds = %22, %9
%26 = phi i32 [ %24, %22 ], [ %17, %9 ]
%27 = icmp slt i32 %26, 1
%28 = select i1 %16, i1 true, i1 %27
%29 = icmp sgt i32 %26, 2
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %9, label %31
31: ; preds = %25
%32 = icmp eq i32 %26, 1
br i1 %32, label %33, label %65
33: ; preds = %31, %62
%34 = phi i32 [ %36, %62 ], [ %3, %31 ]
%35 = phi i32 [ %63, %62 ], [ 1, %31 ]
%36 = add i32 %34, -1
%37 = icmp slt i32 %35, %3
br i1 %37, label %38, label %97
38: ; preds = %33
%39 = zext i32 %36 to i64
br label %40
40: ; preds = %38, %59
%41 = phi i64 [ 0, %38 ], [ %45, %59 ]
%42 = phi i32 [ 1, %38 ], [ %60, %59 ]
%43 = getelementptr inbounds double, double* %0, i64 %41
%44 = load double, double* %43
%45 = add nuw nsw i64 %41, 1
%46 = getelementptr inbounds double, double* %0, i64 %45
%47 = load double, double* %46
%48 = fcmp ogt double %44, %47
br i1 %48, label %49, label %59
49: ; preds = %40
store double %47, double* %43
store double %44, double* %46
%50 = getelementptr inbounds i32, i32* %1, i64 %41
%51 = load i32, i32* %50
%52 = getelementptr inbounds i32, i32* %1, i64 %45
%53 = load i32, i32* %52
store i32 %53, i32* %50
store i32 %51, i32* %52
%54 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 %41, i64 0
%55 = call i32 @strcpy(i8* %8, i8* %54)
%56 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 %45, i64 0
%57 = call i32 @strcpy(i8* %54, i8* %56)
%58 = call i32 @strcpy(i8* %56, i8* %8)
br label %59
59: ; preds = %40, %49
%60 = phi i32 [ 0, %49 ], [ %42, %40 ]
%61 = icmp eq i64 %45, %39
br i1 %61, label %62, label %40
62: ; preds = %59
%63 = add nuw nsw i32 %35, 1
%64 = icmp eq i32 %60, 0
br i1 %64, label %33, label %97
65: ; preds = %31, %94
%66 = phi i32 [ %68, %94 ], [ %3, %31 ]
%67 = phi i32 [ %95, %94 ], [ 1, %31 ]
%68 = add i32 %66, -1
%69 = icmp slt i32 %67, %3
br i1 %69, label %70, label %97
70: ; preds = %65
%71 = zext i32 %68 to i64
br label %72
72: ; preds = %70, %91
%73 = phi i64 [ 0, %70 ], [ %77, %91 ]
%74 = phi i32 [ 1, %70 ], [ %92, %91 ]
%75 = getelementptr inbounds double, double* %0, i64 %73
%76 = load double, double* %75
%77 = add nuw nsw i64 %73, 1
%78 = getelementptr inbounds double, double* %0, i64 %77
%79 = load double, double* %78
%80 = fcmp olt double %76, %79
br i1 %80, label %81, label %91
81: ; preds = %72
store double %79, double* %75
store double %76, double* %78
%82 = getelementptr inbounds i32, i32* %1, i64 %73
%83 = load i32, i32* %82
%84 = getelementptr inbounds i32, i32* %1, i64 %77
%85 = load i32, i32* %84
store i32 %85, i32* %82
store i32 %83, i32* %84
%86 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 %73, i64 0
%87 = call i32 @strcpy(i8* %8, i8* %86)
%88 = getelementptr inbounds [31 x i8], [31 x i8]* %2, i64 %77, i64 0
%89 = call i32 @strcpy(i8* %86, i8* %88)
%90 = call i32 @strcpy(i8* %88, i8* %8)
br label %91
91: ; preds = %72, %81
%92 = phi i32 [ 0, %81 ], [ %74, %72 ]
%93 = icmp eq i64 %77, %71
br i1 %93, label %94, label %72
94: ; preds = %91
%95 = add nuw nsw i32 %67, 1
%96 = icmp eq i32 %92, 0
br i1 %96, label %65, label %97
97: ; preds = %65, %94, %33, %62
ret void
}