#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 /*<<< orphan*/ fabs(float);
double log(int /*<<< orphan*/);
int bitdiff(float a, float b) {
  if (a == b)
    return 24;
  else if (a == 0) {
    int j = (int)(-log(fabs(b)) / 0.69314718055994530942);
    if (j > 24)
      j = 24;
    return j;
  } else
    return (int)(log(fabs(a)) / 0.69314718055994530942 -
                 log(fabs(b - a)) / 0.69314718055994530942);
}


x86 assembly (clang, -O0):
<bitdiff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1153 <bitdiff+0x33>
jp     1153 <bitdiff+0x33>
movl   $0x18,-0x4(%rbp)
jmp    1218 <bitdiff+0xf8>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c1 <bitdiff+0xa1>
jp     11c1 <bitdiff+0xa1>
movss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe66(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x18,-0x10(%rbp)
jle    11b6 <bitdiff+0x96>
movl   $0x18,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1218 <bitdiff+0xf8>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
movsd  0xe26(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitdiff>:
sub    $0x28,%rsp
mov    $0x18,%eax
ucomiss %xmm1,%xmm0
jne    1135 <bitdiff+0x15>
jp     1135 <bitdiff+0x15>
add    $0x28,%rsp
ret
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jne    116a <bitdiff+0x4a>
jp     116a <bitdiff+0x4a>
movaps %xmm1,%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
divsd  0xeba(%rip),%xmm0
cvttsd2si %xmm0,%ecx
cmp    $0x18,%ecx
mov    $0x18,%eax
cmovl  %ecx,%eax
add    $0x28,%rsp
ret
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
movaps %xmm0,0x10(%rsp)
movss  0x8(%rsp),%xmm0
subss  0xc(%rsp),%xmm0
call   1030 <fabs@plt>
mov    %eax,%edi
call   1040 <log@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
divpd  0xe51(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @bitdiff(float %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca i32
store float %0, float* %4
store float %1, float* %5
%7 = load float, float* %4
%8 = load float, float* %5
%9 = fcmp oeq float %7, %8
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 24, i32* %3
br label %39
11: ; preds = %2
%12 = load float, float* %4
%13 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %26
14: ; preds = %11
%15 = load float, float* %5
%16 = call i32 @fabs(float %15)
%17 = call double @log(i32 %16)
%18 = fneg double %17
%19 = fdiv double %18, 0x3FE62E42FEFA39EF
%20 = fptosi double %19 to i32
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp sgt i32 %21, 24
br i1 %22, label %23, label %24
23: ; preds = %14
store i32 24, i32* %6
br label %24
24: ; preds = %23, %14
%25 = load i32, i32* %6
store i32 %25, i32* %3
br label %39
26: ; preds = %11
%27 = load float, float* %4
%28 = call i32 @fabs(float %27)
%29 = call double @log(i32 %28)
%30 = fdiv double %29, 0x3FE62E42FEFA39EF
%31 = load float, float* %5
%32 = load float, float* %4
%33 = fsub float %31, %32
%34 = call i32 @fabs(float %33)
%35 = call double @log(i32 %34)
%36 = fdiv double %35, 0x3FE62E42FEFA39EF
%37 = fsub double %30, %36
%38 = fptosi double %37 to i32
store i32 %38, i32* %3
br label %39
39: ; preds = %26, %24, %10
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @bitdiff(float %0, float %1) {
%3 = fcmp oeq float %0, %1
br i1 %3, label %26, label %4
4: ; preds = %2
%5 = fcmp oeq float %0, 0.000000e+00
br i1 %5, label %6, label %13
6: ; preds = %4
%7 = tail call i32 @fabs(float %1)
%8 = tail call double @log(i32 %7)
%9 = fdiv double %8, 0xBFE62E42FEFA39EF
%10 = fptosi double %9 to i32
%11 = icmp slt i32 %10, 24
%12 = select i1 %11, i32 %10, i32 24
br label %26
13: ; preds = %4
%14 = tail call i32 @fabs(float %0)
%15 = tail call double @log(i32 %14)
%16 = fsub float %1, %0
%17 = tail call i32 @fabs(float %16)
%18 = tail call double @log(i32 %17)
%19 = insertelement <2 x double> poison, double %15, i64 0
%20 = insertelement <2 x double> %19, double %18, i64 1
%21 = fdiv <2 x double> %20, <double 0x3FE62E42FEFA39EF, double 0x3FE62E42FEFA39EF>
%22 = shufflevector <2 x double> %21, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%23 = fsub <2 x double> %21, %22
%24 = extractelement <2 x double> %23, i64 0
%25 = fptosi double %24 to i32
br label %26
26: ; preds = %2, %13, %6
%27 = phi i32 [ %12, %6 ], [ %25, %13 ], [ 24, %2 ]
ret i32 %27
}