#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*/ ERANGE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ finitef(float);
float scalbnf(float, int);
float ldexpf(float value, int exp) {
  if (!finitef(value) || value == (float)0.0)
    return value;
  value = scalbnf(value, exp);
  if (!finitef(value) || value == (float)0.0)
    errno = ERANGE;
  return value;
}


x86 assembly (clang, -O0):
<ldexpf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movaps 0xee4(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xec8(%rip),%xmm1
ucomiss %xmm1,%xmm0
je     1158 <ldexpf+0x48>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1167 <ldexpf+0x57>
jp     1167 <ldexpf+0x57>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cd <ldexpf+0xbd>
movss  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1030 <scalbnf@plt>
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
movaps 0xe8b(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xe6f(%rip),%xmm1
ucomiss %xmm1,%xmm0
je     11b1 <ldexpf+0xa1>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c3 <ldexpf+0xb3>
jp     11c3 <ldexpf+0xb3>
mov    0x2e30(%rip),%rax
mov    (%rax),%ecx
mov    0x2e17(%rip),%rax
mov    %ecx,(%rax)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldexpf>:
push   %rax
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    111b <ldexpf+0xb>
jnp    1150 <ldexpf+0x40>
movaps 0xede(%rip),%xmm1
andps  %xmm0,%xmm1
ucomiss 0xee4(%rip),%xmm1
je     1150 <ldexpf+0x40>
call   1030 <scalbnf@plt>
movaps 0xec6(%rip),%xmm1
andps  %xmm0,%xmm1
ucomiss 0xecc(%rip),%xmm1
je     1152 <ldexpf+0x42>
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1150 <ldexpf+0x40>
jnp    1152 <ldexpf+0x42>
pop    %rax
ret
mov    0x2e8f(%rip),%rax
mov    (%rax),%eax
mov    0x2e76(%rip),%rcx
mov    %eax,(%rcx)
pop    %rax
ret

LLVM IR (-O0):
@ERANGE = global i32 0
@errno = global i32 0
define float @ldexpf(float %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca i32
store float %0, float* %4
store i32 %1, i32* %5
%6 = load float, float* %4
%7 = call float @llvm.fabs.f32(float %6)
%8 = fcmp one float %7, 0x7FF0000000000000
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load float, float* %4
%11 = fcmp oeq float %10, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = load float, float* %4
store float %13, float* %3
br label %28
14: ; preds = %9
%15 = load float, float* %4
%16 = load i32, i32* %5
%17 = call float @scalbnf(float %15, i32 %16)
store float %17, float* %4
%18 = load float, float* %4
%19 = call float @llvm.fabs.f32(float %18)
%20 = fcmp one float %19, 0x7FF0000000000000
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load float, float* %4
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %21, %14
%25 = load i32, i32* @ERANGE
store i32 %25, i32* @errno
br label %26
26: ; preds = %24, %21
%27 = load float, float* %4
store float %27, float* %3
br label %28
28: ; preds = %26, %12
%29 = load float, float* %3
ret float %29
}

LLVM IR (-O2):
@ERANGE = global i32 0
@errno = global i32 0
define float @ldexpf(float %0, i32 %1) {
%3 = tail call float @llvm.fabs.f32(float %0)
%4 = fcmp ueq float %3, 0x7FF0000000000000
%5 = fcmp oeq float %0, 0.000000e+00
%6 = or i1 %5, %4
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = tail call float @scalbnf(float %0, i32 %1)
%9 = tail call float @llvm.fabs.f32(float %8)
%10 = fcmp ueq float %9, 0x7FF0000000000000
%11 = fcmp oeq float %8, 0.000000e+00
%12 = select i1 %10, i1 true, i1 %11
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = load i32, i32* @ERANGE
store i32 %14, i32* @errno
br label %15
15: ; preds = %13, %7, %2
%16 = phi float [ %0, %2 ], [ %8, %7 ], [ %8, %13 ]
ret float %16
}