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

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

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK3Ani4DofT10BaseDofMap15LocalOrderOnTetENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8), i64) #3 align 2

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, i64 4, i64 1, !14, i64 5, i64 1, !14}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !7, i64 8}
!16 = !{!"_ZTSN3Ani4DofT10LocalOrderE", !13, i64 0, !13, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11}
!17 = !{!16, !13, i64 4}
!18 = !{!19, !13, i64 32}
!19 = !{!"_ZTSN3Ani4DofT16NestedDofMapBaseE", !20, i64 0, !21, i64 8, !13, i64 32}
!20 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!21 = !{!"_ZTSSt5arrayIjLm6EE", !7, i64 0}
!22 = !{!16, !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_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(36) %0, i64 %1) local_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 = tail call { i64, i32 } @_ZNK3Ani4DofT10BaseDofMap15LocalOrderOnTetENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8) %6, i64 %1)
  %.fca.0.extract = extractvalue { i64, i32 } %7, 0
  %.fca.1.extract = extractvalue { i64, i32 } %7, 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
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = tail call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %.sroa.6.8.extract.trunc)
  %10 = sext i32 %9 to i64
  %11 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %8, i64 noundef %10) #3
  %12 = load i32, ptr %11, align 4, !tbaa !8
  %13 = add i32 %12, %.sroa.4.0.extract.trunc
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = add i32 %15, %.sroa.05.0.extract.trunc
  %.sroa.4.0.insert.ext = zext i32 %13 to i64
  %.sroa.4.0.insert.shift = shl nuw i64 %.sroa.4.0.insert.ext, 32
  %.sroa.05.0.insert.ext = zext i32 %16 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
}

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i32 } @_ZNK3Ani4DofT10BaseDofMap15LocalOrderOnTetENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8), i64) local_unnamed_addr #2 align 2

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