#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 uint64_t;

/* Variables and functions */
scalar_t__ FE_TONEAREST;
scalar_t__ fegetround();
int /*<<< orphan*/ fesetround(scalar_t__);
float fmaf(float x, float y, float z) {
#pragma STDC FENV_ACCESS ON
  double xy, result;
  union {
    double f;
    uint64_t i;
  } u;
  int e;
  xy = (double)x * y;
  result = xy + z;
  u.f = result;
  e = u.i >> 52 & 0x7ff;
  if ((u.i & 0x1fffffff) != 0x10000000 || e == 0x7ff || result - xy == z ||
      fegetround() != FE_TONEAREST) {
    z = result;
    return z;
  }
  volatile double vxy = xy;
  double adjusted_result = vxy + z;
  fesetround(FE_TONEAREST);
  if (result == adjusted_result) {
    u.f = adjusted_result;
    u.i++;
    adjusted_result = u.f;
  }
  z = adjusted_result;
  return z;
}


x86 assembly (clang, -O0):
<fmaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x34,%ecx
sar    %cl,%eax
and    $0x7ff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
and    $0x1fffffff,%eax
cmp    $0x10000000,%eax
jne    11e7 <fmaf+0xc7>
cmpl   $0x7ff,-0x2c(%rbp)
je     11e7 <fmaf+0xc7>
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setnp  %cl
sete   %al
and    %cl,%al
test   $0x1,%al
jne    11e7 <fmaf+0xc7>
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%rax
je     1204 <fmaf+0xe4>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    128c <fmaf+0x16c>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    0x2dbc(%rip),%rax
mov    (%rax),%rdi
call   1030 <fesetround@plt>
movsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
ucomisd %xmm1,%xmm0
setnp  %cl
sete   %al
and    %cl,%al
test   $0x1,%al
jne    1257 <fmaf+0x137>
jmp    1274 <fmaf+0x154>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmaf>:
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
ret

LLVM IR (-O0):
%union.anon = type { double }
@FE_TONEAREST = global i64 0
define float @fmaf(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca double
%9 = alloca double
%10 = alloca %union.anon
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%14 = load float, float* %5
%15 = call double @llvm.experimental.constrained.fpext.f64.f32(float %14, metadata !"fpexcept.strict")
%16 = load float, float* %6
%17 = call double @llvm.experimental.constrained.fpext.f64.f32(float %16, metadata !"fpexcept.strict")
%18 = call double @llvm.experimental.constrained.fmul.f64(double %15, double %17, metadata !"round.dynamic", metadata !"fpexcept.strict")
store double %18, double* %8
%19 = load double, double* %8
%20 = load float, float* %7
%21 = call double @llvm.experimental.constrained.fpext.f64.f32(float %20, metadata !"fpexcept.strict")
%22 = call double @llvm.experimental.constrained.fadd.f64(double %19, double %21, metadata !"round.dynamic", metadata !"fpexcept.strict")
store double %22, double* %9
%23 = load double, double* %9
%24 = bitcast %union.anon* %10 to double*
store double %23, double* %24
%25 = bitcast %union.anon* %10 to i32*
%26 = load i32, i32* %25
%27 = ashr i32 %26, 52
%28 = and i32 %27, 2047
store i32 %28, i32* %11
%29 = bitcast %union.anon* %10 to i32*
%30 = load i32, i32* %29
%31 = and i32 %30, 536870911
%32 = icmp ne i32 %31, 268435456
br i1 %32, label %47, label %33
33: ; preds = %3
%34 = load i32, i32* %11
%35 = icmp eq i32 %34, 2047
br i1 %35, label %47, label %36
36: ; preds = %33
%37 = load double, double* %9
%38 = load double, double* %8
%39 = call double @llvm.experimental.constrained.fsub.f64(double %37, double %38, metadata !"round.dynamic", metadata !"fpexcept.strict")
%40 = load float, float* %7
%41 = call double @llvm.experimental.constrained.fpext.f64.f32(float %40, metadata !"fpexcept.strict")
%42 = call i1 @llvm.experimental.constrained.fcmp.f64(double %39, double %41, metadata !"oeq", metadata !"fpexcept.strict")
br i1 %42, label %47, label %43
43: ; preds = %36
%44 = call i64 (...) @fegetround()
%45 = load i64, i64* @FE_TONEAREST
%46 = icmp ne i64 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %43, %36, %33, %3
%48 = load double, double* %9
%49 = call float @llvm.experimental.constrained.fptrunc.f32.f64(double %48, metadata !"round.dynamic", metadata !"fpexcept.strict")
store float %49, float* %7
%50 = load float, float* %7
store float %50, float* %4
br label %74
51: ; preds = %43
%52 = load double, double* %8
store volatile double %52, double* %12
%53 = load volatile double, double* %12
%54 = load float, float* %7
%55 = call double @llvm.experimental.constrained.fpext.f64.f32(float %54, metadata !"fpexcept.strict")
%56 = call double @llvm.experimental.constrained.fadd.f64(double %53, double %55, metadata !"round.dynamic", metadata !"fpexcept.strict")
store double %56, double* %13
%57 = load i64, i64* @FE_TONEAREST
%58 = call i32 @fesetround(i64 %57)
%59 = load double, double* %9
%60 = load double, double* %13
%61 = call i1 @llvm.experimental.constrained.fcmp.f64(double %59, double %60, metadata !"oeq", metadata !"fpexcept.strict")
br i1 %61, label %62, label %70
62: ; preds = %51
%63 = load double, double* %13
%64 = bitcast %union.anon* %10 to double*
store double %63, double* %64
%65 = bitcast %union.anon* %10 to i32*
%66 = load i32, i32* %65
%67 = add nsw i32 %66, 1
store i32 %67, i32* %65
%68 = bitcast %union.anon* %10 to double*
%69 = load double, double* %68
store double %69, double* %13
br label %70
70: ; preds = %62, %51
%71 = load double, double* %13
%72 = call float @llvm.experimental.constrained.fptrunc.f32.f64(double %71, metadata !"round.dynamic", metadata !"fpexcept.strict")
store float %72, float* %7
%73 = load float, float* %7
store float %73, float* %4
br label %74
74: ; preds = %70, %47
%75 = load float, float* %4
ret float %75
}

LLVM IR (-O2):
@FE_TONEAREST = global i64 0
define float @fmaf(float %0, float %1, float %2) {
%4 = tail call double @llvm.experimental.constrained.fpext.f64.f32(float %0, metadata !"fpexcept.strict")
%5 = tail call double @llvm.experimental.constrained.fpext.f64.f32(float %1, metadata !"fpexcept.strict")
%6 = tail call double @llvm.experimental.constrained.fmul.f64(double %4, double %5, metadata !"round.dynamic", metadata !"fpexcept.strict")
%7 = tail call double @llvm.experimental.constrained.fpext.f64.f32(float %2, metadata !"fpexcept.strict")
%8 = tail call double @llvm.experimental.constrained.fadd.f64(double %6, double %7, metadata !"round.dynamic", metadata !"fpexcept.strict")
%9 = tail call float @llvm.experimental.constrained.fptrunc.f32.f64(double %8, metadata !"round.dynamic", metadata !"fpexcept.strict")
ret float %9
}