#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 && result - z == xy) || fegetround() != FE_TONEAREST) {
    z = result;
    return z;
  }
  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    1217 <fmaf+0xf7>
cmpl   $0x7ff,-0x2c(%rbp)
je     1217 <fmaf+0xf7>
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    11d5 <fmaf+0xb5>
jmp    1200 <fmaf+0xe0>
movsd  -0x20(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
ucomisd %xmm1,%xmm0
setnp  %cl
sete   %al
and    %cl,%al
test   $0x1,%al
jne    1217 <fmaf+0xf7>
mov    $0x0,%al
call   1040 <fegetround@plt>
mov    0x2dda(%rip),%rcx
cmp    (%rcx),%rax
je     1234 <fmaf+0x114>
movsd  -0x20(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    12bc <fmaf+0x19c>
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    0x2d8c(%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    1287 <fmaf+0x167>
jmp    12a4 <fmaf+0x184>
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 %54, label %33
33: ; preds = %3
%34 = load i32, i32* %11
%35 = icmp eq i32 %34, 2047
br i1 %35, label %54, 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 %43, label %50
43: ; preds = %36
%44 = load double, double* %9
%45 = load float, float* %7
%46 = call double @llvm.experimental.constrained.fpext.f64.f32(float %45, metadata !"fpexcept.strict")
%47 = call double @llvm.experimental.constrained.fsub.f64(double %44, double %46, metadata !"round.dynamic", metadata !"fpexcept.strict")
%48 = load double, double* %8
%49 = call i1 @llvm.experimental.constrained.fcmp.f64(double %47, double %48, metadata !"oeq", metadata !"fpexcept.strict")
br i1 %49, label %54, label %50
50: ; preds = %43, %36
%51 = call i64 (...) @fegetround()
%52 = load i64, i64* @FE_TONEAREST
%53 = icmp ne i64 %51, %52
br i1 %53, label %54, label %58
54: ; preds = %50, %43, %33, %3
%55 = load double, double* %9
%56 = call float @llvm.experimental.constrained.fptrunc.f32.f64(double %55, metadata !"round.dynamic", metadata !"fpexcept.strict")
store float %56, float* %7
%57 = load float, float* %7
store float %57, float* %4
br label %81
58: ; preds = %50
%59 = load double, double* %8
store double %59, double* %12
%60 = load double, double* %12
%61 = load float, float* %7
%62 = call double @llvm.experimental.constrained.fpext.f64.f32(float %61, metadata !"fpexcept.strict")
%63 = call double @llvm.experimental.constrained.fadd.f64(double %60, double %62, metadata !"round.dynamic", metadata !"fpexcept.strict")
store double %63, double* %13
%64 = load i64, i64* @FE_TONEAREST
%65 = call i32 @fesetround(i64 %64)
%66 = load double, double* %9
%67 = load double, double* %13
%68 = call i1 @llvm.experimental.constrained.fcmp.f64(double %66, double %67, metadata !"oeq", metadata !"fpexcept.strict")
br i1 %68, label %69, label %77
69: ; preds = %58
%70 = load double, double* %13
%71 = bitcast %union.anon* %10 to double*
store double %70, double* %71
%72 = bitcast %union.anon* %10 to i32*
%73 = load i32, i32* %72
%74 = add nsw i32 %73, 1
store i32 %74, i32* %72
%75 = bitcast %union.anon* %10 to double*
%76 = load double, double* %75
store double %76, double* %13
br label %77
77: ; preds = %69, %58
%78 = load double, double* %13
%79 = call float @llvm.experimental.constrained.fptrunc.f32.f64(double %78, metadata !"round.dynamic", metadata !"fpexcept.strict")
store float %79, float* %7
%80 = load float, float* %7
store float %80, float* %4
br label %81
81: ; preds = %77, %54
%82 = load float, float* %4
ret float %82
}

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
}