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

; 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::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] }

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef) #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) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT11UniteDofMap11GetGeomMaskEv(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %33, %1
  %7 = load i32, ptr %4, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 6
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %36

10:                                               ; preds = %6
  %11 = getelementptr inbounds %"struct.Ani::DofT::UniteDofMap", ptr %5, i32 0, i32 2
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = add nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %11, i64 noundef %14) #4
  %16 = load i32, ptr %15, align 4, !tbaa !9
  %17 = getelementptr inbounds %"struct.Ani::DofT::UniteDofMap", ptr %5, i32 0, i32 2
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %17, i64 noundef %19) #4
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = sub i32 %16, %21
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %28

24:                                               ; preds = %10
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef %25)
  %27 = zext i8 %26 to i32
  br label %29

28:                                               ; preds = %10
  br label %29

29:                                               ; preds = %28, %24
  %30 = phi i32 [ %27, %24 ], [ 0, %28 ]
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = or i32 %31, %30
  store i32 %32, ptr %3, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %29
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !9
  br label %6, !llvm.loop !11

36:                                               ; preds = %9
  %37 = load i32, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 %37
}

attributes #0 = { nocallback nofree nosync 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 256) i32 @_ZNK3Ani4DofT11UniteDofMap11GetGeomMaskEv(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 36
  %3 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 1) #2
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 0) #2
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %4, %6
  br i1 %.not, label %10, label %7

7:                                                ; preds = %1
  %8 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 0)
  %9 = zext i8 %8 to i32
  br label %10

10:                                               ; preds = %1, %7
  %11 = phi i32 [ %9, %7 ], [ 0, %1 ]
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 2) #2
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 1) #2
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %13, %15
  br i1 %.not.1, label %19, label %16

16:                                               ; preds = %10
  %17 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 1)
  %18 = zext i8 %17 to i32
  br label %19

19:                                               ; preds = %16, %10
  %20 = phi i32 [ %18, %16 ], [ 0, %10 ]
  %21 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 3) #2
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 2) #2
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %.not.2 = icmp eq i32 %22, %24
  br i1 %.not.2, label %28, label %25

25:                                               ; preds = %19
  %26 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 2)
  %27 = zext i8 %26 to i32
  br label %28

28:                                               ; preds = %25, %19
  %29 = phi i32 [ %27, %25 ], [ 0, %19 ]
  %30 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 4) #2
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 3) #2
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %.not.3 = icmp eq i32 %31, %33
  br i1 %.not.3, label %37, label %34

34:                                               ; preds = %28
  %35 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 3)
  %36 = zext i8 %35 to i32
  br label %37

37:                                               ; preds = %34, %28
  %38 = phi i32 [ %36, %34 ], [ 0, %28 ]
  %39 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 5) #2
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 4) #2
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not.4 = icmp eq i32 %40, %42
  br i1 %.not.4, label %46, label %43

43:                                               ; preds = %37
  %44 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 4)
  %45 = zext i8 %44 to i32
  br label %46

46:                                               ; preds = %43, %37
  %47 = phi i32 [ %45, %43 ], [ 0, %37 ]
  %48 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 6) #2
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %2, i64 noundef 5) #2
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %.not.5 = icmp eq i32 %49, %51
  br i1 %.not.5, label %55, label %52

52:                                               ; preds = %46
  %53 = tail call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 5)
  %54 = zext i8 %53 to i32
  br label %55

55:                                               ; preds = %52, %46
  %56 = phi i32 [ %54, %52 ], [ 0, %46 ]
  %57 = or i32 %20, %11
  %58 = or i32 %29, %57
  %59 = or i32 %38, %58
  %60 = or i32 %47, %59
  %61 = or i32 %56, %60
  ret i32 %61
}

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 = { 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,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass