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

; 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::ArrayView" = type { ptr, i64 }
%"struct.Ani::PlainMemoryX" = type { ptr, ptr, ptr, i64, i64, i64 }
%"struct.Ani::DynMem<>::MemPart" = type { %"struct.Ani::PlainMemoryX", ptr, i64, i64 }

; 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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #2 align 2

; 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
define dso_local void @_ZNK3Ani12BaseFemSpace17interpolateByDOFsERKNS_5TetraIKdEERKPFiRKSt5arrayIdLm3EEPdjPvENS_9ArrayViewIdEERKNS_4DofT15TetGeomSparsityERNS_6DynMemIdiEESB_j(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr %3, i64 %4, ptr noundef nonnull align 1 dereferenceable(4) %5, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef %7, i32 noundef %8) #3 align 2 personality ptr @__gxx_personality_v0 {
  %10 = alloca %"struct.Ani::ArrayView", align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca %"struct.Ani::PlainMemoryX", align 8
  %19 = alloca %"struct.Ani::DynMem<>::MemPart", align 8
  %20 = alloca %"struct.Ani::ArrayView", align 8
  %21 = alloca %"struct.Ani::PlainMemoryX", align 8
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 0
  store ptr %3, ptr %24, align 8
  %25 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 1
  store i64 %4, ptr %25, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  store i32 %8, ptr %17, align 4, !tbaa !9
  %26 = load ptr, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %18) #4
  %27 = load i32, ptr %17, align 4, !tbaa !9
  %28 = load ptr, ptr %26, align 8, !tbaa !11
  %29 = getelementptr inbounds ptr, ptr %28, i64 22
  %30 = load ptr, ptr %29, align 8
  call void %30(ptr dead_on_unwind writable sret(%"struct.Ani::PlainMemoryX") align 8 %18, ptr noundef nonnull align 8 dereferenceable(24) %26, i32 noundef %27)
  call void @llvm.lifetime.start.p0(i64 72, ptr %19) #4
  %31 = load ptr, ptr %15, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.Ani::PlainMemoryX", ptr %18, i32 0, i32 3
  %33 = load i64, ptr %32, align 8, !tbaa !13
  %34 = getelementptr inbounds %"struct.Ani::PlainMemoryX", ptr %18, i32 0, i32 4
  %35 = load i64, ptr %34, align 8, !tbaa !16
  %36 = getelementptr inbounds %"struct.Ani::PlainMemoryX", ptr %18, i32 0, i32 5
  %37 = load i64, ptr %36, align 8, !tbaa !17
  %38 = load ptr, ptr %31, align 8, !tbaa !11
  %39 = getelementptr inbounds ptr, ptr %38, i64 0
  %40 = load ptr, ptr %39, align 8
  call void %40(ptr dead_on_unwind writable sret(%"struct.Ani::DynMem<>::MemPart") align 8 %19, ptr noundef nonnull align 8 dereferenceable(32) %31, i64 noundef %33, i64 noundef %35, i64 noundef %37)
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %20, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !18
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.Ani::DynMem<>::MemPart", ptr %19, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %44, i64 48, i1 false), !tbaa.struct !20
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = load i32, ptr %17, align 4, !tbaa !9
  %47 = getelementptr inbounds { ptr, i64 }, ptr %20, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8
  %49 = getelementptr inbounds { ptr, i64 }, ptr %20, i32 0, i32 1
  %50 = load i64, ptr %49, align 8
  %51 = load ptr, ptr %26, align 8, !tbaa !11
  %52 = getelementptr inbounds ptr, ptr %51, i64 21
  %53 = load ptr, ptr %52, align 8
  invoke void %53(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr noundef nonnull align 8 dereferenceable(132) %41, ptr noundef nonnull align 8 dereferenceable(8) %42, ptr %48, i64 %50, ptr noundef nonnull align 1 dereferenceable(4) %43, ptr noundef byval(%"struct.Ani::PlainMemoryX") align 8 %21, ptr noundef %45, i32 noundef %46)
          to label %54 unwind label %55

54:                                               ; preds = %9
  call void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %19) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %18) #4
  ret void

55:                                               ; preds = %9
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %22, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %23, align 4
  call void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %19) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %18) #4
  br label %59

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

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 = { 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, !15, i64 24}
!14 = !{!"_ZTSN3Ani12PlainMemoryXIdiEE", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !15, i64 32, !15, i64 40}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !15, i64 32}
!17 = !{!14, !15, i64 40}
!18 = !{i64 0, i64 8, !5, i64 8, i64 8, !19}
!19 = !{!15, !15, i64 0}
!20 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !19, i64 32, i64 8, !19, i64 40, i64 8, !19}


; 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::DynMem<>::MemPart" = type { %"struct.Ani::PlainMemoryX", ptr, i64, i64 }

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #1 align 2

; 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 uwtable
define dso_local void @_ZNK3Ani12BaseFemSpace17interpolateByDOFsERKNS_5TetraIKdEERKPFiRKSt5arrayIdLm3EEPdjPvENS_9ArrayViewIdEERKNS_4DofT15TetGeomSparsityERNS_6DynMemIdiEESB_j(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr %3, i64 %4, ptr noundef nonnull align 1 dereferenceable(4) %5, ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef %7, i32 noundef %8) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %10 = alloca %"struct.Ani::PlainMemoryX", align 8
  %11 = alloca %"struct.Ani::DynMem<>::MemPart", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %10) #3
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 176
  %14 = load ptr, ptr %13, align 8
  call void %14(ptr dead_on_unwind nonnull writable sret(%"struct.Ani::PlainMemoryX") align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %0, i32 noundef %8)
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %11) #3
  %15 = getelementptr inbounds i8, ptr %10, i64 24
  %16 = load i64, ptr %15, align 8, !tbaa !8
  %17 = getelementptr inbounds i8, ptr %10, i64 32
  %18 = load i64, ptr %17, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %10, i64 40
  %20 = load i64, ptr %19, align 8, !tbaa !14
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %21, align 8
  call void %22(ptr dead_on_unwind nonnull writable sret(%"struct.Ani::DynMem<>::MemPart") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %6, i64 noundef %16, i64 noundef %18, i64 noundef %20)
  %23 = load ptr, ptr %0, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 168
  %25 = load ptr, ptr %24, align 8
  invoke void %25(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(132) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr %3, i64 %4, ptr noundef nonnull align 1 dereferenceable(4) %5, ptr noundef nonnull byval(%"struct.Ani::PlainMemoryX") align 8 %11, ptr noundef %7, i32 noundef %8)
          to label %26 unwind label %27

26:                                               ; preds = %9
  call void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %11) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %10) #3
  ret void

27:                                               ; preds = %9
  %28 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3Ani6DynMemIdiE7MemPartD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %11) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %11) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %10) #3
  resume { ptr, i32 } %28
}

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 = { 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, !12, i64 24}
!9 = !{!"_ZTSN3Ani12PlainMemoryXIdiEE", !10, i64 0, !10, i64 8, !10, i64 16, !12, i64 24, !12, i64 32, !12, i64 40}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"long", !11, i64 0}
!13 = !{!9, !12, i64 32}
!14 = !{!9, !12, i64 40}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass