; LLVM IR from INMOST-DEV/INMOST-FEM :: anifem++/fem/fem_space.ll (ZNK3Ani14VectorFemSpace18evalBasisFunctionsERKNS_4ExprES3_PS1_)

; 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.Ani::VectorFemSpace" = type { %"struct.Ani::BaseFemSpace", %"class.std::shared_ptr.21" }
%"struct.Ani::BaseFemSpace" = type { ptr, %"struct.Ani::DofT::DofMap" }
%"struct.Ani::DofT::DofMap" = type { %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.std::shared_ptr.21" = type { %"class.std::__shared_ptr.22" }
%"class.std::__shared_ptr.22" = type { ptr, %"class.std::__shared_count" }
%"struct.Ani::DofT::VectorDofMap" = type <{ %"struct.Ani::DofT::BaseDofMap", %"class.std::shared_ptr", i32, [4 x i8] }>
%"struct.Ani::DofT::BaseDofMap" = type { ptr }
%"struct.Ani::Expr" = type { ptr, %"class.std::shared_ptr.16" }
%"class.std::shared_ptr.16" = type { %"class.std::__shared_ptr.17" }
%"class.std::__shared_ptr.17" = type { ptr, %"class.std::__shared_count" }

; 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK3Ani4DofT6DofMap11NumDofOnTetEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Ani14VectorFemSpace18evalBasisFunctionsERKNS_4ExprES3_PS1_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3) unnamed_addr #3 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  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
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %13 = getelementptr inbounds %"struct.Ani::VectorFemSpace", ptr %12, i32 0, i32 1
  %14 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %13) #4
  %15 = getelementptr inbounds %"struct.Ani::BaseFemSpace", ptr %14, i32 0, i32 1
  %16 = call noundef i32 @_ZNK3Ani4DofT6DofMap11NumDofOnTetEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  store i32 %16, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %17 = getelementptr inbounds %"struct.Ani::BaseFemSpace", ptr %12, i32 0, i32 1
  %18 = call noundef ptr @_ZNK3Ani4DofT6DofMap6targetINS0_12VectorDofMapEEEPKT_v(ptr noundef nonnull align 8 dereferenceable(16) %17)
  %19 = getelementptr inbounds %"struct.Ani::DofT::VectorDofMap", ptr %18, i32 0, i32 2
  %20 = load i32, ptr %19, align 8, !tbaa !11
  store i32 %20, ptr %10, align 4, !tbaa !9
  %21 = getelementptr inbounds %"struct.Ani::VectorFemSpace", ptr %12, i32 0, i32 1
  %22 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %21) #4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load ptr, ptr %22, align 8, !tbaa !17
  %27 = getelementptr inbounds ptr, ptr %26, i64 5
  %28 = load ptr, ptr %27, align 8
  call void %28(ptr noundef nonnull align 8 dereferenceable(24) %22, ptr noundef nonnull align 8 dereferenceable(24) %23, ptr noundef nonnull align 8 dereferenceable(24) %24, ptr noundef %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %47, %4
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %50

34:                                               ; preds = %29
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds %"struct.Ani::Expr", ptr %36, i64 %38
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = mul i32 %41, %42
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds %"struct.Ani::Expr", ptr %40, i64 %44
  %46 = call noundef ptr @_ZSt4copyIPN3Ani4ExprES2_ET0_T_S4_S3_(ptr noundef %35, ptr noundef %39, ptr noundef %45)
  br label %47

47:                                               ; preds = %34
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = add i32 %48, 1
  store i32 %49, ptr %11, align 4, !tbaa !9
  br label %29, !llvm.loop !19

50:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPN3Ani4ExprES2_ET0_T_S4_S3_(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 24}
!12 = !{!"_ZTSN3Ani4DofT12VectorDofMapE", !13, i64 0, !14, i64 8, !10, i64 24}
!13 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!14 = !{!"_ZTSSt10shared_ptrIN3Ani4DofT10BaseDofMapEE", !15, i64 0}
!15 = !{!"_ZTSSt12__shared_ptrIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !16, i64 8}
!16 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, 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"

%"struct.Ani::Expr" = type { ptr, %"class.std::shared_ptr.16" }
%"class.std::shared_ptr.16" = type { %"class.std::__shared_ptr.17" }
%"class.std::__shared_ptr.17" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZNK3Ani4DofT6DofMap11NumDofOnTetEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Ani14VectorFemSpace18evalBasisFunctionsERKNS_4ExprES3_PS1_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3) unnamed_addr #2 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %5) #3
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = tail call noundef i32 @_ZNK3Ani4DofT6DofMap11NumDofOnTetEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = tail call noundef ptr @_ZNK3Ani4DofT6DofMap6targetINS0_12VectorDofMapEEEPKT_v(ptr noundef nonnull align 8 dereferenceable(16) %9)
  %11 = getelementptr inbounds i8, ptr %10, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %5) #3
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %14, i64 40
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(24) %13, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3)
  %17 = icmp ugt i32 %12, 1
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %18 = zext i32 %8 to i64
  %19 = getelementptr inbounds %"struct.Ani::Expr", ptr %3, i64 %18
  %wide.trip.count = zext i32 %12 to i64
  br label %20

._crit_edge:                                      ; preds = %20, %4
  ret void

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = trunc nuw i64 %indvars.iv to i32
  %22 = mul i32 %8, %21
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds %"struct.Ani::Expr", ptr %3, i64 %23
  %25 = tail call noundef ptr @_ZSt4copyIPN3Ani4ExprES2_ET0_T_S4_S3_(ptr noundef %3, ptr noundef %19, ptr noundef %24)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %20, !llvm.loop !17
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt4copyIPN3Ani4ExprES2_ET0_T_S4_S3_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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 #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 = { 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 = !{!"_ZTSN3Ani4DofT12VectorDofMapE", !7, i64 0, !8, i64 8, !14, i64 24}
!7 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!8 = !{!"_ZTSSt10shared_ptrIN3Ani4DofT10BaseDofMapEE", !9, i64 0}
!9 = !{!"_ZTSSt12__shared_ptrIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2EE", !10, i64 0, !13, i64 8}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !10, i64 0}
!14 = !{!"int", !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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