#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);
int /*<<< orphan*/ quicksort_ascending(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int cutthesticks(void) {
  int numSticks;
  scanf("%d", &numSticks);
  int *stickLengths = malloc(sizeof(int) * numSticks);
  for (int i = 0; i < numSticks; i++) {
    scanf("%d", stickLengths + i);
  }
  quicksort_ascending(stickLengths, numSticks);
  int lastStickLength = -1;
  for (int i = 0; i < numSticks; i++) {
    if (stickLengths[i] != lastStickLength) {
      printf("%d\n", numSticks - i);
    }
    lastStickLength = stickLengths[i];
  }
  free(stickLengths);
  return 0;
}


x86 assembly (clang, -O0):
<cutthesticks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x4(%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    -0x4(%rbp),%eax
jge    11b7 <cutthesticks+0x67>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <cutthesticks+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1040 <quicksort_ascending@plt>
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    121f <cutthesticks+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
je     1203 <cutthesticks+0xb3>
mov    -0x4(%rbp),%esi
sub    -0x1c(%rbp),%esi
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d1 <cutthesticks+0x81>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cutthesticks>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%r12d
lea    0x0(,%r12,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r15
test   %r12d,%r12d
jle    11bd <cutthesticks+0x6d>
xor    %r13d,%r13d
lea    0xe6e(%rip),%r14
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq 0xc(%rsp),%r12
add    $0x4,%rbx
cmp    %r12,%r13
jl     11a0 <cutthesticks+0x50>
mov    %r15,%rdi
mov    %r12d,%esi
call   1040 <quicksort_ascending@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    1217 <cutthesticks+0xc7>
mov    $0xffffffff,%eax
xor    %r12d,%r12d
lea    0xe24(%rip),%r14
xor    %ebx,%ebx
jmp    11fc <cutthesticks+0xac>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    %ebx,%esi
jle    1217 <cutthesticks+0xc7>
cmp    %eax,(%r15,%rbx,4)
je     11f0 <cutthesticks+0xa0>
add    %r12d,%esi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    (%r15,%rbx,4),%eax
mov    0xc(%rsp),%esi
jmp    11f0 <cutthesticks+0xa0>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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