; LLVM IR from Eydcao/Yan-CG-SnowSim :: src/SnowParticle.ll (ZN15SnowParticleSet6updateEv)

; 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.SnowParticleSet = type <{ %"class.std::vector", float, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<SnowParticle *, std::allocator<SnowParticle *>>::_Vector_impl" }
%"struct.std::_Vector_base<SnowParticle *, std::allocator<SnowParticle *>>::_Vector_impl" = type { %"struct.std::_Vector_base<SnowParticle *, std::allocator<SnowParticle *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SnowParticle *, std::allocator<SnowParticle *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.SnowParticle = type { float, float, float, %"class.Eigen::Matrix", %"class.Eigen::Matrix", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", %"class.Eigen::Matrix.3", [64 x %"class.Eigen::Matrix"], [64 x float], ptr }
%"class.Eigen::Matrix" = type { %"class.Eigen::PlainObjectBase" }
%"class.Eigen::PlainObjectBase" = type { %"class.Eigen::DenseStorage" }
%"class.Eigen::DenseStorage" = type { %"struct.Eigen::internal::plain_array" }
%"struct.Eigen::internal::plain_array" = type { [3 x float] }
%"class.Eigen::Matrix.3" = type { %"class.Eigen::PlainObjectBase.4" }
%"class.Eigen::PlainObjectBase.4" = type { %"class.Eigen::DenseStorage.11" }
%"class.Eigen::DenseStorage.11" = type { %"struct.Eigen::internal::plain_array.12" }
%"struct.Eigen::internal::plain_array.12" = type { [9 x float] }

; 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: mustprogress uwtable
declare dso_local void @_ZN12SnowParticle9updatePosEv(ptr noundef nonnull align 8 dereferenceable(1368)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12SnowParticle25updatePureElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12SnowParticle30updateCombinedPElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15SnowParticleSet6updateEv(ptr noundef nonnull align 8 dereferenceable(28) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 1
  store float 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !16
  br label %7

7:                                                ; preds = %45, %1
  %8 = load i32, ptr %3, align 4, !tbaa !16
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 0
  %11 = call noundef i64 @_ZNKSt6vectorIP12SnowParticleSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %48

14:                                               ; preds = %7
  %15 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 0
  %16 = load i32, ptr %3, align 4, !tbaa !16
  %17 = sext i32 %16 to i64
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17) #4
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  call void @_ZN12SnowParticle9updatePosEv(ptr noundef nonnull align 8 dereferenceable(1368) %19)
  %20 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 0
  %21 = load i32, ptr %3, align 4, !tbaa !16
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %20, i64 noundef %22) #4
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  call void @_ZN12SnowParticle25updatePureElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368) %24)
  %25 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 0
  %26 = load i32, ptr %3, align 4, !tbaa !16
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #4
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  call void @_ZN12SnowParticle30updateCombinedPElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368) %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %30 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 0
  %31 = load i32, ptr %3, align 4, !tbaa !16
  %32 = sext i32 %31 to i64
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %32) #4
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.SnowParticle, ptr %34, i32 0, i32 4
  %36 = call noundef float @_ZNK5Eigen10MatrixBaseINS_6MatrixIfLi3ELi1ELi0ELi3ELi1EEEE4normEv(ptr noundef nonnull align 1 dereferenceable(1) %35)
  store float %36, ptr %4, align 4, !tbaa !18
  %37 = load float, ptr %4, align 4, !tbaa !18
  %38 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 1
  %39 = load float, ptr %38, align 8, !tbaa !9
  %40 = fcmp ogt float %37, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %14
  %42 = load float, ptr %4, align 4, !tbaa !18
  %43 = getelementptr inbounds %class.SnowParticleSet, ptr %5, i32 0, i32 1
  store float %42, ptr %43, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %41, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %3, align 4, !tbaa !16
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %3, align 4, !tbaa !16
  br label %7, !llvm.loop !19

48:                                               ; preds = %13
  ret void
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK5Eigen10MatrixBaseINS_6MatrixIfLi3ELi1ELi0ELi3ELi1EEEE4normEv(ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { 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, !15, i64 24}
!10 = !{!"_ZTS15SnowParticleSet", !11, i64 0, !15, i64 24}
!11 = !{!"_ZTSSt6vectorIP12SnowParticleSaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIP12SnowParticleSaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIP12SnowParticleSaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIP12SnowParticleSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"float", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!15, !15, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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
declare dso_local void @_ZN12SnowParticle9updatePosEv(ptr noundef nonnull align 8 dereferenceable(1368)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12SnowParticle25updatePureElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN12SnowParticle30updateCombinedPElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN15SnowParticleSet6updateEv(ptr noundef nonnull align 8 dereferenceable(28) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  store float 0.000000e+00, ptr %2, align 8, !tbaa !5
  %3 = tail call noundef i64 @_ZNKSt6vectorIP12SnowParticleSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %17, %1
  ret void

.lr.ph:                                           ; preds = %1, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %1 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #3
  %5 = load ptr, ptr %4, align 8, !tbaa !15
  tail call void @_ZN12SnowParticle9updatePosEv(ptr noundef nonnull align 8 dereferenceable(1368) %5)
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #3
  %7 = load ptr, ptr %6, align 8, !tbaa !15
  tail call void @_ZN12SnowParticle25updatePureElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368) %7)
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #3
  %9 = load ptr, ptr %8, align 8, !tbaa !15
  tail call void @_ZN12SnowParticle30updateCombinedPElasticGradientEv(ptr noundef nonnull align 8 dereferenceable(1368) %9)
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP12SnowParticleSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #3
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = tail call noundef float @_ZNK5Eigen10MatrixBaseINS_6MatrixIfLi3ELi1ELi0ELi3ELi1EEEE4normEv(ptr noundef nonnull align 1 dereferenceable(1) %12)
  %14 = load float, ptr %2, align 8, !tbaa !5
  %15 = fcmp ogt float %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %.lr.ph
  store float %13, ptr %2, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %16, %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = tail call noundef i64 @_ZNKSt6vectorIP12SnowParticleSaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %19 = icmp ugt i64 %18, %indvars.iv.next
  br i1 %19, label %.lr.ph, label %._crit_edge, !llvm.loop !16
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef float @_ZNK5Eigen10MatrixBaseINS_6MatrixIfLi3ELi1ELi0ELi3ELi1EEEE4normEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 align 2

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 = { 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 #2 = { 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 #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, !14, i64 24}
!6 = !{!"_ZTS15SnowParticleSet", !7, i64 0, !14, i64 24}
!7 = !{!"_ZTSSt6vectorIP12SnowParticleSaIS1_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseIP12SnowParticleSaIS1_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseIP12SnowParticleSaIS1_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseIP12SnowParticleSaIS1_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"float", !12, i64 0}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass