#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 frexpf(float, int *);
int /*<<< orphan*/ isfinite(float);
scalar_t__ isnan(float);
float scalbnf(float, int);
float nextafterf(float x, float y) {
  volatile float delta;
  float absx, denorm_min;
  if (isnan(x) || isnan(y))
    return x + y;
  if (x == y)
    return x;
  if (!isfinite(x))
    return x > 0 ? 3.40282346638528859811704183484516925e+38F
                 : -3.40282346638528859811704183484516925e+38F;
  absx = (x < 0.0) ? -x : x;
  if (1.40129846432481707092372958328991613e-45F == 0.0f)
    denorm_min = 1.17549435082228750796873653722224568e-38F;
  else
    denorm_min = 1.40129846432481707092372958328991613e-45F;
  if (absx < 1.17549435082228750796873653722224568e-38F)
    delta = denorm_min;
  else {
    float frac;
    int exp;
    frac = frexpf(absx, &exp);
    delta = scalbnf(0.5f, exp);
    delta *= 1.19209289550781250000000000000000000e-7F;
    if (frac == 0.5f && (y < x) == (x > 0))
      delta *= 0.5f;
    if (delta == 0.0f)
      delta = denorm_min;
  }
  if (y < x)
    delta = -delta;
  return x + delta;
}


x86 assembly (clang, -O0):
<nextafterf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    117a <nextafterf+0x3a>
movss  -0xc(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     118e <nextafterf+0x4e>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1370 <nextafterf+0x230>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    11b2 <nextafterf+0x72>
jp     11b2 <nextafterf+0x72>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1370 <nextafterf+0x230>
movss  -0x8(%rbp),%xmm0
call   1040 <isfinite@plt>
cmp    $0x0,%eax
jne    11f8 <nextafterf+0xb8>
movss  -0x8(%rbp),%xmm1
movss  0xe2e(%rip),%xmm3
movss  0xe2a(%rip),%xmm2
xorps  %xmm0,%xmm0
cmpltss %xmm1,%xmm0
movaps %xmm0,%xmm1
andps  %xmm3,%xmm1
andnps %xmm2,%xmm0
orps   %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1370 <nextafterf+0x230>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    122a <nextafterf+0xea>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    1234 <nextafterf+0xf4>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xdc6(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xdb5(%rip),%xmm0
ucomiss -0x14(%rbp),%xmm0
jbe    126c <nextafterf+0x12c>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1333 <nextafterf+0x1f3>
movss  -0x14(%rbp),%xmm0
lea    -0x20(%rbp),%rdi
call   1060 <frexpf@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
movss  0xd86(%rip),%xmm0
call   1030 <scalbnf@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xd73(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xd59(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    130d <nextafterf+0x1cd>
jp     130d <nextafterf+0x1cd>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
jne    130d <nextafterf+0x1cd>
movss  -0x10(%rbp),%xmm0
movss  0xd0c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    132e <nextafterf+0x1ee>
jp     132e <nextafterf+0x1ee>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    1333 <nextafterf+0x1f3>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    135d <nextafterf+0x21d>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextafterf>:
sub    $0x28,%rsp
movss  %xmm1,0x4(%rsp)
movaps %xmm0,0x10(%rsp)
call   1050 <isnan@plt>
test   %rax,%rax
jne    1169 <nextafterf+0x29>
movss  0x4(%rsp),%xmm0
call   1050 <isnan@plt>
test   %rax,%rax
je     117c <nextafterf+0x3c>
movaps 0x10(%rsp),%xmm2
addss  0x4(%rsp),%xmm2
movaps %xmm2,%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm2
movss  0x4(%rsp),%xmm0
ucomiss %xmm0,%xmm2
jne    118e <nextafterf+0x4e>
jnp    1174 <nextafterf+0x34>
movaps %xmm2,%xmm0
call   1040 <isfinite@plt>
test   %eax,%eax
je     11df <nextafterf+0x9f>
movaps 0xe5f(%rip),%xmm1
movaps 0x10(%rsp),%xmm3
xorps  %xmm3,%xmm1
xorps  %xmm2,%xmm2
movaps %xmm3,%xmm0
cmpltss %xmm2,%xmm0
andps  %xmm0,%xmm1
andnps %xmm3,%xmm0
orps   %xmm1,%xmm0
movss  0xe4b(%rip),%xmm1
ucomiss %xmm0,%xmm1
jbe    1200 <nextafterf+0xc0>
movaps %xmm3,%xmm2
movl   $0x1,(%rsp)
movss  0x4(%rsp),%xmm3
jmp    128f <nextafterf+0x14f>
xorps  %xmm0,%xmm0
xor    %eax,%eax
movaps 0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
seta   %al
lea    0xe26(%rip),%rcx
movss  (%rcx,%rax,4),%xmm2
jmp    1174 <nextafterf+0x34>
lea    0xc(%rsp),%rdi
call   1060 <frexpf@plt>
movss  %xmm0,0x8(%rsp)
mov    0xc(%rsp),%edi
movss  0xdf8(%rip),%xmm0
call   1030 <scalbnf@plt>
movaps 0x10(%rsp),%xmm2
movss  %xmm0,(%rsp)
movss  (%rsp),%xmm0
mulss  0xde0(%rip),%xmm0
movss  %xmm0,(%rsp)
movss  0x8(%rsp),%xmm0
ucomiss 0xdca(%rip),%xmm0
movss  0x4(%rsp),%xmm3
jne    1279 <nextafterf+0x139>
jp     1279 <nextafterf+0x139>
ucomiss %xmm3,%xmm2
setbe  %al
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm2
seta   %cl
cmp    %al,%cl
je     1279 <nextafterf+0x139>
movss  (%rsp),%xmm0
mulss  0xda0(%rip),%xmm0
movss  %xmm0,(%rsp)
movss  (%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    128f <nextafterf+0x14f>
jp     128f <nextafterf+0x14f>
movl   $0x1,(%rsp)
ucomiss %xmm3,%xmm2
jbe    12a5 <nextafterf+0x165>
movss  (%rsp),%xmm0
xorps  0xd60(%rip),%xmm0
movss  %xmm0,(%rsp)
addss  (%rsp),%xmm2
jmp    1174 <nextafterf+0x34>

LLVM IR (-O0):
define float @nextafterf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
store float %0, float* %4
store float %1, float* %5
%11 = load float, float* %4
%12 = call i64 @isnan(float %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load float, float* %5
%16 = call i64 @isnan(float %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14, %2
%19 = load float, float* %4
%20 = load float, float* %5
%21 = fadd float %19, %20
store float %21, float* %3
br label %90
22: ; preds = %14
%23 = load float, float* %4
%24 = load float, float* %5
%25 = fcmp oeq float %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load float, float* %4
store float %27, float* %3
br label %90
28: ; preds = %22
%29 = load float, float* %4
%30 = call i32 @isfinite(float %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %28
%33 = load float, float* %4
%34 = fcmp ogt float %33, 0.000000e+00
%35 = zext i1 %34 to i64
%36 = select i1 %34, float 0x47EFFFFFE0000000, float 0xC7EFFFFFE0000000
store float %36, float* %3
br label %90
37: ; preds = %28
%38 = load float, float* %4
%39 = fpext float %38 to double
%40 = fcmp olt double %39, 0.000000e+00
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load float, float* %4
%43 = fneg float %42
br label %46
44: ; preds = %37
%45 = load float, float* %4
br label %46
46: ; preds = %44, %41
%47 = phi float [ %43, %41 ], [ %45, %44 ]
store float %47, float* %7
store float 0x36A0000000000000, float* %8
%48 = load float, float* %7
%49 = fcmp olt float %48, 0x3810000000000000
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load float, float* %8
store volatile float %51, float* %6
br label %79
52: ; preds = %46
%53 = load float, float* %7
%54 = call float @frexpf(float %53, i32* %10)
store float %54, float* %9
%55 = load i32, i32* %10
%56 = call float @scalbnf(float 5.000000e-01, i32 %55)
store volatile float %56, float* %6
%57 = load volatile float, float* %6
%58 = fmul float %57, 0x3E80000000000000
store volatile float %58, float* %6
%59 = load float, float* %9
%60 = fcmp oeq float %59, 5.000000e-01
br i1 %60, label %61, label %73
61: ; preds = %52
%62 = load float, float* %5
%63 = load float, float* %4
%64 = fcmp olt float %62, %63
%65 = zext i1 %64 to i32
%66 = load float, float* %4
%67 = fcmp ogt float %66, 0.000000e+00
%68 = zext i1 %67 to i32
%69 = icmp eq i32 %65, %68
br i1 %69, label %70, label %73
70: ; preds = %61
%71 = load volatile float, float* %6
%72 = fmul float %71, 5.000000e-01
store volatile float %72, float* %6
br label %73
73: ; preds = %70, %61, %52
%74 = load volatile float, float* %6
%75 = fcmp oeq float %74, 0.000000e+00
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = load float, float* %8
store volatile float %77, float* %6
br label %78
78: ; preds = %76, %73
br label %79
79: ; preds = %78, %50
%80 = load float, float* %5
%81 = load float, float* %4
%82 = fcmp olt float %80, %81
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load volatile float, float* %6
%85 = fneg float %84
store volatile float %85, float* %6
br label %86
86: ; preds = %83, %79
%87 = load float, float* %4
%88 = load volatile float, float* %6
%89 = fadd float %87, %88
store float %89, float* %3
br label %90
90: ; preds = %86, %32, %26, %18
%91 = load float, float* %3
ret float %91
}

LLVM IR (-O2):
define float @nextafterf(float %0, float %1) {
%3 = alloca float
%4 = alloca i32
%5 = bitcast float* %3 to i8*
%6 = tail call i64 @isnan(float %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i64 @isnan(float %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %2
%12 = fadd float %0, %1
br label %55
13: ; preds = %8
%14 = fcmp oeq float %0, %1
br i1 %14, label %55, label %15
15: ; preds = %13
%16 = tail call i32 @isfinite(float %0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = fcmp ogt float %0, 0.000000e+00
%20 = select i1 %19, float 0x47EFFFFFE0000000, float 0xC7EFFFFFE0000000
br label %55
21: ; preds = %15
%22 = fcmp olt float %0, 0.000000e+00
%23 = fneg float %0
%24 = select i1 %22, float %23, float %0
%25 = fcmp olt float %24, 0x3810000000000000
br i1 %25, label %26, label %27
26: ; preds = %21
store volatile float 0x36A0000000000000, float* %3
br label %47
27: ; preds = %21
%28 = bitcast i32* %4 to i8*
%29 = call float @frexpf(float %24, i32* %4)
%30 = load i32, i32* %4
%31 = tail call float @scalbnf(float 5.000000e-01, i32 %30)
store volatile float %31, float* %3
%32 = load volatile float, float* %3
%33 = fmul float %32, 0x3E80000000000000
store volatile float %33, float* %3
%34 = fcmp oeq float %29, 5.000000e-01
br i1 %34, label %35, label %42
35: ; preds = %27
%36 = fcmp uge float %1, %0
%37 = fcmp ogt float %0, 0.000000e+00
%38 = xor i1 %37, %36
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load volatile float, float* %3
%41 = fmul float %40, 5.000000e-01
store volatile float %41, float* %3
br label %42
42: ; preds = %39, %35, %27
%43 = load volatile float, float* %3
%44 = fcmp oeq float %43, 0.000000e+00
br i1 %44, label %45, label %46
45: ; preds = %42
store volatile float 0x36A0000000000000, float* %3
br label %46
46: ; preds = %45, %42
br label %47
47: ; preds = %46, %26
%48 = fcmp olt float %1, %0
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = load volatile float, float* %3
%51 = fneg float %50
store volatile float %51, float* %3
br label %52
52: ; preds = %49, %47
%53 = load volatile float, float* %3
%54 = fadd float %53, %0
br label %55
55: ; preds = %13, %52, %18, %11
%56 = phi float [ %12, %11 ], [ %54, %52 ], [ %20, %18 ], [ %0, %13 ]
ret float %56
}