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


x86 assembly (clang, -O0):
<nexttowardf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
fldt   0x10(%rbp)
movss  %xmm0,-0x8(%rbp)
fstpt  -0x20(%rbp)
flds   -0x8(%rbp)
fstpt  -0x40(%rbp)
fldt   -0x20(%rbp)
fstps  -0x44(%rbp)
movss  -0x44(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
jne    1157 <nexttowardf+0x47>
movss  -0x8(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1171 <nexttowardf+0x61>
flds   -0x8(%rbp)
fldt   -0x20(%rbp)
faddp  %st,%st(1)
fstps  -0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1268 <nexttowardf+0x158>
fldt   -0x40(%rbp)
fldt   -0x20(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jne    11a3 <nexttowardf+0x93>
jp     11a3 <nexttowardf+0x93>
jmp    118e <nexttowardf+0x7e>
fldt   -0x20(%rbp)
fstps  -0x48(%rbp)
movss  -0x48(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1268 <nexttowardf+0x158>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1216 <nexttowardf+0x106>
jp     1216 <nexttowardf+0x106>
movl   $0x1,-0x28(%rbp)
fldt   -0x20(%rbp)
fldz
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    11f0 <nexttowardf+0xe0>
jmp    11e1 <nexttowardf+0xd1>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
jmp    1207 <nexttowardf+0xf7>
movss  -0x28(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1268 <nexttowardf+0x158>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %al
movzbl %al,%eax
fldt   -0x20(%rbp)
fldt   -0x40(%rbp)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
xor    %ecx,%eax
cmp    $0x0,%eax
jne    1255 <nexttowardf+0x145>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    125e <nexttowardf+0x14e>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nexttowardf>:
sub    $0x38,%rsp
fldt   0x40(%rsp)
movss  %xmm0,0xc(%rsp)
movss  %xmm0,0x1c(%rsp)
flds   0x1c(%rsp)
fstpt  0x20(%rsp)
fld    %st(0)
fstpt  0x2c(%rsp)
fstps  0x18(%rsp)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
jne    115c <nexttowardf+0x4c>
movss  0xc(%rsp),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     117f <nexttowardf+0x6f>
fldt   0x2c(%rsp)
fldt   0x20(%rsp)
faddp  %st,%st(1)
fstps  0x14(%rsp)
movd   0x14(%rsp),%xmm0
fldz
fldz
fxch   %st(1)
fstp   %st(0)
fstp   %st(0)
add    $0x38,%rsp
ret
movss  0xc(%rsp),%xmm1
fldt   0x2c(%rsp)
fldt   0x20(%rsp)
fucomi %st(1),%st
movss  0x10(%rsp),%xmm0
jne    1199 <nexttowardf+0x89>
jnp    1176 <nexttowardf+0x66>
xorps  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    11c0 <nexttowardf+0xb0>
jp     11c0 <nexttowardf+0xb0>
fstp   %st(0)
fldz
xor    %eax,%eax
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
seta   %al
lea    0xe47(%rip),%rcx
movd   (%rcx,%rax,4),%xmm0
jmp    1170 <nexttowardf+0x60>
movaps %xmm1,%xmm0
setbe  %al
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
seta   %cl
xor    %al,%cl
movd   %xmm1,%eax
movzbl %cl,%ecx
lea    (%rax,%rcx,2),%eax
add    $0xffffffff,%eax
movd   %eax,%xmm0
jmp    1170 <nexttowardf+0x60>

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

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