#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 */
int /*<<< orphan*/ printf(char *, ...);
void testfp4(double a, double b, double c) {
  double x;
  double y;
  printf(
      "x = (%.2f + %.2f) * %.2f; y = (%.2f * %.2f) + (%.2f * %.2f); x == y? ",
      a, b, c, a, b, c);
  x = (a + b) * c;
  y = (a * c) + (b * c);
  printf("[%s]\n", ((x == y)) ? "yes" : "NO!");
}


x86 assembly (clang, -O0):
<testfp4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm3
movsd  -0x10(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm5
lea    0xeb4(%rip),%rdi
mov    $0x6,%al
call   1030 <printf@plt>
movsd  -0x8(%rbp),%xmm0
addsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xeb7(%rip),%rsi
lea    0xeac(%rip),%rax
ucomisd %xmm1,%xmm0
setnp  %dl
sete   %cl
test   %dl,%cl
cmovne %rax,%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testfp4>:
sub    $0x18,%rsp
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
lea    0xed4(%rip),%rdi
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
mov    $0x6,%al
call   1030 <printf@plt>
movsd  (%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
ucomisd %xmm2,%xmm0
lea    0xee0(%rip),%rax
lea    0xed5(%rip),%rsi
cmovne %rax,%rsi
cmovp  %rax,%rsi
lea    0xec0(%rip),%rdi
xor    %eax,%eax
add    $0x18,%rsp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [70 x i8] c"x = (%.2f + %.2f) * %.2f; y = (%.2f * %.2f) + (%.2f * %.2f); x == y? \00"
@.str.1 = [6 x i8] c"[%s]\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [4 x i8] c"NO!\00"
define void @testfp4(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %4
%10 = load double, double* %5
%11 = load double, double* %6
%12 = load double, double* %4
%13 = load double, double* %5
%14 = load double, double* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), double %9, double %10, double %11, double %12, double %13, double %14)
%16 = load double, double* %4
%17 = load double, double* %5
%18 = fadd double %16, %17
%19 = load double, double* %6
%20 = fmul double %18, %19
store double %20, double* %7
%21 = load double, double* %4
%22 = load double, double* %6
%23 = load double, double* %5
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = call double @llvm.fmuladd.f64(double %21, double %22, double %25)
store double %26, double* %8
%27 = load double, double* %7
%28 = load double, double* %8
%29 = fcmp oeq double %27, %28
%30 = zext i1 %29 to i64
%31 = select i1 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %31)
ret void
}

LLVM IR (-O2):
@.str = [70 x i8] c"x = (%.2f + %.2f) * %.2f; y = (%.2f * %.2f) + (%.2f * %.2f); x == y? \00"
@.str.1 = [6 x i8] c"[%s]\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [4 x i8] c"NO!\00"
define void @testfp4(double %0, double %1, double %2) {
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0), double %0, double %1, double %2, double %0, double %1, double %2)
%5 = fadd double %0, %1
%6 = fmul double %5, %2
%7 = fmul double %1, %2
%8 = tail call double @llvm.fmuladd.f64(double %0, double %2, double %7)
%9 = fcmp oeq double %6, %8
%10 = select i1 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %10)
ret void
}