#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*/ assert(int);
double log(double);
double logscale_to_position(double val, double lower, double upper) {
  assert(upper > lower && lower * upper > 0);
  assert(val >= lower && val <= upper);
  return log(val / lower) / log(upper / lower);
}


x86 assembly (clang, -O0):
<logscale_to_position>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x19(%rbp)
jbe    1163 <logscale_to_position+0x43>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
xor    %eax,%eax
ucomisd -0x10(%rbp),%xmm0
mov    %al,-0x1a(%rbp)
jb     1199 <logscale_to_position+0x79>
movsd  -0x8(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logscale_to_position>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm1,%xmm2
seta   %al
movapd %xmm1,%xmm0
mulsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  (%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
setae  %al
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
setae  %cl
and    %al,%cl
movzbl %cl,%edi
call   1030 <assert@plt>
movsd  (%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
call   1040 <log@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @logscale_to_position(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %6
%8 = load double, double* %5
%9 = fcmp ogt double %7, %8
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load double, double* %5
%12 = load double, double* %6
%13 = fmul double %11, %12
%14 = fcmp ogt double %13, 0.000000e+00
br label %15
15: ; preds = %10, %3
%16 = phi i1 [ false, %3 ], [ %14, %10 ]
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load double, double* %4
%20 = load double, double* %5
%21 = fcmp oge double %19, %20
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load double, double* %4
%24 = load double, double* %6
%25 = fcmp ole double %23, %24
br label %26
26: ; preds = %22, %15
%27 = phi i1 [ false, %15 ], [ %25, %22 ]
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load double, double* %4
%31 = load double, double* %5
%32 = fdiv double %30, %31
%33 = call double @log(double %32)
%34 = load double, double* %6
%35 = load double, double* %5
%36 = fdiv double %34, %35
%37 = call double @log(double %36)
%38 = fdiv double %33, %37
ret double %38
}

LLVM IR (-O2):
define double @logscale_to_position(double %0, double %1, double %2) {
%4 = fcmp ogt double %2, %1
%5 = fmul double %1, %2
%6 = fcmp ogt double %5, 0.000000e+00
%7 = and i1 %4, %6
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = fcmp oge double %0, %1
%11 = fcmp ole double %0, %2
%12 = and i1 %10, %11
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = fdiv double %0, %1
%16 = tail call double @log(double %15)
%17 = fdiv double %2, %1
%18 = tail call double @log(double %17)
%19 = fdiv double %16, %18
ret double %19
}