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

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

@_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1
@_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds = 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 @_ZN3Ani4DofT15TetGeomSparsity9unsetFaceEib(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 2) #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 %85

20:                                               ; preds = %3
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = mul nsw i32 3, %21
  %23 = sext i32 %22 to i64
  %24 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_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 3, %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) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_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 = load i32, ptr %5, align 4, !tbaa !9
  %38 = mul nsw i32 3, %37
  %39 = add nsw i32 %38, 2
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_nds, i64 noundef %40) #1
  %42 = load i8, ptr %41, align 1, !tbaa !13
  %43 = sext i8 %42 to i32
  %44 = shl i32 1, %43
  %45 = or i32 %36, %44
  %46 = xor i32 %45, -1
  %47 = getelementptr inbounds %"struct.Ani::DofT::TetGeomSparsity", ptr %8, i32 0, i32 0
  %48 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %47, i64 noundef 0) #1
  %49 = load i8, ptr %48, align 1, !tbaa !13
  %50 = zext i8 %49 to i32
  %51 = and i32 %50, %46
  %52 = trunc i32 %51 to i8
  store i8 %52, ptr %48, align 1, !tbaa !13
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = mul nsw i32 3, %53
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %55) #1
  %57 = load i8, ptr %56, align 1, !tbaa !13
  %58 = sext i8 %57 to i32
  %59 = shl i32 1, %58
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = mul nsw i32 3, %60
  %62 = add nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %63) #1
  %65 = load i8, ptr %64, align 1, !tbaa !13
  %66 = sext i8 %65 to i32
  %67 = shl i32 1, %66
  %68 = or i32 %59, %67
  %69 = load i32, ptr %5, align 4, !tbaa !9
  %70 = mul nsw i32 3, %69
  %71 = add nsw i32 %70, 2
  %72 = sext i32 %71 to i64
  %73 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %72) #1
  %74 = load i8, ptr %73, align 1, !tbaa !13
  %75 = sext i8 %74 to i32
  %76 = shl i32 1, %75
  %77 = or i32 %68, %76
  %78 = xor i32 %77, -1
  %79 = getelementptr inbounds %"struct.Ani::DofT::TetGeomSparsity", ptr %8, i32 0, i32 0
  %80 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %79, i64 noundef 1) #1
  %81 = load i8, ptr %80, align 1, !tbaa !13
  %82 = zext i8 %81 to i32
  %83 = and i32 %82, %78
  %84 = trunc i32 %83 to i8
  store i8 %84, ptr %80, align 1, !tbaa !13
  br label %85

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

@_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1
@_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds = 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 @_ZN3Ani4DofT15TetGeomSparsity9unsetFaceEib(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 2) #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 %55

10:                                               ; preds = %3
  %11 = mul nsw i32 %1, 3
  %12 = sext i32 %11 to i64
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_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 = add nsw 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) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_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 = add nsw i32 %11, 2
  %25 = sext i32 %24 to i64
  %26 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_nds, i64 noundef %25) #1
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = zext nneg i8 %27 to i32
  %29 = shl nuw i32 1, %28
  %30 = or i32 %23, %29
  %31 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %0, i64 noundef 0) #1
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = trunc i32 %30 to i8
  %34 = xor i8 %33, -1
  %35 = and i8 %32, %34
  store i8 %35, ptr %31, align 1, !tbaa !5
  %36 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %12) #1
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = zext nneg i8 %37 to i32
  %39 = shl nuw i32 1, %38
  %40 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %18) #1
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = zext nneg i8 %41 to i32
  %43 = shl nuw i32 1, %42
  %44 = or i32 %43, %39
  %45 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt5arrayIcLm12EEixEm(ptr noundef nonnull align 1 dereferenceable(12) @_ZZN3Ani4DofT15TetGeomSparsity9unsetFaceEibE10lookup_eds, i64 noundef %25) #1
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = zext nneg i8 %46 to i32
  %48 = shl nuw i32 1, %47
  %49 = or i32 %44, %48
  %50 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm4EEixEm(ptr noundef nonnull align 1 dereferenceable(4) %0, i64 noundef 1) #1
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = trunc i32 %49 to i8
  %53 = xor i8 %52, -1
  %54 = and i8 %51, %53
  store i8 %54, ptr %50, align 1, !tbaa !5
  br label %55

55:                                               ; 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