#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 qs_double(double *, int);
double median_double(double *data, int len) {
  double cpy[sizeof(double) * len];
  int i;
  for (i = 0; i < len; i++) {
    cpy[i] = data[i];
  }
  return qs_double(cpy, len);
}


x86 assembly (clang, -O0):
<median_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rdx
mov    %rdx,%rax
shl    $0x3,%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
shl    $0x6,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1181 <median_double+0x71>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <median_double+0x3d>
mov    -0x30(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <qs_double@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<median_double>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %esi,%r14d
movslq %esi,%rax
mov    %rsp,%rbx
mov    %rax,%rcx
shl    $0x6,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
test   %eax,%eax
jle    1153 <median_double+0x33>
mov    %rdi,%rsi
mov    %r14d,%edx
shl    $0x3,%rdx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <qs_double@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @median_double(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store double* %0, double** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 8, %9
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca double, i64 %10
store i64 %10, i64* %6
store i32 0, i32* %7
br label %13
13: ; preds = %26, %2
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load double*, double** %3
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds double, double* %12, i64 %24
store double %22, double* %25
br label %26
26: ; preds = %17
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %13
29: ; preds = %13
%30 = load i32, i32* %4
%31 = call double @qs_double(double* %12, i32 %30)
%32 = load i8*, i8** %5
ret double %31
}

LLVM IR (-O2):
define double @median_double(double* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = shl nsw i64 %3, 3
%5 = alloca double, i64 %4
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = bitcast double* %5 to i8*
%9 = bitcast double* %0 to i8*
%10 = zext i32 %1 to i64
%11 = shl nuw nsw i64 %10, 3
br label %12
12: ; preds = %7, %2
%13 = call double @qs_double(double* %5, i32 %1)
ret double %13
}