; LLVM IR from rvillegasm/NuMath :: src/integration (simpsonOneThird)

; 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"

%"struct.numath::Point" = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN6numath11integration15simpsonOneThirdERSt6vectorINS_5PointESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(24) %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNKSt6vectorIN6numath5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #3
  %11 = trunc i64 %10 to i32
  store i32 %11, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = sub i32 %13, 1
  %15 = zext i32 %14 to i64
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %15) #3
  %17 = getelementptr inbounds %"struct.numath::Point", ptr %16, i32 0, i32 0
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef 0) #3
  %21 = getelementptr inbounds %"struct.numath::Point", ptr %20, i32 0, i32 0
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = fsub double %18, %22
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sub i32 %24, 1
  %26 = uitofp i32 %25 to double
  %27 = fdiv double %23, %26
  store double %27, ptr %4, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %43, %1
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = load i32, ptr %3, align 4, !tbaa !9
  %31 = sub i32 %30, 1
  %32 = icmp ult i32 %29, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %46

34:                                               ; preds = %28
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %35, i64 noundef %37) #3
  %39 = getelementptr inbounds %"struct.numath::Point", ptr %38, i32 0, i32 1
  %40 = load double, ptr %39, align 8, !tbaa !15
  %41 = load double, ptr %5, align 8, !tbaa !14
  %42 = fadd double %41, %40
  store double %42, ptr %5, align 8, !tbaa !14
  br label %43

43:                                               ; preds = %34
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = add i32 %44, 2
  store i32 %45, ptr %6, align 4, !tbaa !9
  br label %28, !llvm.loop !16

46:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 0.000000e+00, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 2, ptr %8, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %62, %46
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = load i32, ptr %3, align 4, !tbaa !9
  %50 = sub i32 %49, 1
  %51 = icmp ult i32 %48, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %65

53:                                               ; preds = %47
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = load i32, ptr %8, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %56) #3
  %58 = getelementptr inbounds %"struct.numath::Point", ptr %57, i32 0, i32 1
  %59 = load double, ptr %58, align 8, !tbaa !15
  %60 = load double, ptr %7, align 8, !tbaa !14
  %61 = fadd double %60, %59
  store double %61, ptr %7, align 8, !tbaa !14
  br label %62

62:                                               ; preds = %53
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = add i32 %63, 2
  store i32 %64, ptr %8, align 4, !tbaa !9
  br label %47, !llvm.loop !18

65:                                               ; preds = %52
  %66 = load double, ptr %4, align 8, !tbaa !14
  %67 = fdiv double %66, 3.000000e+00
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %68, i64 noundef 0) #3
  %70 = getelementptr inbounds %"struct.numath::Point", ptr %69, i32 0, i32 1
  %71 = load double, ptr %70, align 8, !tbaa !15
  %72 = load double, ptr %5, align 8, !tbaa !14
  %73 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %72, double %71)
  %74 = load double, ptr %7, align 8, !tbaa !14
  %75 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %74, double %73)
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = load i32, ptr %3, align 4, !tbaa !9
  %78 = sub i32 %77, 1
  %79 = zext i32 %78 to i64
  %80 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %76, i64 noundef %79) #3
  %81 = getelementptr inbounds %"struct.numath::Point", ptr %80, i32 0, i32 1
  %82 = load double, ptr %81, align 8, !tbaa !15
  %83 = fadd double %75, %82
  %84 = fmul double %67, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret double %84
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN6numath5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

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

attributes #0 = { mustprogress nounwind 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN6numath5PointE", !13, i64 0, !13, i64 8}
!13 = !{!"double", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 nounwind uwtable
define dso_local noundef double @_ZN6numath11integration15simpsonOneThirdERSt6vectorINS_5PointESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(24) %0) local_unnamed_addr #0 {
  %2 = tail call noundef i64 @_ZNKSt6vectorIN6numath5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %3 = trunc i64 %2 to i32
  %4 = add i32 %3, -1
  %5 = zext i32 %4 to i64
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #2
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #2
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = icmp ugt i32 %4, 1
  br i1 %10, label %.lr.ph, label %._crit_edge

.preheader:                                       ; preds = %.lr.ph
  %.not = icmp eq i32 %4, 2
  br i1 %.not, label %._crit_edge, label %.lr.ph30

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.02327 = phi i32 [ %16, %.lr.ph ], [ 1, %1 ]
  %.02426 = phi double [ %15, %.lr.ph ], [ 0.000000e+00, %1 ]
  %11 = zext i32 %.02327 to i64
  %12 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %11) #2
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load double, ptr %13, align 8, !tbaa !10
  %15 = fadd double %.02426, %14
  %16 = add i32 %.02327, 2
  %17 = icmp ult i32 %16, %4
  br i1 %17, label %.lr.ph, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph30, %1, %.preheader
  %.024.lcssa34 = phi double [ %15, %.preheader ], [ 0.000000e+00, %1 ], [ %15, %.lr.ph30 ]
  %.022.lcssa = phi double [ 0.000000e+00, %.preheader ], [ 0.000000e+00, %1 ], [ %36, %.lr.ph30 ]
  %18 = fsub double %7, %9
  %19 = uitofp i32 %4 to double
  %20 = fdiv double %18, %19
  %21 = fdiv double %20, 3.000000e+00
  %22 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef 0) #2
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load double, ptr %23, align 8, !tbaa !10
  %25 = tail call double @llvm.fmuladd.f64(double %.024.lcssa34, double 4.000000e+00, double %24)
  %26 = tail call double @llvm.fmuladd.f64(double %.022.lcssa, double 2.000000e+00, double %25)
  %27 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %5) #2
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load double, ptr %28, align 8, !tbaa !10
  %30 = fadd double %26, %29
  %31 = fmul double %21, %30
  ret double %31

.lr.ph30:                                         ; preds = %.preheader, %.lr.ph30
  %.029 = phi i32 [ %37, %.lr.ph30 ], [ 2, %.preheader ]
  %.02228 = phi double [ %36, %.lr.ph30 ], [ 0.000000e+00, %.preheader ]
  %32 = zext i32 %.029 to i64
  %33 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %32) #2
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = load double, ptr %34, align 8, !tbaa !10
  %36 = fadd double %.02228, %35
  %37 = add i32 %.029, 2
  %38 = icmp ult i32 %37, %4
  br i1 %38, label %.lr.ph30, label %._crit_edge, !llvm.loop !13
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN6numath5PointESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN6numath5PointESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { mustprogress nounwind 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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, !7, i64 0}
!6 = !{!"_ZTSN6numath5PointE", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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