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

; 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::LocalOrder" = type { i32, i32, i8, i8, i8, i8 }
%"struct.Ani::DofT::TetOrder" = type { i32 }
%"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__._ZNK3Ani4DofT12VectorDofMap15LocalOrderOnTetENS0_8TetOrderE = external hidden unnamed_addr constant [82 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_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8), i32) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) unnamed_addr #4 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 { i64, i32 } @_ZNK3Ani4DofT12VectorDofMap15LocalOrderOnTetENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 %1) unnamed_addr #5 align 2 {
  %3 = alloca %"struct.Ani::DofT::LocalOrder", align 4
  %4 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %9 = alloca { i64, i32 }, align 8
  %10 = alloca { i64, i32 }, align 8
  %11 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %4, i32 0, i32 0
  store i32 %1, ptr %11, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 4, i1 false), !tbaa.struct !9
  %13 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %6, i32 0, i32 0
  %14 = load i32, ptr %13, align 4
  %15 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 %14)
  br i1 %15, label %16, label %17

16:                                               ; preds = %2
  br label %17

17:                                               ; preds = %16, %2
  %18 = phi i1 [ false, %2 ], [ true, %16 ]
  br i1 %18, label %19, label %20

19:                                               ; preds = %17
  br label %22

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

21:                                               ; No predecessors!
  br label %22

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

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}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"vtable pointer", !8, i64 0}
!14 = !{!15, !11, i64 0}
!15 = !{!"_ZTSN3Ani4DofT8TetOrderE", !11, i64 0}
!16 = !{!17, !7, i64 8}
!17 = !{!"_ZTSN3Ani4DofT10LocalOrderE", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11}
!18 = !{!17, !11, i64 4}
!19 = !{!17, !11, 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::DofT::TetOrder" = type { i32 }

@.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__._ZNK3Ani4DofT12VectorDofMap15LocalOrderOnTetENS0_8TetOrderE = external hidden unnamed_addr constant [82 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_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8), i32) 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 #2 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 { i64, i32 } @_ZNK3Ani4DofT12VectorDofMap15LocalOrderOnTetENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 %1) unnamed_addr #3 align 2 {
  %3 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %4 = tail call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 %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 434, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3Ani4DofT12VectorDofMap15LocalOrderOnTetENS0_8TetOrderE) #4
  unreachable

6:                                                ; preds = %2
  %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 = urem i32 %1, %12
  call void @_ZN3Ani4DofT8TetOrderC2Ej(ptr noundef nonnull align 4 dereferenceable(4) %3, i32 noundef %14)
  %15 = load i32, ptr %3, align 4
  %16 = load ptr, ptr %13, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %16, i64 56
  %18 = load ptr, ptr %17, align 8
  %19 = call { i64, i32 } %18(ptr noundef nonnull align 8 dereferenceable(8) %13, i32 %15)
  %.fca.0.extract = extractvalue { i64, i32 } %19, 0
  %.fca.1.extract = extractvalue { i64, i32 } %19, 1
  %.sroa.3.0.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.3.0.extract.trunc = trunc nuw i64 %.sroa.3.0.extract.shift to i32
  %.sroa.5.8.extract.trunc = trunc i32 %.fca.1.extract to i8
  %20 = udiv i32 %1, %12
  %21 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN3Ani4DofT10BaseDofMapELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %7) #5
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8
  %25 = call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(8) %21, i8 noundef zeroext %.sroa.5.8.extract.trunc)
  %26 = mul i32 %25, %20
  %27 = add i32 %26, %.sroa.3.0.extract.trunc
  %.sroa.3.0.insert.ext = zext i32 %27 to i64
  %.sroa.3.0.insert.shift = shl nuw i64 %.sroa.3.0.insert.ext, 32
  %.sroa.09.0.insert.ext = zext i32 %1 to i64
  %.sroa.09.0.insert.insert = or disjoint i64 %.sroa.3.0.insert.shift, %.sroa.09.0.insert.ext
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.09.0.insert.insert, 0
  %.fca.1.insert = insertvalue { i64, i32 } %.fca.0.insert, i32 %.fca.1.extract, 1
  ret { i64, i32 } %.fca.1.insert
}

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,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass