#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 extractMin(int *);
int /*<<< orphan*/ getArr(int *);
int /*<<< orphan*/ minHeapify(int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int k, arr[5];
  int i, ans;
  printf("Enter the numbers\n");
  getArr(arr);
  minHeapify(arr, 0);
  printf("Enter the value of k\n");
  scanf("%d", &k);
  for (i = 0; i < k; ++i)
    printf("The %d order statistic is %d\n", i + 1, extractMin(arr));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <getArr@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1040 <minHeapify@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e5 <main+0x95>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x20(%rbp),%rdi
call   1070 <extractMin@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a6 <main+0x56>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <getArr@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <minHeapify@plt>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11df <main+0x7f>
lea    0x10(%rsp),%r14
lea    0xe48(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
add    $0x1,%ebp
mov    %r14,%rdi
call   1080 <extractMin@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
cmp    0xc(%rsp),%ebp
jl     11c0 <main+0x60>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Enter the numbers\0A\00"
@.str.1 = [22 x i8] c"Enter the value of k\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [30 x i8] c"The %d order statistic is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%8 = call i32 @getArr(i32* %7)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%10 = call i32 @minHeapify(i32* %9, i32 0)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
br label %13
13: ; preds = %23, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
%20 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%21 = call i32 @extractMin(i32* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %19, i32 %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %13
26: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [30 x i8] c"The %d order statistic is %d\0A\00"
@str = [18 x i8] c"Enter the numbers\00"
@str.4 = [21 x i8] c"Enter the value of k\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%7 = call i32 @getArr(i32* %6)
%8 = call i32 @minHeapify(i32* %6, i32 0)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.4, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %0, %13
%14 = phi i32 [ %15, %13 ], [ 0, %0 ]
%15 = add nuw nsw i32 %14, 1
%16 = call i32 @extractMin(i32* %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %1
%19 = icmp slt i32 %15, %18
br i1 %19, label %13, label %20
20: ; preds = %13, %0
ret i32 0
}