#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 CSPL_Array_quickselect(int, double *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  double dat1[5] = {20, 15, 35, 40, 50};
  double dat2[6] = {1, 2, 2, 6, 7, 8};
  long i;
  double a1;
  printf("dat1:\n");
  for (i = 0; i < 5; i++)
    printf("  %lf\n", dat1[i]);
  printf("dat2:\n");
  for (i = 0; i < 6; i++)
    printf("  %lf\n", dat2[i]);
  a1 = CSPL_Array_quickselect(0, dat1, 0, 4);
  printf("CSPL_Array_quickselect(0, dat1, 0, 4)=%lf\n", a1);
  a1 = CSPL_Array_quickselect(1, dat1, 0, 4);
  printf("CSPL_Array_quickselect(1, dat1, 0, 4)=%lf\n", a1);
  a1 = CSPL_Array_quickselect(2, dat1, 0, 4);
  printf("CSPL_Array_quickselect(2, dat1, 0, 4)=%lf\n", a1);
  a1 = CSPL_Array_quickselect(3, dat1, 0, 4);
  printf("CSPL_Array_quickselect(3, dat1, 0, 4)=%lf\n", a1);
  a1 = CSPL_Array_quickselect(4, dat1, 0, 4);
  printf("CSPL_Array_quickselect(4, dat1, 0, 4)=%lf\n", a1);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movsd  0xef1(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xedc(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec7(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9d(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1050 <memset@plt>
movsd  0xe78(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe63(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe56(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe17(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x68(%rbp)
cmpq   $0x5,-0x68(%rbp)
jge    1238 <main+0x108>
mov    -0x68(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1204 <main+0xd4>
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x68(%rbp)
cmpq   $0x6,-0x68(%rbp)
jge    1282 <main+0x152>
mov    -0x68(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
lea    0xded(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    124e <main+0x11e>
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
mov    $0x4,%ecx
mov    %edx,%edi
call   1030 <CSPL_Array_quickselect@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xdc0(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x1,%edi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xdbe(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x2,%edi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xdbc(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xdba(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x4,%ecx
xor    %edx,%edx
mov    %ecx,%edi
call   1030 <CSPL_Array_quickselect@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
lea    0xdbb(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x4049000000000000,%rax
mov    %rax,0x20(%rsp)
lea    0xfec(%rip),%rdi
call   1040 <puts@plt>
lea    0xf02(%rip),%rbx
movsd  0xeaa(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xea0(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe96(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe8c(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe82(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xf85(%rip),%rdi
call   1040 <puts@plt>
movsd  0xe6c(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe62(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rbx,%rdi
movsd  0xe4d(%rip),%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe46(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe3c(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xe32(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
lea    0xe1c(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
lea    0xe25(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x2,%edi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x3,%edi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
lea    0xe37(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x4,%edi
mov    %rbx,%rsi
xor    %edx,%edx
mov    $0x4,%ecx
call   1030 <CSPL_Array_quickselect@plt>
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"dat1:\0A\00"
@.str.1 = [7 x i8] c" %lf\0A\00"
@.str.2 = [7 x i8] c"dat2:\0A\00"
@.str.3 = [43 x i8] c"CSPL_Array_quickselect(0, dat1, 0, 4)=%lf\0A\00"
@.str.4 = [43 x i8] c"CSPL_Array_quickselect(1, dat1, 0, 4)=%lf\0A\00"
@.str.5 = [43 x i8] c"CSPL_Array_quickselect(2, dat1, 0, 4)=%lf\0A\00"
@.str.6 = [43 x i8] c"CSPL_Array_quickselect(3, dat1, 0, 4)=%lf\0A\00"
@.str.7 = [43 x i8] c"CSPL_Array_quickselect(4, dat1, 0, 4)=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x double]
%3 = alloca [6 x double]
%4 = alloca i64
%5 = alloca double
store i32 0, i32* %1
%6 = bitcast [5 x double]* %2 to i8*
%7 = bitcast i8* %6 to [5 x double]*
%8 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 0
store double 2.000000e+01, double* %8
%9 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 1
store double 1.500000e+01, double* %9
%10 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 2
store double 3.500000e+01, double* %10
%11 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 3
store double 4.000000e+01, double* %11
%12 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 4
store double 5.000000e+01, double* %12
%13 = bitcast [6 x double]* %3 to i8*
%14 = bitcast i8* %13 to [6 x double]*
%15 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 0
store double 1.000000e+00, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 1
store double 2.000000e+00, double* %16
%17 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 2
store double 2.000000e+00, double* %17
%18 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 3
store double 6.000000e+00, double* %18
%19 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 4
store double 7.000000e+00, double* %19
%20 = getelementptr inbounds [6 x double], [6 x double]* %14, i32 0, i32 5
store double 8.000000e+00, double* %20
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %4
br label %22
22: ; preds = %30, %0
%23 = load i64, i64* %4
%24 = icmp slt i64 %23, 5
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i64, i64* %4
%27 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 %26
%28 = load double, double* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %28)
br label %30
30: ; preds = %25
%31 = load i64, i64* %4
%32 = add nsw i64 %31, 1
store i64 %32, i64* %4
br label %22
33: ; preds = %22
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i64 0, i64* %4
br label %35
35: ; preds = %43, %33
%36 = load i64, i64* %4
%37 = icmp slt i64 %36, 6
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i64, i64* %4
%40 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 %39
%41 = load double, double* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %41)
br label %43
43: ; preds = %38
%44 = load i64, i64* %4
%45 = add nsw i64 %44, 1
store i64 %45, i64* %4
br label %35
46: ; preds = %35
%47 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%48 = call double @CSPL_Array_quickselect(i32 0, double* %47, i32 0, i32 4)
store double %48, double* %5
%49 = load double, double* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), double %49)
%51 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%52 = call double @CSPL_Array_quickselect(i32 1, double* %51, i32 0, i32 4)
store double %52, double* %5
%53 = load double, double* %5
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %53)
%55 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%56 = call double @CSPL_Array_quickselect(i32 2, double* %55, i32 0, i32 4)
store double %56, double* %5
%57 = load double, double* %5
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), double %57)
%59 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%60 = call double @CSPL_Array_quickselect(i32 3, double* %59, i32 0, i32 4)
store double %60, double* %5
%61 = load double, double* %5
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), double %61)
%63 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%64 = call double @CSPL_Array_quickselect(i32 4, double* %63, i32 0, i32 4)
store double %64, double* %5
%65 = load double, double* %5
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), double %65)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c" %lf\0A\00"
@.str.3 = [43 x i8] c"CSPL_Array_quickselect(0, dat1, 0, 4)=%lf\0A\00"
@.str.4 = [43 x i8] c"CSPL_Array_quickselect(1, dat1, 0, 4)=%lf\0A\00"
@.str.5 = [43 x i8] c"CSPL_Array_quickselect(2, dat1, 0, 4)=%lf\0A\00"
@.str.6 = [43 x i8] c"CSPL_Array_quickselect(3, dat1, 0, 4)=%lf\0A\00"
@.str.7 = [43 x i8] c"CSPL_Array_quickselect(4, dat1, 0, 4)=%lf\0A\00"
@str = [6 x i8] c"dat1:\00"
@str.8 = [6 x i8] c"dat2:\00"
define i32 @main() {
%1 = alloca [5 x double]
%2 = bitcast [5 x double]* %1 to i8*
%3 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 0
%4 = bitcast [5 x double]* %1 to <2 x double>*
store <2 x double> <double 2.000000e+01, double 1.500000e+01>, <2 x double>* %4
%5 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 2
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 3.500000e+01, double 4.000000e+01>, <2 x double>* %6
%7 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 4
store double 5.000000e+01, double* %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+01)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 1.500000e+01)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 3.500000e+01)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 4.000000e+01)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 5.000000e+01)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.8, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+00)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+00)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 2.000000e+00)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 6.000000e+00)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 7.000000e+00)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double 8.000000e+00)
%21 = call double @CSPL_Array_quickselect(i32 0, double* %3, i32 0, i32 4)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), double %21)
%23 = call double @CSPL_Array_quickselect(i32 1, double* %3, i32 0, i32 4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), double %23)
%25 = call double @CSPL_Array_quickselect(i32 2, double* %3, i32 0, i32 4)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), double %25)
%27 = call double @CSPL_Array_quickselect(i32 3, double* %3, i32 0, i32 4)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), double %27)
%29 = call double @CSPL_Array_quickselect(i32 4, double* %3, i32 0, i32 4)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.7, i64 0, i64 0), double %29)
ret i32 0
}