#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*/ finitef(float);
scalar_t__ isnanf(float);
float rintf(float);
float scalbnf(float, int);
float scalbf(float x, float fn) {
  if (isnanf(x) || isnanf(fn))
    return x * fn;
  if (!finitef(fn)) {
    if (fn > (float)0.0)
      return x * fn;
    else
      return x / (-fn);
  }
  if (rintf(fn) != fn)
    return (fn - fn) / (fn - fn);
  if (fn > (float)65000.0)
    return scalbnf(x, 65000);
  if (-fn > (float)65000.0)
    return scalbnf(x, -65000);
  return scalbnf(x, (int)fn);
}


x86 assembly (clang, -O0):
<scalbf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <isnanf@plt>
cmp    $0x0,%rax
jne    116a <scalbf+0x3a>
movss  -0xc(%rbp),%xmm0
call   1040 <isnanf@plt>
cmp    $0x0,%rax
je     117e <scalbf+0x4e>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0xc(%rbp),%xmm0
movaps 0xe86(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xe6a(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11e9 <scalbf+0xb9>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11c4 <scalbf+0x94>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0xc(%rbp),%xmm0
call   1050 <rintf@plt>
ucomiss -0xc(%rbp),%xmm0
jne    1208 <scalbf+0xd8>
jp     1208 <scalbf+0xd8>
jmp    122a <scalbf+0xfa>
movss  -0xc(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
subss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0xc(%rbp),%xmm0
movss  0xdcd(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1259 <scalbf+0x129>
movss  -0x8(%rbp),%xmm0
mov    $0xfde8,%edi
call   1030 <scalbnf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xd91(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    1295 <scalbf+0x165>
movss  -0x8(%rbp),%xmm0
mov    $0xffff0218,%edi
call   1030 <scalbnf@plt>
movss  %xmm0,-0x4(%rbp)
jmp    12a9 <scalbf+0x179>
movss  -0x8(%rbp),%xmm0
cvttss2si -0xc(%rbp),%edi
call   1030 <scalbnf@plt>
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scalbf>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <isnanf@plt>
test   %rax,%rax
jne    1158 <scalbf+0x28>
movaps 0x10(%rsp),%xmm0
call   1040 <isnanf@plt>
test   %rax,%rax
je     1169 <scalbf+0x39>
movss  0xc(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
add    $0x28,%rsp
ret
movaps 0xe90(%rip),%xmm0
andps  0x10(%rsp),%xmm0
ucomiss 0xea4(%rip),%xmm0
je     11a3 <scalbf+0x73>
movaps 0x10(%rsp),%xmm0
call   1050 <rintf@plt>
ucomiss 0x10(%rsp),%xmm0
jne    1191 <scalbf+0x61>
jnp    11cb <scalbf+0x9b>
movaps 0x10(%rsp),%xmm0
subss  %xmm0,%xmm0
divss  %xmm0,%xmm0
add    $0x28,%rsp
ret
xorps  %xmm0,%xmm0
movaps 0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
ja     1158 <scalbf+0x28>
movaps 0x10(%rsp),%xmm1
xorps  0xe54(%rip),%xmm1
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm0
ucomiss 0xe4d(%rip),%xmm0
jbe    11ed <scalbf+0xbd>
movss  0xc(%rsp),%xmm0
mov    $0xfde8,%edi
add    $0x28,%rsp
jmp    1030 <scalbnf@plt>
movss  0xe33(%rip),%xmm0
ucomiss 0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm0
jbe    1210 <scalbf+0xe0>
mov    $0xffff0218,%edi
add    $0x28,%rsp
jmp    1030 <scalbnf@plt>
cvttss2si 0x10(%rsp),%edi
add    $0x28,%rsp
jmp    1030 <scalbnf@plt>

LLVM IR (-O0):
define float @scalbf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %4
%7 = call i64 @isnanf(float %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load float, float* %5
%11 = call i64 @isnanf(float %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9, %2
%14 = load float, float* %4
%15 = load float, float* %5
%16 = fmul float %14, %15
store float %16, float* %3
br label %64
17: ; preds = %9
%18 = load float, float* %5
%19 = call float @llvm.fabs.f32(float %18)
%20 = fcmp one float %19, 0x7FF0000000000000
br i1 %20, label %33, label %21
21: ; preds = %17
%22 = load float, float* %5
%23 = fcmp ogt float %22, 0.000000e+00
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load float, float* %4
%26 = load float, float* %5
%27 = fmul float %25, %26
store float %27, float* %3
br label %64
28: ; preds = %21
%29 = load float, float* %4
%30 = load float, float* %5
%31 = fneg float %30
%32 = fdiv float %29, %31
store float %32, float* %3
br label %64
33: ; preds = %17
%34 = load float, float* %5
%35 = call float @llvm.rint.f32(float %34)
%36 = load float, float* %5
%37 = fcmp une float %35, %36
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = load float, float* %5
%40 = load float, float* %5
%41 = fsub float %39, %40
%42 = load float, float* %5
%43 = load float, float* %5
%44 = fsub float %42, %43
%45 = fdiv float %41, %44
store float %45, float* %3
br label %64
46: ; preds = %33
%47 = load float, float* %5
%48 = fcmp ogt float %47, 6.500000e+04
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load float, float* %4
%51 = call float @scalbnf(float %50, i32 65000)
store float %51, float* %3
br label %64
52: ; preds = %46
%53 = load float, float* %5
%54 = fneg float %53
%55 = fcmp ogt float %54, 6.500000e+04
br i1 %55, label %56, label %59
56: ; preds = %52
%57 = load float, float* %4
%58 = call float @scalbnf(float %57, i32 -65000)
store float %58, float* %3
br label %64
59: ; preds = %52
%60 = load float, float* %4
%61 = load float, float* %5
%62 = fptosi float %61 to i32
%63 = call float @scalbnf(float %60, i32 %62)
store float %63, float* %3
br label %64
64: ; preds = %59, %56, %49, %38, %28, %24, %13
%65 = load float, float* %3
ret float %65
}

LLVM IR (-O2):
define float @scalbf(float %0, float %1) {
%3 = tail call i64 @isnanf(float %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @isnanf(float %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5, %2
%9 = fmul float %0, %1
br label %37
10: ; preds = %5
%11 = tail call float @llvm.fabs.f32(float %1)
%12 = fcmp ueq float %11, 0x7FF0000000000000
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = fcmp ogt float %1, 0.000000e+00
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = fmul float %0, %1
br label %37
17: ; preds = %13
%18 = fneg float %1
%19 = fdiv float %0, %18
br label %37
20: ; preds = %10
%21 = tail call float @llvm.rint.f32(float %1)
%22 = fcmp une float %21, %1
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = fsub float %1, %1
%25 = fdiv float %24, %24
br label %37
26: ; preds = %20
%27 = fcmp ogt float %1, 6.500000e+04
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = tail call float @scalbnf(float %0, i32 65000)
br label %37
30: ; preds = %26
%31 = fcmp olt float %1, -6.500000e+04
br i1 %31, label %32, label %34
32: ; preds = %30
%33 = tail call float @scalbnf(float %0, i32 -65000)
br label %37
34: ; preds = %30
%35 = fptosi float %1 to i32
%36 = tail call float @scalbnf(float %0, i32 %35)
br label %37
37: ; preds = %34, %32, %28, %23, %17, %15, %8
%38 = phi float [ %9, %8 ], [ %25, %23 ], [ %29, %28 ], [ %33, %32 ], [ %36, %34 ], [ %16, %15 ], [ %19, %17 ]
ret float %38
}