#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 */
double median(int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ quickSort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  printf("Enter size of the Array\n");
  scanf("%d", &n);
  int arr[n];
  printf("Enter %d integers\n", n);
  for (int i = 0; i < n; i++)
    scanf("%d", &arr[i]);
  quickSort(arr, 0, n - 1);
  printf("Median = %f\n", median(n, arr));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e1 <main+0xa1>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4b(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ac <main+0x6c>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <quickSort@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <median@plt>
lea    0xe2a(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8f(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%esi
lea    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edx
test   %edx,%edx
jle    11dc <main+0x8c>
xor    %r13d,%r13d
lea    0xe49(%rip),%r15
mov    %r14,%rbx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rdx
add    $0x4,%rbx
cmp    %rdx,%r13
jl     11c0 <main+0x70>
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <quickSort@plt>
mov    -0x2c(%rbp),%edi
mov    %r14,%rsi
call   1030 <median@plt>
lea    0xe1b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Enter size of the Array\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Enter %d integers\0A\00"
@.str.3 = [13 x i8] c"Median = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %12)
store i32 0, i32* %5
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %11, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %14
26: ; preds = %14
%27 = load i32, i32* %2
%28 = sub nsw i32 %27, 1
%29 = call i32 @quickSort(i32* %11, i32 0, i32 %28)
%30 = load i32, i32* %2
%31 = call double @median(i32 %30, i32* %11)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %31)
store i32 0, i32* %1
%33 = load i8*, i8** %3
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Enter %d integers\0A\00"
@.str.3 = [13 x i8] c"Median = %f\0A\00"
@str = [24 x i8] c"Enter size of the Array\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = alloca i32, i64 %6
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = icmp sgt i32 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %20, %0
%14 = phi i32 [ %11, %0 ], [ %25, %20 ]
%15 = add nsw i32 %14, -1
%16 = call i32 @quickSort(i32* %8, i32 0, i32 %15)
%17 = load i32, i32* %1
%18 = call double @median(i32 %17, i32* %8)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), double %18)
ret i32 0
20: ; preds = %0, %20
%21 = phi i64 [ %24, %20 ], [ 0, %0 ]
%22 = getelementptr inbounds i32, i32* %8, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %21, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %24, %26
br i1 %27, label %20, label %13
}