#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 */
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int vectVectMultCheckResultGMDP(double *h_VectA, double *h_VectB, double output,
                                int ROW) {
  int i;
  double sum = 0.0;
  double errorNorm = 0.0;
  double eps = 1.0e-15;
  double relativeError = 0.0;
  int flag = 0;
  for (i = 0; i < ROW; i++) {
    sum += h_VectA[i] * h_VectB[i];
  }
  if (fabs(sum) > fabs(output))
    relativeError = fabs((sum - output) / sum);
  else
    relativeError = fabs((output - sum) / output);
  if (relativeError > eps && relativeError != 0.0e+00) {
    if (errorNorm < relativeError) {
      errorNorm = relativeError;
      flag = 1;
    }
  }
  if (flag == 1) {
    printf(" \n Results verfication : Failed");
    printf(" \n Considered machine precision : %e", eps);
    printf(" \n Relative Error                  : %e", errorNorm);
  }
  if (flag == 0) {
    printf("\n\t\t Result Verification success\n\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<vectVectMultCheckResultGMDP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a1 <vectVectMultCheckResultGMDP+0x91>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115b <vectVectMultCheckResultGMDP+0x4b>
movsd  -0x28(%rbp),%xmm0
movaps 0xe63(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movaps 0xe53(%rip),%xmm2
pand   %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ef <vectVectMultCheckResultGMDP+0xdf>
movsd  -0x28(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movaps 0xe2f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    120e <vectVectMultCheckResultGMDP+0xfe>
movsd  -0x18(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movaps 0xe0b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1265 <vectVectMultCheckResultGMDP+0x155>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    123b <vectVectMultCheckResultGMDP+0x12b>
jp     123b <vectVectMultCheckResultGMDP+0x12b>
jmp    1265 <vectVectMultCheckResultGMDP+0x155>
movsd  -0x30(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1260 <vectVectMultCheckResultGMDP+0x150>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x1,-0x44(%rbp)
jmp    1265 <vectVectMultCheckResultGMDP+0x155>
cmpl   $0x1,-0x44(%rbp)
jne    12a3 <vectVectMultCheckResultGMDP+0x193>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xdb7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
lea    0xdc9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    12bb <vectVectMultCheckResultGMDP+0x1ab>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectVectMultCheckResultGMDP>:
sub    $0x18,%rsp
test   %edx,%edx
jle    1141 <vectVectMultCheckResultGMDP+0x21>
mov    %edx,%edx
lea    -0x1(%rdx),%rcx
mov    %edx,%eax
and    $0x3,%eax
cmp    $0x3,%rcx
jae    114a <vectVectMultCheckResultGMDP+0x2a>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
jmp    11a7 <vectVectMultCheckResultGMDP+0x87>
xorpd  %xmm1,%xmm1
jmp    11d7 <vectVectMultCheckResultGMDP+0xb7>
and    $0xfffffffc,%edx
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rdi,%rcx,8),%xmm2
movsd  0x8(%rdi,%rcx,8),%xmm3
mulsd  (%rsi,%rcx,8),%xmm2
mulsd  0x8(%rsi,%rcx,8),%xmm3
addsd  %xmm1,%xmm2
movsd  0x10(%rdi,%rcx,8),%xmm4
mulsd  0x10(%rsi,%rcx,8),%xmm4
addsd  %xmm2,%xmm3
movsd  0x18(%rdi,%rcx,8),%xmm1
mulsd  0x18(%rsi,%rcx,8),%xmm1
addsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
add    $0x4,%rcx
cmp    %rcx,%rdx
jne    1160 <vectVectMultCheckResultGMDP+0x40>
test   %rax,%rax
je     11d7 <vectVectMultCheckResultGMDP+0xb7>
lea    (%rsi,%rcx,8),%rdx
lea    (%rdi,%rcx,8),%rcx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movsd  (%rcx,%rsi,8),%xmm2
mulsd  (%rdx,%rsi,8),%xmm2
addsd  %xmm2,%xmm1
add    $0x1,%rsi
cmp    %rsi,%rax
jne    11c0 <vectVectMultCheckResultGMDP+0xa0>
movapd 0xe21(%rip),%xmm2
movapd %xmm1,%xmm3
andpd  %xmm2,%xmm3
andpd  %xmm0,%xmm2
ucomisd %xmm2,%xmm3
jbe    11ff <vectVectMultCheckResultGMDP+0xdf>
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
jmp    120b <vectVectMultCheckResultGMDP+0xeb>
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
je     1275 <vectVectMultCheckResultGMDP+0x155>
movapd 0xde3(%rip),%xmm1
andpd  %xmm2,%xmm1
ucomisd 0xde7(%rip),%xmm1
jbe    1275 <vectVectMultCheckResultGMDP+0x155>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1237 <vectVectMultCheckResultGMDP+0x117>
jnp    1275 <vectVectMultCheckResultGMDP+0x155>
lea    0xdda(%rip),%rdi
xor    %eax,%eax
movapd %xmm1,(%rsp)
call   1040 <printf@plt>
lea    0xde7(%rip),%rdi
movsd  0xdb7(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdf6(%rip),%rdi
movapd (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1281 <vectVectMultCheckResultGMDP+0x161>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [32 x i8] c" \0A Results verfication : Failed\00"
@.str.1 = [37 x i8] c" \0A Considered machine precision : %e\00"
@.str.2 = [40 x i8] c" \0A Relative Error : %e\00"
@.str.3 = [34 x i8] c"\0A\09\09 Result Verification success\0A\0A\00"
define i32 @vectVectMultCheckResultGMDP(double* %0, double* %1, double %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store i32 %3, i32* %8
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 1.000000e-15, double* %12
store double 0.000000e+00, double* %13
store i32 0, i32* %14
store i32 0, i32* %9
br label %15
15: ; preds = %32, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %35
19: ; preds = %15
%20 = load double*, double** %5
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double, double* %10
%31 = call double @llvm.fmuladd.f64(double %24, double %29, double %30)
store double %31, double* %10
br label %32
32: ; preds = %19
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %15
35: ; preds = %15
%36 = load double, double* %10
%37 = call double @llvm.fabs.f64(double %36)
%38 = load double, double* %7
%39 = call double @llvm.fabs.f64(double %38)
%40 = fcmp ogt double %37, %39
br i1 %40, label %41, label %48
41: ; preds = %35
%42 = load double, double* %10
%43 = load double, double* %7
%44 = fsub double %42, %43
%45 = load double, double* %10
%46 = fdiv double %44, %45
%47 = call double @llvm.fabs.f64(double %46)
store double %47, double* %13
br label %55
48: ; preds = %35
%49 = load double, double* %7
%50 = load double, double* %10
%51 = fsub double %49, %50
%52 = load double, double* %7
%53 = fdiv double %51, %52
%54 = call double @llvm.fabs.f64(double %53)
store double %54, double* %13
br label %55
55: ; preds = %48, %41
%56 = load double, double* %13
%57 = load double, double* %12
%58 = fcmp ogt double %56, %57
br i1 %58, label %59, label %69
59: ; preds = %55
%60 = load double, double* %13
%61 = fcmp une double %60, 0.000000e+00
br i1 %61, label %62, label %69
62: ; preds = %59
%63 = load double, double* %11
%64 = load double, double* %13
%65 = fcmp olt double %63, %64
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = load double, double* %13
store double %67, double* %11
store i32 1, i32* %14
br label %68
68: ; preds = %66, %62
br label %69
69: ; preds = %68, %59, %55
%70 = load i32, i32* %14
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %78
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%74 = load double, double* %12
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %74)
%76 = load double, double* %11
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %76)
br label %78
78: ; preds = %72, %69
%79 = load i32, i32* %14
%80 = icmp eq i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %83
83: ; preds = %81, %78
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c" \0A Results verfication : Failed\00"
@.str.1 = [37 x i8] c" \0A Considered machine precision : %e\00"
@.str.2 = [40 x i8] c" \0A Relative Error : %e\00"
@str = [33 x i8] c"\0A\09\09 Result Verification success\0A\00"
define i32 @vectVectMultCheckResultGMDP(double* nocapture %0, double* nocapture %1, double %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %60
6: ; preds = %4
%7 = zext i32 %3 to i64
%8 = add nsw i64 %7, -1
%9 = and i64 %7, 3
%10 = icmp ult i64 %8, 3
br i1 %10, label %43, label %11
11: ; preds = %6
%12 = and i64 %7, 4294967292
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %40, %13 ]
%15 = phi double [ 0.000000e+00, %11 ], [ %39, %13 ]
%16 = phi i64 [ 0, %11 ], [ %41, %13 ]
%17 = getelementptr inbounds double, double* %0, i64 %14
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %1, i64 %14
%20 = load double, double* %19
%21 = tail call double @llvm.fmuladd.f64(double %18, double %20, double %15)
%22 = or i64 %14, 1
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %1, i64 %22
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %21)
%28 = or i64 %14, 2
%29 = getelementptr inbounds double, double* %0, i64 %28
%30 = load double, double* %29
%31 = getelementptr inbounds double, double* %1, i64 %28
%32 = load double, double* %31
%33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %27)
%34 = or i64 %14, 3
%35 = getelementptr inbounds double, double* %0, i64 %34
%36 = load double, double* %35
%37 = getelementptr inbounds double, double* %1, i64 %34
%38 = load double, double* %37
%39 = tail call double @llvm.fmuladd.f64(double %36, double %38, double %33)
%40 = add nuw nsw i64 %14, 4
%41 = add i64 %16, 4
%42 = icmp eq i64 %41, %12
br i1 %42, label %43, label %13
43: ; preds = %13, %6
%44 = phi double [ undef, %6 ], [ %39, %13 ]
%45 = phi i64 [ 0, %6 ], [ %40, %13 ]
%46 = phi double [ 0.000000e+00, %6 ], [ %39, %13 ]
%47 = icmp eq i64 %9, 0
br i1 %47, label %60, label %48
48: ; preds = %43, %48
%49 = phi i64 [ %57, %48 ], [ %45, %43 ]
%50 = phi double [ %56, %48 ], [ %46, %43 ]
%51 = phi i64 [ %58, %48 ], [ 0, %43 ]
%52 = getelementptr inbounds double, double* %0, i64 %49
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %1, i64 %49
%55 = load double, double* %54
%56 = tail call double @llvm.fmuladd.f64(double %53, double %55, double %50)
%57 = add nuw nsw i64 %49, 1
%58 = add i64 %51, 1
%59 = icmp eq i64 %58, %9
br i1 %59, label %60, label %48
60: ; preds = %43, %48, %4
%61 = phi double [ 0.000000e+00, %4 ], [ %44, %43 ], [ %56, %48 ]
%62 = tail call double @llvm.fabs.f64(double %61)
%63 = tail call double @llvm.fabs.f64(double %2)
%64 = fcmp ogt double %62, %63
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = fsub double %61, %2
%67 = fdiv double %66, %61
br label %71
68: ; preds = %60
%69 = fsub double %2, %61
%70 = fdiv double %69, %2
br label %71
71: ; preds = %68, %65
%72 = phi double [ %70, %68 ], [ %67, %65 ]
%73 = tail call double @llvm.fabs.f64(double %72)
%74 = fcmp ogt double %73, 1.000000e-15
%75 = fcmp une double %72, 0.000000e+00
%76 = and i1 %74, %75
%77 = fcmp one double %72, 0.000000e+00
%78 = and i1 %77, %76
br i1 %78, label %79, label %83
79: ; preds = %71
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%81 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 1.000000e-15)
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %73)
br label %85
83: ; preds = %71
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %85
85: ; preds = %79, %83
ret i32 0
}