; 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::TetOrder" = type { i32 }
%"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 uwtable
declare dso_local i64 @_ZNK3Ani4DofT10LocalOrder12getGeomOrderEv(ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Ani4DofT16NestedDofMapBase18isValidOutputIndexENS0_10LocalOrderE(ptr noundef nonnull align 8 dereferenceable(36) %0, i64 %1, i32 %2) #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca %"struct.Ani::DofT::LocalOrder", align 4
  %6 = alloca { i64, i32 }, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %"struct.Ani::DofT::TetOrder", align 4
  %9 = alloca %"struct.Ani::DofT::LocGeomOrder", align 4
  %10 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 0
  store i64 %1, ptr %10, align 4
  %11 = getelementptr inbounds { i64, i32 }, ptr %6, i32 0, i32 1
  store i32 %2, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %6, i64 12, i1 false)
  store ptr %0, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8
  %13 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %5, i32 0, i32 2
  %14 = load i8, ptr %13, align 4, !tbaa !9
  %15 = zext i8 %14 to i32
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %21, label %17

17:                                               ; preds = %3
  %18 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %5, i32 0, i32 2
  %19 = load i8, ptr %18, align 4, !tbaa !9
  %20 = call noundef zeroext i1 @_ZN3Ani4DofT15GeomTypeIsValidEh(i8 noundef zeroext %19)
  br i1 %20, label %22, label %21

21:                                               ; preds = %17, %3
  store i1 false, ptr %4, align 1
  br label %57

22:                                               ; preds = %17
  %23 = getelementptr inbounds %"struct.Ani::DofT::NestedDofMapBase", ptr %12, i32 0, i32 2
  %24 = load i32, ptr %23, align 8, !tbaa !12
  %25 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %5, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = sub i32 %26, %24
  store i32 %27, ptr %25, align 4, !tbaa !16
  %28 = load ptr, ptr %12, align 8, !tbaa !17
  %29 = getelementptr inbounds ptr, ptr %28, i64 22
  %30 = load ptr, ptr %29, align 8
  %31 = call noundef ptr %30(ptr noundef nonnull align 8 dereferenceable(36) %12)
  %32 = call i32 @_ZNK3Ani4DofT10LocalOrder11getTetOrderEv(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %33 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %8, i32 0, i32 0
  store i32 %32, ptr %33, align 4
  %34 = getelementptr inbounds %"struct.Ani::DofT::TetOrder", ptr %8, i32 0, i32 0
  %35 = load i32, ptr %34, align 4
  %36 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8) %31, i32 %35)
  br i1 %36, label %38, label %37

37:                                               ; preds = %22
  store i1 false, ptr %4, align 1
  br label %57

38:                                               ; preds = %22
  %39 = getelementptr inbounds %"struct.Ani::DofT::NestedDofMapBase", ptr %12, i32 0, i32 1
  %40 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %5, i32 0, i32 2
  %41 = load i8, ptr %40, align 4, !tbaa !9
  %42 = call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %41)
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %39, i64 noundef %43) #5
  %45 = load i32, ptr %44, align 4, !tbaa !19
  %46 = getelementptr inbounds %"struct.Ani::DofT::LocalOrder", ptr %5, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !20
  %48 = sub i32 %47, %45
  store i32 %48, ptr %46, align 4, !tbaa !20
  %49 = load ptr, ptr %12, align 8, !tbaa !17
  %50 = getelementptr inbounds ptr, ptr %49, i64 22
  %51 = load ptr, ptr %50, align 8
  %52 = call noundef ptr %51(ptr noundef nonnull align 8 dereferenceable(36) %12)
  %53 = call i64 @_ZNK3Ani4DofT10LocalOrder12getGeomOrderEv(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %54 = trunc i64 %53 to i48
  store i48 %54, ptr %9, align 4
  %55 = load i64, ptr %9, align 4
  %56 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8) %52, i64 %55)
  store i1 %56, ptr %4, align 1
  br label %57

57:                                               ; preds = %38, %37, %21
  %58 = load i1, ptr %4, align 1
  ret i1 %58
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3Ani4DofT15GeomTypeIsValidEh(i8 noundef zeroext) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK3Ani4DofT10LocalOrder11getTetOrderEv(ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; 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) #4 align 2

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


; 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::LocalOrder" = type { i32, i32, i8, i8, i8, i8 }

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_ZNK3Ani4DofT10LocalOrder12getGeomOrderEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8), i32) local_unnamed_addr #0 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 #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK3Ani4DofT16NestedDofMapBase18isValidOutputIndexENS0_10LocalOrderE(ptr noundef nonnull align 8 dereferenceable(36) %0, i64 %1, i32 %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"struct.Ani::DofT::LocalOrder", align 8
  store i64 %1, ptr %4, align 8
  %.sroa.23.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %2, ptr %.sroa.23.0..sroa_idx, align 8
  %5 = trunc i32 %2 to i8
  %6 = icmp eq i8 %5, 0
  %7 = trunc i64 %1 to i32
  br i1 %6, label %36, label %8

8:                                                ; preds = %3
  %9 = tail call noundef zeroext i1 @_ZN3Ani4DofT15GeomTypeIsValidEh(i8 noundef zeroext %5)
  br i1 %9, label %10, label %36

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %13 = sub i32 %7, %12
  store i32 %13, ptr %4, align 8, !tbaa !12
  %14 = load ptr, ptr %0, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %14, i64 176
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef ptr %16(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %18 = call i32 @_ZNK3Ani4DofT10LocalOrder11getTetOrderEv(ptr noundef nonnull align 4 dereferenceable(12) %4)
  %19 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_8TetOrderE(ptr noundef nonnull align 8 dereferenceable(8) %17, i32 %18)
  br i1 %19, label %20, label %36

20:                                               ; preds = %10
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load i8, ptr %.sroa.23.0..sroa_idx, align 8, !tbaa !16
  %23 = call noundef i32 @_ZN3Ani4DofT13GeomTypeToNumEh(i8 noundef zeroext %22)
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %21, i64 noundef %24) #4
  %26 = load i32, ptr %25, align 4, !tbaa !17
  %27 = getelementptr inbounds i8, ptr %4, i64 4
  %28 = load i32, ptr %27, align 4, !tbaa !18
  %29 = sub i32 %28, %26
  store i32 %29, ptr %27, align 4, !tbaa !18
  %30 = load ptr, ptr %0, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %30, i64 176
  %32 = load ptr, ptr %31, align 8
  %33 = call noundef ptr %32(ptr noundef nonnull align 8 dereferenceable(36) %0)
  %34 = call i64 @_ZNK3Ani4DofT10LocalOrder12getGeomOrderEv(ptr noundef nonnull align 4 dereferenceable(12) %4)
  %.sroa.0.0.insert.ext = and i64 %34, 281474976710655
  %35 = call noundef zeroext i1 @_ZNK3Ani4DofT10BaseDofMap12isValidIndexENS0_12LocGeomOrderE(ptr noundef nonnull align 8 dereferenceable(8) %33, i64 %.sroa.0.0.insert.ext)
  br label %36

36:                                               ; preds = %10, %3, %8, %20
  %.0 = phi i1 [ %35, %20 ], [ false, %8 ], [ false, %3 ], [ false, %10 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN3Ani4DofT15GeomTypeIsValidEh(i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK3Ani4DofT10LocalOrder11getTetOrderEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #0 align 2

; 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 #3 align 2

attributes #0 = { 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 #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 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 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 = { 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, !11, i64 32}
!6 = !{!"_ZTSN3Ani4DofT16NestedDofMapBaseE", !7, i64 0, !8, i64 8, !11, i64 32}
!7 = !{!"_ZTSN3Ani4DofT10BaseDofMapE"}
!8 = !{!"_ZTSSt5arrayIjLm6EE", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTSN3Ani4DofT10LocalOrderE", !11, i64 0, !11, i64 4, !9, i64 8, !9, i64 9, !9, i64 10, !9, i64 11}
!14 = !{!15, !15, i64 0}
!15 = !{!"vtable pointer", !10, i64 0}
!16 = !{!13, !9, i64 8}
!17 = !{!11, !11, i64 0}
!18 = !{!13, !11, i64 4}


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