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

; 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) #0

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

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

; Function Attrs: mustprogress uwtable
define dso_local { i64, i32 } @_ZNK3Ani4DofT16NestedDofMapBase15LocalOrderOnTetENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 %1) unnamed_addr #3 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 { i64, i32 }, align 8
  %8 = alloca { i64, i32 }, align 8
  %9 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %4, i32 0, i32 0
  store i32 %1, ptr %9, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i64 22
  %13 = load ptr, ptr %12, align 8
  %14 = call noundef ptr %13(ptr noundef nonnull align 8 dereferenceable(36) %10)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %4, i64 4, i1 false), !tbaa.struct !11
  %15 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %6, i32 0, i32 0
  %16 = load i32, ptr %15, align 4
  %17 = load ptr, ptr %14, align 8, !tbaa !9
  %18 = getelementptr inbounds ptr, ptr %17, i64 7
  %19 = load ptr, ptr %18, align 8
  %20 = call { i64, i32 } %19(ptr noundef nonnull align 8 dereferenceable(8) %14, i32 %16)
  store { i64, i32 } %20, ptr %7, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 8 %7, i64 12, i1 false)
  %21 = getelementptr inbounds %"struct.Ani::DofT::NestedDofMapBase", ptr %10, i32 0, i32 1
  %22 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %3, i32 0, i32 2
  %23 = load i8, ptr %22, align 4, !tbaa !14
  %24 = call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %23)
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %21, i64 noundef %25) #4
  %27 = load i32, ptr %26, align 4, !tbaa !12
  %28 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %3, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = add i32 %29, %27
  store i32 %30, ptr %28, align 4, !tbaa !16
  %31 = getelementptr inbounds %"struct.Ani::DofT::NestedDofMapBase", ptr %10, i32 0, i32 2
  %32 = load i32, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %3, i32 0, i32 0
  %34 = load i32, ptr %33, align 4, !tbaa !21
  %35 = add i32 %34, %32
  store i32 %35, ptr %33, align 4, !tbaa !21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 4 %3, i64 12, i1 false)
  %36 = load { i64, i32 }, ptr %8, align 8
  ret { i64, i32 } %36
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"vtable pointer", !8, i64 0}
!11 = !{i64 0, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"_ZTSN3Ani4DofT10LocalOrderE", !13, i64 0, !13, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11}
!16 = !{!15, !13, i64 4}
!17 = !{!18, !13, i64 32}
!18 = !{!"_ZTSN3Ani4DofT16NestedDofMapBaseE", !19, i64 0, !20, i64 8, !13, i64 32}
!19 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!20 = !{!"_ZTSSt5arrayIjLm6EE", !7, i64 0}
!21 = !{!15, !13, 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"

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

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

; Function Attrs: mustprogress uwtable
define dso_local { i64, i32 } @_ZNK3Ani4DofT16NestedDofMapBase15LocalOrderOnTetENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 %1) unnamed_addr #2 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 176
  %5 = load ptr, ptr %4, align 8
  %6 = tail call noundef ptr %5(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 56
  %9 = load ptr, ptr %8, align 8
  %10 = tail call { i64, i32 } %9(ptr noundef nonnull align 8 dereferenceable(8) %6, i32 %1)
  %.fca.0.extract = extractvalue { i64, i32 } %10, 0
  %.fca.1.extract = extractvalue { i64, i32 } %10, 1
  %.sroa.05.0.extract.trunc = trunc i64 %.fca.0.extract to i32
  %.sroa.4.0.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %.sroa.6.8.extract.trunc = trunc i32 %.fca.1.extract to i8
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = tail call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %.sroa.6.8.extract.trunc)
  %13 = sext i32 %12 to i64
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %11, i64 noundef %13) #3
  %15 = load i32, ptr %14, align 4, !tbaa !8
  %16 = add i32 %15, %.sroa.4.0.extract.trunc
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = add i32 %18, %.sroa.05.0.extract.trunc
  %.sroa.4.0.insert.ext = zext i32 %16 to i64
  %.sroa.4.0.insert.shift = shl nuw i64 %.sroa.4.0.insert.ext, 32
  %.sroa.05.0.insert.ext = zext i32 %19 to i64
  %.sroa.05.0.insert.insert = or disjoint i64 %.sroa.4.0.insert.shift, %.sroa.05.0.insert.ext
  %.fca.0.insert = insertvalue { i64, i32 } poison, i64 %.sroa.05.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 = { 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 #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, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !9, i64 32}
!12 = !{!"_ZTSN3Ani4DofT16NestedDofMapBaseE", !13, i64 0, !14, i64 8, !9, i64 32}
!13 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!14 = !{!"_ZTSSt5arrayIjLm6EE", !10, i64 0}


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