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

declare i32 @__gxx_personality_v0(...)

; 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 @_ZN16MACVelocityField26_updateExtrapolationLayersER17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(36)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MACVelocityField35_extrapolateVelocitiesForLayerIndexEiR17FluidMaterialGridR7Array3dIiE(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
declare dso_local void @_ZN16MACVelocityField33_resetExtrapolatedFluidVelocitiesER17FluidMaterialGrid(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 8 dereferenceable(88)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16MACVelocityField24extrapolateVelocityFieldER17FluidMaterialGridi(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %2) #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %class.Array3d.0, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = getelementptr inbounds %class.MACVelocityField, ptr %11, i32 0, i32 8
  store i32 %12, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 40, ptr %7) #3
  %14 = getelementptr inbounds %class.MACVelocityField, ptr %11, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !17
  %16 = getelementptr inbounds %class.MACVelocityField, ptr %11, i32 0, i32 2
  %17 = load i32, ptr %16, align 8, !tbaa !18
  %18 = getelementptr inbounds %class.MACVelocityField, ptr %11, i32 0, i32 3
  %19 = load i32, ptr %18, align 4, !tbaa !19
  call void @_ZN7Array3dIiEC2Eiiii(ptr noundef nonnull align 8 dereferenceable(36) %7, i32 noundef %15, i32 noundef %17, i32 noundef %19, i32 noundef -1)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN16MACVelocityField33_resetExtrapolatedFluidVelocitiesER17FluidMaterialGrid(ptr noundef nonnull align 8 dereferenceable(148) %11, ptr noundef nonnull align 8 dereferenceable(88) %20)
          to label %21 unwind label %29

21:                                               ; preds = %3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN16MACVelocityField26_updateExtrapolationLayersER17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %11, ptr noundef nonnull align 8 dereferenceable(88) %22, ptr noundef nonnull align 8 dereferenceable(36) %7)
          to label %23 unwind label %29

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

24:                                               ; preds = %37, %23
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp sle i32 %25, %26
  br i1 %27, label %33, label %28

28:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %44

29:                                               ; preds = %21, %3
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %8, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %9, align 4
  br label %45

33:                                               ; preds = %24
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  invoke void @_ZN16MACVelocityField35_extrapolateVelocitiesForLayerIndexEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %11, i32 noundef %34, ptr noundef nonnull align 8 dereferenceable(88) %35, ptr noundef nonnull align 8 dereferenceable(36) %7)
          to label %36 unwind label %40

36:                                               ; preds = %33
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %10, align 4, !tbaa !9
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %10, align 4, !tbaa !9
  br label %24, !llvm.loop !20

40:                                               ; preds = %33
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %8, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %45

44:                                               ; preds = %28
  call void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36) %7) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #3
  ret void

45:                                               ; preds = %40, %29
  call void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36) %7) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr %7) #3
  br label %46

46:                                               ; preds = %45
  %47 = load ptr, ptr %8, align 8
  %48 = load i32, ptr %9, align 4
  %49 = insertvalue { ptr, i32 } poison, ptr %47, 0
  %50 = insertvalue { ptr, i32 } %49, i32 %48, 1
  resume { ptr, i32 } %50
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #2 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 = { 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 #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 144}
!12 = !{!"_ZTS16MACVelocityField", !13, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !14, i64 16, !15, i64 24, !15, i64 64, !15, i64 104, !10, i64 144}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTS7Array3dIfE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !16, i64 24, !13, i64 28, !10, i64 32}
!16 = !{!"bool", !7, i64 0}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !10, i64 8}
!19 = !{!12, !10, i64 12}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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

%class.Array3d.0 = type <{ i32, i32, i32, [4 x i8], ptr, i8, [3 x i8], i32, i32, [4 x i8] }>

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress 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 @_ZN16MACVelocityField26_updateExtrapolationLayersER17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16MACVelocityField35_extrapolateVelocitiesForLayerIndexEiR17FluidMaterialGridR7Array3dIiE(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 #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16MACVelocityField24extrapolateVelocityFieldER17FluidMaterialGridi(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %2) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.Array3d.0, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load i32, ptr %8, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !17
  call void @_ZN7Array3dIiEC2Eiiii(ptr noundef nonnull align 8 dereferenceable(36) %4, i32 noundef %7, i32 noundef %9, i32 noundef %11, i32 noundef -1)
  invoke void @_ZN16MACVelocityField33_resetExtrapolatedFluidVelocitiesER17FluidMaterialGrid(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 8 dereferenceable(88) %1)
          to label %12 unwind label %13

12:                                               ; preds = %3
  invoke 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) %4)
          to label %.preheader unwind label %13

.preheader:                                       ; preds = %12
  %.not13 = icmp slt i32 %2, 1
  br i1 %.not13, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %15, %.preheader
  call void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36) %4) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #3
  ret void

13:                                               ; preds = %12, %3
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %19

.lr.ph:                                           ; preds = %.preheader, %15
  %.014 = phi i32 [ %16, %15 ], [ 1, %.preheader ]
  invoke void @_ZN16MACVelocityField35_extrapolateVelocitiesForLayerIndexEiR17FluidMaterialGridR7Array3dIiE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %.014, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(36) %4)
          to label %15 unwind label %17

15:                                               ; preds = %.lr.ph
  %16 = add nuw i32 %.014, 1
  %exitcond.not = icmp eq i32 %.014, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

17:                                               ; preds = %.lr.ph
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %19

19:                                               ; preds = %17, %13
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %14, %13 ]
  call void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36) %4) #3
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #3
  resume { ptr, i32 } %.pn
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7Array3dIiED2Ev(ptr noundef nonnull align 8 dereferenceable(36)) unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 #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, !10, i64 144}
!6 = !{!"_ZTS16MACVelocityField", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !12, i64 24, !12, i64 64, !12, i64 104, !10, i64 144}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!"_ZTS7Array3dIfE", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 16, !14, i64 24, !7, i64 28, !10, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !10, i64 12}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass