#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;
  t = drand48();
  if (t > 0.5) {
    retval = log(1.0 - (2.0 * (162754.79141900392083592475 - 1) * (t - 0.5) /
                        162754.79141900392083592475)) /
             12.0;
  } else {
    retval = -log(1.0 - (2.0 * (162754.79141900392083592475 - 1) * t /
                         162754.79141900392083592475)) /
             12.0;
  }
  retval = (retval + 1.0) * (max - min) / 2.0;
  retval = retval + min;
  return retval;
}


x86 assembly (clang, -O0):
<median>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a8 <median+0x88>
movsd  -0x20(%rbp),%xmm0
movsd  0xe9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeaf(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xe9b(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe87(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  0xe6e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11fa <median+0xda>
movsd  0xe70(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe5b(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe47(%rip),%xmm0
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe17(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe0e(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe0b(%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    $0x30,%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
addsd  0xe9b(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
subsd  %xmm1,%xmm2
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
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
%9 = call double (...) @drand48()
store double %9, double* %7
%10 = load double, double* %7
%11 = fcmp ogt double %10, 5.000000e-01
br i1 %11, label %12, label %20
12: ; preds = %3
%13 = load double, double* %7
%14 = fsub double %13, 5.000000e-01
%15 = fmul double 0x4113DE0E54D37C9A, %14
%16 = fdiv double %15, 0x4103DE1654D37C9A
%17 = fsub double 1.000000e+00, %16
%18 = call double @log(double %17)
%19 = fdiv double %18, 1.200000e+01
store double %19, double* %8
br label %28
20: ; preds = %3
%21 = load double, double* %7
%22 = fmul double 0x4113DE0E54D37C9A, %21
%23 = fdiv double %22, 0x4103DE1654D37C9A
%24 = fsub double 1.000000e+00, %23
%25 = call double @log(double %24)
%26 = fneg double %25
%27 = fdiv double %26, 1.200000e+01
store double %27, double* %8
br label %28
28: ; preds = %20, %12
%29 = load double, double* %8
%30 = fadd double %29, 1.000000e+00
%31 = load double, double* %5
%32 = load double, double* %4
%33 = fsub double %31, %32
%34 = fmul double %30, %33
%35 = fdiv double %34, 2.000000e+00
store double %35, double* %8
%36 = load double, double* %8
%37 = load double, double* %4
%38 = fadd double %36, %37
store double %38, double* %8
%39 = load double, double* %8
ret double %39
}

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 = fadd double %13, 1.000000e+00
%15 = fsub double %1, %0
%16 = fmul double %15, %14
%17 = fmul double %16, 5.000000e-01
%18 = fadd double %17, %0
ret double %18
}