#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*/ dump(int *, int);
int findKthlagest(int *, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ quick_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a[10] = {30, 20, 10, 15, 4, 8, 40, 80, 20, 9};
  int k;
  scanf("%d", &k);
  printf("\r\n从小到大排序，第%d个元素数值是%d", k, findKthlagest(a, 10, k));
  quick_sort(a, 0, 9);
  dump(a, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xecb(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0xa,%esi
call   1060 <findKthlagest@plt>
mov    -0x38(%rbp),%esi
mov    %eax,%edx
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1080 <quick_sort@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1040 <dump@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xec2(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xea6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8a(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    %ebx,%edx
call   1050 <findKthlagest@plt>
lea    0xe7d(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1070 <quick_sort@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <dump@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [10 x i32] [i32 30, i32 20, i32 10, i32 15, i32 4, i32 8, i32 40, i32 80, i32 20, i32 9]
@.str = [3 x i8] c"%d\00"
@.str.1 = [49 x i8] c"\0D\0A\E4\BB\8E\E5\B0\8F\E5\88\B0\E5\A4\A7\E6\8E\92\E5\BA\8F\EF\BC\8C\E7\AC\AC%d\E4\B8\AA\E5\85\83\E7\B4\A0\E6\95\B0\E5\80\BC\E6\98\AF%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @findKthlagest(i32* %7, i32 10, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%12 = call i32 @quick_sort(i32* %11, i32 0, i32 9)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%14 = call i32 @dump(i32* %13, i32 10)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [10 x i32] [i32 30, i32 20, i32 10, i32 15, i32 4, i32 8, i32 40, i32 80, i32 20, i32 9]
@.str = [3 x i8] c"%d\00"
@.str.1 = [49 x i8] c"\0D\0A\E4\BB\8E\E5\B0\8F\E5\88\B0\E5\A4\A7\E6\8E\92\E5\BA\8F\EF\BC\8C\E7\AC\AC%d\E4\B8\AA\E5\85\83\E7\B4\A0\E6\95\B0\E5\80\BC\E6\98\AF%d\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%8 = call i32 @findKthlagest(i32* %7, i32 10, i32 %6)
%9 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %8)
%10 = call i32 @quick_sort(i32* %7, i32 0, i32 9)
%11 = call i32 @dump(i32* %7, i32 10)
ret i32 0
}