#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*/ free(int *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quicksort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a;
  int *arr;
  int i;
  while (1) {
    scanf("%d", &a);
    if (a == -1)
      break;
    arr = malloc(a * sizeof(int));
    for (i = 0; i < a; i++) {
      scanf("%d", &arr[i]);
    }
    quicksort(arr, 0, a - 1);
    for (i = 0; i < a; i++) {
      printf("%d ", arr[i]);
    }
    printf("\n");
    free(arr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
jne    117e <main+0x2e>
jmp    1234 <main+0xe4>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cd <main+0x7d>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe46(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1198 <main+0x48>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1040 <quicksort@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1218 <main+0xc8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e5 <main+0x95>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    115f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    $0xffffffff,%ebx
je     1252 <main+0xf2>
lea    0xe70(%rip),%r12
lea    0xe6c(%rip),%r14
jmp    11cc <main+0x6c>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    $0xffffffff,%ebx
je     1252 <main+0xf2>
lea    0x0(,%rbx,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
test   %ebx,%ebx
jle    120d <main+0xad>
mov    %r13,%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %rbp,%rsi
call   1080 <scanf@plt>
add    $0x1,%r15
movslq 0x4(%rsp),%rbx
add    $0x4,%rbp
cmp    %rbx,%r15
jl     11f0 <main+0x90>
add    $0xffffffff,%ebx
mov    %r13,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1050 <quicksort@plt>
cmpl   $0x0,0x4(%rsp)
jle    11a0 <main+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x0(%r13,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
cmp    %rax,%rbx
jl     1230 <main+0xd0>
jmp    11a0 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, -1
br i1 %5, label %40, label %6
6: ; preds = %0, %34
%7 = phi i32 [ %38, %34 ], [ %4, %0 ]
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = icmp sgt i32 %7, 0
br i1 %10, label %11, label %19
11: ; preds = %6, %11
%12 = phi i64 [ %15, %11 ], [ 0, %6 ]
%13 = getelementptr inbounds i32, i32* %9, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %6
%20 = phi i32 [ %7, %6 ], [ %16, %11 ]
%21 = add nsw i32 %20, -1
%22 = call i32 @quicksort(i32* %9, i32 0, i32 %21)
%23 = load i32, i32* %1
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %19, %25
%26 = phi i64 [ %30, %25 ], [ 0, %19 ]
%27 = getelementptr inbounds i32, i32* %9, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = add nuw nsw i64 %26, 1
%31 = load i32, i32* %1
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %25, label %34
34: ; preds = %25, %19
%35 = call i32 @putchar(i32 10)
%36 = call i32 @free(i32* %9)
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%38 = load i32, i32* %1
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %6
40: ; preds = %34, %0
ret i32 0
}