#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(double *, double *, int);
double nthd(int, double *, double);
int /*<<< orphan*/ stderr;
double doublequartile0(int ndat, double *dat) {
  double *a, m;
  if ((a = (double *)malloc(sizeof(double) * ndat)) == NULL) {
    fprintf(stderr, "Cannot allocate a in doublequartile, ndat=%d\n", ndat);
    exit(-1);
  }
  memcpy(a, dat, sizeof(double) * ndat);
  m = nthd(ndat, a, (double)(ndat - 1) * 0.25);
  free(a);
  return m;
}


x86 assembly (clang, -O0):
<doublequartile0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11ae <doublequartile0+0x4e>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
lea    0xe69(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe22(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1080 <nthd@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doublequartile0>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
lea    0x0(,%r14,8),%ebp
mov    %ebp,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11c9 <doublequartile0+0x69>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <memcpy@plt>
lea    -0x1(%r14),%eax
cvtsi2sd %eax,%xmm0
mulsd  0xe5f(%rip),%xmm0
mov    %r14d,%edi
mov    %rbx,%rsi
call   1080 <nthd@plt>
movsd  %xmm0,(%rsp)
mov    %rbx,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
mov    %r14d,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [46 x i8] c"Cannot allocate a in doublequartile, ndat=%d\0A\00"
define double @doublequartile0(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
store i32 %0, i32* %3
store double* %1, double** %4
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = mul i64 8, %8
%10 = trunc i64 %9 to i32
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %5
%13 = icmp eq double* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* %3
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %2
%20 = load double*, double** %5
%21 = load double*, double** %4
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = mul i64 8, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @memcpy(double* %20, double* %21, i32 %25)
%27 = load i32, i32* %3
%28 = load double*, double** %5
%29 = load i32, i32* %3
%30 = sub nsw i32 %29, 1
%31 = sitofp i32 %30 to double
%32 = fmul double %31, 2.500000e-01
%33 = call double @nthd(i32 %27, double* %28, double %32)
store double %33, double* %6
%34 = load double*, double** %5
%35 = call i32 @free(double* %34)
%36 = load double, double* %6
ret double %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [46 x i8] c"Cannot allocate a in doublequartile, ndat=%d\0A\00"
define double @doublequartile0(i32 %0, double* %1) {
%3 = shl i32 %0, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to double*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %0)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = tail call i32 @memcpy(double* %5, double* %1, i32 %3)
%13 = add nsw i32 %0, -1
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 2.500000e-01
%16 = tail call double @nthd(i32 %0, double* %5, double %15)
%17 = tail call i32 @free(double* %5)
ret double %16
}