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

; 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::DofT::LocGeomOrder" = type <{ i32, i8, i8, [2 x i8] }>
%"struct.Ani::DofT::VectorDofMap" = type <{ %"struct.Ani::DofT::BaseDofMap", %"class.std::shared_ptr", i32, [4 x i8] }>
%"struct.Ani::DofT::BaseDofMap" = type { 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 }

@.str.3 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE = external hidden unnamed_addr constant [67 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8), i64) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(28) %0, i64 %1) unnamed_addr #5 align 2 {
  %3 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  store i64 %1, ptr %3, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !9
  %11 = load i64, ptr %5, align 4
  %12 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8) %10, i64 %11)
  br i1 %12, label %13, label %14

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %13, %2
  %15 = phi i1 [ false, %2 ], [ true, %13 ]
  br i1 %15, label %16, label %17

16:                                               ; preds = %14
  br label %19

17:                                               ; preds = %14
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.3, i32 noundef 442, ptr noundef @__PRETTY_FUNCTION__._ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE) #6
  unreachable

18:                                               ; No predecessors!
  br label %19

19:                                               ; preds = %18, %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %20 = getelementptr inbounds %"struct.Ani::DofT::VectorDofMap", ptr %10, i32 0, i32 1
  %21 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %20) #7
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds ptr, ptr %22, i64 3
  %24 = load ptr, ptr %23, align 8
  %25 = call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(8) %21)
  store i32 %25, ptr %6, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %26 = getelementptr inbounds %"struct.Ani::DofT::VectorDofMap", ptr %10, i32 0, i32 1
  %27 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %26) #7
  %28 = getelementptr inbounds %"struct.Ani::DofT::LocGeomOrder", ptr %3, i32 0, i32 1
  %29 = load i8, ptr %28, align 4, !tbaa !15
  %30 = load ptr, ptr %27, align 8, !tbaa !13
  %31 = getelementptr inbounds ptr, ptr %30, i64 2
  %32 = load ptr, ptr %31, align 8
  %33 = call noundef i32 %32(ptr noundef nonnull align 8 dereferenceable(8) %27, i8 noundef zeroext %29)
  store i32 %33, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %34 = getelementptr inbounds %"struct.Ani::DofT::LocGeomOrder", ptr %3, i32 0, i32 0
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = load i32, ptr %7, align 4, !tbaa !10
  %37 = udiv i32 %35, %36
  store i32 %37, ptr %8, align 4, !tbaa !10
  %38 = load i32, ptr %8, align 4, !tbaa !10
  %39 = load i32, ptr %6, align 4, !tbaa !10
  %40 = mul nsw i32 %38, %39
  %41 = getelementptr inbounds %"struct.Ani::DofT::VectorDofMap", ptr %10, i32 0, i32 1
  %42 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %41) #7
  %43 = getelementptr inbounds %"struct.Ani::DofT::LocGeomOrder", ptr %3, i32 0, i32 1
  %44 = load i8, ptr %43, align 4, !tbaa !15
  %45 = getelementptr inbounds %"struct.Ani::DofT::LocGeomOrder", ptr %3, i32 0, i32 2
  %46 = load i8, ptr %45, align 1, !tbaa !18
  %47 = getelementptr inbounds %"struct.Ani::DofT::LocGeomOrder", ptr %3, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !17
  %49 = load i32, ptr %7, align 4, !tbaa !10
  %50 = urem i32 %48, %49
  call void @_ZN3Ani4DofT12LocGeomOrderC2Ehhj(ptr noundef nonnull align 4 dereferenceable(6) %9, i8 noundef zeroext %44, i8 noundef zeroext %46, i32 noundef %50)
  %51 = load i64, ptr %9, align 4
  %52 = load ptr, ptr %42, align 8, !tbaa !13
  %53 = getelementptr inbounds ptr, ptr %52, i64 9
  %54 = load ptr, ptr %53, align 8
  %55 = call noundef i32 %54(ptr noundef nonnull align 8 dereferenceable(8) %42, i64 %51)
  %56 = add i32 %40, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  ret i32 %56
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Ani4DofT12LocGeomOrderC2Ehhj(ptr noundef nonnull align 4 dereferenceable(6), i8 noundef zeroext, i8 noundef zeroext, i32 noundef) unnamed_addr #4 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 = { 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 = { noreturn nounwind }
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 = !{i64 0, i64 4, !10, i64 4, i64 1, !12, i64 5, i64 1, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !7, i64 4}
!16 = !{!"_ZTSN3Ani4DofT12LocGeomOrderE", !11, i64 0, !7, i64 4, !7, i64 5}
!17 = !{!16, !11, i64 0}
!18 = !{!16, !7, i64 5}


; 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::DofT::LocGeomOrder" = type <{ i32, i8, i8, [2 x i8] }>

@.str.3 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE = external hidden unnamed_addr constant [67 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8), i64) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(28) %0, i64 %1) unnamed_addr #3 align 2 {
  %3 = alloca %"struct.Ani::DofT::LocGeomOrder", align 8
  %4 = tail call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 %1)
  br i1 %4, label %6, label %5

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.3, i32 noundef 442, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3Ani4DofT12VectorDofMap8TetDofIDENS0_12LocGeomOrderE) #4
  unreachable

6:                                                ; preds = %2
  %.sroa.04.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.4.0.extract.shift = lshr i64 %1, 32
  %.sroa.4.0.extract.trunc = trunc i64 %.sroa.4.0.extract.shift to i8
  %.sroa.6.0.extract.shift = lshr i64 %1, 40
  %.sroa.6.0.extract.trunc = trunc i64 %.sroa.6.0.extract.shift to i8
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load ptr, ptr %10, align 8
  %12 = tail call noundef i32 %11(ptr noundef nonnull align 8 dereferenceable(8) %8)
  %13 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef i32 %16(ptr noundef nonnull align 8 dereferenceable(8) %13, i8 noundef zeroext %.sroa.4.0.extract.trunc)
  %18 = udiv i32 %.sroa.04.0.extract.trunc, %17
  %19 = mul nsw i32 %18, %12
  %20 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  %21 = urem i32 %.sroa.04.0.extract.trunc, %17
  call void @_ZN3Ani4DofT12LocGeomOrderC2Ehhj(ptr noundef nonnull align 4 dereferenceable(6) %3, i8 noundef zeroext %.sroa.4.0.extract.trunc, i8 noundef zeroext %.sroa.6.0.extract.trunc, i32 noundef %21)
  %22 = load i64, ptr %3, align 8
  %23 = load ptr, ptr %20, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %23, i64 72
  %25 = load ptr, ptr %24, align 8
  %26 = call noundef i32 %25(ptr noundef nonnull align 8 dereferenceable(8) %20, i64 %22)
  %27 = add i32 %26, %19
  ret i32 %27
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Ani4DofT12LocGeomOrderC2Ehhj(ptr noundef nonnull align 4 dereferenceable(6), i8 noundef zeroext, i8 noundef zeroext, i32 noundef) unnamed_addr #2 align 2

attributes #0 = { noreturn 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 #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 = { noreturn nounwind }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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