#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 */
scalar_t__ isnan(float);
float nextafterf(float x, float y) {
  union {
    float f;
    unsigned int i;
  } u;
  if (isnan(y) || isnan(x))
    return x + y;
  if (x == y)
    return y;
  u.f = x;
  if (x == 0.0F) {
    u.i = 1;
    return y > 0.0F ? u.f : -u.f;
  }
  if (((x > 0.0F) ^ (y > x)) == 0)
    u.i++;
  else
    u.i--;
  return u.f;
}


x86 assembly (clang, -O0):
<nextafterf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
jne    114a <nextafterf+0x3a>
movss  -0x8(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     115e <nextafterf+0x4e>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1241 <nextafterf+0x131>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1182 <nextafterf+0x72>
jp     1182 <nextafterf+0x72>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1241 <nextafterf+0x131>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11f0 <nextafterf+0xe0>
jp     11f0 <nextafterf+0xe0>
movl   $0x1,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11ca <nextafterf+0xba>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11e1 <nextafterf+0xd1>
movss  -0x10(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1241 <nextafterf+0x131>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
movss  -0xc(%rbp),%xmm0
ucomiss -0x8(%rbp),%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
xor    %ecx,%eax
cmp    $0x0,%eax
jne    122e <nextafterf+0x11e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1237 <nextafterf+0x127>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextafterf>:
push   %rax
movss  %xmm0,(%rsp)
movss  %xmm1,0x4(%rsp)
movaps %xmm1,%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
jne    1138 <nextafterf+0x28>
movss  (%rsp),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     1145 <nextafterf+0x35>
movss  0x4(%rsp),%xmm0
addss  (%rsp),%xmm0
pop    %rax
ret
movss  (%rsp),%xmm0
movss  0x4(%rsp),%xmm1
ucomiss %xmm1,%xmm0
movaps %xmm1,%xmm0
jne    115c <nextafterf+0x4c>
jp     115c <nextafterf+0x4c>
pop    %rax
ret
xorps  %xmm1,%xmm1
movss  (%rsp),%xmm2
ucomiss %xmm1,%xmm2
jne    1181 <nextafterf+0x71>
jp     1181 <nextafterf+0x71>
xor    %eax,%eax
ucomiss %xmm1,%xmm0
seta   %al
lea    0xe86(%rip),%rcx
movss  (%rcx,%rax,4),%xmm0
pop    %rax
ret
setbe  %al
movss  (%rsp),%xmm1
ucomiss %xmm1,%xmm0
seta   %cl
xor    %al,%cl
movd   %xmm1,%eax
movzbl %cl,%ecx
lea    (%rax,%rcx,2),%eax
add    $0xffffffff,%eax
movd   %eax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%union.anon = type { float }
define float @nextafterf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca %union.anon
store float %0, float* %4
store float %1, float* %5
%7 = load float, float* %5
%8 = call i64 @isnan(float %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load float, float* %4
%12 = call i64 @isnan(float %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10, %2
%15 = load float, float* %4
%16 = load float, float* %5
%17 = fadd float %15, %16
store float %17, float* %3
br label %63
18: ; preds = %10
%19 = load float, float* %4
%20 = load float, float* %5
%21 = fcmp oeq float %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load float, float* %5
store float %23, float* %3
br label %63
24: ; preds = %18
%25 = load float, float* %4
%26 = bitcast %union.anon* %6 to float*
store float %25, float* %26
%27 = load float, float* %4
%28 = fcmp oeq float %27, 0.000000e+00
br i1 %28, label %29, label %42
29: ; preds = %24
%30 = bitcast %union.anon* %6 to i32*
store i32 1, i32* %30
%31 = load float, float* %5
%32 = fcmp ogt float %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = bitcast %union.anon* %6 to float*
%35 = load float, float* %34
br label %40
36: ; preds = %29
%37 = bitcast %union.anon* %6 to float*
%38 = load float, float* %37
%39 = fneg float %38
br label %40
40: ; preds = %36, %33
%41 = phi float [ %35, %33 ], [ %39, %36 ]
store float %41, float* %3
br label %63
42: ; preds = %24
%43 = load float, float* %4
%44 = fcmp ogt float %43, 0.000000e+00
%45 = zext i1 %44 to i32
%46 = load float, float* %5
%47 = load float, float* %4
%48 = fcmp ogt float %46, %47
%49 = zext i1 %48 to i32
%50 = xor i32 %45, %49
%51 = icmp eq i32 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %42
%53 = bitcast %union.anon* %6 to i32*
%54 = load i32, i32* %53
%55 = add i32 %54, 1
store i32 %55, i32* %53
br label %60
56: ; preds = %42
%57 = bitcast %union.anon* %6 to i32*
%58 = load i32, i32* %57
%59 = add i32 %58, -1
store i32 %59, i32* %57
br label %60
60: ; preds = %56, %52
%61 = bitcast %union.anon* %6 to float*
%62 = load float, float* %61
store float %62, float* %3
br label %63
63: ; preds = %60, %40, %22, %14
%64 = load float, float* %3
ret float %64
}

LLVM IR (-O2):
define float @nextafterf(float %0, float %1) {
%3 = tail call i64 @isnan(float %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @isnan(float %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5, %2
%9 = fadd float %0, %1
br label %25
10: ; preds = %5
%11 = fcmp oeq float %0, %1
br i1 %11, label %25, label %12
12: ; preds = %10
%13 = fcmp oeq float %0, 0.000000e+00
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = fcmp ogt float %1, 0.000000e+00
%16 = select i1 %15, float 0x36A0000000000000, float 0xB6A0000000000000
br label %25
17: ; preds = %12
%18 = fcmp ule float %0, 0.000000e+00
%19 = fcmp ogt float %1, %0
%20 = xor i1 %18, %19
%21 = bitcast float %0 to i32
%22 = select i1 %20, i32 1, i32 -1
%23 = add i32 %22, %21
%24 = bitcast i32 %23 to float
br label %25
25: ; preds = %10, %17, %14, %8
%26 = phi float [ %9, %8 ], [ %16, %14 ], [ %24, %17 ], [ %1, %10 ]
ret float %26
}