#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 FP_ILOGB0;
int FP_ILOGBNAN;
int INT_MAX;
int __approx_log2f(float);
scalar_t__ isinf(float);
scalar_t__ isnan(float);
int ilogbf(float x) {
  if (isnan(x))
    return FP_ILOGBNAN;
  if (isinf(x))
    return INT_MAX;
  if (!x)
    return FP_ILOGB0;
  return __approx_log2f(x);
}


x86 assembly (clang, -O0):
<ilogbf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1162 <ilogbf+0x32>
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <ilogbf+0x8c>
movss  -0x8(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     1187 <ilogbf+0x57>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <ilogbf+0x8c>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11af <ilogbf+0x7f>
jp     11af <ilogbf+0x7f>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bc <ilogbf+0x8c>
movss  -0x8(%rbp),%xmm0
call   1030 <__approx_log2f@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ilogbf>:
push   %rax
movss  %xmm0,0x4(%rsp)
call   1040 <isnan@plt>
test   %rax,%rax
je     114a <ilogbf+0x1a>
mov    0x2e88(%rip),%rax
jmp    1161 <ilogbf+0x31>
movss  0x4(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
je     1165 <ilogbf+0x35>
mov    0x2e87(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
xorps  %xmm0,%xmm0
movss  0x4(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jne    1175 <ilogbf+0x45>
jnp    1181 <ilogbf+0x51>
movss  0x4(%rsp),%xmm0
pop    %rax
jmp    1030 <__approx_log2f@plt>
mov    0x2e50(%rip),%rax
jmp    1161 <ilogbf+0x31>

LLVM IR (-O0):
@FP_ILOGBNAN = global i32 0
@INT_MAX = global i32 0
@FP_ILOGB0 = global i32 0
define i32 @ilogbf(float %0) {
%2 = alloca i32
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = call i64 @isnan(float %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i32, i32* @FP_ILOGBNAN
store i32 %8, i32* %2
br label %23
9: ; preds = %1
%10 = load float, float* %3
%11 = call i64 @isinf(float %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load i32, i32* @INT_MAX
store i32 %14, i32* %2
br label %23
15: ; preds = %9
%16 = load float, float* %3
%17 = fcmp une float %16, 0.000000e+00
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = load i32, i32* @FP_ILOGB0
store i32 %19, i32* %2
br label %23
20: ; preds = %15
%21 = load float, float* %3
%22 = call i32 @__approx_log2f(float %21)
store i32 %22, i32* %2
br label %23
23: ; preds = %20, %18, %13, %7
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
@FP_ILOGBNAN = global i32 0
@INT_MAX = global i32 0
@FP_ILOGB0 = global i32 0
define i32 @ilogbf(float %0) {
%2 = tail call i64 @isnan(float %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = load i32, i32* @FP_ILOGBNAN
br label %17
6: ; preds = %1
%7 = tail call i64 @isinf(float %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = load i32, i32* @INT_MAX
br label %17
11: ; preds = %6
%12 = fcmp une float %0, 0.000000e+00
br i1 %12, label %15, label %13
13: ; preds = %11
%14 = load i32, i32* @FP_ILOGB0
br label %17
15: ; preds = %11
%16 = tail call i32 @__approx_log2f(float %0)
br label %17
17: ; preds = %15, %13, %9, %4
%18 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %16, %15 ], [ %14, %13 ]
ret i32 %18
}