#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 GetIntegerArray(int *, int, int);
int /*<<< orphan*/ PrintIntegerArray(int *, int);
int /*<<< orphan*/ SortIntegerArray(int *, int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  int scores[100];
  int n;
  printf("Enter exam scores, one per line, ending\n");
  printf("with the sentinel value %d.\n", -1);
  n = GetIntegerArray(scores, 100, -1);
  SortIntegerArray(scores, n);
  printf("\nThe sorted exam scores are:\n");
  PrintIntegerArray(scores, n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0xffffffff,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x190(%rbp),%rdi
mov    $0x64,%esi
mov    $0xffffffff,%edx
call   1050 <GetIntegerArray@plt>
mov    %eax,-0x194(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
call   1040 <SortIntegerArray@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
call   1030 <PrintIntegerArray@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x198,%rsp
lea    0xebd(%rip),%rdi
call   1050 <puts@plt>
lea    0xe94(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
mov    $0xffffffff,%edx
call   1060 <GetIntegerArray@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <SortIntegerArray@plt>
lea    0xea5(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <PrintIntegerArray@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Enter exam scores, one per line, ending\0A\00"
@.str.1 = [29 x i8] c"with the sentinel value %d.\0A\00"
@.str.2 = [30 x i8] c"\0AThe sorted exam scores are:\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 -1)
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = call i32 @GetIntegerArray(i32* %5, i32 100, i32 -1)
store i32 %6, i32* %2
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @SortIntegerArray(i32* %7, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%12 = load i32, i32* %2
%13 = call i32 @PrintIntegerArray(i32* %11, i32 %12)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"with the sentinel value %d.\0A\00"
@str = [40 x i8] c"Enter exam scores, one per line, ending\00"
@str.3 = [29 x i8] c"\0AThe sorted exam scores are:\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 -1)
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%6 = call i32 @GetIntegerArray(i32* %5, i32 100, i32 -1)
%7 = call i32 @SortIntegerArray(i32* %5, i32 %6)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
%9 = call i32 @PrintIntegerArray(i32* %5, i32 %6)
ret i32 0
}