; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src/fluidmaterialgrid.ll (ZN17FluidMaterialGrid24isFaceBorderingMaterialWEiii8Material)

; 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"

%class.FluidMaterialGrid = type { i32, i32, i32, %class.SubdividedArray3d }
%class.SubdividedArray3d = type { i32, i32, i32, i32, i32, i32, %class.Array3d, i32, double }
%class.Array3d = type { i32, i32, i32, ptr, i8, i8, i32 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef, i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN17FluidMaterialGrid24isFaceBorderingMaterialWEiii8Material(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i8 noundef signext %4) #0 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i8, align 1
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i8 %4, ptr %11, align 1, !tbaa !11
  %12 = load ptr, ptr %7, align 8
  %13 = load i32, ptr %10, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.FluidMaterialGrid, ptr %12, i32 0, i32 3
  %15 = getelementptr inbounds %class.SubdividedArray3d, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp eq i32 %13, %16
  br i1 %17, label %18, label %27

18:                                               ; preds = %5
  %19 = getelementptr inbounds %class.FluidMaterialGrid, ptr %12, i32 0, i32 3
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 1
  %24 = call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %19, i32 noundef %20, i32 noundef %21, i32 noundef %23)
  %25 = load i8, ptr %11, align 1, !tbaa !11
  %26 = icmp eq i8 %24, %25
  store i1 %26, ptr %6, align 1
  br label %57

27:                                               ; preds = %5
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = icmp sgt i32 %28, 0
  br i1 %29, label %30, label %49

30:                                               ; preds = %27
  %31 = getelementptr inbounds %class.FluidMaterialGrid, ptr %12, i32 0, i32 3
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %31, i32 noundef %32, i32 noundef %33, i32 noundef %34)
  %36 = load i8, ptr %11, align 1, !tbaa !11
  %37 = icmp eq i8 %35, %36
  br i1 %37, label %47, label %38

38:                                               ; preds = %30
  %39 = getelementptr inbounds %class.FluidMaterialGrid, ptr %12, i32 0, i32 3
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = sub nsw i32 %42, 1
  %44 = call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %39, i32 noundef %40, i32 noundef %41, i32 noundef %43)
  %45 = load i8, ptr %11, align 1, !tbaa !11
  %46 = icmp eq i8 %44, %45
  br label %47

47:                                               ; preds = %38, %30
  %48 = phi i1 [ true, %30 ], [ %46, %38 ]
  store i1 %48, ptr %6, align 1
  br label %57

49:                                               ; preds = %27
  %50 = getelementptr inbounds %class.FluidMaterialGrid, ptr %12, i32 0, i32 3
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %50, i32 noundef %51, i32 noundef %52, i32 noundef %53)
  %55 = load i8, ptr %11, align 1, !tbaa !11
  %56 = icmp eq i8 %54, %55
  store i1 %56, ptr %6, align 1
  br label %57

57:                                               ; preds = %49, %47, %18
  %58 = load i1, ptr %6, align 1
  ret i1 %58
}

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

!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 = !{!"_ZTS8Material", !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"_ZTS17FluidMaterialGrid", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 16}
!15 = !{!"_ZTS17SubdividedArray3dI8MaterialE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !16, i64 24, !10, i64 56, !18, i64 64}
!16 = !{!"_ZTS7Array3dI8MaterialE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !17, i64 24, !12, i64 25, !10, i64 28}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"double", !7, i64 0}


; 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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN17FluidMaterialGrid24isFaceBorderingMaterialWEiii8Material(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i8 noundef signext %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i32 %8, %3
  br i1 %9, label %.sink.split, label %10

10:                                               ; preds = %5
  %11 = icmp slt i32 %3, 1
  %12 = tail call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %6, i32 noundef %1, i32 noundef %2, i32 noundef %3)
  %13 = icmp eq i8 %12, %4
  %brmerge = or i1 %11, %13
  %not. = xor i1 %11, true
  %.mux = or i1 %13, %not.
  br i1 %brmerge, label %17, label %.sink.split

.sink.split:                                      ; preds = %10, %5
  %14 = add nsw i32 %3, -1
  %15 = tail call noundef signext i8 @_ZN17SubdividedArray3dI8MaterialEclEiii(ptr noundef nonnull align 8 dereferenceable(72) %6, i32 noundef %1, i32 noundef %2, i32 noundef %14)
  %16 = icmp eq i8 %15, %4
  br label %17

17:                                               ; preds = %10, %.sink.split
  %.0 = phi i1 [ %.mux, %10 ], [ %16, %.sink.split ]
  ret i1 %.0
}

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

!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, !7, i64 24}
!6 = !{!"_ZTS17FluidMaterialGrid", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS17SubdividedArray3dI8MaterialE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !11, i64 24, !7, i64 56, !15, i64 64}
!11 = !{!"_ZTS7Array3dI8MaterialE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !13, i64 24, !14, i64 25, !7, i64 28}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTS8Material", !8, i64 0}
!15 = !{!"double", !8, i64 0}


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