; LLVM IR from SourangshuGhosh/Fluid-Simulation-for-Computer-Graphics :: src (macvelocityfield)

; 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.2, i32, double }
%class.Array3d.2 = type { i32, i32, i32, ptr, i8, i8, i32 }
%class.MACVelocityField = type <{ float, i32, i32, i32, double, %class.Array3d, %class.Array3d, %class.Array3d, i32, [4 x i8] }>
%class.Array3d = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], float, i32, [4 x i8] }>

; 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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MACVelocityField25_updateExtrapolationLayerEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), i32 noundef, ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(36)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16MACVelocityField26_updateExtrapolationLayersER17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(36) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %56, %3
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.FluidMaterialGrid, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp slt i32 %14, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %59

20:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %52, %20
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %class.FluidMaterialGrid, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !18
  %26 = icmp slt i32 %22, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %21
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %55

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %48, %28
  %30 = load i32, ptr %10, align 4, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %class.FluidMaterialGrid, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !19
  %34 = icmp slt i32 %30, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %29
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %51

36:                                               ; preds = %29
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = load i32, ptr %9, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellFluidEiii(ptr noundef nonnull align 8 dereferenceable(88) %37, i32 noundef %38, i32 noundef %39, i32 noundef %40)
  br i1 %41, label %42, label %47

42:                                               ; preds = %36
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !9
  call void @_ZN7Array3dIiE3setEiiii(ptr noundef nonnull align 8 dereferenceable(36) %43, i32 noundef %44, i32 noundef %45, i32 noundef %46, i32 noundef 0)
  br label %47

47:                                               ; preds = %42, %36
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %10, align 4, !tbaa !9
  br label %29, !llvm.loop !20

51:                                               ; preds = %35
  br label %52

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

55:                                               ; preds = %27
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !9
  br label %13, !llvm.loop !23

59:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %70, %59
  %61 = load i32, ptr %11, align 4, !tbaa !9
  %62 = getelementptr inbounds %class.MACVelocityField, ptr %12, i32 0, i32 8
  %63 = load i32, ptr %62, align 8, !tbaa !24
  %64 = icmp sle i32 %61, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %73

66:                                               ; preds = %60
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN16MACVelocityField25_updateExtrapolationLayerEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %12, i32 noundef %67, ptr noundef nonnull align 8 dereferenceable(88) %68, ptr noundef nonnull align 8 dereferenceable(36) %69)
  br label %70

70:                                               ; preds = %66
  %71 = load i32, ptr %11, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %11, align 4, !tbaa !9
  br label %60, !llvm.loop !28

73:                                               ; preds = %65
  ret void
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIiE3setEiiii(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { "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, !10, i64 8}
!12 = !{!"_ZTS17FluidMaterialGrid", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16}
!13 = !{!"_ZTS17SubdividedArray3dI8MaterialE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !14, i64 24, !10, i64 56, !17, i64 64}
!14 = !{!"_ZTS7Array3dI8MaterialE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !15, i64 24, !16, i64 25, !10, i64 28}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTS8Material", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!12, !10, i64 4}
!19 = !{!12, !10, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}
!24 = !{!25, !10, i64 144}
!25 = !{!"_ZTS16MACVelocityField", !26, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !17, i64 16, !27, i64 24, !27, i64 64, !27, i64 104, !10, i64 144}
!26 = !{!"float", !7, i64 0}
!27 = !{!"_ZTS7Array3dIfE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !15, i64 24, !26, i64 28, !10, i64 32}
!28 = distinct !{!28, !21}


; 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 void @_ZN16MACVelocityField25_updateExtrapolationLayerEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), i32 noundef, ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16MACVelocityField26_updateExtrapolationLayersER17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(36) %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader26.lr.ph, label %.preheader

.preheader26.lr.ph:                               ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !16
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.preheader26, label %.preheader

.preheader26:                                     ; preds = %.preheader26.lr.ph, %._crit_edge29
  %10 = phi i32 [ %21, %._crit_edge29 ], [ %5, %.preheader26.lr.ph ]
  %11 = phi i32 [ %22, %._crit_edge29 ], [ %8, %.preheader26.lr.ph ]
  %12 = phi i32 [ %23, %._crit_edge29 ], [ %8, %.preheader26.lr.ph ]
  %.02430 = phi i32 [ %24, %._crit_edge29 ], [ 0, %.preheader26.lr.ph ]
  %13 = icmp sgt i32 %12, 0
  %14 = load i32, ptr %1, align 8
  %15 = icmp sgt i32 %14, 0
  %or.cond = select i1 %13, i1 %15, i1 false
  br i1 %or.cond, label %.preheader25, label %._crit_edge29

.preheader:                                       ; preds = %._crit_edge29, %.preheader26.lr.ph, %3
  %16 = getelementptr inbounds i8, ptr %0, i64 144
  %17 = load i32, ptr %16, align 8, !tbaa !17
  %.not32 = icmp slt i32 %17, 1
  br i1 %.not32, label %._crit_edge35, label %.lr.ph34

.preheader25:                                     ; preds = %.preheader26, %._crit_edge
  %18 = phi i32 [ %26, %._crit_edge ], [ %11, %.preheader26 ]
  %19 = phi i32 [ %27, %._crit_edge ], [ %14, %.preheader26 ]
  %.02328 = phi i32 [ %28, %._crit_edge ], [ 0, %.preheader26 ]
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

._crit_edge29.loopexit:                           ; preds = %._crit_edge
  %.pre38 = load i32, ptr %4, align 8, !tbaa !5
  br label %._crit_edge29

._crit_edge29:                                    ; preds = %._crit_edge29.loopexit, %.preheader26
  %21 = phi i32 [ %.pre38, %._crit_edge29.loopexit ], [ %10, %.preheader26 ]
  %22 = phi i32 [ %26, %._crit_edge29.loopexit ], [ %11, %.preheader26 ]
  %23 = phi i32 [ %26, %._crit_edge29.loopexit ], [ %12, %.preheader26 ]
  %24 = add nuw nsw i32 %.02430, 1
  %25 = icmp slt i32 %24, %21
  br i1 %25, label %.preheader26, label %.preheader, !llvm.loop !21

._crit_edge.loopexit:                             ; preds = %32
  %.pre = load i32, ptr %7, align 4, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader25
  %26 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %18, %.preheader25 ]
  %27 = phi i32 [ %34, %._crit_edge.loopexit ], [ %19, %.preheader25 ]
  %28 = add nuw nsw i32 %.02328, 1
  %29 = icmp slt i32 %28, %26
  br i1 %29, label %.preheader25, label %._crit_edge29.loopexit, !llvm.loop !24

.lr.ph:                                           ; preds = %.preheader25, %32
  %.02227 = phi i32 [ %33, %32 ], [ 0, %.preheader25 ]
  %30 = tail call noundef zeroext i1 @_ZN17FluidMaterialGrid11isCellFluidEiii(ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %.02227, i32 noundef %.02328, i32 noundef %.02430)
  br i1 %30, label %31, label %32

31:                                               ; preds = %.lr.ph
  tail call void @_ZN7Array3dIiE3setEiiii(ptr noundef nonnull align 8 dereferenceable(36) %2, i32 noundef %.02227, i32 noundef %.02328, i32 noundef %.02430, i32 noundef 0)
  br label %32

32:                                               ; preds = %.lr.ph, %31
  %33 = add nuw nsw i32 %.02227, 1
  %34 = load i32, ptr %1, align 8, !tbaa !25
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !26

._crit_edge35:                                    ; preds = %.lr.ph34, %.preheader
  ret void

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %.033 = phi i32 [ %36, %.lr.ph34 ], [ 1, %.preheader ]
  tail call void @_ZN16MACVelocityField25_updateExtrapolationLayerEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.033, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(36) %2)
  %36 = add nuw nsw i32 %.033, 1
  %37 = load i32, ptr %16, align 8, !tbaa !17
  %.not.not = icmp slt i32 %.033, %37
  br i1 %.not.not, label %.lr.ph34, label %._crit_edge35, !llvm.loop !27
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Array3dIiE3setEiiii(ptr noundef nonnull align 8 dereferenceable(36), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

!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 8}
!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}
!16 = !{!6, !7, i64 4}
!17 = !{!18, !7, i64 144}
!18 = !{!"_ZTS16MACVelocityField", !19, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !15, i64 16, !20, i64 24, !20, i64 64, !20, i64 104, !7, i64 144}
!19 = !{!"float", !8, i64 0}
!20 = !{!"_ZTS7Array3dIfE", !7, i64 0, !7, i64 4, !7, i64 8, !12, i64 16, !13, i64 24, !19, i64 28, !7, i64 32}
!21 = distinct !{!21, !22, !23}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.unswitch.partial.disable"}
!24 = distinct !{!24, !22, !23}
!25 = !{!6, !7, i64 0}
!26 = distinct !{!26, !22}
!27 = distinct !{!27, !22}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass