#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int mantissa1;
  int exponent;
};
union ieee754_double {
  double d;
  TYPE_1__ ieee;
};
typedef int /*<<< orphan*/ fenv_t;

/* Variables and functions */
int /*<<< orphan*/ FE_INEXACT;
int /*<<< orphan*/ FE_TOWARDZERO;
int /*<<< orphan*/ feholdexcept(int /*<<< orphan*/ *);
int /*<<< orphan*/ fesetround(int /*<<< orphan*/);
scalar_t__ fetestexcept(int /*<<< orphan*/);
int /*<<< orphan*/ feupdateenv(int /*<<< orphan*/ *);
float __fmaf(float x, float y, float z) {
  fenv_t env;
  double temp = (double)x * (double)y;
  union ieee754_double u;
  feholdexcept(&env);
  fesetround(FE_TOWARDZERO);
  u.d = temp + (double)z;
  if ((u.ieee.mantissa1 & 1) == 0 && u.ieee.exponent != 0x7ff)
    u.ieee.mantissa1 |= fetestexcept(FE_INEXACT) != 0;
  feupdateenv(&env);
  return (float)u.d;
}


x86 assembly (clang, -O0):
<__fmaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
call   1060 <feholdexcept@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1040 <fesetround@plt>
movsd  -0x18(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11dc <__fmaf+0x9c>
cmpl   $0x7ff,-0x1c(%rbp)
je     11dc <__fmaf+0x9c>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1030 <fetestexcept@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x10(%rbp),%rdi
call   1050 <feupdateenv@plt>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fmaf>:
push   %rbx
sub    $0x20,%rsp
movss  %xmm2,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
lea    0x14(%rsp),%rdi
call   1060 <feholdexcept@plt>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1040 <fesetround@plt>
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0x18(%rsp),%xmm0
movq   %xmm0,%rbx
test   $0x1,%bl
jne    11c9 <__fmaf+0x89>
movabs $0xffffffff00000000,%rax
ff ff ff
and    %rbx,%rax
movabs $0x7ff00000000,%rcx
cmp    %rcx,%rax
je     11c9 <__fmaf+0x89>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1030 <fetestexcept@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
or     %rcx,%rbx
movq   %rbx,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x14(%rsp),%rdi
call   1050 <feupdateenv@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%union.ieee754_double = type { double }
%struct.TYPE_2__ = type { i32, i32 }
@FE_TOWARDZERO = global i32 0
@FE_INEXACT = global i32 0
define float @__fmaf(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca double
%9 = alloca %union.ieee754_double
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%10 = load float, float* %4
%11 = fpext float %10 to double
%12 = load float, float* %5
%13 = fpext float %12 to double
%14 = fmul double %11, %13
store double %14, double* %8
%15 = call i32 @feholdexcept(i32* %7)
%16 = load i32, i32* @FE_TOWARDZERO
%17 = call i32 @fesetround(i32 %16)
%18 = load double, double* %8
%19 = load float, float* %6
%20 = fpext float %19 to double
%21 = fadd double %18, %20
%22 = bitcast %union.ieee754_double* %9 to double*
store double %21, double* %22
%23 = bitcast %union.ieee754_double* %9 to %struct.TYPE_2__*
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = and i32 %25, 1
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %42
28: ; preds = %3
%29 = bitcast %union.ieee754_double* %9 to %struct.TYPE_2__*
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = icmp ne i32 %31, 2047
br i1 %32, label %33, label %42
33: ; preds = %28
%34 = load i32, i32* @FE_INEXACT
%35 = call i64 @fetestexcept(i32 %34)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
%38 = bitcast %union.ieee754_double* %9 to %struct.TYPE_2__*
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = or i32 %40, %37
store i32 %41, i32* %39
br label %42
42: ; preds = %33, %28, %3
%43 = call i32 @feupdateenv(i32* %7)
%44 = bitcast %union.ieee754_double* %9 to double*
%45 = load double, double* %44
%46 = fptrunc double %45 to float
ret float %46
}

LLVM IR (-O2):
@FE_TOWARDZERO = global i32 0
@FE_INEXACT = global i32 0
define float @__fmaf(float %0, float %1, float %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = fpext float %0 to double
%7 = fpext float %1 to double
%8 = fmul double %6, %7
%9 = call i32 @feholdexcept(i32* %4)
%10 = load i32, i32* @FE_TOWARDZERO
%11 = call i32 @fesetround(i32 %10)
%12 = fpext float %2 to double
%13 = fadd double %8, %12
%14 = bitcast double %13 to i64
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
%17 = and i64 %14, -4294967296
%18 = icmp ne i64 %17, 8791798054912
%19 = and i1 %16, %18
br i1 %19, label %20, label %27
20: ; preds = %3
%21 = load i32, i32* @FE_INEXACT
%22 = call i64 @fetestexcept(i32 %21)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = or i64 %14, %24
%26 = bitcast i64 %25 to double
br label %27
27: ; preds = %20, %3
%28 = phi double [ %26, %20 ], [ %13, %3 ]
%29 = call i32 @feupdateenv(i32* %4)
%30 = fptrunc double %28 to float
ret float %30
}