#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 FLT_MIN;
scalar_t__ isinf(float);
scalar_t__ isnan(float);
float __hsail_ftz_f32(float a) {
  if (isnan(a) || isinf(a) || a == 0.0f)
    return a;
  if (a < 0.0f) {
    if (-a < FLT_MIN)
      return -0.0f;
  } else {
    if (a < FLT_MIN)
      return 0.0f;
  }
  return a;
}


x86 assembly (clang, -O0):
<__hsail_ftz_f32>:
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+0x4c>
movss  -0x8(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
jne    116c <__hsail_ftz_f32+0x4c>
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    117b <__hsail_ftz_f32+0x5b>
jp     117b <__hsail_ftz_f32+0x5b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fa <__hsail_ftz_f32+0xda>
xorps  %xmm0,%xmm0
ucomiss -0x8(%rbp),%xmm0
jbe    11c5 <__hsail_ftz_f32+0xa5>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mov    0x2e47(%rip),%rax
movss  (%rax),%xmm0
ucomiss %xmm1,%xmm0
jbe    11c0 <__hsail_ftz_f32+0xa0>
movss  0xe4a(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fa <__hsail_ftz_f32+0xda>
jmp    11f0 <__hsail_ftz_f32+0xd0>
movss  -0x8(%rbp),%xmm1
mov    0x2e17(%rip),%rax
movss  (%rax),%xmm0
ucomiss %xmm1,%xmm0
jbe    11eb <__hsail_ftz_f32+0xcb>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11fa <__hsail_ftz_f32+0xda>
jmp    11f0 <__hsail_ftz_f32+0xd0>
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>:
sub    $0x18,%rsp
movaps %xmm0,(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     113b <__hsail_ftz_f32+0x1b>
movaps (%rsp),%xmm0
add    $0x18,%rsp
ret
movaps (%rsp),%xmm0
call   1040 <isinf@plt>
xorps  %xmm0,%xmm0
movaps (%rsp),%xmm2
ucomiss %xmm0,%xmm2
jne    1152 <__hsail_ftz_f32+0x32>
jnp    1196 <__hsail_ftz_f32+0x76>
test   %rax,%rax
jne    1196 <__hsail_ftz_f32+0x76>
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    1186 <__hsail_ftz_f32+0x66>
movaps 0xe9a(%rip),%xmm0
xorps  %xmm2,%xmm0
mov    0x2e78(%rip),%rax
movss  (%rax),%xmm1
ucomiss %xmm0,%xmm1
jbe    1196 <__hsail_ftz_f32+0x76>
movss  0xe8f(%rip),%xmm0
add    $0x18,%rsp
ret
mov    0x2e5b(%rip),%rax
movss  (%rax),%xmm1
ucomiss %xmm2,%xmm1
ja     1199 <__hsail_ftz_f32+0x79>
movaps %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@FLT_MIN = global float 0.000000e+00
define float @__hsail_ftz_f32(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 = load float, float* @FLT_MIN
%23 = fcmp olt float %21, %22
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 = load float, float* @FLT_MIN
%29 = fcmp olt float %27, %28
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):
@FLT_MIN = global float 0.000000e+00
define float @__hsail_ftz_f32(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 = load float, float* @FLT_MIN
%14 = fcmp ogt float %13, %12
br i1 %14, label %19, label %18
15: ; preds = %9
%16 = load float, float* @FLT_MIN
%17 = fcmp ogt float %16, %0
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
}