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

; 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.0" = type { [12 x i8] }
%"struct.Ani::DofT::TetGeomSparsity" = type { %"struct.std::array" }
%"struct.std::array" = type { [4 x i8] }

@_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN3Ani4DofT15TetGeomSparsity7setEdgeEib(ptr noundef nonnull align 1 dereferenceable(4) %0, i32 noundef %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !11
  %8 = load ptr, ptr %4, align 8
  %9 = load i32, ptr %5, align 4, !tbaa !9
  %10 = shl i32 1, %9
  %11 = getelementptr inbounds %"struct.Ani::DofT::TetGeomSparsity", ptr %8, i32 0, i32 0
  %12 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %11, i64 noundef 1) #1
  %13 = load i8, ptr %12, align 1, !tbaa !13
  %14 = zext i8 %13 to i32
  %15 = or i32 %14, %10
  %16 = trunc i32 %15 to i8
  store i8 %16, ptr %12, align 1, !tbaa !13
  %17 = load i8, ptr %6, align 1, !tbaa !11, !range !14, !noundef !15
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %42

19:                                               ; preds = %3
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = mul nsw i32 2, %20
  %22 = sext i32 %21 to i64
  %23 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds, i64 noundef %22) #1
  %24 = load i8, ptr %23, align 1, !tbaa !13
  %25 = sext i8 %24 to i32
  %26 = shl i32 1, %25
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = mul nsw i32 2, %27
  %29 = add nsw i32 %28, 1
  %30 = sext i32 %29 to i64
  %31 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds, i64 noundef %30) #1
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = sext i8 %32 to i32
  %34 = shl i32 1, %33
  %35 = or i32 %26, %34
  %36 = getelementptr inbounds %"struct.Ani::DofT::TetGeomSparsity", ptr %8, i32 0, i32 0
  %37 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %36, i64 noundef 0) #1
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = zext i8 %38 to i32
  %40 = or i32 %39, %35
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %37, align 1, !tbaa !13
  br label %42

42:                                               ; preds = %19, %3
  ret ptr %8
}

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 = !{!"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 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}


; 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.0" = type { [12 x i8] }

@_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN3Ani4DofT15TetGeomSparsity7setEdgeEib(ptr noundef nonnull returned align 1 dereferenceable(4) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = shl nuw i32 1, %1
  %5 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %0, i64 noundef 1) #1
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = trunc i32 %4 to i8
  %8 = or i8 %6, %7
  store i8 %8, ptr %5, align 1, !tbaa !5
  br i1 %2, label %9, label %27

9:                                                ; preds = %3
  %10 = shl nsw i32 %1, 1
  %11 = sext i32 %10 to i64
  %12 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds, i64 noundef %11) #1
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = zext nneg i8 %13 to i32
  %15 = shl nuw i32 1, %14
  %16 = or disjoint i32 %10, 1
  %17 = sext i32 %16 to i64
  %18 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity7setEdgeEibE10lookup_nds, i64 noundef %17) #1
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = zext nneg i8 %19 to i32
  %21 = shl nuw i32 1, %20
  %22 = or i32 %21, %15
  %23 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %0, i64 noundef 0) #1
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = trunc i32 %22 to i8
  %26 = or i8 %24, %25
  store i8 %26, ptr %23, align 1, !tbaa !5
  br label %27

27:                                               ; preds = %9, %3
  ret ptr %0
}

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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass