#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*/ array;

/* Variables and functions */
int /*<<< orphan*/ median(double *, int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int main(int argc, const char *argv[]) {
  double array[] = {12.2, 10.0, 13.4, 14.5, 56.2, 23.3};
  int nArray = sizeof(array) / sizeof(array[0]);
  printf("Median is %lf.\n", median(array, nArray));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
movsd  0xeca(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xeb5(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x6,-0x44(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <median@plt>
mov    %eax,%esi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %rsp,%rdi
mov    $0x6,%esi
call   1030 <median@plt>
lea    0xed5(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Median is %lf.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x double]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [6 x double]* %6 to i8*
%9 = bitcast i8* %8 to [6 x double]*
%10 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 0
store double 1.220000e+01, double* %10
%11 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 1
store double 1.000000e+01, double* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 2
store double 1.340000e+01, double* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 3
store double 1.450000e+01, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 4
store double 5.620000e+01, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %9, i32 0, i32 5
store double 2.330000e+01, double* %15
store i32 6, i32* %7
%16 = getelementptr inbounds [6 x double], [6 x double]* %6, i64 0, i64 0
%17 = load i32, i32* %7
%18 = call i32 @median(double* %16, i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Median is %lf.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x double]
%4 = bitcast [6 x double]* %3 to i8*
%5 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%6 = bitcast [6 x double]* %3 to <2 x double>*
store <2 x double> <double 1.220000e+01, double 1.000000e+01>, <2 x double>* %6
%7 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 2
%8 = bitcast double* %7 to <2 x double>*
store <2 x double> <double 1.340000e+01, double 1.450000e+01>, <2 x double>* %8
%9 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 4
%10 = bitcast double* %9 to <2 x double>*
store <2 x double> <double 5.620000e+01, double 2.330000e+01>, <2 x double>* %10
%11 = call i32 @median(double* %5, i32 6)
%12 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}