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

; 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::PlainMemoryX" = type { ptr, ptr, ptr, i64, i64, i64 }
%"struct.Ani::DofT::ComponentTetOrder" = type { %"struct.Ani::DofT::TetOrder", %"struct.Ani::DofT::TetOrder", i32 }
%"struct.Ani::DofT::TetOrder" = type { i32 }
%"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 }
%"struct.Ani::ComplexFemSpace" = type <{ %"struct.Ani::BaseFemSpace", %"class.std::vector.31", i32, i32, i32, i32, %"struct.std::array.36", [4 x i8] }>
%"class.std::vector.31" = type { %"struct.std::_Vector_base.32" }
%"struct.std::_Vector_base.32" = type { %"struct.std::_Vector_base<std::shared_ptr<Ani::BaseFemSpace>, std::allocator<std::shared_ptr<Ani::BaseFemSpace>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<Ani::BaseFemSpace>, std::allocator<std::shared_ptr<Ani::BaseFemSpace>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<Ani::BaseFemSpace>, std::allocator<std::shared_ptr<Ani::BaseFemSpace>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<Ani::BaseFemSpace>, std::allocator<std::shared_ptr<Ani::BaseFemSpace>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::array.36" = type { [3 x i32] }

; 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 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; 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 void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Ani15ComplexFemSpace24interpolateOnDOF_mem_reqEiij(ptr dead_on_unwind noalias writable sret(%"struct.Ani::PlainMemoryX") align 8 %0, ptr noundef nonnull align 8 dereferenceable(76) %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #3 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.Ani::DofT::ComponentTetOrder", align 4
  %11 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %12 = alloca { i64, i32 }, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  store i32 %4, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #5
  %16 = getelementptr inbounds %"struct.Ani::BaseFemSpace", ptr %15, i32 0, i32 1
  %17 = call noundef ptr @_ZNK3Ani4DofT6DofMap6targetINS0_13ComplexDofMapEEEPKT_v(ptr noundef nonnull align 8 dereferenceable(16) %16)
  %18 = load i32, ptr %7, align 4, !tbaa !9
  call void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef %18)
  %19 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %11, i32 0, i32 0
  %20 = load i32, ptr %19, align 4
  %21 = call { i64, i32 } @_ZNK3Ani4DofT13ComplexDofMap11ComponentIDENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(344) %17, i32 %20)
  store { i64, i32 } %21, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %22 = getelementptr inbounds %"struct.Ani::DofT::ComponentTetOrder", ptr %10, i32 0, i32 1
  %23 = call noundef i32 @_ZNK3Ani4DofT8TetOrdercvjEv(ptr noundef nonnull align 4 dereferenceable(4) %22)
  store i32 %23, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %24 = load ptr, ptr %15, align 8, !tbaa !11
  %25 = getelementptr inbounds ptr, ptr %24, i64 3
  %26 = load ptr, ptr %25, align 8
  %27 = call noundef i32 %26(ptr noundef nonnull align 8 dereferenceable(76) %15)
  store i32 %27, ptr %14, align 4, !tbaa !9
  %28 = getelementptr inbounds %"struct.Ani::ComplexFemSpace", ptr %15, i32 0, i32 1
  %29 = getelementptr inbounds %"struct.Ani::DofT::ComponentTetOrder", ptr %10, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = zext i32 %30 to i64
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN3Ani12BaseFemSpaceEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %31) #5
  %33 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani12BaseFemSpaceELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %32) #5
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = load ptr, ptr %33, align 8, !tbaa !11
  %38 = getelementptr inbounds ptr, ptr %37, i64 7
  %39 = load ptr, ptr %38, align 8
  call void %39(ptr dead_on_unwind writable sret(%"struct.Ani::PlainMemoryX") align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %33, i32 noundef %34, i32 noundef %35, i32 noundef %36)
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = mul i32 %40, %41
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds %"struct.Ani::PlainMemoryX", ptr %0, i32 0, i32 3
  %45 = load i64, ptr %44, align 8, !tbaa !16
  %46 = add i64 %45, %43
  store i64 %46, ptr %44, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #5
  ret void
}

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

declare { i64, i32 } @_ZNK3Ani4DofT13ComplexDofMap11ComponentIDENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(344), i32) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN3Ani4DofT17ComponentTetOrderE", !15, i64 0, !15, i64 4, !10, i64 8}
!15 = !{!"_ZTSN3Ani4DofT8TetOrderE", !10, i64 0}
!16 = !{!17, !18, i64 24}
!17 = !{!"_ZTSN3Ani12PlainMemoryXIdiEE", !6, i64 0, !6, i64 8, !6, i64 16, !18, i64 24, !18, i64 32, !18, i64 40}
!18 = !{!"long", !7, i64 0}


; 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::PlainMemoryX" = type { ptr, ptr, ptr, i64, i64, i64 }
%"struct.Ani::DofT::ComponentTetOrder" = type { %"struct.Ani::DofT::TetOrder", %"struct.Ani::DofT::TetOrder", i32 }
%"struct.Ani::DofT::TetOrder" = type { i32 }

; 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 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 void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3Ani15ComplexFemSpace24interpolateOnDOF_mem_reqEiij(ptr dead_on_unwind noalias writable sret(%"struct.Ani::PlainMemoryX") align 8 %0, ptr noundef nonnull align 8 dereferenceable(76) %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #2 align 2 {
  %6 = alloca %"struct.Ani::DofT::ComponentTetOrder", align 8
  %7 = alloca %"struct.Ani::DofT::TetOrder", align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #4
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = tail call noundef ptr @_ZNK3Ani4DofT6DofMap6targetINS0_13ComplexDofMapEEEPKT_v(ptr noundef nonnull align 8 dereferenceable(16) %8)
  call void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef %2)
  %10 = load i32, ptr %7, align 4
  %11 = call { i64, i32 } @_ZNK3Ani4DofT13ComplexDofMap11ComponentIDENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(344) %9, i32 %10)
  %.fca.0.extract = extractvalue { i64, i32 } %11, 0
  %.fca.1.extract = extractvalue { i64, i32 } %11, 1
  store i64 %.fca.0.extract, ptr %6, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %12 = getelementptr inbounds i8, ptr %6, i64 4
  %13 = call noundef i32 @_ZNK3Ani4DofT8TetOrdercvjEv(ptr noundef nonnull align 4 dereferenceable(4) %12)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = load ptr, ptr %15, align 8
  %17 = call noundef i32 %16(ptr noundef nonnull align 8 dereferenceable(76) %1)
  %18 = getelementptr inbounds i8, ptr %1, i64 24
  %19 = load i32, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !8
  %20 = zext i32 %19 to i64
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorISt10shared_ptrIN3Ani12BaseFemSpaceEESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %20) #4
  %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 %22, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 56
  %25 = load ptr, ptr %24, align 8
  call void %25(ptr dead_on_unwind writable sret(%"struct.Ani::PlainMemoryX") align 8 %0, ptr noundef nonnull align 8 dereferenceable(24) %22, i32 noundef %13, i32 noundef %3, i32 noundef %4)
  %26 = mul i32 %17, %3
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load i64, ptr %28, align 8, !tbaa !13
  %30 = add i64 %29, %27
  store i64 %30, ptr %28, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #4
  ret void
}

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

declare { i64, i32 } @_ZNK3Ani4DofT13ComplexDofMap11ComponentIDENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(344), i32) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTSN3Ani4DofT17ComponentTetOrderE", !10, i64 0, !10, i64 4, !11, i64 8}
!10 = !{!"_ZTSN3Ani4DofT8TetOrderE", !11, i64 0}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!14, !16, i64 24}
!14 = !{!"_ZTSN3Ani12PlainMemoryXIdiEE", !15, i64 0, !15, i64 8, !15, i64 16, !16, i64 24, !16, i64 32, !16, i64 40}
!15 = !{!"any pointer", !12, i64 0}
!16 = !{!"long", !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass