#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 */
typedef int /*<<< orphan*/ array4;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int get_kth_largest_element_among_array_of_integers_v1(int *, int, int);
int get_kth_largest_element_among_array_of_integers_v2(int *, int, int);
int main() {
  int array4[] = {6, 5, 3, 1, 4, 2, 9, 7, 8};
  int len4 = sizeof(array4) / sizeof(int);
  int k4 = 1;
  int exp_kth_largest4 = 9;
  assert(exp_kth_largest4 = get_kth_largest_element_among_array_of_integers_v1(
             array4, len4, k4));
  assert(exp_kth_largest4 = get_kth_largest_element_among_array_of_integers_v2(
             array4, len4, k4));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x9,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x9,-0x3c(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1030 <get_kth_largest_element_among_array_of_integers_v1@plt>
mov    %eax,%edi
mov    %edi,-0x3c(%rbp)
call   1040 <assert@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1060 <get_kth_largest_element_among_array_of_integers_v2@plt>
mov    %eax,%edi
mov    %edi,-0x3c(%rbp)
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xee5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeca(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeae(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%edx
call   1030 <get_kth_largest_element_among_array_of_integers_v1@plt>
mov    %eax,%edi
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1,%edx
call   1050 <get_kth_largest_element_among_array_of_integers_v2@plt>
mov    %eax,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.array4 = [9 x i32] [i32 6, i32 5, i32 3, i32 1, i32 4, i32 2, i32 9, i32 7, i32 8]
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [9 x i32]* %2 to i8*
store i32 9, i32* %3
store i32 1, i32* %4
store i32 9, i32* %5
%7 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @get_kth_largest_element_among_array_of_integers_v1(i32* %7, i32 %8, i32 %9)
store i32 %10, i32* %5
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 @get_kth_largest_element_among_array_of_integers_v2(i32* %12, i32 %13, i32 %14)
store i32 %15, i32* %5
%16 = call i32 @assert(i32 %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.array4 = [9 x i32] [i32 6, i32 5, i32 3, i32 1, i32 4, i32 2, i32 9, i32 7, i32 8]
define i32 @main() {
%1 = alloca [9 x i32]
%2 = bitcast [9 x i32]* %1 to i8*
%3 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%4 = call i32 @get_kth_largest_element_among_array_of_integers_v1(i32* %3, i32 9, i32 1)
%5 = call i32 @assert(i32 %4)
%6 = call i32 @get_kth_largest_element_among_array_of_integers_v2(i32* %3, i32 9, i32 1)
%7 = call i32 @assert(i32 %6)
ret i32 0
}