#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int logscale_to_position(double, double, double);
int round(double);
double logscale_to_position_with_steps(double val, double lower, double upper,
                                       uint32_t steps) {
  assert(steps > 1);
  double v = logscale_to_position(val, lower, upper) * (steps - 1.0);
  return round(v) / (steps - 1.0);
}


x86 assembly (clang, -O0):
<logscale_to_position_with_steps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <logscale_to_position@plt>
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe80(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <round@plt>
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe58(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logscale_to_position_with_steps>:
push   %rbx
sub    $0x20,%rsp
mov    %edi,%ebx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
cmp    $0x2,%ebx
setge  %dil
call   1040 <assert@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
call   1030 <logscale_to_position@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd  0xe7c(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm0
call   1050 <round@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0x8(%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @logscale_to_position_with_steps(double %0, double %1, double %2, i32 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = icmp sgt i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load double, double* %5
%15 = load double, double* %6
%16 = load double, double* %7
%17 = call i32 @logscale_to_position(double %14, double %15, double %16)
%18 = sitofp i32 %17 to double
%19 = load i32, i32* %8
%20 = sitofp i32 %19 to double
%21 = fsub double %20, 1.000000e+00
%22 = fmul double %18, %21
store double %22, double* %9
%23 = load double, double* %9
%24 = call i32 @round(double %23)
%25 = sitofp i32 %24 to double
%26 = load i32, i32* %8
%27 = sitofp i32 %26 to double
%28 = fsub double %27, 1.000000e+00
%29 = fdiv double %25, %28
ret double %29
}

LLVM IR (-O2):
define double @logscale_to_position_with_steps(double %0, double %1, double %2, i32 %3) {
%5 = icmp sgt i32 %3, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @logscale_to_position(double %0, double %1, double %2)
%9 = sitofp i32 %8 to double
%10 = sitofp i32 %3 to double
%11 = fadd double %10, -1.000000e+00
%12 = fmul double %11, %9
%13 = tail call i32 @round(double %12)
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, %11
ret double %15
}