#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 FLT_EPSILON;
scalar_t__ ceil(double);
double round(double);
unsigned int getAuditoryBandLen(const unsigned int xLen, double avgBW) {
  unsigned int a = 3;
  if (avgBW < FLT_EPSILON)
    return xLen;
  double step = avgBW;
  unsigned int cnt = 0;
  while (a + step - 1.0 < xLen) {
    a = a + (unsigned int)ceil(round(step) * 0.5);
    step = step * avgBW;
    cnt = cnt + 1;
  }
  return (cnt > (xLen >> 1)) ? xLen : cnt;
}


x86 assembly (clang, -O0):
<getAuditoryBandLen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm1
mov    0x2e9d(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    115c <getAuditoryBandLen+0x3c>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120d <getAuditoryBandLen+0xed>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
cvtsi2sd %rax,%xmm1
movsd  -0x20(%rbp),%xmm0
addsd  %xmm0,%xmm1
movsd  0xe7a(%rip),%xmm0
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%eax
cvtsi2sd %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    11e5 <getAuditoryBandLen+0xc5>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <round@plt>
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116d <getAuditoryBandLen+0x4d>
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x1,%ecx
cmp    %ecx,%eax
jbe    1201 <getAuditoryBandLen+0xe1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1207 <getAuditoryBandLen+0xe7>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getAuditoryBandLen>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
mov    0x2eae(%rip),%rax
movsd  (%rax),%xmm1
movsd  %xmm0,0x8(%rsp)
ucomisd %xmm0,%xmm1
ja     11e4 <getAuditoryBandLen+0xc4>
mov    %r14d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
movsd  0xea7(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
addsd  0xea1(%rip),%xmm0
xor    %ebp,%ebp
ucomisd %xmm0,%xmm1
jbe    11d9 <getAuditoryBandLen+0xb9>
mov    $0x3,%ebx
xor    %ebp,%ebp
movsd  0x8(%rsp),%xmm0
movsd  %xmm1,0x10(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x18(%rsp)
call   1040 <round@plt>
mulsd  0xe6d(%rip),%xmm0
call   1030 <ceil@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
add    %eax,%ebx
mulsd  0x8(%rsp),%xmm0
add    $0x1,%ebp
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
addsd  %xmm0,%xmm2
addsd  0xe35(%rip),%xmm2
ucomisd %xmm2,%xmm1
ja     1190 <getAuditoryBandLen+0x70>
mov    %r14d,%eax
shr    %eax
cmp    %eax,%ebp
cmovbe %ebp,%r14d
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@FLT_EPSILON = global double 0.000000e+00
define i32 @getAuditoryBandLen(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
store i32 %0, i32* %4
store double %1, double* %5
store i32 3, i32* %6
%9 = load double, double* %5
%10 = load double, double* @FLT_EPSILON
%11 = fcmp olt double %9, %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* %4
store i32 %13, i32* %3
br label %49
14: ; preds = %2
%15 = load double, double* %5
store double %15, double* %7
store i32 0, i32* %8
br label %16
16: ; preds = %25, %14
%17 = load i32, i32* %6
%18 = uitofp i32 %17 to double
%19 = load double, double* %7
%20 = fadd double %18, %19
%21 = fsub double %20, 1.000000e+00
%22 = load i32, i32* %4
%23 = uitofp i32 %22 to double
%24 = fcmp olt double %21, %23
br i1 %24, label %25, label %38
25: ; preds = %16
%26 = load i32, i32* %6
%27 = load double, double* %7
%28 = call double @llvm.round.f64(double %27)
%29 = fmul double %28, 5.000000e-01
%30 = call i64 @ceil(double %29)
%31 = trunc i64 %30 to i32
%32 = add i32 %26, %31
store i32 %32, i32* %6
%33 = load double, double* %7
%34 = load double, double* %5
%35 = fmul double %33, %34
store double %35, double* %7
%36 = load i32, i32* %8
%37 = add i32 %36, 1
store i32 %37, i32* %8
br label %16
38: ; preds = %16
%39 = load i32, i32* %8
%40 = load i32, i32* %4
%41 = lshr i32 %40, 1
%42 = icmp ugt i32 %39, %41
br i1 %42, label %43, label %45
43: ; preds = %38
%44 = load i32, i32* %4
br label %47
45: ; preds = %38
%46 = load i32, i32* %8
br label %47
47: ; preds = %45, %43
%48 = phi i32 [ %44, %43 ], [ %46, %45 ]
store i32 %48, i32* %3
br label %49
49: ; preds = %47, %12
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@FLT_EPSILON = global double 0.000000e+00
define i32 @getAuditoryBandLen(i32 %0, double %1) {
%3 = load double, double* @FLT_EPSILON
%4 = fcmp ogt double %3, %1
br i1 %4, label %30, label %5
5: ; preds = %2
%6 = uitofp i32 %0 to double
%7 = fadd double %1, 3.000000e+00
%8 = fadd double %7, -1.000000e+00
%9 = fcmp olt double %8, %6
br i1 %9, label %10, label %25
10: ; preds = %5, %10
%11 = phi i32 [ %20, %10 ], [ 0, %5 ]
%12 = phi double [ %19, %10 ], [ %1, %5 ]
%13 = phi i32 [ %18, %10 ], [ 3, %5 ]
%14 = tail call double @llvm.round.f64(double %12)
%15 = fmul double %14, 5.000000e-01
%16 = tail call i64 @ceil(double %15)
%17 = trunc i64 %16 to i32
%18 = add i32 %13, %17
%19 = fmul double %12, %1
%20 = add i32 %11, 1
%21 = uitofp i32 %18 to double
%22 = fadd double %19, %21
%23 = fadd double %22, -1.000000e+00
%24 = fcmp olt double %23, %6
br i1 %24, label %10, label %25
25: ; preds = %10, %5
%26 = phi i32 [ 0, %5 ], [ %20, %10 ]
%27 = lshr i32 %0, 1
%28 = icmp ugt i32 %26, %27
%29 = select i1 %28, i32 %0, i32 %26
br label %30
30: ; preds = %2, %25
%31 = phi i32 [ %29, %25 ], [ %0, %2 ]
ret i32 %31
}