#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);
double position_to_logscale(double, double, double);
int round(double);
double position_to_logscale_with_steps(double pos, double lower, double upper,
                                       uint32_t steps) {
  assert(steps > 1);
  double p = round(pos * (steps - 1.0)) / (steps - 1.0);
  return position_to_logscale(p, lower, upper);
}


x86 assembly (clang, -O0):
<position_to_logscale_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   1030 <assert@plt>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe93(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1050 <round@plt>
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
movsd  0xe75(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1040 <position_to_logscale@plt>
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define double @position_to_logscale_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 i32, i32* %8
%16 = sitofp i32 %15 to double
%17 = fsub double %16, 1.000000e+00
%18 = fmul double %14, %17
%19 = call i32 @round(double %18)
%20 = sitofp i32 %19 to double
%21 = load i32, i32* %8
%22 = sitofp i32 %21 to double
%23 = fsub double %22, 1.000000e+00
%24 = fdiv double %20, %23
store double %24, double* %9
%25 = load double, double* %9
%26 = load double, double* %6
%27 = load double, double* %7
%28 = call double @position_to_logscale(double %25, double %26, double %27)
ret double %28
}

LLVM IR (-O2):
define double @position_to_logscale_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 = sitofp i32 %3 to double
%9 = fadd double %8, -1.000000e+00
%10 = fmul double %9, %0
%11 = tail call i32 @round(double %10)
%12 = sitofp i32 %11 to double
%13 = fdiv double %12, %9
%14 = tail call double @position_to_logscale(double %13, double %1, double %2)
ret double %14
}