#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 */
int floatToRawIntBits(float);
__attribute__((always_)) const int ilogbkf(float d) {
  int m = d < 5.421010862427522E-20f;
  d = m ? 1.8446744073709552E19f * d : d;
  int q = (floatToRawIntBits(d) >> 23) & 0xff;
  q = m ? q - (64 + 0x7f) : q - 0x7f;
  return q;
}


x86 assembly (clang, -O0):
<ilogbkf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xedb(%rip),%xmm0
ucomiss -0x4(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1155 <ilogbkf+0x45>
movss  0xebe(%rip),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    115f <ilogbkf+0x4f>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <floatToRawIntBits@plt>
sar    $0x17,%eax
and    $0xff,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1198 <ilogbkf+0x88>
mov    -0xc(%rbp),%eax
sub    $0xbf,%eax
mov    %eax,-0x14(%rbp)
jmp    11a1 <ilogbkf+0x91>
mov    -0xc(%rbp),%eax
sub    $0x7f,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ilogbkf>:
push   %rbx
movss  0xee7(%rip),%xmm2
xor    %ebx,%ebx
ucomiss %xmm0,%xmm2
setbe  %bl
movss  0xedb(%rip),%xmm3
mulss  %xmm0,%xmm3
movaps %xmm0,%xmm1
cmpltss %xmm2,%xmm1
andps  %xmm1,%xmm3
andnps %xmm0,%xmm1
orps   %xmm3,%xmm1
movaps %xmm1,%xmm0
call   1030 <floatToRawIntBits@plt>
shr    $0x17,%eax
movzbl %al,%eax
shl    $0x6,%ebx
add    %ebx,%eax
add    $0xffffff41,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ilogbkf(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
store float %0, float* %2
%5 = load float, float* %2
%6 = fcmp olt float %5, 0x3BF0000000000000
%7 = zext i1 %6 to i32
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load float, float* %2
%12 = fmul float 0x43F0000000000000, %11
br label %15
13: ; preds = %1
%14 = load float, float* %2
br label %15
15: ; preds = %13, %10
%16 = phi float [ %12, %10 ], [ %14, %13 ]
store float %16, float* %2
%17 = load float, float* %2
%18 = call i32 @floatToRawIntBits(float %17)
%19 = ashr i32 %18, 23
%20 = and i32 %19, 255
store i32 %20, i32* %4
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* %4
%25 = sub nsw i32 %24, 191
br label %29
26: ; preds = %15
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 127
br label %29
29: ; preds = %26, %23
%30 = phi i32 [ %25, %23 ], [ %28, %26 ]
store i32 %30, i32* %4
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @ilogbkf(float %0) {
%2 = fcmp olt float %0, 0x3BF0000000000000
%3 = fmul float %0, 0x43F0000000000000
%4 = select i1 %2, float %3, float %0
%5 = tail call i32 @floatToRawIntBits(float %4)
%6 = lshr i32 %5, 23
%7 = and i32 %6, 255
%8 = select i1 %2, i32 -191, i32 -127
%9 = add nsw i32 %7, %8
ret i32 %9
}