#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 */
float ceil(int);
int log2(int);
int sqrt(float);
int fa_get_start_common_scalefac(float max_mdct_line) {
  int start_common_scalefac;
  float tmp;
  if (max_mdct_line == 0.)
    return 0;
  tmp = ceil(16. / 3 *
             ((log2(((sqrt(max_mdct_line * (sqrt(max_mdct_line))))) / 8191))));
  start_common_scalefac = (int)tmp;
  start_common_scalefac =
      ((start_common_scalefac) < (255) ? (start_common_scalefac) : (255));
  start_common_scalefac =
      ((start_common_scalefac) > (0) ? (start_common_scalefac) : (0));
  return start_common_scalefac;
}


x86 assembly (clang, -O0):
<fa_get_start_common_scalefac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1165 <fa_get_start_common_scalefac+0x35>
jp     1165 <fa_get_start_common_scalefac+0x35>
movl   $0x0,-0x4(%rbp)
jmp    1216 <fa_get_start_common_scalefac+0xe6>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
call   1050 <sqrt@plt>
movss  -0x14(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
call   1050 <sqrt@plt>
mov    $0x1fff,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <log2@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe5a(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <ceil@plt>
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jge    11d8 <fa_get_start_common_scalefac+0xa8>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11e5 <fa_get_start_common_scalefac+0xb5>
mov    $0xff,%eax
mov    %eax,-0x18(%rbp)
jmp    11e5 <fa_get_start_common_scalefac+0xb5>
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1200 <fa_get_start_common_scalefac+0xd0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    120a <fa_get_start_common_scalefac+0xda>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    120a <fa_get_start_common_scalefac+0xda>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_get_start_common_scalefac>:
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113d <fa_get_start_common_scalefac+0xd>
jp     113d <fa_get_start_common_scalefac+0xd>
ret
push   %rax
movss  %xmm0,0x4(%rsp)
call   1050 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x4(%rsp),%xmm0
call   1050 <sqrt@plt>
movslq %eax,%rdi
imul   $0xffffffff80040021,%rdi,%rax
shr    $0x20,%rax
add    %eax,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0xc,%edi
add    %eax,%edi
call   1030 <log2@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe77(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <ceil@plt>
cvttss2si %xmm0,%eax
cmp    $0xff,%eax
mov    $0xff,%ecx
cmovl  %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @fa_get_start_common_scalefac(float %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca i32
%5 = alloca float
store float %0, float* %3
%6 = load float, float* %3
%7 = fpext float %6 to double
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %40
10: ; preds = %1
%11 = load float, float* %3
%12 = load float, float* %3
%13 = call i32 @sqrt(float %12)
%14 = sitofp i32 %13 to float
%15 = fmul float %11, %14
%16 = call i32 @sqrt(float %15)
%17 = sdiv i32 %16, 8191
%18 = call i32 @log2(i32 %17)
%19 = sitofp i32 %18 to double
%20 = fmul double 0x4015555555555555, %19
%21 = fptosi double %20 to i32
%22 = call float @ceil(i32 %21)
store float %22, float* %5
%23 = load float, float* %5
%24 = fptosi float %23 to i32
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 255
br i1 %26, label %27, label %29
27: ; preds = %10
%28 = load i32, i32* %4
br label %30
29: ; preds = %10
br label %30
30: ; preds = %29, %27
%31 = phi i32 [ %28, %27 ], [ 255, %29 ]
store i32 %31, i32* %4
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = load i32, i32* %4
br label %37
36: ; preds = %30
br label %37
37: ; preds = %36, %34
%38 = phi i32 [ %35, %34 ], [ 0, %36 ]
store i32 %38, i32* %4
%39 = load i32, i32* %4
store i32 %39, i32* %2
br label %40
40: ; preds = %37, %9
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
define i32 @fa_get_start_common_scalefac(float %0) {
%2 = fcmp oeq float %0, 0.000000e+00
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @sqrt(float %0)
%5 = sitofp i32 %4 to float
%6 = fmul float %5, %0
%7 = tail call i32 @sqrt(float %6)
%8 = sdiv i32 %7, 8191
%9 = tail call i32 @log2(i32 %8)
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 0x4015555555555555
%12 = fptosi double %11 to i32
%13 = tail call float @ceil(i32 %12)
%14 = fptosi float %13 to i32
%15 = icmp slt i32 %14, 255
%16 = select i1 %15, i32 %14, i32 255
%17 = icmp sgt i32 %16, 0
%18 = select i1 %17, i32 %16, i32 0
br label %19
19: ; preds = %1, %3
%20 = phi i32 [ %18, %3 ], [ 0, %1 ]
ret i32 %20
}