#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 pieCalCheckResultGMSP(int noOfIntervals, float *finalPieValue) {
  float totalsum = 0.0f, x = 0.0f;
  float h = 1.0 / noOfIntervals;
  int i;
  float errorNorm = 0.0f;
  float eps = 1.0e-8f;
  float relativeError = 0.0f;
  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):
<pieCalCheckResultGMSP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xecc(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xea7(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11f6 <pieCalCheckResultGMSP+0xe6>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
movsd  0xe7d(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x18(%rbp),%xmm1
mulss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xe3d(%rip),%xmm2
addsd  %xmm1,%xmm2
movsd  0xe39(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1174 <pieCalCheckResultGMSP+0x64>
movss  -0x14(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
subss  (%rax),%xmm0
divss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
ucomiss -0x28(%rbp),%xmm0
jbe    1275 <pieCalCheckResultGMSP+0x165>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124c <pieCalCheckResultGMSP+0x13c>
jp     124c <pieCalCheckResultGMSP+0x13c>
jmp    1275 <pieCalCheckResultGMSP+0x165>
movss  -0x24(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1270 <pieCalCheckResultGMSP+0x160>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1275 <pieCalCheckResultGMSP+0x165>
cmpl   $0x1,-0x30(%rbp)
jne    12bb <pieCalCheckResultGMSP+0x1ab>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jne    12d3 <pieCalCheckResultGMSP+0x1c3>
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pieCalCheckResultGMSP>:
push   %rax
cvtsi2sd %edi,%xmm0
movsd  0xed3(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm8,%xmm8
xorps  %xmm4,%xmm4
test   %edi,%edi
jle    11b4 <pieCalCheckResultGMSP+0x94>
cvtss2sd %xmm1,%xmm3
neg    %edi
mov    $0x1,%eax
xorps  %xmm4,%xmm4
movsd  0xeae(%rip),%xmm5
movsd  0xeae(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorps  %xmm7,%xmm7
cvtsi2sd %eax,%xmm7
addsd  %xmm5,%xmm7
mulsd  %xmm3,%xmm7
cvtsd2ss %xmm7,%xmm7
cvtss2sd %xmm4,%xmm4
mulss  %xmm7,%xmm7
cvtss2sd %xmm7,%xmm7
addsd  %xmm2,%xmm7
movapd %xmm0,%xmm6
divsd  %xmm7,%xmm6
addsd  %xmm4,%xmm6
xorps  %xmm4,%xmm4
cvtsd2ss %xmm6,%xmm4
lea    (%rdi,%rax,1),%ecx
add    $0x1,%ecx
add    $0x1,%eax
cmp    $0x1,%ecx
jne    1170 <pieCalCheckResultGMSP+0x50>
mulss  %xmm1,%xmm4
movaps %xmm4,%xmm1
subss  (%rsi),%xmm1
divss  %xmm4,%xmm1
ucomiss %xmm8,%xmm1
jbe    1222 <pieCalCheckResultGMSP+0x102>
ucomiss 0xe50(%rip),%xmm1
jbe    1222 <pieCalCheckResultGMSP+0x102>
xorpd  %xmm0,%xmm0
ucomiss %xmm0,%xmm1
jne    11dd <pieCalCheckResultGMSP+0xbd>
jnp    1222 <pieCalCheckResultGMSP+0x102>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe34(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
movsd  0xe12(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
jmp    122e <pieCalCheckResultGMSP+0x10e>
lea    0xe68(%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 @pieCalCheckResultGMSP(i32 %0, float* %1) {
%3 = alloca i32
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca i32
store i32 %0, i32* %3
store float* %1, float** %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%13 = load i32, i32* %3
%14 = sitofp i32 %13 to double
%15 = fdiv double 1.000000e+00, %14
%16 = fptrunc double %15 to float
store float %16, float* %7
store float 0.000000e+00, float* %9
store float 0x3E45798EE0000000, float* %10
store float 0.000000e+00, float* %11
store i32 0, i32* %12
store i32 1, i32* %8
br label %17
17: ; preds = %40, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %43
22: ; preds = %17
%23 = load float, float* %7
%24 = fpext float %23 to double
%25 = load i32, i32* %8
%26 = sitofp i32 %25 to double
%27 = fadd double %26, 5.000000e-01
%28 = fmul double %24, %27
%29 = fptrunc double %28 to float
store float %29, float* %6
%30 = load float, float* %5
%31 = fpext float %30 to double
%32 = load float, float* %6
%33 = load float, float* %6
%34 = fmul float %32, %33
%35 = fpext float %34 to double
%36 = fadd double 1.000000e+00, %35
%37 = fdiv double 4.000000e+00, %36
%38 = fadd double %31, %37
%39 = fptrunc double %38 to float
store float %39, float* %5
br label %40
40: ; preds = %22
%41 = load i32, i32* %8
%42 = add nsw i32 %41, 1
store i32 %42, i32* %8
br label %17
43: ; preds = %17
%44 = load float, float* %5
%45 = load float, float* %7
%46 = fmul float %44, %45
store float %46, float* %5
%47 = load float, float* %5
%48 = load float*, float** %4
%49 = load float, float* %48
%50 = fsub float %47, %49
%51 = load float, float* %5
%52 = fdiv float %50, %51
store float %52, float* %11
%53 = load float, float* %11
%54 = load float, float* %10
%55 = fcmp ogt float %53, %54
br i1 %55, label %56, label %67
56: ; preds = %43
%57 = load float, float* %11
%58 = fpext float %57 to double
%59 = fcmp une double %58, 0.000000e+00
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = load float, float* %9
%62 = load float, float* %11
%63 = fcmp olt float %61, %62
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = load float, float* %11
store float %65, float* %9
store i32 1, i32* %12
br label %66
66: ; preds = %64, %60
br label %67
67: ; preds = %66, %56, %43
%68 = load i32, i32* %12
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %78
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%72 = load float, float* %10
%73 = fpext float %72 to double
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %73)
%75 = load float, float* %9
%76 = fpext float %75 to double
%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 = %70, %67
%79 = load i32, i32* %12
%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 @pieCalCheckResultGMSP(i32 %0, float* nocapture %1) {
%3 = sitofp i32 %0 to double
%4 = fdiv double 1.000000e+00, %3
%5 = fptrunc double %4 to float
%6 = icmp slt i32 %0, 1
br i1 %6, label %25, label %7
7: ; preds = %2
%8 = fpext float %5 to double
br label %9
9: ; preds = %7, %9
%10 = phi float [ 0.000000e+00, %7 ], [ %22, %9 ]
%11 = phi i32 [ 1, %7 ], [ %23, %9 ]
%12 = sitofp i32 %11 to double
%13 = fadd double %12, 5.000000e-01
%14 = fmul double %13, %8
%15 = fptrunc double %14 to float
%16 = fpext float %10 to double
%17 = fmul float %15, %15
%18 = fpext float %17 to double
%19 = fadd double %18, 1.000000e+00
%20 = fdiv double 4.000000e+00, %19
%21 = fadd double %20, %16
%22 = fptrunc double %21 to float
%23 = add nuw i32 %11, 1
%24 = icmp eq i32 %11, %0
br i1 %24, label %25, label %9
25: ; preds = %9, %2
%26 = phi float [ 0.000000e+00, %2 ], [ %22, %9 ]
%27 = fmul float %26, %5
%28 = load float, float* %1
%29 = fsub float %27, %28
%30 = fdiv float %29, %27
%31 = fcmp ogt float %30, 0x3E45798EE0000000
%32 = fcmp une float %30, 0.000000e+00
%33 = and i1 %31, %32
%34 = fcmp ogt float %30, 0.000000e+00
%35 = and i1 %34, %33
br i1 %35, label %36, label %41
36: ; preds = %25
%37 = fpext float %30 to double
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 0x3E45798EE0000000)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), double %37)
br label %43
41: ; preds = %25
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %43
43: ; preds = %36, %41
ret i32 0
}