#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 */
typedef int int32_t;

/* Variables and functions */
float const copysignfk(float, float);
float fabsfk(float);
scalar_t__ xisinff(float);
__attribute__((visibility("default"))) const float xrintf(float d) {
  float x = d + 0.5f;
  int32_t isodd = (1 & (int32_t)x) != 0;
  float fr = x - (int32_t)x;
  fr = (fr < 0 || (fr == 0 && isodd)) ? fr + 1.0f : fr;
  x = d == 0.50000005960464477539f ? 0 : x;
  return (xisinff(d) || fabsfk(d) >= (float)(1LL << 23))
             ? d
             : copysignfk(x - fr, d);
}


x86 assembly (clang, -O0):
<xrintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xebb(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
cvttss2si -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
cvttss2si -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x10(%rbp),%xmm0
ja     11aa <xrintf+0x7a>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c1 <xrintf+0x91>
jp     11c1 <xrintf+0x91>
cmpl   $0x0,-0xc(%rbp)
je     11c1 <xrintf+0x91>
movss  0xe52(%rip),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11cb <xrintf+0x9b>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
movss  0xe26(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11fe <xrintf+0xce>
jp     11fe <xrintf+0xce>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    1208 <xrintf+0xd8>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <xisinff@plt>
cmp    $0x0,%rax
jne    1241 <xrintf+0x111>
movss  -0x4(%rbp),%xmm0
call   1050 <fabsfk@plt>
movss  0xdd4(%rip),%xmm1
ucomiss %xmm1,%xmm0
jb     1250 <xrintf+0x120>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1269 <xrintf+0x139>
movss  -0x8(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1030 <copysignfk@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrintf>:
sub    $0x38,%rsp
movss  0xec4(%rip),%xmm2
addss  %xmm0,%xmm2
cvttps2dq %xmm2,%xmm1
cvtdq2ps %xmm1,%xmm1
movaps %xmm2,%xmm3
subss  %xmm1,%xmm3
xorps  %xmm1,%xmm1
ucomiss %xmm3,%xmm1
movaps %xmm2,0x20(%rsp)
ja     116b <xrintf+0x3b>
ucomiss %xmm1,%xmm3
jne    1173 <xrintf+0x43>
jp     1173 <xrintf+0x43>
cvttss2si %xmm2,%eax
and    $0x1,%eax
je     1173 <xrintf+0x43>
addss  0xe91(%rip),%xmm3
movaps %xmm3,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
call   1040 <xisinff@plt>
test   %rax,%rax
jne    11c3 <xrintf+0x93>
movss  0xc(%rsp),%xmm0
call   1050 <fabsfk@plt>
ucomiss 0xe72(%rip),%xmm0
jae    11c3 <xrintf+0x93>
movss  0xe64(%rip),%xmm0
movss  0xc(%rsp),%xmm1
cmpeqss %xmm1,%xmm0
andnps 0x20(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
add    $0x38,%rsp
jmp    1030 <copysignfk@plt>
movss  0xc(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define float @xrintf(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca float
store float %0, float* %2
%6 = load float, float* %2
%7 = fadd float %6, 5.000000e-01
store float %7, float* %3
%8 = load float, float* %3
%9 = fptosi float %8 to i32
%10 = and i32 1, %9
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i32
store i32 %12, i32* %4
%13 = load float, float* %3
%14 = load float, float* %3
%15 = fptosi float %14 to i32
%16 = sitofp i32 %15 to float
%17 = fsub float %13, %16
store float %17, float* %5
%18 = load float, float* %5
%19 = fcmp olt float %18, 0.000000e+00
br i1 %19, label %26, label %20
20: ; preds = %1
%21 = load float, float* %5
%22 = fcmp oeq float %21, 0.000000e+00
br i1 %22, label %23, label %29
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23, %1
%27 = load float, float* %5
%28 = fadd float %27, 1.000000e+00
br label %31
29: ; preds = %23, %20
%30 = load float, float* %5
br label %31
31: ; preds = %29, %26
%32 = phi float [ %28, %26 ], [ %30, %29 ]
store float %32, float* %5
%33 = load float, float* %2
%34 = fcmp oeq float %33, 0x3FE0000020000000
br i1 %34, label %35, label %36
35: ; preds = %31
br label %38
36: ; preds = %31
%37 = load float, float* %3
br label %38
38: ; preds = %36, %35
%39 = phi float [ 0.000000e+00, %35 ], [ %37, %36 ]
store float %39, float* %3
%40 = load float, float* %2
%41 = call i64 @xisinff(float %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %38
%44 = load float, float* %2
%45 = call float @fabsfk(float %44)
%46 = fcmp oge float %45, 0x4160000000000000
br i1 %46, label %47, label %49
47: ; preds = %43, %38
%48 = load float, float* %2
br label %55
49: ; preds = %43
%50 = load float, float* %3
%51 = load float, float* %5
%52 = fsub float %50, %51
%53 = load float, float* %2
%54 = call float @copysignfk(float %52, float %53)
br label %55
55: ; preds = %49, %47
%56 = phi float [ %48, %47 ], [ %54, %49 ]
ret float %56
}

LLVM IR (-O2):
define float @xrintf(float %0) {
%2 = fadd float %0, 5.000000e-01
%3 = fptosi float %2 to i32
%4 = sitofp i32 %3 to float
%5 = fsub float %2, %4
%6 = fcmp olt float %5, 0.000000e+00
br i1 %6, label %12, label %7
7: ; preds = %1
%8 = and i32 %3, 1
%9 = icmp ne i32 %8, 0
%10 = fcmp oeq float %5, 0.000000e+00
%11 = select i1 %10, i1 %9, i1 false
br i1 %11, label %12, label %14
12: ; preds = %7, %1
%13 = fadd float %5, 1.000000e+00
br label %14
14: ; preds = %7, %12
%15 = phi float [ %13, %12 ], [ %5, %7 ]
%16 = fcmp oeq float %0, 0x3FE0000020000000
%17 = select i1 %16, float 0.000000e+00, float %2
%18 = tail call i64 @xisinff(float %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = tail call float @fabsfk(float %0)
%22 = fcmp ult float %21, 0x4160000000000000
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = fsub float %17, %15
%25 = tail call float @copysignfk(float %24, float %0)
br label %26
26: ; preds = %14, %20, %23
%27 = phi float [ %25, %23 ], [ %0, %20 ], [ %0, %14 ]
ret float %27
}