#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 log(int);
int /*<<< orphan*/ max(int, int);
int range_limit(int, int, int /*<<< orphan*/);
int set_dft_length(int num_taps, int min, int large) {
  double d = log((double)num_taps) / log(2.);
  return 1 << range_limit((int)(d + 2.77), min, max((int)(d + 1.77), large));
}


x86 assembly (clang, -O0):
<set_dft_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
movsd  %xmm0,-0x28(%rbp)
mov    $0x2,%edi
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe91(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsd  0xe6f(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0xc(%rbp),%esi
call   1030 <max@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
call   1040 <range_limit@plt>
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dft_length>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%r14d
call   1050 <log@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x2,%edi
call   1050 <log@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0xe9c(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebp
addsd  0xe94(%rip),%xmm1
cvttsd2si %xmm1,%edi
mov    %ebx,%esi
call   1030 <max@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   1040 <range_limit@plt>
mov    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @set_dft_length(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = fptosi double %9 to i32
%11 = call double @log(i32 %10)
%12 = call double @log(i32 2)
%13 = fdiv double %11, %12
store double %13, double* %7
%14 = load double, double* %7
%15 = fadd double %14, 2.770000e+00
%16 = fptosi double %15 to i32
%17 = load i32, i32* %5
%18 = load double, double* %7
%19 = fadd double %18, 1.770000e+00
%20 = fptosi double %19 to i32
%21 = load i32, i32* %6
%22 = call i32 @max(i32 %20, i32 %21)
%23 = call i32 @range_limit(i32 %16, i32 %17, i32 %22)
%24 = shl i32 1, %23
ret i32 %24
}

LLVM IR (-O2):
define i32 @set_dft_length(i32 %0, i32 %1, i32 %2) {
%4 = tail call double @log(i32 %0)
%5 = tail call double @log(i32 2)
%6 = fdiv double %4, %5
%7 = fadd double %6, 2.770000e+00
%8 = fptosi double %7 to i32
%9 = fadd double %6, 1.770000e+00
%10 = fptosi double %9 to i32
%11 = tail call i32 @max(i32 %10, i32 %2)
%12 = tail call i32 @range_limit(i32 %8, i32 %1, i32 %11)
%13 = shl nuw i32 1, %12
ret i32 %13
}