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

; 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.std::array.2" = type { [6 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
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT10BaseDofMap11NumDofOnTetEh(ptr noundef nonnull align 8 dereferenceable(8) %0, i8 noundef zeroext %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca %"struct.std::array.2", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #4
  %9 = load ptr, ptr %8, align 8, !tbaa !10
  %10 = getelementptr inbounds ptr, ptr %9, i64 5
  %11 = load ptr, ptr %10, align 8
  call void %11(ptr dead_on_unwind writable sret(%"struct.std::array.2") align 4 %5, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !12
  br label %12

12:                                               ; preds = %32, %2
  %13 = load i32, ptr %7, align 4, !tbaa !12
  %14 = icmp ult i32 %13, 6
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %35

16:                                               ; preds = %12
  %17 = load i8, ptr %4, align 1, !tbaa !9
  %18 = zext i8 %17 to i32
  %19 = load i32, ptr %7, align 4, !tbaa !12
  %20 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef %19)
  %21 = zext i8 %20 to i32
  %22 = and i32 %18, %21
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %31

24:                                               ; preds = %16
  %25 = load i32, ptr %7, align 4, !tbaa !12
  %26 = zext i32 %25 to i64
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %5, i64 noundef %26) #4
  %28 = load i32, ptr %27, align 4, !tbaa !12
  %29 = load i32, ptr %6, align 4, !tbaa !12
  %30 = add i32 %29, %28
  store i32 %30, ptr %6, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %24, %16
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %7, align 4, !tbaa !12
  %34 = add i32 %33, 1
  store i32 %34, ptr %7, align 4, !tbaa !12
  br label %12, !llvm.loop !14

35:                                               ; preds = %15
  %36 = load i32, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #4
  ret i32 %36
}

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

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 = { 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 = { 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 #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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"vtable pointer", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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"

%"struct.std::array.2" = type { [6 x i32] }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK3Ani4DofT10BaseDofMap11NumDofOnTetEh(ptr noundef nonnull align 8 dereferenceable(8) %0, i8 noundef zeroext %1) unnamed_addr #2 align 2 {
  %3 = alloca %"struct.std::array.2", align 4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #4
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 40
  %6 = load ptr, ptr %5, align 8
  call void %6(ptr dead_on_unwind nonnull writable sret(%"struct.std::array.2") align 4 %3, ptr noundef nonnull align 8 dereferenceable(8) %0)
  %7 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 0)
  %8 = and i8 %7, %1
  %.not = icmp eq i8 %8, 0
  br i1 %.not, label %12, label %9

9:                                                ; preds = %2
  %10 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 0) #4
  %11 = load i32, ptr %10, align 4, !tbaa !8
  br label %12

12:                                               ; preds = %2, %9
  %.1 = phi i32 [ %11, %9 ], [ 0, %2 ]
  %13 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 1)
  %14 = and i8 %13, %1
  %.not.1 = icmp eq i8 %14, 0
  br i1 %.not.1, label %19, label %15

15:                                               ; preds = %12
  %16 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 1) #4
  %17 = load i32, ptr %16, align 4, !tbaa !8
  %18 = add i32 %17, %.1
  br label %19

19:                                               ; preds = %15, %12
  %.1.1 = phi i32 [ %18, %15 ], [ %.1, %12 ]
  %20 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 2)
  %21 = and i8 %20, %1
  %.not.2 = icmp eq i8 %21, 0
  br i1 %.not.2, label %26, label %22

22:                                               ; preds = %19
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 2) #4
  %24 = load i32, ptr %23, align 4, !tbaa !8
  %25 = add i32 %24, %.1.1
  br label %26

26:                                               ; preds = %22, %19
  %.1.2 = phi i32 [ %25, %22 ], [ %.1.1, %19 ]
  %27 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 3)
  %28 = and i8 %27, %1
  %.not.3 = icmp eq i8 %28, 0
  br i1 %.not.3, label %33, label %29

29:                                               ; preds = %26
  %30 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 3) #4
  %31 = load i32, ptr %30, align 4, !tbaa !8
  %32 = add i32 %31, %.1.2
  br label %33

33:                                               ; preds = %29, %26
  %.1.3 = phi i32 [ %32, %29 ], [ %.1.2, %26 ]
  %34 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 4)
  %35 = and i8 %34, %1
  %.not.4 = icmp eq i8 %35, 0
  br i1 %.not.4, label %40, label %36

36:                                               ; preds = %33
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 4) #4
  %38 = load i32, ptr %37, align 4, !tbaa !8
  %39 = add i32 %38, %.1.3
  br label %40

40:                                               ; preds = %36, %33
  %.1.4 = phi i32 [ %39, %36 ], [ %.1.3, %33 ]
  %41 = call noundef zeroext i8 @_ZN3Ani4DofT13NumToGeomTypeEi(i32 noundef 5)
  %42 = and i8 %41, %1
  %.not.5 = icmp eq i8 %42, 0
  br i1 %.not.5, label %47, label %43

43:                                               ; preds = %40
  %44 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt5arrayIjLm6EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %3, i64 noundef 5) #4
  %45 = load i32, ptr %44, align 4, !tbaa !8
  %46 = add i32 %45, %.1.4
  br label %47

47:                                               ; preds = %43, %40
  %.1.5 = phi i32 [ %46, %43 ], [ %.1.4, %40 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #4
  ret i32 %.1.5
}

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

attributes #0 = { mustprogress 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 = { 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 = { 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 #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 = !{!"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}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass