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

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT11UniteDofMap11NumDofOnTetEh(ptr noundef nonnull align 8 dereferenceable(128) %0, i8 noundef zeroext %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !10
  br label %8

8:                                                ; preds = %35, %2
  %9 = load i32, ptr %6, align 4, !tbaa !10
  %10 = icmp slt i32 %9, 6
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %38

12:                                               ; preds = %8
  %13 = load i8, ptr %4, align 1, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = load i32, ptr %6, align 4, !tbaa !10
  %16 = shl i32 1, %15
  %17 = and i32 %14, %16
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %34

19:                                               ; preds = %12
  %20 = getelementptr inbounds %"struct.Ani::DofT::UniteDofMap", ptr %7, i32 0, i32 2
  %21 = load i32, ptr %6, align 4, !tbaa !10
  %22 = add nsw i32 %21, 1
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %20, i64 noundef %23) #2
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = getelementptr inbounds %"struct.Ani::DofT::UniteDofMap", ptr %7, i32 0, i32 2
  %27 = load i32, ptr %6, align 4, !tbaa !10
  %28 = sext i32 %27 to i64
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %26, i64 noundef %28) #2
  %30 = load i32, ptr %29, align 4, !tbaa !10
  %31 = sub i32 %25, %30
  %32 = load i32, ptr %5, align 4, !tbaa !10
  %33 = add i32 %32, %31
  store i32 %33, ptr %5, align 4, !tbaa !10
  br label %34

34:                                               ; preds = %19, %12
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %6, align 4, !tbaa !10
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %6, align 4, !tbaa !10
  br label %8, !llvm.loop !12

38:                                               ; preds = %11
  %39 = load i32, ptr %5, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %39
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT11UniteDofMap11NumDofOnTetEh(ptr noundef nonnull align 8 dereferenceable(128) %0, i8 noundef zeroext %1) unnamed_addr #0 align 2 {
  %3 = zext i8 %1 to i32
  %4 = getelementptr inbounds i8, ptr %0, i64 36
  %5 = and i32 %3, 1
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %12, label %6

6:                                                ; preds = %2
  %7 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 1) #1
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 0) #1
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = sub i32 %8, %10
  br label %12

12:                                               ; preds = %2, %6
  %.1 = phi i32 [ %11, %6 ], [ 0, %2 ]
  %13 = and i32 %3, 2
  %.not.1 = icmp eq i32 %13, 0
  br i1 %.not.1, label %21, label %14

14:                                               ; preds = %12
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 2) #1
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 1) #1
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = add i32 %16, %.1
  %20 = sub i32 %19, %18
  br label %21

21:                                               ; preds = %14, %12
  %.1.1 = phi i32 [ %20, %14 ], [ %.1, %12 ]
  %22 = and i32 %3, 4
  %.not.2 = icmp eq i32 %22, 0
  br i1 %.not.2, label %30, label %23

23:                                               ; preds = %21
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 3) #1
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 2) #1
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = add i32 %25, %.1.1
  %29 = sub i32 %28, %27
  br label %30

30:                                               ; preds = %23, %21
  %.1.2 = phi i32 [ %29, %23 ], [ %.1.1, %21 ]
  %31 = and i32 %3, 8
  %.not.3 = icmp eq i32 %31, 0
  br i1 %.not.3, label %39, label %32

32:                                               ; preds = %30
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 4) #1
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 3) #1
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = add i32 %34, %.1.2
  %38 = sub i32 %37, %36
  br label %39

39:                                               ; preds = %32, %30
  %.1.3 = phi i32 [ %38, %32 ], [ %.1.2, %30 ]
  %40 = and i32 %3, 16
  %.not.4 = icmp eq i32 %40, 0
  br i1 %.not.4, label %48, label %41

41:                                               ; preds = %39
  %42 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 5) #1
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 4) #1
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add i32 %43, %.1.3
  %47 = sub i32 %46, %45
  br label %48

48:                                               ; preds = %41, %39
  %.1.4 = phi i32 [ %47, %41 ], [ %.1.3, %39 ]
  %49 = and i32 %3, 32
  %.not.5 = icmp eq i32 %49, 0
  br i1 %.not.5, label %57, label %50

50:                                               ; preds = %48
  %51 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 6) #1
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIjLm7EEixEm(ptr noundef nonnull align 4 dereferenceable(28) %4, i64 noundef 5) #1
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add i32 %52, %.1.4
  %56 = sub i32 %55, %54
  br label %57

57:                                               ; preds = %50, %48
  %.1.5 = phi i32 [ %56, %50 ], [ %.1.4, %48 ]
  ret i32 %.1.5
}

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

attributes #0 = { 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 = { 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,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass