#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 pieCalCheckResultGMDP(int noOfIntervals, double *finalPieValue) {
  double totalsum = 0.0, x = 0.0;
  double h = 1.0 / noOfIntervals;
  int i;
  double errorNorm = 0.0;
  double eps = 1.0e-15;
  double relativeError = 0.0;
  int flag = 0;
  for (i = 1; i < noOfIntervals + 1; i = i + 1) {
    x = h * (i + 0.5);
    totalsum = totalsum + 4.0 / (1.0 + x * x);
  }
  totalsum = totalsum * h;
  relativeError = ((totalsum - ((*finalPieValue))) / totalsum);
  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):
<pieCalCheckResultGMDP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xecc(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11e2 <pieCalCheckResultGMDP+0xd2>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  0xe85(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm2
movsd  0xe4d(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0xe49(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1170 <pieCalCheckResultGMDP+0x60>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    125f <pieCalCheckResultGMDP+0x14f>
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1235 <pieCalCheckResultGMDP+0x125>
jp     1235 <pieCalCheckResultGMDP+0x125>
jmp    125f <pieCalCheckResultGMDP+0x14f>
movsd  -0x38(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    125a <pieCalCheckResultGMDP+0x14a>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    125f <pieCalCheckResultGMDP+0x14f>
cmpl   $0x1,-0x4c(%rbp)
jne    129d <pieCalCheckResultGMDP+0x18d>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xdbd(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xdcf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x4c(%rbp)
jne    12b5 <pieCalCheckResultGMDP+0x1a5>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pieCalCheckResultGMDP>:
push   %rax
cvtsi2sd %edi,%xmm1
movsd  0xed3(%rip),%xmm3
movapd %xmm3,%xmm0
divsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
xorpd  %xmm2,%xmm2
test   %edi,%edi
jle    1215 <pieCalCheckResultGMDP+0xf5>
cmp    $0x1,%edi
jne    1165 <pieCalCheckResultGMDP+0x45>
movsd  0xeb6(%rip),%xmm3
xorpd  %xmm2,%xmm2
test   $0x1,%dil
jne    11f5 <pieCalCheckResultGMDP+0xd5>
jmp    1215 <pieCalCheckResultGMDP+0xf5>
mov    %edi,%eax
and    $0xfffffffe,%eax
mov    $0x1,%ecx
xorpd  %xmm2,%xmm2
movsd  0xe95(%rip),%xmm4
movsd  0xe95(%rip),%xmm5
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm6,%xmm6
cvtsi2sd %ecx,%xmm6
addsd  %xmm4,%xmm6
mulsd  %xmm0,%xmm6
mulsd  %xmm6,%xmm6
addsd  %xmm3,%xmm6
movapd %xmm5,%xmm7
divsd  %xmm6,%xmm7
addsd  %xmm2,%xmm7
lea    0x1(%rcx),%edx
xorps  %xmm6,%xmm6
cvtsi2sd %edx,%xmm6
addsd  %xmm4,%xmm6
mulsd  %xmm0,%xmm6
mulsd  %xmm6,%xmm6
addsd  %xmm3,%xmm6
movapd %xmm5,%xmm2
divsd  %xmm6,%xmm2
addsd  %xmm7,%xmm2
add    $0x2,%ecx
cmp    %eax,%edx
jne    1190 <pieCalCheckResultGMDP+0x70>
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
addsd  0xe21(%rip),%xmm3
test   $0x1,%dil
je     1215 <pieCalCheckResultGMDP+0xf5>
mulsd  %xmm0,%xmm3
mulsd  %xmm3,%xmm3
addsd  0xdfb(%rip),%xmm3
movsd  0xe0b(%rip),%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm0
movapd %xmm0,%xmm2
subsd  (%rsi),%xmm2
divsd  %xmm0,%xmm2
ucomisd %xmm1,%xmm2
jbe    127f <pieCalCheckResultGMDP+0x15f>
ucomisd 0xded(%rip),%xmm2
jbe    127f <pieCalCheckResultGMDP+0x15f>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jne    1241 <pieCalCheckResultGMDP+0x121>
jnp    127f <pieCalCheckResultGMDP+0x15f>
lea    0xde0(%rip),%rdi
xor    %eax,%eax
movsd  %xmm2,(%rsp)
call   1040 <printf@plt>
lea    0xded(%rip),%rdi
movsd  0xdbd(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xdfc(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    128b <pieCalCheckResultGMDP+0x16b>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
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 @pieCalCheckResultGMDP(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
%13 = load i32, i32* %3
%14 = sitofp i32 %13 to double
%15 = fdiv double 1.000000e+00, %14
store double %15, double* %7
store double 0.000000e+00, double* %9
store double 1.000000e-15, double* %10
store double 0.000000e+00, double* %11
store i32 0, i32* %12
store i32 1, i32* %8
br label %16
16: ; preds = %33, %2
%17 = load i32, i32* %8
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %36
21: ; preds = %16
%22 = load double, double* %7
%23 = load i32, i32* %8
%24 = sitofp i32 %23 to double
%25 = fadd double %24, 5.000000e-01
%26 = fmul double %22, %25
store double %26, double* %6
%27 = load double, double* %5
%28 = load double, double* %6
%29 = load double, double* %6
%30 = call double @llvm.fmuladd.f64(double %28, double %29, double 1.000000e+00)
%31 = fdiv double 4.000000e+00, %30
%32 = fadd double %27, %31
store double %32, double* %5
br label %33
33: ; preds = %21
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %16
36: ; preds = %16
%37 = load double, double* %5
%38 = load double, double* %7
%39 = fmul double %37, %38
store double %39, double* %5
%40 = load double, double* %5
%41 = load double*, double** %4
%42 = load double, double* %41
%43 = fsub double %40, %42
%44 = load double, double* %5
%45 = fdiv double %43, %44
store double %45, double* %11
%46 = load double, double* %11
%47 = load double, double* %10
%48 = fcmp ogt double %46, %47
br i1 %48, label %49, label %59
49: ; preds = %36
%50 = load double, double* %11
%51 = fcmp une double %50, 0.000000e+00
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load double, double* %9
%54 = load double, double* %11
%55 = fcmp olt double %53, %54
br i1 %55, label %56, label %58
56: ; preds = %52
%57 = load double, double* %11
store double %57, double* %9
store i32 1, i32* %12
br label %58
58: ; preds = %56, %52
br label %59
59: ; preds = %58, %49, %36
%60 = load i32, i32* %12
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %68
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%64 = load double, double* %10
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %64)
%66 = load double, double* %9
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %66)
br label %68
68: ; preds = %62, %59
%69 = load i32, i32* %12
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %68
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %68
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 @pieCalCheckResultGMDP(i32 %0, double* nocapture %1) {
%3 = sitofp i32 %0 to double
%4 = fdiv double 1.000000e+00, %3
%5 = icmp slt i32 %0, 1
br i1 %5, label %44, label %6
6: ; preds = %2
%7 = and i32 %0, 1
%8 = icmp eq i32 %0, 1
br i1 %8, label %34, label %9
9: ; preds = %6
%10 = and i32 %0, -2
br label %11
11: ; preds = %11, %9
%12 = phi double [ 0.000000e+00, %9 ], [ %27, %11 ]
%13 = phi i32 [ 1, %9 ], [ %28, %11 ]
%14 = phi i32 [ 0, %9 ], [ %29, %11 ]
%15 = sitofp i32 %13 to double
%16 = fadd double %15, 5.000000e-01
%17 = fmul double %4, %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double %17, double 1.000000e+00)
%19 = fdiv double 4.000000e+00, %18
%20 = fadd double %12, %19
%21 = add nuw i32 %13, 1
%22 = sitofp i32 %21 to double
%23 = fadd double %22, 5.000000e-01
%24 = fmul double %4, %23
%25 = tail call double @llvm.fmuladd.f64(double %24, double %24, double 1.000000e+00)
%26 = fdiv double 4.000000e+00, %25
%27 = fadd double %20, %26
%28 = add nuw i32 %13, 2
%29 = add i32 %14, 2
%30 = icmp eq i32 %29, %10
br i1 %30, label %31, label %11
31: ; preds = %11
%32 = sitofp i32 %28 to double
%33 = fadd double %32, 5.000000e-01
br label %34
34: ; preds = %31, %6
%35 = phi double [ undef, %6 ], [ %27, %31 ]
%36 = phi double [ 0.000000e+00, %6 ], [ %27, %31 ]
%37 = phi double [ 1.500000e+00, %6 ], [ %33, %31 ]
%38 = icmp eq i32 %7, 0
br i1 %38, label %44, label %39
39: ; preds = %34
%40 = fmul double %4, %37
%41 = tail call double @llvm.fmuladd.f64(double %40, double %40, double 1.000000e+00)
%42 = fdiv double 4.000000e+00, %41
%43 = fadd double %36, %42
br label %44
44: ; preds = %39, %34, %2
%45 = phi double [ 0.000000e+00, %2 ], [ %35, %34 ], [ %43, %39 ]
%46 = fmul double %4, %45
%47 = load double, double* %1
%48 = fsub double %46, %47
%49 = fdiv double %48, %46
%50 = fcmp ogt double %49, 1.000000e-15
%51 = fcmp une double %49, 0.000000e+00
%52 = and i1 %50, %51
%53 = fcmp ogt double %49, 0.000000e+00
%54 = and i1 %53, %52
br i1 %54, label %55, label %59
55: ; preds = %44
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%57 = 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)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %49)
br label %61
59: ; preds = %44
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %61
61: ; preds = %55, %59
ret i32 0
}