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

; 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.PressureSolver = type { i32, i32, i32, double, double, double, i32, double, i32, ptr, ptr, ptr, ptr, %class.GridIndexKeyMap }
%class.GridIndexKeyMap = type <{ i32, i32, i32, [4 x i8], %"class.std::vector.5", i32, [4 x i8] }>
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN14PressureSolver31_getNumFluidOrAirCellNeighboursEiii(ptr noundef nonnull align 8 dereferenceable(144) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  %11 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %12 = load ptr, ptr %11, align 8, !tbaa !11
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = sub nsw i32 %13, 1
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %12, i32 noundef %14, i32 noundef %15, i32 noundef %16)
  br i1 %17, label %21, label %18

18:                                               ; preds = %4
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %9, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %18, %4
  %22 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %23, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  br i1 %28, label %32, label %29

29:                                               ; preds = %21
  %30 = load i32, ptr %9, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %9, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %29, %21
  %33 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %34 = load ptr, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load i32, ptr %7, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %34, i32 noundef %35, i32 noundef %37, i32 noundef %38)
  br i1 %39, label %43, label %40

40:                                               ; preds = %32
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %9, align 4, !tbaa !9
  br label %43

43:                                               ; preds = %40, %32
  %44 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %45 = load ptr, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %45, i32 noundef %46, i32 noundef %48, i32 noundef %49)
  br i1 %50, label %54, label %51

51:                                               ; preds = %43
  %52 = load i32, ptr %9, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %9, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %51, %43
  %55 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = sub nsw i32 %59, 1
  %61 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %56, i32 noundef %57, i32 noundef %58, i32 noundef %60)
  br i1 %61, label %65, label %62

62:                                               ; preds = %54
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %9, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %62, %54
  %66 = getelementptr inbounds %class.PressureSolver, ptr %10, i32 0, i32 10
  %67 = load ptr, ptr %66, align 8, !tbaa !11
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  %72 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %67, i32 noundef %68, i32 noundef %69, i32 noundef %71)
  br i1 %72, label %76, label %73

73:                                               ; preds = %65
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %9, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %73, %65
  %77 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %77
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { 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" }
attributes #3 = { 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, !6, i64 72}
!12 = !{!"_ZTS14PressureSolver", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !13, i64 48, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !14, i64 96}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTS15GridIndexKeyMap", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 16, !10, i64 40}
!15 = !{!"_ZTSSt6vectorIiSaIiEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


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

declare noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 7) i32 @_ZN14PressureSolver31_getNumFluidOrAirCellNeighboursEiii(ptr nocapture noundef nonnull readonly align 8 dereferenceable(144) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = add nsw i32 %1, -1
  %8 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %6, i32 noundef %7, i32 noundef %2, i32 noundef %3)
  %not. = xor i1 %8, true
  %spec.select = zext i1 %not. to i32
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = add nsw i32 %1, 1
  %11 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %9, i32 noundef %10, i32 noundef %2, i32 noundef %3)
  %12 = select i1 %8, i32 1, i32 2
  %.1 = select i1 %11, i32 %spec.select, i32 %12
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = add nsw i32 %2, -1
  %15 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %13, i32 noundef %1, i32 noundef %14, i32 noundef %3)
  %not.25 = xor i1 %15, true
  %16 = zext i1 %not.25 to i32
  %.2 = add nuw nsw i32 %.1, %16
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = add nsw i32 %2, 1
  %19 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %17, i32 noundef %1, i32 noundef %18, i32 noundef %3)
  %not.26 = xor i1 %19, true
  %20 = zext i1 %not.26 to i32
  %.3 = add nuw nsw i32 %.2, %20
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = add nsw i32 %3, -1
  %23 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %21, i32 noundef %1, i32 noundef %2, i32 noundef %22)
  %not.27 = xor i1 %23, true
  %24 = zext i1 %not.27 to i32
  %.4 = add nuw nsw i32 %.3, %24
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = add nsw i32 %3, 1
  %27 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellSolidEiii(ptr noundef nonnull align 8 dereferenceable(88) %25, i32 noundef %1, i32 noundef %2, i32 noundef %26)
  %not.28 = xor i1 %27, true
  %28 = zext i1 %not.28 to i32
  %.5 = add nuw nsw i32 %.4, %28
  ret i32 %.5
}

attributes #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 = { 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, !11, i64 72}
!6 = !{!"_ZTS14PressureSolver", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !10, i64 48, !7, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !12, i64 96}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"_ZTS15GridIndexKeyMap", !7, i64 0, !7, i64 4, !7, i64 8, !13, i64 16, !7, i64 40}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}


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