; LLVM IR from tivole/Numerary :: src/integration.ll (ZN8numerary8Numerary17integrate_simpsonEPFddERKdS4_S4_)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8numerary8Numerary17integrate_simpsonEPFddERKdS4_S4_(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %22 = call noalias noundef nonnull ptr @_Znam(i64 noundef 16) #6
  store ptr %22, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load double, ptr %23, align 8, !tbaa !9
  store double %24, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load double, ptr %25, align 8, !tbaa !9
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = fsub double %26, %28
  store double %29, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store double 0.000000e+00, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store double 0.000000e+00, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  br label %30

30:                                               ; preds = %135, %4
  %31 = load double, ptr %10, align 8, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fsub double %33, %35
  %37 = fcmp olt double %31, %36
  br i1 %37, label %38, label %136

38:                                               ; preds = %30
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load double, ptr %10, align 8, !tbaa !9
  %41 = call noundef double %39(double noundef %40)
  store double %41, ptr %19, align 8, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load double, ptr %10, align 8, !tbaa !9
  %44 = load double, ptr %15, align 8, !tbaa !9
  %45 = fdiv double %44, 2.000000e+00
  %46 = fadd double %43, %45
  %47 = call noundef double %42(double noundef %46)
  store double %47, ptr %20, align 8, !tbaa !9
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load double, ptr %10, align 8, !tbaa !9
  %50 = load double, ptr %15, align 8, !tbaa !9
  %51 = fadd double %49, %50
  %52 = call noundef double %48(double noundef %51)
  store double %52, ptr %21, align 8, !tbaa !9
  %53 = load double, ptr %15, align 8, !tbaa !9
  %54 = fdiv double %53, 6.000000e+00
  %55 = load double, ptr %19, align 8, !tbaa !9
  %56 = load double, ptr %20, align 8, !tbaa !9
  %57 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %56, double %55)
  %58 = load double, ptr %21, align 8, !tbaa !9
  %59 = fadd double %57, %58
  %60 = fmul double %54, %59
  store double %60, ptr %11, align 8, !tbaa !9
  %61 = load double, ptr %15, align 8, !tbaa !9
  %62 = fdiv double %61, 1.200000e+01
  %63 = load double, ptr %19, align 8, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = load double, ptr %10, align 8, !tbaa !9
  %66 = load double, ptr %15, align 8, !tbaa !9
  %67 = fdiv double %66, 4.000000e+00
  %68 = fadd double %65, %67
  %69 = call noundef double %64(double noundef %68)
  %70 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %69, double %63)
  %71 = load double, ptr %20, align 8, !tbaa !9
  %72 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %71, double %70)
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load double, ptr %10, align 8, !tbaa !9
  %75 = load double, ptr %15, align 8, !tbaa !9
  %76 = fmul double 3.000000e+00, %75
  %77 = fdiv double %76, 4.000000e+00
  %78 = fadd double %74, %77
  %79 = call noundef double %73(double noundef %78)
  %80 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %79, double %72)
  %81 = load double, ptr %21, align 8, !tbaa !9
  %82 = fadd double %80, %81
  %83 = fmul double %62, %82
  store double %83, ptr %12, align 8, !tbaa !9
  %84 = load double, ptr %12, align 8, !tbaa !9
  %85 = load double, ptr %11, align 8, !tbaa !9
  %86 = fsub double %84, %85
  %87 = fdiv double %86, 1.500000e+01
  store double %87, ptr %13, align 8, !tbaa !9
  %88 = load double, ptr %13, align 8, !tbaa !9
  %89 = call double @llvm.fabs.f64(double %88)
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = load double, ptr %90, align 8, !tbaa !9
  %92 = fdiv double %89, %91
  %93 = call double @pow(double noundef %92, double noundef 2.000000e-01) #5
  store double %93, ptr %14, align 8, !tbaa !9
  %94 = load double, ptr %14, align 8, !tbaa !9
  %95 = fcmp ogt double %94, 1.000000e+04
  br i1 %95, label %96, label %97

96:                                               ; preds = %38
  store double 1.000000e+04, ptr %14, align 8, !tbaa !9
  br label %97

97:                                               ; preds = %96, %38
  %98 = load double, ptr %14, align 8, !tbaa !9
  %99 = fcmp olt double %98, 1.000000e-04
  br i1 %99, label %100, label %101

100:                                              ; preds = %97
  store double 1.000000e-04, ptr %14, align 8, !tbaa !9
  br label %101

101:                                              ; preds = %100, %97
  %102 = load double, ptr %15, align 8, !tbaa !9
  %103 = fmul double 0x3FEE666666666666, %102
  %104 = load double, ptr %14, align 8, !tbaa !9
  %105 = fdiv double %103, %104
  store double %105, ptr %16, align 8, !tbaa !9
  %106 = load double, ptr %13, align 8, !tbaa !9
  %107 = call double @llvm.fabs.f64(double %106)
  %108 = load ptr, ptr %8, align 8, !tbaa !5
  %109 = load double, ptr %108, align 8, !tbaa !9
  %110 = fcmp olt double %107, %109
  br i1 %110, label %111, label %122

111:                                              ; preds = %101
  %112 = load double, ptr %15, align 8, !tbaa !9
  %113 = load double, ptr %10, align 8, !tbaa !9
  %114 = fadd double %113, %112
  store double %114, ptr %10, align 8, !tbaa !9
  %115 = load double, ptr %12, align 8, !tbaa !9
  %116 = load double, ptr %18, align 8, !tbaa !9
  %117 = fadd double %116, %115
  store double %117, ptr %18, align 8, !tbaa !9
  %118 = load double, ptr %13, align 8, !tbaa !9
  %119 = call double @llvm.fabs.f64(double %118)
  %120 = load double, ptr %17, align 8, !tbaa !9
  %121 = fadd double %120, %119
  store double %121, ptr %17, align 8, !tbaa !9
  br label %122

122:                                              ; preds = %111, %101
  %123 = load double, ptr %16, align 8, !tbaa !9
  store double %123, ptr %15, align 8, !tbaa !9
  %124 = load double, ptr %10, align 8, !tbaa !9
  %125 = load double, ptr %15, align 8, !tbaa !9
  %126 = fadd double %124, %125
  %127 = load ptr, ptr %7, align 8, !tbaa !5
  %128 = load double, ptr %127, align 8, !tbaa !9
  %129 = fcmp ogt double %126, %128
  br i1 %129, label %130, label %135

130:                                              ; preds = %122
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = load double, ptr %131, align 8, !tbaa !9
  %133 = load double, ptr %10, align 8, !tbaa !9
  %134 = fsub double %132, %133
  store double %134, ptr %15, align 8, !tbaa !9
  br label %135

135:                                              ; preds = %130, %122
  br label %30, !llvm.loop !11

136:                                              ; preds = %30
  %137 = load double, ptr %18, align 8, !tbaa !9
  %138 = load ptr, ptr %9, align 8, !tbaa !5
  %139 = getelementptr inbounds double, ptr %138, i64 0
  store double %137, ptr %139, align 8, !tbaa !9
  %140 = load double, ptr %17, align 8, !tbaa !9
  %141 = load ptr, ptr %9, align 8, !tbaa !5
  %142 = getelementptr inbounds double, ptr %141, i64 1
  store double %140, ptr %142, align 8, !tbaa !9
  %143 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret ptr %143
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8numerary8Numerary17integrate_simpsonEPFddERKdS4_S4_(ptr nocapture noundef readonly %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %3) local_unnamed_addr #0 align 2 {
  %5 = tail call noalias noundef nonnull dereferenceable(16) ptr @_Znam(i64 noundef 16) #5
  %6 = load double, ptr %1, align 8, !tbaa !5
  %7 = load double, ptr %2, align 8, !tbaa !5
  %8 = load double, ptr %3, align 8, !tbaa !5
  %9 = fsub double %7, %8
  %10 = fcmp olt double %6, %9
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %4
  %11 = fsub double %7, %6
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.069 = phi double [ %.1, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %.05768 = phi double [ %.158, %.lr.ph ], [ %11, %.lr.ph.preheader ]
  %12 = phi <2 x double> [ %57, %.lr.ph ], [ zeroinitializer, %.lr.ph.preheader ]
  %13 = tail call noundef double %0(double noundef %.069)
  %14 = fmul double %.05768, 5.000000e-01
  %15 = fadd double %.069, %14
  %16 = tail call noundef double %0(double noundef %15)
  %17 = fadd double %.05768, %.069
  %18 = tail call noundef double %0(double noundef %17)
  %19 = insertelement <2 x double> poison, double %.05768, i64 0
  %20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
  %21 = fdiv <2 x double> %20, <double 1.200000e+01, double 6.000000e+00>
  %22 = fmul double %.05768, 2.500000e-01
  %23 = fadd double %.069, %22
  %24 = tail call noundef double %0(double noundef %23)
  %25 = tail call double @llvm.fmuladd.f64(double %24, double 4.000000e+00, double %13)
  %26 = tail call double @llvm.fmuladd.f64(double %16, double 2.000000e+00, double %25)
  %27 = fmul double %.05768, 3.000000e+00
  %28 = fmul double %27, 2.500000e-01
  %29 = fadd double %.069, %28
  %30 = tail call noundef double %0(double noundef %29)
  %31 = insertelement <2 x double> poison, double %30, i64 0
  %32 = insertelement <2 x double> %31, double %16, i64 1
  %33 = insertelement <2 x double> poison, double %26, i64 0
  %34 = insertelement <2 x double> %33, double %13, i64 1
  %35 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> <double 4.000000e+00, double 4.000000e+00>, <2 x double> %34)
  %36 = insertelement <2 x double> poison, double %18, i64 0
  %37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
  %38 = fadd <2 x double> %35, %37
  %39 = fmul <2 x double> %21, %38
  %shift = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %40 = fsub <2 x double> %39, %shift
  %41 = extractelement <2 x double> %40, i64 0
  %42 = fdiv double %41, 1.500000e+01
  %43 = tail call double @llvm.fabs.f64(double %42)
  %44 = load double, ptr %3, align 8, !tbaa !5
  %45 = fdiv double %43, %44
  %46 = tail call double @pow(double noundef %45, double noundef 2.000000e-01) #6
  %47 = fcmp ogt double %46, 1.000000e+04
  %.055 = select i1 %47, double 1.000000e+04, double %46
  %48 = fcmp olt double %.055, 1.000000e-04
  %.156 = select i1 %48, double 1.000000e-04, double %.055
  %49 = fmul double %.05768, 0x3FEE666666666666
  %50 = fdiv double %49, %.156
  %51 = load double, ptr %3, align 8, !tbaa !5
  %52 = fcmp olt double %43, %51
  %53 = insertelement <2 x double> %39, double %43, i64 1
  %54 = fadd <2 x double> %12, %53
  %55 = insertelement <2 x i1> poison, i1 %52, i64 0
  %56 = shufflevector <2 x i1> %55, <2 x i1> poison, <2 x i32> zeroinitializer
  %57 = select <2 x i1> %56, <2 x double> %54, <2 x double> %12
  %.1 = select i1 %52, double %17, double %.069
  %58 = fadd double %50, %.1
  %59 = load double, ptr %2, align 8, !tbaa !5
  %60 = fcmp ogt double %58, %59
  %61 = fsub double %59, %.1
  %.158 = select i1 %60, double %61, double %50
  %62 = fsub double %59, %51
  %63 = fcmp olt double %.1, %62
  br i1 %63, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %4
  %64 = phi <2 x double> [ zeroinitializer, %4 ], [ %57, %.lr.ph ]
  store <2 x double> %64, ptr %5, align 8, !tbaa !5
  ret ptr %5
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass