; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src (anisotropicparticlemesher)

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

%class.AABB = type { %"class.vmath::vec3", double, double, double }
%"class.vmath::vec3" = type { float, float, float }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN16FragmentedVectorIN5vmath4vec3EE9push_backES1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN25AnisotropicParticleMesher13_getSliceAABBEii(ptr dead_on_unwind noalias writable sret(%class.AABB) align 8, ptr noundef nonnull align 8 dereferenceable(784), i32 noundef, i32 noundef) #5 align 2

; Function Attrs: nounwind
declare void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN25AnisotropicParticleMesher18_getSliceParticlesEiiR16FragmentedVectorIN5vmath4vec3EES4_(ptr noundef nonnull align 8 dereferenceable(784) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(48) %4) #5 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %class.AABB, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca %"class.vmath::vec3", align 4
  %16 = alloca %"class.vmath::vec3", align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #7
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN25AnisotropicParticleMesher13_getSliceAABBEii(ptr dead_on_unwind writable sret(%class.AABB) align 8 %11, ptr noundef nonnull align 8 dereferenceable(784) %17, i32 noundef %18, i32 noundef %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %54, %5
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = invoke noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %22)
          to label %24 unwind label %27

24:                                               ; preds = %20
  %25 = icmp ult i32 %21, %23
  br i1 %25, label %31, label %26

26:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %58

27:                                               ; preds = %38, %31, %20
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %13, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %14, align 4
  br label %57

31:                                               ; preds = %24
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %32, i32 noundef %33)
          to label %35 unwind label %27

35:                                               ; preds = %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %34, i64 12, i1 false), !tbaa.struct !11
  %36 = invoke noundef zeroext i1 @_ZN4AABB13isPointInsideEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(40) %11, ptr noundef %15)
          to label %37 unwind label %45

37:                                               ; preds = %35
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  br i1 %36, label %38, label %53

38:                                               ; preds = %37
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %40, i32 noundef %41)
          to label %43 unwind label %27

43:                                               ; preds = %38
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %42, i64 12, i1 false), !tbaa.struct !11
  invoke void @_ZN16FragmentedVectorIN5vmath4vec3EE9push_backES1_(ptr noundef nonnull align 8 dereferenceable(48) %39, ptr noundef %16)
          to label %44 unwind label %49

44:                                               ; preds = %43
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  br label %53

45:                                               ; preds = %35
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %13, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %14, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %15) #7
  br label %57

49:                                               ; preds = %43
  %50 = landingpad { ptr, i32 }
          cleanup
  %51 = extractvalue { ptr, i32 } %50, 0
  store ptr %51, ptr %13, align 8
  %52 = extractvalue { ptr, i32 } %50, 1
  store i32 %52, ptr %14, align 4
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %16) #7
  br label %57

53:                                               ; preds = %44, %37
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = add i32 %55, 1
  store i32 %56, ptr %12, align 4, !tbaa !9
  br label %20, !llvm.loop !14

57:                                               ; preds = %49, %45, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #7
  br label %59

58:                                               ; preds = %26
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #7
  ret void

59:                                               ; preds = %57
  %60 = load ptr, ptr %13, align 8
  %61 = load i32, ptr %14, align 4
  %62 = insertvalue { ptr, i32 } poison, ptr %60, 0
  %63 = insertvalue { ptr, i32 } %62, i32 %61, 1
  resume { ptr, i32 } %63
}

declare noundef zeroext i1 @_ZN4AABB13isPointInsideEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { inlinehint 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 #5 = { 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 #6 = { "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 #7 = { 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 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%class.AABB = type { %"class.vmath::vec3", double, double, double }
%"class.vmath::vec3" = type { float, float, float }

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind
declare void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN16FragmentedVectorIN5vmath4vec3EE9push_backES1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN25AnisotropicParticleMesher13_getSliceAABBEii(ptr dead_on_unwind noalias writable sret(%class.AABB) align 8, ptr noundef nonnull align 8 dereferenceable(784), i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: nounwind
declare void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN25AnisotropicParticleMesher18_getSliceParticlesEiiR16FragmentedVectorIN5vmath4vec3EES4_(ptr noundef nonnull align 8 dereferenceable(784) %0, i32 noundef %1, i32 noundef %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef nonnull align 8 dereferenceable(48) %4) local_unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %class.AABB, align 8
  %7 = alloca %"class.vmath::vec3", align 4
  %8 = alloca %"class.vmath::vec3", align 4
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #7
  call void @_ZN25AnisotropicParticleMesher13_getSliceAABBEii(ptr dead_on_unwind nonnull writable sret(%class.AABB) align 8 %6, ptr noundef nonnull align 8 dereferenceable(784) %0, i32 noundef %1, i32 noundef %2)
  %9 = call noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %24, %5
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #7
  ret void

10:                                               ; preds = %16, %.lr.ph
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %28

.lr.ph:                                           ; preds = %5, %24
  %.01315 = phi i32 [ %25, %24 ], [ 0, %5 ]
  %12 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %3, i32 noundef %.01315)
          to label %13 unwind label %10

13:                                               ; preds = %.lr.ph
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %12, i64 12, i1 false), !tbaa.struct !5
  %14 = invoke noundef zeroext i1 @_ZN4AABB13isPointInsideEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(40) %6, ptr noundef nonnull %7)
          to label %15 unwind label %20

15:                                               ; preds = %13
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  br i1 %14, label %16, label %24

16:                                               ; preds = %15
  %17 = invoke noundef nonnull align 4 dereferenceable(12) ptr @_ZN16FragmentedVectorIN5vmath4vec3EEixEi(ptr noundef nonnull align 8 dereferenceable(48) %3, i32 noundef %.01315)
          to label %18 unwind label %10

18:                                               ; preds = %16
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %17, i64 12, i1 false), !tbaa.struct !5
  invoke void @_ZN16FragmentedVectorIN5vmath4vec3EE9push_backES1_(ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull %8)
          to label %19 unwind label %22

19:                                               ; preds = %18
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  br label %24

20:                                               ; preds = %13
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %7) #7
  br label %28

22:                                               ; preds = %18
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5vmath4vec3D1Ev(ptr noundef nonnull align 4 dereferenceable(12) %8) #7
  br label %28

24:                                               ; preds = %15, %19
  %25 = add nuw i32 %.01315, 1
  %26 = call noundef i32 @_ZN16FragmentedVectorIN5vmath4vec3EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(48) %3)
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !10

28:                                               ; preds = %22, %20, %10
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %11, %10 ], [ %21, %20 ]
  call void @_ZN4AABBD1Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #7
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #7
  resume { ptr, i32 } %.pn
}

declare noundef zeroext i1 @_ZN4AABB13isPointInsideEN5vmath4vec3E(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { inlinehint 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 #5 = { 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 #6 = { "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 #7 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass