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

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

@_ZZN3Ani4DofT15TetGeomSparsity9unsetEdgeEibE10lookup_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 @_ZN3Ani4DofT15TetGeomSparsity9unsetEdgeEib(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 = xor i32 %10, -1
  %12 = getelementptr inbounds %"struct.Ani::DofT::TetGeomSparsity", ptr %8, i32 0, i32 0
  %13 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %12, i64 noundef 1) #1
  %14 = load i8, ptr %13, align 1, !tbaa !13
  %15 = zext i8 %14 to i32
  %16 = and i32 %15, %11
  %17 = trunc i32 %16 to i8
  store i8 %17, ptr %13, align 1, !tbaa !13
  %18 = load i8, ptr %6, align 1, !tbaa !11, !range !14, !noundef !15
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %44

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

44:                                               ; preds = %20, %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] }

@_ZZN3Ani4DofT15TetGeomSparsity9unsetEdgeEibE10lookup_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 @_ZN3Ani4DofT15TetGeomSparsity9unsetEdgeEib(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 = xor i8 %7, -1
  %9 = and i8 %6, %8
  store i8 %9, ptr %5, align 1, !tbaa !5
  br i1 %2, label %10, label %29

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

29:                                               ; preds = %10, %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