#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 */
long double ilogbl(long double);
int /*<<< orphan*/ isfinite(long double);
long double logbl(long double x) {
  if (!isfinite(x))
    return x * x;
  if (x == 0)
    return -1 / (x * x);
  return ilogbl(x);
}


x86 assembly (clang, -O0):
<logbl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    1151 <logbl+0x31>
fldt   -0x20(%rbp)
fmul   %st,%st(0)
fstpt  -0x10(%rbp)
jmp    1190 <logbl+0x70>
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    1180 <logbl+0x60>
jp     1180 <logbl+0x60>
jmp    116d <logbl+0x4d>
fldt   -0x20(%rbp)
fmul   %st,%st(0)
fld1
fchs
fdivp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1190 <logbl+0x70>
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <ilogbl@plt>
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logbl>:
sub    $0x28,%rsp
fldt   0x30(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
call   1040 <isfinite@plt>
test   %eax,%eax
je     1155 <logbl+0x35>
fldz
fldt   0x1c(%rsp)
fucomi %st(1),%st
fstp   %st(1)
jne    1160 <logbl+0x40>
jp     1160 <logbl+0x40>
fmul   %st,%st(0)
fld1
fchs
fdivp  %st,%st(1)
add    $0x28,%rsp
ret
fldt   0x1c(%rsp)
fmul   %st,%st(0)
add    $0x28,%rsp
ret
fstpt  (%rsp)
call   1030 <ilogbl@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @logbl(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %3
%4 = load x86_fp80, x86_fp80* %3
%5 = call i32 @isfinite(x86_fp80 %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load x86_fp80, x86_fp80* %3
%9 = load x86_fp80, x86_fp80* %3
%10 = fmul x86_fp80 %8, %9
store x86_fp80 %10, x86_fp80* %2
br label %22
11: ; preds = %1
%12 = load x86_fp80, x86_fp80* %3
%13 = fcmp oeq x86_fp80 %12, 0xK00000000000000000000
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load x86_fp80, x86_fp80* %3
%16 = load x86_fp80, x86_fp80* %3
%17 = fmul x86_fp80 %15, %16
%18 = fdiv x86_fp80 0xKBFFF8000000000000000, %17
store x86_fp80 %18, x86_fp80* %2
br label %22
19: ; preds = %11
%20 = load x86_fp80, x86_fp80* %3
%21 = call x86_fp80 @ilogbl(x86_fp80 %20)
store x86_fp80 %21, x86_fp80* %2
br label %22
22: ; preds = %19, %14, %7
%23 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %23
}

LLVM IR (-O2):
define x86_fp80 @logbl(x86_fp80 %0) {
%2 = tail call i32 @isfinite(x86_fp80 %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = fmul x86_fp80 %0, %0
br label %13
6: ; preds = %1
%7 = fcmp oeq x86_fp80 %0, 0xK00000000000000000000
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = fmul x86_fp80 %0, %0
%10 = fdiv x86_fp80 0xKBFFF8000000000000000, %9
br label %13
11: ; preds = %6
%12 = tail call x86_fp80 @ilogbl(x86_fp80 %0)
br label %13
13: ; preds = %11, %8, %4
%14 = phi x86_fp80 [ %10, %8 ], [ %12, %11 ], [ %5, %4 ]
ret x86_fp80 %14
}