; LLVM IR from INMOST-DEV/INMOST-FEM :: anifem++/fem/tetdofmap.ll (ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_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.std::pair.4" = type <{ i32, %"struct.Ani::DofT::LocSymOrder", [2 x i8] }>
%"struct.Ani::DofT::LocSymOrder" = type { i8, i8 }
%"struct.Ani::DofT::LocGeomOrder" = type <{ i32, i8, i8, [2 x i8] }>
%"struct.Ani::DofT::UniteDofMap" = type { %"struct.Ani::DofT::BaseDofMap", %"struct.std::array.7", %"struct.std::array.7", %"struct.Ani::DofT::DofSymmetries" }
%"struct.Ani::DofT::BaseDofMap" = type { ptr }
%"struct.std::array.7" = type { [7 x i32] }
%"struct.Ani::DofT::DofSymmetries" = type { %"struct.std::array.6" }
%"struct.std::array.6" = type { [16 x i32] }

@.str.3 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_12LocGeomOrderE = external hidden unnamed_addr constant [99 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i16 @_ZNK3Ani4DofT13DofSymmetries26GetLocSymOrder_by_geom_numEhj(ptr noundef nonnull align 4 dereferenceable(64), i8 noundef zeroext, i32 noundef) #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext) #5

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(128) %0, i64 %1) unnamed_addr #6 align 2 {
  %3 = alloca %"struct.std::pair.4", align 4
  %4 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.Ani::DofT::LocSymOrder", align 1
  store i64 %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 8, i1 false), !tbaa.struct !9
  %11 = load i64, ptr %6, 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.8, ptr noundef @.str.3, i32 noundef 350, ptr noundef @__PRETTY_FUNCTION__._ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_12LocGeomOrderE) #7
  unreachable

18:                                               ; No predecessors!
  br label %19

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairIjN3Ani4DofT11LocSymOrderEEC2IRjRS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 4 dereferenceable(6), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 1 dereferenceable(2)) unnamed_addr #3 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 = { 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 #4 = { 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 #5 = { inlinehint 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 #6 = { 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 #7 = { noreturn nounwind }
attributes #8 = { 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, !7, i64 4}
!14 = !{!"_ZTSN3Ani4DofT12LocGeomOrderE", !11, i64 0, !7, i64 4, !7, i64 5}
!15 = !{!14, !7, i64 5}
!16 = !{!14, !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.std::pair.4" = type <{ i32, %"struct.Ani::DofT::LocSymOrder", [2 x i8] }>
%"struct.Ani::DofT::LocSymOrder" = type { i8, i8 }

@.str.3 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__._ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_12LocGeomOrderE = external hidden unnamed_addr constant [99 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i16 @_ZNK3Ani4DofT13DofSymmetries26GetLocSymOrder_by_geom_numEhj(ptr noundef nonnull align 4 dereferenceable(64), i8 noundef zeroext, i32 noundef) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext) local_unnamed_addr #4

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

7:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.3, i32 noundef 350, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK3Ani4DofT11UniteDofMap11TetDofIDExtENS0_12LocGeomOrderE) #6
  unreachable

8:                                                ; 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.5.0.extract.shift = lshr i64 %1, 40
  %.sroa.5.0.extract.trunc = trunc nuw nsw i64 %.sroa.5.0.extract.shift to i32
  %9 = tail call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %.sroa.4.0.extract.trunc)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %10 = getelementptr inbounds i8, ptr %0, i64 36
  %11 = zext i32 %9 to i64
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %10, i64 noundef %11) #7
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = and i32 %.sroa.5.0.extract.trunc, 255
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = add i32 %9, 1
  %17 = zext i32 %16 to i64
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %15, i64 noundef %17) #7
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %15, i64 noundef %11) #7
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = sub i32 %19, %21
  %23 = mul i32 %22, %14
  %24 = add i32 %13, %.sroa.04.0.extract.trunc
  %25 = add i32 %24, %23
  store i32 %25, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %5) #7
  %26 = getelementptr inbounds i8, ptr %0, i64 64
  %27 = trunc i32 %9 to i8
  %28 = tail call i16 @_ZNK3Ani4DofT13DofSymmetries26GetLocSymOrder_by_geom_numEhj(ptr noundef nonnull align 4 dereferenceable(64) %26, i8 noundef zeroext %27, i32 noundef %.sroa.04.0.extract.trunc)
  store i16 %28, ptr %5, align 2
  call void @_ZNSt4pairIjN3Ani4DofT11LocSymOrderEEC2IRjRS2_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS8_S9_EEEbE4typeELb1EEEOS8_OS9_(ptr noundef nonnull align 4 dereferenceable(6) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 1 dereferenceable(2) %5)
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %29 = load i64, ptr %3, align 8
  ret i64 %29
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { inlinehint 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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