#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 INT_MAX;
int /*<<< orphan*/ fabsfk(float);
int ilogbkf(int /*<<< orphan*/);
scalar_t__ xisinff(float);
scalar_t__ xisnanf(float);
__attribute__((visibility("default"))) const int xilogbf(float d) {
  int e = ilogbkf(fabsfk(d));
  e = d == 0.0f ? ((int)-2147483648) : e;
  e = xisnanf(d) ? ((int)2147483647) : e;
  e = xisinff(d) ? INT_MAX : e;
  return e;
}


x86 assembly (clang, -O0):
<xilogbf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <fabsfk@plt>
mov    %eax,%edi
call   1050 <ilogbkf@plt>
mov    %eax,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1185 <xilogbf+0x45>
jp     1185 <xilogbf+0x45>
mov    $0x80000000,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <xilogbf+0x4b>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1060 <xisnanf@plt>
cmp    $0x0,%rax
je     11b2 <xilogbf+0x72>
mov    $0x7fffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    11b8 <xilogbf+0x78>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <xisinff@plt>
cmp    $0x0,%rax
je     11e3 <xilogbf+0xa3>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11e9 <xilogbf+0xa9>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xilogbf>:
push   %rbp
push   %rbx
push   %rax
movss  %xmm0,0x4(%rsp)
call   1040 <fabsfk@plt>
mov    %eax,%edi
call   1050 <ilogbkf@plt>
xorps  %xmm1,%xmm1
movss  0x4(%rsp),%xmm0
ucomiss %xmm1,%xmm0
mov    $0x80000000,%ebp
cmovne %eax,%ebp
cmovp  %eax,%ebp
call   1060 <xisnanf@plt>
test   %rax,%rax
mov    $0x7fffffff,%ebx
cmove  %ebp,%ebx
movss  0x4(%rsp),%xmm0
call   1030 <xisinff@plt>
test   %rax,%rax
je     1195 <xilogbf+0x55>
mov    0x2e55(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @xilogbf(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = load float, float* %2
%5 = call i32 @fabsfk(float %4)
%6 = call i32 @ilogbkf(i32 %5)
store i32 %6, i32* %3
%7 = load float, float* %2
%8 = fcmp oeq float %7, 0.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %1
br label %12
10: ; preds = %1
%11 = load i32, i32* %3
br label %12
12: ; preds = %10, %9
%13 = phi i32 [ -2147483648, %9 ], [ %11, %10 ]
store i32 %13, i32* %3
%14 = load float, float* %2
%15 = call i64 @xisnanf(float %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
br label %20
18: ; preds = %12
%19 = load i32, i32* %3
br label %20
20: ; preds = %18, %17
%21 = phi i32 [ 2147483647, %17 ], [ %19, %18 ]
store i32 %21, i32* %3
%22 = load float, float* %2
%23 = call i64 @xisinff(float %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i32, i32* @INT_MAX
br label %29
27: ; preds = %20
%28 = load i32, i32* %3
br label %29
29: ; preds = %27, %25
%30 = phi i32 [ %26, %25 ], [ %28, %27 ]
store i32 %30, i32* %3
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @xilogbf(float %0) {
%2 = tail call i32 @fabsfk(float %0)
%3 = tail call i32 @ilogbkf(i32 %2)
%4 = fcmp oeq float %0, 0.000000e+00
%5 = select i1 %4, i32 -2147483648, i32 %3
%6 = tail call i64 @xisnanf(float %0)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 %5, i32 2147483647
%9 = tail call i64 @xisinff(float %0)
%10 = icmp eq i64 %9, 0
%11 = load i32, i32* @INT_MAX
%12 = select i1 %10, i32 %8, i32 %11
ret i32 %12
}