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

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

@_ZZN3Ani4DofT15TetGeomSparsity7setFaceEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1
@_ZZN3Ani4DofT15TetGeomSparsity7setFaceEibE10lookup_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
define dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN3Ani4DofT15TetGeomSparsity7setFaceEib(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 2) #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 %82

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

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

; 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

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

@_ZZN3Ani4DofT15TetGeomSparsity7setFaceEibE10lookup_nds = external hidden constant %"struct.std::array.0", align 1
@_ZZN3Ani4DofT15TetGeomSparsity7setFaceEibE10lookup_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
define dso_local noundef nonnull align 1 dereferenceable(4) ptr @_ZN3Ani4DofT15TetGeomSparsity7setFaceEib(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 = or i8 %6, %7
  store i8 %8, ptr %5, align 1, !tbaa !5
  br i1 %2, label %9, label %52

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

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

; 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

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