#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 drand48();
double log(double);
double median(double min, double max, int n) {
  double t;
  double retval;
  double tmp;
  double tmp___0;
  double __cil_tmp8;
  double __cil_tmp9;
  double __cil_tmp10;
  double __cil_tmp11;
  double __cil_tmp12;
  double __cil_tmp13;
  double __cil_tmp14;
  double __cil_tmp15;
  double __cil_tmp16;
  double __cil_tmp17;
  double __cil_tmp18;
  double __cil_tmp19;
  double __cil_tmp20;
  double __cil_tmp21;
  double __cil_tmp22;
  double __cil_tmp23;
  double __cil_tmp24;
  {
    { t = drand48(); }
    if (t > 0.5) {
      {
        __cil_tmp8 = t - 0.5;
        __cil_tmp9 = (double)1;
        __cil_tmp10 = 162754.79141900392083592475 - __cil_tmp9;
        __cil_tmp11 = 2.0 * __cil_tmp10;
        __cil_tmp12 = __cil_tmp11 * __cil_tmp8;
        __cil_tmp13 = __cil_tmp12 / 162754.79141900392083592475;
        __cil_tmp14 = 1.0 - __cil_tmp13;
        tmp = log(__cil_tmp14);
        retval = tmp / 12.0;
      }
    } else {
      {
        __cil_tmp15 = (double)1;
        __cil_tmp16 = 162754.79141900392083592475 - __cil_tmp15;
        __cil_tmp17 = 2.0 * __cil_tmp16;
        __cil_tmp18 = __cil_tmp17 * t;
        __cil_tmp19 = __cil_tmp18 / 162754.79141900392083592475;
        __cil_tmp20 = 1.0 - __cil_tmp19;
        tmp___0 = log(__cil_tmp20);
        __cil_tmp21 = -tmp___0;
        retval = __cil_tmp21 / 12.0;
      }
    }
    __cil_tmp22 = max - min;
    __cil_tmp23 = retval + 1.0;
    __cil_tmp24 = __cil_tmp23 * __cil_tmp22;
    retval = __cil_tmp24 / 2.0;
    retval = retval + min;
    return (retval);
  }
}


x86 assembly (clang, -O0):
<median>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    $0x0,%al
call   1040 <drand48@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xeaf(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1203 <median+0xe3>
movsd  -0x20(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe92(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe88(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe41(%rip),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    12cf <median+0x1af>
movsd  0xe05(%rip),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xe00(%rip),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xdf6(%rip),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xdbc(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  0xda0(%rip),%xmm0
subsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
call   1030 <log@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  0xd42(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  0xd27(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movsd  0xd02(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<median>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <drand48@plt>
xor    %ebx,%ebx
ucomisd 0xebd(%rip),%xmm0
seta   %bpl
jbe    1151 <median+0x31>
addsd  0xeb7(%rip),%xmm0
mulsd  0xeb7(%rip),%xmm0
divsd  0xeb7(%rip),%xmm0
addsd  0xeb7(%rip),%xmm0
call   1030 <log@plt>
mov    %bpl,%bl
lea    0xeb0(%rip),%rax
divsd  (%rax,%rbx,8),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
addsd  0xe8b(%rip),%xmm0
mulsd  %xmm2,%xmm0
mulsd  0xe5f(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @median(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
%28 = call double (...) @drand48()
store double %28, double* %7
%29 = load double, double* %7
%30 = fcmp ogt double %29, 5.000000e-01
br i1 %30, label %31, label %49
31: ; preds = %3
%32 = load double, double* %7
%33 = fsub double %32, 5.000000e-01
store double %33, double* %11
store double 1.000000e+00, double* %12
%34 = load double, double* %12
%35 = fsub double 0x4103DE1654D37C9A, %34
store double %35, double* %13
%36 = load double, double* %13
%37 = fmul double 2.000000e+00, %36
store double %37, double* %14
%38 = load double, double* %14
%39 = load double, double* %11
%40 = fmul double %38, %39
store double %40, double* %15
%41 = load double, double* %15
%42 = fdiv double %41, 0x4103DE1654D37C9A
store double %42, double* %16
%43 = load double, double* %16
%44 = fsub double 1.000000e+00, %43
store double %44, double* %17
%45 = load double, double* %17
%46 = call double @log(double %45)
store double %46, double* %9
%47 = load double, double* %9
%48 = fdiv double %47, 1.200000e+01
store double %48, double* %8
br label %67
49: ; preds = %3
store double 1.000000e+00, double* %18
%50 = load double, double* %18
%51 = fsub double 0x4103DE1654D37C9A, %50
store double %51, double* %19
%52 = load double, double* %19
%53 = fmul double 2.000000e+00, %52
store double %53, double* %20
%54 = load double, double* %20
%55 = load double, double* %7
%56 = fmul double %54, %55
store double %56, double* %21
%57 = load double, double* %21
%58 = fdiv double %57, 0x4103DE1654D37C9A
store double %58, double* %22
%59 = load double, double* %22
%60 = fsub double 1.000000e+00, %59
store double %60, double* %23
%61 = load double, double* %23
%62 = call double @log(double %61)
store double %62, double* %10
%63 = load double, double* %10
%64 = fneg double %63
store double %64, double* %24
%65 = load double, double* %24
%66 = fdiv double %65, 1.200000e+01
store double %66, double* %8
br label %67
67: ; preds = %49, %31
%68 = load double, double* %5
%69 = load double, double* %4
%70 = fsub double %68, %69
store double %70, double* %25
%71 = load double, double* %8
%72 = fadd double %71, 1.000000e+00
store double %72, double* %26
%73 = load double, double* %26
%74 = load double, double* %25
%75 = fmul double %73, %74
store double %75, double* %27
%76 = load double, double* %27
%77 = fdiv double %76, 2.000000e+00
store double %77, double* %8
%78 = load double, double* %8
%79 = load double, double* %4
%80 = fadd double %78, %79
store double %80, double* %8
%81 = load double, double* %8
ret double %81
}

LLVM IR (-O2):
define double @median(double %0, double %1, i32 %2) {
%4 = tail call double (...) @drand48()
%5 = fcmp ogt double %4, 5.000000e-01
%6 = fadd double %4, -5.000000e-01
%7 = select i1 %5, double %6, double %4
%8 = select i1 %5, double 1.200000e+01, double -1.200000e+01
%9 = fmul double %7, 0x4113DE0E54D37C9A
%10 = fdiv double %9, 0x4103DE1654D37C9A
%11 = fsub double 1.000000e+00, %10
%12 = tail call double @log(double %11)
%13 = fdiv double %12, %8
%14 = fsub double %1, %0
%15 = fadd double %13, 1.000000e+00
%16 = fmul double %14, %15
%17 = fmul double %16, 5.000000e-01
%18 = fadd double %17, %0
ret double %18
}