#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 _lsx_set_dft_length(int num_taps) {
  int min = 10;
  double d = log((double)num_taps) / log(2.);
  return 1 << ((
             ((((((int)(d + 2.77)) > (min)) ? ((int)(d + 2.77)) : (min))) <
              (((((int)(d + 1.77)) > (17)) ? ((int)(d + 1.77)) : (17))))
                 ? (((((int)(d + 2.77)) > (min)) ? ((int)(d + 2.77)) : (min)))
                 : (((((int)(d + 1.77)) > (17)) ? ((int)(d + 1.77)) : (17)))));
}


x86 assembly (clang, -O0):
<_lsx_set_dft_length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  %xmm0,-0x18(%rbp)
mov    $0x2,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xea8(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cmp    -0x8(%rbp),%eax
jle    1183 <_lsx_set_dft_length+0x73>
movsd  0xe8e(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
jmp    1189 <_lsx_set_dft_length+0x79>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
movsd  0xe71(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x11,%eax
jle    11c2 <_lsx_set_dft_length+0xb2>
movsd  0xe57(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
jmp    11cf <_lsx_set_dft_length+0xbf>
mov    $0x11,%eax
mov    %eax,-0x24(%rbp)
jmp    11cf <_lsx_set_dft_length+0xbf>
mov    -0x20(%rbp),%eax
mov    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1221 <_lsx_set_dft_length+0x111>
movsd  0xe1b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cmp    -0x8(%rbp),%eax
jle    1210 <_lsx_set_dft_length+0x100>
movsd  0xe01(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x28(%rbp)
jmp    1216 <_lsx_set_dft_length+0x106>
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1267 <_lsx_set_dft_length+0x157>
movsd  0xddf(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
cmp    $0x11,%eax
jle    1254 <_lsx_set_dft_length+0x144>
movsd  0xdc5(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
jmp    1261 <_lsx_set_dft_length+0x151>
mov    $0x11,%eax
mov    %eax,-0x30(%rbp)
jmp    1261 <_lsx_set_dft_length+0x151>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_lsx_set_dft_length>:
sub    $0x18,%rsp
call   1030 <log@plt>
movapd %xmm0,(%rsp)
mov    $0x2,%edi
call   1030 <log@plt>
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
unpcklpd %xmm1,%xmm1
addpd  0xec3(%rip),%xmm1
cvttpd2dq %xmm1,%xmm0
movdqa 0xec7(%rip),%xmm1
movapd %xmm0,%xmm2
pcmpgtd %xmm1,%xmm2
andpd  %xmm2,%xmm0
pandn  %xmm1,%xmm2
por    %xmm0,%xmm2
movd   %xmm2,%eax
pshufd $0x55,%xmm2,%xmm0
movd   %xmm0,%ecx
cmp    %ecx,%eax
cmovb  %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @_lsx_set_dft_length(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
store i32 %0, i32* %2
store i32 10, i32* %3
%5 = load i32, i32* %2
%6 = sitofp i32 %5 to double
%7 = fptosi double %6 to i32
%8 = call double @log(i32 %7)
%9 = call double @log(i32 2)
%10 = fdiv double %8, %9
store double %10, double* %4
%11 = load double, double* %4
%12 = fadd double %11, 2.770000e+00
%13 = fptosi double %12 to i32
%14 = load i32, i32* %3
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %1
%17 = load double, double* %4
%18 = fadd double %17, 2.770000e+00
%19 = fptosi double %18 to i32
br label %22
20: ; preds = %1
%21 = load i32, i32* %3
br label %22
22: ; preds = %20, %16
%23 = phi i32 [ %19, %16 ], [ %21, %20 ]
%24 = load double, double* %4
%25 = fadd double %24, 1.770000e+00
%26 = fptosi double %25 to i32
%27 = icmp sgt i32 %26, 17
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load double, double* %4
%30 = fadd double %29, 1.770000e+00
%31 = fptosi double %30 to i32
br label %33
32: ; preds = %22
br label %33
33: ; preds = %32, %28
%34 = phi i32 [ %31, %28 ], [ 17, %32 ]
%35 = icmp slt i32 %23, %34
br i1 %35, label %36, label %50
36: ; preds = %33
%37 = load double, double* %4
%38 = fadd double %37, 2.770000e+00
%39 = fptosi double %38 to i32
%40 = load i32, i32* %3
%41 = icmp sgt i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load double, double* %4
%44 = fadd double %43, 2.770000e+00
%45 = fptosi double %44 to i32
br label %48
46: ; preds = %36
%47 = load i32, i32* %3
br label %48
48: ; preds = %46, %42
%49 = phi i32 [ %45, %42 ], [ %47, %46 ]
br label %62
50: ; preds = %33
%51 = load double, double* %4
%52 = fadd double %51, 1.770000e+00
%53 = fptosi double %52 to i32
%54 = icmp sgt i32 %53, 17
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load double, double* %4
%57 = fadd double %56, 1.770000e+00
%58 = fptosi double %57 to i32
br label %60
59: ; preds = %50
br label %60
60: ; preds = %59, %55
%61 = phi i32 [ %58, %55 ], [ 17, %59 ]
br label %62
62: ; preds = %60, %48
%63 = phi i32 [ %49, %48 ], [ %61, %60 ]
%64 = shl i32 1, %63
ret i32 %64
}

LLVM IR (-O2):
define i32 @_lsx_set_dft_length(i32 %0) {
%2 = tail call double @log(i32 %0)
%3 = tail call double @log(i32 2)
%4 = fdiv double %2, %3
%5 = insertelement <2 x double> poison, double %4, i64 0
%6 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> zeroinitializer
%7 = fadd <2 x double> %6, <double 2.770000e+00, double 1.770000e+00>
%8 = fptosi <2 x double> %7 to <2 x i32>
%9 = icmp sgt <2 x i32> %8, <i32 10, i32 17>
%10 = select <2 x i1> %9, <2 x i32> %8, <2 x i32> <i32 10, i32 17>
%11 = extractelement <2 x i32> %10, i64 0
%12 = extractelement <2 x i32> %10, i64 1
%13 = icmp ult i32 %11, %12
%14 = select i1 %13, i32 %11, i32 %12
%15 = shl nuw i32 1, %14
ret i32 %15
}