#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 */
struct Node {
  int dummy;
};

/* Variables and functions */
struct Node *insert(struct Node *, int);
int /*<<< orphan*/ kthLargest(struct Node *, int);
int main() {
  struct Node *root = NULL;
  root = insert(root, 50);
  insert(root, 30);
  insert(root, 20);
  insert(root, 40);
  insert(root, 70);
  insert(root, 60);
  insert(root, 80);
  int c = 0;
  for (int k = 1; k <= 7; k++)
    kthLargest(root, k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x32,%esi
call   1040 <insert@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1e,%esi
call   1040 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%esi
call   1040 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x28,%esi
call   1040 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x46,%esi
call   1040 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3c,%esi
call   1040 <insert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x50,%esi
call   1040 <insert@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x7,-0x18(%rbp)
jg     11cf <main+0xaf>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <kthLargest@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ab <main+0x8b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
mov    $0x32,%esi
call   1040 <insert@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1e,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x46,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x3c,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
call   1040 <insert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <kthLargest@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <kthLargest@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.Node*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store %struct.Node* null, %struct.Node** %2
%5 = load %struct.Node*, %struct.Node** %2
%6 = call %struct.Node* @insert(%struct.Node* %5, i32 50)
store %struct.Node* %6, %struct.Node** %2
%7 = load %struct.Node*, %struct.Node** %2
%8 = call %struct.Node* @insert(%struct.Node* %7, i32 30)
%9 = load %struct.Node*, %struct.Node** %2
%10 = call %struct.Node* @insert(%struct.Node* %9, i32 20)
%11 = load %struct.Node*, %struct.Node** %2
%12 = call %struct.Node* @insert(%struct.Node* %11, i32 40)
%13 = load %struct.Node*, %struct.Node** %2
%14 = call %struct.Node* @insert(%struct.Node* %13, i32 70)
%15 = load %struct.Node*, %struct.Node** %2
%16 = call %struct.Node* @insert(%struct.Node* %15, i32 60)
%17 = load %struct.Node*, %struct.Node** %2
%18 = call %struct.Node* @insert(%struct.Node* %17, i32 80)
store i32 0, i32* %3
store i32 1, i32* %4
br label %19
19: ; preds = %26, %0
%20 = load i32, i32* %4
%21 = icmp sle i32 %20, 7
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load %struct.Node*, %struct.Node** %2
%24 = load i32, i32* %4
%25 = call i32 @kthLargest(%struct.Node* %23, i32 %24)
br label %26
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %19
29: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
%struct.Node = type { i32 }
define i32 @main() {
%1 = tail call %struct.Node* @insert(%struct.Node* null, i32 50)
%2 = tail call %struct.Node* @insert(%struct.Node* %1, i32 30)
%3 = tail call %struct.Node* @insert(%struct.Node* %1, i32 20)
%4 = tail call %struct.Node* @insert(%struct.Node* %1, i32 40)
%5 = tail call %struct.Node* @insert(%struct.Node* %1, i32 70)
%6 = tail call %struct.Node* @insert(%struct.Node* %1, i32 60)
%7 = tail call %struct.Node* @insert(%struct.Node* %1, i32 80)
%8 = tail call i32 @kthLargest(%struct.Node* %1, i32 1)
%9 = tail call i32 @kthLargest(%struct.Node* %1, i32 2)
%10 = tail call i32 @kthLargest(%struct.Node* %1, i32 3)
%11 = tail call i32 @kthLargest(%struct.Node* %1, i32 4)
%12 = tail call i32 @kthLargest(%struct.Node* %1, i32 5)
%13 = tail call i32 @kthLargest(%struct.Node* %1, i32 6)
%14 = tail call i32 @kthLargest(%struct.Node* %1, i32 7)
ret i32 0
}