#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__ isinf(float);
scalar_t__ isnan(float);
float __hsail_ftz_f32_f16(float a) {
  if (isnan(a) || isinf(a) || a == 0.0f)
    return a;
  if (a < 0.0f) {
    if (-a < (6.10e-5))
      return -0.0f;
  } else {
    if (a < (6.10e-5))
      return 0.0f;
  }
  return a;
}


x86 assembly (clang, -O0):
<__hsail_ftz_f32_f16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
jne    116c <__hsail_ftz_f32_f16+0x4c>
movss  -0x8(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
jne    116c <__hsail_ftz_f32_f16+0x4c>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    117b <__hsail_ftz_f32_f16+0x5b>
jp     117b <__hsail_ftz_f32_f16+0x5b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fe <__hsail_ftz_f32_f16+0xde>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11c7 <__hsail_ftz_f32_f16+0xa7>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c2 <__hsail_ftz_f32_f16+0xa2>
movss  0xe50(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fe <__hsail_ftz_f32_f16+0xde>
jmp    11f4 <__hsail_ftz_f32_f16+0xd4>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe28(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ef <__hsail_ftz_f32_f16+0xcf>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fe <__hsail_ftz_f32_f16+0xde>
jmp    11f4 <__hsail_ftz_f32_f16+0xd4>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__hsail_ftz_f32_f16>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     113b <__hsail_ftz_f32_f16+0x1b>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
movaps (%rsp),%xmm0
call   1040 <isinf@plt>
xorps  %xmm0,%xmm0
movaps (%rsp),%xmm3
ucomiss %xmm0,%xmm3
jne    1152 <__hsail_ftz_f32_f16+0x32>
jnp    119a <__hsail_ftz_f32_f16+0x7a>
test   %rax,%rax
jne    119a <__hsail_ftz_f32_f16+0x7a>
xorps  %xmm0,%xmm0
ucomiss %xmm3,%xmm0
jbe    1188 <__hsail_ftz_f32_f16+0x68>
movaps 0xeaa(%rip),%xmm0
xorps  %xmm3,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    119a <__hsail_ftz_f32_f16+0x7a>
movss  0xe9d(%rip),%xmm0
add    $0x18,%rsp
ret
cvtss2sd %xmm3,%xmm1
movsd  0xe6c(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     119d <__hsail_ftz_f32_f16+0x7d>
movaps %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @__hsail_ftz_f32_f16(float %0) {
%2 = alloca float
%3 = alloca float
store float %0, float* %3
%4 = load float, float* %3
%5 = call i64 @isnan(float %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %1
%8 = load float, float* %3
%9 = call i64 @isinf(float %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = load float, float* %3
%13 = fcmp oeq float %12, 0.000000e+00
br i1 %13, label %14, label %16
14: ; preds = %11, %7, %1
%15 = load float, float* %3
store float %15, float* %2
br label %34
16: ; preds = %11
%17 = load float, float* %3
%18 = fcmp olt float %17, 0.000000e+00
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load float, float* %3
%21 = fneg float %20
%22 = fpext float %21 to double
%23 = fcmp olt double %22, 6.100000e-05
br i1 %23, label %24, label %25
24: ; preds = %19
store float -0.000000e+00, float* %2
br label %34
25: ; preds = %19
br label %32
26: ; preds = %16
%27 = load float, float* %3
%28 = fpext float %27 to double
%29 = fcmp olt double %28, 6.100000e-05
br i1 %29, label %30, label %31
30: ; preds = %26
store float 0.000000e+00, float* %2
br label %34
31: ; preds = %26
br label %32
32: ; preds = %31, %25
%33 = load float, float* %3
store float %33, float* %2
br label %34
34: ; preds = %32, %30, %24, %14
%35 = load float, float* %2
ret float %35
}

LLVM IR (-O2):
define float @__hsail_ftz_f32_f16(float %0) {
%2 = tail call i64 @isnan(float %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %19
4: ; preds = %1
%5 = tail call i64 @isinf(float %0)
%6 = icmp ne i64 %5, 0
%7 = fcmp oeq float %0, 0.000000e+00
%8 = or i1 %7, %6
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = fcmp olt float %0, 0.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = fneg float %0
%13 = fpext float %12 to double
%14 = fcmp olt double %13, 6.100000e-05
br i1 %14, label %19, label %18
15: ; preds = %9
%16 = fpext float %0 to double
%17 = fcmp olt double %16, 6.100000e-05
br i1 %17, label %19, label %18
18: ; preds = %15, %11
br label %19
19: ; preds = %15, %11, %1, %4, %18
%20 = phi float [ %0, %18 ], [ %0, %4 ], [ %0, %1 ], [ -0.000000e+00, %11 ], [ 0.000000e+00, %15 ]
ret float %20
}