#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 */
float INFINITY;
scalar_t__ ceilf(int /*<<< orphan*/);
float ldexpf(double, int);
int /*<<< orphan*/ log2f(float);
float frexpf(float x, int *exponent) {
  if (x == INFINITY) {
    *exponent = 0;
    return INFINITY;
  }
  if (x == -INFINITY) {
    *exponent = 0;
    return -INFINITY;
  }
  if (x == 0) {
    *exponent = 0;
    return 0;
  }
  *exponent = (int)ceilf(log2f(x));
  return x / ldexpf(1.0, *exponent);
}


x86 assembly (clang, -O0):
<frexpf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
mov    0x2e9b(%rip),%rax
ucomiss (%rax),%xmm0
jne    117b <frexpf+0x4b>
jp     117b <frexpf+0x4b>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e7b(%rip),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1248 <frexpf+0x118>
movss  -0x8(%rbp),%xmm0
mov    0x2e61(%rip),%rax
movss  (%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
ucomiss %xmm1,%xmm0
jne    11d3 <frexpf+0xa3>
jp     11d3 <frexpf+0xa3>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    0x2e30(%rip),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1248 <frexpf+0x118>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1201 <frexpf+0xd1>
jp     1201 <frexpf+0xd1>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1248 <frexpf+0x118>
movss  -0x8(%rbp),%xmm0
call   1030 <log2f@plt>
mov    %eax,%edi
call   1040 <ceilf@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
movsd  0xdce(%rip),%xmm0
call   1050 <ldexpf@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frexpf>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movaps %xmm0,%xmm1
mov    0x2ea6(%rip),%rax
movss  (%rax),%xmm0
ucomiss %xmm1,%xmm0
jne    114d <frexpf+0x1d>
jnp    1165 <frexpf+0x35>
xorps  0xeac(%rip),%xmm0
ucomiss %xmm1,%xmm0
jne    115b <frexpf+0x2b>
jnp    1165 <frexpf+0x35>
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    1171 <frexpf+0x41>
jp     1171 <frexpf+0x41>
movl   $0x0,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret
movaps %xmm1,%xmm0
movss  %xmm1,0xc(%rsp)
call   1030 <log2f@plt>
mov    %eax,%edi
call   1040 <ceilf@plt>
mov    %eax,(%rbx)
movsd  0xe80(%rip),%xmm0
mov    %eax,%edi
call   1050 <ldexpf@plt>
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
jmp    116b <frexpf+0x3b>

LLVM IR (-O0):
@INFINITY = global float 0.000000e+00
define float @frexpf(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 = load float, float* @INFINITY
%8 = fcmp oeq float %6, %7
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32*, i32** %5
store i32 0, i32* %10
%11 = load float, float* @INFINITY
store float %11, float* %3
br label %37
12: ; preds = %2
%13 = load float, float* %4
%14 = load float, float* @INFINITY
%15 = fneg float %14
%16 = fcmp oeq float %13, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32*, i32** %5
store i32 0, i32* %18
%19 = load float, float* @INFINITY
%20 = fneg float %19
store float %20, float* %3
br label %37
21: ; preds = %12
%22 = load float, float* %4
%23 = fcmp oeq float %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = load i32*, i32** %5
store i32 0, i32* %25
store float 0.000000e+00, float* %3
br label %37
26: ; preds = %21
%27 = load float, float* %4
%28 = call i32 @log2f(float %27)
%29 = call i64 @ceilf(i32 %28)
%30 = trunc i64 %29 to i32
%31 = load i32*, i32** %5
store i32 %30, i32* %31
%32 = load float, float* %4
%33 = load i32*, i32** %5
%34 = load i32, i32* %33
%35 = call float @ldexpf(double 1.000000e+00, i32 %34)
%36 = fdiv float %32, %35
store float %36, float* %3
br label %37
37: ; preds = %26, %24, %17, %9
%38 = load float, float* %3
ret float %38
}

LLVM IR (-O2):
@INFINITY = global float 0.000000e+00
define float @frexpf(float %0, i32* nocapture writeonly %1) {
%3 = load float, float* @INFINITY
%4 = fcmp oeq float %3, %0
br i1 %4, label %5, label %6
5: ; preds = %2
store i32 0, i32* %1
br label %19
6: ; preds = %2
%7 = fneg float %3
%8 = fcmp oeq float %7, %0
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 0, i32* %1
br label %19
10: ; preds = %6
%11 = fcmp oeq float %0, 0.000000e+00
br i1 %11, label %12, label %13
12: ; preds = %10
store i32 0, i32* %1
br label %19
13: ; preds = %10
%14 = tail call i32 @log2f(float %0)
%15 = tail call i64 @ceilf(i32 %14)
%16 = trunc i64 %15 to i32
store i32 %16, i32* %1
%17 = tail call float @ldexpf(double 1.000000e+00, i32 %16)
%18 = fdiv float %0, %17
br label %19
19: ; preds = %13, %12, %9, %5
%20 = phi float [ %3, %5 ], [ %7, %9 ], [ 0.000000e+00, %12 ], [ %18, %13 ]
ret float %20
}