#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 *, ...);
int /*<<< orphan*/ store(double);
int run_test(int n) {
  int i;
  for (i = 0; i < n; i++) {
    double a, b, c, d, e, f, g, h;
    if (i & 1) {
      a = i * 100 + 39;
      b = (3000000 - i * 6);
    } else {
      a = (2800000 - i * 7);
      b = i * 121 + 45;
    }
    store(a);
    store(b);
    a = a / 23456;
    b = b / 12345;
    store(a);
    store(b);
    c = a * a;
    store(c);
    d = b * b;
    store(d);
    e = c - d;
    store(e);
    f = a + b;
    store(f);
    g = a - b;
    store(g);
    h = f * g;
    store(h);
    if (e - h > 0.000001) {
      printf("Mismatch: a=%f, b=%f:  e=%f, h=%f, delta=%f\n", a, b, e, h,
             e - h);
      printf("VFP test FAILED!\n");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12f9 <run_test+0x1d9>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1176 <run_test+0x56>
imul   $0x64,-0xc(%rbp),%eax
add    $0x27,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
imul   $0x6,-0xc(%rbp),%ecx
mov    $0x2dc6c0,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    119a <run_test+0x7a>
imul   $0x7,-0xc(%rbp),%ecx
mov    $0x2ab980,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
imul   $0x79,-0xc(%rbp),%eax
add    $0x2d,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x20(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe37(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x20(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <store@plt>
movsd  -0x38(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  0xd6a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12e6 <run_test+0x1c6>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
subsd  -0x50(%rbp),%xmm4
lea    0xd53(%rip),%rdi
mov    $0x5,%al
call   1040 <printf@plt>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1300 <run_test+0x1e0>
jmp    12eb <run_test+0x1cb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1132 <run_test+0x12>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
test   %edi,%edi
jle    12a3 <run_test+0x173>
mov    %edi,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
test   $0x1,%bpl
sete   %al
movd   %eax,%xmm0
pshufd $0x50,%xmm0,%xmm0
pslld  $0x1f,%xmm0
psrad  $0x1f,%xmm0
movdqa %xmm0,%xmm1
pandn  0xe88(%rip),%xmm1
movdqa %xmm0,%xmm2
pand   0xe8c(%rip),%xmm2
por    %xmm1,%xmm2
movdqa %xmm0,%xmm1
pandn  0xe8c(%rip),%xmm1
pand   0xe94(%rip),%xmm0
por    %xmm1,%xmm0
movd   %ebp,%xmm1
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm1,%xmm3
pmuludq %xmm2,%xmm1
punpckldq %xmm3,%xmm1
paddd  %xmm0,%xmm1
cvtdq2pd %xmm1,%xmm0
movaps %xmm0,(%rsp)
call   1030 <store@plt>
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <store@plt>
movapd (%rsp),%xmm0
divpd  0xe61(%rip),%xmm0
movapd %xmm0,(%rsp)
call   1030 <store@plt>
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
call   1030 <store@plt>
movapd (%rsp),%xmm0
mulpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
call   1030 <store@plt>
movaps 0x20(%rsp),%xmm0
movhlps %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
call   1030 <store@plt>
movapd 0x20(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
call   1030 <store@plt>
movapd 0x30(%rsp),%xmm0
addsd  (%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
call   1030 <store@plt>
movapd (%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <store@plt>
movapd 0x10(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
call   1030 <store@plt>
movapd 0x10(%rsp),%xmm3
movapd 0x20(%rsp),%xmm2
movapd %xmm2,%xmm4
subsd  %xmm3,%xmm4
ucomisd 0xdba(%rip),%xmm4
ja     12a7 <run_test+0x177>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1150 <run_test+0x20>
xor    %eax,%eax
jmp    12d1 <run_test+0x1a1>
lea    0xdaa(%rip),%rdi
movapd (%rsp),%xmm0
movdqa 0x30(%rsp),%xmm1
mov    $0x5,%al
call   1050 <printf@plt>
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"Mismatch: a=%f, b=%f: e=%f, h=%f, delta=%f\0A\00"
@.str.1 = [18 x i8] c"VFP test FAILED!\0A\00"
define i32 @run_test(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %3
store i32 0, i32* %4
br label %13
13: ; preds = %97, %1
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %100
17: ; preds = %13
%18 = load i32, i32* %4
%19 = and i32 %18, 1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %4
%23 = mul nsw i32 %22, 100
%24 = add nsw i32 %23, 39
%25 = sitofp i32 %24 to double
store double %25, double* %5
%26 = load i32, i32* %4
%27 = mul nsw i32 %26, 6
%28 = sub nsw i32 3000000, %27
%29 = sitofp i32 %28 to double
store double %29, double* %6
br label %39
30: ; preds = %17
%31 = load i32, i32* %4
%32 = mul nsw i32 %31, 7
%33 = sub nsw i32 2800000, %32
%34 = sitofp i32 %33 to double
store double %34, double* %5
%35 = load i32, i32* %4
%36 = mul nsw i32 %35, 121
%37 = add nsw i32 %36, 45
%38 = sitofp i32 %37 to double
store double %38, double* %6
br label %39
39: ; preds = %30, %21
%40 = load double, double* %5
%41 = call i32 @store(double %40)
%42 = load double, double* %6
%43 = call i32 @store(double %42)
%44 = load double, double* %5
%45 = fdiv double %44, 2.345600e+04
store double %45, double* %5
%46 = load double, double* %6
%47 = fdiv double %46, 1.234500e+04
store double %47, double* %6
%48 = load double, double* %5
%49 = call i32 @store(double %48)
%50 = load double, double* %6
%51 = call i32 @store(double %50)
%52 = load double, double* %5
%53 = load double, double* %5
%54 = fmul double %52, %53
store double %54, double* %7
%55 = load double, double* %7
%56 = call i32 @store(double %55)
%57 = load double, double* %6
%58 = load double, double* %6
%59 = fmul double %57, %58
store double %59, double* %8
%60 = load double, double* %8
%61 = call i32 @store(double %60)
%62 = load double, double* %7
%63 = load double, double* %8
%64 = fsub double %62, %63
store double %64, double* %9
%65 = load double, double* %9
%66 = call i32 @store(double %65)
%67 = load double, double* %5
%68 = load double, double* %6
%69 = fadd double %67, %68
store double %69, double* %10
%70 = load double, double* %10
%71 = call i32 @store(double %70)
%72 = load double, double* %5
%73 = load double, double* %6
%74 = fsub double %72, %73
store double %74, double* %11
%75 = load double, double* %11
%76 = call i32 @store(double %75)
%77 = load double, double* %10
%78 = load double, double* %11
%79 = fmul double %77, %78
store double %79, double* %12
%80 = load double, double* %12
%81 = call i32 @store(double %80)
%82 = load double, double* %9
%83 = load double, double* %12
%84 = fsub double %82, %83
%85 = fcmp ogt double %84, 0x3EB0C6F7A0B5ED8D
br i1 %85, label %86, label %96
86: ; preds = %39
%87 = load double, double* %5
%88 = load double, double* %6
%89 = load double, double* %9
%90 = load double, double* %12
%91 = load double, double* %9
%92 = load double, double* %12
%93 = fsub double %91, %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %87, double %88, double %89, double %90, double %93)
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %101
96: ; preds = %39
br label %97
97: ; preds = %96
%98 = load i32, i32* %4
%99 = add nsw i32 %98, 1
store i32 %99, i32* %4
br label %13
100: ; preds = %13
store i32 0, i32* %2
br label %101
101: ; preds = %100, %86
%102 = load i32, i32* %2
ret i32 %102
}

LLVM IR (-O2):
@.str = [45 x i8] c"Mismatch: a=%f, b=%f: e=%f, h=%f, delta=%f\0A\00"
@str = [17 x i8] c"VFP test FAILED!\00"
define i32 @run_test(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %5, label %47
3: ; preds = %5
%4 = icmp eq i32 %42, %0
br i1 %4, label %47, label %5
5: ; preds = %1, %3
%6 = phi i32 [ %42, %3 ], [ 0, %1 ]
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
%9 = insertelement <2 x i1> poison, i1 %8, i64 0
%10 = shufflevector <2 x i1> %9, <2 x i1> poison, <2 x i32> zeroinitializer
%11 = select <2 x i1> %10, <2 x i32> <i32 -7, i32 121>, <2 x i32> <i32 100, i32 -6>
%12 = select <2 x i1> %10, <2 x i32> <i32 2800000, i32 45>, <2 x i32> <i32 39, i32 3000000>
%13 = insertelement <2 x i32> poison, i32 %6, i64 0
%14 = shufflevector <2 x i32> %13, <2 x i32> poison, <2 x i32> zeroinitializer
%15 = mul <2 x i32> %14, %11
%16 = add <2 x i32> %15, %12
%17 = sitofp <2 x i32> %16 to <2 x double>
%18 = extractelement <2 x double> %17, i64 0
%19 = tail call i32 @store(double %18)
%20 = extractelement <2 x double> %17, i64 1
%21 = tail call i32 @store(double %20)
%22 = fdiv <2 x double> %17, <double 2.345600e+04, double 1.234500e+04>
%23 = extractelement <2 x double> %22, i64 0
%24 = tail call i32 @store(double %23)
%25 = extractelement <2 x double> %22, i64 1
%26 = tail call i32 @store(double %25)
%27 = fmul <2 x double> %22, %22
%28 = extractelement <2 x double> %27, i64 0
%29 = tail call i32 @store(double %28)
%30 = extractelement <2 x double> %27, i64 1
%31 = tail call i32 @store(double %30)
%32 = fsub double %28, %30
%33 = tail call i32 @store(double %32)
%34 = fadd double %25, %23
%35 = tail call i32 @store(double %34)
%36 = fsub double %23, %25
%37 = tail call i32 @store(double %36)
%38 = fmul double %34, %36
%39 = tail call i32 @store(double %38)
%40 = fsub double %32, %38
%41 = fcmp ogt double %40, 0x3EB0C6F7A0B5ED8D
%42 = add nuw nsw i32 %6, 1
br i1 %41, label %43, label %3
43: ; preds = %5
%44 = extractelement <2 x double> %22, i64 0
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), double %44, double %25, double %32, double %38, double %40)
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %47
47: ; preds = %3, %1, %43
%48 = phi i32 [ -1, %43 ], [ 0, %1 ], [ 0, %3 ]
ret i32 %48
}